diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java index 58fff47f8..56eb416d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java @@ -1,14 +1,17 @@ package mineplex.core.cosmetic.ui; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.plugin.messaging.PluginMessageListener; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.page.GadgetPage; import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.PetTagPage; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; @@ -44,4 +47,10 @@ public class CosmeticShop extends ShopBase implements PluginMes } } } + + @EventHandler + public void itemGadgetEmptyAmmo(ItemGadgetOutOfAmmoEvent event) + { + new GadgetPage(Plugin, this, ClientManager, DonationManager, "Gadgets", event.getPlayer()).purchaseGadget(event.getPlayer(), event.getGadget()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index c024bfcfb..9a6927479 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -123,7 +123,7 @@ public class GadgetPage extends ShopPageBase { if (Plugin.getInventoryManager().Get(player).getItemCount(gadget.GetName()) <= 0) { - PlayDenySound(player); + purchaseGadget(player, gadget); return; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index 7cc873c9f..4baf499d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -68,6 +68,7 @@ public class PetTagPage extends ShopPageBase PlayDenySound(Player); Shop.OpenPageForPlayer(Player, new PetPage(Plugin, Shop, ClientManager, DonationManager, "Pets", Player)); + return; } PetExtra tag = new PetExtra("Rename " + _pet.GetName() + " to " + _tagName, Material.NAME_TAG, 100); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 449d03393..27b1dd35a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -324,7 +324,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable } } else if (packet instanceof PacketPlayOutEntityMetadata) - { + { int entityId = ((PacketPlayOutEntityMetadata)packet).a; if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/ItemGadgetOutOfAmmoEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/ItemGadgetOutOfAmmoEvent.java new file mode 100644 index 000000000..1e4f2f774 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/ItemGadgetOutOfAmmoEvent.java @@ -0,0 +1,41 @@ +package mineplex.core.gadget.event; + +import mineplex.core.gadget.types.ItemGadget; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class ItemGadgetOutOfAmmoEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private ItemGadget _gadget; + + public ItemGadgetOutOfAmmoEvent(Player player, ItemGadget gadget) + { + _player = player; + _gadget = gadget; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public ItemGadget getGadget() + { + return _gadget; + } + + public Player getPlayer() + { + return _player; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java index 04fa4d4a8..34d4ed557 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -75,12 +76,16 @@ public class ItemPaintballGun extends ItemGadget if (block.getType() == Material.CACTUS) return; + + if (block.getType() == Material.SUGAR_CANE_BLOCK) + return; } List blocks = new ArrayList(); blocks.addAll(UtilBlock.getInRadius(loc, 1.5d).keySet()); GadgetBlockEvent gadgetEvent = new GadgetBlockEvent(this, blocks); + Bukkit.getServer().getPluginManager().callEvent(gadgetEvent); if (gadgetEvent.isCancelled()) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java index f924605ae..d919f51cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java @@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; @@ -72,7 +73,7 @@ public abstract class ItemGadget extends Gadget itemLore.add(C.cBlack); itemLore.add(C.cWhite + "Your Ammo : " + Manager.getInventoryManager().Get(player).getItemCount(GetName())); - player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); + player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName()))); if (inform) UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + ".")); @@ -143,13 +144,19 @@ public abstract class ItemGadget extends Gadget if (Manager.getInventoryManager().Get(player).getItemCount(GetName()) <= 0) { + UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left.")); - Disable(player); + + ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this); + Bukkit.getServer().getPluginManager().callEvent(ammoEvent); + return; } Manager.getInventoryManager().addItemToInventory(player, getGadgetType().name(), GetName(), -1); + player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName()))); + ActivateCustom(event.getPlayer()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 270442f9d..af51e43a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -14,6 +14,7 @@ import java.util.UUID; import net.minecraft.server.v1_7_R4.EntityAgeable; import net.minecraft.server.v1_7_R4.EntityInsentient; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World.Environment; @@ -27,6 +28,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -43,6 +45,8 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.creature.Creature; import mineplex.core.creature.event.CreatureKillEntitiesEvent; import mineplex.core.npc.Commands.NpcCommand; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; public class NpcManager extends MiniPlugin { @@ -118,6 +122,23 @@ public class NpcManager extends MiniPlugin } } + @EventHandler(priority = EventPriority.LOWEST) + public void OnEntityDamage(EntityDamageByEntityEvent event) + { + if (_npcs.containsKey(event.getEntity().getUniqueId().toString())) + { + if (event.getDamager() instanceof LivingEntity) + { + NpcDamageByEntityEvent npcEvent = new NpcDamageByEntityEvent((LivingEntity)event.getEntity(), (LivingEntity)event.getDamager()); + + Bukkit.getServer().getPluginManager().callEvent(npcEvent); + } + + event.setCancelled(true); + return; + } + } + @EventHandler(priority = EventPriority.LOWEST) public void OnCreatureKillEntities(CreatureKillEntitiesEvent event) { @@ -225,6 +246,10 @@ public class NpcManager extends MiniPlugin if (_npcs.containsKey(event.getRightClicked().getUniqueId().toString())) { + NpcInteractEntityEvent npcEvent = new NpcInteractEntityEvent((LivingEntity)event.getRightClicked(), event.getPlayer()); + + Bukkit.getServer().getPluginManager().callEvent(npcEvent); + event.setCancelled(true); return; } @@ -521,4 +546,9 @@ public class NpcManager extends MiniPlugin { return _npcs.get(uniqueId.toString()); } + + public boolean isNpc(LivingEntity entity) + { + return _npcs.containsKey(entity.getUniqueId().toString()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcDamageByEntityEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcDamageByEntityEvent.java new file mode 100644 index 000000000..8cf1eb67f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcDamageByEntityEvent.java @@ -0,0 +1,20 @@ +package mineplex.core.npc.event; + +import org.bukkit.entity.LivingEntity; + +public class NpcDamageByEntityEvent extends NpcEvent +{ + private LivingEntity _damager; + + public NpcDamageByEntityEvent(LivingEntity npc, LivingEntity damager) + { + super(npc); + + _damager = damager; + } + + public LivingEntity getDamager() + { + return _damager; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcEvent.java new file mode 100644 index 000000000..db48f41ec --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcEvent.java @@ -0,0 +1,44 @@ +package mineplex.core.npc.event; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class NpcEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private LivingEntity _npc; + + private boolean _cancelled = false; + + public NpcEvent(LivingEntity npc) + { + _npc = npc; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public LivingEntity getNpc() + { + return _npc; + } + + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public boolean isCancelled() + { + return _cancelled; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcInteractEntityEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcInteractEntityEvent.java new file mode 100644 index 000000000..f2370dc57 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/event/NpcInteractEntityEvent.java @@ -0,0 +1,21 @@ +package mineplex.core.npc.event; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +public class NpcInteractEntityEvent extends NpcEvent +{ + private Player _player; + + public NpcInteractEntityEvent(LivingEntity npc, Player player) + { + super(npc); + + _player = player; + } + + public Player getPlayer() + { + return _player; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java index 8f71b331d..c4af9984f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java @@ -93,7 +93,7 @@ public class ServerCommand extends CommandBase { UtilPlayer.message( player, - F.main(Plugin.GetName(), C.cRed + "You don't have permission to join " + C.cGold + args[0])); + F.main(Plugin.GetName(), C.cRed + "You don't have permission to join " + C.cGold + args[0] + " with /server")); } } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java index 0116f162e..fa948f5b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; public class PreferencesShop extends ShopBase { - public PreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager) + public PreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager) { super(plugin, clientManager, donationManager, "User Preferences"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index 97f69c058..d912758e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -22,6 +22,9 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; import mineplex.core.shop.page.ShopPageBase; public abstract class ShopBase implements Listener @@ -62,28 +65,22 @@ public abstract class ShopBase implements Listene } @EventHandler(priority = EventPriority.LOWEST) - public void OnPlayerDamageEntity(EntityDamageByEntityEvent event) + public void OnPlayerDamageEntity(NpcDamageByEntityEvent event) { - if (event.getEntity() instanceof LivingEntity) + if (event.getDamager() instanceof Player) { - if (event.getDamager() instanceof Player) - { - if (AttemptShopOpen((Player)event.getDamager(), (LivingEntity)event.getEntity())) - { - event.setCancelled(true); - } - } + if (AttemptShopOpen((Player)event.getDamager(), event.getNpc())) + { + event.setCancelled(true); + } } } @EventHandler(priority = EventPriority.LOWEST) - public void OnPlayerInteractEntity(PlayerInteractEntityEvent event) + public void OnPlayerInteractEntity(NpcInteractEntityEvent event) { - if (event.getRightClicked() instanceof LivingEntity) - { - if (AttemptShopOpen(event.getPlayer(), (LivingEntity)event.getRightClicked())) - event.setCancelled(true); - } + if (AttemptShopOpen(event.getPlayer(), (LivingEntity)event.getNpc())) + event.setCancelled(true); } private boolean AttemptShopOpen(Player player, LivingEntity entity) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 65386a2f2..ddbe36297 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -3,7 +3,6 @@ package mineplex.hub.modules; import java.util.HashSet; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -14,17 +13,11 @@ import org.bukkit.entity.Horse; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -34,8 +27,6 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.event.StackerEvent; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileUser; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 9db284f4b..4203e8771 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -761,4 +761,14 @@ public class ServerManager extends MiniPlugin { return _hubManager; } + + public ShopBase getDrawMyThingShop() + { + return _serverNpcShopMap.get("Draw My Thing"); + } + + public ShopBase getTeamDeathmatchShop() + { + return _serverNpcShopMap.get("Team Deathmatch"); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 3ec401fd4..4e4680c77 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -14,24 +14,30 @@ import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; +import mineplex.hub.server.ui.button.SelectBHButton; +import mineplex.hub.server.ui.button.SelectBRButton; +import mineplex.hub.server.ui.button.SelectCSButton; +import mineplex.hub.server.ui.button.SelectDMTButton; +import mineplex.hub.server.ui.button.SelectDOMButton; +import mineplex.hub.server.ui.button.SelectMINButton; +import mineplex.hub.server.ui.button.SelectSGButton; +import mineplex.hub.server.ui.button.SelectSSMButton; +import mineplex.hub.server.ui.button.SelectTDMButton; public class ServerGameMenu extends ShopPageBase { private List _superSmashCycle = new ArrayList(); private List _minigameCycle = new ArrayList(); - private List _turfFortsCycle = new ArrayList(); private int _ssmIndex; private int _minigameIndex; - private int _turfFortsIndex; public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { - super(plugin, quickShop, clientManager, donationManager, name, player, 9); + super(plugin, quickShop, clientManager, donationManager, name, player, 27); createSuperSmashCycle(); createMinigameCycle(); - createTurfFortsCycle(); BuildPage(); } @@ -39,16 +45,7 @@ public class ServerGameMenu extends ShopPageBase @Override protected void BuildPage() { - this.setItem(1, _superSmashCycle.get(_ssmIndex)); - this.setItem(2, _minigameCycle.get(_minigameIndex)); - this.setItem(3, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Survival Games " + C.cGray + "Last Man Standing", new String[] - { - ChatColor.RESET + "", - ChatColor.RESET + "Search for chests to find loot and ", - ChatColor.RESET + "fight others to be the last man standing. ", - ChatColor.RESET + "Beware of the deep freeze!", - })); - this.setItem(4, ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "The Bridges " + C.cGray + "4 Team Survival", new String[] + this.setItem(1, ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "The Bridges " + C.cGray + "4 Team Survival", new String[] { ChatColor.RESET + "", ChatColor.RESET + "4 Teams get 10 minutes to prepare.", @@ -56,7 +53,18 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "breaks loose as you battle to the", ChatColor.RESET + "death with the other teams.", })); - this.setItem(5, ItemStackFactory.Instance.CreateStack(Material.ANVIL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Block Hunt " + C.cGray + "Cat and Mouse", new String[] + + this.setItem(3, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Survival Games " + C.cGray + "Last Man Standing", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Search for chests to find loot and ", + ChatColor.RESET + "fight others to be the last man standing. ", + ChatColor.RESET + "Beware of the deep freeze!", + })); + + this.setItem(5, _superSmashCycle.get(_ssmIndex)); + + this.setItem(7, ItemStackFactory.Instance.CreateStack(Material.ANVIL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Block Hunt " + C.cGray + "Cat and Mouse", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Hide as blocks/animals, upgrade your ", @@ -64,15 +72,15 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "the Hunters!", })); - this.setItem(6, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Champions " + C.cGray + "Team Game", new String[] - { + this.setItem(18, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Draw My Thing " + C.cGray + "Pictionary!", new String[] + { ChatColor.RESET + "", - ChatColor.RESET + "Customize one of five exciting champions", - ChatColor.RESET + "and battle with the opposing team for the", - ChatColor.RESET + "control points on the map.", + ChatColor.RESET + "Players take turns at drawing a random", + ChatColor.RESET + "word. Whoever guesses it within the time", + ChatColor.RESET + "limit gets some points!", })); - this.setItem(7, ItemStackFactory.Instance.CreateStack(98, (byte)2, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Castle Siege " + C.cGray + "Team Game", new String[] + this.setItem(20, ItemStackFactory.Instance.CreateStack(98, (byte)2, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Castle Siege " + C.cGray + "Team Game", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Defenders must protect King Sparklez", @@ -80,30 +88,34 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "until the sun rises!", })); - ButtonMap.put(1, new SelectSSMButton(this)); - ButtonMap.put(2, new SelectMINButton(this)); - ButtonMap.put(3, new SelectSGButton(this)); - ButtonMap.put(4, new SelectBRButton(this)); - ButtonMap.put(5, new SelectBHButton(this)); - ButtonMap.put(6, new SelectDOMButton(this)); - ButtonMap.put(7, new SelectCSButton(this)); - } - - private void createTurfFortsCycle() - { - _turfFortsCycle.add(ItemStackFactory.Instance.CreateStack(Material.WOOL.getId(), (byte)11, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Turf Forts " + C.cGray + "Arcade Minigame", new String [] - { + this.setItem(22, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Dominate " + C.cGray + "Team Game", new String[] + { ChatColor.RESET + "", - ChatColor.RESET + "Use your archery skills to kill your", - ChatColor.RESET + "enemies and take over their turf!" + ChatColor.RESET + "Customize one of five exciting champions", + ChatColor.RESET + "and battle with the opposing team for the", + ChatColor.RESET + "control points on the map.", })); - _turfFortsCycle.add(ItemStackFactory.Instance.CreateStack(Material.WOOL.getId(), (byte)14, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Turf Forts " + C.cGray + "Arcade Minigame", new String [] - { - ChatColor.RESET + "", - ChatColor.RESET + "Use your archery skills to kill your", - ChatColor.RESET + "enemies and take over their turf!" - })); + this.setItem(24, ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Team Deathmatch " + C.cGray + "Team Game", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Customize one of five exciting champions", + ChatColor.RESET + "and battle with the opposing team to the", + ChatColor.RESET + "last man standing.", + })); + + this.setItem(26, _minigameCycle.get(_minigameIndex)); + + ButtonMap.put(1, new SelectBRButton(this)); + ButtonMap.put(3, new SelectSGButton(this)); + ButtonMap.put(5, new SelectSSMButton(this)); + ButtonMap.put(7, new SelectBHButton(this)); + + ButtonMap.put(18, new SelectDMTButton(this)); + ButtonMap.put(20, new SelectCSButton(this)); + ButtonMap.put(22, new SelectDOMButton(this)); + ButtonMap.put(24, new SelectTDMButton(this)); + ButtonMap.put(26, new SelectMINButton(this)); } private void createMinigameCycle() @@ -324,7 +336,6 @@ public class ServerGameMenu extends ShopPageBase { _ssmIndex++; _minigameIndex++; - _turfFortsIndex++; if (_ssmIndex >= _superSmashCycle.size()) _ssmIndex = 0; @@ -332,9 +343,6 @@ public class ServerGameMenu extends ShopPageBase if (_minigameIndex >= _minigameCycle.size()) _minigameIndex = 0; - if (_turfFortsIndex >= _turfFortsCycle.size()) - _turfFortsIndex = 0; - BuildPage(); } @@ -372,4 +380,14 @@ public class ServerGameMenu extends ShopPageBase { Plugin.getSurvivalGamesShop().attemptShopOpen(player); } + + public void openDMT(Player player) + { + Plugin.getDrawMyThingShop().attemptShopOpen(player); + } + + public void OpenTDM(Player player) + { + Plugin.getTeamDeathmatchShop().attemptShopOpen(player); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectBHButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBHButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectBHButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBHButton.java index 153ff276f..4f90b6f58 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectBHButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBHButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectBHButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectBRButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBRButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectBRButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBRButton.java index 966cca52c..7c31ed4a7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectBRButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBRButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectBRButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectCSButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCSButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectCSButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCSButton.java index 1034f5689..185e42d7e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectCSButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCSButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectCSButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectDMTButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectDMTButton.java new file mode 100644 index 000000000..b310df634 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectDMTButton.java @@ -0,0 +1,28 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectDMTButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectDMTButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void ClickedLeft(Player player) + { + _menu.openDMT(player); + } + + @Override + public void ClickedRight(Player player) + { + ClickedLeft(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectDOMButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectDOMButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectDOMButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectDOMButton.java index bbc3a7db7..a6523f3d9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectDOMButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectDOMButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectDOMButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectMINButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMINButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectMINButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMINButton.java index 3ce476d5e..99aad932d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectMINButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMINButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectMINButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectSGButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSGButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectSGButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSGButton.java index e918dee3e..ceca7fc55 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectSGButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSGButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectSGButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectSSMButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSSMButton.java similarity index 82% rename from Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectSSMButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSSMButton.java index 0af74d7e4..b4cd28f25 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SelectSSMButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSSMButton.java @@ -1,8 +1,9 @@ -package mineplex.hub.server.ui; +package mineplex.hub.server.ui.button; import org.bukkit.entity.Player; import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; public class SelectSSMButton implements IButton { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTDMButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTDMButton.java new file mode 100644 index 000000000..c4aca5e28 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectTDMButton.java @@ -0,0 +1,28 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectTDMButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectTDMButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void ClickedLeft(Player player) + { + _menu.OpenTDM(player); + } + + @Override + public void ClickedRight(Player player) + { + ClickedLeft(player); + } +} diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 6d9a2918f..c43893973 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -89,12 +89,12 @@ public class ServerMonitor { if (isServerOffline(serverData)) { - System.out.println("------=[OFFLINE]=------=[" + serverData.getName() + ":" + serverData.getPublicAddress() + "]=------=[OFFLINE]=------"); + log("------=[OFFLINE]=------=[" + serverData.getName() + ":" + serverData.getPublicAddress() + "]=------=[OFFLINE]=------"); _badServers.put(serverData.getName(), true); } } - System.out.println(_badServers.size() + " bad servers."); + log(_badServers.size() + " bad servers."); } for (Iterator iterator = dedicatedServers.iterator(); iterator.hasNext();) @@ -128,7 +128,7 @@ public class ServerMonitor onlineServers.add(minecraftServer.getName()); if (minecraftServer.getTps() <= 17) - System.out.println("[Performance] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress() + "] Running poorly at " + minecraftServer.getTps() + " TPS"); + log("[Performance] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress() + "] Running poorly at " + minecraftServer.getTps() + " TPS"); } for (Iterator>> iterator = serverTracker.entrySet().iterator(); iterator.hasNext();) @@ -176,7 +176,7 @@ public class ServerMonitor { try { - System.out.println("Sleeping while processes run..."); + log("Sleeping while processes run..."); Thread.sleep(6000); } catch (InterruptedException e) @@ -187,7 +187,7 @@ public class ServerMonitor if (processWaits >= 10) { - System.out.println("Killing stale processes."); + log("Killing stale processes."); for (Iterator iterator = _processes.iterator(); iterator.hasNext();) { @@ -203,7 +203,7 @@ public class ServerMonitor try { - System.out.println("Natural sleep."); + log("Natural sleep."); Thread.sleep(10000); } catch (InterruptedException e) @@ -290,9 +290,9 @@ public class ServerMonitor if (announce) { if (error) - System.out.println("[" + serverName + ":" + serverAddress + "] Kill errored."); + log("[" + serverName + ":" + serverAddress + "] Kill errored."); else - System.out.println(message); + log(message); } } }); @@ -385,9 +385,9 @@ public class ServerMonitor public void run(Boolean error) { if (error) - System.out.println("[" + serverName + ":" + serverAddress + "] Errored " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")"); + log("[" + serverName + ":" + serverAddress + "] Errored " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")"); else - System.out.println("[" + serverName + ":" + serverAddress + "] Added " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")"); + log("[" + serverName + ":" + serverAddress + "] Added " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")"); } }); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java index afe63edd9..70afd046b 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java @@ -24,7 +24,12 @@ public class RankCommand extends CommandBase String rank = args[1]; boolean perm = Boolean.parseBoolean(args[2]); - Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm); - caller.sendMessage(F.main(Plugin.GetName(), playerName + "'s rank has been updated to " + rank + "!")); + final Rank rankEnum = Rank.valueOf(rank); + + if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA) + { + Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm); + caller.sendMessage(F.main(Plugin.GetName(), playerName + "'s rank has been updated to " + rank + "!")); + } } } diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/NetworkManager.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/NetworkManager.java new file mode 100644 index 000000000..c70894293 --- /dev/null +++ b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/NetworkManager.java @@ -0,0 +1,308 @@ +package net.minecraft.server.v1_7_R4; + +import java.net.SocketAddress; +import java.util.Queue; +import javax.crypto.SecretKey; + +import net.minecraft.util.com.google.common.collect.Queues; +import net.minecraft.util.com.google.common.util.concurrent.ThreadFactoryBuilder; +import net.minecraft.util.com.mojang.authlib.properties.Property; +import net.minecraft.util.io.netty.channel.Channel; +import net.minecraft.util.io.netty.channel.ChannelFutureListener; +import net.minecraft.util.io.netty.channel.ChannelHandlerContext; +import net.minecraft.util.io.netty.channel.SimpleChannelInboundHandler; +import net.minecraft.util.io.netty.channel.local.LocalChannel; +import net.minecraft.util.io.netty.channel.local.LocalServerChannel; +import net.minecraft.util.io.netty.channel.nio.NioEventLoopGroup; +import net.minecraft.util.io.netty.handler.timeout.TimeoutException; +import net.minecraft.util.io.netty.util.AttributeKey; +import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.util.org.apache.commons.lang3.Validate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; +// Spigot start +import com.google.common.collect.ImmutableSet; + +// Spigot end + +public class NetworkManager extends SimpleChannelInboundHandler +{ + + private static final Logger i = LogManager.getLogger(); + public static final Marker a = MarkerManager.getMarker("NETWORK"); + public static final Marker b = MarkerManager.getMarker("NETWORK_PACKETS", a); + public static final Marker c = MarkerManager.getMarker("NETWORK_STAT", a); + public static final AttributeKey d = new AttributeKey("protocol"); + public static final AttributeKey e = new AttributeKey("receivable_packets"); + public static final AttributeKey f = new AttributeKey("sendable_packets"); + public static final NioEventLoopGroup g = new NioEventLoopGroup(0, (new ThreadFactoryBuilder()) + .setNameFormat("Netty Client IO #%d").setDaemon(true).build()); + public static final NetworkStatistics h = new NetworkStatistics(); + private final boolean j; + private final Queue k = Queues.newConcurrentLinkedQueue(); + private final Queue l = Queues.newConcurrentLinkedQueue(); + private Channel m; + // Spigot Start + public SocketAddress n; + public java.util.UUID spoofedUUID; + public Property[] spoofedProfile; + public boolean preparing = true; + // Spigot End + private PacketListener o; + private EnumProtocol p; + private IChatBaseComponent q; + private boolean r; + // Spigot Start + public static final AttributeKey protocolVersion = new AttributeKey("protocol_version"); + public static final ImmutableSet SUPPORTED_VERSIONS = ImmutableSet.of(4, 5); + public static final int CURRENT_VERSION = 5; + + public static int getVersion(Channel attr) + { + Integer ver = attr.attr(protocolVersion).get(); + return (ver != null) ? ver : CURRENT_VERSION; + } + + public int getVersion() + { + return getVersion(this.m); + } + + // Spigot End + + public NetworkManager(boolean flag) + { + this.j = flag; + } + + public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception + { // CraftBukkit - throws Exception + super.channelActive(channelhandlercontext); + this.m = channelhandlercontext.channel(); + this.n = this.m.remoteAddress(); + // Spigot Start + this.preparing = false; + // Spigot End + this.a(EnumProtocol.HANDSHAKING); + } + + public void a(EnumProtocol enumprotocol) + { + this.p = (EnumProtocol) this.m.attr(d).getAndSet(enumprotocol); + this.m.attr(e).set(enumprotocol.a(this.j)); + this.m.attr(f).set(enumprotocol.b(this.j)); + this.m.config().setAutoRead(true); + i.debug("Enabled auto read"); + } + + public void channelInactive(ChannelHandlerContext channelhandlercontext) + { + this.close(new ChatMessage("disconnect.endOfStream", new Object[0])); + } + + public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) + { + ChatMessage chatmessage; + + if (throwable instanceof TimeoutException) + { + chatmessage = new ChatMessage("disconnect.timeout", new Object[0]); + } + else + { + chatmessage = new ChatMessage("disconnect.genericReason", + new Object[] { "Internal Exception: " + throwable }); + } + + this.close(chatmessage); + if (MinecraftServer.getServer().isDebugging()) + { + throwable.printStackTrace(); // Spigot + System.out.println("------------"); + for (StackTraceElement trace : Thread.currentThread().getStackTrace()) + { + System.out.println(trace); + } + } + } + + protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) + { + if (this.m.isOpen()) + { + if (packet.a()) + { + packet.handle(this.o); + } + else + { + this.k.add(packet); + } + } + } + + public void a(PacketListener packetlistener) + { + Validate.notNull(packetlistener, "packetListener", new Object[0]); + i.debug("Set listener of {} to {}", new Object[] { this, packetlistener }); + this.o = packetlistener; + } + + public void handle(Packet packet, GenericFutureListener... agenericfuturelistener) + { + if (this.m != null && this.m.isOpen()) + { + this.i(); + this.b(packet, agenericfuturelistener); + } + else + { + this.l.add(new QueuedPacket(packet, agenericfuturelistener)); + } + } + + private void b(Packet packet, GenericFutureListener[] agenericfuturelistener) + { + EnumProtocol enumprotocol = EnumProtocol.a(packet); + EnumProtocol enumprotocol1 = (EnumProtocol) this.m.attr(d).get(); + + if (enumprotocol1 != enumprotocol) + { + i.debug("Disabled auto read"); + this.m.config().setAutoRead(false); + } + + if (this.m.eventLoop().inEventLoop()) + { + if (enumprotocol != enumprotocol1) + { + this.a(enumprotocol); + } + + this.m.writeAndFlush(packet).addListeners(agenericfuturelistener) + .addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + else + { + this.m.eventLoop().execute( + new QueuedProtocolSwitch(this, enumprotocol, enumprotocol1, packet, agenericfuturelistener)); + } + } + + private void i() + { + if (this.m != null && this.m.isOpen()) + { + while (!this.l.isEmpty()) + { + QueuedPacket queuedpacket = (QueuedPacket) this.l.poll(); + + this.b(QueuedPacket.a(queuedpacket), QueuedPacket.b(queuedpacket)); + } + } + } + + public void a() + { + this.i(); + EnumProtocol enumprotocol = (EnumProtocol) this.m.attr(d).get(); + + if (this.p != enumprotocol) + { + if (this.p != null) + { + this.o.a(this.p, enumprotocol); + } + + this.p = enumprotocol; + } + + if (this.o != null) + { + for (int i = 1000; !this.k.isEmpty() && i >= 0; --i) + { + Packet packet = (Packet) this.k.poll(); + + // CraftBukkit start + if (!this.isConnected() || !this.m.config().isAutoRead()) + { + continue; + } + // CraftBukkit end + packet.handle(this.o); + } + + this.o.a(); + } + + this.m.flush(); + } + + public SocketAddress getSocketAddress() + { + return this.n; + } + + public void close(IChatBaseComponent ichatbasecomponent) + { + // Spigot Start + this.preparing = false; + // Spigot End + if (this.m.isOpen()) + { + this.m.close(); + this.q = ichatbasecomponent; + } + } + + public boolean c() + { + return this.m instanceof LocalChannel || this.m instanceof LocalServerChannel; + } + + public void a(SecretKey secretkey) + { + this.m.pipeline().addBefore("splitter", "decrypt", new PacketDecrypter(MinecraftEncryption.a(2, secretkey))); + this.m.pipeline().addBefore("prepender", "encrypt", new PacketEncrypter(MinecraftEncryption.a(1, secretkey))); + this.r = true; + } + + public boolean isConnected() + { + return this.m != null && this.m.isOpen(); + } + + public PacketListener getPacketListener() + { + return this.o; + } + + public IChatBaseComponent f() + { + return this.q; + } + + public void g() + { + this.m.config().setAutoRead(false); + } + + protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) + { + this.a(channelhandlercontext, (Packet) object); + } + + static Channel a(NetworkManager networkmanager) + { + return networkmanager.m; + } + + // Spigot Start + public SocketAddress getRawAddress() + { + return this.m.remoteAddress(); + } + // Spigot End +} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketDataSerializer.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketDataSerializer.java new file mode 100644 index 000000000..4508f313c --- /dev/null +++ b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketDataSerializer.java @@ -0,0 +1,922 @@ +package net.minecraft.server.v1_7_R4; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.GatheringByteChannel; +import java.nio.channels.ScatteringByteChannel; +import java.nio.charset.Charset; + +import net.minecraft.util.com.google.common.base.Charsets; +import net.minecraft.util.io.netty.buffer.ByteBuf; +import net.minecraft.util.io.netty.buffer.ByteBufAllocator; +import net.minecraft.util.io.netty.buffer.ByteBufProcessor; + +import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; // CraftBukkit + +public class PacketDataSerializer extends ByteBuf +{ + + private final ByteBuf a; + // Spigot Start + public final int version; + + public PacketDataSerializer(ByteBuf bytebuf) + { + this(bytebuf, NetworkManager.CURRENT_VERSION); + } + + public PacketDataSerializer(ByteBuf bytebuf, int version) + { + this.a = bytebuf; + this.version = version; + } + + // Spigot End + + public static int a(int i) + { + return (i & -128) == 0 ? 1 : ((i & -16384) == 0 ? 2 : ((i & -2097152) == 0 ? 3 + : ((i & -268435456) == 0 ? 4 : 5))); + } + + public int a() + { + int i = 0; + int j = 0; + + byte b0; + + do + { + b0 = this.readByte(); + i |= (b0 & 127) << j++ * 7; + if (j > 5) + { + throw new RuntimeException("VarInt too big"); + } + } + while ((b0 & 128) == 128); + + return i; + } + + public void b(int i) + { + while ((i & -128) != 0) + { + this.writeByte(i & 127 | 128); + i >>>= 7; + } + + this.writeByte(i); + } + + public void a(NBTTagCompound nbttagcompound) + { + if (nbttagcompound == null) + { + this.writeShort(-1); + } + else + { + byte[] abyte = NBTCompressedStreamTools.a(nbttagcompound); + + this.writeShort((short) abyte.length); + this.writeBytes(abyte); + } + } + + public NBTTagCompound b() + { + short short1 = this.readShort(); + + if (short1 < 0) + { + return null; + } + else + { + byte[] abyte = new byte[short1]; + + this.readBytes(abyte); + return NBTCompressedStreamTools.a(abyte, new NBTReadLimiter(2097152L)); + } + } + + public void a(ItemStack itemstack) + { + if (itemstack == null || itemstack.getItem() == null) + { // CraftBukkit - NPE fix itemstack.getItem() + this.writeShort(-1); + } + else + { + this.writeShort(Item.getId(itemstack.getItem())); + this.writeByte(itemstack.count); + this.writeShort(itemstack.getData()); + NBTTagCompound nbttagcompound = null; + + if (itemstack.getItem().usesDurability() || itemstack.getItem().s()) + { + nbttagcompound = itemstack.tag; + } + + this.a(nbttagcompound); + } + } + + public ItemStack c() + { + ItemStack itemstack = null; + short short1 = this.readShort(); + + if (short1 >= 0) + { + byte b0 = this.readByte(); + short short2 = this.readShort(); + + itemstack = new ItemStack(Item.getById(short1), b0, short2); + itemstack.tag = this.b(); + // CraftBukkit start + if (itemstack.tag != null) + { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + } + // CraftBukkit end + } + + return itemstack; + } + + public String c(int i) throws IOException + { // CraftBukkit - throws IOException + int j = this.a(); + + if (j > i * 4) + { + throw new IOException("The received encoded string buffer length is longer than maximum allowed (" + j + + " > " + i * 4 + ")"); + } + else if (j < 0) + { + throw new IOException("The received encoded string buffer length is less than zero! Weird string!"); + } + else + { + String s = new String(this.readBytes(j).array(), Charsets.UTF_8); + + if (s.length() > i) + { + throw new IOException("The received string length is longer than maximum allowed (" + j + " > " + i + + ")"); + } + else + { + return s; + } + } + } + + public void a(String s) throws IOException + { // CraftBukkit - throws IOException + byte[] abyte = s.getBytes(Charsets.UTF_8); + + if (abyte.length > 32767) + { + throw new IOException("String too big (was " + s.length() + " bytes encoded, max " + 32767 + ")"); + } + else + { + this.b(abyte.length); + this.writeBytes(abyte); + } + } + + public int capacity() + { + return this.a.capacity(); + } + + public ByteBuf capacity(int i) + { + return this.a.capacity(i); + } + + public int maxCapacity() + { + return this.a.maxCapacity(); + } + + public ByteBufAllocator alloc() + { + return this.a.alloc(); + } + + public ByteOrder order() + { + return this.a.order(); + } + + public ByteBuf order(ByteOrder byteorder) + { + return this.a.order(byteorder); + } + + public ByteBuf unwrap() + { + return this.a.unwrap(); + } + + public boolean isDirect() + { + return this.a.isDirect(); + } + + public int readerIndex() + { + return this.a.readerIndex(); + } + + public ByteBuf readerIndex(int i) + { + return this.a.readerIndex(i); + } + + public int writerIndex() + { + return this.a.writerIndex(); + } + + public ByteBuf writerIndex(int i) + { + return this.a.writerIndex(i); + } + + public ByteBuf setIndex(int i, int j) + { + return this.a.setIndex(i, j); + } + + public int readableBytes() + { + return this.a.readableBytes(); + } + + public int writableBytes() + { + return this.a.writableBytes(); + } + + public int maxWritableBytes() + { + return this.a.maxWritableBytes(); + } + + public boolean isReadable() + { + return this.a.isReadable(); + } + + public boolean isReadable(int i) + { + return this.a.isReadable(i); + } + + public boolean isWritable() + { + return this.a.isWritable(); + } + + public boolean isWritable(int i) + { + return this.a.isWritable(i); + } + + public ByteBuf clear() + { + return this.a.clear(); + } + + public ByteBuf markReaderIndex() + { + return this.a.markReaderIndex(); + } + + public ByteBuf resetReaderIndex() + { + return this.a.resetReaderIndex(); + } + + public ByteBuf markWriterIndex() + { + return this.a.markWriterIndex(); + } + + public ByteBuf resetWriterIndex() + { + return this.a.resetWriterIndex(); + } + + public ByteBuf discardReadBytes() + { + return this.a.discardReadBytes(); + } + + public ByteBuf discardSomeReadBytes() + { + return this.a.discardSomeReadBytes(); + } + + public ByteBuf ensureWritable(int i) + { + return this.a.ensureWritable(i); + } + + public int ensureWritable(int i, boolean flag) + { + return this.a.ensureWritable(i, flag); + } + + public boolean getBoolean(int i) + { + return this.a.getBoolean(i); + } + + public byte getByte(int i) + { + return this.a.getByte(i); + } + + public short getUnsignedByte(int i) + { + return this.a.getUnsignedByte(i); + } + + public short getShort(int i) + { + return this.a.getShort(i); + } + + public int getUnsignedShort(int i) + { + return this.a.getUnsignedShort(i); + } + + public int getMedium(int i) + { + return this.a.getMedium(i); + } + + public int getUnsignedMedium(int i) + { + return this.a.getUnsignedMedium(i); + } + + public int getInt(int i) + { + return this.a.getInt(i); + } + + public long getUnsignedInt(int i) + { + return this.a.getUnsignedInt(i); + } + + public long getLong(int i) + { + return this.a.getLong(i); + } + + public char getChar(int i) + { + return this.a.getChar(i); + } + + public float getFloat(int i) + { + return this.a.getFloat(i); + } + + public double getDouble(int i) + { + return this.a.getDouble(i); + } + + public ByteBuf getBytes(int i, ByteBuf bytebuf) + { + return this.a.getBytes(i, bytebuf); + } + + public ByteBuf getBytes(int i, ByteBuf bytebuf, int j) + { + return this.a.getBytes(i, bytebuf, j); + } + + public ByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) + { + return this.a.getBytes(i, bytebuf, j, k); + } + + public ByteBuf getBytes(int i, byte[] abyte) + { + return this.a.getBytes(i, abyte); + } + + public ByteBuf getBytes(int i, byte[] abyte, int j, int k) + { + return this.a.getBytes(i, abyte, j, k); + } + + public ByteBuf getBytes(int i, ByteBuffer bytebuffer) + { + return this.a.getBytes(i, bytebuffer); + } + + public ByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException + { // CraftBukkit - throws IOException + return this.a.getBytes(i, outputstream, j); + } + + public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException + { // CraftBukkit - throws IOException + return this.a.getBytes(i, gatheringbytechannel, j); + } + + public ByteBuf setBoolean(int i, boolean flag) + { + return this.a.setBoolean(i, flag); + } + + public ByteBuf setByte(int i, int j) + { + return this.a.setByte(i, j); + } + + public ByteBuf setShort(int i, int j) + { + return this.a.setShort(i, j); + } + + public ByteBuf setMedium(int i, int j) + { + return this.a.setMedium(i, j); + } + + public ByteBuf setInt(int i, int j) + { + return this.a.setInt(i, j); + } + + public ByteBuf setLong(int i, long j) + { + return this.a.setLong(i, j); + } + + public ByteBuf setChar(int i, int j) + { + return this.a.setChar(i, j); + } + + public ByteBuf setFloat(int i, float f) + { + return this.a.setFloat(i, f); + } + + public ByteBuf setDouble(int i, double d0) + { + return this.a.setDouble(i, d0); + } + + public ByteBuf setBytes(int i, ByteBuf bytebuf) + { + return this.a.setBytes(i, bytebuf); + } + + public ByteBuf setBytes(int i, ByteBuf bytebuf, int j) + { + return this.a.setBytes(i, bytebuf, j); + } + + public ByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) + { + return this.a.setBytes(i, bytebuf, j, k); + } + + public ByteBuf setBytes(int i, byte[] abyte) + { + return this.a.setBytes(i, abyte); + } + + public ByteBuf setBytes(int i, byte[] abyte, int j, int k) + { + return this.a.setBytes(i, abyte, j, k); + } + + public ByteBuf setBytes(int i, ByteBuffer bytebuffer) + { + return this.a.setBytes(i, bytebuffer); + } + + public int setBytes(int i, InputStream inputstream, int j) throws IOException + { // CraftBukkit - throws IOException + return this.a.setBytes(i, inputstream, j); + } + + public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException + { // CraftBukkit - throws IOException + return this.a.setBytes(i, scatteringbytechannel, j); + } + + public ByteBuf setZero(int i, int j) + { + return this.a.setZero(i, j); + } + + public boolean readBoolean() + { + return this.a.readBoolean(); + } + + public byte readByte() + { + return this.a.readByte(); + } + + public short readUnsignedByte() + { + return this.a.readUnsignedByte(); + } + + public short readShort() + { + return this.a.readShort(); + } + + public int readUnsignedShort() + { + return this.a.readUnsignedShort(); + } + + public int readMedium() + { + return this.a.readMedium(); + } + + public int readUnsignedMedium() + { + return this.a.readUnsignedMedium(); + } + + public int readInt() + { + return this.a.readInt(); + } + + public long readUnsignedInt() + { + return this.a.readUnsignedInt(); + } + + public long readLong() + { + return this.a.readLong(); + } + + public char readChar() + { + return this.a.readChar(); + } + + public float readFloat() + { + return this.a.readFloat(); + } + + public double readDouble() + { + return this.a.readDouble(); + } + + public ByteBuf readBytes(int i) + { + return this.a.readBytes(i); + } + + public ByteBuf readSlice(int i) + { + return this.a.readSlice(i); + } + + public ByteBuf readBytes(ByteBuf bytebuf) + { + return this.a.readBytes(bytebuf); + } + + public ByteBuf readBytes(ByteBuf bytebuf, int i) + { + return this.a.readBytes(bytebuf, i); + } + + public ByteBuf readBytes(ByteBuf bytebuf, int i, int j) + { + return this.a.readBytes(bytebuf, i, j); + } + + public ByteBuf readBytes(byte[] abyte) + { + return this.a.readBytes(abyte); + } + + public ByteBuf readBytes(byte[] abyte, int i, int j) + { + return this.a.readBytes(abyte, i, j); + } + + public ByteBuf readBytes(ByteBuffer bytebuffer) + { + return this.a.readBytes(bytebuffer); + } + + public ByteBuf readBytes(OutputStream outputstream, int i) throws IOException + { // CraftBukkit - throws IOException + return this.a.readBytes(outputstream, i); + } + + public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException + { // CraftBukkit - throws IOException + return this.a.readBytes(gatheringbytechannel, i); + } + + public ByteBuf skipBytes(int i) + { + return this.a.skipBytes(i); + } + + public ByteBuf writeBoolean(boolean flag) + { + return this.a.writeBoolean(flag); + } + + public ByteBuf writeByte(int i) + { + return this.a.writeByte(i); + } + + public ByteBuf writeShort(int i) + { + return this.a.writeShort(i); + } + + public ByteBuf writeMedium(int i) + { + return this.a.writeMedium(i); + } + + public ByteBuf writeInt(int i) + { + return this.a.writeInt(i); + } + + public ByteBuf writeLong(long i) + { + return this.a.writeLong(i); + } + + public ByteBuf writeChar(int i) + { + return this.a.writeChar(i); + } + + public ByteBuf writeFloat(float f) + { + return this.a.writeFloat(f); + } + + public ByteBuf writeDouble(double d0) + { + return this.a.writeDouble(d0); + } + + public ByteBuf writeBytes(ByteBuf bytebuf) + { + return this.a.writeBytes(bytebuf); + } + + public ByteBuf writeBytes(ByteBuf bytebuf, int i) + { + return this.a.writeBytes(bytebuf, i); + } + + public ByteBuf writeBytes(ByteBuf bytebuf, int i, int j) + { + return this.a.writeBytes(bytebuf, i, j); + } + + public ByteBuf writeBytes(byte[] abyte) + { + return this.a.writeBytes(abyte); + } + + public ByteBuf writeBytes(byte[] abyte, int i, int j) + { + return this.a.writeBytes(abyte, i, j); + } + + public ByteBuf writeBytes(ByteBuffer bytebuffer) + { + return this.a.writeBytes(bytebuffer); + } + + public int writeBytes(InputStream inputstream, int i) throws IOException + { // CraftBukkit - throws IOException + return this.a.writeBytes(inputstream, i); + } + + public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException + { // CraftBukkit - throws IOException + return this.a.writeBytes(scatteringbytechannel, i); + } + + public ByteBuf writeZero(int i) + { + return this.a.writeZero(i); + } + + public int indexOf(int i, int j, byte b0) + { + return this.a.indexOf(i, j, b0); + } + + public int bytesBefore(byte b0) + { + return this.a.bytesBefore(b0); + } + + public int bytesBefore(int i, byte b0) + { + return this.a.bytesBefore(i, b0); + } + + public int bytesBefore(int i, int j, byte b0) + { + return this.a.bytesBefore(i, j, b0); + } + + public int forEachByte(ByteBufProcessor bytebufprocessor) + { + return this.a.forEachByte(bytebufprocessor); + } + + public int forEachByte(int i, int j, ByteBufProcessor bytebufprocessor) + { + return this.a.forEachByte(i, j, bytebufprocessor); + } + + public int forEachByteDesc(ByteBufProcessor bytebufprocessor) + { + return this.a.forEachByteDesc(bytebufprocessor); + } + + public int forEachByteDesc(int i, int j, ByteBufProcessor bytebufprocessor) + { + return this.a.forEachByteDesc(i, j, bytebufprocessor); + } + + public ByteBuf copy() + { + return this.a.copy(); + } + + public ByteBuf copy(int i, int j) + { + return this.a.copy(i, j); + } + + public ByteBuf slice() + { + return this.a.slice(); + } + + public ByteBuf slice(int i, int j) + { + return this.a.slice(i, j); + } + + public ByteBuf duplicate() + { + return this.a.duplicate(); + } + + public int nioBufferCount() + { + return this.a.nioBufferCount(); + } + + public ByteBuffer nioBuffer() + { + return this.a.nioBuffer(); + } + + public ByteBuffer nioBuffer(int i, int j) + { + return this.a.nioBuffer(i, j); + } + + public ByteBuffer internalNioBuffer(int i, int j) + { + return this.a.internalNioBuffer(i, j); + } + + public ByteBuffer[] nioBuffers() + { + return this.a.nioBuffers(); + } + + public ByteBuffer[] nioBuffers(int i, int j) + { + return this.a.nioBuffers(i, j); + } + + public boolean hasArray() + { + return this.a.hasArray(); + } + + public byte[] array() + { + return this.a.array(); + } + + public int arrayOffset() + { + return this.a.arrayOffset(); + } + + public boolean hasMemoryAddress() + { + return this.a.hasMemoryAddress(); + } + + public long memoryAddress() + { + return this.a.memoryAddress(); + } + + public String toString(Charset charset) + { + return this.a.toString(charset); + } + + public String toString(int i, int j, Charset charset) + { + return this.a.toString(i, j, charset); + } + + public int hashCode() + { + return this.a.hashCode(); + } + + public boolean equals(Object object) + { + return this.a.equals(object); + } + + public int compareTo(ByteBuf bytebuf) + { + return this.a.compareTo(bytebuf); + } + + public String toString() + { + return this.a.toString(); + } + + public ByteBuf retain(int i) + { + return this.a.retain(i); + } + + public ByteBuf retain() + { + return this.a.retain(); + } + + public int refCnt() + { + return this.a.refCnt(); + } + + public boolean release() + { + return this.a.release(); + } + + public boolean release(int i) + { + return this.a.release(i); + } +}