Fixing Players can disguise as disguised Players.

This commit is contained in:
Sarah 2015-08-06 20:57:56 +02:00
parent 4a10f8d71a
commit d8041ba582
2 changed files with 32 additions and 20 deletions

View File

@ -81,7 +81,10 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
{
for(Team team : other.getScoreboard().getTeams())
{
team.removePlayer(caller);
if(team.hasPlayer(caller))
{
team.removePlayer(caller);
}
}
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
}
@ -119,6 +122,11 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
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]);
@ -129,19 +137,16 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
{
CoreClient client = Plugin.GetClients().Get(caller);
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
GameProfile profile = null;
try
{
final GameProfile profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
_disguisedPlayers.put(caller, profile);
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
}
catch (Exception e)
{
uuid = UUIDFetcher.getUUIDOf("Alex");
final GameProfile profile = new ProfileLoader(uuid.toString(), "Steve").loadProfile();
_disguisedPlayers.put(caller, profile);
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
}
_disguisedPlayersNames.put(caller, caller.getName());
Plugin.GetDisguise().undisguise(caller);
Rank otherRank = Rank.ALL;
try
@ -155,10 +160,10 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
if(otherRank.Has(Rank.TWITCH))
{
UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!");
_disguisedPlayers.remove(caller);
_disguisedPlayersNames.remove(caller);
return;
}
_disguisedPlayers.put(caller, profile);
_disguisedPlayersNames.put(caller, caller.getName());
client.setDisguisedRank(otherRank);
client.setDisguised(true);
@ -195,11 +200,15 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
{
try
{
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player))
for(Team team : other.getScoreboard().getTeams())
{
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player);
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player);
if(team.hasPlayer(player))
{
team.removePlayer(player);
}
}
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player);
}
catch (NullPointerException exp)
{}

View File

@ -120,6 +120,11 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
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]);
@ -130,18 +135,16 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
{
CoreClient client = Plugin.GetClients().Get(caller);
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
GameProfile profile = null;
try
{
final GameProfile profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
_disguisedPlayers.put(caller, profile);
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
}
catch (Exception e)
{
uuid = UUIDFetcher.getUUIDOf("Alex");
final GameProfile profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
_disguisedPlayers.put(caller, profile);
profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
}
_disguisedPlayersNames.put(caller, caller.getName());
Rank otherRank = Rank.ALL;
try
@ -151,14 +154,14 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
otherRank = other.GetRank();
}
catch (NullPointerException exception)
{}
{}
if(otherRank.Has(Rank.TWITCH))
{
UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!");
_disguisedPlayers.remove(caller);
_disguisedPlayersNames.remove(caller);
return;
}
_disguisedPlayers.put(caller, profile);
_disguisedPlayersNames.put(caller, caller.getName());
client.setDisguisedRank(otherRank);
client.setDisguised(true);