mirror of
https://github.com/taoneill/war.git
synced 2025-01-20 14:21:19 +01:00
Fix NPE and reset attack speed when necessary
This commit is contained in:
parent
98afe494c1
commit
2e6466fab2
1
war/.gitignore
vendored
1
war/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/target/
|
|
@ -14,7 +14,7 @@ public enum WarConfig {
|
|||||||
LANGUAGE (String.class, "Language", "Preferred server language"),
|
LANGUAGE (String.class, "Language", "Preferred server language"),
|
||||||
AUTOJOIN (String.class, "Auto-join", "Name of warzone to send players to upon join"),
|
AUTOJOIN (String.class, "Auto-join", "Name of warzone to send players to upon join"),
|
||||||
TPWARMUP(Integer.class, "TP warmup", "Amount of seconds a player must wait after requesting a teleport"),
|
TPWARMUP(Integer.class, "TP warmup", "Amount of seconds a player must wait after requesting a teleport"),
|
||||||
DISABLECOOLDOWN(Boolean.class, "Disable the 1.9 combat cooldown", "Disables the attack cooldown when swinging a weapon");
|
DISABLECOOLDOWN (Boolean.class, "Disable the 1.9 combat cooldown", "Disables the attack cooldown when swinging a weapon");
|
||||||
|
|
||||||
private final Class<?> configType;
|
private final Class<?> configType;
|
||||||
private final String title;
|
private final String title;
|
||||||
|
@ -47,8 +47,7 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
public class WarPlayerListener implements Listener {
|
public class WarPlayerListener implements Listener {
|
||||||
private java.util.Random random = new java.util.Random();
|
private java.util.Random random = new java.util.Random();
|
||||||
private HashMap<String, Location> latestLocations = new HashMap<String, Location>();
|
private HashMap<String, Location> latestLocations = new HashMap<String, Location>();
|
||||||
private boolean cooldownDisabled = War.war.getWarConfig().getBoolean(WarConfig.DISABLECOOLDOWN);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Correctly removes quitting players from warzones
|
* Correctly removes quitting players from warzones
|
||||||
@ -68,11 +67,17 @@ public class WarPlayerListener implements Listener {
|
|||||||
War.war.removeWandBearer(player);
|
War.war.removeWandBearer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||||
event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(cooldownDisabled ? 1024 : 4);
|
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);
|
String autojoinName = War.war.getWarConfig().getString(WarConfig.AUTOJOIN);
|
||||||
boolean autojoinEnabled = !autojoinName.isEmpty();
|
boolean autojoinEnabled = !autojoinName.isEmpty();
|
||||||
if (autojoinEnabled) { // Won't be able to find warzone if unset
|
if (autojoinEnabled) { // Won't be able to find warzone if unset
|
||||||
|
Loading…
Reference in New Issue
Block a user