Add limited inmate clothing! Closes Ticket #22

This commit is contained in:
graywolf336 2014-07-14 19:05:28 -05:00
parent a38ae137ee
commit 8fe7dea3ae
3 changed files with 86 additions and 0 deletions

View File

@ -9,6 +9,11 @@ public enum Settings {
BLOCKPLACEPENALTY("jailing.during.blockPlacePenalty"),
BLOCKPLACEPROTECTION("jailing.during.blockPlaceProtection"),
BLOCKPLACEWHITELIST("jailing.during.blockPlaceWhiteList"),
CLOTHINGENABLED("jailing.jail.clothing.enabled"),
CLOTHINGHELMET("jailing.jail.clothing.helmet"),
CLOTHINGCHEST("jailing.jail.clothing.chest"),
CLOTHINGLEGS("jailing.jail.clothing.legs"),
CLOTHINGBOOTS("jailing.jail.clothing.boots"),
COMMANDSONJAIL("jailing.jail.commands"),
COMMANDSONRELEASE("jailing.release.commands"),
COMMANDPENALTY("jailing.during.commandPenalty"),

View File

@ -4,13 +4,19 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
import com.graywolf336.jail.events.PrePrisonerJailedEvent;
import com.graywolf336.jail.events.PrisonerJailedEvent;
public class JailingListener implements Listener {
private JailMain pl;
@ -36,4 +42,73 @@ public class JailingListener implements Listener {
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
}
@EventHandler
public void setInmatesClothing(PrisonerJailedEvent event) {
if(pl.getConfig().getBoolean(Settings.CLOTHINGENABLED.getPath())) {
String[] helmet = pl.getConfig().getString(Settings.CLOTHINGHELMET.getPath()).split("~");
switch(helmet.length) {
case 1:
event.getPlayer().getInventory().setHelmet(new ItemStack(Material.valueOf(helmet[0])));
break;
case 2:
ItemStack item = new ItemStack(Material.valueOf(helmet[0]));
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
String[] colors = helmet[1].split(",");
meta.setColor(Color.fromBGR(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2])));
item.setItemMeta(meta);
event.getPlayer().getInventory().setHelmet(item);
default:
break;
}
String[] chest = pl.getConfig().getString(Settings.CLOTHINGCHEST.getPath()).split("~");
switch(chest.length) {
case 1:
event.getPlayer().getInventory().setChestplate(new ItemStack(Material.valueOf(chest[0])));
break;
case 2:
ItemStack item = new ItemStack(Material.valueOf(chest[0]));
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
String[] colors = chest[1].split(",");
meta.setColor(Color.fromBGR(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2])));
item.setItemMeta(meta);
event.getPlayer().getInventory().setChestplate(item);
default:
break;
}
String[] legs = pl.getConfig().getString(Settings.CLOTHINGLEGS.getPath()).split("~");
switch(legs.length) {
case 1:
event.getPlayer().getInventory().setLeggings(new ItemStack(Material.valueOf(legs[0])));
break;
case 2:
ItemStack item = new ItemStack(Material.valueOf(legs[0]));
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
String[] colors = legs[1].split(",");
meta.setColor(Color.fromBGR(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2])));
item.setItemMeta(meta);
event.getPlayer().getInventory().setLeggings(item);
default:
break;
}
String[] boots = pl.getConfig().getString(Settings.CLOTHINGBOOTS.getPath()).split("~");
switch(boots.length) {
case 1:
event.getPlayer().getInventory().setBoots(new ItemStack(Material.valueOf(boots[0])));
break;
case 2:
ItemStack item = new ItemStack(Material.valueOf(boots[0]));
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
String[] colors = boots[1].split(",");
meta.setColor(Color.fromBGR(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2])));
item.setItemMeta(meta);
event.getPlayer().getInventory().setBoots(item);
default:
break;
}
}
}
}

View File

@ -47,6 +47,12 @@ jailing:
jail:
automaticMute: true
broadcastJailing: false
clothing:
set: true
helmet: leather_boots~255,102,0
chest: leather_chestplate~255,102,0
legs: leather_leggings~255,102,0
boots: leather_boots~255,102,0
commands: []
defaultJail: nearest #the jail nearest to the player
defaultTime: 30m #default the time to 30 minutes, if no time