diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java index bef877efd..a71666592 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java @@ -1,8 +1,18 @@ package mineplex.core.common.util; import java.util.HashMap; +import java.util.Map; import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.scheduler.BukkitRunnable; + import mineplex.core.common.DummyEntity; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Entity; @@ -13,17 +23,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutBossBar; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scheduler.BukkitRunnable; - public class UtilTextTop { // Base Commands @@ -42,7 +41,7 @@ public class UtilTextTop public static final int EntityDragonId = 777777; public static final int EntityWitherId = 777778; public static final UUID BossUUID = UUID.fromString("178f5cde-2fb0-3e73-8296-967ec7e46748"); - private static HashMap _lastUpdated = new HashMap(); + private static Map _lastUpdated = new HashMap<>(); // Display public static void displayTextBar(final Player player, double healthPercent, String text) @@ -68,7 +67,7 @@ public class UtilTextTop } }; - runnable.runTaskLater(Bukkit.getPluginManager().getPlugins()[0], 20); + runnable.runTaskLater(UtilServer.getPlugin(), 20); if (UtilPlayer.is1_9(player)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java index 4dfdc198b..3d8edd8ec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -65,14 +65,15 @@ public class ClansBanManager extends MiniPlugin private void generatePermissions() { - PermissionGroup.ADMIN.setPermission(Perm.ALERT_PUNISHMENT, true, true); PermissionGroup.CMOD.setPermission(Perm.ALERT_PUNISHMENT, false, true); PermissionGroup.CMA.setPermission(Perm.ALERT_PUNISHMENT, false, true); + PermissionGroup.QA.setPermission(Perm.ALERT_PUNISHMENT, true, true); PermissionGroup.ADMIN.setPermission(Perm.PUNISHMENT_COMMAND, true, true); PermissionGroup.CMOD.setPermission(Perm.PUNISHMENT_COMMAND, false, true); PermissionGroup.CMA.setPermission(Perm.PUNISHMENT_COMMAND, false, true); + PermissionGroup.QA.setPermission(Perm.PUNISHMENT_COMMAND, true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java index f1aef1a3a..6f89f178e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java @@ -546,7 +546,7 @@ public class WebsiteLinkManager extends MiniDbClientPlugin try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(API_URL + "?hash=" + API_KEY + "&" + call).openStream()))) { - reader.lines().forEach(l -> input.append(l)); + reader.lines().forEachOrdered(input::append); } catch (IOException e) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java index 9238be23a..2c2f1305a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java @@ -1,5 +1,10 @@ package mineplex.game.clans.clans.moderation.antialt; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; @@ -17,6 +22,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; import mineplex.core.common.Pair; import mineplex.core.common.util.C; @@ -25,10 +31,11 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.punish.clans.ClansBanManager; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.moderation.antialt.AltRepository.ChainedDatabaseAction; import mineplex.game.clans.clans.moderation.antialt.AltRepository.IpUnbanResult; +import mineplex.game.clans.clans.moderation.antialt.AltRepository.IpUnwhitelistResult; import mineplex.game.clans.clans.moderation.antialt.IpAPIData.ImmutableIpAPIData; -import mineplex.game.clans.clans.moderation.antialt.IpAPIData.LocationInfo; -import mineplex.game.clans.clans.moderation.antialt.IpAPIData.RegionInfo; +import mineplex.serverdata.Utility; import mineplex.serverdata.commands.ServerCommandManager; import net.md_5.bungee.api.ChatColor; @@ -38,6 +45,8 @@ public class AltManager extends MiniPlugin { BAN_IP, UNBAN_IP, + WHITELIST_IP, + UNWHITELIST_IP, CHECK_IP, ACCOUNT_HISTORY, IP_HISTORY, @@ -47,7 +56,7 @@ public class AltManager extends MiniPlugin private final ClansBanManager _punish = Managers.require(ClansBanManager.class); private final CoreClientManager _clientManager = Managers.require(CoreClientManager.class); - private final AltRepository _repo; + protected final AltRepository _repo; private final int _serverId; private final Map> _vpnCache = new HashMap<>(); @@ -98,7 +107,7 @@ public class AltManager extends MiniPlugin { if (result == IpUnbanResult.UNBANNED) { - UtilPlayer.message(caller, F.main(getName(), "Ip successfully banned!")); + UtilPlayer.message(caller, F.main(getName(), "Ip successfully unbanned!")); } else if (result == IpUnbanResult.NOT_BANNED) { @@ -111,6 +120,59 @@ public class AltManager extends MiniPlugin }); } }); + addCommand(new CommandBase(this, Perm.WHITELIST_IP, "whitelistip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /whitelistip ")); + return; + } + final String ip = args[0]; + _repo.whitelistIp(ip, caller.getName(), success -> + { + if (success) + { + UtilPlayer.message(caller, F.main(getName(), "Ip successfully whitelisted!")); + new IpBanNotification(ip).publish(); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "An error occurred while attempting to whitelist that ip!")); + } + }); + } + }); + addCommand(new CommandBase(this, Perm.UNWHITELIST_IP, "unwhitelistip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /unwhitelistip ")); + return; + } + final String ip = args[0]; + _repo.unwhitelistIp(ip, result -> + { + if (result == IpUnwhitelistResult.UNWHITELISTED) + { + UtilPlayer.message(caller, F.main(getName(), "Ip successfully unwhitelisted!")); + } + else if (result == IpUnwhitelistResult.NOT_WHITELISTED) + { + UtilPlayer.message(caller, F.main(getName(), "That ip was not whitelisted!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "An error occurred while attempting to unwhitelist that ip!")); + } + }); + } + }); addCommand(new CommandBase(this, Perm.CHECK_IP, "checkip") { @Override @@ -124,7 +186,9 @@ public class AltManager extends MiniPlugin final String ip = args[0]; runAsync(() -> { - final boolean banned = _repo.checkIpBanned(ip); + Pair status = checkIpStatus(ip); + final boolean banned = status.getLeft(); + final boolean whitelisted = status.getRight(); runSync(() -> { if (banned) @@ -135,6 +199,14 @@ public class AltManager extends MiniPlugin { UtilPlayer.message(caller, F.main(getName(), "That ip is not banned!")); } + if (whitelisted) + { + UtilPlayer.message(caller, F.main(getName(), "That ip is whitelisted!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "That ip is not whitelisted!")); + } }); }); } @@ -287,6 +359,21 @@ public class AltManager extends MiniPlugin }); }); }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionGroup.ADMIN.setPermission(Perm.BAN_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UNBAN_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.WHITELIST_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UNWHITELIST_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.CHECK_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.ACCOUNT_HISTORY, true, true); + PermissionGroup.ADMIN.setPermission(Perm.IP_HISTORY, true, true); + PermissionGroup.ADMIN.setPermission(Perm.CHECK_ALTS, true, true); + PermissionGroup.CMOD.setPermission(Perm.CHECK_ALTS, false, true); } private synchronized boolean checkForVPN(String ipAddress) @@ -294,26 +381,32 @@ public class AltManager extends MiniPlugin _vpnCache.entrySet().removeIf(entry -> UtilTime.elapsed(entry.getValue().getRight(), 120000)); //expire cache Pair cacheValue = _vpnCache.computeIfAbsent(ipAddress, ip -> { - //run api call here - IpAPIData data = new IpAPIData(); - data.status = "success"; - data.accessPackage = "Free"; - data.remaining_requests = 499; - data.ipaddress = ipAddress; - data.host_ip = false; - data.org = "Verizon Fios"; - data.country = new RegionInfo(); - data.country.name = "United States"; - data.country.code = "US"; - data.subdivision = new RegionInfo(); - data.subdivision.name = "New York"; - data.subdivision.code = "NY"; - data.city = "New York"; - data.postal = "10007"; - data.location = new LocationInfo(); - data.location.latitude = 40.7139; - data.location.longitude = -74.0079; - return Pair.create(data.makeImmutable(), System.currentTimeMillis()); + try + { + StringBuilder response = new StringBuilder(); + URLConnection connection = new URL("http://api.vpnblocker.net/v2/json/" + ipAddress + "/1YimOXUxTgh34kNRZYF31y5YEw8Phs").openConnection(); + connection.setConnectTimeout(10000); + connection.setRequestProperty("User-Agent", "Mineplex Clans"); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) + { + reader.lines().forEachOrdered(response::append); + } + if (response.length() == 0) + { + return Pair.create(new IpAPIData().makeImmutable(), System.currentTimeMillis()); + } + IpAPIData data = Utility.deserialize(response.toString(), IpAPIData.class); + if (data == null) + { + return Pair.create(new IpAPIData().makeImmutable(), System.currentTimeMillis()); + } + return Pair.create(data.makeImmutable(), System.currentTimeMillis()); + } + catch (IOException e) + { + e.printStackTrace(); + return Pair.create(new IpAPIData().makeImmutable(), System.currentTimeMillis()); + } }); if (cacheValue.getLeft().host_ip) { @@ -322,9 +415,11 @@ public class AltManager extends MiniPlugin return false; } - private boolean checkIpBanned(String ipAddress) + private Pair checkIpStatus(String ipAddress) { - return _repo.checkIpBanned(ipAddress); + ChainedDatabaseAction action = _repo.checkIpBanned(ipAddress).chain(_repo.checkIpWhitelisted(ipAddress)); + action.execute(); + return Pair.create(action.getResult(AltRepository.BAN_STATUS_KEY), action.getResult(AltRepository.WHITELIST_STATUS_KEY)); } private void checkIfAlt(int accountId, String ipAddress, Consumer callback) @@ -350,12 +445,13 @@ public class AltManager extends MiniPlugin } final String ipAddress = event.getAddress().toString().substring(1); - if (checkForVPN(ipAddress)) + Pair status = checkIpStatus(ipAddress); + if (!status.getRight() && checkForVPN(ipAddress)) { event.disallow(Result.KICK_BANNED, C.cRedB + "VPN/Proxy usage is not permitted on Mineplex Clans"); return; } - if (checkIpBanned(ipAddress)) + if (status.getLeft()) { event.disallow(Result.KICK_BANNED, C.cRedB + "Your IP has been suspended from Mineplex Clans.\n" + C.cGold + "Visit %FORUM_LINK_HERE% for more information."); return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java index e67fa40f5..def04caf5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java @@ -1,9 +1,15 @@ package mineplex.game.clans.clans.moderation.antialt; +import java.sql.Connection; +import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; import java.util.function.Consumer; +import mineplex.core.Managers; import mineplex.core.common.util.EnclosedObject; import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; @@ -13,18 +19,27 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class AltRepository extends RepositoryBase { + public static final String ALT_STATUS_KEY = "ALT_ACCOUNT"; + public static final String WHITELIST_STATUS_KEY = "WHITELISTED_IP"; + public static final String BAN_STATUS_KEY = "BANNED_IP"; + private static final String CREATE_IP_BAN_TABLE = "CREATE TABLE IF NOT EXISTS clansIpBans (ipAddress VARCHAR(16), admin VARCHAR(40), PRIMARY KEY (ipAddress), INDEX adminIndex (admin));"; private static final String FETCH_IP_BAN_INFO = "SELECT * FROM clansIpBans WHERE ipAddress=?;"; private static final String BAN_IP = "INSERT INTO clansIpBans (ipAddress, admin) VALUES (?, ?) ON DUPLICATE KEY UPDATE admin=VALUES(admin);"; private static final String UNBAN_IP = "DELETE FROM clansIpBans WHERE ipAddress=?;"; + private static final String CREATE_IP_WHITELIST_TABLE = "CREATE TABLE IF NOT EXISTS clansIpWhitelists (ipAddress VARCHAR(16), admin VARCHAR(40), PRIMARY KEY (ipAddress), INDEX adminIndex (admin));"; + private static final String FETCH_IP_WHITELIST_INFO = "SELECT * FROM clansIpWhitelists WHERE ipAddress=?;"; + private static final String WHITELIST_IP = "INSERT INTO clansIpWhitelists (ipAddress, admin) VALUES (?, ?) ON DUPLICATE KEY UPDATE admin=VALUES(admin);"; + private static final String UNWHITELIST_IP = "DELETE FROM clansIpWhitelists WHERE ipAddress=?;"; + private static final String CREATE_IP_HISTORY_TABLE = "CREATE TABLE IF NOT EXISTS clansIpHistory (ipAddress VARCHAR(16), accountId INT, serverId INT, PRIMARY KEY (ipAddress, accountId, serverId), INDEX ipIndex (ipAddress), INDEX accountIndex (accountId), INDEX accountServerIndex (accountId, serverId), INDEX ipServerIndex (ipAddress, serverId), FOREIGN KEY (serverId) REFERENCES clanServer(id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private static final String FETCH_LOCAL_ACCOUNT_IPS = "SELECT ipAddress FROM clansIpHistory WHERE accountId=? AND serverId=?;"; - private static final String FETCH_ACCOUNT_IPS = "SELECT ipAddress FROM clansIpHistory WHERE accountId=?;"; - private static final String FETCH_IP_ACCOUNTS = "SELECT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress=?);"; - private static final String FETCH_LOCAL_IP_ACCOUNTS = "SELECT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress=? AND serverId=?);"; - private static final String FETCH_LOCAL_IP_ACCOUNT_IDS = "SELECT accountId FROM clansIpHistory WHERE ipAddress=? AND serverId=?;"; - private static final String FETCH_DUPLICATE_ACCOUNTS = "SELECT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress IN (SELECT ipAddress FROM clansIpHistory WHERE accountId=?));"; + private static final String FETCH_ACCOUNT_IPS = "SELECT DISTINCT ipAddress FROM clansIpHistory WHERE accountId=?;"; + private static final String FETCH_IP_ACCOUNTS = "SELECT DISTINCT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress=?);"; + private static final String FETCH_LOCAL_IP_ACCOUNTS = "SELECT DISTINCT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress=? AND serverId=?);"; + private static final String FETCH_LOCAL_IP_ACCOUNT_IDS = "SELECT DISTINCT accountId FROM clansIpHistory WHERE ipAddress=? AND serverId=?;"; + private static final String FETCH_DUPLICATE_ACCOUNTS = "SELECT DISTINCT name FROM accounts WHERE id IN (SELECT DISTINCT accountId FROM clansIpHistory WHERE ipAddress IN (SELECT DISTINCT ipAddress FROM clansIpHistory WHERE accountId=?));"; private static final String LOGIN_ACCOUNT = "INSERT INTO clansIpHistory (ipAddress, accountId, serverId) VALUES (?, ?, ?);"; public AltRepository() @@ -32,15 +47,34 @@ public class AltRepository extends RepositoryBase super(DBPool.getAccount()); } - public boolean checkIpBanned(String ipAddress) + public ChainedDatabaseAction checkIpBanned(String ipAddress) { - EnclosedObject recordExists = new EnclosedObject<>(false); - executeQuery(FETCH_IP_BAN_INFO, resultSet -> + return new ChainedDatabaseAction((connection, resultMap) -> { - recordExists.Set(resultSet.next()); - }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); - - return recordExists.Get(); + EnclosedObject recordExists = new EnclosedObject<>(false); + + executeQuery(connection, FETCH_IP_BAN_INFO, resultSet -> + { + recordExists.Set(resultSet.next()); + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + resultMap.put(BAN_STATUS_KEY, recordExists.Get()); + }); + } + + public ChainedDatabaseAction checkIpWhitelisted(String ipAddress) + { + return new ChainedDatabaseAction((connection, resultMap) -> + { + EnclosedObject recordExists = new EnclosedObject<>(false); + + executeQuery(connection, FETCH_IP_WHITELIST_INFO, resultSet -> + { + recordExists.Set(resultSet.next()); + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + resultMap.put(WHITELIST_STATUS_KEY, recordExists.Get()); + }); } public void banIp(String ipAddress, String admin, Consumer callback) @@ -91,6 +125,54 @@ public class AltRepository extends RepositoryBase }); } + public void whitelistIp(String ipAddress, String admin, Consumer callback) + { + UtilServer.runAsync(() -> + { + Consumer passThrough = success -> + { + if (callback != null) + { + UtilServer.runSync(() -> callback.accept(success)); + } + }; + executeInsert(WHITELIST_IP, rs -> passThrough.accept(true), () -> passThrough.accept(false), new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnVarChar("admin", admin.length(), admin)); + }); + } + + public void unwhitelistIp(String ipAddress, Consumer callback) + { + UtilServer.runAsync(() -> + { + Consumer passThrough = result -> + { + if (callback != null) + { + UtilServer.runSync(() -> callback.accept(result)); + } + }; + EnclosedObject errored = new EnclosedObject<>(false); + + int rows = executeUpdate(UNWHITELIST_IP, () -> + { + errored.Set(true); + passThrough.accept(IpUnwhitelistResult.ERROR); + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + if (!errored.Get()) + { + if (rows > 0) + { + passThrough.accept(IpUnwhitelistResult.UNWHITELISTED); + } + else + { + passThrough.accept(IpUnwhitelistResult.NOT_WHITELISTED); + } + } + }); + } + public void login(String ipAddress, int accountId, int serverId) { UtilServer.runAsync(() -> @@ -237,4 +319,84 @@ public class AltRepository extends RepositoryBase NOT_BANNED, ERROR; } + + protected static enum IpUnwhitelistResult + { + UNWHITELISTED, + NOT_WHITELISTED, + ERROR; + } + + protected static class ChainedDatabaseAction + { + private final BiConsumer> _action; + private final Map _results = new HashMap<>(); + private final Object _resultLock = new Object(); + + public ChainedDatabaseAction(BiConsumer> action) + { + _action = action; + } + + public ChainedDatabaseAction chain(ChainedDatabaseAction action) + { + return new ChainedDatabaseAction(_action.andThen(action._action)); + } + + @SuppressWarnings("unchecked") + public T getResult(String key) + { + synchronized (_resultLock) + { + Object result = _results.get(key); + if (result == null) + { + return null; + } + try + { + return (T) result; + } + catch (ClassCastException ex) + { + ex.printStackTrace(); + return null; + } + } + } + + public void execute() + { + synchronized (_resultLock) + { + try (Connection c = Managers.get(AltManager.class)._repo.getConnection()) + { + _action.accept(c, _results); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + + public void executeAsync(Runnable onComplete) + { + UtilServer.runAsync(() -> + { + synchronized (_resultLock) + { + try (Connection c = Managers.get(AltManager.class)._repo.getConnection()) + { + _action.accept(c, _results); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + UtilServer.runSync(onComplete); + }); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java index 635288c93..6f7ec852f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java @@ -32,7 +32,7 @@ public class IpAPIData public ImmutableIpAPIData makeImmutable() { - return new ImmutableIpAPIData(this); + return ImmutableIpAPIData.create(this); } public static class ImmutableIpAPIData @@ -63,7 +63,7 @@ public class IpAPIData public final ImmutableLocationInfo location; - public ImmutableIpAPIData(IpAPIData base) + private ImmutableIpAPIData(IpAPIData base) { status = base.status; msg = base.msg; @@ -72,11 +72,20 @@ public class IpAPIData ipaddress = base.ipaddress; host_ip = base.host_ip; org = base.org; - country = new ImmutableRegionInfo(base.country); - subdivision = new ImmutableRegionInfo(base.subdivision); + country = ImmutableRegionInfo.create(base.country); + subdivision = ImmutableRegionInfo.create(base.subdivision); city = base.city; postal = base.postal; - location = new ImmutableLocationInfo(base.location); + location = ImmutableLocationInfo.create(base.location); + } + + public static ImmutableIpAPIData create(IpAPIData base) + { + if (base == null) + { + return null; + } + return new ImmutableIpAPIData(base); } } @@ -93,11 +102,21 @@ public class IpAPIData public final String code; - public ImmutableRegionInfo(RegionInfo base) + private ImmutableRegionInfo(RegionInfo base) { name = base.name; code = base.code; } + + public static ImmutableRegionInfo create(RegionInfo base) + { + if (base == null) + { + return null; + } + + return new ImmutableRegionInfo(base); + } } public static class LocationInfo @@ -117,10 +136,20 @@ public class IpAPIData @SerializedName("long") public final double longitude; - public ImmutableLocationInfo(LocationInfo base) + private ImmutableLocationInfo(LocationInfo base) { latitude = base.latitude; longitude = base.longitude; } + + public static ImmutableLocationInfo create(LocationInfo base) + { + if (base == null) + { + return null; + } + + return new ImmutableLocationInfo(base); + } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java index 6f14d1bc4..160b4d1b0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java @@ -18,6 +18,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -94,6 +95,15 @@ public class PvPTimerManager extends MiniPlugin } } }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionGroup.PLAYER.setPermission(Perm.PVP_ENABLE_SELF, true, true); + PermissionGroup.CMOD.setPermission(Perm.PVP_ENABLE_OTHER, false, true); + PermissionGroup.ADMIN.setPermission(Perm.PVP_ENABLE_OTHER, true, true); } private String getPvPTimerFile(String fileName) throws IOException @@ -179,7 +189,7 @@ public class PvPTimerManager extends MiniPlugin { if (addPvPTimer(event.getPlayer())) { - UtilPlayer.message(event.getPlayer(), "You now have 1 hour of PvP Protection!"); + runSyncLater(() -> UtilPlayer.message(event.getPlayer(), F.main(getName(), "You now have 1 hour of PvP Protection!")), 40L); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java index 575d9e61a..b694a31f2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java @@ -9,10 +9,10 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import mineplex.core.common.Pair; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilWorld; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -21,7 +21,7 @@ import mineplex.game.clans.clans.worldevent.api.WorldEvent; public class CapturePointEvent extends WorldEvent { - private static final long MAX_TICKS = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; + private static final long MAX_TICKS = 20 * 10;//UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; private Player _capturing = null; private Player _winner = null; private Pair _resetData = null; @@ -81,12 +81,17 @@ public class CapturePointEvent extends WorldEvent if (_ticks >= MAX_TICKS) { _winner = _capturing; + UtilTextTop.display(C.cGoldB + "Capturing Point: " + C.cWhite + "100%", _capturing); stop(); + return; } else if (Recharge.Instance.use(_capturing, "Capture Point Alert", 30000, false, false)) { announceMessage(F.name(_capturing.getName()) + " is still capturing the point!"); } + double percentage = ((double)_ticks) / ((double)MAX_TICKS); + percentage *= 100; + UtilTextTop.display(C.cGoldB + "Capturing Point: " + C.cWhite + (int)Math.floor(percentage) + "%", _capturing); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java index 1ecca6318..7236e034a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java @@ -7,7 +7,7 @@ import org.bukkit.World; public enum CapturePointLocation { - ONE(1075, 67, -456), + ONE(1075, 66, -456), TWO(636, 65, 1102), THREE(-1140, 57, -163), FOUR(-636, 66, -948), diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java index e56cdcda7..715f3d42a 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java @@ -17,7 +17,7 @@ public class ClansServerShop extends ShopBase { public ClansServerShop(ClansTransferManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Clans"); + super(plugin, clientManager, donationManager, "Clans Servers"); } @Override