diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 73dba54e8..74e648808 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -18,6 +18,7 @@ public enum Rank HELPER("Trainee", ChatColor.DARK_AQUA), MAPLEAD("MapLead", ChatColor.DARK_PURPLE), MAPDEV("Builder", ChatColor.BLUE), + MEDIA("Media", ChatColor.BLUE), EVENT("Event", ChatColor.WHITE), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java b/Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java new file mode 100644 index 000000000..3ddbb0f50 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/NCPDataManFix.java @@ -0,0 +1,10 @@ +package mineplex.core; + +import fr.neatmonster.nocheatplus.config.ConfigManager; + +public class NCPDataManFix +{ + public NCPDataManFix() { + ConfigManager.getConfigFile().set("data.consistencychecks.suppresswarnings", true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index ebec4be13..df6717c6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -8,8 +8,11 @@ public class CoreClient { private int _accountId = -1; private String _name; + private String _disguisedAs; private Player _player; private Rank _rank; + private Rank _disguisedRank; + private boolean _disguised; public CoreClient(Player player) { @@ -62,4 +65,34 @@ public class CoreClient { _rank = rank; } + + public String getDisguisedAs() + { + return _disguisedAs; + } + + public void setDisguisedAs(String originalName) + { + this._disguisedAs = originalName; + } + + /** + * Only use this method if the client is actually disguised! + * @return + */ + public Rank getDisguisedRank() { + return _disguisedRank; + } + + public void setDisguisedRank(Rank disguisedRank) { + this._disguisedRank = disguisedRank; + } + + public boolean isDisguised() { + return _disguised; + } + + public void setDisguised(boolean disguised) { + this._disguised = disguised; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 9d11610a5..f2b2a0016 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -118,16 +118,19 @@ public class CoreClientManager extends MiniPlugin { synchronized(_clientLock) { + for(CoreClient client : _clientList.values()) + { + if(client.getDisguisedAs() != null) + if(client.getDisguisedAs().equalsIgnoreCase(name)) + return client; + } return _clientList.get(name); } } public CoreClient Get(Player player) { - synchronized(_clientLock) - { - return _clientList.get(player.getName()); - } + return Get(player.getName()); } public int getPlayerCountIncludingConnecting() @@ -248,7 +251,7 @@ public class CoreClientManager extends MiniPlugin }); } - private boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) + public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { TimingManager.start(client.GetPlayerName() + " LoadClient Total."); long timeStart = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 82808334e..9279f5bd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -144,7 +144,7 @@ public class Chat extends MiniPlugin @EventHandler public void lagTest(PlayerCommandPreprocessEvent event) { - if (event.getMessage().equals("lag") || event.getMessage().equals("ping")) + if (event.getMessage().equals("/lag") || event.getMessage().equals("/ping")) { event.getPlayer().sendMessage(F.main(getName(), "PONG!")); event.setCancelled(true); 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 3024ff2f4..af8b2e9f8 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 @@ -11,6 +11,8 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.ActivateGadgetButton; @@ -121,6 +123,11 @@ public class GadgetPage extends ShopPageBase public void purchaseGadget(final Player player, final Gadget gadget) { + if(getClientManager().Get(player).isDisguised()) + { + UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); + return; + } getShop().openPageForPlayer(getPlayer(), new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() { public void run() @@ -149,7 +156,7 @@ public class GadgetPage extends ShopPageBase } public void handleRightClick(Player player, Gadget gadget) - { + { if (gadget instanceof ItemGadget) { purchaseGadget(player, gadget); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 521812057..86a78df78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -1143,18 +1143,20 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity(); + if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid) disguiseIterator.remove(); - else - { + + try{ for (Iterator playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();) { Player player = playerIterator.next(); - + if (!player.isOnline() || !player.isValid()) playerIterator.remove(); } } + catch (Exception exception) {} } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index 33126f3d6..5fcff15ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -2,140 +2,152 @@ package mineplex.core.disguise.disguises; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.spigotmc.ProtocolData; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayInSettings; import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo; import net.minecraft.util.com.mojang.authlib.GameProfile; public class DisguisePlayer extends DisguiseHuman { - private GameProfile _profile; - private boolean _sneaking; - private BlockFace _sleeping; + private GameProfile _profile; + private boolean _sneaking; + private BlockFace _sleeping; - public DisguisePlayer(org.bukkit.entity.Entity entity) + public DisguisePlayer(org.bukkit.entity.Entity entity) + { + super(entity); + } + + public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile) + { + this(entity); + + setProfile(profile); + } + + public void setProfile(GameProfile profile) + { + GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName()); + + newProfile.getProperties().putAll(profile.getProperties()); + + _profile = newProfile; + } + + public BlockFace getSleepingDirection() + { + return _sleeping; + } + + /** + * Don't use this if the disguise is already on as it will not work the way + * you want it to. Contact libraryaddict if you need that added. + */ + public void setSleeping(BlockFace sleeping) + { + _sleeping = sleeping; + } + + public void setSneaking(boolean sneaking) + { + _sneaking = sneaking; + } + + public boolean getSneaking() + { + return _sneaking; + } + + public Packet getOldInfoPacket(boolean add) + { + PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(); + + if(Entity instanceof Player) { - super(entity); + playerInfo.username = Entity.getName(); + playerInfo.action = add ? 0 : 4; + playerInfo.ping = 90; + playerInfo.player = ((CraftPlayer) (Player) Entity).getProfile(); + playerInfo.gamemode = 0; } - public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile) - { - this(entity); + return playerInfo; + } - setProfile(profile); - } + public Packet getNewInfoPacket(boolean add) + { + PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); + newDisguiseInfo.username = _profile.getName(); + newDisguiseInfo.action = add ? 0 : 4; + newDisguiseInfo.ping = 90; + newDisguiseInfo.player = _profile; + newDisguiseInfo.gamemode = 0; - public void setProfile(GameProfile profile) - { - GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName()); + return newDisguiseInfo; + } - newProfile.getProperties().putAll(profile.getProperties()); + @SuppressWarnings("static-access") + @Override + public void UpdateDataWatcher() + { + super.UpdateDataWatcher(); - _profile = newProfile; - } + byte b0 = DataWatcher.getByte(0); + DataWatcher.watch(10, (Object)(byte)0x40); + + if(_sneaking) + DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1))); + else + DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1)))); + } - public BlockFace getSleepingDirection() - { - return _sleeping; - } + public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) + { + Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30)); + loc.setY(Math.max(loc.getY(), 0)); - /** - * Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need - * that added. - */ - public void setSleeping(BlockFace sleeping) - { - _sleeping = sleeping; - } + PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); + packet.a = Entity.getId(); + packet.b = _profile; + packet.c = MathHelper.floor(loc.getX() * 32.0D); + packet.d = MathHelper.floor(loc.getY() * 32.0D); + packet.e = MathHelper.floor(loc.getZ() * 32.0D); + packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F)); + packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)); + packet.i = DataWatcher; - public void setSneaking(boolean sneaking) - { - _sneaking = sneaking; - } + return packet; + } - public Packet getOldInfoPacket(boolean add) - { - PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(); + @Override + public PacketPlayOutNamedEntitySpawn GetSpawnPacket() + { + PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); + packet.a = Entity.getId(); + packet.b = _profile; + packet.c = MathHelper.floor(Entity.locX * 32.0D); + packet.d = MathHelper.floor(Entity.locY * 32.0D); + packet.e = MathHelper.floor(Entity.locZ * 32.0D); + packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); + packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); + packet.i = DataWatcher; - if (Entity instanceof Player) - { - playerInfo.username = Entity.getName(); - playerInfo.action = add ? 0 : 4; - playerInfo.ping = 90; - playerInfo.player = ((CraftPlayer) (Player) Entity).getProfile(); - playerInfo.gamemode = 0; - } + return packet; + } - return playerInfo; - } - - public Packet getNewInfoPacket(boolean add) - { - PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); - newDisguiseInfo.username = _profile.getName(); - newDisguiseInfo.action = add ? 0 : 4; - newDisguiseInfo.ping = 90; - newDisguiseInfo.player = _profile; - newDisguiseInfo.gamemode = 0; - - return newDisguiseInfo; - } - - @Override - public void UpdateDataWatcher() - { - super.UpdateDataWatcher(); - - byte b0 = DataWatcher.getByte(0); - - if (_sneaking) - DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1))); - else - DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1)))); - } - - public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) - { - Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30)); - loc.setY(Math.max(loc.getY(), 0)); - - PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); - packet.b = _profile; - packet.c = MathHelper.floor(loc.getX() * 32.0D); - packet.d = MathHelper.floor(loc.getY() * 32.0D); - packet.e = MathHelper.floor(loc.getZ() * 32.0D); - packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F)); - packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)); - packet.i = DataWatcher; - - return packet; - } - - @Override - public PacketPlayOutNamedEntitySpawn GetSpawnPacket() - { - PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); - packet.b = _profile; - packet.c = MathHelper.floor(Entity.locX * 32.0D); - packet.d = MathHelper.floor(Entity.locY * 32.0D); - packet.e = MathHelper.floor(Entity.locZ * 32.0D); - packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.i = DataWatcher; - - return packet; - } - - public String getName() - { - return _profile.getName(); - } + public String getName() + { + return _profile.getName(); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index aaad37d68..71f7ea718 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -205,7 +205,7 @@ public class DonationManager extends MiniDbClientPlugin } public void RewardCoins(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) - { + { _repository.rewardCoins(new Callback() { public void run(Boolean success) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 566c95a04..65d95c26a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; public class HostEventServerCommand extends CommandBase @@ -19,6 +21,11 @@ public class HostEventServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false)) return; + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + return; + } Plugin.hostServer(caller, caller.getName(), true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index b09c4cc54..dbf091299 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; public class HostServerCommand extends CommandBase @@ -19,6 +21,11 @@ public class HostServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Server", 30000, false, false)) return; + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + return; + } Plugin.hostServer(caller, caller.getName(), false); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 466a26d50..2030044e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -177,4 +177,9 @@ public class PersonalServerManager extends MiniPlugin } }); } + + public CoreClientManager getClients() + { + return _clientManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index d81122d3a..ef9fbad63 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -1,15 +1,23 @@ package mineplex.core.stats; +import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.util.com.mojang.authlib.GameProfile; + import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 1e932656f..e1afeaf64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -4,7 +4,10 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.account.event.GetClientEvent; import mineplex.core.common.CurrencyType; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.inventory.InventoryManager; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ConfirmationPage; @@ -36,6 +39,11 @@ public class BuyChestButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if(_inventoryManager.getClientManager().Get(player).isDisguised()) + { + UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); + return; + } _page.getShop().openPageForPlayer(player, new ConfirmationPage( _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 60dcb8d55..b0bc33c67 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -122,7 +122,7 @@ public class Hub extends JavaPlugin implements IRelation PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this)); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), packetHandler); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 9c3042ee5..dc6b3fe59 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -3,6 +3,70 @@ package mineplex.hub; import java.util.ArrayList; import java.util.HashMap; +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.benefit.BenefitManager; +import mineplex.core.blockrestore.BlockRestore; +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; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.notifier.NotificationManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.pet.PetManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.stats.StatsManager; +import mineplex.core.task.TaskManager; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.commands.DisguiseCommand; +import mineplex.hub.commands.ForcefieldRadius; +import mineplex.hub.commands.GadgetToggle; +import mineplex.hub.commands.GameModeCommand; +import mineplex.hub.commands.NewsCommand; +import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HubVisibilityManager; +import mineplex.hub.modules.JumpManager; +import mineplex.hub.modules.NewsManager; +import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.SoccerManager; +import mineplex.hub.modules.TextManager; +import mineplex.hub.modules.WorldManager; +import mineplex.hub.poll.PollManager; +import mineplex.hub.tutorial.TutorialManager; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -39,68 +103,6 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementManager; -import mineplex.core.aprilfools.AprilFoolsManager; -import mineplex.core.benefit.BenefitManager; -import mineplex.core.blockrestore.BlockRestore; -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; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseSlime; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetActivateEvent; -import mineplex.core.gadget.event.GadgetCollideEntityEvent; -import mineplex.core.hologram.HologramManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.message.PrivateMessageEvent; -import mineplex.core.mount.MountManager; -import mineplex.core.mount.event.MountActivateEvent; -import mineplex.core.notifier.NotificationManager; -import mineplex.core.party.Party; -import mineplex.core.party.PartyManager; -import mineplex.core.pet.PetManager; -import mineplex.core.portal.Portal; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.projectile.ProjectileManager; -import mineplex.core.stats.StatsManager; -import mineplex.core.task.TaskManager; -import mineplex.core.treasure.TreasureManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.commands.ForcefieldRadius; -import mineplex.hub.commands.GadgetToggle; -import mineplex.hub.commands.GameModeCommand; -import mineplex.hub.commands.NewsCommand; -import mineplex.hub.modules.ForcefieldManager; -import mineplex.hub.modules.HubVisibilityManager; -import mineplex.hub.modules.JumpManager; -import mineplex.hub.modules.NewsManager; -import mineplex.hub.modules.ParkourManager; -import mineplex.hub.modules.SoccerManager; -import mineplex.hub.modules.TextManager; -import mineplex.hub.modules.WorldManager; -import mineplex.hub.poll.PollManager; -import mineplex.hub.tutorial.TutorialManager; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; -import mineplex.minecraft.game.core.condition.ConditionManager; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! @@ -127,6 +129,7 @@ public class HubManager extends MiniClientPlugin private AchievementManager _achievementManager; private TreasureManager _treasureManager; private PetManager _petManager; + private PacketHandler _packetHandler; private Location _spawn; private int _scoreboardTick = 0; @@ -147,7 +150,7 @@ public class HubManager extends MiniClientPlugin //Admin private boolean _gadgetsEnabled = true; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, PacketHandler packetHandler) { super("Hub Manager", plugin); @@ -194,6 +197,7 @@ public class HubManager extends MiniClientPlugin _statsManager = statsManager; _achievementManager = achievementManager; _achievementManager.setGiveInterfaceItem(true); + _packetHandler = packetHandler; new NotificationManager(getPlugin(), clientManager); @@ -345,6 +349,7 @@ public class HubManager extends MiniClientPlugin addCommand(new GadgetToggle(this)); addCommand(new NewsCommand(this)); addCommand(new GameModeCommand(this)); + addCommand(new DisguiseCommand(this)); } @EventHandler(priority = EventPriority.HIGHEST) @@ -652,6 +657,9 @@ public class HubManager extends MiniClientPlugin playerName = AprilFoolsManager.Instance.getName(player); Rank rank = GetClients().Get(player).GetRank(); + + if(GetClients().Get(player).isDisguised()) + rank = GetClients().Get(player).getDisguisedRank(); boolean ownsUltra = _donationManager.Get(player.getName()).OwnsUltraPackage(); @@ -1081,4 +1089,9 @@ public class HubManager extends MiniClientPlugin UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); } } + + public PacketHandler getPacketHandler() + { + return _packetHandler; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java new file mode 100644 index 000000000..0402366e7 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -0,0 +1,355 @@ +package mineplex.hub.commands; + +import java.lang.reflect.Field; +import java.util.UUID; + +import mineplex.core.NCPDataManFix; +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.ProfileLoader; +import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.donation.Donor; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation; +import net.minecraft.util.com.mojang.authlib.GameProfile; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scoreboard.Team; + +import com.mysql.jdbc.BalanceStrategy; + +public class DisguiseCommand extends CommandBase implements Listener +{ + + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + + public DisguiseCommand(HubManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] + { + Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if(args == null) + { + if(!Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); + + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(caller, playerName); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(caller)) + { + team.removePlayer(caller); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + return; + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.Has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0]); + + Plugin.GetGadget().RemoveItem(caller); + + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(player)) + { + team.removePlayer(player); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } + } + + public void changeName(Player player, String changedName) + { + try + { + Field name = GameProfile.class.getDeclaredField("name"); + Field declaredProfile = EntityHuman.class.getDeclaredField("i"); + declaredProfile.setAccessible(true); + GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } + } + } + +} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index e892c5f75..6e1815456 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -545,12 +545,19 @@ public class ClientClass private boolean ValidSkill(String skillName, ISkill skill, SkillType expectedType) { + try + { if (skillName == null || skill == null || expectedType == null) return false; if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.OwnsUnknownPackage("Champions " + skillName) && !_client.GetRank().Has(Rank.ULTRA) && !_donor.OwnsUnknownPackage("Competitive ULTRA")))) return false; + } catch (NullPointerException ex) + { + System.out.println("Somehow a Nullpointer happens here if someone uses /disguise.\n" + + "shouldnt be a problem because Youtube+ can have all skills."); + } return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index f45344d2a..7c32ed36a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -1,61 +1,374 @@ package nautilus.game.arcade.command; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import net.minecraft.util.com.mojang.authlib.GameProfile; +import java.lang.reflect.Field; +import java.util.UUID; +import mineplex.core.NCPDataManFix; +import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation; +import net.minecraft.util.com.mojang.authlib.GameProfile; -public class DisguiseCommand extends CommandBase +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.scoreboard.Team; + +public class DisguiseCommand extends CommandBase implements Listener { - public DisguiseCommand(ArcadeManager plugin) + + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + + public DisguiseCommand(ArcadeManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] + { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if(args == null) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, "disguise"); + if(!Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); + + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + team.removePlayer(caller); + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + return; } - @Override - public void Execute(final Player caller, final String[] args) + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() { - if (args.length == 0) + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + for(Player other : UtilServer.getPlayers()) { - @Override - public void run() + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.Has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0], true); + + Plugin.getCosmeticManager().getGadgetManager().RemoveItem(caller); + + Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) + { + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + } + if(other.getScoreboard().getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) + { + if(other.getScoreboard() + .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .getPlayers().contains(player)) { - try - { - final GameProfile profile = new ProfileLoader(UUIDFetcher.getUUIDOf(args[0]).toString(), args[0]).loadProfile(); - - Bukkit.getServer().getScheduler().runTask(Plugin.getPlugin(), new Runnable() - { - public void run() - { - DisguisePlayer playerDisguise = new DisguisePlayer(caller, profile); - Plugin.GetDisguise().disguise(playerDisguise); - - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } - }); - } - catch (Exception e) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - }} - ); + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .removePlayer(player); + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).getDisguisedRank().Name + + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); + } + } + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); } + } + + public void changeName(final Player player, String changedName, boolean skin) + { + try + { + GameProfile gameProfile = ((CraftPlayer) player).getProfile(); + + Field name = GameProfile.class.getDeclaredField("name"); + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName, true); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler + public void onPlayerLeftClick(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(player)) + { + EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + human.world.broadcastEntityEffect(human, (byte) 0); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java index 73cc210e7..cae387d71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java @@ -10,7 +10,7 @@ public class KitUnlockCommand extends CommandBase { public KitUnlockCommand(ArcadeManager plugin) { - super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, new String[] {"youtube", "twitch", "kits"}); + super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"}); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 1945b3afe..075c2afdb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -13,6 +14,8 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; import org.bukkit.entity.Player; @@ -55,6 +58,8 @@ import nautilus.game.arcade.managers.GameLobbyManager; import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.stats.*; import nautilus.game.arcade.world.WorldData; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.util.com.mojang.authlib.GameProfile; public abstract class Game implements Listener { @@ -671,7 +676,7 @@ public abstract class Game implements Listener { if (!countAmount && gems < 1) gems = 1; - + if (GetGems(player).containsKey(reason) && multipleAllowed) { GetGems(player).get(reason).AddGems(gems); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index 6eb27a139..4aed91a8a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -2,14 +2,14 @@ package nautilus.game.arcade.managers; import java.util.Iterator; +import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.party.Party; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -56,6 +56,18 @@ public class GameChatManager implements Listener dead = C.cGray + "Dead "; Rank rank = Manager.GetClients().Get(sender).GetRank(); + String disguiseTag = ""; + if(Manager.GetClients().Get(sender).isDisguised()) + { + CoreClient cc = Manager.GetClients().Get(sender); + rank = cc.getDisguisedRank(); + + if(!cc.GetRank().Has(Rank.JNR_DEV)) + { + disguiseTag = ChatColor.BLACK + " "; + } + } + boolean ownsUltra = false; if (Manager.GetGame() != null) @@ -110,7 +122,7 @@ public class GameChatManager implements Listener } //Base Format - event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); + event.setFormat(disguiseTag + dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); //Public/Private (Not If Player Dead) if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Live) @@ -126,13 +138,13 @@ public class GameChatManager implements Listener if (event.getMessage().charAt(0) == '@') { event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(disguiseTag + C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); } //All Chat else { globalMessage = true; - event.setFormat(dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index dce24d8da..07bb93f7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -1,7 +1,9 @@ package nautilus.game.arcade.managers; +import java.lang.reflect.Field; import java.util.HashMap; +import mineplex.core.account.event.GetClientEvent; import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -18,8 +20,12 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.util.com.mojang.authlib.GameProfile; import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -156,6 +162,14 @@ public class GameGemManager implements Listener earned = (int) (earned * gameMult); int total = earned; + + String oldName = player.getName(); + + if(Manager.GetClients().Get(player).getDisguisedAs() != null) + { + changeName(player, Manager.GetClients().Get(player).GetPlayerName()); + System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName()); + } //Gem Boooster if (game.GemBoosterEnabled) @@ -179,8 +193,33 @@ public class GameGemManager implements Listener //Stats Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total); Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total); + + if(Manager.GetClients().Get(player).getDisguisedAs() != null) + { + changeName(player, oldName); + } + } + private void changeName(Player player, String newName) + { + try + { + Field name = GameProfile.class.getDeclaredField("name"); + Field declaredProfile = EntityHuman.class.getDeclaredField("i"); + declaredProfile.setAccessible(true); + GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity)((CraftPlayer) player)).getHandle()); + + name.setAccessible(true); + name.set(gameProfile, newName); + name.setAccessible(false); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + public void AnnounceGems(Game game, Player player, HashMap gems, boolean give) { if (gems == null)