Merge branch 'master' of ssh://dev.mineplex.com:7999/min/mineplex into feature/report
This commit is contained in:
commit
7ce028203b
@ -0,0 +1,34 @@
|
|||||||
|
package mineplex.core.disguise;
|
||||||
|
|
||||||
|
import mineplex.serverdata.data.Data;
|
||||||
|
|
||||||
|
public class DisguisePlayerBean implements Data
|
||||||
|
{
|
||||||
|
private int _accountID;
|
||||||
|
private String _disguisedPlayer;
|
||||||
|
private String _playerName;
|
||||||
|
public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs)
|
||||||
|
{
|
||||||
|
this._accountID = playerAccountID;
|
||||||
|
this._disguisedPlayer = disguiseAs;
|
||||||
|
this._playerName = playerName;
|
||||||
|
|
||||||
|
}
|
||||||
|
public int getAccountID()
|
||||||
|
{
|
||||||
|
return _accountID;
|
||||||
|
}
|
||||||
|
public String getDisguisedPlayer()
|
||||||
|
{
|
||||||
|
return _disguisedPlayer;
|
||||||
|
}
|
||||||
|
public String getPlayerName()
|
||||||
|
{
|
||||||
|
return _playerName;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getDataId()
|
||||||
|
{
|
||||||
|
return _accountID+_playerName;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package mineplex.core.disguise;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.serverdata.Region;
|
||||||
|
import mineplex.serverdata.redis.RedisDataRepository;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class PlayerDisguiseManager extends MiniPlugin
|
||||||
|
{
|
||||||
|
private CoreClientManager _clients;
|
||||||
|
private RedisDataRepository<DisguisePlayerBean> _redis;
|
||||||
|
public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients)
|
||||||
|
{
|
||||||
|
super("Player Disguise Manager", plugin);
|
||||||
|
this._clients = clients;
|
||||||
|
|
||||||
|
_redis = new RedisDataRepository<DisguisePlayerBean>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDisguisedPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
CoreClient client = _clients.Get(event.getPlayer());
|
||||||
|
if(client.isDisguised())
|
||||||
|
{
|
||||||
|
_redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDisguisedPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
CoreClient client = _clients.Get(event.getPlayer());
|
||||||
|
|
||||||
|
if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(_redis.elementExists(client.getAccountId()+client.GetPlayerName()))
|
||||||
|
{
|
||||||
|
DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName());
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer()));
|
||||||
|
event.setJoinMessage("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(getPlugin(), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerUndisguise(PlayerUndisguiseEvent event)
|
||||||
|
{
|
||||||
|
CoreClient client = _clients.Get(event.getPlayer());
|
||||||
|
_redis.removeElement(client.getAccountId()+client.GetPlayerName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package mineplex.core.disguise;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class PlayerUndisguiseEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private Player _player;
|
||||||
|
public PlayerUndisguiseEvent(Player disguisee)
|
||||||
|
{
|
||||||
|
this._player = disguisee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,6 +10,7 @@ import mineplex.core.common.util.F;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.message.MessageManager;
|
import mineplex.core.message.MessageManager;
|
||||||
|
import mineplex.core.visibility.VisibilityManager;
|
||||||
|
|
||||||
public class AdminCommand extends CommandBase<MessageManager>
|
public class AdminCommand extends CommandBase<MessageManager>
|
||||||
{
|
{
|
||||||
@ -53,6 +54,11 @@ public class AdminCommand extends CommandBase<MessageManager>
|
|||||||
if (!to.equals(caller))
|
if (!to.equals(caller))
|
||||||
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);
|
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);
|
||||||
|
|
||||||
|
if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV))
|
||||||
|
{
|
||||||
|
if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
staff = true;
|
staff = true;
|
||||||
|
|
||||||
//Sound
|
//Sound
|
||||||
|
@ -33,6 +33,7 @@ import mineplex.core.common.util.UtilWorld;
|
|||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.customdata.CustomDataManager;
|
import mineplex.core.customdata.CustomDataManager;
|
||||||
import mineplex.core.disguise.DisguiseManager;
|
import mineplex.core.disguise.DisguiseManager;
|
||||||
|
import mineplex.core.disguise.PlayerDisguiseManager;
|
||||||
import mineplex.core.disguise.disguises.DisguiseSlime;
|
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
@ -249,7 +250,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
// _halloweenManager = new HalloweenSpookinessManager(this);
|
// _halloweenManager = new HalloweenSpookinessManager(this);
|
||||||
|
|
||||||
new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
|
new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
|
||||||
|
new PlayerDisguiseManager(plugin, _clientManager);
|
||||||
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
|
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
|
||||||
// new MailManager(_plugin, notificationManager);
|
// new MailManager(_plugin, notificationManager);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.hub.commands;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.NCPDataManFix;
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
@ -14,17 +13,26 @@ import mineplex.core.common.util.ProfileLoader;
|
|||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.disguise.PlayerUndisguiseEvent;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.core.donation.Donor;
|
|
||||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.hub.HubManager;
|
import mineplex.hub.HubManager;
|
||||||
|
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R3.EnumDifficulty;
|
||||||
|
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
|
||||||
|
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
|
||||||
|
import net.minecraft.server.v1_8_R3.WorldType;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -38,13 +46,12 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mysql.jdbc.BalanceStrategy;
|
|
||||||
|
|
||||||
public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
||||||
{
|
{
|
||||||
@ -55,11 +62,9 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
|
|
||||||
public DisguiseCommand(HubManager plugin)
|
public DisguiseCommand(HubManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.JNR_DEV, new Rank[]
|
super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise");
|
||||||
{
|
|
||||||
Rank.YOUTUBE, Rank.TWITCH }, "disguise");
|
|
||||||
plugin.getPluginManager().registerEvents(this, Plugin.getPlugin());
|
plugin.getPluginManager().registerEvents(this, Plugin.getPlugin());
|
||||||
new NCPDataManFix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,36 +74,57 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
{
|
{
|
||||||
if(!Plugin.GetDisguise().isDisguised(caller))
|
if(!Plugin.GetDisguise().isDisguised(caller))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise <name> first");
|
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise <name> first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
GameProfile profile = _disguisedPlayers.get(caller);
|
||||||
_disguisedPlayers.remove(caller);
|
_disguisedPlayers.remove(caller);
|
||||||
_disguisedPlayerDisguises.remove(caller);
|
_disguisedPlayerDisguises.remove(caller);
|
||||||
Plugin.GetDisguise().undisguise(caller);
|
Plugin.GetDisguise().undisguise(caller);
|
||||||
String playerName = _disguisedPlayersNames.get(caller);
|
String playerName = _disguisedPlayersNames.get(caller);
|
||||||
|
Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller));
|
||||||
|
|
||||||
CoreClient client = Plugin.GetClients().Get(caller);
|
CoreClient client = Plugin.GetClients().Get(caller);
|
||||||
client.setDisguisedRank(null);
|
client.setDisguisedRank(null);
|
||||||
client.setDisguisedAs(null);
|
client.setDisguisedAs(null);
|
||||||
client.setDisguised(false);
|
client.setDisguised(false);
|
||||||
|
|
||||||
changeName(caller, playerName);
|
changeName(caller, playerName, true);
|
||||||
|
|
||||||
|
for(Player other : UtilServer.getPlayers())
|
||||||
|
updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false);
|
||||||
|
|
||||||
|
Field field;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
field = GameProfile.class.getDeclaredField("id");
|
||||||
|
field.setAccessible(true);
|
||||||
|
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||||
|
UUID newUUID = profile.getId();
|
||||||
|
field.set(profile, old);
|
||||||
|
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// removed "due to Kicked for Flying"
|
||||||
|
//PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||||
|
//UtilPlayer.sendPacket(caller, packet);
|
||||||
|
|
||||||
for(Player other : UtilServer.getPlayers())
|
for(Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
for(Team team : other.getScoreboard().getTeams())
|
for(Team team : other.getScoreboard().getTeams())
|
||||||
{
|
|
||||||
if(team.hasPlayer(caller))
|
|
||||||
{
|
{
|
||||||
team.removePlayer(caller);
|
team.removePlayer(caller);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!");
|
UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!"));
|
||||||
return;
|
return;
|
||||||
} catch(Exception ex)
|
} catch(Exception ex)
|
||||||
{
|
{
|
||||||
@ -107,12 +133,10 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
}
|
}
|
||||||
if(args != null && args.length > 1)
|
if(args != null && args.length > 1)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise <name>");
|
UtilPlayer.message(caller, F.main("Disguise", "/disguise <name>"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Rank rank = Plugin.GetClients().Get(caller).GetRank();
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -120,40 +144,41 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
{
|
{
|
||||||
if(Plugin.GetDisguise().isDisguised(caller))
|
if(Plugin.GetDisguise().isDisguised(caller))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first");
|
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(Player other : UtilServer.getPlayers())
|
for(Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
if(other.getName().equalsIgnoreCase(args[0]))
|
if(other.getName().equalsIgnoreCase(args[0]))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_disguisedPlayersNames.containsValue(args[0]))
|
if(_disguisedPlayersNames.containsValue(args[0]))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(args[0].length() > 16)
|
if(args[0].length() > 16)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CoreClient client = Plugin.GetClients().Get(caller);
|
CoreClient client = Plugin.GetClients().Get(caller);
|
||||||
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
|
UUID uuid = UUID.randomUUID();
|
||||||
GameProfile profile = null;
|
GameProfile profile = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
uuid = UUIDFetcher.getUUIDOf("Alex");
|
uuid = UUID.randomUUID();
|
||||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
profile = new ProfileLoader(null, args[0]).loadProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rank otherRank = Rank.ALL;
|
Rank otherRank = Rank.ALL;
|
||||||
@ -164,9 +189,9 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
otherRank = other.GetRank();
|
otherRank = other.GetRank();
|
||||||
} catch(NullPointerException exception)
|
} catch(NullPointerException exception)
|
||||||
{}
|
{}
|
||||||
if(otherRank.has(Rank.TWITCH) && !rank.has(Rank.OWNER))
|
if(otherRank.has(Rank.TWITCH))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!");
|
UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_disguisedPlayers.put(caller, profile);
|
_disguisedPlayers.put(caller, profile);
|
||||||
@ -176,21 +201,100 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
|
|
||||||
client.setDisguisedAs(args[0]);
|
client.setDisguisedAs(args[0]);
|
||||||
|
|
||||||
changeName(caller, args[0]);
|
changeName(caller, args[0], true);
|
||||||
|
|
||||||
Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item);
|
Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item);
|
||||||
|
|
||||||
UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]);
|
// Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller));
|
||||||
|
UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0]));
|
||||||
|
|
||||||
|
Field field;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
field = GameProfile.class.getDeclaredField("id");
|
||||||
|
field.setAccessible(true);
|
||||||
|
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||||
|
UUID newUUID = profile.getId();
|
||||||
|
field.set(profile, old);
|
||||||
|
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||||
|
UtilPlayer.sendPacket(caller, packet);
|
||||||
|
|
||||||
|
tablistRefresh(caller);
|
||||||
} catch(Exception e)
|
} catch(Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void refreshTabNames(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if(event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(Player player : _disguisedPlayers.keySet())
|
||||||
|
{
|
||||||
|
if(!player.isOnline())
|
||||||
|
return;
|
||||||
|
|
||||||
|
tablistRefresh(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tablistRefresh(Player player)
|
||||||
|
{
|
||||||
|
for (Player other : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
if (player.canSee(other))
|
||||||
|
{
|
||||||
|
updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly)
|
||||||
|
{
|
||||||
|
ChatColor team = ChatColor.WHITE;
|
||||||
|
Player player = Bukkit.getPlayer(profileToAdd.getName());
|
||||||
|
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " ";
|
||||||
|
if(Plugin.GetClients().Get(player).isDisguised())
|
||||||
|
{
|
||||||
|
tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
IChatBaseComponent component = new ChatComponentText(tag + team + player.getName());
|
||||||
|
|
||||||
|
if(!refreshOnly)
|
||||||
|
{
|
||||||
|
PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER);
|
||||||
|
PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||||
|
removePacket.b.add(removeData);
|
||||||
|
UtilPlayer.sendPacket(target, removePacket);
|
||||||
|
|
||||||
|
PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
|
PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||||
|
addPacket.b.add(addData);
|
||||||
|
UtilPlayer.sendPacket(target, addPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME);
|
||||||
|
PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||||
|
updatePacket.b.add(updateData);
|
||||||
|
UtilPlayer.sendPacket(target, updatePacket);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateDisguises(UpdateEvent event)
|
public void updateDisguises(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -206,15 +310,11 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for(Team team : other.getScoreboard().getTeams())
|
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player))
|
||||||
{
|
{
|
||||||
if(team.hasPlayer(player))
|
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player);
|
||||||
{
|
|
||||||
team.removePlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player);
|
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player);
|
||||||
|
}
|
||||||
} catch(NullPointerException exp)
|
} catch(NullPointerException exp)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
@ -228,18 +328,17 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeName(Player player, String changedName)
|
public void changeName(final Player player, String changedName, boolean skin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field name = GameProfile.class.getDeclaredField("name");
|
GameProfile gameProfile = ((CraftPlayer) player).getProfile();
|
||||||
Field declaredProfile = EntityHuman.class.getDeclaredField("bH");
|
|
||||||
declaredProfile.setAccessible(true);
|
|
||||||
GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle());
|
|
||||||
|
|
||||||
|
Field name = GameProfile.class.getDeclaredField("name");
|
||||||
name.setAccessible(true);
|
name.setAccessible(true);
|
||||||
name.set(gameProfile, changedName);
|
name.set(gameProfile, changedName);
|
||||||
name.setAccessible(false);
|
name.setAccessible(false);
|
||||||
|
|
||||||
} catch(Exception ex)
|
} catch(Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -266,7 +365,7 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
client.setDisguisedAs(null);
|
client.setDisguisedAs(null);
|
||||||
client.setDisguised(false);
|
client.setDisguised(false);
|
||||||
|
|
||||||
changeName(player, playerName);
|
changeName(player, playerName, true);
|
||||||
} catch(Exception ex)
|
} catch(Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -321,6 +420,21 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onDPlayerChat(AsyncPlayerChatEvent event)
|
public void onDPlayerChat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
@ -353,5 +467,4 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
|
|||||||
_region = region;
|
_region = region;
|
||||||
_elementType = elementType;
|
_elementType = elementType;
|
||||||
_elementLabel = elementLabel;
|
_elementLabel = elementLabel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RedisDataRepository(ConnectionData conn, Region region, Class<T> elementType, String elementLabel)
|
public RedisDataRepository(ConnectionData conn, Region region, Class<T> elementType, String elementLabel)
|
||||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -51,6 +52,7 @@ import mineplex.core.cosmetic.CosmeticManager;
|
|||||||
import mineplex.core.creature.Creature;
|
import mineplex.core.creature.Creature;
|
||||||
import mineplex.core.customdata.CustomDataManager;
|
import mineplex.core.customdata.CustomDataManager;
|
||||||
import mineplex.core.disguise.DisguiseManager;
|
import mineplex.core.disguise.DisguiseManager;
|
||||||
|
import mineplex.core.disguise.PlayerDisguiseManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.elo.EloManager;
|
import mineplex.core.elo.EloManager;
|
||||||
import mineplex.core.energy.Energy;
|
import mineplex.core.energy.Energy;
|
||||||
@ -291,6 +293,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||||
new HolidayManager(this, titanGiveaway);
|
new HolidayManager(this, titanGiveaway);
|
||||||
new GameTestingManager(this);
|
new GameTestingManager(this);
|
||||||
|
new PlayerDisguiseManager(plugin, _clientManager);
|
||||||
|
|
||||||
// Game Addons
|
// Game Addons
|
||||||
new CompassAddon(plugin, this);
|
new CompassAddon(plugin, this);
|
||||||
|
@ -3,7 +3,6 @@ package nautilus.game.arcade.command;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.NCPDataManFix;
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
@ -14,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader;
|
|||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.disguise.PlayerUndisguiseEvent;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
@ -21,8 +21,19 @@ import mineplex.core.treasure.event.TreasureStartEvent;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R3.EnumDifficulty;
|
||||||
|
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
|
||||||
|
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
|
||||||
|
import net.minecraft.server.v1_8_R3.WorldType;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -52,10 +63,9 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
|
|
||||||
public DisguiseCommand(ArcadeManager plugin)
|
public DisguiseCommand(ArcadeManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.JNR_DEV, new Rank[]
|
super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise");
|
||||||
{ Rank.YOUTUBE, Rank.TWITCH }, "disguise");
|
|
||||||
plugin.getPluginManager().registerEvents(this, Plugin.getPlugin());
|
plugin.getPluginManager().registerEvents(this, Plugin.getPlugin());
|
||||||
new NCPDataManFix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,15 +75,17 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
{
|
{
|
||||||
if(!Plugin.GetDisguise().isDisguised(caller))
|
if(!Plugin.GetDisguise().isDisguised(caller))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise <name> first");
|
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise <name> first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
GameProfile profile = _disguisedPlayers.get(caller);
|
||||||
_disguisedPlayers.remove(caller);
|
_disguisedPlayers.remove(caller);
|
||||||
_disguisedPlayerDisguises.remove(caller);
|
_disguisedPlayerDisguises.remove(caller);
|
||||||
Plugin.GetDisguise().undisguise(caller);
|
Plugin.GetDisguise().undisguise(caller);
|
||||||
String playerName = _disguisedPlayersNames.get(caller);
|
String playerName = _disguisedPlayersNames.get(caller);
|
||||||
|
Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller));
|
||||||
|
|
||||||
CoreClient client = Plugin.GetClients().Get(caller);
|
CoreClient client = Plugin.GetClients().Get(caller);
|
||||||
client.setDisguisedRank(null);
|
client.setDisguisedRank(null);
|
||||||
@ -82,6 +94,29 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
|
|
||||||
changeName(caller, playerName, true);
|
changeName(caller, playerName, true);
|
||||||
|
|
||||||
|
for(Player other : UtilServer.getPlayers())
|
||||||
|
updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false);
|
||||||
|
|
||||||
|
Field field;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
field = GameProfile.class.getDeclaredField("id");
|
||||||
|
field.setAccessible(true);
|
||||||
|
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||||
|
UUID newUUID = profile.getId();
|
||||||
|
field.set(profile, old);
|
||||||
|
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// removed "due to Kicked for Flying"
|
||||||
|
//PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||||
|
//UtilPlayer.sendPacket(caller, packet);
|
||||||
|
|
||||||
for(Player other : UtilServer.getPlayers())
|
for(Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
for(Team team : other.getScoreboard().getTeams())
|
for(Team team : other.getScoreboard().getTeams())
|
||||||
@ -91,7 +126,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!");
|
UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!"));
|
||||||
return;
|
return;
|
||||||
} catch(Exception ex)
|
} catch(Exception ex)
|
||||||
{
|
{
|
||||||
@ -100,7 +135,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
}
|
}
|
||||||
if(args != null && args.length > 1)
|
if(args != null && args.length > 1)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise <name>");
|
UtilPlayer.message(caller, F.main("Disguise", "/disguise <name>"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,40 +146,41 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
{
|
{
|
||||||
if(Plugin.GetDisguise().isDisguised(caller))
|
if(Plugin.GetDisguise().isDisguised(caller))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first");
|
UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(Player other : UtilServer.getPlayers())
|
for(Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
if(other.getName().equalsIgnoreCase(args[0]))
|
if(other.getName().equalsIgnoreCase(args[0]))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_disguisedPlayersNames.containsValue(args[0]))
|
if(_disguisedPlayersNames.containsValue(args[0]))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!");
|
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(args[0].length() > 16)
|
if(args[0].length() > 16)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CoreClient client = Plugin.GetClients().Get(caller);
|
CoreClient client = Plugin.GetClients().Get(caller);
|
||||||
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
|
UUID uuid = UUID.randomUUID();
|
||||||
GameProfile profile = null;
|
GameProfile profile = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
uuid = UUIDFetcher.getUUIDOf("Alex");
|
uuid = UUID.randomUUID();
|
||||||
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
profile = new ProfileLoader(null, args[0]).loadProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rank otherRank = Rank.ALL;
|
Rank otherRank = Rank.ALL;
|
||||||
@ -157,7 +193,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
{}
|
{}
|
||||||
if(otherRank.has(Rank.TWITCH))
|
if(otherRank.has(Rank.TWITCH))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!");
|
UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_disguisedPlayers.put(caller, profile);
|
_disguisedPlayers.put(caller, profile);
|
||||||
@ -171,18 +207,102 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
|
|
||||||
Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.Item);
|
Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.Item);
|
||||||
|
|
||||||
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(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]);
|
UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0]));
|
||||||
|
|
||||||
|
Field field;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
field = GameProfile.class.getDeclaredField("id");
|
||||||
|
field.setAccessible(true);
|
||||||
|
UUID old = ((CraftPlayer) caller).getProfile().getId();
|
||||||
|
UUID newUUID = profile.getId();
|
||||||
|
field.set(profile, old);
|
||||||
|
field.set(((CraftPlayer) caller).getProfile(), newUUID);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue()));
|
||||||
|
UtilPlayer.sendPacket(caller, packet);
|
||||||
|
|
||||||
|
tablistRefresh(caller);
|
||||||
} catch(Exception e)
|
} catch(Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
|
UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void refreshTabNames(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if(event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(Player player : _disguisedPlayers.keySet())
|
||||||
|
{
|
||||||
|
if(!player.isOnline())
|
||||||
|
return;
|
||||||
|
|
||||||
|
tablistRefresh(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tablistRefresh(Player player)
|
||||||
|
{
|
||||||
|
for (Player other : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
if (player.canSee(other))
|
||||||
|
{
|
||||||
|
updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly)
|
||||||
|
{
|
||||||
|
ChatColor team = ChatColor.WHITE;
|
||||||
|
Player player = Bukkit.getPlayer(profileToAdd.getName());
|
||||||
|
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if(Plugin.GetGame().GetTeam(player) != null)
|
||||||
|
{
|
||||||
|
team = Plugin.GetGame().GetTeam(player).GetColor();
|
||||||
|
}
|
||||||
|
String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " ";
|
||||||
|
if(Plugin.GetClients().Get(player).isDisguised())
|
||||||
|
{
|
||||||
|
tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " ";
|
||||||
|
}
|
||||||
|
if(Plugin.GetGame().GetState() != GameState.Recruit)
|
||||||
|
tag = "";
|
||||||
|
|
||||||
|
IChatBaseComponent component = new ChatComponentText(tag + team + player.getName());
|
||||||
|
|
||||||
|
if(!refreshOnly)
|
||||||
|
{
|
||||||
|
PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER);
|
||||||
|
PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||||
|
removePacket.b.add(removeData);
|
||||||
|
UtilPlayer.sendPacket(target, removePacket);
|
||||||
|
|
||||||
|
PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
|
PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||||
|
addPacket.b.add(addData);
|
||||||
|
UtilPlayer.sendPacket(target, addPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME);
|
||||||
|
PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component);
|
||||||
|
updatePacket.b.add(updateData);
|
||||||
|
UtilPlayer.sendPacket(target, updatePacket);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateDisguises(UpdateEvent event)
|
public void updateDisguises(UpdateEvent event)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user