Merge branch 'SarahsAwesomeBugFixes' of ssh://184.154.0.242:7999/min/mineplex into SarahsAwesomeBugFixes

This commit is contained in:
Mini-Chiss 2015-08-05 20:25:38 +02:00
commit 7fbe29d0af
4 changed files with 124 additions and 17 deletions

View File

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

View File

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

@ -1,13 +1,12 @@
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;
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;
@ -26,19 +25,18 @@ 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;
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
{
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 +68,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");
@ -85,6 +83,16 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
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;
}
@ -117,16 +125,34 @@ 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]);
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());
_disguisedPlayersRanks.put(caller, client.GetRank());
Plugin.GetDisguise().undisguise(caller);
client.SetRank(Rank.ALL);
CoreClient other = new CoreClient(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 +182,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).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)) != null)
{
if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player)).getPlayers().contains(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);
}
}
}
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 +256,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 +278,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");
}
}
}
}

View File

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