Disable incognito for staff in hub invisibility, and vice-versa

This commit is contained in:
Ben 2016-04-08 20:18:56 +01:00
parent 79a2ef3608
commit a04f7c23c6
9 changed files with 74 additions and 35 deletions

View File

@ -2,8 +2,6 @@ package mineplex.core.incognito;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -13,8 +11,6 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.base.Function;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
@ -27,6 +23,7 @@ import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.incognito.repository.IncognitoClient;
import mineplex.core.incognito.repository.IncognitoRepository;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -34,11 +31,12 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{
private CoreClientManager _clientManager;
private IncognitoRepository _repository;
private PreferencesManager _preferencesManager;
public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
{
super("Incognito", plugin, clientManager);
_repository = new IncognitoRepository(this);
_clientManager = clientManager;
}
@ -217,4 +215,14 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
Get(playerName).Status = resultSet.getInt("status") == 1;
}
}
public PreferencesManager getPreferences()
{
return _preferencesManager;
}
public void setPreferencesManager(PreferencesManager preferencesManager)
{
_preferencesManager = preferencesManager;
}
}

View File

@ -18,6 +18,12 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
@Override
public void Execute(Player caller, String[] args)
{
if (Plugin.getPreferences().Get(caller).Invisibility)
{
UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled."));
return;
}
if (Plugin.toggle(caller))
{
UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again."));

View File

@ -4,20 +4,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map.Entry;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -29,17 +15,35 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{
private PreferencesRepository _repository;
private PreferencesShop _shop;
private ExclusivePreferencesShop _exclusiveShop;
private IncognitoManager _incognitoManager;
private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>();
public boolean GiveItem;
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager)
{
super("Preferences", plugin, clientManager);
@ -47,6 +51,8 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
_exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager);
_shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop);
_incognitoManager = incognito;
_exclusiveShop.setPreferencesShop(_shop);
addCommand(new PreferencesCommand(this));
@ -138,4 +144,9 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
}
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
}

View File

@ -8,6 +8,8 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager;
import mineplex.core.preferences.PreferencesManager;
@ -149,6 +151,12 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
private void toggleHubInvisibility(org.bukkit.entity.Player player)
{
if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status)
{
UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode."));
return;
}
getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility;
// Dont save for Mod/SnrMod - prevents them just being invis 24/7

View File

@ -97,8 +97,12 @@ public class Clans extends JavaPlugin
new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
// TODO: Add spawn locations to a configuration file of some sort?
@ -111,7 +115,6 @@ public class Clans extends JavaPlugin
// ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
PacketHandler packetHandler = new PacketHandler(this);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false);
@ -120,8 +123,6 @@ public class Clans extends JavaPlugin
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
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, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
@ -143,7 +144,7 @@ public class Clans extends JavaPlugin
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
HologramManager hologram = new HologramManager(this, packetHandler);
_clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
_clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
new Recipes(this);
new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager);

View File

@ -227,7 +227,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// Spawn area
public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
{
super("Clans Manager", plugin);
@ -236,7 +236,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
/*_clansBans = clansBans;*/
_punish = punish;
_incognitoManager = new IncognitoManager(plugin, clientManager, packetHandler);
_incognitoManager = incognitoManager;
_serverName = serverName;
_clientManager = clientManager;
_combatManager = new CombatManager(plugin);

View File

@ -106,7 +106,11 @@ public class Hub extends JavaPlugin implements IRelation
//Other Modules
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager);
incognito.setPreferencesManager(preferenceManager);
preferenceManager.GiveItem = true;
Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature);
@ -140,7 +144,6 @@ public class Hub extends JavaPlugin implements IRelation
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
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, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());

View File

@ -57,7 +57,7 @@ public class StaffServer extends JavaPlugin
Punish punish = new Punish(this, webServerAddress, clientManager);
new NpcManager(this, new Creature(this));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager, donationManager);
preferenceManager.GiveItem = false;
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());

View File

@ -109,15 +109,19 @@ public class Arcade extends JavaPlugin
_serverConfiguration = new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
Creature creature = new Creature(this);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager);
Teleport teleport = new Teleport(this, _clientManager);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
@ -128,8 +132,6 @@ public class Arcade extends JavaPlugin
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false);
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);