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,61 +241,72 @@ 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
|
|
||||||
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
|
||||||
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
|
||||||
}else {
|
|
||||||
if(player.hasPermission("jail.cantbejailed")) {
|
|
||||||
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
|
||||||
}else {
|
|
||||||
Stick s = pl.getJailStickManager().getStick(attacker.getInventory().getItemInMainHand().getType());
|
|
||||||
|
|
||||||
if(player.getHealth() <= s.getHealth() || s.getHealth() == -1) {
|
//They don't have a valid jail stick type
|
||||||
Prisoner p = new Prisoner(player.getUniqueId().toString(), player.getName(),
|
if(!pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) return;
|
||||||
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
|
||||||
s.getTime(), attacker.getName(), s.getReason());
|
|
||||||
|
|
||||||
PrePrisonerJailedByJailStickEvent jEvent = new PrePrisonerJailedByJailStickEvent(
|
//They don't have permission for that type of jail stick
|
||||||
pl.getJailManager().getJail(s.getJail()), new AnyCell(), p, player, attacker.getName(), s);
|
if(!attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase())) return;
|
||||||
|
|
||||||
pl.getServer().getPluginManager().callEvent(jEvent);
|
//The player they hit is already jailed.
|
||||||
|
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||||
|
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(jEvent.isCancelled()) {
|
//The player can't be jailed due to permissions.
|
||||||
if(jEvent.getCancelledMessage().isEmpty())
|
if(player.hasPermission("jail.cantbejailed")) {
|
||||||
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
|
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
||||||
else
|
return;
|
||||||
attacker.sendMessage(jEvent.getCancelledMessage());
|
}
|
||||||
}else {
|
|
||||||
//recall data from the event
|
|
||||||
Jail j = jEvent.getJail();
|
|
||||||
ICell c = jEvent.getCell();
|
|
||||||
p = jEvent.getPrisoner();
|
|
||||||
player = jEvent.getPlayer();
|
|
||||||
|
|
||||||
//Player is not online
|
//Get the stick the attacker (police) is using
|
||||||
if(player == null) {
|
Stick s = pl.getJailStickManager().getStick(attacker.getInventory().getItemInMainHand().getType());
|
||||||
attacker.sendMessage(Lang.OFFLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
|
||||||
}else {
|
|
||||||
//Player *is* online
|
|
||||||
attacker.sendMessage(Lang.ONLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
//Check if the player can resist arrest via health with this stick
|
||||||
pl.getPrisonerManager().prepareJail(j, c, player, p);
|
pl.debug("Jail stick health resist check: " + "(" + s.getHealth() + "," + player.getHealth() + ") - " + (s.getHealth() <= player.getHealth() && s.getHealth() != -1));
|
||||||
} catch (Exception e) {
|
if(s.getHealth() < player.getHealth() && s.getHealth() != -1) {
|
||||||
attacker.sendMessage(ChatColor.RED + e.getMessage());
|
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
|
||||||
}
|
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
|
||||||
}
|
return;
|
||||||
}else {
|
}
|
||||||
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
|
|
||||||
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
|
//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());
|
||||||
}
|
|
||||||
|
PrePrisonerJailedByJailStickEvent jEvent = new PrePrisonerJailedByJailStickEvent(
|
||||||
|
pl.getJailManager().getJail(s.getJail()), new AnyCell(), p, player, attacker.getName(), s);
|
||||||
|
|
||||||
|
pl.getServer().getPluginManager().callEvent(jEvent);
|
||||||
|
|
||||||
|
if(jEvent.isCancelled()) {
|
||||||
|
if(jEvent.getCancelledMessage().isEmpty())
|
||||||
|
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
|
||||||
|
else
|
||||||
|
attacker.sendMessage(jEvent.getCancelledMessage());
|
||||||
|
}else {
|
||||||
|
//recall data from the event
|
||||||
|
Jail j = jEvent.getJail();
|
||||||
|
ICell c = jEvent.getCell();
|
||||||
|
p = jEvent.getPrisoner();
|
||||||
|
player = jEvent.getPlayer();
|
||||||
|
|
||||||
|
//Player is not online
|
||||||
|
if(player == null) {
|
||||||
|
attacker.sendMessage(Lang.OFFLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||||
|
}else {
|
||||||
|
//Player *is* online
|
||||||
|
attacker.sendMessage(Lang.ONLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
pl.getPrisonerManager().prepareJail(j, c, player, p);
|
||||||
|
} catch (Exception e) {
|
||||||
|
attacker.sendMessage(ChatColor.RED + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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