Love you Sarah <3

This commit is contained in:
Morten 2016-01-02 03:19:39 +01:00
parent a06a0060aa
commit 7e1b0b9110
9 changed files with 150 additions and 2 deletions

View File

@ -0,0 +1,34 @@
package mineplex.core.disguise;
import mineplex.serverdata.data.Data;
public class DisguisePlayerBean implements Data
{
private int _accountID;
private String _disguisedPlayer;
private String _playerName;
public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs)
{
this._accountID = playerAccountID;
this._disguisedPlayer = disguiseAs;
this._playerName = playerName;
}
public int getAccountID()
{
return _accountID;
}
public String getDisguisedPlayer()
{
return _disguisedPlayer;
}
public String getPlayerName()
{
return _playerName;
}
@Override
public String getDataId()
{
return _accountID+_playerName;
}
}

View File

@ -0,0 +1,68 @@
package mineplex.core.disguise;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.serverdata.Region;
import mineplex.serverdata.redis.RedisDataRepository;
public class PlayerDisguiseManager extends MiniPlugin
{
private CoreClientManager _clients;
private RedisDataRepository<DisguisePlayerBean> _redis;
public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients)
{
super("Player Disguise Manager", plugin);
this._clients = clients;
_redis = new RedisDataRepository<DisguisePlayerBean>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer");
}
@EventHandler
public void onDisguisedPlayerQuit(PlayerQuitEvent event)
{
CoreClient client = _clients.Get(event.getPlayer());
if(client.isDisguised())
{
_redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours
}
}
@EventHandler
public void onDisguisedPlayerJoin(PlayerJoinEvent event)
{
new BukkitRunnable()
{
@Override
public void run()
{
CoreClient client = _clients.Get(event.getPlayer());
if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE)
return;
if(_redis.elementExists(client.getAccountId()+client.GetPlayerName()))
{
DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName());
Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer()));
}
}
}.runTaskLater(getPlugin(), 7);
}
@EventHandler
public void onPlayerUndisguise(PlayerUndisguiseEvent event)
{
CoreClient client = _clients.Get(event.getPlayer());
_redis.removeElement(client.getAccountId()+client.GetPlayerName());
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.disguise;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerUndisguiseEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
public PlayerUndisguiseEvent(Player disguisee)
{
this._player = disguisee;
}
public Player getPlayer()
{
return _player;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.message.MessageManager;
import mineplex.core.visibility.VisibilityManager;
public class AdminCommand extends CommandBase<MessageManager>
{
@ -53,6 +54,11 @@ public class AdminCommand extends CommandBase<MessageManager>
if (!to.equals(caller))
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);
if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV))
{
if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to))
continue;
}
staff = true;
//Sound

View File

@ -33,6 +33,7 @@ import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.PlayerDisguiseManager;
import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
@ -249,7 +250,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
// _halloweenManager = new HalloweenSpookinessManager(this);
new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
new PlayerDisguiseManager(plugin, _clientManager);
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
// new MailManager(_plugin, notificationManager);

View File

@ -13,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.PlayerUndisguiseEvent;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.types.GadgetType;
@ -83,6 +84,7 @@ public class DisguiseCommand extends CommandBase<HubManager> implements Listener
_disguisedPlayerDisguises.remove(caller);
Plugin.GetDisguise().undisguise(caller);
String playerName = _disguisedPlayersNames.get(caller);
Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller));
CoreClient client = Plugin.GetClients().Get(caller);
client.setDisguisedRank(null);

View File

@ -55,6 +55,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
_region = region;
_elementType = elementType;
_elementLabel = elementLabel;
}
public RedisDataRepository(ConnectionData conn, Region region, Class<T> elementType, String elementLabel)

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -51,6 +52,7 @@ import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.PlayerDisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
@ -291,6 +293,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
new HolidayManager(this, titanGiveaway);
new GameTestingManager(this);
new PlayerDisguiseManager(plugin, _clientManager);
// Game Addons
new CompassAddon(plugin, this);

View File

@ -13,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.PlayerUndisguiseEvent;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.types.GadgetType;
@ -86,6 +87,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
_disguisedPlayerDisguises.remove(caller);
Plugin.GetDisguise().undisguise(caller);
String playerName = _disguisedPlayersNames.get(caller);
Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller));
CoreClient client = Plugin.GetClients().Get(caller);
client.setDisguisedRank(null);