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 {
|
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) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe(s);
|
pl.getLogger().severe(s);
|
||||||
|
@ -241,19 +241,39 @@ public class PlayerListener implements Listener {
|
|||||||
Player attacker = (Player) event.getDamager();
|
Player attacker = (Player) event.getDamager();
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
if(pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) {
|
//They aren't using the jail stick, they need to toggle themselves
|
||||||
if(pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) {
|
if(!pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) return;
|
||||||
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 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())) {
|
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||||
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
||||||
}else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//The player can't be jailed due to permissions.
|
||||||
if(player.hasPermission("jail.cantbejailed")) {
|
if(player.hasPermission("jail.cantbejailed")) {
|
||||||
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
||||||
}else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the stick the attacker (police) is using
|
||||||
Stick s = pl.getJailStickManager().getStick(attacker.getInventory().getItemInMainHand().getType());
|
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(),
|
Prisoner p = new Prisoner(player.getUniqueId().toString(), player.getName(),
|
||||||
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
||||||
s.getTime(), attacker.getName(), s.getReason());
|
s.getTime(), attacker.getName(), s.getReason());
|
||||||
@ -289,15 +309,6 @@ public class PlayerListener implements Listener {
|
|||||||
attacker.sendMessage(ChatColor.RED + e.getMessage());
|
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
|
default: true
|
||||||
jail.modifyjail:
|
jail.modifyjail:
|
||||||
default: op
|
default: op
|
||||||
jail.usejailstick280:
|
jail.usejailstick.stick:
|
||||||
default: op
|
default: op
|
||||||
description: change 280 for another jailstick item
|
description: change stick for another jailstick item
|
||||||
jail.canbestickjailed:
|
jail.canbestickjailed:
|
||||||
default: true
|
default: true
|
||||||
jail.openchest:
|
jail.openchest:
|
||||||
|
Loading…
Reference in New Issue
Block a user