Fixing more /disguise bugs.
This commit is contained in:
parent
83da6b7a9a
commit
a15e8e1b95
@ -114,38 +114,25 @@ public class CoreClientManager extends MiniPlugin
|
||||
_plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name));
|
||||
}
|
||||
|
||||
public CoreClient Get(String name, boolean disguised)
|
||||
public CoreClient Get(String name)
|
||||
{
|
||||
synchronized(_clientLock)
|
||||
{
|
||||
if(!disguised)
|
||||
for(CoreClient client : _clientList.values())
|
||||
{
|
||||
for(CoreClient client : _clientList.values())
|
||||
{
|
||||
if(client.getDisguisedAs() != null)
|
||||
if(client.getDisguisedAs().equalsIgnoreCase(name))
|
||||
return client;
|
||||
}
|
||||
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());
|
||||
|
@ -4,11 +4,9 @@ import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
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;
|
||||
@ -30,10 +28,9 @@ 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;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
|
||||
import com.sun.xml.internal.ws.resources.UtilMessages;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class DisguiseCommand extends CommandBase<ArcadeManager> implements Listener
|
||||
{
|
||||
@ -85,7 +82,17 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
name.setAccessible(true);
|
||||
name.set(gameProfile, playerName);
|
||||
name.setAccessible(false);
|
||||
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
for(Team team : other.getScoreboard().getTeams())
|
||||
{
|
||||
team.removePlayer(caller);
|
||||
}
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller);
|
||||
}
|
||||
|
||||
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!");
|
||||
return;
|
||||
}
|
||||
@ -128,12 +135,19 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
{
|
||||
CoreClient client = Plugin.GetClients().Get(caller);
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(args[0]);
|
||||
try
|
||||
{
|
||||
final GameProfile profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile();
|
||||
_disguisedPlayers.put(caller, profile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + C.Bold + "There went something wrong!");
|
||||
}
|
||||
_disguisedPlayersNames.put(caller, caller.getName());
|
||||
Plugin.GetDisguise().undisguise(caller);
|
||||
|
||||
CoreClient other = Plugin.GetClients().Add(args[0]);
|
||||
CoreClient other = new CoreClient(args[0]);
|
||||
Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString());
|
||||
Rank otherRank = other.GetRank();
|
||||
client.setDisguisedRank(otherRank);
|
||||
@ -144,7 +158,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
Field name = GameProfile.class.getDeclaredField("name");
|
||||
Field declaredProfile = EntityHuman.class.getDeclaredField("i");
|
||||
declaredProfile.setAccessible(true);
|
||||
GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity)((CraftPlayer) caller) ).getHandle());
|
||||
GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity)((CraftPlayer) caller)).getHandle());
|
||||
|
||||
name.setAccessible(true);
|
||||
name.set(gameProfile, args[0]);
|
||||
@ -178,17 +192,17 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
||||
|
||||
for(Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player, false).GetRank().Name).getPlayers().contains(player))
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).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);
|
||||
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, false).GetRank().Name + Plugin.GetGame().GetTeam(player)) != null)
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).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))
|
||||
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).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);
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player)).removePlayer(player);
|
||||
other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name + Plugin.GetGame().GetTeam(player)).addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user