Consistency. (Changed Vanish to Incognito)

This commit is contained in:
Ben 2016-03-09 01:53:01 +00:00
parent befb27d3db
commit 5b3da3d06f
17 changed files with 52 additions and 203 deletions

View File

@ -113,7 +113,7 @@ public class UtilServer
return getServer().getPluginManager();
}
public static <T extends Event> T callEvent(T event)
public static <T extends Event> T CallEvent(T event)
{
getPluginManager().callEvent(event);
return event;

View File

@ -43,18 +43,18 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.vanish.Vanish;
public class Chat extends MiniPlugin
{
private CoreClientManager _clientManager;
private PreferencesManager _preferences;
private AchievementManager _achievements;
private Vanish _vanish;
private IncognitoManager _incognitoManager;
private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"};
private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate";
@ -69,7 +69,7 @@ public class Chat extends MiniPlugin
private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>();
public Chat(JavaPlugin plugin, CoreClientManager clientManager, Vanish vanish, PreferencesManager preferences, AchievementManager achievements, String serverName)
public Chat(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName)
{
super("Chat", plugin);
@ -303,7 +303,7 @@ public class Chat extends MiniPlugin
Player sender = event.getPlayer();
if (_vanish.Get(sender).Status)
if (_incognitoManager.Get(sender).Status)
{
UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito.");
event.setCancelled(true);

View File

@ -29,11 +29,11 @@ import mineplex.core.friend.command.FriendsDisplay;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendRepository;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.vanish.Vanish;
public class FriendManager extends MiniDbClientPlugin<FriendData>
{
@ -279,8 +279,8 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
if (friend.Status == FriendStatusType.Accepted)
{
// Online Friend and not vanished
if (friend.Online && !Vanish.Instance.getRepository().GetStatus(friend.Name))
// Online Friend and not incognito
if (friend.Online && !IncognitoManager.Instance.getRepository().GetStatus(friend.Name))
{
if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST"))
{

View File

@ -32,10 +32,10 @@ import mineplex.core.friend.FriendManager;
import mineplex.core.friend.FriendStatusType;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemLayout;
import mineplex.core.shop.item.IButton;
import mineplex.core.vanish.Vanish;
public class FriendsGUI implements Listener
{
@ -129,16 +129,16 @@ public class FriendsGUI implements Listener
FriendStatus friend = friends.get(friendSlot);
boolean vanished = friend.Online ? Vanish.Instance.getRepository().GetStatus(friend.Name) : false;
boolean incognito = friend.Online ? IncognitoManager.Instance.getRepository().GetStatus(friend.Name) : false;
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !vanished ? 3 : 0));
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !incognito ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
if (friend.Online && !vanished)
if (friend.Online && !incognito)
{
builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName);
}
@ -276,16 +276,16 @@ public class FriendsGUI implements Listener
FriendStatus friend = friends.get(friendSlot);
boolean vanished = friend.Online ? Vanish.Instance.getRepository().GetStatus(friend.Name) : false;
boolean incognito = friend.Online ? IncognitoManager.Instance.getRepository().GetStatus(friend.Name) : false;
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !vanished ? 3 : 0));
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !incognito ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online && !vanished ? C.cDGreen + "Online" : C.cRed + "Offline"));
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online && !incognito ? C.cDGreen + "Online" : C.cRed + "Offline"));
if (friend.Online && !vanished)
if (friend.Online && !incognito)
{
builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName);
}
@ -294,7 +294,7 @@ public class FriendsGUI implements Listener
builder.addLore(C.cGray + "Last seen " + UtilTime.MakeStr(friend.LastSeenOnline) + " ago");
}
if (friend.Online && !vanished)
if (friend.Online && !incognito)
{
builder.addLore("");
builder.addLore(C.cGray + "Left click to teleport to their server");

View File

@ -1,4 +1,4 @@
package mineplex.core.vanish.commands;
package mineplex.core.incognito.commands;
import org.bukkit.entity.Player;
@ -6,11 +6,11 @@ import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.vanish.Vanish;
import mineplex.core.incognito.IncognitoManager;
public class VanishCommand extends CommandBase<Vanish>
public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
{
public VanishCommand(Vanish plugin)
public IncognitoToggleCommand(IncognitoManager plugin)
{
super(plugin, Rank.HELPER, "incognito", "vanish");
}

View File

@ -1,4 +1,4 @@
package mineplex.core.vanish.events;
package mineplex.core.incognito.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;

View File

@ -0,0 +1,6 @@
package mineplex.core.incognito.repository;
public class IncognitoClient
{
public boolean Status;
}

View File

@ -1,32 +1,32 @@
package mineplex.core.vanish.repository;
package mineplex.core.incognito.repository;
import mineplex.cache.player.PlayerCache;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.EnclosedObject;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.vanish.Vanish;
import mineplex.core.incognito.IncognitoManager;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnInt;
public class VanishRepository extends MinecraftRepository
public class IncognitoRepository extends MinecraftRepository
{
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, status TINYINT(1) DEFAULT '0');";
private static final String GET_STATUS = "SELECT * FROM incognitoStaff WHERE accountId = ?;";
private static final String SET_STATUS = "INSERT INTO incognitoStaff (accountId, status) VALUES (?, ?);";
private Vanish _vanish;
private IncognitoManager _incognitoManager;
private CoreClientManager _clientManager;
public VanishRepository(Vanish vanish, CoreClientManager clientManager)
public IncognitoRepository(IncognitoManager incognitoManager, CoreClientManager clientManager)
{
super(vanish.getPlugin(), DBPool.getAccount());
super(incognitoManager.getPlugin(), DBPool.getAccount());
_clientManager = clientManager;
_vanish = vanish;
_incognitoManager = incognitoManager;
}
public void SetStatus(int accountId, boolean status)

View File

@ -26,6 +26,7 @@ import mineplex.core.friend.FriendManager;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.message.commands.*;
import mineplex.core.message.redis.AnnouncementHandler;
import mineplex.core.message.redis.MessageHandler;
@ -36,7 +37,6 @@ import mineplex.core.punish.Punish;
import mineplex.core.punish.PunishClient;
import mineplex.core.punish.Punishment;
import mineplex.core.punish.PunishmentSentence;
import mineplex.core.vanish.Vanish;
import mineplex.serverdata.commands.AnnouncementCommand;
import mineplex.serverdata.commands.ServerCommandManager;
@ -524,7 +524,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
// If this is a message inside the server
if (to != null)
{
if (Vanish.Instance.Get(to).Status)
if (IncognitoManager.Instance.Get(to).Status)
{
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
return;
@ -549,7 +549,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
// If this is a admin message, or the sender isn't muted/ignoring the target
if (adminMessage || canSenderMessageThem(sender, playerTarget))
{
if (Vanish.Instance.getRepository().GetStatus(playerTarget))
if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget))
{
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
return;

View File

@ -1,151 +0,0 @@
package mineplex.core.vanish;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.vanish.commands.VanishCommand;
import mineplex.core.vanish.events.IncognitoStatusChangeEvent;
import mineplex.core.vanish.repository.VanishClient;
import mineplex.core.vanish.repository.VanishRepository;
public class Vanish extends MiniClientPlugin<VanishClient>
{
private CoreClientManager _clientManager;
private VanishRepository _repository;
public static Vanish Instance;
public Vanish(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
{
super("Vanish", plugin);
_repository = new VanishRepository(this, clientManager);
_clientManager = clientManager;
Instance = this;
}
public void addCommands()
{
addCommand(new VanishCommand(this));
}
public boolean toggle(Player caller)
{
boolean enabled = !Get(caller).Status;
IncognitoStatusChangeEvent event = new IncognitoStatusChangeEvent(caller, enabled);//UtilServer.callEvent(new PreVanishEvent(caller, true));
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return false;
}
Get(caller).Status = enabled;
runAsync(() -> _repository.SetStatus(_clientManager.getAccountId(caller), enabled));
return enabled;
}
@EventHandler(priority = EventPriority.LOWEST)
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
UtilServer.getPlayersCollection().forEach(player -> {
UtilServer.getPlayersCollection().forEach(other -> {
if (Get(other).Status && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
player.hidePlayer(other);
if (Get(player).Status)
{
if (!_clientManager.hasRank(other, _clientManager.Get(player).GetRank()))
other.hidePlayer(player);
}
});
});
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void ClientLoad(AsyncPlayerPreLoginEvent event)
{
_clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> {
Get(event.getName()).Status = _repository.GetStatus(accountId.intValue());
});
}
@EventHandler(priority = EventPriority.HIGHEST)
public void Join(PlayerJoinEvent event)
{
if (Get(event.getPlayer()).Status)
{
event.setJoinMessage(null);
informVanished(event.getPlayer());
}
UtilServer.getPlayersCollection().forEach(player -> {
if (Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank()))
player.hidePlayer(event.getPlayer());
if (Get(player).Status)
{
if (!_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank()))
event.getPlayer().hidePlayer(player);
}
});
}
@EventHandler(priority = EventPriority.HIGHEST)
public void Quit(PlayerQuitEvent event)
{
if (Get(event.getPlayer()).Status)
{
event.setQuitMessage(null);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void Kick(PlayerKickEvent event)
{
if (Get(event.getPlayer()).Status)
{
event.setLeaveMessage(null);
}
}
private void informVanished(Player player)
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cGoldB + "You are currently in Incognito mode.");
UtilPlayer.message(player, C.cYellow + "This means you are invisible to all except for those who are " + _clientManager.Get(player).GetRank().getTag(true, false) + C.mBody + "+");
UtilPlayer.message(player, " ");
}
protected VanishClient AddPlayer(String player)
{
return new VanishClient();
}
public VanishRepository getRepository()
{
return _repository;
}
}

View File

@ -1,6 +0,0 @@
package mineplex.core.vanish.repository;
public class VanishClient
{
public boolean Status;
}

View File

@ -21,6 +21,7 @@ import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix;
@ -39,7 +40,6 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.vanish.Vanish;
import mineplex.core.visibility.VisibilityManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ban.ClansBanManager;
@ -114,11 +114,11 @@ public class Clans extends JavaPlugin
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
Vanish incognito = new Vanish(this, _clientManager, packetHandler);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
Chat chat = new Chat(this, _clientManager, incognito, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
new MemoryFix(this);

View File

@ -56,6 +56,7 @@ import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
@ -69,7 +70,6 @@ import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.vanish.events.IncognitoStatusChangeEvent;
import mineplex.game.clans.Clans;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;

View File

@ -354,7 +354,7 @@ public class Gameplay extends MiniPlugin
ClansWaterPlaceEvent placeEvent = new ClansWaterPlaceEvent(event.getPlayer(), event.getBlock());
UtilServer.callEvent(placeEvent);
UtilServer.CallEvent(placeEvent);
if (placeEvent.isCancelled())
{

View File

@ -25,6 +25,7 @@ import mineplex.core.give.Give;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix;
@ -52,7 +53,6 @@ import mineplex.core.teleport.Teleport;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.vanish.Vanish;
import mineplex.core.velocity.VelocityFix;
import mineplex.core.visibility.VisibilityManager;
import mineplex.hub.modules.StackerManager;
@ -140,10 +140,10 @@ public class Hub extends JavaPlugin implements IRelation
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
Vanish incognito = new Vanish(this, clientManager, packetHandler);
IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
Chat chat = new Chat(this, clientManager, incognito, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
Chat chat = new Chat(this, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
new MemoryFix(this);
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());

View File

@ -30,6 +30,7 @@ import mineplex.core.give.Give;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.leaderboard.LeaderboardManager;
@ -53,7 +54,6 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.vanish.Vanish;
import mineplex.core.velocity.VelocityFix;
import mineplex.core.visibility.VisibilityManager;
import mineplex.minecraft.game.core.combat.CombatManager;
@ -128,13 +128,13 @@ public class Arcade extends JavaPlugin
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false);
Vanish incognito = new Vanish(this, _clientManager, packetHandler);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal);
Chat chat = new Chat(this, _clientManager, incognito, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
BlockRestore blockRestore = new BlockRestore(this);

View File

@ -62,6 +62,8 @@ import mineplex.core.facebook.FacebookManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.movement.Movement;
@ -86,8 +88,6 @@ import mineplex.core.teleport.Teleport;
import mineplex.core.timing.TimingManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.core.vanish.Vanish;
import mineplex.core.vanish.events.IncognitoStatusChangeEvent;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
@ -1101,7 +1101,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public boolean IsObserver(Player player)
{
if (Vanish.Instance.Get(player).Status)
if (IncognitoManager.Instance.Get(player).Status)
{
_specList.add(player);
}