Fix the blacklist not working or sometimes erroring out.
This commit is contained in:
parent
9e0722c218
commit
c9b0fc8480
@ -198,6 +198,7 @@ public class PrisonerManager {
|
|||||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||||
|
|
||||||
for(ItemStack item : inventory) {
|
for(ItemStack item : inventory) {
|
||||||
|
if(item != null) {
|
||||||
if(!Util.isStringInsideList(blacklist, item.getType().toString())) {
|
if(!Util.isStringInsideList(blacklist, item.getType().toString())) {
|
||||||
int i = chest.firstEmpty();
|
int i = chest.firstEmpty();
|
||||||
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
||||||
@ -205,8 +206,10 @@ public class PrisonerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(ItemStack item : armor) {
|
for(ItemStack item : armor) {
|
||||||
|
if(item != null) {
|
||||||
if(!Util.isStringInsideList(blacklist, item.getType().toString())) {
|
if(!Util.isStringInsideList(blacklist, item.getType().toString())) {
|
||||||
int i = chest.firstEmpty();
|
int i = chest.firstEmpty();
|
||||||
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
||||||
@ -214,6 +217,7 @@ public class PrisonerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
player.getInventory().setArmorContents(null);
|
player.getInventory().setArmorContents(null);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
@ -222,19 +226,15 @@ public class PrisonerManager {
|
|||||||
//Updates the cell's signs
|
//Updates the cell's signs
|
||||||
cell.update();
|
cell.update();
|
||||||
}else {
|
}else {
|
||||||
for(ItemStack item : player.getInventory().getContents()) {
|
for(ItemStack item : player.getInventory().getContents())
|
||||||
if(Util.isStringInsideList(blacklist, item.getType().toString())) {
|
if(item != null)
|
||||||
pl.debug("Removing " + item.getType() + " from " + player.getName() + "'s (" + player.getUniqueId().toString() + ") inventory.");
|
if(Util.isStringInsideList(blacklist, item.getType().toString()))
|
||||||
player.getInventory().remove(item.getType());
|
player.getInventory().remove(item);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(ItemStack item : player.getInventory().getArmorContents()) {
|
for(ItemStack item : player.getInventory().getArmorContents())
|
||||||
if(Util.isStringInsideList(blacklist, item.getType().toString())) {
|
if(item != null)
|
||||||
pl.debug("Removing " + item.getType() + " from " + player.getName() + "'s (" + player.getUniqueId().toString() + ") inventory.");
|
if(Util.isStringInsideList(blacklist, item.getType().toString()))
|
||||||
player.getInventory().remove(item.getType());
|
player.getInventory().remove(item);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] inv = Util.playerInventoryToBase64(player.getInventory());
|
String[] inv = Util.playerInventoryToBase64(player.getInventory());
|
||||||
prisoner.setInventory(inv[0]);
|
prisoner.setInventory(inv[0]);
|
||||||
@ -252,6 +252,18 @@ public class PrisonerManager {
|
|||||||
}else {
|
}else {
|
||||||
//There is no cell we're jailing them to, so stick them in the jail
|
//There is no cell we're jailing them to, so stick them in the jail
|
||||||
if(pl.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath(), true)) {
|
if(pl.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath(), true)) {
|
||||||
|
List<String> blacklist = pl.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath());
|
||||||
|
|
||||||
|
for(ItemStack item : player.getInventory().getContents())
|
||||||
|
if(item != null)
|
||||||
|
if(Util.isStringInsideList(blacklist, item.getType().toString()))
|
||||||
|
player.getInventory().remove(item);
|
||||||
|
|
||||||
|
for(ItemStack item : player.getInventory().getArmorContents())
|
||||||
|
if(item != null)
|
||||||
|
if(Util.isStringInsideList(blacklist, item.getType().toString()))
|
||||||
|
player.getInventory().remove(item);
|
||||||
|
|
||||||
String[] inv = Util.playerInventoryToBase64(player.getInventory());
|
String[] inv = Util.playerInventoryToBase64(player.getInventory());
|
||||||
prisoner.setInventory(inv[0]);
|
prisoner.setInventory(inv[0]);
|
||||||
prisoner.setArmor(inv[1]);
|
prisoner.setArmor(inv[1]);
|
||||||
|
@ -84,12 +84,11 @@ public class Util {
|
|||||||
* @return true if the list contains the provided value, false if it doesn't
|
* @return true if the list contains the provided value, false if it doesn't
|
||||||
*/
|
*/
|
||||||
public static boolean isStringInsideList(List<String> list, String value) {
|
public static boolean isStringInsideList(List<String> list, String value) {
|
||||||
boolean r = false;
|
|
||||||
for(String s : list)
|
for(String s : list)
|
||||||
if(s.equalsIgnoreCase(value))
|
if(s.equalsIgnoreCase(value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return r;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a colorful message from the color codes. */
|
/** Returns a colorful message from the color codes. */
|
||||||
|
Loading…
Reference in New Issue
Block a user