Fix bug where a players inventory was not properly updated after switching to SURVIVAL mode, causing CustomGear items to remain unhidden an JSON encoded.
This commit is contained in:
parent
a110cd6d9c
commit
17fbd42b9c
@ -134,7 +134,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
|
||||
if (page.matchesInventory(event.getInventory()))
|
||||
{
|
||||
_playerPageMap.get(event.getWhoClicked().getName()).playerClicked(event);
|
||||
page.playerClicked(event);
|
||||
|
||||
if (event.getRawSlot() < page.getSize())
|
||||
{
|
||||
|
@ -433,7 +433,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
Packet packet = packetInfo.getPacket();
|
||||
|
||||
if (packet instanceof PacketPlayOutSetSlot)
|
||||
{
|
||||
{
|
||||
PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet;
|
||||
slotPacket.c = maskItem(slotPacket.c); // Mask all out-going item packets
|
||||
}
|
||||
@ -445,7 +445,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
{
|
||||
itemsPacket.b[i] = maskItem(itemsPacket.b[i]); // Mask all out-going item packets
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private net.minecraft.server.v1_7_R4.ItemStack maskItem(net.minecraft.server.v1_7_R4.ItemStack item)
|
||||
|
@ -5,6 +5,7 @@ import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import net.minecraft.server.v1_7_R4.Material;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -44,7 +45,7 @@ public class ItemListener implements Listener
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onGamemodeChange(PlayerGameModeChangeEvent event)
|
||||
{
|
||||
if (event.getNewGameMode() == GameMode.CREATIVE) // Entering creative mode
|
||||
@ -54,6 +55,17 @@ public class ItemListener implements Listener
|
||||
else if (event.getPlayer().getGameMode() == GameMode.CREATIVE) // Exiting creative mode
|
||||
{
|
||||
GearManager.getInstance().removeCreativePlayer(event.getPlayer());
|
||||
|
||||
// Update/refresh the players inventory in 5 ticks once they're in survival mode again
|
||||
final Player player = event.getPlayer();
|
||||
Bukkit.getScheduler().runTaskLater(_plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.updateInventory();
|
||||
}
|
||||
}, 5l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,21 +175,6 @@ public class ItemListener implements Listener
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
// Prevent players from equipping armour items in hand (prevents lore-breaking bug)
|
||||
ItemStack itemInHand = event.getItem();
|
||||
if (isArmour(itemInHand))
|
||||
{
|
||||
Action action = event.getAction();
|
||||
boolean rightClick = action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
|
||||
|
||||
if (rightClick)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
GearManager.notify(event.getPlayer(), "You must manually equip armour!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Activate weapon interact abilities
|
||||
PlayerGear playerGear = getGear(event.getPlayer());
|
||||
playerGear.onInteract(event);
|
||||
|
@ -58,6 +58,7 @@ public class GearCommand extends CommandBase<GearManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.updateInventory();
|
||||
//caller.setFoodLevel(10);
|
||||
//return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user