Improving the /disguise command.

This commit is contained in:
Sarah 2015-08-05 07:57:52 +02:00
parent 95bb4ab04b
commit e55557e1fd
8 changed files with 73 additions and 69 deletions

View File

@ -8,6 +8,7 @@ public class CoreClient
{
private int _accountId = -1;
private String _name;
private String _disguisedAs;
private Player _player;
private Rank _rank;
@ -62,4 +63,14 @@ public class CoreClient
{
_rank = rank;
}
public String getDisguisedAs()
{
return _disguisedAs;
}
public void setDisguisedAs(String originalName)
{
this._disguisedAs = originalName;
}
}

View File

@ -118,16 +118,19 @@ public class CoreClientManager extends MiniPlugin
{
synchronized(_clientLock)
{
for(CoreClient client : _clientList.values())
{
if(client.getDisguisedAs() != null)
if(client.getDisguisedAs().equalsIgnoreCase(name))
return client;
}
return _clientList.get(name);
}
}
public CoreClient Get(Player player)
{
synchronized(_clientLock)
{
return _clientList.get(player.getName());
}
return Get(player.getName());
}
public int getPlayerCountIncludingConnecting()

View File

@ -1,15 +1,23 @@
package mineplex.core.stats;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
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.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.stats.command.GiveStatCommand;

View File

@ -1,61 +0,0 @@
package nautilus.game.arcade.command;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.ProfileLoader;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguisePlayer;
import nautilus.game.arcade.ArcadeManager;
public class DisguiseCommand extends CommandBase<ArcadeManager>
{
public DisguiseCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, "disguise");
}
@Override
public void Execute(final Player caller, final String[] args)
{
if (args.length == 0)
{
UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise <name>");
return;
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
{
@Override
public void run()
{
try
{
final GameProfile profile = new ProfileLoader(UUIDFetcher.getUUIDOf(args[0]).toString(), args[0]).loadProfile();
Bukkit.getServer().getScheduler().runTask(Plugin.getPlugin(), new Runnable()
{
public void run()
{
DisguisePlayer playerDisguise = new DisguisePlayer(caller, profile);
Plugin.GetDisguise().disguise(playerDisguise);
UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]);
}
});
}
catch (Exception e)
{
UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]);
return;
}
}}
);
}
}

View File

@ -10,7 +10,7 @@ public class KitUnlockCommand extends CommandBase<ArcadeManager>
{
public KitUnlockCommand(ArcadeManager plugin)
{
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, new String[] {"youtube", "twitch", "kits"});
super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"});
}
@Override

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -13,6 +14,8 @@ import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Player;
@ -55,6 +58,8 @@ import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import nautilus.game.arcade.stats.*;
import nautilus.game.arcade.world.WorldData;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.util.com.mojang.authlib.GameProfile;
public abstract class Game implements Listener
{
@ -671,7 +676,7 @@ public abstract class Game implements Listener
{
if (!countAmount && gems < 1)
gems = 1;
if (GetGems(player).containsKey(reason) && multipleAllowed)
{
GetGems(player).get(reason).AddGems(gems);

View File

@ -7,9 +7,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.party.Party;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

View File

@ -1,7 +1,9 @@
package nautilus.game.arcade.managers;
import java.lang.reflect.Field;
import java.util.HashMap;
import mineplex.core.account.event.GetClientEvent;
import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -18,8 +20,12 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GemData;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.Sound;
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;
@ -156,6 +162,14 @@ public class GameGemManager implements Listener
earned = (int) (earned * gameMult);
int total = earned;
String oldName = player.getName();
if(Manager.GetClients().Get(player).getDisguisedAs() != null)
{
changeName(player, Manager.GetClients().Get(player).GetPlayerName());
System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName());
}
//Gem Boooster
if (game.GemBoosterEnabled)
@ -179,8 +193,33 @@ public class GameGemManager implements Listener
//Stats
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total);
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total);
if(Manager.GetClients().Get(player).getDisguisedAs() != null)
{
changeName(player, oldName);
}
}
private void changeName(Player player, String newName)
{
try
{
Field name = GameProfile.class.getDeclaredField("name");
Field declaredProfile = EntityHuman.class.getDeclaredField("i");
declaredProfile.setAccessible(true);
GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity)((CraftPlayer) player)).getHandle());
name.setAccessible(true);
name.set(gameProfile, newName);
name.setAccessible(false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)
{
if (gems == null)