Only set player attack speed when in warzone

This commit is contained in:
= 2018-11-28 15:57:53 -08:00
parent 2e6466fab2
commit 3217c0a732
No known key found for this signature in database
GPG Key ID: 918580825B8F6862
2 changed files with 8 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -371,6 +372,12 @@ public class Team {
player.setScoreboard(this.warzone.getScoreboard());
}
warzone.updateScoreboard();
boolean cooldownEnabled = War.war.getWarConfig().getBoolean(WarConfig.DISABLECOOLDOWN);
if(cooldownEnabled) {
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(1024.0);
} else {
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0);
}
}
public List<Player> getPlayers() {
@ -431,6 +438,7 @@ public class Team {
}
this.warzone.getLoadoutSelections().remove(thePlayer);
warzone.updateScoreboard();
thePlayer.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0);
}
public int getRemainingLives() {

View File

@ -19,7 +19,6 @@ import com.tommytony.war.utility.LoadoutSelection;
import com.tommytony.war.volume.Volume;
import org.apache.commons.lang.Validate;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Item;
@ -67,17 +66,10 @@ public class WarPlayerListener implements Listener {
War.war.removeWandBearer(player);
}
}
event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0);
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
boolean cooldownDisabled = War.war.getWarConfig().getBoolean(WarConfig.DISABLECOOLDOWN);
if(cooldownDisabled) {
event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(1024.0);
} else {
event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0);
}
String autojoinName = War.war.getWarConfig().getString(WarConfig.AUTOJOIN);
boolean autojoinEnabled = !autojoinName.isEmpty();
if (autojoinEnabled) { // Won't be able to find warzone if unset