Give SlackAPI a valid payload link, fix some display issues with clans nether, fix claiming in clans nether, update coordinates to match new map

This commit is contained in:
AlexTheCoder 2016-11-13 02:13:52 -05:00 committed by Shaun Bennett
parent 5e1fcabe36
commit 7d14b6073d
8 changed files with 95 additions and 26 deletions

View File

@ -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

View File

@ -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") + ".");

View File

@ -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,14 +290,11 @@ public class ClansUtility
{
if (_clansManager.getNetherManager().getNetherWorld().equals(loc.getWorld()))
{
for (NetherPortal portal : _clansManager.getNetherManager().getReturnPortals())
{
if (UtilMath.offset2d(loc, portal.getLocation()) <= 5)
if (_clansManager.getNetherManager().isInSpawn(loc))
{
return true;
}
}
}
// Fix for PC-279
// Do not change to getChunk
// PlayerList#updatePlayers -> iterator -> PlayerVelocityEvent -> getChunk -> loadChunk -> loadPersistentEntities -> addTracker -> ITERATE ON SAME SET
@ -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!"));

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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();
}

View File

@ -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()