From 7d14b6073dd66952faf574eb1d818d1724c232fe Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 13 Nov 2016 02:13:52 -0500 Subject: [PATCH] Give SlackAPI a valid payload link, fix some display issues with clans nether, fix claiming in clans nether, update coordinates to match new map --- .../src/mineplex/core/slack/SlackTeam.java | 2 +- .../game/clans/clans/ClansDisplay.java | 11 ++++- .../game/clans/clans/ClansUtility.java | 13 +++--- .../clans/clans/nether/NetherManager.java | 25 ++++++++++++ .../elements/ScoreboardElementPlayer.java | 4 ++ .../clans/worldevent/EventTerrainFinder.java | 22 +++++----- .../game/clans/restart/RestartManager.java | 40 +++++++++++++++++-- .../src/mineplex/game/clans/spawn/Spawn.java | 4 +- 8 files changed, 95 insertions(+), 26 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java index b1d913d5a..4dd60c9fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java @@ -6,7 +6,7 @@ package mineplex.core.slack; public enum SlackTeam { // Dev team - mineplex.slack.com - DEVELOPER("Mineplex Dev", "T045RUM7F", "B2ED9B9Q9", "STwdq9LFar2Qt4H3JWyDK3Ow"), + DEVELOPER("Mineplex Dev", "T045RUM7F", "B3165UYN4", "lV5GESG9FDIHG3mQ0LlOGeNV"), // QA team - mineplexqa.slack.com QA("Mineplex QA", "todo", "todo", "todo"), // TODO: new details diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 17d27fc9c..804690b92 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -65,7 +65,7 @@ public class ClansDisplay extends MiniPlugin boolean safe = _clansManager.getClanUtility().isSafe(player); - PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : _clansManager.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); + PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, (owner.equals("Wilderness") && !_clansManager.getNetherManager().isInNether(player)) ? false : _clansManager.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); UtilServer.getServer().getPluginManager().callEvent(event); @@ -118,6 +118,15 @@ public class ClansDisplay extends MiniPlugin if (relation == ClanRelation.ALLY_TRUST) ownerString += " " + C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } + if (_clansManager.getNetherManager().isInNether(player)) + { + ownerString = C.cClansNether + "The Nether"; + if (_clansManager.getClanUtility().isSafe(player.getLocation())) + { + ownerString = C.cClansNether + "Nether Spawn"; + } + } + // if (_clansManager.getNetherManager().isInNether(player)) // { // _clansManager.message(player, "You are not allowed to claim territory in " + F.clansNether("The Nether") + "."); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index b4dd54100..b1c63970f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -23,7 +23,6 @@ import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; -import mineplex.game.clans.clans.nether.NetherPortal; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; @@ -291,12 +290,9 @@ public class ClansUtility { if (_clansManager.getNetherManager().getNetherWorld().equals(loc.getWorld())) { - for (NetherPortal portal : _clansManager.getNetherManager().getReturnPortals()) + if (_clansManager.getNetherManager().isInSpawn(loc)) { - if (UtilMath.offset2d(loc, portal.getLocation()) <= 5) - { - return true; - } + return true; } } // Fix for PC-279 @@ -779,6 +775,11 @@ public class ClansUtility return false; } + if (_clansManager.getNetherManager().isInNether(caller)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory while in " + F.clansNether("The Nether") + "!")); + } + if (!ClansManager.isClaimable(caller.getLocation())) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 179afb7b7..13ea3c37d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -67,6 +67,11 @@ public class NetherManager extends MiniPlugin private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); + private static final int SPAWN_MIN_X = 30; + private static final int SPAWN_MIN_Z = 99; + private static final int SPAWN_MAX_X = 56; + private static final int SPAWN_MAX_Z = 115; + private PortalRepository _repo; private NetherMinibossManager _miniboss; private World _netherWorld; @@ -149,6 +154,26 @@ public class NetherManager extends MiniPlugin return player.getWorld().equals(_netherWorld); } + /** + * Checks if a location is inside Nether Spawn + * @param loc The location to check + * @return true if the location is inside the Nether Spawn + */ + public boolean isInSpawn(Location loc) + { + if (loc.getWorld().equals(getNetherWorld())) + { + if (loc.getBlockX() >= SPAWN_MIN_X && loc.getBlockX() <= SPAWN_MAX_X) + { + if (loc.getBlockZ() >= SPAWN_MIN_Z && loc.getBlockZ() <= SPAWN_MAX_Z) + { + return true; + } + } + } + return false; + } + /** * Gets the place a player will exit the nether * @param player The player to check diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 3fb06b2f0..b5e11e8a1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -52,6 +52,10 @@ public class ScoreboardElementPlayer implements ScoreboardElement if (_clansManager.getNetherManager().isInNether(player)) { regionString = C.cClansNether + "The Nether"; + if (_clansManager.getClanUtility().isSafe(player.getLocation())) + { + regionString = C.cClansNether + "Nether Spawn"; + } } output.add(regionString); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 378b50478..d8b89874e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -21,7 +21,7 @@ import com.google.common.collect.Lists; public class EventTerrainFinder { - private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(3, TimeUnit.HOURS, TimeUnit.MILLISECONDS); + private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(2, TimeUnit.HOURS, TimeUnit.MILLISECONDS); private ClansManager _clansManager; public EventTerrainFinder(ClansManager clansManager) @@ -135,18 +135,14 @@ public class EventTerrainFinder */ private static enum EventLocation { - NORTH_1("world", -495, 73, -1028), - NORTH_2("world", 197, 66, -1018), - NORTH_3("world", 948, 72, -959), - EAST_1("world", 1109, 66, -753), - EAST_2("world", 1141, 68, 31), - EAST_3("world", 1044, 71, 603), - SOUTH_1("world", 690, 71, 895), - SOUTH_2("world", 144, 66, 1012), - SOUTH_3("world", -1093, 72, 895), - WEST_1("world", -937, 71, 559), - WEST_2("world", -1092, 67, -9), - WEST_3("world", -969, 72, -441); + ONE("world", -662, 64, -1108), + TWO("world", 738, 64, -986), + THREE("world", 1180, 64, -435), + FOUR("world", 995, 64, 550), + FIVE("world", 375, 64, 1142), + SIX("world", -479, 64, 975), + SEVEN("world", -1140, 64, 449), + EIGHT("world", -1014, 64, -342); private String _world; private double _x, _y, _z; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index 2800434cb..23d5fd391 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -14,9 +14,13 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.portal.Portal; +import mineplex.core.slack.SlackAPI; +import mineplex.core.slack.SlackMessage; +import mineplex.core.slack.SlackTeam; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin { @@ -26,10 +30,16 @@ public class RestartManager extends MiniPlugin private Long _restartTime = -1L; private boolean _restarting; + private final String _serverName; + private final boolean _testServer; + public RestartManager(JavaPlugin plugin) { super("Restart Manager", plugin); + _serverName = plugin.getConfig().getString("serverstatus.name"); + _testServer = plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + if (inRestartZone(Calendar.HOUR_OF_DAY)) { _restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS); @@ -44,6 +54,11 @@ public class RestartManager extends MiniPlugin _warnings.add(10000L); _warnings.add(5000L); addCommand(new RestartCommand(this)); + + if (!_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has started up!"), true); + } } private boolean inRestartZone(int hour) @@ -51,7 +66,7 @@ public class RestartManager extends MiniPlugin return hour >= 0 && hour < MAX_RESTART_TIME; //12 am = 0 } - private boolean tryRestart() + private boolean tryRestartTime() { if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock) { @@ -73,6 +88,18 @@ public class RestartManager extends MiniPlugin return true; } + private boolean tryRestartTps() + { + boolean restart = MinecraftServer.getServer().recentTps[0] <= 12; + + if (restart && !_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has scheduled an immediate restart due to low TPS!"), true); + } + + return restart; + } + public void restart() { Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!")); @@ -107,12 +134,19 @@ public class RestartManager extends MiniPlugin { _restarting = true; Portal.getInstance().sendAllPlayers("ClansHub"); - runSyncLater(() -> {Bukkit.shutdown();}, 120L); + runSyncLater(() -> + { + if (!_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " is now restarting!"), true); + } + Bukkit.shutdown(); + }, 120L); } } else { - if (tryRestart()) + if (tryRestartTime() || tryRestartTps()) { restart(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 10df32a92..979b9743e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -460,7 +460,7 @@ public class Spawn extends MiniPlugin public static Location getWestTown() { - return new Location(getSpawnWorld(), -440.91, 65, 23.08); + return new Location(getSpawnWorld(), -440.91, 67, 23.08); } public static Location getWestTownCenter() @@ -470,7 +470,7 @@ public class Spawn extends MiniPlugin public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 65, -23.08); + return new Location(getSpawnWorld(), 440.91, 72, -23.08); } public static Location getEastTownCenter()