Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ProjectCranked</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>CombatLog</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>Utils</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>Core</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>LunarAPI</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>StorageUtilsShaded</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../StorageUtils/target/StorageUtils-1.0-shaded.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.crankedpvp.combatlog;
|
||||
|
||||
import com.lunarclient.bukkitapi.cooldown.LunarClientAPICooldown;
|
||||
import net.crankedpvp.crankedutils.events.PlayerCombatEnterEvent;
|
||||
import net.crankedpvp.combatlog.language.Language;
|
||||
import net.crankedpvp.combatlog.tasks.CombatTimer;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.WorldGuardUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class CombatTagAPI {
|
||||
public static void putPlayerInCombat(Player player) {
|
||||
if (player == null) return;
|
||||
|
||||
if (player.getAllowFlight()) {
|
||||
player.setAllowFlight(false);
|
||||
}
|
||||
if (player.isFlying()) {
|
||||
player.setFlying(false);
|
||||
}
|
||||
|
||||
LunarClientAPICooldown.sendCooldown(player, "CombatTag");
|
||||
if(!CombatTimer.playersInCombat.containsKey(player)) {
|
||||
player.sendMessage(CC.translate(Language.ENTER_COMBAT.getMessage().replace("%duration%", Language.COMBAT_DURATION.getValue())));
|
||||
Event event = new PlayerCombatEnterEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
CombatTimer.playersInCombat.put(player, 0);
|
||||
}
|
||||
|
||||
public static void removePlayerFromCombat(Player player) {
|
||||
LunarClientAPICooldown.clearCooldown(player, "CombatTag");
|
||||
CombatTimer.playersInCombat.remove(player);
|
||||
player.sendMessage(CC.translate(Language.LEFT_COMBAT.getMessage().replace("%duration%", Language.COMBAT_DURATION.getValue())));
|
||||
}
|
||||
|
||||
public static boolean isInCombat(Player player) {
|
||||
return CombatTimer.playersInCombat.containsKey(player) && WorldGuardUtils.canPvPInRegion(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.crankedpvp.combatlog;
|
||||
|
||||
import com.lunarclient.bukkitapi.cooldown.LCCooldown;
|
||||
import com.lunarclient.bukkitapi.cooldown.LunarClientAPICooldown;
|
||||
import lombok.Getter;
|
||||
import me.mattstudios.mf.base.CommandManager;
|
||||
import net.crankedpvp.combatlog.commands.AdminCombatCommand;
|
||||
import net.crankedpvp.combatlog.commands.ToggleBarCommand;
|
||||
import net.crankedpvp.combatlog.language.Language;
|
||||
import net.crankedpvp.combatlog.language.LanguageHandler;
|
||||
import net.crankedpvp.combatlog.listeners.CombatDamageListener;
|
||||
import net.crankedpvp.combatlog.listeners.CombatWhitelistedCommand;
|
||||
import net.crankedpvp.combatlog.tasks.CombatTimer;
|
||||
import net.crankedpvp.crankedutils.utils.PluginUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@Getter
|
||||
public class CombatlogPlugin extends JavaPlugin {
|
||||
@Getter
|
||||
private static CombatlogPlugin instance;
|
||||
private LanguageHandler languageHandler;
|
||||
private CommandManager commandManager;
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.languageHandler = new LanguageHandler(this);
|
||||
this.languageHandler.load();
|
||||
LunarClientAPICooldown.registerCooldown(new LCCooldown("CombatTag", Long.parseLong(Language.COMBAT_DURATION.getValue()), Material.DIAMOND_SWORD));
|
||||
PluginUtils.registerListeners(this, new CombatDamageListener(), new CombatWhitelistedCommand());
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new CombatTimer(), 20L, 20L);
|
||||
this.commandManager = new CommandManager(this);
|
||||
commandManager.register(new AdminCombatCommand());
|
||||
commandManager.register(new ToggleBarCommand());
|
||||
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
CombatTimer.playersInCombat.clear();
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.crankedpvp.combatlog.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.Command;
|
||||
import me.mattstudios.mf.annotations.Permission;
|
||||
import me.mattstudios.mf.annotations.SubCommand;
|
||||
import me.mattstudios.mf.annotations.WrongUsage;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.combatlog.CombatlogPlugin;
|
||||
import net.crankedpvp.combatlog.language.Language;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("cl")
|
||||
public class AdminCombatCommand extends CommandBase {
|
||||
@SubCommand("reload")
|
||||
@WrongUsage("&cUsage: /cl reload")
|
||||
@Permission("cranked.admin")
|
||||
public void reloadCommand(Player sender) {
|
||||
Language.ADMIN_RELOADING.send(sender);
|
||||
long then = System.currentTimeMillis();
|
||||
|
||||
CombatlogPlugin.getInstance().getLanguageHandler().load();
|
||||
|
||||
long diff = System.currentTimeMillis() - then;
|
||||
Language.ADMIN_RELOADED.send(sender, str -> str.replace("%took%", String.valueOf(diff)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.crankedpvp.combatlog.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.Alias;
|
||||
import me.mattstudios.mf.annotations.Command;
|
||||
import me.mattstudios.mf.annotations.Default;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.combatlog.language.Language;
|
||||
import net.crankedpvp.crankedcore.CrankedCore;
|
||||
import net.crankedpvp.crankedcore.data.CrankedUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("combattagtimer")
|
||||
@Alias({"togglecombattag", "togglecombattagtimer"})
|
||||
public class ToggleBarCommand extends CommandBase {
|
||||
@Default
|
||||
public void toggle(CommandSender sender) {
|
||||
CrankedUser user = CrankedCore.getInstance().getCrankedUserManager().getCrankedUser(((Player)sender).getUniqueId());
|
||||
if (user.isCombatTagTimerEnabled()) {
|
||||
user.setCombatTagTimerEnabled(false);
|
||||
Language.DISABLED_TIMER.send(sender);
|
||||
} else {
|
||||
user.setCombatTagTimerEnabled(true);
|
||||
Language.ENABLED_TIMER.send(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package net.crankedpvp.combatlog.language;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum Language {
|
||||
|
||||
ENTER_COMBAT,
|
||||
LEFT_COMBAT,
|
||||
COMBAT_DURATION,
|
||||
BLACKLISTED_COMMAND,
|
||||
COMBAT_WHITELISTED_COMMANDS,
|
||||
COMBAT_BLACKLISTED_COMMANDS,
|
||||
ADMIN_RELOADING,
|
||||
ADMIN_RELOADED,
|
||||
BYPASSING_COMMAND_BLACKLIST,
|
||||
ENABLED_TIMER,
|
||||
DISABLED_TIMER,
|
||||
|
||||
;
|
||||
|
||||
private String value;
|
||||
private ImmutableList<String> valueList;
|
||||
|
||||
public String getValue() {
|
||||
return this.value != null ? this.value : this.name();
|
||||
}
|
||||
|
||||
public String getValue(UnaryOperator<String> function) {
|
||||
return this.value != null ? function.apply(this.value) : this.name();
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
public List<String> getValuesAsList() {
|
||||
return this.valueList;
|
||||
}
|
||||
|
||||
public List<String> getValuesAsList(String oldString, String newString) {
|
||||
List<String> list = new ArrayList<>(this.valueList);
|
||||
list.replaceAll(s -> s.replace(oldString, newString));
|
||||
return list;
|
||||
}
|
||||
|
||||
void setValue(String value) {
|
||||
this.value = CC.translate(value);
|
||||
|
||||
List<String> tempList = Arrays.stream(StringUtils.split(value, System.lineSeparator()))
|
||||
.map(CC::translate)
|
||||
.collect(Collectors.toList());
|
||||
this.valueList = ImmutableList.copyOf(tempList);
|
||||
}
|
||||
|
||||
void setValue(List<String> valueList) {
|
||||
this.value = CC.translate(valueList.parallelStream().collect(Collectors.joining(System.lineSeparator())));
|
||||
|
||||
List<String> tempList = valueList.stream()
|
||||
.map(CC::translate)
|
||||
.collect(Collectors.toList());
|
||||
this.valueList = ImmutableList.copyOf(tempList);
|
||||
}
|
||||
|
||||
public void send(CommandSender sender, UnaryOperator<String> function) {
|
||||
sender.sendMessage(CC.translate(this.getValue(function)));
|
||||
}
|
||||
|
||||
public void send(CommandSender sender) {
|
||||
sender.sendMessage(CC.translate(this.getValue()));
|
||||
}
|
||||
|
||||
|
||||
public void send(List<CommandSender> senders, UnaryOperator<String> function) {
|
||||
String msg = CC.translate(this.getValue(function));
|
||||
senders.forEach(sender -> sender.sendMessage(msg));
|
||||
}
|
||||
|
||||
public void sendPlayers(List<Player> senders, UnaryOperator<String> function) {
|
||||
String msg = CC.translate(this.getValue(function));
|
||||
senders.forEach(sender -> sender.sendMessage(msg));
|
||||
}
|
||||
|
||||
public void send(CommandSender ...senders) {
|
||||
String msg = CC.translate(this.getValue());
|
||||
Arrays.asList(senders).forEach(sender -> sender.sendMessage(msg));
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return CC.translate(this.getValue());
|
||||
}
|
||||
|
||||
public String getMessage(UnaryOperator<String> function) {
|
||||
return CC.translate(this.getValue(function));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.crankedpvp.combatlog.language;
|
||||
|
||||
import net.crankedpvp.combatlog.CombatlogPlugin;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public final class LanguageHandler {
|
||||
|
||||
private final File file;
|
||||
private final FileConfiguration config;
|
||||
private final String path;
|
||||
private final CombatlogPlugin plugin;
|
||||
|
||||
public LanguageHandler(CombatlogPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.path = "language.yml";
|
||||
file = new File(plugin.getDataFolder(), path);
|
||||
config = new YamlConfiguration();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
this.saveDefaultConfig();
|
||||
|
||||
this.loadConfigFromDisk();
|
||||
this.copyDefaults();
|
||||
this.save();
|
||||
|
||||
this.loadConfigFromDisk();
|
||||
|
||||
this.loadLangMessages();
|
||||
}
|
||||
|
||||
private void loadLangMessages() {
|
||||
for (Language entry : Language.values()) {
|
||||
String path = entry.getPath();
|
||||
if (config.isList(path)) {
|
||||
entry.setValue(config.getStringList(path));
|
||||
continue;
|
||||
}
|
||||
entry.setValue(config.getString(path));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfigFromDisk() {
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not save config file for " + file.getPath() + "!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDefaults() {
|
||||
InputStream defConfig = plugin.getResource(this.path);
|
||||
if (defConfig != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfig)));
|
||||
}
|
||||
config.options().copyDefaults(true);
|
||||
}
|
||||
|
||||
private void saveDefaultConfig() {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
plugin.saveResource(file.getName(),false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package net.crankedpvp.combatlog.listeners;
|
||||
|
||||
import com.lunarclient.bukkitapi.cooldown.LunarClientAPICooldown;
|
||||
import net.crankedpvp.combatlog.CombatTagAPI;
|
||||
import net.crankedpvp.combatlog.tasks.CombatTimer;
|
||||
import net.crankedpvp.crankedutils.utils.WorldGuardUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CombatDamageListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!WorldGuardUtils.canPvPInRegion(player)) return;
|
||||
//if (CombatTimer.playersInCombat.containsKey(player)) player.setHealth(0.0);
|
||||
if (CombatTagAPI.isInCombat(player)) player.setHealth(0.0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!WorldGuardUtils.canPvPInRegion(player)) return;
|
||||
//if (CombatTimer.playersInCombat.containsKey(player)) player.setHealth(0.0);
|
||||
if (CombatTagAPI.isInCombat(player)) player.setHealth(0.0);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
//if (event.getEntity().getWorld().getName().equals("world_arenas")) return;
|
||||
if (event.isCancelled()) return;
|
||||
if(event.getDamage() <= 0) return;
|
||||
Player victim = null;
|
||||
Player attacker = null;
|
||||
|
||||
// Handle projectile hits on players and bosses
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
|
||||
if (event.getDamager() instanceof EnderPearl) return;
|
||||
|
||||
Projectile projectile = (Projectile) event.getDamager();
|
||||
|
||||
if (!(projectile.getShooter() instanceof Player)) return;
|
||||
|
||||
|
||||
victim = (Player) event.getEntity();
|
||||
attacker = (Player) projectile.getShooter();
|
||||
|
||||
}
|
||||
|
||||
// Handle direct hits by players
|
||||
else if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
|
||||
victim = (Player) event.getEntity();
|
||||
attacker = (Player) event.getDamager();
|
||||
}
|
||||
|
||||
if (victim == null) return;
|
||||
|
||||
if (attacker != null &&
|
||||
attacker.getGameMode() != GameMode.SURVIVAL &&
|
||||
attacker.getGameMode() != GameMode.ADVENTURE) return;
|
||||
|
||||
this.handleCombatTag(victim, attacker);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
if (event.getEntity() == null) return;
|
||||
LunarClientAPICooldown.clearCooldown(event.getEntity(), "CombatTag");
|
||||
CombatTimer.playersInCombat.remove(event.getEntity());
|
||||
}
|
||||
|
||||
private void handleCombatTag(@NotNull Player victim, @Nullable Player attacker) {
|
||||
if (attacker != null) {
|
||||
if (victim.getUniqueId().equals(attacker.getUniqueId())) {
|
||||
this.handleTagActions(attacker);
|
||||
return;
|
||||
}
|
||||
this.handleTagActions(attacker);
|
||||
}
|
||||
this.handleTagActions(victim);
|
||||
}
|
||||
|
||||
private void handleTagActions(Player combatPlayer) {
|
||||
CombatTagAPI.putPlayerInCombat(combatPlayer);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package net.crankedpvp.combatlog.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.crankedpvp.combatlog.CombatTagAPI;
|
||||
import net.crankedpvp.combatlog.language.Language;
|
||||
import net.crankedpvp.combatlog.tasks.CombatTimer;
|
||||
import net.crankedpvp.crankedutils.utils.WorldGuardUtils;
|
||||
import org.apache.commons.codec.language.bm.Lang;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class CombatWhitelistedCommand implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onCommandInCombat(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!CombatTagAPI.isInCombat(event.getPlayer())) return;
|
||||
|
||||
//if (!CombatTimer.playersInCombat.containsKey(player)) return;
|
||||
|
||||
if (player.hasPermission("cranked.admin")) {
|
||||
Language.BYPASSING_COMMAND_BLACKLIST.send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
//if (!WorldGuardUtils.canPvPInRegion(player)) return;
|
||||
|
||||
String command = event.getMessage().replace("/", "");
|
||||
List<String> whitelistedCommands = Language.COMBAT_WHITELISTED_COMMANDS.getValuesAsList();
|
||||
List<String> blacklistedCommands = Language.COMBAT_BLACKLISTED_COMMANDS.getValuesAsList();
|
||||
|
||||
if (blacklistedCommands.stream().anyMatch(command::equals)) {
|
||||
event.setCancelled(true);
|
||||
Language.BLACKLISTED_COMMAND.send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (whitelistedCommands.stream().anyMatch(command::startsWith)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
Language.BLACKLISTED_COMMAND.send(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.crankedpvp.combatlog.tasks;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.crankedpvp.combatlog.language.Language;
|
||||
import net.crankedpvp.crankedcore.CrankedCore;
|
||||
import net.crankedpvp.crankedutils.utils.ActionBarUtils;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.TitleUtils;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CombatTimer implements Runnable {
|
||||
public void run() {
|
||||
List<Player> list = new ArrayList<>();
|
||||
for (Player player : playersInCombat.keySet()) {
|
||||
if (playersInCombat.get(player) >= combatTimer) {
|
||||
Language.LEFT_COMBAT.send(player);
|
||||
ActionBarUtils actionBarUtils1 = new ActionBarUtils(CC.translate("&b&lCombat &7↣ &8[&aExpired&8]"));
|
||||
actionBarUtils1.sendToPlayer(player);
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_WINGS, 3, 5);
|
||||
player.setAllowFlight(true);
|
||||
list.add(player);
|
||||
continue;
|
||||
}
|
||||
playersInCombat.replace(player, playersInCombat.get(player) + 1);
|
||||
|
||||
if (CrankedCore.getInstance().getCrankedUserManager().getCrankedUser(player.getUniqueId()).isCombatTagTimerEnabled()) {
|
||||
ActionBarUtils actionBarUtils = new ActionBarUtils(CC.translate("&b&lCombat &7⤔ &8[" + getProgressBar((combatTimer - playersInCombat.get(player)), 10, 10) + "&8]"));
|
||||
actionBarUtils.sendToPlayer(player);
|
||||
}
|
||||
|
||||
}
|
||||
for (Player player : list) {
|
||||
playersInCombat.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<Player, Integer> playersInCombat = new HashMap<>();
|
||||
|
||||
public int combatTimer = Integer.parseInt(Language.COMBAT_DURATION.getValue());
|
||||
|
||||
public static String getProgressBar(int currentLevel, int maxLevel, int totalSquares) {
|
||||
float percent = (float) currentLevel / maxLevel;
|
||||
int progressBars = (int) (totalSquares * percent);
|
||||
|
||||
return CC.translate(
|
||||
Strings.repeat("&a|", progressBars) +
|
||||
Strings.repeat("&c|", totalSquares - progressBars)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#I like carrots ~Bry
|
||||
@@ -0,0 +1,14 @@
|
||||
ENTER_COMBAT: "&c&lCombatLog &8➥ &7You have &aentered &7combat. Do not log out for &a%duration%&7 seconds."
|
||||
LEFT_COMBAT: "&c&lCombatLog &8➥ &7You have &cleft&7 combat. You can now safely log out."
|
||||
COMBAT_DURATION: 10
|
||||
BLACKLISTED_COMMAND: "&c&lCombatLog &8➥ &7That command is &cnot &7allowed while in combat."
|
||||
ADMIN_RELOADING: "&c&lCombatLog &8➥ &7Reloading configs now..."
|
||||
ADMIN_RELOADED: "&c&lCombatLog &8➥ &7Reloaded configs and other cool stuff. Took &d%took%ms&7."
|
||||
BYPASSING_COMMAND_BLACKLIST: "&c&lCombatLog &8➥ &7You have bypassed blocked commands during combat"
|
||||
ENABLED_TIMER: "&c&lCombatLog &8➥ &7You &a&lENABLED&7 CombatTag Timer"
|
||||
DISABLED_TIMER: "&c&lCombatLog &8➥ &7You &c&lDISABLED&7 CombatTag Timer"
|
||||
COMBAT_WHITELISTED_COMMANDS:
|
||||
- "bless"
|
||||
- "apply"
|
||||
COMBAT_BLACKLISTED_COMMANDS:
|
||||
- "fly"
|
||||
@@ -0,0 +1,6 @@
|
||||
name: CrankedCombatLog
|
||||
version: 1.1
|
||||
main: net.crankedpvp.combatlog.CombatlogPlugin
|
||||
depend:
|
||||
- CrankedUtils
|
||||
- CrankedLunarAPI
|
||||
Reference in New Issue
Block a user