Improving the /disguise command even more. ;D
This commit is contained in:
parent
91de6a1852
commit
83da6b7a9a
@ -11,6 +11,8 @@ public class CoreClient
|
||||
private String _disguisedAs;
|
||||
private Player _player;
|
||||
private Rank _rank;
|
||||
private Rank _disguisedRank;
|
||||
private boolean _disguised;
|
||||
|
||||
public CoreClient(Player player)
|
||||
{
|
||||
@ -73,4 +75,20 @@ public class CoreClient
|
||||
{
|
||||
this._disguisedAs = originalName;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -114,25 +114,38 @@ public class CoreClientManager extends MiniPlugin
|
||||
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name));
|
||||
}
|
||||
|
||||
public CoreClient Get(String name)
|
||||
public CoreClient Get(String name, boolean disguised)
|
||||
{
|
||||
synchronized(_clientLock)
|
||||
{
|
||||
for(CoreClient client : _clientList.values())
|
||||
if(!disguised)
|
||||
{
|
||||
if(client.getDisguisedAs() != null)
|
||||
if(client.getDisguisedAs().equalsIgnoreCase(name))
|
||||
return client;
|
||||
for(CoreClient client : _clientList.values())
|
||||
{
|
||||
if(client.getDisguisedAs() != null)
|
||||
if(client.getDisguisedAs().equalsIgnoreCase(name))
|
||||
return client;
|
||||
}
|
||||
}
|
||||
return _clientList.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
public CoreClient Get(String name)
|
||||
{
|
||||
return Get(name, false);
|
||||
}
|
||||
|
||||
public CoreClient Get(Player player)
|
||||
{
|
||||
return Get(player.getName());
|
||||
}
|
||||
|
||||
public CoreClient Get(Player player, boolean disguised)
|
||||
{
|
||||
return Get(player.getName(), disguised);
|
||||
}
|
||||
|
||||
public int getPlayerCountIncludingConnecting()
|
||||
{
|
||||
return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get());
|
||||
@ -251,7 +264,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();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package nautilus.game.arcade.command;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
@ -26,6 +27,7 @@ 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.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -38,7 +40,6 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
|
||||
private NautHashMap<Player, GameProfile> _disguisedPlayers = new NautHashMap<>();
|
||||
private NautHashMap<Player, String> _disguisedPlayersNames = new NautHashMap<>();
|
||||
private NautHashMap<Player, Rank> _disguisedPlayersRanks = new NautHashMap<>();
|
||||
|
||||
public DisguiseCommand(ArcadeManager plugin)
|
||||
{
|
||||
@ -70,11 +71,11 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
_disguisedPlayers.remove(caller);
|
||||
Plugin.GetDisguise().undisguise(caller);
|
||||
String playerName = _disguisedPlayersNames.get(caller);
|
||||
Rank rank = _disguisedPlayersRanks.get(caller);
|
||||
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
client.SetRank(rank);
|
||||
client.setDisguisedRank(null);
|
||||
client.setDisguisedAs(null);
|
||||
client.setDisguised(false);
|
||||
|
||||
Field name = GameProfile.class.getDeclaredField("name");
|
||||
Field declaredProfile = EntityHuman.class.getDeclaredField("i");
|
||||
@ -117,16 +118,27 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("Chiss") || args[0].equalsIgnoreCase("Sterling_") || args[0].equalsIgnoreCase("defek7"))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "nice try ;D");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
final GameProfile profile = new ProfileLoader(UUIDFetcher.getUUIDOf(args[0]).toString(), args[0]).loadProfile();
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||
final GameProfile profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||
_disguisedPlayers.put(caller, profile);
|
||||
_disguisedPlayersNames.put(caller, caller.getName());
|
||||
_disguisedPlayersRanks.put(caller, client.GetRank());
|
||||
Plugin.GetDisguise().undisguise(caller);
|
||||
client.SetRank(Rank.ALL);
|
||||
|
||||
CoreClient other = Plugin.GetClients().Add(args[0]);
|
||||
Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString());
|
||||
Rank otherRank = other.GetRank();
|
||||
client.setDisguisedRank(otherRank);
|
||||
client.setDisguised(true);
|
||||
|
||||
client.setDisguisedAs(args[0]);
|
||||
|
||||
Field name = GameProfile.class.getDeclaredField("name");
|
||||
@ -156,17 +168,65 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
if(event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for(Player player : UtilServer.getPlayers())
|
||||
for(final Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if(!_disguisedPlayers.containsKey(player))
|
||||
return;
|
||||
|
||||
if(!Plugin.GetClients().Get(player).isDisguised())
|
||||
return;
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).GetRank().Name).getPlayers().contains(player))
|
||||
{
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).GetRank().Name).removePlayer(player);
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).getDisguisedRank().Name).addPlayer(player);
|
||||
}
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).GetRank().Name + Plugin.GetGame().GetTeam(player)) != null)
|
||||
{
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).GetRank().Name + Plugin.GetGame().GetTeam(player)).getPlayers().contains(player))
|
||||
{
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).GetRank().Name + Plugin.GetGame().GetTeam(player)).removePlayer(player);
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).getDisguisedRank().Name + Plugin.GetGame().GetTeam(player)).addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Plugin.GetDisguise().isDisguised(player))
|
||||
return;
|
||||
|
||||
DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player));
|
||||
Plugin.GetDisguise().disguise(playerDisguise);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(Plugin.getPlugin(), new Runnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.hidePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
}, 10);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(Plugin.getPlugin(), new Runnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.showPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
}, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,11 +242,11 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
_disguisedPlayers.remove(player);
|
||||
Plugin.GetDisguise().undisguise(player);
|
||||
String playerName = _disguisedPlayersNames.get(player);
|
||||
Rank rank = _disguisedPlayersRanks.get(player);
|
||||
|
||||
CoreClient client = Plugin.GetClients().Get(player);
|
||||
client.SetRank(rank);
|
||||
client.setDisguisedRank(null);
|
||||
client.setDisguisedAs(null);
|
||||
client.setDisguised(false);
|
||||
|
||||
Field name = GameProfile.class.getDeclaredField("name");
|
||||
Field declaredProfile = EntityHuman.class.getDeclaredField("i");
|
||||
@ -204,4 +264,16 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
}
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,9 @@ public class GameChatManager implements Listener
|
||||
dead = C.cGray + "Dead ";
|
||||
|
||||
Rank rank = Manager.GetClients().Get(sender).GetRank();
|
||||
if(Manager.GetClients().Get(sender).isDisguised())
|
||||
rank = Manager.GetClients().Get(sender).getDisguisedRank();
|
||||
|
||||
boolean ownsUltra = false;
|
||||
|
||||
if (Manager.GetGame() != null)
|
||||
|
Loading…
Reference in New Issue
Block a user