Cherry-pick the changes for the jail stick
This commit is contained in:
parent
9e281a821f
commit
543a862c98
@ -67,7 +67,7 @@ public class JailStickManager implements IJailStickManager {
|
||||
}
|
||||
|
||||
try {
|
||||
this.sticks.put(m, new Stick(jail, a[3], time, a.length > 5 ? Double.valueOf(a[4]) : -1));
|
||||
this.sticks.put(m, new Stick(jail, a[3], time, a.length >= 5 ? Double.valueOf(a[4]) : -1));
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
pl.getLogger().severe(s);
|
||||
|
@ -241,19 +241,39 @@ public class PlayerListener implements Listener {
|
||||
Player attacker = (Player) event.getDamager();
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if(pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) {
|
||||
if(pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) {
|
||||
if(attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase())) {
|
||||
//The person the attacker is trying to jail stick is already jailed, don't handle that
|
||||
//They aren't using the jail stick, they need to toggle themselves
|
||||
if(!pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) return;
|
||||
|
||||
//They don't have a valid jail stick type
|
||||
if(!pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) return;
|
||||
|
||||
//They don't have permission for that type of jail stick
|
||||
if(!attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase())) return;
|
||||
|
||||
//The player they hit is already jailed.
|
||||
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
//The player can't be jailed due to permissions.
|
||||
if(player.hasPermission("jail.cantbejailed")) {
|
||||
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the stick the attacker (police) is using
|
||||
Stick s = pl.getJailStickManager().getStick(attacker.getInventory().getItemInMainHand().getType());
|
||||
|
||||
if(player.getHealth() <= s.getHealth() || s.getHealth() == -1) {
|
||||
//Check if the player can resist arrest via health with this stick
|
||||
pl.debug("Jail stick health resist check: " + "(" + s.getHealth() + "," + player.getHealth() + ") - " + (s.getHealth() <= player.getHealth() && s.getHealth() != -1));
|
||||
if(s.getHealth() < player.getHealth() && s.getHealth() != -1) {
|
||||
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
|
||||
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
//The player can be jailed.
|
||||
Prisoner p = new Prisoner(player.getUniqueId().toString(), player.getName(),
|
||||
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
||||
s.getTime(), attacker.getName(), s.getReason());
|
||||
@ -289,15 +309,6 @@ public class PlayerListener implements Listener {
|
||||
attacker.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
|
||||
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,9 +135,9 @@ permissions:
|
||||
default: true
|
||||
jail.modifyjail:
|
||||
default: op
|
||||
jail.usejailstick280:
|
||||
jail.usejailstick.stick:
|
||||
default: op
|
||||
description: change 280 for another jailstick item
|
||||
description: change stick for another jailstick item
|
||||
jail.canbestickjailed:
|
||||
default: true
|
||||
jail.openchest:
|
||||
|
Loading…
Reference in New Issue
Block a user