Merge branch 'master' of git@github.com:graywolf336/Jail.git
This commit is contained in:
commit
b22fad16c4
@ -29,6 +29,7 @@ Done
|
|||||||
* Config value ``jailing.during.maxFoodLevel`` is now used in one part
|
* Config value ``jailing.during.maxFoodLevel`` is now used in one part
|
||||||
* Config value ``jailing.during.minFoodLevel`` is now used in one part
|
* Config value ``jailing.during.minFoodLevel`` is now used in one part
|
||||||
* Config value ``jailing.release.teleport`` is used in unjailing
|
* Config value ``jailing.release.teleport`` is used in unjailing
|
||||||
|
* Config value ``jailing.release.commands`` is now used
|
||||||
|
|
||||||
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
|
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
|
||||||
====
|
====
|
@ -1,7 +1,5 @@
|
|||||||
package com.graywolf336.jail;
|
package com.graywolf336.jail;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -348,51 +346,25 @@ public class PrisonerManager {
|
|||||||
|
|
||||||
chest.clear();
|
chest.clear();
|
||||||
}else {
|
}else {
|
||||||
restoreInventory(player, prisoner);
|
Util.restoreInventory(player, prisoner);
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.getJailIO().removePrisoner(jail, cell, prisoner);
|
pl.getJailIO().removePrisoner(jail, cell, prisoner);
|
||||||
cell.removePrisoner();
|
cell.removePrisoner();
|
||||||
}else {
|
}else {
|
||||||
restoreInventory(player, prisoner);
|
Util.restoreInventory(player, prisoner);
|
||||||
|
|
||||||
pl.getJailIO().removePrisoner(jail, prisoner);
|
pl.getJailIO().removePrisoner(jail, prisoner);
|
||||||
jail.removePrisoner(prisoner);
|
jail.removePrisoner(prisoner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get the commands to execute prisoners are unjailed
|
||||||
|
//replace all of the %p% so that the commands can have a player name in them
|
||||||
|
for(String command : pl.getConfig().getStringList(Settings.COMMANDSONRELEASE.getPath())) {
|
||||||
|
command = command.replaceAll("%p%", player.getName());
|
||||||
|
pl.getServer().dispatchCommand(pl.getServer().getConsoleSender(), command);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreInventory(Player player, Prisoner prisoner) {
|
player.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILED));
|
||||||
try {
|
|
||||||
Inventory content = Util.fromBase64(prisoner.getInventory());
|
|
||||||
ItemStack[] armor = Util.itemStackArrayFromBase64(prisoner.getArmor());
|
|
||||||
|
|
||||||
for(ItemStack item : armor) {
|
|
||||||
if(item == null)
|
|
||||||
continue;
|
|
||||||
else if(item.getType().toString().toLowerCase().contains("helmet"))
|
|
||||||
player.getInventory().setHelmet(item);
|
|
||||||
else if(item.getType().toString().toLowerCase().contains("chestplate"))
|
|
||||||
player.getInventory().setChestplate(item);
|
|
||||||
else if(item.getType().toString().toLowerCase().contains("leg"))
|
|
||||||
player.getInventory().setLeggings(item);
|
|
||||||
else if(item.getType().toString().toLowerCase().contains("boots"))
|
|
||||||
player.getInventory().setBoots(item);
|
|
||||||
else if (player.getInventory().firstEmpty() == -1)
|
|
||||||
player.getWorld().dropItem(player.getLocation(), item);
|
|
||||||
else
|
|
||||||
player.getInventory().addItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(ItemStack item : content.getContents()) {
|
|
||||||
if(item == null) continue;
|
|
||||||
else if(player.getInventory().firstEmpty() == -1)
|
|
||||||
player.getWorld().dropItem(player.getLocation(), item);
|
|
||||||
else
|
|
||||||
player.getInventory().addItem(item);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
pl.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import java.util.regex.Pattern;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -20,6 +21,8 @@ import org.bukkit.util.io.BukkitObjectInputStream;
|
|||||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||||
|
|
||||||
|
import com.graywolf336.jail.beans.Prisoner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a variety of methods, static, that are used throughout the plugin.
|
* Provides a variety of methods, static, that are used throughout the plugin.
|
||||||
*
|
*
|
||||||
@ -265,4 +268,39 @@ public class Util {
|
|||||||
throw new IOException("Unable to decode class type.", e);
|
throw new IOException("Unable to decode class type.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void restoreInventory(Player player, Prisoner prisoner) {
|
||||||
|
try {
|
||||||
|
Inventory content = Util.fromBase64(prisoner.getInventory());
|
||||||
|
ItemStack[] armor = Util.itemStackArrayFromBase64(prisoner.getArmor());
|
||||||
|
|
||||||
|
for(ItemStack item : armor) {
|
||||||
|
if(item == null)
|
||||||
|
continue;
|
||||||
|
else if(item.getType().toString().toLowerCase().contains("helmet"))
|
||||||
|
player.getInventory().setHelmet(item);
|
||||||
|
else if(item.getType().toString().toLowerCase().contains("chestplate"))
|
||||||
|
player.getInventory().setChestplate(item);
|
||||||
|
else if(item.getType().toString().toLowerCase().contains("leg"))
|
||||||
|
player.getInventory().setLeggings(item);
|
||||||
|
else if(item.getType().toString().toLowerCase().contains("boots"))
|
||||||
|
player.getInventory().setBoots(item);
|
||||||
|
else if (player.getInventory().firstEmpty() == -1)
|
||||||
|
player.getWorld().dropItem(player.getLocation(), item);
|
||||||
|
else
|
||||||
|
player.getInventory().addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ItemStack item : content.getContents()) {
|
||||||
|
if(item == null) continue;
|
||||||
|
else if(player.getInventory().firstEmpty() == -1)
|
||||||
|
player.getWorld().dropItem(player.getLocation(), item);
|
||||||
|
else
|
||||||
|
player.getInventory().addItem(item);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.graywolf336.jail.enums;
|
|||||||
public enum Settings {
|
public enum Settings {
|
||||||
BROADCASTJAILING("jailing.jail.broadcastJailing"),
|
BROADCASTJAILING("jailing.jail.broadcastJailing"),
|
||||||
COMMANDSONJAIL("jailing.jail.commands"),
|
COMMANDSONJAIL("jailing.jail.commands"),
|
||||||
|
COMMANDSONRELEASE("jailing.release.commands"),
|
||||||
DEBUG("system.debug"),
|
DEBUG("system.debug"),
|
||||||
DEFAULTJAIL("jailing.jail.defaultJail"),
|
DEFAULTJAIL("jailing.jail.defaultJail"),
|
||||||
DELETEINVENTORY("jailing.jail.deleteInventory"),
|
DELETEINVENTORY("jailing.jail.deleteInventory"),
|
||||||
|
Loading…
Reference in New Issue
Block a user