Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void HandleSetter(BlockCommandSender sender, ArrayList<Player> affectedPlayers, String arg) {
- Setter setter = new Gson().fromJson(arg, Setter.class);
- if (setter.giveitems.length > 0) {
- for (Inventory inv : setter.giveitems) {
- if (inv.id != -1) {
- int id = inv.id;
- int meta = inv.data != -1 ? inv.data : 0;
- int amount = inv.amount != -1 ? inv.amount : 1;
- ItemStack is = new ItemStack(id, amount, (short)meta);
- if (id == Material.MAP.getId() && inv.mapurl != null) {
- is = MapChanger.getCustomMap(inv.mapurl);
- is.setAmount(amount);
- }
- if (inv.name != null) {
- is.getItemMeta().setDisplayName(inv.name);
- }
- if (inv.lore.length > 0) {
- List<String> lore = new ArrayList<String>();
- for (String clore : inv.lore) {
- lore.add(clore);
- }
- is.getItemMeta().setLore(lore);
- }
- if (inv.ench.length > 0) {
- for (Enchantment e : inv.ench) {
- if (e.id != -1 && e.level != -1) {
- is.getItemMeta().addEnchant(org.bukkit.enchantments.Enchantment.getById(e.id), e.level, true);
- }
- }
- }
- if (inv.skullowner != null && (is.getType() == Material.SKULL || is.getType() == Material.SKULL_ITEM)) {
- SkullMeta smeta = (SkullMeta)is.getItemMeta();
- smeta.setOwner(inv.skullowner);
- is.setItemMeta(smeta);
- }
- for (Player p : affectedPlayers) {
- if (inv.slot != -1) {
- p.getInventory().setItem(inv.slot, is);
- } else {
- p.getInventory().addItem(is);
- }
- }
- }
- }
- }
- if (setter.setblocks.length > 0) {
- for (SetBlock sb : setter.setblocks) {
- if (sb.x != Integer.MAX_VALUE && sb.y != Integer.MAX_VALUE && sb.z != Integer.MAX_VALUE) {
- Location loc = new Location(sender.getBlock().getWorld(), sb.x, sb.y, sb.z);
- int id = (sb.id == -1) ? sender.getBlock().getWorld().getBlockAt(loc).getTypeId() : sb.id;
- int meta = sb.meta;
- sender.getBlock().getWorld().getBlockAt(loc).setTypeIdAndData(id, (byte)meta, true);
- }
- }
- }
- if (setter.newobj != null) {
- if (setter.newobj.name != null && setter.newobj.goals.length > 0) {
- ObjectiveSystem.AddObjective(setter.newobj.name, setter.newobj.goals);
- }
- }
- if (setter.setobj != null) {
- if (setter.setobj.completegoal.length > 1) {
- Objective obj = ObjectiveSystem.find(setter.setobj.completegoal[0]);
- obj.completeGoal(setter.setobj.completegoal[1]);
- }
- if (setter.setobj.deleteobj != null) {
- Objective obj = ObjectiveSystem.find(setter.setobj.deleteobj);
- if (obj == null) { Msg.send("couldn't find objective: '" + setter.setobj.deleteobj + "'"); }
- else {
- ObjectiveSystem.objectives.remove(obj);
- }
- }
- if (setter.setobj.reset == 1) {
- ObjectiveSystem.objectives.clear();
- }
- }
- if (setter.spawnmobs.length > 0) {
- for (SpawnMob sm : setter.spawnmobs) {
- if (sm.x != Integer.MAX_VALUE && sm.y != Integer.MAX_VALUE && sm.z != Integer.MAX_VALUE && sm.types.length > 0 && sm.count > 0) {
- Location center = new Location(sender.getBlock().getWorld(), sm.x, sm.y, sm.z);
- for (int i=0;i<sm.count;i++) {
- String mobtype = getRandomMob(sm.types);
- Location spawnloc = getSpreadLocation(center, sm.spread);
- if (mobtype.equalsIgnoreCase("skeleton")) {
- sender.getBlock().getWorld().spawnEntity(spawnloc, EntityType.SKELETON);
- } else if (mobtype.equalsIgnoreCase("creeper")) {
- sender.getBlock().getWorld().spawnEntity(spawnloc, EntityType.CREEPER);
- } else {
- sender.getBlock().getWorld().spawnEntity(spawnloc, EntityType.ZOMBIE);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement