diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 66b107d9d..c3f0efc59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -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>> _suspicion = new HashMap>>(); @@ -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) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index 3f764b6f2..ad9615a9f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -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())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index 6da2a2e16..a48011290 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -11,4 +11,5 @@ public class UserPreferences public boolean PartyRequests = true; public boolean Invisibility = false; public boolean HubForcefield = false; + public boolean ShowMacReports = false; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java index 59d972c17..761a11dff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java @@ -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 { private IButton _toggleHubGames; @@ -22,6 +22,7 @@ public class PreferencesPage extends ShopPageBase