Merge branch 'SarahsAwesomeBugFixes'

Conflicts:
	Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java
This commit is contained in:
Mini-Chiss 2015-08-07 21:48:35 +02:00
commit 090c1f135d
23 changed files with 1076 additions and 229 deletions

View File

@ -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),

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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<CosmeticManager, CosmeticShop>
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<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
{
public void run()

View File

@ -1143,10 +1143,11 @@ 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<Player> playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();)
{
Player player = playerIterator.next();
@ -1155,6 +1156,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
playerIterator.remove();
}
}
catch (Exception exception) {}
}
}
}

View File

@ -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);
public BlockFace getSleepingDirection()
{
return _sleeping;
}
if(_sneaking)
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)));
else
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))));
}
/**
* 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 PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation)
{
Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30));
loc.setY(Math.max(loc.getY(), 0));
public void setSneaking(boolean sneaking)
{
_sneaking = sneaking;
}
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 Packet getOldInfoPacket(boolean add)
{
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo();
return packet;
}
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;
}
@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 playerInfo;
}
return packet;
}
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();
}
}

View File

@ -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<PersonalServerManager>
@ -19,6 +21,11 @@ public class HostEventServerCommand extends CommandBase<PersonalServerManager>
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);
}
}

View File

@ -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<PersonalServerManager>
@ -19,6 +21,11 @@ public class HostServerCommand extends CommandBase<PersonalServerManager>
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);
}
}

View File

@ -177,4 +177,9 @@ public class PersonalServerManager extends MiniPlugin
}
});
}
public CoreClientManager getClients()
{
return _clientManager;
}
}

View File

@ -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;

View File

@ -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<TreasureManager, TreasureShop>(
_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
{

View File

@ -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);

View File

@ -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<HubClient>
{
// Snowman!
@ -127,6 +129,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
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<HubClient>
//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<HubClient>
_statsManager = statsManager;
_achievementManager = achievementManager;
_achievementManager.setGiveInterfaceItem(true);
_packetHandler = packetHandler;
new NotificationManager(getPlugin(), clientManager);
@ -345,6 +349,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
addCommand(new GadgetToggle(this));
addCommand(new NewsCommand(this));
addCommand(new GameModeCommand(this));
addCommand(new DisguiseCommand(this));
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -653,6 +658,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
Rank rank = GetClients().Get(player).GetRank();
if(GetClients().Get(player).isDisguised())
rank = GetClients().Get(player).getDisguisedRank();
boolean ownsUltra = _donationManager.Get(player.getName()).OwnsUltraPackage();
//Level Prefix
@ -1081,4 +1089,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false)));
}
}
public PacketHandler getPacketHandler()
{
return _packetHandler;
}
}

View File

@ -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<HubManager> implements Listener
{
private NautHashMap<Player, GameProfile> _disguisedPlayers = new NautHashMap<>();
private NautHashMap<Player, String> _disguisedPlayersNames = new NautHashMap<>();
private NautHashMap<Player, DisguisePlayer> _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 <name> 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 <name>");
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);
}
}
}
}
}
}

View File

@ -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;
}

View File

@ -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<ArcadeManager>
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<ArcadeManager> implements Listener
{
public DisguiseCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, "disguise");
}
@Override
public void Execute(final Player caller, final String[] args)
private NautHashMap<Player, GameProfile> _disguisedPlayers = new NautHashMap<>();
private NautHashMap<Player, String> _disguisedPlayersNames = new NautHashMap<>();
private NautHashMap<Player, DisguisePlayer> _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)
{
if (args.length == 0)
if(!Plugin.GetDisguise().isDisguised(caller))
{
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise <name> 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())
{
UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise <name>");
return;
for(Team team : other.getScoreboard().getTeams())
{
team.removePlayer(caller);
}
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
{
@Override
public void run()
{
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;
}
}}
);
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 <name>");
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], 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))
{
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);
}
}
}
}
}
}

View File

@ -10,7 +10,7 @@ public class KitUnlockCommand extends CommandBase<ArcadeManager>
{
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

View File

@ -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
{

View File

@ -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");
}
}

View File

@ -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;
@ -157,6 +163,14 @@ public class GameGemManager implements Listener
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)
total += (int)(earned * game.GetGemBoostAmount());
@ -179,6 +193,31 @@ 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<String,GemData> gems, boolean give)