mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-01-25 17:51:20 +01:00
Add support for off-hand items.
This commit is contained in:
parent
558681a2f2
commit
8705b5c9f7
@ -13,7 +13,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
public class ArenaClass
|
||||
{
|
||||
private String configName, lowercaseName;
|
||||
private ItemStack helmet, chestplate, leggings, boots;
|
||||
private ItemStack helmet, chestplate, leggings, boots, offhand;
|
||||
private List<ItemStack> items, armor;
|
||||
private Map<String,Boolean> perms;
|
||||
private Map<String,Boolean> lobbyperms;
|
||||
@ -100,6 +100,14 @@ public class ArenaClass
|
||||
this.boots = boots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the off-hand slot for the class.
|
||||
* @param offHand
|
||||
*/
|
||||
public void setOffHand(ItemStack offHand) {
|
||||
this.offhand = offHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the items list.
|
||||
* @param stack an item
|
||||
@ -182,6 +190,7 @@ public class ArenaClass
|
||||
if (chestplate != null) inv.setChestplate(chestplate);
|
||||
if (leggings != null) inv.setLeggings(leggings);
|
||||
if (boots != null) inv.setBoots(boots);
|
||||
if (offhand != null) inv.setItemInOffHand(offhand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1124,6 +1124,7 @@ public class ArenaImpl implements Arena
|
||||
ItemStack chestplate = null;
|
||||
ItemStack leggings = null;
|
||||
ItemStack boots = null;
|
||||
ItemStack offhand = null;
|
||||
|
||||
// Check the very last slot to see if it'll work as a helmet
|
||||
int last = contents.length-1;
|
||||
@ -1147,6 +1148,13 @@ public class ArenaImpl implements Arena
|
||||
contents[i] = null;
|
||||
}
|
||||
|
||||
// Equip the fifth last slot as the off-hand
|
||||
ItemStack fifth = contents[contents.length - 5];
|
||||
if (fifth != null) {
|
||||
offhand = fifth.clone();
|
||||
contents[contents.length - 5] = null;
|
||||
}
|
||||
|
||||
// Check the remaining slots for weapons
|
||||
if (arenaClass.hasUnbreakableWeapons()) {
|
||||
for (ItemStack stack : contents) {
|
||||
@ -1162,6 +1170,7 @@ public class ArenaImpl implements Arena
|
||||
inv.setChestplate(chestplate);
|
||||
inv.setLeggings(leggings);
|
||||
inv.setBoots(boots);
|
||||
inv.setItemInOffHand(offhand);
|
||||
|
||||
PermissionAttachment pa = arenaClass.grantLobbyPermissions(plugin, p);
|
||||
replacePermissions(p, pa);
|
||||
|
@ -338,18 +338,21 @@ public class ArenaMasterImpl implements ArenaMaster
|
||||
String chest = section.getString("chestplate", null);
|
||||
String legs = section.getString("leggings", null);
|
||||
String feet = section.getString("boots", null);
|
||||
String off = section.getString("offhand", null);
|
||||
|
||||
// Parse to ItemStacks
|
||||
ItemStack helmet = ItemParser.parseItem(head);
|
||||
ItemStack chestplate = ItemParser.parseItem(chest);
|
||||
ItemStack leggings = ItemParser.parseItem(legs);
|
||||
ItemStack boots = ItemParser.parseItem(feet);
|
||||
ItemStack offhand = ItemParser.parseItem(off);
|
||||
|
||||
// Set in ArenaClass
|
||||
arenaClass.setHelmet(helmet);
|
||||
arenaClass.setChestplate(chestplate);
|
||||
arenaClass.setLeggings(leggings);
|
||||
arenaClass.setBoots(boots);
|
||||
arenaClass.setOffHand(offhand);
|
||||
|
||||
// Per-class permissions
|
||||
loadClassPermissions(arenaClass, section);
|
||||
@ -420,6 +423,12 @@ public class ArenaMasterImpl implements ArenaMaster
|
||||
section.set("helmet", ItemParser.parseString(helmet));
|
||||
}
|
||||
|
||||
// Include the off-hand
|
||||
ItemStack offhand = inv.getItemInOffHand();
|
||||
if (offhand != null) {
|
||||
section.set("offhand", ItemParser.parseString(offhand));
|
||||
}
|
||||
|
||||
// Save changes.
|
||||
plugin.saveConfig();
|
||||
|
||||
|
@ -94,6 +94,7 @@ public class InventoryManager
|
||||
inv.setChestplate(null);
|
||||
inv.setLeggings(null);
|
||||
inv.setBoots(null);
|
||||
inv.setItemInOffHand(null);
|
||||
InventoryView view = p.getOpenInventory();
|
||||
if (view != null) {
|
||||
view.setCursor(null);
|
||||
|
Loading…
Reference in New Issue
Block a user