Add show mac reports user pref for mod+

This commit is contained in:
Shaun Bennett 2014-09-29 11:14:20 -05:00
parent efa03945cb
commit 7892c442d0
6 changed files with 69 additions and 29 deletions

View File

@ -6,20 +6,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.MiniPlugin;
import mineplex.core.antihack.types.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.portal.Portal;
import mineplex.core.punish.Punish;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -33,6 +19,24 @@ import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.types.Fly;
import mineplex.core.antihack.types.Idle;
import mineplex.core.antihack.types.Speed;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Punish;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class AntiHack extends MiniPlugin
{
private static Object _antiHackLock = new Object();
@ -43,6 +47,8 @@ public class AntiHack extends MiniPlugin
public Punish Punish;
public Portal Portal;
private PreferencesManager _preferences;
private CoreClientManager _clientManager;
//Record Offenses
private HashMap<Player, HashMap<String, ArrayList<Long>>> _suspicion = new HashMap<Player, HashMap<String, ArrayList<Long>>>();
@ -71,12 +77,14 @@ public class AntiHack extends MiniPlugin
private AntiHackRepository _repository;
protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal)
protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager)
{
super("AntiHack", plugin);
Punish = punish;
Portal = portal;
_preferences = preferences;
_clientManager = clientManager;
_repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name"));
_repository.initialize();
@ -88,9 +96,9 @@ public class AntiHack extends MiniPlugin
_detectors.add(new Speed(this));
}
public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal)
public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager)
{
Instance = new AntiHack(plugin, punish, portal);
Instance = new AntiHack(plugin, punish, portal, preferences, clientManager);
}
@EventHandler
@ -248,7 +256,7 @@ public class AntiHack extends MiniPlugin
}
for (Player admin : UtilServer.getPlayers())
if (admin.isOp() && UtilGear.isMat(admin.getItemInHand(), Material.PAPER))
if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
UtilPlayer.message(admin, C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
// Print (Debug)

View File

@ -15,10 +15,10 @@ import mineplex.core.database.column.ColumnVarChar;
public class PreferencesRepository extends RepositoryBase
{
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield FROM accountPreferences WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ? WHERE uuid=?;";
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports FROM accountPreferences WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ? WHERE uuid=?;";
public PreferencesRepository(JavaPlugin plugin, String connectionString)
{
@ -54,7 +54,8 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(6, entry.getValue().PartyRequests);
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
preparedStatement.setString(9, entry.getKey());
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setString(10, entry.getKey());
preparedStatement.addBatch();
}
@ -103,6 +104,7 @@ public class PreferencesRepository extends RepositoryBase
preferences.PartyRequests = resultSet.getBoolean(6);
preferences.Invisibility = resultSet.getBoolean(7);
preferences.HubForcefield = resultSet.getBoolean(8);
preferences.ShowMacReports = resultSet.getBoolean(9);
}
}
}, new ColumnVarChar("uuid", 100, uuid.toString()));

View File

@ -11,4 +11,5 @@ public class UserPreferences
public boolean PartyRequests = true;
public boolean Invisibility = false;
public boolean HubForcefield = false;
public boolean ShowMacReports = false;
}

View File

@ -1,5 +1,9 @@
package mineplex.core.preferences.ui;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.donation.DonationManager;
@ -9,10 +13,6 @@ import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class PreferencesPage extends ShopPageBase<PreferencesManager, PreferencesShop>
{
private IButton _toggleHubGames;
@ -22,6 +22,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
private IButton _toggleHubPartyRequests;
private IButton _toggleHubInvisibility;
private IButton _toggleHubForcefield;
private IButton _toggleMacReports;
private boolean _hubGamesToggled;
private boolean _hubPlayersToggled;
@ -30,6 +31,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
private boolean _hubPartyRequestsToggled;
private boolean _hubInvisibilityToggled;
private boolean _hubForcefieldToggled;
private boolean _macReportsToggled;
public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
@ -145,6 +147,21 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
toggleHubForcefield(player);
}
};
_toggleMacReports = new IButton()
{
@Override
public void ClickedLeft(Player player)
{
toggleMacReports(player);
}
@Override
public void ClickedRight(Player player)
{
toggleMacReports(player);
}
};
}
private void buildPreference(int index, Material material, String name, boolean preference, IButton button)
@ -211,6 +228,13 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
_hubGamesToggled = !_hubGamesToggled;
BuildPage();
}
protected void toggleMacReports(org.bukkit.entity.Player player)
{
Plugin.Get(player).ShowMacReports = !Plugin.Get(player).ShowMacReports;
_macReportsToggled = !_macReportsToggled;
BuildPage();
}
@Override
public void PlayerClosed()
@ -249,6 +273,11 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
{
buildPreference(39, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(41, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(43, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
}
else if (ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR))
{
buildPreference(40, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
}
}

View File

@ -10,7 +10,6 @@ import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
@ -50,6 +49,7 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
@ -94,7 +94,7 @@ public class Hub extends JavaPlugin implements IRelation
//new FriendManager(this, packetHandler);
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
AntiHack.Initialize(this, punish, portal);
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);

View File

@ -104,7 +104,7 @@ public class Arcade extends JavaPlugin
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
BlockRestore blockRestore = new BlockRestore(this);