mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Fix Spigot's semi-breaking inventory change.
Because it is clearly impossible to change JavaDocs to correctly describe what a method does, the method setContents() has now been changed to a useless, over-aggressive, inventory-wiping piece of junk that must be invoked before anything else. This commit ensures that armor contents are set after the setContents() method is called, overwriting the nulls that the setContents() method creates.
This commit is contained in:
parent
847726a29a
commit
93ce8b9667
@ -1119,12 +1119,19 @@ public class ArenaImpl implements Arena
|
|||||||
|
|
||||||
PlayerInventory inv = p.getInventory();
|
PlayerInventory inv = p.getInventory();
|
||||||
|
|
||||||
|
// Collect armor items, because setContents() now overwrites everyhing
|
||||||
|
ItemStack helmet = null;
|
||||||
|
ItemStack chestplate = null;
|
||||||
|
ItemStack leggings = null;
|
||||||
|
ItemStack boots = null;
|
||||||
|
|
||||||
// Check the very last slot to see if it'll work as a helmet
|
// Check the very last slot to see if it'll work as a helmet
|
||||||
int last = contents.length-1;
|
int last = contents.length-1;
|
||||||
if (contents[last] != null) {
|
if (contents[last] != null) {
|
||||||
inv.setHelmet(contents[last]);
|
helmet = contents[last].clone();
|
||||||
contents[last] = null;
|
contents[last] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the remaining three of the four last slots for armor
|
// Check the remaining three of the four last slots for armor
|
||||||
for (int i = contents.length-1; i > contents.length-5; i--) {
|
for (int i = contents.length-1; i > contents.length-5; i--) {
|
||||||
if (contents[i] == null) continue;
|
if (contents[i] == null) continue;
|
||||||
@ -1132,9 +1139,9 @@ public class ArenaImpl implements Arena
|
|||||||
if (type == null || type == ArmorType.HELMET) continue;
|
if (type == null || type == ArmorType.HELMET) continue;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CHESTPLATE: inv.setChestplate(contents[i]); break;
|
case CHESTPLATE: chestplate = contents[i].clone(); break;
|
||||||
case LEGGINGS: inv.setLeggings(contents[i]); break;
|
case LEGGINGS: leggings = contents[i].clone(); break;
|
||||||
case BOOTS: inv.setBoots(contents[i]); break;
|
case BOOTS: boots = contents[i].clone(); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
contents[i] = null;
|
contents[i] = null;
|
||||||
@ -1148,7 +1155,13 @@ public class ArenaImpl implements Arena
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.getInventory().setContents(contents);
|
|
||||||
|
// Set contents, THEN set armor contents
|
||||||
|
inv.setContents(contents);
|
||||||
|
inv.setHelmet(helmet);
|
||||||
|
inv.setChestplate(chestplate);
|
||||||
|
inv.setLeggings(leggings);
|
||||||
|
inv.setBoots(boots);
|
||||||
|
|
||||||
PermissionAttachment pa = arenaClass.grantLobbyPermissions(plugin, p);
|
PermissionAttachment pa = arenaClass.grantLobbyPermissions(plugin, p);
|
||||||
replacePermissions(p, pa);
|
replacePermissions(p, pa);
|
||||||
|
Loading…
Reference in New Issue
Block a user