Add a black list to storing the player's inventory.
This commit is contained in:
parent
a5bf89b07e
commit
9ca8e14e29
@ -1,5 +1,6 @@
|
|||||||
package com.graywolf336.jail;
|
package com.graywolf336.jail;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -135,12 +136,6 @@ public class PrisonerManager {
|
|||||||
player.sendMessage(pl.getJailIO().getLanguageString(LangString.JAILEDWITHREASON, new String[] { prisoner.getReason() }));
|
player.sendMessage(pl.getJailIO().getLanguageString(LangString.JAILEDWITHREASON, new String[] { prisoner.getReason() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the config has inventory deletion, then let's delete it
|
|
||||||
if(pl.getConfig().getBoolean(Settings.DELETEINVENTORY.getPath(), false)) {
|
|
||||||
player.getInventory().setArmorContents(null);
|
|
||||||
player.getInventory().clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//If the config has releasing them back to their previous position,
|
//If the config has releasing them back to their previous position,
|
||||||
//then let's set it in the prisoner data.
|
//then let's set it in the prisoner data.
|
||||||
if(pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
|
if(pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
|
||||||
@ -191,6 +186,7 @@ public class PrisonerManager {
|
|||||||
if(cell != null) {
|
if(cell != null) {
|
||||||
//check if we store the inventory
|
//check if we store the inventory
|
||||||
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());
|
||||||
//Check if there is a chest to store our items to and if it is a double chest, if not we will then serialize it
|
//Check if there is a chest to store our items to and if it is a double chest, if not we will then serialize it
|
||||||
if(cell.hasChest()) {
|
if(cell.hasChest()) {
|
||||||
//Get the chest's inventory and then clear it
|
//Get the chest's inventory and then clear it
|
||||||
@ -202,16 +198,20 @@ public class PrisonerManager {
|
|||||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||||
|
|
||||||
for(ItemStack item : inventory) {
|
for(ItemStack item : inventory) {
|
||||||
int i = chest.firstEmpty();
|
if(!Util.isStringInsideList(blacklist, item.getType().toString())) {
|
||||||
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
int i = chest.firstEmpty();
|
||||||
chest.setItem(i, item);
|
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
||||||
|
chest.setItem(i, item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ItemStack item : armor) {
|
for(ItemStack item : armor) {
|
||||||
int i = chest.firstEmpty();
|
if(!Util.isStringInsideList(blacklist, item.getType().toString())) {
|
||||||
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
int i = chest.firstEmpty();
|
||||||
chest.setItem(i, item);
|
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
||||||
|
chest.setItem(i, item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +222,18 @@ 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()) {
|
||||||
|
if(Util.isStringInsideList(blacklist, item.getType().toString())) {
|
||||||
|
player.getInventory().remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ItemStack item : player.getInventory().getArmorContents()) {
|
||||||
|
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]);
|
||||||
|
@ -24,7 +24,6 @@ public enum Settings {
|
|||||||
CROPTRAMPLINGPROTECTION("jailing.during.cropTramplingProtection"),
|
CROPTRAMPLINGPROTECTION("jailing.during.cropTramplingProtection"),
|
||||||
DEBUG("system.debug"),
|
DEBUG("system.debug"),
|
||||||
DEFAULTJAIL("jailing.jail.defaultJail"),
|
DEFAULTJAIL("jailing.jail.defaultJail"),
|
||||||
DELETEINVENTORY("jailing.jail.deleteInventory"),
|
|
||||||
ENDERMENPROTECTION("jails.endermenProtection"),
|
ENDERMENPROTECTION("jails.endermenProtection"),
|
||||||
EXPLOSIONPROTECTION("jails.explosionProtection"),
|
EXPLOSIONPROTECTION("jails.explosionProtection"),
|
||||||
FOODCONTROL("jailing.during.foodControl"),
|
FOODCONTROL("jailing.during.foodControl"),
|
||||||
@ -35,7 +34,8 @@ public enum Settings {
|
|||||||
JAILSTICKSTICKS("jailstick.sticks"),
|
JAILSTICKSTICKS("jailstick.sticks"),
|
||||||
JAILDEFAULTTIME("jailing.jail.defaultTime"),
|
JAILDEFAULTTIME("jailing.jail.defaultTime"),
|
||||||
JAILEDGAMEMODE("jailing.jail.gameMode"),
|
JAILEDGAMEMODE("jailing.jail.gameMode"),
|
||||||
JAILEDSTOREINVENTORY("jailing.jail.storeInventory"),
|
JAILEDINVENTORYBLACKLIST("jailing.jail.inventory.blacklist"),
|
||||||
|
JAILEDSTOREINVENTORY("jailing.jail.inventory.store"),
|
||||||
JAILPAYENABLED("jailpay.enabled"),
|
JAILPAYENABLED("jailpay.enabled"),
|
||||||
JAILPAYITEM("jailpay.item"),
|
JAILPAYITEM("jailpay.item"),
|
||||||
JAILPAYPRICEPERMINUTE ("jailpay.pricePerMinute"),
|
JAILPAYPRICEPERMINUTE ("jailpay.pricePerMinute"),
|
||||||
|
@ -56,11 +56,12 @@ jailing:
|
|||||||
commands: []
|
commands: []
|
||||||
defaultJail: nearest #the jail nearest to the player
|
defaultJail: nearest #the jail nearest to the player
|
||||||
defaultTime: 30m #default the time to 30 minutes, if no time
|
defaultTime: 30m #default the time to 30 minutes, if no time
|
||||||
deleteInventory: false
|
|
||||||
gameMode: adventure
|
gameMode: adventure
|
||||||
|
inventory:
|
||||||
|
blacklist: ['diamond_block', 'gold_block', 'emerald_block'] #items they aren't allowed to keep
|
||||||
|
store: true
|
||||||
logToConsole: true
|
logToConsole: true
|
||||||
logToProfile: false
|
logToProfile: false
|
||||||
storeInventory: true
|
|
||||||
release:
|
release:
|
||||||
backToPreviousPosition: false
|
backToPreviousPosition: false
|
||||||
commands: []
|
commands: []
|
||||||
|
Loading…
Reference in New Issue
Block a user