Fix item glitching.

Let's see you glitch items out now, suckers!
This commit is contained in:
garbagemule 2013-08-19 06:22:31 +02:00
parent 69741a3bdc
commit 6ef8bf23da
2 changed files with 21 additions and 5 deletions

View File

@ -1,7 +1,7 @@
name: MobArena
author: garbagemule
main: com.garbagemule.MobArena.MobArena
version: 0.95.5.27
version: 0.95.5.28
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
commands:
ma:

View File

@ -15,9 +15,8 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.*;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.*;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.potion.PotionEffect;
@ -624,6 +623,11 @@ public class ArenaImpl implements Arena
if (event.isCancelled()) {
return false;
}
// Clear inventory if player is an arena player
if (arenaPlayers.contains(p)) {
clearInv(p);
}
removeClassPermissions(p);
removePotionEffects(p);
@ -658,7 +662,10 @@ public class ArenaImpl implements Arena
ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this, last);
plugin.getServer().getPluginManager().callEvent(event);
arenaPlayers.remove(p);
// Clear the player's inventory
if (arenaPlayers.remove(p)) {
clearInv(p);
}
if (!settings.getBoolean("auto-respawn", true)) {
deadPlayers.add(p);
@ -671,6 +678,15 @@ public class ArenaImpl implements Arena
endArena();
}
private void clearInv(Player p) {
InventoryView view = p.getOpenInventory();
if (view != null) {
view.setCursor(new ItemStack(0));
view.getBottomInventory().clear();
view.close();
}
}
@Override
public void playerRespawn(Player p) {
if (settings.getBoolean("auto-respawn", true)) {