diff --git a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml index b32fcf94a..4b46f2b44 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml +++ b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml @@ -28,10 +28,6 @@ commons-codec commons-codec - - net.kencochrane.raven - raven - net.md-5 bungeecord-proxy diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java index 56e179590..91039533d 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java @@ -1,39 +1,21 @@ package mineplex.bungee; -import java.util.logging.Handler; -import java.util.logging.Level; import mineplex.bungee.lobbyBalancer.LobbyBalancer; import mineplex.bungee.motd.MotdManager; import mineplex.bungee.playerCount.PlayerCount; import mineplex.bungee.playerStats.PlayerStats; import mineplex.bungee.playerTracker.PlayerTracker; -import net.kencochrane.raven.DefaultRavenFactory; -import net.kencochrane.raven.dsn.Dsn; -import net.kencochrane.raven.jul.SentryHandler; import net.md_5.bungee.api.plugin.Plugin; public class Mineplexer extends Plugin { @Override public void onEnable() { - getProxy().getScheduler().runAsync(this, new Runnable() { - @Override - public void run() { - // Sentry setup - Handler sentry = new SentryHandler(new DefaultRavenFactory().createRavenInstance( - new Dsn("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323" - ))); - sentry.setLevel(Level.SEVERE); - getProxy().getLogger().addHandler(sentry); - } - }); - new MotdManager(this); new LobbyBalancer(this); - PlayerCount playerCount = new PlayerCount(this); + new PlayerCount(this); new FileUpdater(this); new PlayerStats(this); - //new InternetStatus(this); new PlayerTracker(this); } } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index 5f7153ae9..0c57abfea 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -2,7 +2,6 @@ package mineplex.bungee.lobbyBalancer; import java.io.File; import java.net.InetSocketAddress; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -12,21 +11,24 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ServerRepository; -import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; +import com.google.common.collect.Lists; + public class LobbyBalancer implements Listener, Runnable { private Plugin _plugin; private ServerRepository _repository; - private List _sortedLobbies = new ArrayList(); + private List _sortedLobbies = Lists.newArrayList(); + private List _sortedClans = Lists.newArrayList(); private static Object _serverLock = new Object(); private int _lobbyIndex = 0; + private int _clansIndex = 0; public LobbyBalancer(Plugin plugin) { @@ -35,7 +37,7 @@ public class LobbyBalancer implements Listener, Runnable Region region = !new File("eu.dat").exists() ? Region.US : Region.EU; _repository = ServerManager.getServerRepository(region); - loadLobbyServers(); + run(); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); _plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS); @@ -44,27 +46,49 @@ public class LobbyBalancer implements Listener, Runnable @EventHandler public void playerConnect(ServerConnectEvent event) { - if (!event.getTarget().getName().equalsIgnoreCase("Lobby")) - return; - - synchronized (_serverLock) + if (event.getTarget().getName().equalsIgnoreCase("Lobby")) { - if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount()) - _lobbyIndex = 0; - - event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_lobbyIndex).getName())); - _sortedLobbies.get(_lobbyIndex).incrementPlayerCount(1); - System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedLobbies.get(_lobbyIndex).getName() + "(" + _sortedLobbies.get(_lobbyIndex).getPublicAddress() + ")"); - _lobbyIndex++; + synchronized (_serverLock) + { + if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount()) + _lobbyIndex = 0; + + event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_lobbyIndex).getName())); + _sortedLobbies.get(_lobbyIndex).incrementPlayerCount(1); + System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedLobbies.get(_lobbyIndex).getName() + "(" + _sortedLobbies.get(_lobbyIndex).getPublicAddress() + ")"); + _lobbyIndex++; + } + } + if (event.getTarget().getName().equalsIgnoreCase("ClansHub")) + { + synchronized (_serverLock) + { + if (_clansIndex >= _sortedClans.size() || _sortedClans.get(_clansIndex).getPlayerCount() >= _sortedClans.get(_clansIndex).getMaxPlayerCount()) + _clansIndex = 0; + + event.setTarget(_plugin.getProxy().getServerInfo(_sortedClans.get(_clansIndex).getName())); + _sortedClans.get(_clansIndex).incrementPlayerCount(1); + System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedClans.get(_clansIndex).getName() + "(" + _sortedClans.get(_clansIndex).getPublicAddress() + ")"); + _clansIndex++; + } } } public void run() { - loadLobbyServers(); + loadServers(); + + if (!_plugin.getProxy().getServers().containsKey("ClansHub")) + { + _plugin.getProxy().getServers().put("ClansHub", _plugin.getProxy().constructServerInfo("ClansHub", new InetSocketAddress("lobby.mineplex.com", 25565), "LobbyBalancer", false)); + } + if (!_plugin.getProxy().getServers().containsKey("Lobby")) + { + _plugin.getProxy().getServers().put("Lobby", _plugin.getProxy().constructServerInfo("Lobby", new InetSocketAddress("lobby.mineplex.com", 25565), "LobbyBalancer", false)); + } } - public void loadLobbyServers() + public void loadServers() { Collection servers = _repository.getServerStatuses(); @@ -72,6 +96,7 @@ public class LobbyBalancer implements Listener, Runnable { long startTime = System.currentTimeMillis(); _sortedLobbies.clear(); + _sortedClans.clear(); for (MinecraftServer server : servers) { @@ -88,9 +113,17 @@ public class LobbyBalancer implements Listener, Runnable _sortedLobbies.add(server); } } + if (server.getName().toUpperCase().startsWith("CLANSHUB")) + { + if (server.getMotd() == null || !server.getMotd().contains("Restarting")) + { + _sortedClans.add(server); + } + } } Collections.sort(_sortedLobbies, new LobbySorter()); + Collections.sort(_sortedClans, new LobbySorter()); long timeSpentInLock = System.currentTimeMillis() - startTime; diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index 1f5bc2b09..aa2565f27 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -1,20 +1,18 @@ package mineplex.bungee.motd; -import java.awt.Color; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; import mineplex.serverdata.Region; -import mineplex.serverdata.data.BungeeServer; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ConnectionData; -import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ConnectionData.ConnectionType; -import net.md_5.bungee.api.ChatColor; +import mineplex.serverdata.servers.ServerManager; import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; @@ -31,6 +29,8 @@ public class MotdManager implements Listener, Runnable private Random _random = new Random(); private String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r"; private List _motdLines; + private String _firstCLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r"; + private List _motdCLines; public MotdManager(Plugin plugin) { @@ -70,25 +70,50 @@ public class MotdManager implements Listener, Runnable public void serverPing(ProxyPingEvent event) { net.md_5.bungee.api.ServerPing serverPing = event.getResponse(); - - String motd = _firstLine; - if (_motdLines != null && _motdLines.size() > 0) + if (event.getConnection().getListener() != null && event.getConnection().getListener().getDefaultServer().equalsIgnoreCase("ClansHub")) { - motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size())); + String motd = _firstCLine; + if (_motdCLines != null && _motdCLines.size() > 0) + { + motd += "\n" + _motdCLines.get(_random.nextInt(_motdCLines.size())); + } + event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject())); + } + else + { + String motd = _firstLine; + if (_motdLines != null && _motdLines.size() > 0) + { + motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size())); + } + event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject())); } - - event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject())); } @Override public void run() { - GlobalMotd motd = _repository.getElement("MainMotd"); - - if (motd != null) - { - _motdLines = motd.getMotd(); - _firstLine = motd.getHeadline(); + { + GlobalMotd motd = _repository.getElement("MainMotd"); + + if (motd != null) + { + _motdLines = motd.getMotd(); + _firstLine = motd.getHeadline(); + } + } + { + GlobalMotd motd = _repository.getElement("ClansMotd"); + + if (motd != null) + { + _motdCLines = motd.getMotd(); + _firstCLine = motd.getHeadline(); + } + else + { + _repository.addElement(new GlobalMotd("ClansMotd", "§4§lMineplex Clans§r", Arrays.asList("Default MOTD"))); + } } } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java index 61767b81d..9c6cdfbc5 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java @@ -1,7 +1,6 @@ package mineplex.bungee.playerCount; import java.io.File; -import java.util.UUID; import java.util.concurrent.TimeUnit; import mineplex.bungee.status.InternetStatus; @@ -12,7 +11,6 @@ import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ConnectionData; import mineplex.serverdata.servers.ConnectionData.ConnectionType; import mineplex.serverdata.servers.ServerManager; -import mineplex.serverdata.servers.ServerRepository; import net.md_5.bungee.api.ServerPing.Players; import net.md_5.bungee.api.config.ListenerInfo; import net.md_5.bungee.api.event.ProxyPingEvent; @@ -39,7 +37,13 @@ public class PlayerCount implements Listener, Runnable _plugin.getProxy().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next(); + for (ListenerInfo info : _plugin.getProxy().getConfigurationAdapter().getListeners()) + { + if (info.getDefaultServer().equalsIgnoreCase("Lobby")) + { + _listenerInfo = info; + } + } _repository = new RedisDataRepository(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL), Region.ALL, BungeeServer.class, "bungeeServers"); @@ -55,7 +59,10 @@ public class PlayerCount implements Listener, Runnable public void run() { BungeeServer snapshot = generateSnapshot(); - _repository.addElement(snapshot, 15); // Update with a 15 second expiry on session + if (snapshot != null) + { + _repository.addElement(snapshot, 15); // Update with a 15 second expiry on session + } _totalPlayers = fetchPlayerCount(); } @@ -84,6 +91,10 @@ public class PlayerCount implements Listener, Runnable */ private BungeeServer generateSnapshot() { + if (_listenerInfo == null) + { + return null; + } String name = _listenerInfo.getHost().getAddress().getHostAddress(); String host = _listenerInfo.getHost().getAddress().getHostAddress(); int port = _listenerInfo.getHost().getPort(); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java deleted file mode 100644 index 550a761a7..000000000 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java +++ /dev/null @@ -1,41 +0,0 @@ -package mineplex.core.common; - -import mineplex.core.common.util.C; -import org.bukkit.Material; - -public enum CurrencyType -{ - TOKEN("Tokens", "Token", C.cWhite, Material.EMERALD), - TREASURE_SHARD("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD), - GEM("Gems", "Gem", C.cGreen, Material.EMERALD), - GOLD("Gold", "Gold", C.cGold, Material.GOLD_NUGGET); - - private String _plural; - private String _single; - private String _color; - private Material _displayMaterial; - - CurrencyType(String plural, String single, String color, Material displayMaterial) - { - _plural = plural; - _single = single; - _color = color; - _displayMaterial = displayMaterial; - } - - @Deprecated - public String getPrefix() - { - return _plural; - } - - public String getString(int amount) - { - return _color + amount + " " + (amount == 1 ? _single : _plural); - } - - public Material getDisplayMaterial() - { - return _displayMaterial; - } -} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java index 7b985dd82..279747684 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java @@ -42,6 +42,7 @@ public class SortedSchematicLoader if (entry != null && !entry.getKey().equals(_currentValue)) { _currentValue = entry.getKey(); + Schematic schematic = entry.getValue(); entry.getValue().paste(_pasteLocation, false); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java index 06fdc0896..3b12c1d0b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiEndpoint.java @@ -1,23 +1,30 @@ package mineplex.core.common.api; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * @author Shaun Bennett */ public class ApiEndpoint { - private static final String API_HOST = "10.33.53.12"; -// private static final String API_HOST = "localhost"; -// private static final int API_PORT = 3000; - private static final int API_PORT = 7979; - private Gson _gson; private ApiWebCall _webCall; - public ApiEndpoint(String path, Gson gson) + public ApiEndpoint(ApiHost host, String path) { - String url = "http://" + API_HOST + ":" + API_PORT + path; + this(host, path, new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy()) + .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create()); + } + + public ApiEndpoint(ApiHost host, String path, Gson gson) + { + this(host.getHost(), host.getPort(), path, gson); + } + + public ApiEndpoint(String host, int port, String path, Gson gson) + { + String url = "http://" + host + ":" + port + path; _webCall = new ApiWebCall(url, gson); _gson = gson; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java new file mode 100644 index 000000000..93dbf761b --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java @@ -0,0 +1,31 @@ +package mineplex.core.common.api; + +/** + * TODO: Store this in a file instead of being hardcoded + * + * @author Shaun Bennett + */ +public enum ApiHost +{ + AMPLIFIERS("10.33.53.12", 7979), + ANTISPAM("10.33.53.12", 8181); + + private String _host; + private int _port; + + ApiHost(String host, int port) + { + _host = host; + _port = port; + } + + public String getHost() + { + return _host; + } + + public int getPort() + { + return _port; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java index 492c58bfc..e08a70c0d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java @@ -283,13 +283,29 @@ public class Schematic return index < _blocks.length && index >= 0; } - public short getBlock(int x, int y, int z) + public Short getBlock(int x, int y, int z) { + if (getIndex(x, y, z) >= _blocks.length) + { + return null; + } + if (getIndex(x, y, z) < 0) + { + return null; + } return _blocks[getIndex(x, y, z)]; } - public byte getData(int x, int y, int z) + public Byte getData(int x, int y, int z) { + if (getIndex(x, y, z) >= _blocks.length) + { + return null; + } + if (getIndex(x, y, z) < 0) + { + return null; + } return _blockData[getIndex(x, y, z)]; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java index e3b8c1d0a..b45c9b682 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java @@ -99,10 +99,13 @@ public class SchematicRunnable implements Runnable private void setBlock(Block block, int x, int y, int z) { - - int materialId = _schematic.getBlock(x, y, z); - byte data = _schematic.getData(x, y, z); - + Short materialId = _schematic.getBlock(x, y, z); + Byte data = _schematic.getData(x, y, z); + + if (materialId == null || data == null) + { + return; + } Material material = Material.getMaterial(materialId); if (material == null) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java new file mode 100644 index 000000000..f82182bb6 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java @@ -0,0 +1,41 @@ +package mineplex.core.common.currency; + +import org.bukkit.Material; + +/** + * Currency is the base class for all currency types in mineplex: + * - Global currencies, found in {@link GlobalCurrency}, e.g., treasure shards + * - Clans gold, found in the Mineplex.Game.Clans project + */ +public class Currency +{ + private final String _plural; + private final String _singular; + private final String _color; + private final Material _displayMaterial; + + public Currency(String plural, String singular, String color, Material displayMaterial) + { + this._plural = plural; + this._singular = singular; + this._color = color; + this._displayMaterial = displayMaterial; + } + + @Deprecated + public String getPrefix() + { + return _plural; + } + + public String getString(int amount) + { + return _color + amount + " " + (amount == 1 ? _singular : _plural); + } + + public Material getDisplayMaterial() + { + return _displayMaterial; + } +} + diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java new file mode 100644 index 000000000..1e6b6bc03 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java @@ -0,0 +1,17 @@ +package mineplex.core.common.currency; + +import mineplex.core.common.util.C; +import org.bukkit.Material; + +/** + * A GlobalCurrency is one whose state is shared between all Mineplex servers. + * GlobalCurrencies can be retrieved and modified through DonationManager/Donor in Mineplex.Core + */ +public class GlobalCurrency extends Currency { + public static final GlobalCurrency TREASURE_SHARD = new GlobalCurrency("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD); + public static final GlobalCurrency GEM = new GlobalCurrency("Gems", "Gem", C.cGreen, Material.EMERALD); + + public GlobalCurrency(String plural, String singular, String color, Material displayMaterial) { + super(plural, singular, color, displayMaterial); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java new file mode 100644 index 000000000..12b860d19 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java @@ -0,0 +1,60 @@ +package mineplex.core.common.events; + +import org.bukkit.entity.Entity; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; + +/** + * Called just before UtilAction#velocity changes an entity's velocity. + */ +public class EntityVelocityChangeEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Entity _ent; + private Vector _vel; + + private boolean _cancelled; + + public EntityVelocityChangeEvent(Entity entity, Vector velocity) + { + _ent = entity; + _vel = velocity; + } + + public Entity getEntity() + { + return _ent; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public Vector getVelocity() + { + return _vel; + } + + public void setVelocity(Vector velocity) + { + _vel = velocity; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java index f4ce9532e..c32abd4a8 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java @@ -108,7 +108,7 @@ public class JsonMessage public void sendToPlayer(Player player) { - UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + player.getName() + " " + toString()); + ((CraftPlayer) player).getHandle().sendMessage(IChatBaseComponent.ChatSerializer.a(toString())); } /** diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index b89b34866..5494a5672 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -1,7 +1,22 @@ package mineplex.core.common.skin; +import java.lang.reflect.Field; +import java.util.Base64; +import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.UUID; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.authlib.minecraft.InsecureTextureException; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository; +import mineplex.core.common.util.UtilPlayer; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Player; @@ -16,20 +31,42 @@ import net.minecraft.server.v1_8_R3.MinecraftKey; import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagList; import net.minecraft.server.v1_8_R3.NBTTagString; +import org.bukkit.inventory.meta.SkullMeta; public class SkinData { + private static final Field PROFILE_FIELD; + + static + { + try + { + PROFILE_FIELD = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaSkull").getDeclaredField("profile"); + PROFILE_FIELD.setAccessible(true); + } + catch (ReflectiveOperationException ex) + { + throw new RuntimeException(ex); + } + } + private static long _nameCount = -99999999999999L; public final static SkinData FREEDOM_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY1NzA5NDAzODcsInByb2ZpbGVJZCI6IjQwZWQ5NzU1OWIzNTQ1M2Q4NjU1ZmMwMDM5OGRiNmI5IiwicHJvZmlsZU5hbWUiOiJTcG9vYm5jb29iciIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4N2Q4OGNlYzNmOWI0M2RiNDg1YTU0Mjc2YTQ1MjQzNGFiZDI2ZDMzY2QzZmZhMTM2N2ZiMzVmOWUzODQifX19", "UgsQyW/HJ/jmDzfI1d7RWFbhKi8PeJAKBuAOk7ajS5dzH5od301KfcmiT2X3TU7cBbUswcKtDb2F/m7gNrg/t+pU7Bi9UKzyALEu9HRjd4s1uKbqGkBip1z5Qycp4fhkSyKvtvTnA2fhpP9oHtE5FxGXdMhZXyFkLrli4Hyxp1BI0N4h7pgbcMaISPS0ZYzDRNxkrSnl3y3KyKn5Rl5qH7utmQtAjoyx9aueMZxG3tg/igfYF7uAvvmuYKsSiTZWZOOuSh+U1dkP+ZE/cQANfryXkLJSJHa9YZPCMJHXe4mMoAyu0/quwZCW9NlW3P30XeCfZ87IxfKxISIP0dLgY8hUJyCuI2u5U7TEDrDggPKr6XTcIbX2kFKOsYSeovsAgjC+1UKFH4Ba0jTbRmqzPK49fk/jU8XqRP2Gl9UZDIVbc0dMEXNOeJ0e0wejDtSyX8flBk9sIKYwqeB9ns4cFqSyTI5tKnNin12BNTFRK/bDp8dN7nloyQvhDGlW88UlnJmOFhR6R0naP89VM04VCLaYCr6jyv/ZwV88uPvL2kjhx14qSFfgqJI5ORhFgYkuc+nhyQaD8+y2t3ZMs0HAfoujmq98lp2ECLWyI0ATUcXjUyNYadLj4valS/m0jl7U2fwzcmVMQqOC3ddu6mHbt871hIkG2X4v6kEcVAtKmkg="); + + public final static SkinData ALEX = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY3Mzc4OTE4MTgsInByb2ZpbGVJZCI6IjZhYjQzMTc4ODlmZDQ5MDU5N2Y2MGY2N2Q5ZDc2ZmQ5IiwicHJvZmlsZU5hbWUiOiJNSEZfQWxleCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7Im1ldGFkYXRhIjp7Im1vZGVsIjoic2xpbSJ9LCJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzYjA5ODk2NzM0MGRhYWM1MjkyOTNjMjRlMDQ5MTA1MDliMjA4ZTdiOTQ1NjNjM2VmMzFkZWM3YjM3NTAifX19", "BCyo2Ycx5cxjS9eR8ejakJ0inXSaiOO/2Wb3GoOSBFeKmnLpigR2kbvnIv0j+R5wtGLAbcAmxCZzvI9VpkHC0Al7zyAzY+WypfXi5MAju+dpVdCmp8p3m3oznYscPaI1ADR8ecQBMLFeG8RWuWha5whUyyRNQU8pBPbKMcsIMOn2voCQkH3cjtrZRgDGebxF32CE7I10GEhiFv8UyBVhZ11t6Jbbsj345j0ZHoydTlGADFFpnx+bAQ6BQlkMgNOWAJoI7/3p6IjFQUVYQV70o3VvP9G+B0VwHSQPxhCYxgF/1PcmKsET/HN6cPR34qKJ5HiSt2oS5q/EqLPc9cK/pFAVb+/rq/Z/TSVL94SE/OcImT7NHvVOqurLPLNyj7SMbQvL3bZS3wNkeU7TIkQkGiza2jmeTfPOkBXwMUBl95b+BX3aM36EtyZ4jL1eTOJdqG4x5JG9uGVvcGHw5289ykXUW3L3+A/9J2uYT3mzH9dJ1YLGA3dmTmMqjWrJRxdA5OU46fREsMWMaELbpiHOkhAgqMW1Bofs4hdvkBZE3JIbjIivncvXVU0MGgnd//U4P5iteUMY8Dpc+uKJ3N8KMojCbhWiig0ElLMuNFbNG9PVsUNwwT/wYLJZ3PJ0VBcNERgAWnJ16DM4oA8SfAKosmSQBCW11+1Sxfkj55QoxH0="); + public final static SkinData STEVE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY3MzgxOTAzNDYsInByb2ZpbGVJZCI6ImJiYjg3ZGJlNjkwZjQyMDViZGM1NzJmZmI4ZWJjMjlkIiwicHJvZmlsZU5hbWUiOiJkaXJld29sZjIwIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82NmZlNTE3NjY1MTdmM2QwMWNmZGI3MjQyZWI1ZjM0YWVhOTYyOGExNjZlM2U0MGZhZjRjMTMyMTY5NiJ9fX0=", "xIDCRBS39ZhhROcYkYORDcWosWqR5xvrTTScNzpt8WtBq1cAoL1mXEi/PtBrEEvajcpR/nGhRlZV/IeavtmUx49ulY3bdX827Rex3504DnmolxVqnq8/p1W8ywxV9FBcMI4Cto3c5kmIXHTTAcLsUuCmsmprzuMS+/RvfJ//vjem+lUc+eQKBe3Hc3ocapfxf1dHqSrtzurW2fRTMZcJWEOr9eicRDzOOP2nbtfZGeCcwJPnYJMxJReBWLO/LiV6Bzm/8+ynRFzmJVw7zvXY9WCz/Yt95nK1lqpFZXR7djFYTsnLpLc71rUPhPwSZSVm0Ca+wZWI2RFnm3kbKRsIB89EqsVIxgw9SMKHJwGPc/GBMOZuO2J6HxGn5xXE5JnLTn8YzpBDft+3Hnb2EJTJ2OCPHaQtzMiYDG4+OkwP7ksxcwmMxRUWuE37dwXi/d4A94IKsLqrCxj+vGFPo13wc5L0DRRx7Plk2/nrC32UhKomkjGz2XbS1aJpKgLILbaM1nYnNGKx/VBLNNJdpwhwaoWgRPEB2MEFmxV+GQ/QgOJuaI7fj5KfLqCePX5V3tfdEUb5OmnC2rH1+ptE1RNOBvPPV/D04NzpvvT9QtCq3I6f1fqbcdWVaYkrRcyD/EjQv0Vod46GJPT4jEQ8f2K10dpDtaB/cWGpT16XCRNT0F8="); + + public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=", "UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt/5frMi2BKMMs7pLa0EF8CrrDU7QCwPav+EZVGFvVZbxSkCDq+n3IQ3PUWSCzy6KPxpdOlUjD0pAfLoiNj0P8u4+puQtID76r/St8ExchYl2dodUImu1ZETWeFUClF3ZGat62evx8uRQEI2W4dsVwj40VUfjaAuvyDzuouaKTrCzJXLQZZjR1B8URvuK61fGX0nhW607mEi6DE+nxP2ZoBrROEX4e37Ap6+TQn9Q8tKDPdcxtwSOpPO4Qkncjn/mGtP9lZU/DQ="); + public final static SkinData COMPANION_CUBE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDk5NjI0NjEsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyMTVkYmRhNTY1ZjVjYjhlYjEyZjU1NWY1ZTNkYTBlYTVmNTUxOTg5MWNjNWM1ZDY3NmZkODJjNjIifX19", "vaAQbhnhnTOs64ToFWLg7o4JmqkIl07HWJ6l7xibfISaOcU4BvYBxsfGvmoxlVdsUeCunAJ8/05qVLl5zZYd8Dt+To6JSY0RlqV8piRaaj3FztYWV2ZvG3YZxPxiD3HRJTAQnDobSuxHyPa1e3khjAFp9xJo4q1oqQ28oI2WDuoT+IHqxwkKVbGzO7UD5lzz5chjQC46E8SxddNKp9aqwbbccrkHYT4gteoonOXu4MFxZniJN12LqUCb6+G15rU8MijlBkWx0xE5NMUloeTGuJZItbHun9fysLk/+HE5xJOKYtpZNMuWX+DB/O5ds9dXrOoSAg+Vn0QU4CZbwcxzLii5ILOfEEBtePuEAgzROri+iCKp59CqlEMBrCsd3Um0MCdbuOfvkXGBHBz+bqX7VJY1ujlSdMefmbJtHAkDANnsaaVb+eli9Dk6139041sptsLytD+EfJzaitX6crBwKZ2WDx2P6LHo8B+iSOzOJxjf/08zlXqFw1vsk62IN6lisuZ89QyZw23RvOx3obLAGYs1GxAlMl9qQdpXcmuE1+lPR3g8gZ0BfnTeYwflC2wbR1tuwGG98lyUGCvGLyqNKAQTN87XV4IFQWR81mi1c5CcasoWhKf9D9nAik9aK7A915fEE5IvpeuUdZseDxDVVN5dBIs5q2PIHFAS0rDsDBc="); - public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==","ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ="); + public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==", "ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ="); public final static SkinData LOVESTRUCK = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAyNDMyNjUsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "LL4RiSKQoTZamRQ4QG6izpvhgFu5gAqW4eZxcWAihk7GkhyxifpJpBTOzKrj5hH9fCUfYkkijVWUYTEcVSVRWhocp2HXW59TbKfxOeMvHU5vTMwgpwm6PnUfwuTsRPSLC7WMnEreI3cjOxPVmXbTniOSd+o8j4oOIgwFS+VLPiYLh5Jl16i5I/9ekafl3/x41NISKWl62geqO2jPWehlk+r3soiRJsxaKw20T61GSNLu19iA96Rz2T2tUHB4opm8hbLgoiNL2g1affTjq3cZPLHH4JWF3vPhqLB5uw6xb55vFLM/PP0YiEMIi7YZOfRGeaPp7uXbXgHeew+7PG9UDVMfqbwANQY4ndECijZoei54+xX3MDXkMhQsc5S+FLnGH6e4d008v81eEOyzJUPkKbGxLCBgTUb1s4IHwomCr30twPlo1IuFBOY1qeVvZUfAfPJsREuj5q/oCAoYFgupmb3ClWECnwwaH/T4wdHjfSBHoZQdLzcgDOAl0b5EXxWmYBECqk/WA4TrYIDVGdwkqjI0RkPLUoxTj6135KO+F7P7PwhU9WBGeW8hHq918DBL0fjQVHjrzvolTqwmw6nySSePnPOxFX/iwtHWzpBa9V6kUNNN+V7OGTgRr0H/yUxB+oq1F8UBqyqT4YpqxXCSD36derF/Xt5IdpTbEbGBpm0="); - public final static SkinData PRESENT = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3MDIxNjIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U2YzRkZWQwNTdjMjhiMTU0NjVkYzQzNmFmODIyYTNkZTY4NzgyZTZjMzgyOGMzMmFhYWE4ZjRiOTIzOWVjIn19fQ==","rJNlxTqHHmOoWwbXdMQLcj0P9w/PIr/hWKXH0nbhm/S2CFo/zfefffZlnQmpKCgn1Y8tXvcRwLGQ4CLpm9m2ZrKprSWRhrnOtZWYabrhExQESEammS3TY81VoNt+4On0pAGBippz/bRfWLuDne2rDbhuljnqvxjROmxpky7gRCU06VMlm2WLFC5XYJkiAaOXBqzpiHMMRPNnCvtcbtpILKi/Luj302eyN8nRKjHHbbiDmttwvlshxZ8UxJHvALtM506IUHba10Q6QX2zCeDAU5/WYRKa6e19r8plROcgGbKYFSq8JW5cWuWT3/rveZM6FnU6ABn9DWsCyfQ5wr2jdBd+xaevGTAScRHA5J493GqL1bBZYKj9yhQFtxJHCAf0++raAVPCZgyPtwTth4TAQisn8gnhM5R+txnW6xK+oflLy0dwEN1YdPLN/h7yuDnyjSMDe9RZT2NKMjok2C6Kux4WBI0KFXKC5Gqwa3Htku4v3WEOWMaVoWOtchQ9BzpQ/etD0ylmzjALQLB+HtndEEm1Jd3tmob42X4hBE8hCce7C3EtGINB33dlx4CK1xBqyGTJEqi69DJRzVL99u98+7kJ1Db9+MaPOfI4B2RY3XbvnSYwecandY//A3bb19FGSdl299ZXbp4zpm8fivzeB1rUAhhmtaA3Iwu/nEQNMkU="); - public final static SkinData RUDOLPH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk1NjgxODIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2IzZjdlMjhiNTJkZjJjZjhlZWM2NDk2ZmM0NWFlMGQ2NTM0Njc5OGIxYWRjNzM3ZDcxYzBmOTRlNDIyMSJ9fX0=","uUBOTe63CL+qRvtsb2g4AjB2YzxE3N6AUqIsTv8n0jYyPsuXpuOmZPSMEdgDVONywEJ1L4XRx05sjnGu56A8vuXmGI/uHQWuMZzbOSjiFfT3DkEm8zEl5AWpH9dz/t8nZ1WYUIwy0pN5VrZqIr1DAkF6AMh/Qy+FGDw1GG9ReRr80eJ0JiRskpkCpCZIGGjrgwNKAM8JOuNZ4gCQOTRC3etrcfls3qmUMFcVlhuB4bydxSR01i2w0A4b5KpufsJjLKw4InWn2+m/druo8hl9sYuusTeItW0MQmZqCAqXCc9YBnRPQ0hDXFgnPxOh3RwGWiZvL4MnWUVmLwZWh/Fk9QmyVbd7zVao0lxS8YNsKtP8j5B+hs4l9qNohhf0A07bt4oPeTtd5fQeOU5N87fUGuUAcpC4gP9U5WpVY5FFPBvLvGbXdV5jpuAQz4lLSoo1grsP9baR2IBvdN/0awjQWoPJfGOttegubkBHwz3LNcVqvZLtX/M13IDHZa6zQZEX0wsnMX60LeWgBWfTON1l2cSgaPTerHFS2EifJ2LvTBife3s9/4XR6Zth3FLFqxI3MSlqT2hVFRPLke6rBqfqPoWOj2MCykQ70IAwb3oTHcJDJ86V2DdNaU2bZ8V4TjaP+nRobsLJOImoPYEPq23MP36X8gbXEIjmuu8S5xRlrrc="); - public final static SkinData SANTA = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3OTM3NTgsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyNTM5ZGFkZDUxYmE5ZTg0YzFhOTE1OTY3NWUxZTJiYWM1NmFlNmFlNTMxNTQyZDI1YTlkM2Q1YzQ2ODZmNiJ9fX0=","gvLc0Vo6+1vl17vrFCbK1eNqa4/ix4xiwcWae7WOCvqiVIX4sdIPagOGUrKsDdEhuWCKkTWILGP1K3wYfC9v/0mXZvbu0sRln+APTOsswMkQmbKcA1zTFTMpwEI+nIMzYJSbIx5wjz28K5hDf/umtHH2GADTENdJGGUtU4CyEdeHTzcqIAEV3bcMLkfTKvwKUWqI5gZbbercqmDeGkmXVS9297a9paRX1NfEL9pFT0pjdH3tCjgvvKfAwGC6tYtvTFbfcJocqgI+PI2f5OFf62A4XjWwWFi4wxCHVYNpqs/XTbfF64K7KVE0d9gsLjJoB8DMZPxlNpMFA0R5OIW6Q7Qjyz9IKxUqEYRCQbuUKpHyNDcmVKcTJRwBpCHeqAbTbweZHd5tzrT/terWhLEMsK1+lH2KBfIRIRB9kd3epyShNjSEKoly6uRXVxU+IJtfcq0aFVZlwgG3c1Ds9jbsNJV158e1n6WCmvT00RLdvpcIekwUKODhi3zFeFkrVvV50tGYqXLRZenitLJvDzx4c0IGK4krALrUS0oybinBS7/GmW3Ktz3xbGKZSzzaDw0EKB7Y6XHdb4yqR1xS7lAWgv4cNDEIUSzUDJ7HpmDCIF2A5kPS4XVYFCclyR6qPGD5e+9apVhBMz4lfYlT1IfRAUQlucO4UpAlkXs7ho3pQXU="); + public final static SkinData PRESENT = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3MDIxNjIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U2YzRkZWQwNTdjMjhiMTU0NjVkYzQzNmFmODIyYTNkZTY4NzgyZTZjMzgyOGMzMmFhYWE4ZjRiOTIzOWVjIn19fQ==", "rJNlxTqHHmOoWwbXdMQLcj0P9w/PIr/hWKXH0nbhm/S2CFo/zfefffZlnQmpKCgn1Y8tXvcRwLGQ4CLpm9m2ZrKprSWRhrnOtZWYabrhExQESEammS3TY81VoNt+4On0pAGBippz/bRfWLuDne2rDbhuljnqvxjROmxpky7gRCU06VMlm2WLFC5XYJkiAaOXBqzpiHMMRPNnCvtcbtpILKi/Luj302eyN8nRKjHHbbiDmttwvlshxZ8UxJHvALtM506IUHba10Q6QX2zCeDAU5/WYRKa6e19r8plROcgGbKYFSq8JW5cWuWT3/rveZM6FnU6ABn9DWsCyfQ5wr2jdBd+xaevGTAScRHA5J493GqL1bBZYKj9yhQFtxJHCAf0++raAVPCZgyPtwTth4TAQisn8gnhM5R+txnW6xK+oflLy0dwEN1YdPLN/h7yuDnyjSMDe9RZT2NKMjok2C6Kux4WBI0KFXKC5Gqwa3Htku4v3WEOWMaVoWOtchQ9BzpQ/etD0ylmzjALQLB+HtndEEm1Jd3tmob42X4hBE8hCce7C3EtGINB33dlx4CK1xBqyGTJEqi69DJRzVL99u98+7kJ1Db9+MaPOfI4B2RY3XbvnSYwecandY//A3bb19FGSdl299ZXbp4zpm8fivzeB1rUAhhmtaA3Iwu/nEQNMkU="); + public final static SkinData RUDOLPH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk1NjgxODIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2IzZjdlMjhiNTJkZjJjZjhlZWM2NDk2ZmM0NWFlMGQ2NTM0Njc5OGIxYWRjNzM3ZDcxYzBmOTRlNDIyMSJ9fX0=", "uUBOTe63CL+qRvtsb2g4AjB2YzxE3N6AUqIsTv8n0jYyPsuXpuOmZPSMEdgDVONywEJ1L4XRx05sjnGu56A8vuXmGI/uHQWuMZzbOSjiFfT3DkEm8zEl5AWpH9dz/t8nZ1WYUIwy0pN5VrZqIr1DAkF6AMh/Qy+FGDw1GG9ReRr80eJ0JiRskpkCpCZIGGjrgwNKAM8JOuNZ4gCQOTRC3etrcfls3qmUMFcVlhuB4bydxSR01i2w0A4b5KpufsJjLKw4InWn2+m/druo8hl9sYuusTeItW0MQmZqCAqXCc9YBnRPQ0hDXFgnPxOh3RwGWiZvL4MnWUVmLwZWh/Fk9QmyVbd7zVao0lxS8YNsKtP8j5B+hs4l9qNohhf0A07bt4oPeTtd5fQeOU5N87fUGuUAcpC4gP9U5WpVY5FFPBvLvGbXdV5jpuAQz4lLSoo1grsP9baR2IBvdN/0awjQWoPJfGOttegubkBHwz3LNcVqvZLtX/M13IDHZa6zQZEX0wsnMX60LeWgBWfTON1l2cSgaPTerHFS2EifJ2LvTBife3s9/4XR6Zth3FLFqxI3MSlqT2hVFRPLke6rBqfqPoWOj2MCykQ70IAwb3oTHcJDJ86V2DdNaU2bZ8V4TjaP+nRobsLJOImoPYEPq23MP36X8gbXEIjmuu8S5xRlrrc="); + public final static SkinData SANTA = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3OTM3NTgsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyNTM5ZGFkZDUxYmE5ZTg0YzFhOTE1OTY3NWUxZTJiYWM1NmFlNmFlNTMxNTQyZDI1YTlkM2Q1YzQ2ODZmNiJ9fX0=", "gvLc0Vo6+1vl17vrFCbK1eNqa4/ix4xiwcWae7WOCvqiVIX4sdIPagOGUrKsDdEhuWCKkTWILGP1K3wYfC9v/0mXZvbu0sRln+APTOsswMkQmbKcA1zTFTMpwEI+nIMzYJSbIx5wjz28K5hDf/umtHH2GADTENdJGGUtU4CyEdeHTzcqIAEV3bcMLkfTKvwKUWqI5gZbbercqmDeGkmXVS9297a9paRX1NfEL9pFT0pjdH3tCjgvvKfAwGC6tYtvTFbfcJocqgI+PI2f5OFf62A4XjWwWFi4wxCHVYNpqs/XTbfF64K7KVE0d9gsLjJoB8DMZPxlNpMFA0R5OIW6Q7Qjyz9IKxUqEYRCQbuUKpHyNDcmVKcTJRwBpCHeqAbTbweZHd5tzrT/terWhLEMsK1+lH2KBfIRIRB9kd3epyShNjSEKoly6uRXVxU+IJtfcq0aFVZlwgG3c1Ds9jbsNJV158e1n6WCmvT00RLdvpcIekwUKODhi3zFeFkrVvV50tGYqXLRZenitLJvDzx4c0IGK4krALrUS0oybinBS7/GmW3Ktz3xbGKZSzzaDw0EKB7Y6XHdb4yqR1xS7lAWgv4cNDEIUSzUDJ7HpmDCIF2A5kPS4XVYFCclyR6qPGD5e+9apVhBMz4lfYlT1IfRAUQlucO4UpAlkXs7ho3pQXU="); public final static SkinData SECRET_PACKAGE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAzNzE3OTIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QyNWI5YTRjOWRhOThkZTliZmIwZDNjOWI1M2MzMjJhMjgxN2IyMTMxOTQzY2E1YWM2NTBjZThmMzEzZjdhIn19fQ==", "Wb5T0Zhp1RVt78V/i8dYrwZCNT0xZIRe3LvL0bngH498f8Jrl43KHgTi4f299zE9giVynkTogGhJ8inq/xqFCRctl7Nn9L3LVu78uQwt+fs+o+kw/Qc+lggFSjEIc+fc13AZndpec0Df46Kh/OGD7NXbtbLb6TE/0dU2RwQlvZrZ/QHYJb8OJ6aUcnHvAZim8NUtG/nlZtSClepHVSuKdNnfzoF9rFVFA/x4jTr6mZYPZ33YgQd2oTAPk+qE3iN+0InjZQNs2YLoKFmFrgzn+tGvNApC0siF0HEZGQCFIwJOtnBsasGoxujIrln/ZdOil+5ac4VWInXr8lKgY0Q3Ocy8/0cJl+E/XqB+ztG29zhB8B1zdHBfJr+MgeSIqBCPx4SCtY6r7gnMlQYG+uVx5NP3S5aJW/cEfDyXmpCykIcBPzeErnKC0SiAqXkCVNjWJpX6qRWvWMXqS69w6ht6qHvEY2GxlZUb5AP+JgFlsl3hJDms6EPvM4zNL0Ko4oWIBzwYRQXiemrP9TGgyo0aL1RcQ0JgBFO2hSo37PK0YL3tUPgteJXzm21wu0TiZLkLCWSgMUfYfvVnhTa+xzod0xvfujpN6Y1DUTdcf8WS8TRYw2JigSkWrRW0fXPBCtTtQN5jiwM5/HrTpNLzg03J6SpfZ+rr8Rhq0S/8beQOMas="); - public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==","NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT7Gl8AhJS6JK5kCvip1rBBI8yjrsjE/E+lyJFIbC4rXxyMDGZWkcdrd7U4ZFYKiLHbzdFRqX+11qs9xO2BvomGXkATCzYmOf2kQ86R6rNN0+JfE4QpKzj2WWt3C8ky2qpuXZz29p0816E3/qseYtgg="); + public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==", "NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT7Gl8AhJS6JK5kCvip1rBBI8yjrsjE/E+lyJFIbC4rXxyMDGZWkcdrd7U4ZFYKiLHbzdFRqX+11qs9xO2BvomGXkATCzYmOf2kQ86R6rNN0+JfE4QpKzj2WWt3C8ky2qpuXZz29p0816E3/qseYtgg="); public final static SkinData TEDDY_BEAR = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDkzOTE4MjYsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzQ0OTU4ZDdjNjlhZTQ4NGM2NWYzMTM0N2NkY2M5MmM2OWY1NDA2ODA1YjUzNjUyYTc1YThlZDc5OWRmNyJ9fX0=", "sNTRV9jTjLszUmyaqyEG7N8d5RM1jbwMSXi34S2EkVmIjWsowfSMnHRQqqgZfxcyqBM5I7MljtB84IeQWu4rqhyFrM9blWvtowjijFIOgKCs97q2sswv9iauU6ohvgTpgN5B0Q16MJmMIgZU8d8TATtEaIzq2eg6Ve1AJlNnW4huGNsoNfm8WdVU1tZmsYAwtVP/ryvhyj7mHyVF27m0Sm4fZRf/lHH5gEJYB4JHSAoEhjPIQOdkgRMJRrWGOfhhiGs3kEWmsRGfIPFo2ZJfcu+TFV2rd4Q+A1LmY8kimnzdKX3InXeKbk8qzcgqGNro4XFnSiHo1d6/B+N0JeYOTITYRQ6u24rNSUh5ezbG01iikVFCfrgb7UR6utoLK15F4/fmhpex+BJpmyZoXAqk08tZws/5wsIWQ1okrGcbBKWEHhw2ekUc82US21/W53vd657UBg7FuqM4FhkAqmsYPvYLMpNYxxmDJaI8uJyU7cnGFYyBaFlqUxfJUfcFTwWo10JO3yp5FjqeCQa7rFvfpsqw3w2mBpJmlZ5HRjfS5pmhk0QiY0TRfwZfFemkuZYnNbO82qLUm+6zTm0fbC90Swt8nNr/42ajzEoUjnL6VsERIXS5/fPwjftbQAC60ujy8yo66Sp3sSAALNg5zjM+Uizkq2f9Axc+kind22hp10M="); public final static SkinData UNCLE_SAM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjYxODA0NjY4NTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYzM1YWRmZTQ3ODBjNmU2NTk4YTJlYzk2ZjdhZGQ5ZDc4NjljMjBlZjRmYjEyNjk2NmJhOGFlMDRlOWRhIn19fQ==", "NmJ+hXmvwQlYFYY7YVQWRr11yBbAfJP+jk11SQ91gUUtJJjb4v8RFbNu5UXNCKxYj3BPtldqshG1maNB0NWJRud7ZyAdHc0JMmR1vtHEge9Hhet4fLyyaZ9rZn4BvD9Guqgv9H/mZzUzrft9TIho0Qbu/U++lVsbZXC2GrJDDMyLnYr9C7f+FUnr0z4WvkNcg23SHBOYkOYT95NSdykIka3c3v+/HvSvuwOnMsfVxqLyCZLpo20vamBJ1uK1dmx2+TVGnUPlofFHRdOXOpJc+YmicJvrsQR6a9zlvnTbU4MYClMOKvjLe6aX5Af+n8Gw3oKcm0PuR8CPLyf9kjcmUF6XMiEXAWWJtCgvhCiFV5/mQQH3cQ1kqk4BDLUxMVhG5tzjKLoQQy39cFM32ee+QFjXlzy59meC8jgvPmOVU3GpJ32XWOtaXMCyeJrhz2QVKRLEr2KZgz8Pd8VrHARXVZsNYEasj8z0cHjgSJqTU9kD90CC+4YpvdyRBRqbNQig5KuGCqUHKgflsEsM7YrFRKP5As1LgqYQfqRAMmLSo47eW0onOwchC9wCqqisPlYSuDRt4Mun/KFGqYh1Sghn8/gzu49La8BpwlekjVEoPEcDaIIgnFzOvgmmgMANkoJ3PzhHoHMoXtObe3eSTi+eYp4qAQVzkTxfF3WXY2fui1M="); @@ -40,49 +77,39 @@ public class SkinData //public final static SkinData CHISS = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI5NjgyNDEsInByb2ZpbGVJZCI6IjFkMmJmZTYxN2ViZDQ0NWRiYTdkODM1NGEwZmZkMWVhIiwicHJvZmlsZU5hbWUiOiJDaGlzcyIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTg3MmNkMzRjY2IzMTIxYjRjNmEzOGFjM2JmOGVkM2UwMzk3YmQ2YTg4NDI4YjdhZmM2ZTUyNTI4NTVhMzQzIiwibWV0YWRhdGEiOnsibW9kZWwiOiJzbGltIn19fX0=", "hNTLRA2acZYx2dM90lnJN8FMK/ceD3+AxKNdD5FrXzxGtYL4C1Jr/vbTE0UosmwFP3wScNEW/fuDOjeZRjZHMJdvgDZMlMK/5KDhOY6sj/RS9RckztsgummSyjH/hdDn7TWWfhZLMbiia/K0VReI9eq2yD6zGQpvMlz5hB/5SX5YHWXvCah3TL4UzYSlSVDlwY/Q3sVuIZUr8m/LIXJwniJKLGo6tUgtiJd9eseOsbBpVjzCUtLD8A9WBe2/eODgmLfqEvXESIoDRG8vL2nPSXWma/YolYHIl32/i+ZxVD7dRRaXQFYSiLI24EtzX1pPhMjyaTLazP9abH43J6J31w02pKM7N/xTa62020L/YfRRKGT5lygEDb1NMoSpAjszPxah+Ra2/L+yUWEI8cMES6I4mIJ00tclPjWK01xhIn3tqg+y2gqsGHwPhu/7vmF5NirNfKFw0qciKNBfbCAF7ae+mkUKjmAPuvBUBqQb7BOcpNVWsCo/XvzmiZZYsf5P4Uwz8LqUK4uH6V/5dg7lY2Xg3+IUylsrDqLGFDI8iy/NdjIQMbuRadh4IDO6DcmxBri2Ax4JNBPBTnRezge8uq37MZcft/IXQgFWKB9RtidVEACaTOkRj27k+Ojnkki+j44k0wZB47hiXFUHMCHl3a0SVdQe15ZbVsQj/HAvAS0="); //public final static SkinData DEFEK7 = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTk1NDI3ODkwNTksInByb2ZpbGVJZCI6Ijg5ZDQ2M2Y3MjNlYzQ3MGE4MjQ0NDU3ZjBjOGQ4NjFjIiwicHJvZmlsZU5hbWUiOiJkZWZlazciLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2JmYWNjOWM4ZjhlY2E1OWU0NTE4MTUxZmE4OGFiMDZjOTFmNjM3OTE2NzJmMTRlNGYzODY3YTI2OTVlN2NmYmYifSwiQ0FQRSI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIyYjljNWVhNzYzYzg2ZmM1Y2FlYTMzZDgyYjBmYTY1YTdjMjI4ZmQzMjFiYTU0NzY2ZWE5NWEzZDBiOTc5MyJ9fX0=", "jBoRvkhQXz+nap8yJJIZ+4HClMItWODumeSOYjXytP3WWKHK0UMq0xC/keXsnmvo89lMRdRbknPt2ZX5Flgyjgr4Rt0KtDvpL/hG4BUsTWryUZZMKxdd6DkZXYRtTogLUfHeDYIz+cZQ0aXGMtvX/ZYTXJfMi6FYbIHY/qEEDnWhDX5y+SPpaJaZByPsvzi+qbfcFGnJ6nqi9ccyZYnYpnI2IVBM/yO/VRXWHxfqvJ0VVvv5KsGmVbko2Jxo0SDCxUL2UTH2+eol53FxhkkC+m2geC14k1zsZQLHDF3BgAG9+kFJ4UEoYRKF2Gy1FxeDCJtjYNdrYR8fdaUKRMcpBgEs+ZGe2U9EVVS/ZcBCjB7S+1Ne2bPzPFzTQPuBoMgggo1xbxBmQ5NyhYo4gwgj/xjSLIhb+5h7ioN1URfSRcfYdVv6RRO9l/u9l09jEom8y/jGRviefpEr+/e9iAl5Dd/6nzQgosBQja3NSfqYZmyuet2eI9zu61CObDTpR6yaCbNgBe/lWofRfULdpJpgjb4UNTBom3q82FcCiOe02OekGPw4+YlilhICBhajF5JzN8FKAdqI1osDcX3KuJgikYIW3voNaOP5YN3GXgilJNdou20KFC8ICq68HglgX7/0rLrWKIEoswnINIM6HcJbQuXncVPwQhV6K34Hlt/Na60="); - + private Property _skinProperty; - + public SkinData(String value, String signature) { _skinProperty = new Property("textures", value, signature); } - - public SkinData(GameProfile profile) + + private SkinData(GameProfile profile) { _skinProperty = profile.getProperties().get("textures").iterator().next(); } - - public SkinData(Player player) - { - this(((CraftPlayer)player).getProfile()); - } - + public ItemStack getSkull() { - NBTTagCompound arrayElement = new NBTTagCompound(); - arrayElement.setString("Value", _skinProperty.getValue()); - arrayElement.setString("Signature", _skinProperty.getSignature()); - - NBTTagList textures = new NBTTagList(); - textures.add(arrayElement); - - NBTTagCompound properties = new NBTTagCompound(); - properties.set("textures", textures); - - NBTTagCompound skullOwner = new NBTTagCompound(); - skullOwner.set("Properties", properties); - skullOwner.set("Name", new NBTTagString(getUnusedSkullName())); - - NBTTagCompound tag = new NBTTagCompound(); - tag.set("SkullOwner", skullOwner); - - - net.minecraft.server.v1_8_R3.ItemStack nmsItem = new net.minecraft.server.v1_8_R3.ItemStack(Item.REGISTRY.get(new MinecraftKey("skull")), 1, 3); - nmsItem.setTag(tag); - - - return CraftItemStack.asBukkitCopy(nmsItem); + ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); + SkullMeta meta = (SkullMeta) item.getItemMeta(); + + GameProfile data = new GameProfile(UUID.randomUUID(), getUnusedSkullName()); + data.getProperties().put("textures", getProperty()); + + try + { + PROFILE_FIELD.set(meta, data); + } + catch (ReflectiveOperationException t) + { + t.printStackTrace(); + } + + item.setItemMeta(meta); + + return item; } public ItemStack getSkull(String name, List lore) @@ -94,16 +121,51 @@ public class SkinData stack.setItemMeta(meta); return stack; } - + public Property getProperty() { return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature()); } - + public static String getUnusedSkullName() { _nameCount++; return "_" + _nameCount; } + + /* + * Creates a {@link SkinData} from a given {@link GameProfile}. + * Will return null if the GameProfile does not have any texture data + * + * @param input The GameProfile to get textures from + * @param requireSecure Whether the SkinData should be signed + * @param useDefaultSkins Whether to subsitute an Alex or Steve skin if no textures are present + * + * @return The SkinData, or null if no textures are present + */ + public static SkinData constructFromGameProfile(GameProfile input, boolean requireSecure, boolean useDefaultSkins) + { + final Map map = Maps.newHashMap(); + + try + { + map.putAll(MinecraftServer.getServer().aD().getTextures(input, requireSecure)); + } + catch (InsecureTextureException ignored) + { + } + + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) + { + return new SkinData(input); + } + + if (useDefaultSkins) + { + return UtilPlayer.isSlimSkin(input.getId()) ? SkinData.ALEX : SkinData.STEVE; + } + + return null; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index aef32b218..ed3548020 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -2,8 +2,8 @@ package mineplex.core.common.util; import org.bukkit.ChatColor; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.Currency; public class F { @@ -204,7 +204,7 @@ public class F return out; } - public static String currency(CurrencyType type, int amount) + public static String currency(Currency type, int amount) { return type.getString(amount) + ChatColor.RESET + C.mBody; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java index 50d8fe661..887369e33 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java @@ -1,5 +1,8 @@ package mineplex.core.common.util; +import mineplex.core.common.events.EntityVelocityChangeEvent; + +import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -49,6 +52,15 @@ public class UtilAction if (groundBoost) if (UtilEnt.isGrounded(ent)) vec.setY(vec.getY() + 0.2); + + EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + vec = event.getVelocity(); //Velocity ent.setFallDistance(0); @@ -65,6 +77,16 @@ public class UtilAction public static void zeroVelocity(Entity ent) { Vector vec = new Vector(0,0,0); + + EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + vec = event.getVelocity(); + ent.setFallDistance(0); //Store It! diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 1945a0e1b..adcc05264 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -1,25 +1,23 @@ package mineplex.core.common.util; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Stream; - +import net.minecraft.server.v1_8_R3.AxisAlignedBB; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.TrigMath; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; -import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.TreeSet; public class UtilAlg { @@ -56,6 +54,17 @@ public class UtilAlg { return to.clone().subtract(from).normalize(); } + + public static double[] getTrajectory(double srcx, double srcy, double srcz, double dstx, double dsty, double dstz) + { + double dx = dstx - srcx; + double dy = dsty - srcy; + double dz = dstz - srcz; + + double len = Math.sqrt(dx * dx + dy * dy + dz * dz); + + return new double[] { dx / len, dy / len, dz / len}; + } public static Vector getTrajectory2d(Entity from, Entity to) { @@ -98,28 +107,42 @@ public class UtilAlg public static float GetPitch(Vector vec) { - double x = vec.getX(); - double y = vec.getY(); - double z = vec.getZ(); + return GetPitch(vec.getX(), vec.getY(), vec.getZ()); + } + + public static float GetPitch(double[] vec) + { + return GetPitch(vec[0], vec[1], vec[2]); + } + + public static float GetPitch(double x, double y, double z) + { double xz = Math.sqrt((x*x) + (z*z)); - double pitch = Math.toDegrees(Math.atan(xz/y)); + double pitch = Math.toDegrees(TrigMath.atan(xz/y)); if (y <= 0) pitch += 90; else pitch -= 90; - - //Fix for two vectors at same Y giving 180 + + //Fix for two vectors at same Y giving 180 if (pitch == 180) pitch = 0; - + return (float) pitch; } public static float GetYaw(Vector vec) { - double x = vec.getX(); - double z = vec.getZ(); - - double yaw = Math.toDegrees(Math.atan((-x)/z)); + return GetYaw(vec.getX(), vec.getY(), vec.getZ()); + } + + public static float GetYaw(double[] vec) + { + return GetYaw(vec[0], vec[1], vec[2]); + } + + public static float GetYaw(double x, double y, double z) + { + double yaw = Math.toDegrees(TrigMath.atan((-x)/z)); if (z < 0) yaw += 180; return (float) yaw; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index e1113d49b..00a28781d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -1616,4 +1616,35 @@ public class UtilBlock } } + + public static boolean water(Material type) + { + return type == Material.WATER || type == Material.STATIONARY_WATER; + } + + public static boolean lava(Material type) + { + return type == Material.LAVA || type == Material.STATIONARY_LAVA; + } + + public static boolean liquid(Material type) + { + return water(type) || lava(type); + } + + public static boolean water(Block block) + { + return water(block.getType()); + } + + public static boolean lava(Block block) + { + return lava(block.getType()); + } + + public static boolean liquid(Block block) + { + return liquid(block.getType()); + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 786f816a2..0e78782db 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -12,6 +12,7 @@ import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.TrigMath; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; @@ -295,7 +296,7 @@ public class UtilEnt Vector dir = entity.getEyeLocation().toVector().subtract(location.toVector()).normalize(); Location loc = entity.getEyeLocation().clone(); - loc.setYaw(180 - (float) Math.toDegrees(Math.atan2(dir.getX(), dir.getZ()))); + loc.setYaw(180 - (float) Math.toDegrees(TrigMath.atan2(dir.getX(), dir.getZ()))); loc.setPitch(90 - (float) Math.toDegrees(Math.acos(dir.getY()))); Rotate(entity, loc.getYaw(), loc.getPitch()); @@ -700,6 +701,13 @@ public class UtilEnt return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); } + public static boolean CreatureLook(Entity ent, double srcx, double srcy, double srcz, double dstx, double dsty, double dstz) + { + double[] vec = UtilAlg.getTrajectory(srcx, srcy, srcz, dstx, dsty, dstz); + + return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); + } + public static boolean CreatureLook(Entity ent, Vector target) { return CreatureLook(ent, UtilAlg.GetPitch(target), UtilAlg.GetYaw(target)); @@ -737,16 +745,19 @@ public class UtilEnt EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.getWorld()).tracker.trackedEntities.get(ec.getId()); - byte ya = (byte) (yaw * 256.0F / 360.0F); - byte pi = (byte) (pitch * 256.0F / 360.0F); + if (entry != null) + { + byte ya = (byte) (yaw * 256.0F / 360.0F); + byte pi = (byte) (pitch * 256.0F / 360.0F); - entry.yRot = ya; - entry.xRot = pi; - entry.i = ya; + entry.yRot = ya; + entry.xRot = pi; + entry.i = ya; - // Looks like both packets need to be sent. EntityLook packet for body yaw and head pitch. Head rotation for head yaw. - entry.broadcast(new PacketPlayOutEntity.PacketPlayOutEntityLook(ent.getEntityId(), ya, pi, ec.onGround)); - entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya)); + // Looks like both packets need to be sent. EntityLook packet for body yaw and head pitch. Head rotation for head yaw. + entry.broadcast(new PacketPlayOutEntity.PacketPlayOutEntityLook(ent.getEntityId(), ya, pi, ec.onGround)); + entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya)); + } return true; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 9f5f14739..bac5ec7fb 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -1,8 +1,16 @@ package mineplex.core.common.util; -import java.util.*; - -import net.minecraft.server.v1_8_R3.*; +import mineplex.core.common.MinecraftVersion; +import mineplex.core.common.events.PlayerMessageEvent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; +import net.minecraft.server.v1_8_R3.PlayerConnection; +import net.minecraft.server.v1_8_R3.WorldBorder; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -20,8 +28,17 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; -import mineplex.core.common.MinecraftVersion; -import mineplex.core.common.events.PlayerMessageEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; public class UtilPlayer { @@ -179,7 +196,7 @@ public class UtilPlayer for (Entity entity : p.getNearbyEntities(range, range, range)) { - if (entity == p || UtilPlayer.isSpectator(entity)) + if (entity == p || UtilPlayer.isSpectator(entity) || !(entity instanceof Player)) continue; double theirDist = p.getEyeLocation().distance(entity.getLocation()); @@ -938,9 +955,79 @@ public class UtilPlayer return true; } + public static void removeAllowedCommands(Player player) { if (ALLOWED_COMMANDS.containsKey(player.getUniqueId())) ALLOWED_COMMANDS.remove(player.getUniqueId()); } + + /** + * Sends a formatted clickable accept or deny (or view) message to a player + * Both ACCEPT and DENY will always be sent, but VIEW will only be sent when viewCommand is not null + * + * @param player The player to send the message to + * @param header The message header, such as Party or Game + * @param acceptCommand The command to be run if ACCEPT is clicked + * @param acceptDisplayText The text displayed when hovering over ACCEPT + * @param declineCommand The command to be run when DENY is clicked + * @param declineDisplayText The text displayed when hovering over DENY + * @param viewCommand Optional The command to be run when VIEW is clicked + * @param viewDisplayText Optional The text displayed when hovering over VIEW + */ + public static void sendAcceptOrDeny(Player player, String header, + String acceptCommand, String acceptDisplayText, + String declineCommand, String declineDisplayText, + String viewCommand, String viewDisplayText) + { + TextComponent textComponent = new TextComponent(F.main(header, "Reply: ")); + + TextComponent accept = new TextComponent("ACCEPT"); + accept.setColor(net.md_5.bungee.api.ChatColor.GREEN); + accept.setBold(true); + accept.setClickEvent(new ClickEvent(Action.RUN_COMMAND, acceptCommand)); + accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{ + new TextComponent(acceptDisplayText) + })); + + textComponent.addExtra(accept); + textComponent.addExtra(" "); + + TextComponent deny = new TextComponent("DENY"); + deny.setColor(net.md_5.bungee.api.ChatColor.RED); + deny.setBold(true); + deny.setClickEvent(new ClickEvent(Action.RUN_COMMAND, declineCommand)); + deny.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{ + new TextComponent(declineDisplayText) + })); + + textComponent.addExtra(deny); + + if(viewCommand != null) + { + textComponent.addExtra(" "); + + TextComponent view = new TextComponent("VIEW"); + view.setColor(net.md_5.bungee.api.ChatColor.YELLOW); + view.setBold(true); + view.setClickEvent(new ClickEvent(Action.RUN_COMMAND, viewCommand)); + if(viewDisplayText != null) + { + view.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{ + new TextComponent(viewDisplayText) + })); + } + textComponent.addExtra(view); + } + + player.spigot().sendMessage(textComponent); + } + + /* + * Returns whether the UUID belongs to a slim skin + */ + public static boolean isSlimSkin(UUID playerUUID) + { + return (playerUUID.hashCode() & 1) == 1; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index 886d8e26d..b0ccc63ef 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -111,7 +111,7 @@ public class UtilServer HandlerList.unregisterAll(listener); } - public static Plugin getPlugin() + public static JavaPlugin getPlugin() { return JavaPlugin.getProvidingPlugin(UtilServer.class); } @@ -193,6 +193,11 @@ public class UtilServer return _serverName; } + public static String getServerNameFromConfig() + { + return getPlugin().getConfig().getString("serverstatus.name"); + } + public static Collection GetPlayers() { return Lists.newArrayList(getPlayers()); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java new file mode 100644 index 000000000..6e71d4002 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTasks.java @@ -0,0 +1,40 @@ +package mineplex.core.common.util; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitScheduler; + +import java.util.function.Consumer; + +public class UtilTasks +{ + private static final JavaPlugin LOADING_PLUGIN = JavaPlugin.getProvidingPlugin(UtilTasks.class); + + private static final BukkitScheduler SCHEDULER = Bukkit.getScheduler(); + + public static Runnable onMainThread(Runnable original) + { + return () -> + { + if (Bukkit.isPrimaryThread()) + { + original.run(); + } + else + { + SCHEDULER.runTask(LOADING_PLUGIN, original); + } + }; + } + + public static Consumer onMainThread(Consumer original) + { + return t -> + { + onMainThread(() -> + { + original.accept(t); + }); + }; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index d0825126d..0867db6d4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -1,5 +1,9 @@ package mineplex.core.common.util; +import org.apache.commons.lang.WordUtils; +import org.bukkit.ChatColor; + +import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; @@ -7,13 +11,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import javax.imageio.ImageIO; - -import org.apache.commons.lang.WordUtils; -import org.bukkit.ChatColor; - -import mineplex.core.common.CurrencyType; - public class UtilText { private static HashMap _characters = new HashMap<>(); @@ -25,7 +22,7 @@ public class UtilText { try { - InputStream inputStream = CurrencyType.class.getResourceAsStream("/ascii.png"); + InputStream inputStream = UtilText.class.getResourceAsStream("/ascii.png"); BufferedImage image = ImageIO.read(inputStream); char[] text = new char[] diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java index 99979144b..86c6083f2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java @@ -24,7 +24,12 @@ public class UtilWorld { return UtilServer.getServer().getWorld(world); } - + + public static boolean areChunksEqual(Location first, Location second) + { + return first.getBlockX() >> 4 == second.getBlockX() >> 4 && first.getBlockZ() >> 4 == second.getBlockZ() >> 4; + } + public static String chunkToStr(Chunk chunk) { if (chunk == null) diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index 2a88ca1ca..81a567966 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -44,6 +44,11 @@ org.apache.httpcomponents httpclient + + com.mineplex + anticheat + 1.1 + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 7a32a4aa3..fbbe9c561 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -1,9 +1,12 @@ package mineplex.core; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.UUID; import mineplex.core.common.DummyEntity; @@ -53,15 +56,15 @@ import fr.neatmonster.nocheatplus.hooks.NCPHookManager; public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { - private NautHashMap> _entityMap = new NautHashMap>(); - private NautHashMap> _entityNameMap = new NautHashMap>(); - private NautHashMap> _entityRiding = new NautHashMap>(); + private Map> _entityMap = new HashMap<>(); + private Map> _entityNameMap = new HashMap<>(); + private Map> _entityRiding = new HashMap<>(); - private HashSet _loggedIn = new HashSet(); - private HashSet _ignoreIds = new HashSet(); + private Set _loggedIn = new HashSet<>(); + private Set _ignoreIds = new HashSet<>(); - private NautHashMap _exemptTimeMap = new NautHashMap(); - private NautHashMap> _doubleStrike = new NautHashMap>(); + private Map _exemptTimeMap = new HashMap<>(); + private Map> _doubleStrike = new HashMap<>(); public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler) { @@ -79,10 +82,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook @EventHandler public void playerQuit(PlayerQuitEvent event) { - _entityMap.remove(event.getPlayer().getName()); - _entityNameMap.remove(event.getPlayer().getName()); - _entityRiding.remove(event.getPlayer().getName()); - _loggedIn.remove(event.getPlayer().getName()); + _entityMap.remove(event.getPlayer().getUniqueId()); + _entityNameMap.remove(event.getPlayer().getUniqueId()); + _entityRiding.remove(event.getPlayer().getUniqueId()); + _loggedIn.remove(event.getPlayer().getUniqueId()); } @EventHandler(priority = EventPriority.LOW) @@ -122,7 +125,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook public void ncpExemptVelocity(final PlayerVelocityEvent event) { long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500); - + if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId())) { _exemptTimeMap.put(event.getPlayer().getUniqueId(), @@ -139,7 +142,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (event.getType() != UpdateType.TICK) return; - for (Iterator> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext();) + for (Iterator> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext(); ) { final Entry entry = iterator.next(); @@ -150,12 +153,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } for (Iterator>> iterator = _doubleStrike.entrySet().iterator(); iterator - .hasNext();) + .hasNext(); ) { Entry> entry = iterator.next(); for (Iterator> innerIterator = entry.getValue().entrySet().iterator(); innerIterator - .hasNext();) + .hasNext(); ) { final Entry entry2 = innerIterator.next(); @@ -176,11 +179,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (event.getType() != UpdateType.SEC) return; - for (Iterator iterator = _loggedIn.iterator(); iterator.hasNext();) + for (Iterator iterator = _loggedIn.iterator(); iterator.hasNext(); ) { - String player = iterator.next(); + UUID player = iterator.next(); - if (Bukkit.getPlayerExact(player) == null) + if (Bukkit.getPlayer(player) == null) { iterator.remove(); _entityMap.remove(player); @@ -195,7 +198,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } } - @SuppressWarnings("unchecked") + public void handle(PacketInfo packetInfo) { if (packetInfo.isCancelled()) @@ -205,311 +208,84 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook Player owner = packetInfo.getPlayer(); PacketVerifier verifier = packetInfo.getVerifier(); - if (owner.isOnline()) + if (!owner.isOnline()) + // wat + return; + + if (!_entityMap.containsKey(owner.getUniqueId())) { - if (owner.isOnline() && !_entityMap.containsKey(owner.getName())) + _entityMap.put(owner.getUniqueId(), new HashMap<>()); + _entityNameMap.put(owner.getUniqueId(), new HashMap<>()); + _loggedIn.add(owner.getUniqueId()); + } + + if (packet instanceof PacketPlayOutSpawnEntityLiving) + { + PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving) packet; + + // Ignore Armor stand packets + if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId() || spawnPacket.l == null || spawnPacket.l.c() == null) { - _entityMap.put(owner.getName(), new NautHashMap()); - _entityNameMap.put(owner.getName(), new NautHashMap()); - _loggedIn.add(owner.getName()); - } - - if (packet instanceof PacketPlayOutSpawnEntityLiving) - { - PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving) packet; - - // Ignore Armor stand packets - if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId() || spawnPacket.l == null || spawnPacket.l.c() == null) - { - if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId()) - { - _ignoreIds.add(spawnPacket.a); - } - - return; - } - - for (WatchableObject watchable : (List) spawnPacket.l.c()) - { - if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) - { - if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a); - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); - - _entityNameMap.get(owner.getName()).remove(spawnPacket.a); - _entityMap.get(owner.getName()).remove(spawnPacket.a); - } - - final String entityName = spawnPacket.l.getString(2); - - if (entityName.isEmpty()) - { - return; - } - - Integer[] ids = new Integer[] - { - UtilEnt.getNewEntityId(), - UtilEnt.getNewEntityId() - }; - - _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); - _entityMap.get(owner.getName()).put(spawnPacket.a, ids); - - sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); - break; - } - } - } - else if (packet instanceof PacketPlayOutNamedEntitySpawn) - { - PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet; - - for (WatchableObject watchable : (List) spawnPacket.i.c()) - { - if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) - { - if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a); - - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); - - _entityNameMap.get(owner.getName()).remove(spawnPacket.a); - _entityMap.get(owner.getName()).remove(spawnPacket.a); - } - - final String entityName = spawnPacket.i.getString(2); - - if (entityName.isEmpty()) - { - return; - } - - Integer[] ids = new Integer[] - { - UtilEnt.getNewEntityId(), - UtilEnt.getNewEntityId() - }; - - _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); - _entityMap.get(owner.getName()).put(spawnPacket.a, ids); - - sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); - break; - } - } - } - else if (packet instanceof PacketPlayOutEntityMetadata) - { - PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; - - if (metaPacket.a != 777777 && !_ignoreIds.contains(metaPacket.a) && metaPacket.a != owner.getEntityId()) - { - boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a); - String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a); - - if (currentName == null) - { - currentName = ""; - } - - String newName = currentName; - boolean displayName = isDisplaying; - - for (WatchableObject watchable : (List) metaPacket.b) - { - if (watchable.a() == 3 && watchable.b() instanceof Byte) - { - displayName = ((Byte) watchable.b()) == 1; - } - - if (watchable.a() == 2 && watchable.b() instanceof String) - { - newName = (String) watchable.b(); - } - } - - // If the name has changed and the name should be showing, or the name display status has changed. - if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying) - { - // If name is still being displayed - if (displayName) - { - Integer[] newId; - - if (isDisplaying) // Sending metadata - { - newId = _entityMap.get(owner.getName()).get(metaPacket.a); - } - else - // Spawning new entity - { - newId = new Integer[] - { - UtilEnt.getNewEntityId(), - UtilEnt.getNewEntityId() - }; - - _entityMap.get(owner.getName()).put(metaPacket.a, newId); - } - - _entityNameMap.get(owner.getName()).put(metaPacket.a, newName); - sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId); - } - else - { // Lets delete it - Integer[] ids = _entityMap.get(owner.getName()).get(metaPacket.a); - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds)); - - _entityMap.get(owner.getName()).remove(metaPacket.a); - _entityNameMap.get(owner.getName()).remove(metaPacket.a); - } - } - } - } - else if (packet instanceof PacketPlayOutEntityDestroy) - { - try - { - for (int id : ((PacketPlayOutEntityDestroy) packet).a) - { - if (_entityMap.get(owner.getName()).containsKey(id)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(id); - int[] newIds = new int[ids.length]; - - for (int a = 0; a < ids.length; a++) - { - newIds[a] = ids[a]; - } - - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); - _entityMap.get(owner.getName()).remove(id); - _entityNameMap.get(owner.getName()).remove(id); - } - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - } - else if (packet instanceof PacketPlayOutSpawnEntity) - { - PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet; - if (spawnPacket.j == 78) // Armor Stand Object ID + if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId()) { _ignoreIds.add(spawnPacket.a); } + + return; } - else if (packet instanceof PacketPlayInUseEntity) + + for (WatchableObject watchable : (List) spawnPacket.l.c()) { - PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; - - loop: - - for (Entry entry : _entityMap.get(owner.getName()).entrySet()) + if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) { - for (int id : entry.getValue()) + if (_entityMap.get(owner.getUniqueId()).containsKey(spawnPacket.a)) { - if (id == usePacket.a) + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(spawnPacket.a); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) { - PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); - newPacket.a = entry.getKey(); - newPacket.action = usePacket.action; - newPacket.c = usePacket.c; - - { - ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); - } - - break loop; + newIds[a] = ids[a]; } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + + _entityNameMap.get(owner.getUniqueId()).remove(spawnPacket.a); + _entityMap.get(owner.getUniqueId()).remove(spawnPacket.a); } + + final String entityName = spawnPacket.l.getString(2); + + if (entityName.isEmpty()) + { + return; + } + + Integer[] ids = new Integer[] + { + UtilEnt.getNewEntityId(), + UtilEnt.getNewEntityId() + }; + + _entityNameMap.get(owner.getUniqueId()).put(spawnPacket.a, entityName); + _entityMap.get(owner.getUniqueId()).put(spawnPacket.a, ids); + + sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); + break; } } - else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity) + } + else if (packet instanceof PacketPlayOutNamedEntitySpawn) + { + PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet; + + for (WatchableObject watchable : (List) spawnPacket.i.c()) { - int vech = -1; - int rider = -1; - - if (packet instanceof PacketPlayOutAttachEntity) + if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) { - PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; - vech = attachPacket.b; - rider = attachPacket.c; - } - else if (packet instanceof PacketPlayOutNewAttachEntity) - { - PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet; - vech = attachPacket.a; - - if (attachPacket.b.length > 0) - rider = attachPacket.b[0]; - } - - // c = rider, b = ridden - // When detaching, c is sent, b is -1 - - // If this attach packet is for a player that has the fix - // If the attach packet isn't ordained by me - if (!_entityMap.containsKey(owner.getName())) - { - return; - } - - if (!_entityRiding.containsKey(owner.getName())) - { - _entityRiding.put(owner.getName(), new NautHashMap()); - } - - int vehicleId = -1; - - if (_entityRiding.get(owner.getName()).containsKey(vech)) - { - vehicleId = _entityRiding.get(owner.getName()).get(vech); - } - - if (rider == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId)) - { - Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId); - - _entityRiding.get(owner.getName()).remove(vech); - - sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true, - ids); - } - else - { - Integer[] ids = _entityMap.get(owner.getName()).get(rider); - - if (ids != null && ids[1] != vech) + if (_entityMap.get(owner.getUniqueId()).containsKey(spawnPacket.a)) { - _entityRiding.get(owner.getName()).put(vech, rider); + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(spawnPacket.a); int[] newIds = new int[ids.length]; @@ -519,14 +295,242 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + + _entityNameMap.get(owner.getUniqueId()).remove(spawnPacket.a); + _entityMap.get(owner.getUniqueId()).remove(spawnPacket.a); } + + final String entityName = spawnPacket.i.getString(2); + + if (entityName.isEmpty()) + { + return; + } + + Integer[] ids = new Integer[] + { + UtilEnt.getNewEntityId(), + UtilEnt.getNewEntityId() + }; + + _entityNameMap.get(owner.getUniqueId()).put(spawnPacket.a, entityName); + _entityMap.get(owner.getUniqueId()).put(spawnPacket.a, ids); + + sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids); + break; + } + } + } + else if (packet instanceof PacketPlayOutEntityMetadata) + { + PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; + + if (metaPacket.a != 777777 && !_ignoreIds.contains(metaPacket.a) && metaPacket.a != owner.getEntityId()) + { + boolean isDisplaying = _entityMap.get(owner.getUniqueId()).containsKey(metaPacket.a); + String currentName = _entityNameMap.get(owner.getUniqueId()).get(metaPacket.a); + + if (currentName == null) + { + currentName = ""; + } + + String newName = currentName; + boolean displayName = isDisplaying; + + for (WatchableObject watchable : (List) metaPacket.b) + { + if (watchable.a() == 3 && watchable.b() instanceof Byte) + { + displayName = ((Byte) watchable.b()) == 1; + } + + if (watchable.a() == 2 && watchable.b() instanceof String) + { + newName = (String) watchable.b(); + } + } + + // If the name has changed and the name should be showing, or the name display status has changed. + if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying) + { + // If name is still being displayed + if (displayName) + { + Integer[] newId; + + if (isDisplaying) // Sending metadata + { + newId = _entityMap.get(owner.getUniqueId()).get(metaPacket.a); + } + else + // Spawning new entity + { + newId = new Integer[] + { + UtilEnt.getNewEntityId(), + UtilEnt.getNewEntityId() + }; + + _entityMap.get(owner.getUniqueId()).put(metaPacket.a, newId); + } + + _entityNameMap.get(owner.getUniqueId()).put(metaPacket.a, newName); + sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId); + } + else + { // Lets delete it + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(metaPacket.a); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds)); + + _entityMap.get(owner.getUniqueId()).remove(metaPacket.a); + _entityNameMap.get(owner.getUniqueId()).remove(metaPacket.a); + } + } + } + } + else if (packet instanceof PacketPlayOutEntityDestroy) + { + try + { + for (int id : ((PacketPlayOutEntityDestroy) packet).a) + { + if (_entityMap.get(owner.getUniqueId()).containsKey(id)) + { + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(id); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + _entityMap.get(owner.getUniqueId()).remove(id); + _entityNameMap.get(owner.getUniqueId()).remove(id); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + else if (packet instanceof PacketPlayOutSpawnEntity) + { + PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet; + if (spawnPacket.j == 78) // Armor Stand Object ID + { + _ignoreIds.add(spawnPacket.a); + } + } + else if (packet instanceof PacketPlayInUseEntity) + { + PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; + + loop: + + for (Entry entry : _entityMap.get(owner.getUniqueId()).entrySet()) + { + for (int id : entry.getValue()) + { + if (id == usePacket.a) + { + PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); + newPacket.a = entry.getKey(); + newPacket.action = usePacket.action; + newPacket.c = usePacket.c; + + { + ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); + } + + break loop; + } + } + } + } + else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity) + { + int vech = -1; + int rider = -1; + + if (packet instanceof PacketPlayOutAttachEntity) + { + PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; + vech = attachPacket.b; + rider = attachPacket.c; + } + else if (packet instanceof PacketPlayOutNewAttachEntity) + { + PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet; + vech = attachPacket.a; + + if (attachPacket.b.length > 0) + rider = attachPacket.b[0]; + } + + // c = rider, b = ridden + // When detaching, c is sent, b is -1 + + // If this attach packet is for a player that has the fix + // If the attach packet isn't ordained by me + if (!_entityMap.containsKey(owner.getUniqueId())) + { + return; + } + + if (!_entityRiding.containsKey(owner.getUniqueId())) + { + _entityRiding.put(owner.getUniqueId(), new HashMap()); + } + + int vehicleId = -1; + + if (_entityRiding.get(owner.getUniqueId()).containsKey(vech)) + { + vehicleId = _entityRiding.get(owner.getUniqueId()).get(vech); + } + + if (rider == -1 && _entityMap.get(owner.getUniqueId()).containsKey(vehicleId)) + { + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(vehicleId); + + _entityRiding.get(owner.getUniqueId()).remove(vech); + + sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getUniqueId()).get(vehicleId), verifier, true, + ids); + } + else + { + Integer[] ids = _entityMap.get(owner.getUniqueId()).get(rider); + + if (ids != null && ids[1] != vech) + { + _entityRiding.get(owner.getUniqueId()).put(vech, rider); + + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); } } } } private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList, - final boolean newPacket, final Integer[] entityIds) + final boolean newPacket, final Integer[] entityIds) { CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); _plugin.getServer().getPluginManager().callEvent(event); @@ -565,9 +569,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (UtilPlayer.is1_9(owner)) { UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[] - { - entityIds[1] - })); + { + entityIds[1] + })); } else { @@ -595,9 +599,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook if (UtilPlayer.is1_9(owner)) { UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[] - { - entityIds[0] - })); + { + entityIds[0] + })); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/Managers.java b/Plugins/Mineplex.Core/src/mineplex/core/Managers.java new file mode 100644 index 000000000..f37bfc810 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/Managers.java @@ -0,0 +1,92 @@ +package mineplex.core; + +import mineplex.core.common.util.UtilServer; + +import java.lang.reflect.Constructor; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * This class will manage all the MiniPlugin instances. It's not the best way to do it, but it works given how + * we use MiniPlugins right now, so let's not fret about that + */ +public class Managers +{ + private static final Map, Object> MANAGER_MAP = Collections.synchronizedMap(new HashMap<>()); + + /** + * Gets a Manager ({@link MiniPlugin}) based on its class + * + * @param clazz The class of the MiniPlugin to return + * @return The mapped MiniPlugin, or null if not found + */ + public static T get(Class clazz) + { + Object result = MANAGER_MAP.get(clazz); + return clazz.cast(result); + } + + /** + * Gets the given module, and initializes if necessary + * @param clazz + * @param + * @return + */ + public static T require(Class clazz) + { + if (MANAGER_MAP.containsKey(clazz)) + { + return get(clazz); + } + try + { + ReflectivelyCreateMiniPlugin annotation = clazz.getAnnotation(ReflectivelyCreateMiniPlugin.class); + if (annotation != null) + { + Constructor defaultConstructor = clazz.getDeclaredConstructor(); + defaultConstructor.setAccessible(true); + return defaultConstructor.newInstance(); + } + } + catch (ReflectiveOperationException ex) + { + ex.printStackTrace(System.out); + } + return null; + } + + public static void put(MiniPlugin manager) + { + if (manager == null) throw new NullPointerException("Manager cannot be null"); + if (MANAGER_MAP.containsKey(manager.getClass())) + { + if (!UtilServer.isTestServer()) + { + System.out.println("============== WARNING =============="); + System.out.println(" "); + System.out.println(" "); + System.out.println(" "); + System.out.println("Attempted to register " + manager.getClass().getName() + ", but it was already registered"); + new Exception("Stack trace").printStackTrace(System.out); + System.out.println(" "); + System.out.println(" "); + System.out.println(" "); + System.out.println("============== WARNING =============="); + } + else + { + throw new IllegalArgumentException("Manager " + manager.getClass().getName() + " is already registered"); + } + } + MANAGER_MAP.put(manager.getClass(), manager); + } + + public static void put(MiniPlugin manager, Class type) + { + if (manager == null) throw new NullPointerException("Manager cannot be null"); + if (!type.isAssignableFrom(manager.getClass())) throw new IllegalArgumentException(manager.getClass().getName() + " is not a subclass of " + type.getName()); + if (MANAGER_MAP.containsKey(type)) throw new IllegalArgumentException("Manager " + type.getName() + " is already registered"); + MANAGER_MAP.put(type, manager); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java index d90d08fe5..c5f2119e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java @@ -1,19 +1,21 @@ package mineplex.core; -import java.util.Collection; - +import mineplex.core.account.event.ClientUnloadEvent; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.account.event.ClientUnloadEvent; -import mineplex.core.common.util.NautHashMap; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public abstract class MiniClientPlugin extends MiniPlugin { - private static Object _clientDataLock = new Object(); + private static final Object _clientDataLock = new Object(); - private NautHashMap _clientData = new NautHashMap(); + private Map _clientData = new HashMap<>(); public MiniClientPlugin(String moduleName, JavaPlugin plugin) { @@ -26,18 +28,27 @@ public abstract class MiniClientPlugin extends MiniPlug synchronized (_clientDataLock) { saveData(event.GetName(), event.getAccountId()); - _clientData.remove(event.GetName()); + _clientData.remove(event.getUniqueId()); } } - + + @Deprecated public DataType Get(String name) + { + Player player = Bukkit.getPlayerExact(name); + if (player == null) + return null; + return Get(player); + } + + public DataType Get(UUID uuid) { synchronized (_clientDataLock) { - if (!_clientData.containsKey(name)) - _clientData.put(name, addPlayer(name)); - - return _clientData.get(name); + if (!_clientData.containsKey(uuid)) + _clientData.put(uuid, addPlayer(uuid)); + + return _clientData.get(uuid); } } @@ -45,7 +56,7 @@ public abstract class MiniClientPlugin extends MiniPlug public DataType Get(Player player) { - return Get(player.getName()); + return Get(player.getUniqueId()); } protected Collection GetValues() @@ -55,16 +66,16 @@ public abstract class MiniClientPlugin extends MiniPlug protected void Set(Player player, DataType data) { - Set(player.getName(), data); + Set(player.getUniqueId(), data); } - - protected void Set(String name, DataType data) + + protected void Set(UUID uuid, DataType data) { synchronized (_clientDataLock) { - _clientData.put(name, data); + _clientData.put(uuid, data); } } - protected abstract DataType addPlayer(String player); + protected abstract DataType addPlayer(UUID uuid); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java index 2f479adeb..52805cdc5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniDbClientPlugin.java @@ -2,6 +2,7 @@ package mineplex.core; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import org.bukkit.plugin.java.JavaPlugin; @@ -21,7 +22,7 @@ public abstract class MiniDbClientPlugin extends MiniCl clientManager.addStoredProcedureLoginProcessor(this); } - public abstract void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException; + public abstract void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException; public CoreClientManager getClientManager() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java index 435f4dcff..80c128715 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java @@ -1,20 +1,30 @@ package mineplex.core; +import mineplex.core.command.CommandCenter; +import mineplex.core.command.ICommand; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.thread.ThreadPool; import org.bukkit.Bukkit; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitTask; -import mineplex.core.command.CommandCenter; -import mineplex.core.command.ICommand; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.thread.ThreadPool; - +/** + * In the future, all implementations of MiniPlugin should only have one constructor: + * + * private MiniPlugin() + * + * MiniPlugins should also not depend on load order. + * + * This way, we can reflectively create them during {@link #require} when they do not exist, leading to much cleaner code + */ public abstract class MiniPlugin implements Listener { protected String _moduleName = "Default"; @@ -23,6 +33,11 @@ public abstract class MiniPlugin implements Listener protected long _initializedTime; + public MiniPlugin(String moduleName) + { + this(moduleName, UtilServer.getPlugin()); + } + public MiniPlugin(String moduleName, JavaPlugin plugin) { _moduleName = moduleName; @@ -30,11 +45,13 @@ public abstract class MiniPlugin implements Listener _initializedTime = System.currentTimeMillis(); - _commands = new NautHashMap(); + _commands = new NautHashMap<>(); onEnable(); registerEvents(this); + + Managers.put(this); } public PluginManager getPluginManager() @@ -111,22 +128,36 @@ public abstract class MiniPlugin implements Listener public void runAsync(Runnable runnable) { - // Instead of using ThreadPool.ASYNC.execute(runnable); } - public void runAsync(Runnable runnable, long time) + public BukkitTask runAsync(Runnable runnable, long time) { - _plugin.getServer().getScheduler().runTaskLaterAsynchronously(_plugin, runnable, time); + return _plugin.getServer().getScheduler().runTaskLaterAsynchronously(_plugin, runnable, time); } - public void runSync(Runnable runnable) + public BukkitTask runAsyncTimer(Runnable runnable, long time, long period) { - _plugin.getServer().getScheduler().runTask(_plugin, runnable); + return _plugin.getServer().getScheduler().runTaskTimerAsynchronously(_plugin, runnable, time, period); } - public void runSyncLater(Runnable runnable, long delay) + public BukkitTask runSync(Runnable runnable) { - _plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay); + return _plugin.getServer().getScheduler().runTask(_plugin, runnable); + } + + public BukkitTask runSyncLater(Runnable runnable, long delay) + { + return _plugin.getServer().getScheduler().runTaskLater(_plugin, runnable, delay); + } + + public BukkitTask runSyncTimer(Runnable runnable, long delay, long period) + { + return _plugin.getServer().getScheduler().runTaskTimer(_plugin, runnable, delay, period); + } + + protected T require(Class clazz) + { + return Managers.require(clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java b/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java index 227cba9bb..19d74a4b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java @@ -4,6 +4,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.MathHelper; @@ -33,7 +35,7 @@ import mineplex.core.updater.event.UpdateEvent; public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler { - private HashMap> _armorStands = new HashMap>(); + private Map> _armorStands = new HashMap<>(); public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler) { @@ -46,7 +48,7 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler @EventHandler public void onQuit(PlayerQuitEvent event) { - _armorStands.remove(event.getPlayer().getName()); + _armorStands.remove(event.getPlayer().getUniqueId()); } @EventHandler @@ -57,13 +59,13 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler return; } - Iterator itel = _armorStands.keySet().iterator(); + Iterator itel = _armorStands.keySet().iterator(); while (itel.hasNext()) { - String name = itel.next(); + UUID id = itel.next(); - Player player = Bukkit.getPlayerExact(name); + Player player = Bukkit.getPlayer(id); if (player != null) { @@ -89,12 +91,12 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler return; } - if (!_armorStands.containsKey(player.getName())) + if (!_armorStands.containsKey(player.getUniqueId())) { - _armorStands.put(player.getName(), new HashSet()); + _armorStands.put(player.getUniqueId(), new HashSet()); } - HashSet list = _armorStands.get(player.getName()); + HashSet list = _armorStands.get(player.getUniqueId()); if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java new file mode 100644 index 000000000..7969cf22e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java @@ -0,0 +1,159 @@ +package mineplex.core; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.incognito.IncognitoManager; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * A helper for selecting arbitrary players given a set of conditions + */ +public class PlayerSelector +{ + /** + * Select a random player from all the online players + * + * @return A random player, or null if none matched + */ + public static Player selectPlayer() + { + return selectPlayer(player -> true); + } + + /** + * Select a random player who match the given criterion + * + * @param selector The condition that the players must match against + * @return A random player, or null if none matched + */ + public static Player selectPlayer(Predicate selector) + { + List selected = selectPlayers(selector); + return selected.get(ThreadLocalRandom.current().nextInt(selected.size())); + } + + /** + * Select all the players who match the given criterion + * @param selector The condition that the players must match against + * @return All the players who match + */ + public static List selectPlayers(Predicate selector) + { + return Bukkit.getOnlinePlayers().stream().filter(selector).collect(Collectors.toList()); + } + + /** + * This condition will return true if the player is not vanished, and false if they are. + * + * If the {@link IncognitoManager} is not loaded, then this will return true + */ + public static final Predicate NOT_VANISHED = player -> + { + IncognitoManager manager = Managers.get(IncognitoManager.class); + if (manager == null) + { + return true; + } + return !manager.Get(player).Status; + }; + + /** + * This condition will return true if the player is not spectating, and false if they are + */ + public static final Predicate NOT_SPECTATING = player -> player.getGameMode() != GameMode.SPECTATOR; + + /** + * This condition will return true if the player has one of the given ranks + * + * @param useDisguisedRank Whether to use the disguised rank of the player should they be disguised + * @param ranks The ranks to check + * @return The resulting criterion + */ + public static Predicate hasAnyRank(boolean useDisguisedRank, Rank... ranks) + { + return player -> + { + CoreClientManager coreClientManager = Managers.get(CoreClientManager.class); + if (coreClientManager == null) + { + return true; + } + CoreClient client = coreClientManager.Get(player); + Rank rank = useDisguisedRank ? client.getRealOrDisguisedRank() : client.GetRank(); + + for (Rank requiredRank : ranks) + { + if (rank == requiredRank) + { + return true; + } + } + + return false; + }; + } + + + /** + * This condition will return true if the entity is in the world specified + * @param world The world that the entity must be in + * @return The resulting criterion + */ + public static Predicate inWorld(World world) + { + return entity -> world == null || entity.getWorld().equals(world); + } + + /** + * This will return a {@link Predicate} which will return true if and only if all of the supplied Predicates + * return true + * @param predicates The Predicates to test against + * @return The resulting criterion + */ + @SafeVarargs + public static Predicate and(Predicate... predicates) + { + return t -> + { + for (Predicate predicate : predicates) + { + if (!predicate.test(t)) + { + return false; + } + } + return true; + }; + } + + /** + * This will return a {@link Predicate} which will return true if and only if one of the the supplied Predicates + * return true + * @param predicates The Predicates to test against + * @return The resulting criterion + */ + @SafeVarargs + public static Predicate or(Predicate... predicates) + { + return t -> + { + for (Predicate predicate : predicates) + { + if (predicate.test(t)) + { + return true; + } + } + return false; + }; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java new file mode 100644 index 000000000..18c11d4cf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ReflectivelyCreateMiniPlugin.java @@ -0,0 +1,15 @@ +package mineplex.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Simply represents that this {@link MiniPlugin} can be reflectively instantiated with no harm + */ +@Target(value = ElementType.TYPE) +@Retention(value = RetentionPolicy.RUNTIME) +public @interface ReflectivelyCreateMiniPlugin +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 61ccdc618..603281907 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -9,51 +9,66 @@ import mineplex.serverdata.Utility; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -public class CoreClient +import java.util.UUID; + +public class CoreClient { - private int _accountId = -1; - private long _networkSessionLoginTime; + private int _accountId = -1; + private long _networkSessionLoginTime; private String _name; - private String _disguisedAs; + private UUID _uuid; private Player _player; private Rank _rank, _lastRank; - private Rank _disguisedRank; private Rank _tempRank, _lastTemp; - private boolean _disguised; - + + /* + * Disguise info + */ + private String _disguisedName; + private String _disguisedSkin; + private UUID _disguisedUUID; + private Rank _disguisedRank; + public CoreClient(Player player) { _player = player; + _uuid = player.getUniqueId(); _name = player.getName(); _networkSessionLoginTime = Utility.currentTimeMillis(); } - - public CoreClient(String name) + + public CoreClient(String name, UUID uuid) { _name = name; + _uuid = uuid; } - public String GetPlayerName() + public UUID getUniqueId() + { + return this._uuid; + } + + public String getName() { return _name; } - + public Player GetPlayer() { return _player; } - - public void SetPlayer(Player player) - { - _player = player; - } - - public int getAccountId() - { - return _accountId; - } - public void Delete() + public void SetPlayer(Player player) + { + _player = player; + } + + public int getAccountId() + { + return _accountId; + } + + public void Delete() { _name = null; _player = null; @@ -63,7 +78,7 @@ public class CoreClient { _accountId = accountId; } - + public Rank GetRank() { return GetRank(false); @@ -73,13 +88,13 @@ public class CoreClient { if (_rank == null) _rank = Rank.ALL; - + if (bypass || _tempRank == null) return _rank; else return _tempRank; } - + public Rank GetLastRank(boolean temp) { if (temp) @@ -100,7 +115,7 @@ public class CoreClient return _lastRank; } } - + public void SetRank(Rank rank, boolean temp) { if (temp) @@ -117,47 +132,70 @@ public class CoreClient _rank = rank; } } - + public long getNetworkSessionLoginTime() { return _networkSessionLoginTime; } - public String getDisguisedAs() + public void undisguise() { - return _disguisedAs; + this._disguisedName = null; + this._disguisedSkin = null; + this._disguisedRank = null; + this._disguisedUUID = null; } - public void setDisguisedAs(String originalName) + public String getDisguisedAs() { - this._disguisedAs = originalName; + return this._disguisedName; } - /** - * Only use this method if the client is actually disguised! - * @return - */ - public Rank getDisguisedRank() { + public String getDisguisedSkin() + { + return this._disguisedSkin; + } + + public Rank getDisguisedRank() + { return _disguisedRank; } - public void setDisguisedRank(Rank disguisedRank) { - this._disguisedRank = disguisedRank; + public UUID getDisguisedAsUUID() + { + return this._disguisedUUID; } - public boolean isDisguised() { - return _disguised; + public boolean isDisguised() + { + if (this._disguisedName == null) + { + return false; + } + return !this._name.equalsIgnoreCase(this._disguisedName); } - public void setDisguised(boolean disguised) { - this._disguised = disguised; + public void disguise(String name, UUID uuid, Rank rank) + { + this._disguisedName = name; + this._disguisedUUID = uuid; + this._disguisedRank = rank; } - public void setNetworkSessionLoginTime(long loginTime) + public Rank getRealOrDisguisedRank() + { + if (this._disguisedRank != null) + { + return this._disguisedRank; + } + return this.GetRank(); + } + + public void setNetworkSessionLoginTime(long loginTime) { _networkSessionLoginTime = loginTime; } - + public void resetTemp() { if (_tempRank != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index e025133f9..dc68fca79 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -2,12 +2,17 @@ package mineplex.core.account; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import com.google.gson.Gson; @@ -22,13 +27,14 @@ import mineplex.core.account.repository.AccountRepository; import mineplex.core.account.repository.token.ClientToken; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTasks; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -43,43 +49,41 @@ import org.bukkit.plugin.java.JavaPlugin; public class CoreClientManager extends MiniPlugin { - private static NautHashMap _clientLoginLock = new NautHashMap(); - + private static final Map CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>(); + private JavaPlugin _plugin; private AccountRepository _repository; - private NautHashMap _clientList; - private HashSet _duplicateLoginGlitchPreventionList; + private Map _clientList = new HashMap<>(); + private HashSet _duplicateLoginGlitchPreventionList = new HashSet<>(); private List _loginProcessors = new ArrayList<>(); - private Object _clientLock = new Object(); - + private final Object _clientLock = new Object(); + private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsProcessing = new AtomicInteger(0); - + private final Rank WHITELIST_BYPASS; - + public CoreClientManager(JavaPlugin plugin, String webServer) { this(plugin, webServer, Rank.MODERATOR); } - + public CoreClientManager(JavaPlugin plugin, String webServer, Rank whitelistBypass) { super("Client Manager", plugin); - + _plugin = plugin; _repository = new AccountRepository(plugin, webServer); - _clientList = new NautHashMap(); - _duplicateLoginGlitchPreventionList = new HashSet(); - WHITELIST_BYPASS = whitelistBypass; + WHITELIST_BYPASS = whitelistBypass; } - + public AccountRepository getRepository() { return _repository; } - + @Override public void addCommands() { @@ -87,72 +91,71 @@ public class CoreClientManager extends MiniPlugin addCommand(new TestRank(this)); } - public CoreClient Add(String name) + public CoreClient Add(String name, UUID uuid) { - CoreClient newClient = null; - - if (newClient == null) + CoreClient newClient = new CoreClient(name, uuid); + + CoreClient oldClient; + + synchronized (_clientLock) { - newClient = new CoreClient(name); + oldClient = _clientList.put(uuid, newClient); } - - CoreClient oldClient = null; - - synchronized(_clientLock) + + if (oldClient != null) { - oldClient = _clientList.put(name, newClient); + oldClient.Delete(); } - - if (oldClient != null) - { - oldClient.Delete(); - } return newClient; } - public void Del(String name, int accountId) + public void Del(String name, UUID uuid, int accountId) { - synchronized(_clientLock) + synchronized (_clientLock) { - _clientList.remove(name); + _clientList.remove(uuid); } // rawr added account id for custom data - william - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name, accountId)); + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name, uuid, accountId)); } + @Deprecated public CoreClient Get(String name) { - synchronized(_clientLock) + Player p = Bukkit.getPlayerExact(name); + return Get(p.getUniqueId()); + } + + public CoreClient Get(UUID uuid) + { + synchronized (_clientLock) { - for(CoreClient client : _clientList.values()) - { - if(client.getDisguisedAs() != null) - if(client.getDisguisedAs().equalsIgnoreCase(name)) - return client; - } - CoreClient client = _clientList.get(name); - + CoreClient client = _clientList.get(uuid); + if (client == null) { - client = new CoreClient(name); + Player player = Bukkit.getPlayer(uuid); + if (player != null) + { + client = new CoreClient(player.getName(), uuid); + } + else + { + client = new CoreClient(null, uuid); + } } - + return client; } } - - public boolean Contains(String name) - { - return _clientList.containsKey(name); - } - + public CoreClient Get(Player player) { - return Get(player.getName()); + return Get(player.getUniqueId()); } - + public int getPlayerCountIncludingConnecting() { return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get()); @@ -160,6 +163,7 @@ public class CoreClientManager extends MiniPlugin /** * Get the databse account id for a player. Requires the player is online + * * @param player * @return */ @@ -185,12 +189,12 @@ public class CoreClientManager extends MiniPlugin e.printStackTrace(); } } - + try { _clientsProcessing.incrementAndGet(); - - if (!LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress())) + + if (!LoadClient(Add(event.getName(), event.getUniqueId()), event.getUniqueId(), event.getAddress().getHostAddress())) event.disallow(Result.KICK_OTHER, "There was a problem logging you in."); } catch (Exception exception) @@ -202,8 +206,8 @@ public class CoreClientManager extends MiniPlugin { _clientsProcessing.decrementAndGet(); } - - if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(WHITELIST_BYPASS)) + + if (Bukkit.hasWhitelist() && !Get(event.getUniqueId()).GetRank().has(WHITELIST_BYPASS)) { for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { @@ -212,7 +216,7 @@ public class CoreClientManager extends MiniPlugin return; } } - + event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend."); } } @@ -226,93 +230,84 @@ public class CoreClientManager extends MiniPlugin { _repository.getAccountId(uuid, callback); } - + public void loadClientByName(final String playerName, final Runnable runnable) { - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + loadClientByName(playerName, client -> runnable.run()); + } + + public void loadClientByName(String playerName, Consumer loadedClient) + { + runAsync(() -> { - public void run() + AtomicReference loaded = new AtomicReference<>(); + try { - try + ClientToken token = null; + Gson gson = new Gson(); + + // Fails if not in DB and if duplicate. + UUID uuid = loadUUIDFromDB(playerName); + + if (uuid == null) { - ClientToken token = null; - Gson gson = new Gson(); - - // Fails if not in DB and if duplicate. - UUID uuid = loadUUIDFromDB(playerName); - - if (uuid == null) + uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> {}).get().getId(); + } + + String response = ""; + + if (uuid == null) + { + response = _repository.getClientByName(playerName); + } + else + { + response = _repository.getClientByUUID(uuid); + } + + token = gson.fromJson(response, ClientToken.class); + + CoreClient client = Add(playerName, uuid); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + + // JSON sql response + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); + + if (client.getAccountId() > 0) + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) { - try - { - uuid = UUIDFetcher.getUUIDOf(playerName); - } - catch (Exception exception) - { - System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); - } - } - - String response = ""; - - if (uuid == null) - { - response = _repository.getClientByName(playerName); - } - else - { - response = _repository.getClientByUUID(uuid); - } - - token = gson.fromJson(response, ClientToken.class); - - CoreClient client = Add(playerName); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); - - // JSON sql response - Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); - - if (client.getAccountId() > 0) - { - PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); - - if (playerInfo != null) - { - playerInfo.setAccountId(client.getAccountId()); - PlayerCache.getInstance().addPlayer(playerInfo); - } + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); } } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() - { - public void run() - { - if (runnable != null) - runnable.run(); - } - }); - } + + loaded.set(client); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + UtilTasks.onMainThread(() -> loadedClient.accept(loaded.get())).run(); } }); } - + public void loadClientByNameSync(final String playerName, final Runnable runnable) { try { ClientToken token = null; Gson gson = new Gson(); - + // Fails if not in DB and if duplicate. UUID uuid = loadUUIDFromDB(playerName); - + if (uuid == null) { try @@ -324,9 +319,9 @@ public class CoreClientManager extends MiniPlugin System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); } } - + String response = ""; - + if (uuid == null) { response = _repository.getClientByName(playerName); @@ -335,20 +330,20 @@ public class CoreClientManager extends MiniPlugin { response = _repository.getClientByUUID(uuid); } - - token = gson.fromJson(response, ClientToken.class); - CoreClient client = Add(playerName); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); - + token = gson.fromJson(response, ClientToken.class); + + CoreClient client = Add(playerName, uuid); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); - + if (client.getAccountId() > 0) { PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); - + if (playerInfo != null) { playerInfo.setAccountId(client.getAccountId()); @@ -358,7 +353,7 @@ public class CoreClientManager extends MiniPlugin } catch (Exception exception) { - exception.printStackTrace(); + exception.printStackTrace(); } finally { @@ -372,13 +367,13 @@ public class CoreClientManager extends MiniPlugin }); } } - + public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { - TimingManager.start(client.GetPlayerName() + " LoadClient Total."); + TimingManager.start(client.getName() + " LoadClient Total."); long timeStart = System.currentTimeMillis(); - _clientLoginLock.put(client.GetPlayerName(), new Object()); + CLIENT_LOGIN_LOCKS.put(client.getName(), new Object()); ClientToken token = null; Gson gson = new Gson(); @@ -387,33 +382,36 @@ public class CoreClientManager extends MiniPlugin @Override public void run() { - try { - client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); - } catch (SQLException e) { + try + { + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + } + catch (SQLException e) + { // TODO Auto-generated catch block e.printStackTrace(); } - _clientLoginLock.remove(client.GetPlayerName()); + CLIENT_LOGIN_LOCKS.remove(client.getName()); } }); - - TimingManager.start(client.GetPlayerName() + " GetClient."); - String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress); - TimingManager.stop(client.GetPlayerName() + " GetClient."); - TimingManager.start(client.GetPlayerName() + " Event."); - token = gson.fromJson(response, ClientToken.class); - + TimingManager.start(client.getName() + " GetClient."); + String response = _repository.GetClient(client.getName(), uuid, ipAddress); + TimingManager.stop(client.getName() + " GetClient."); + + TimingManager.start(client.getName() + " Event."); + token = gson.fromJson(response, ClientToken.class); + client.SetRank(Rank.valueOf(token.Rank), false); - + // _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString()); - + // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); - TimingManager.stop(client.GetPlayerName() + " Event."); + TimingManager.stop(client.getName() + " Event."); - TimingManager.start(client.GetPlayerName() + " While Loop."); - while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000) + TimingManager.start(client.getName() + " While Loop."); + while (CLIENT_LOGIN_LOCKS.containsKey(client.getName()) && System.currentTimeMillis() - timeStart < 15000) { try { @@ -424,19 +422,19 @@ public class CoreClientManager extends MiniPlugin e.printStackTrace(); } } - TimingManager.stop(client.GetPlayerName() + " While Loop."); - - if (_clientLoginLock.containsKey(client.GetPlayerName())) + TimingManager.stop(client.getName() + " While Loop."); + + if (CLIENT_LOGIN_LOCKS.containsKey(client.getName())) { System.out.println("MYSQL TOO LONG TO LOGIN...."); } - - TimingManager.stop(client.GetPlayerName() + " LoadClient Total."); - + + TimingManager.stop(client.getName() + " LoadClient Total."); + if (client.getAccountId() > 0) { PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); - + if (playerInfo != null) { client.setNetworkSessionLoginTime(playerInfo.getLoginTime()); @@ -444,32 +442,32 @@ public class CoreClientManager extends MiniPlugin PlayerCache.getInstance().addPlayer(playerInfo); } } - - return !_clientLoginLock.containsKey(client.GetPlayerName()); + + return !CLIENT_LOGIN_LOCKS.containsKey(client.getName()); } @EventHandler(priority = EventPriority.LOWEST) public void Login(PlayerLoginEvent event) { - synchronized(_clientLock) + synchronized (_clientLock) { - if (!_clientList.containsKey(event.getPlayer().getName())) + if (!_clientList.containsKey(event.getPlayer().getUniqueId())) { - _clientList.put(event.getPlayer().getName(), new CoreClient(event.getPlayer().getName())); + _clientList.put(event.getPlayer().getUniqueId(), new CoreClient(event.getPlayer().getName(), event.getPlayer().getUniqueId())); } } - CoreClient client = Get(event.getPlayer().getName()); - - if (client == null || client.GetRank() == null) - { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); - return; - } - - client.SetPlayer(event.getPlayer()); - - // Reserved Slot Check + CoreClient client = Get(event.getPlayer().getUniqueId()); + + if (client == null || client.GetRank() == null) + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); + return; + } + + client.SetPlayer(event.getPlayer()); + + // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false)) @@ -478,27 +476,29 @@ public class CoreClientManager extends MiniPlugin event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server is full and no longer accepts players."); } } - + @EventHandler public void Kick(PlayerKickEvent event) { if (event.getReason().contains("You logged in from another location")) { - _duplicateLoginGlitchPreventionList.add(event.getPlayer().getName()); - Bukkit.getScheduler().runTask(_plugin, new Runnable() { - public void run() { - if(!_clientList.containsKey(event.getPlayer().getName())) return; - Player p = _clientList.get(event.getPlayer().getName()).GetPlayer(); - p.kickPlayer("You're already logged in."); - } + _duplicateLoginGlitchPreventionList.add(event.getPlayer().getUniqueId()); + Bukkit.getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + if (!_clientList.containsKey(event.getPlayer().getUniqueId())) return; + Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer(); + p.kickPlayer("You're already logged in."); + } }); } } - + @EventHandler(priority = EventPriority.MONITOR) public void Quit(PlayerQuitEvent event) { @@ -509,11 +509,11 @@ public class CoreClientManager extends MiniPlugin // PlayerKick -> old // PlayerQuit -> old // Then it glitches because it added new, but then removed old afterwards since its based on name as key. - - if (!_duplicateLoginGlitchPreventionList.contains(event.getPlayer().getName())) + + if (!_duplicateLoginGlitchPreventionList.contains(event.getPlayer().getUniqueId())) { - Del(event.getPlayer().getName(), _clientList.get(event.getPlayer().getName()).getAccountId()); - _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getName()); + Del(event.getPlayer().getName(), event.getPlayer().getUniqueId(), _clientList.get(event.getPlayer().getUniqueId()).getAccountId()); + _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getUniqueId()); } } @@ -525,14 +525,14 @@ public class CoreClientManager extends MiniPlugin { if (_plugin.getServer().getPlayer(name) != null) { - CoreClient client = Get(name); + CoreClient client = Get(name); client.SetRank(newRank, false); } } }, name, uuid, rank, perm); } - + public void SaveRank(final Callback callback, final String name, final UUID uuid, Rank rank, boolean perm) { _repository.saveRank(new Callback() @@ -541,17 +541,17 @@ public class CoreClientManager extends MiniPlugin { if (_plugin.getServer().getPlayer(name) != null) { - CoreClient client = Get(name); + CoreClient client = Get(name); client.SetRank(newRank, false); } - + if (callback != null) callback.run(newRank); } }, name, uuid, rank, perm); } - + public void checkPlayerNameExact(final Callback callback, final String playerName) { _repository.matchPlayerName(new Callback>() @@ -570,7 +570,7 @@ public class CoreClientManager extends MiniPlugin } }, playerName); } - + public void checkPlayerName(final Player caller, final String playerName, final Callback callback) { _repository.matchPlayerName(new Callback>() @@ -617,51 +617,51 @@ public class CoreClientManager extends MiniPlugin } }, playerName); } - + // DONT USE THIS IN PRODUCTION...its for enjin listener -someone you despise but definitely not me (defek7) public UUID loadUUIDFromDB(String name) { return _repository.getClientUUID(name); } - + @EventHandler public void cleanGlitchedClients(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - - synchronized(_clientLock) + + synchronized (_clientLock) { - for (Iterator> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext();) + for (Iterator> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext(); ) { CoreClient client = clientIterator.next().getValue(); // rawr, needed this for custom data - william Player clientPlayer = client.GetPlayer(); - + if (clientPlayer != null && !clientPlayer.isOnline()) { clientIterator.remove(); - + if (clientPlayer != null) { - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName(), client.getAccountId())); + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName(), clientPlayer.getUniqueId(), client.getAccountId())); } } } } } - + @EventHandler public void debug(UpdateEvent event) { if (event.getType() != UpdateType.SLOWER) return; - + // System.out.println("====="); // System.out.println("Connecting : " + _clientsConnecting.get()); // System.out.println("Processing : " + _clientsProcessing.get()); // System.out.println("====="); } - + public void addStoredProcedureLoginProcessor(ILoginProcessor processor) { _loginProcessors.add(processor); @@ -672,7 +672,7 @@ public class CoreClientManager extends MiniPlugin CoreClient client = Get(player); if (client == null) return false; - + return client.GetRank().has(rank); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java index 7c7db7911..6aa25a27b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java @@ -2,12 +2,13 @@ package mineplex.core.account; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; public interface ILoginProcessor { String getName(); - void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException; + void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException; String getQuery(int accountId, String uuid, String name); } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java index d0d2d467a..47325e2c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java @@ -3,36 +3,45 @@ package mineplex.core.account.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import java.util.UUID; + public class ClientUnloadEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - - private String _name; - private int _accountId; + private static final HandlerList handlers = new HandlerList(); - public ClientUnloadEvent(String name, int accountId) - { - _name = name; - _accountId = accountId; - } - - public String GetName() - { - return _name; - } + private String _name; + private UUID _uuid; + private int _accountId; - public int getAccountId() - { - return _accountId; - } + public ClientUnloadEvent(String name, UUID uuid, int accountId) + { + _name = name; + _accountId = accountId; + this._uuid = uuid; + } - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } + public String GetName() + { + return _name; + } + + public UUID getUniqueId() + { + return this._uuid; + } + + public int getAccountId() + { + return _accountId; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index e00cd1b21..daea474e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -113,7 +113,7 @@ public class AccountRepository extends MinecraftRepository for (ILoginProcessor loginProcessor : loginProcessors) { - loginProcessor.processLoginResultSet(name, finalId, statement.getResultSet()); + loginProcessor.processLoginResultSet(name, uuid, finalId, statement.getResultSet()); statement.getMoreResults(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 5cdc68527..dbd63549c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -18,6 +18,8 @@ import mineplex.core.incognito.IncognitoManager; import mineplex.core.stats.StatsManager; import mineplex.core.stats.event.StatChangeEvent; +import java.util.UUID; + public class AchievementManager extends MiniPlugin { private IncognitoManager _incognitoManager; @@ -44,16 +46,16 @@ public class AchievementManager extends MiniPlugin public AchievementData get(Player player, Achievement type) { - return get(player.getName(), type); + return get(player.getUniqueId(), type); } - public AchievementData get(String playerName, Achievement type) + public AchievementData get(UUID playerUUID, Achievement type) { int exp = 0; for (String stat : type.getStats()) { - exp += _statsManager.Get(playerName).getStat(stat); + exp += _statsManager.Get(playerUUID).getStat(stat); } return type.getLevelData(exp); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 2bd3903b3..ebcc16e82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,59 +1,110 @@ package mineplex.core.antihack; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerVelocityEvent; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.plugin.java.JavaPlugin; - +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.collect.ImmutableMap; +import com.google.common.util.concurrent.AtomicDouble; +import com.mineplex.anticheat.api.GameEndEvent; +import com.mineplex.anticheat.api.GameStartEvent; +import com.mineplex.anticheat.api.MineplexLink; +import com.mineplex.anticheat.api.PlayerViolationEvent; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.PlayerSelector; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.actions.AntiHackAction; +import mineplex.core.antihack.banwave.BanWaveManager; import mineplex.core.antihack.types.Fly; import mineplex.core.antihack.types.Idle; import mineplex.core.antihack.types.Reach; import mineplex.core.antihack.types.Speed; +import mineplex.core.command.CommandBase; 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.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.*; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Category; import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; +import mineplex.core.punish.Punishment; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.commands.ServerCommandManager; +import net.minecraft.server.v1_8_R3.*; +import org.bukkit.*; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.*; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.plugin.ServicePriority; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitTask; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.function.Predicate; + +@ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - public static AntiHack Instance; + public static final Map CHECKS = ImmutableMap.of( + "Killaura (Type A)", new CheckThresholds("Kill Aura", 25, 50), + "Killaura (Type B)", new CheckThresholds("High CPS", 0, Integer.MAX_VALUE), + "Killaura (Type C)", new CheckThresholds("Reach", Integer.MAX_VALUE, Integer.MAX_VALUE), + "Killaura (Type D)", new CheckThresholds("Kill Aura", 1000, 1500), + "BadPackets", new CheckThresholds("Regen", 1000, 2000) + ); + + public static final String NAME = "Chiss"; + public static final String USER_HAS_BEEN_BANNED = F.main("GWEN", "%s has been banned. I am always watching"); + public static final String USER_HAS_BEEN_BANNED_BANWAVE = USER_HAS_BEEN_BANNED; + + private static final int VL_DIFF_BEFORE_RENOTIFY = 999999; + private static final int MAX_STALKED_PLAYERS = 3; + private static final int STALK_COOLDOWN_TIME_SECONDS = 5; + private static final int MIN_STALK_TIME = 10 * 20; + private static final int MAX_STALK_TIME = 20 * 20; + private static final int MAX_MIN_DIFF = MAX_STALK_TIME - MIN_STALK_TIME; + private static final Function STALK_END_PROBABILITY_EQUATION = x -> + { + return 1.0/ MAX_MIN_DIFF * x; // linear equation with points (0, 0) and (diff, 1) + }; + + private final Cache _cooldown = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(30, TimeUnit.SECONDS) + .build(); + + private final Cache _stalkingCooldown = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(STALK_COOLDOWN_TIME_SECONDS, TimeUnit.SECONDS) + .build(); + private final List _stalking = new ArrayList<>(); + + private final String _thisServer; private boolean _enabled = true; private boolean _strict = false; private boolean _kick = true; - public Punish Punish; - public Portal Portal; - private PreferencesManager _preferences; - private CoreClientManager _clientManager; + public Portal Portal = require(Portal.class); + private PreferencesManager _preferences = require(PreferencesManager.class); + private CoreClientManager _clientManager = require(CoreClientManager.class); //Record Offenses private HashMap>> _offense = new HashMap>>(); @@ -63,16 +114,16 @@ public class AntiHack extends MiniPlugin //Player Info private HashSet _velocityEvent = new HashSet(); - private HashMap _lastMoveEvent = new HashMap(); - + private HashMap _lastMoveEvent = new HashMap(); + private HashSet _hubAttempted = new HashSet(); //Hack Requirements - public int FloatHackTicks = 10; - public int HoverHackTicks = 4; + public int FloatHackTicks = 10; + public int HoverHackTicks = 4; public int RiseHackTicks = 6; public int SpeedHackTicks = 6; - public int IdleTime = 20000; + public int IdleTime = 20000; public int KeepOffensesFor = 30000; @@ -81,19 +132,25 @@ public class AntiHack extends MiniPlugin public ArrayList _movementDetectors; public ArrayList _combatDetectors; - + private AntiHackRepository _repository; - protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager) + private List _guardians = new ArrayList<>(); + + private Predicate _filter = player -> true; + + private Set _pendingBan = new HashSet<>(); + + @SuppressWarnings("Convert2streamapi") + private AntiHack() { - super("AntiHack", plugin); + super("AntiHack"); - Punish = punish; - Portal = portal; - _preferences = preferences; - _clientManager = clientManager; + DisguiseManager disguiseManager = require(DisguiseManager.class); - _repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name")); + this._thisServer = UtilServer.getServerNameFromConfig(); + + _repository = new AntiHackRepository(this._thisServer); _repository.initialize(); _movementDetectors = new ArrayList(); @@ -102,13 +159,598 @@ public class AntiHack extends MiniPlugin _movementDetectors.add(new Fly(this)); _movementDetectors.add(new Idle(this)); _movementDetectors.add(new Speed(this)); - + _combatDetectors.add(new Reach(this)); + + Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLink() + { + @Override + public EntityType getActiveDisguise(Player player) + { + DisguiseBase disguise = disguiseManager.getActiveDisguise(player); + return disguise != null ? disguise.getDisguiseType() : null; + } + + @Override + public boolean isSpectator(Player player) + { + return UtilPlayer.isSpectator(player); + } + }, this._plugin, ServicePriority.Normal); + + ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> + { + IChatBaseComponent component = getMinimalMessage(violation); + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (player.getName().equals("Spoobncoobr")) + { + ((CraftPlayer) player).getHandle().sendMessage(getDetailedMessage(violation)); + + } else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || Managers.get(PreferencesManager.class).get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) + { + ((CraftPlayer) player).getHandle().sendMessage(component); + } + } + }); + + this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + { + for (AntiHackGuardian guardian : this._guardians) + { + if (guardian.getTarget() != null && !guardian.getTarget().isOnline()) + { + this._stalking.remove(guardian.getTarget().getUniqueId()); + guardian.stopTargeting(); + } + else if (guardian.getTargetingTime() > MIN_STALK_TIME) + { + double threshold = STALK_END_PROBABILITY_EQUATION.apply(guardian.getTargetingTime() - MIN_STALK_TIME); + if (Math.random() <= threshold) + { + this._stalking.remove(guardian.getTarget().getUniqueId()); + _stalkingCooldown.put(guardian.getTarget().getUniqueId(), true); + guardian.stopTargeting(); + } + } + guardian.tick(); + } + }, 0L, 1L); + + this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + { + if (_stalking.size() >= MAX_STALKED_PLAYERS) + { + return; + } + + if (_guardians.size() == 0) + { + return; + } + + List targets = PlayerSelector.selectPlayers(PlayerSelector.and( + PlayerSelector.NOT_VANISHED, + PlayerSelector.hasAnyRank(false, + Rank.ALL, + Rank.ULTRA, + Rank.HERO, + Rank.LEGEND, + Rank.TITAN, + Rank.TWITCH, + Rank.YOUTUBE_SMALL, + Rank.YOUTUBE, + Rank.MEDIA, + Rank.ADMIN, + Rank.DEVELOPER, + Rank.OWNER, + Rank.LT + ), + player -> !_stalking.contains(player.getUniqueId()), + player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null, + _filter + )); + + while (_stalking.size() < MAX_STALKED_PLAYERS && targets.size() > 0) + { + Player target = targets.remove(ThreadLocalRandom.current().nextInt(targets.size())); + + int start = ThreadLocalRandom.current().nextInt(_guardians.size()); + + for (int i = start, j = 0; j < _guardians.size(); i++, j++) + { + if (i >= _guardians.size()) + { + i -= _guardians.size(); + } + AntiHackGuardian guardian = _guardians.get(i); + if (!guardian.isTargeting()) + { + guardian.target(target); + _stalking.add(target.getUniqueId()); + break; + } + } + } + }, 0L, 20L); + + require(BanWaveManager.class); } - public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager) + private IChatBaseComponent getDetailedMessage(MajorViolationCommand violation) { - Instance = new AntiHack(plugin, punish, portal, preferences, clientManager); + return new ChatComponentText("") + .addSibling( + new ChatComponentText("A") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setRandom(true) + ) + ) + .addSibling( + new ChatComponentText(" GWEN > ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.RED) + .setBold(true) + ) + ) + .addSibling( + new ChatComponentText(violation.getPlayerName()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.GOLD) + ) + ) + .addSibling( + new ChatComponentText(" failed " + violation.getHackType() + " VL" + violation.getViolations() + " in server ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling( + new ChatComponentText( + violation.getOriginatingServer() + ) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + .setChatClickable( + new ChatClickable( + ChatClickable.EnumClickAction.RUN_COMMAND, + "/server " + violation.getOriginatingServer() + ) + ) + .setChatHoverable( + new ChatHoverable( + ChatHoverable.EnumHoverAction.SHOW_TEXT, + new ChatComponentText("Teleport to " + violation.getOriginatingServer()) + ) + ) + ) + ) + .addSibling( + new ChatComponentText(": " + violation.getMessage() + ". Please investigate!") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ); + } + + private IChatBaseComponent getMinimalMessage(MajorViolationCommand violation) + { + IChatBaseComponent component = new ChatComponentText("") + .addSibling( + new ChatComponentText("A") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setRandom(true) + ) + ) + .addSibling( + new ChatComponentText(" GWEN > ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.RED) + .setBold(true) + ) + ) + .addSibling( + new ChatComponentText(violation.getPlayerName()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.GOLD) + ) + ) + .addSibling( + new ChatComponentText(" suspected of ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling(CHECKS.get(violation.getHackType()).format(violation.getViolations())); + + if (!violation.getOriginatingServer().equals(this._thisServer)) + { + component + .addSibling( + new ChatComponentText(" in ") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ) + .addSibling( + new ChatComponentText(violation.getOriginatingServer()) + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.AQUA) + .setChatClickable( + new ChatClickable( + ChatClickable.EnumClickAction.RUN_COMMAND, + "/server " + violation.getOriginatingServer() + ) + ) + .setChatHoverable( + new ChatHoverable( + ChatHoverable.EnumHoverAction.SHOW_TEXT, + new ChatComponentText("Teleport to " + violation.getOriginatingServer()) + ) + ) + ) + ); + } + + return component.addSibling( + new ChatComponentText(". Please investigate!") + .setChatModifier( + new ChatModifier() + .setColor(EnumChatFormat.YELLOW) + ) + ); + } + + public void registerFilter(Predicate filter) + { + if (filter == null) + { + this._filter = player -> true; + } + else + { + this._filter = filter; + } + } + + public void registerGuardian(AntiHackGuardian guardian) + { + this._guardians.add(guardian); + } + + public void clearGuardians() + { + this._guardians.forEach(AntiHackGuardian::remove); + this._guardians.clear(); + this._stalking.clear(); + this._stalkingCooldown.cleanUp(); + } + + public void runBanAnimation(Player player, Runnable after) + { + if (_pendingBan.add(player)) + { + float oldWalkSpeed = player.getWalkSpeed(); + player.setWalkSpeed(0); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); + + double radius = 4; + double heightAdj = 8; + + double baseDeg = 18; + + Location center = player.getLocation().add(0, heightAdj, 0); + AntiHackGuardian north = new AntiHackGuardian(center.clone().add(0, 0, -radius), 0, 0, 0, 0, 0, 0); + AntiHackGuardian east = new AntiHackGuardian(center.clone().add(radius, 0, 0), 0, 0, 0, 0, 0, 0); + AntiHackGuardian south = new AntiHackGuardian(center.clone().add(0, 0, radius), 0, 0, 0, 0, 0, 0); + AntiHackGuardian west = new AntiHackGuardian(center.clone().add(-radius, 0, 0), 0, 0, 0, 0, 0, 0); + + UtilEnt.CreatureLook(east.getEntity(), player); + UtilEnt.CreatureLook(west.getEntity(), player); + UtilEnt.CreatureLook(south.getEntity(), player); + UtilEnt.CreatureLook(north.getEntity(), player); + + Function magic = seconds -> + { + return Math.pow(2, seconds - 5); + }; + + runSyncLater(() -> + { + north.shoot(player); + east.shoot(player); + south.shoot(player); + west.shoot(player); + + // We get 5 seconds, or 100 ticks + AtomicInteger timer = new AtomicInteger(5); + AtomicReference task = new AtomicReference<>(); + + AtomicDouble cNorth = new AtomicDouble(270); + AtomicDouble cEast = new AtomicDouble(0); + AtomicDouble cSouth = new AtomicDouble(90); + AtomicDouble cWest = new AtomicDouble(180); + + task.set(runSyncTimer(() -> + { + timer.getAndIncrement(); + if (timer.get() > 100) + { + task.get().cancel(); + + player.removePotionEffect(PotionEffectType.JUMP); + player.setWalkSpeed(oldWalkSpeed); + Location location = player.getLocation(); + + UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, player.getLocation(), 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); + + after.run(); + + _pendingBan.remove(player); + + north.shoot(null); + south.shoot(null); + east.shoot(null); + west.shoot(null); + UtilEnt.CreatureLook(north.getEntity(), location); + UtilEnt.CreatureLook(south.getEntity(), location); + UtilEnt.CreatureLook(east.getEntity(), location); + UtilEnt.CreatureLook(west.getEntity(), location); + runSyncLater(() -> + { + north.remove(); + south.remove(); + east.remove(); + west.remove(); + }, 40L); + return; + } + + double seconds = timer.get() / 20.0; + + double rate = magic.apply(seconds) * 3 * baseDeg; + + player.getLocation(center); + center.add(0, heightAdj, 0); + + { + cNorth.addAndGet(rate); + north.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cNorth.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cNorth.get()))); + } + { + cSouth.addAndGet(rate); + south.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cSouth.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cSouth.get()))); + } + { + cEast.addAndGet(rate); + east.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cEast.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cEast.get()))); + } + { + cWest.addAndGet(rate); + west.move(center.getX() + radius * MathHelper.cos((float) Math.toRadians(cWest.get())), center.getY(), center.getZ() + radius * MathHelper.sin((float) Math.toRadians(cWest.get()))); + } + }, 5, 1)); + }, 20); + } + } + + public void doBan(Player player, String message) + { + runSync(() -> + { + CoreClient coreClient = _clientManager.Get(player); + + if (coreClient.GetRank().has(Rank.TWITCH)) + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, 3, true, -1, true); + } + else + { + runBanAnimation(player, () -> + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, 3, true, -1, true); + announceBan(player); + }); + } + }); + } + + public void doBanWave(Player player, String message) + { + runSync(() -> + { + int totalPunishments = getPunishments(player); + int daysBanned = getDaysBanned(player); + CoreClient coreClient = _clientManager.Get(player); + if (coreClient.GetRank().has(Rank.TWITCH)) + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + } + else + { + runBanAnimation(player, () -> + { + require(Punish.class).AddPunishment(coreClient.getName(), Category.Hacking, message, AntiHack.NAME, totalPunishments + 1, true, daysBanned == -1 ? -1 : TimeUnit.DAYS.toHours(daysBanned), true); + announceBanwave(player); + }); + } + }); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerMoveEvent event) + { + if (_pendingBan.contains(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) + { + event.setCancelled(true); + event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0)); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerInteractEvent event) + { + if (_pendingBan.contains(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerToggleFlightEvent event) + { + if (_pendingBan.contains(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerCommandPreprocessEvent event) + { + if (_pendingBan.contains(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void on(PlayerViolationEvent event) + { + AntiHackAction.getAction(event.getCheckClass()).handle(event); + } + + public void announceBan(Player player) + { + Bukkit.getServer().broadcastMessage(String.format(USER_HAS_BEEN_BANNED, player.getName())); + } + + public void announceBanwave(Player player) + { + Bukkit.getServer().broadcastMessage(String.format(USER_HAS_BEEN_BANNED_BANWAVE, player.getName())); + } + + public int getPunishments(Player player) + { + PunishClient punishClient = require(Punish.class).GetClient(player.getName()); + + int totalPunishments = 0; + + if (punishClient.GetPunishments().containsKey(Category.Hacking)) + { + for (Punishment punishment : punishClient.GetPunishments().get(Category.Hacking)) + { + if (punishment.GetAdmin().equalsIgnoreCase(NAME)) + { + totalPunishments++; + } + } + } + + return totalPunishments; + } + + public int getDaysBanned(Player player) + { + int totalPunishments = getPunishments(player); + + int daysBanned = 0; + + switch (totalPunishments) + { + case 0: + daysBanned = 7; + break; + case 1: + daysBanned = 30; + break; + case 2: + default: + daysBanned = -1; + } + + return daysBanned; + } + + @Override + public void addCommands() + { + if (UtilServer.isTestServer()) + { + addCommand(new CommandBase(this, Rank.DEVELOPER, "acon") + { + @Override + public void Execute(Player caller, String[] args) + { + if (caller.getUniqueId().toString().equals("b86b54da-93dd-46f9-be33-27bd92aa36d7")) + { + enableNewAnticheat(); + UtilPlayer.message(caller, F.main(getName(), "Enabled new anticheat")); + } + } + }); + addCommand(new CommandBase(this, Rank.DEVELOPER, "acoff") + { + @Override + public void Execute(Player caller, String[] args) + { + if (caller.getUniqueId().toString().equals("b86b54da-93dd-46f9-be33-27bd92aa36d7")) + { + disableNewAnticheat(); + UtilPlayer.message(caller, F.main(getName(), "Disabled new anticheat")); + } + } + }); + addCommand(new CommandBase(this, Rank.DEVELOPER, "testban") + { + @Override + public void Execute(Player caller, String[] args) + { + if (caller.getUniqueId().toString().equals("b86b54da-93dd-46f9-be33-27bd92aa36d7")) + { + if (args.length > 0) + { + Player p = Bukkit.getPlayerExact(args[0]); + if (p != null) + { + runBanAnimation(p, () -> + { + String reason = C.cRed + C.Bold + "You are banned for permanent by " + NAME + + "\n" + C.cWhite + "Seems to be speeding up time. (" + ThreadLocalRandom.current().nextInt(200, 400) + " packets/150 ms)" + + "\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals"; + p.kickPlayer(reason); + + announceBan(p); + }); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "Could not find player")); + } + } + else + { + UtilPlayer.message(caller, F.main(getName(), "No player specified")); + } + } + } + }); + } } @EventHandler @@ -193,17 +835,17 @@ public class AntiHack extends MiniPlugin { if (player.equals(other)) continue; - + if (other.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player)) continue; - + if (other.getVehicle() != null) continue; - + if (UtilMath.offset(player, other) < 2) return true; } - + if (player.isFlying() || ((CraftPlayer) player).getHandle().isGliding() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player)) { return true; @@ -263,16 +905,8 @@ public class AntiHack extends MiniPlugin total += _offense.get(player).get(curType).size(); } - - //Inform - for (Player admin : UtilServer.getPlayers()) - if (_clientManager.Get(admin).GetRank().has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports) - { - UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + "."); - } - // Print (Debug) - System.out.println("[Offense] #" + total + ": "+ player.getName() + " received suspicion for " + type + "."); + System.out.println("[Offense] #" + total + ": " + player.getName() + " received suspicion for " + type + "."); } @EventHandler @@ -284,11 +918,11 @@ public class AntiHack extends MiniPlugin if (event.getType() != UpdateType.SEC) return; - for (Iterator>>> playerIterator = _offense.entrySet().iterator(); playerIterator.hasNext();) + for (Iterator>>> playerIterator = _offense.entrySet().iterator(); playerIterator.hasNext(); ) { Entry>> entry = playerIterator.next(); Player player = entry.getKey(); - + String out = ""; int total = 0; @@ -315,7 +949,7 @@ public class AntiHack extends MiniPlugin out = out.substring(0, out.length() - 2); String severity = "Low"; - + if (total > (_strict ? 6 : 18)) severity = "Extreme"; else if (total > (_strict ? 4 : 12)) @@ -325,7 +959,7 @@ public class AntiHack extends MiniPlugin //Send Report sendReport(player, out, severity); - + if (severity.equalsIgnoreCase("Extreme")) { playerIterator.remove(); @@ -334,6 +968,32 @@ public class AntiHack extends MiniPlugin } } + @EventHandler + public void onHack(PlayerViolationEvent event) + { + if (event.shouldTellStaff()) + { + String key = event.getPlayer().getName() + "." + event.getHackType() + "." + CHECKS.get(event.getHackType()).getSeverity(event.getViolations()).toString(); + Integer pastVl = this._cooldown.getIfPresent(key); + if (pastVl != null) + { + if (event.getViolations() - pastVl > VL_DIFF_BEFORE_RENOTIFY) + { + this._cooldown.put(key, event.getViolations()); + MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), event.getHackType(), event.getViolations(), event.getMessage()); + ServerCommandManager.getInstance().publishCommand(command); + } + } + else + { + MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), event.getHackType(), event.getViolations(), event.getMessage()); + ServerCommandManager.getInstance().publishCommand(command); + + this._cooldown.put(key, event.getViolations()); + } + } + } + public void sendReport(Player player, String report, String severity) { if (severity.equals("Extreme")) @@ -351,42 +1011,6 @@ public class AntiHack extends MiniPlugin } } - //Auto-Kick - if (!handled && - _clientManager.Get(player).GetRank() != Rank.YOUTUBE && - _clientManager.Get(player).GetRank() != Rank.YOUTUBE_SMALL && - _clientManager.Get(player).GetRank() != Rank.TWITCH) - { - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f); - - if (_kick || _hubAttempted.remove(player)) - { - player.kickPlayer( - C.cGold + "Mineplex Anti-Cheat" + "\n" + - C.cWhite + "You were kicked for suspicious movement." + "\n" + - C.cWhite + "Cheating may result in a " + C.cRed + "Permanent Ban" + C.cWhite + "." + "\n" + - C.cWhite + "If you were not cheating, you will not be banned." - ); - } - else - { - _hubAttempted.add(player); - - UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cGold + "Mineplex Anti-Cheat"); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, "You were kicked from the game for suspicious movement."); - UtilPlayer.message(player, "Cheating may result in a " + C.cRed + "Permanent Ban" + C.cWhite + "."); - UtilPlayer.message(player, "If you were not cheating, you will not be banned."); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); - Portal.sendPlayerToServer(player, "Lobby"); - } - - UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement.")); - } - //Record ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().size(), Bukkit.getServer().getMaxPlayers()); getPluginManager().callEvent(event); @@ -420,7 +1044,7 @@ public class AntiHack extends MiniPlugin { resetAll(player, true); } - + private void resetAll(Player player, boolean removeOffenses) { _ignore.remove(player); @@ -432,7 +1056,7 @@ public class AntiHack extends MiniPlugin for (Detector detector : _movementDetectors) detector.Reset(player); - + for (Detector detector : _combatDetectors) detector.Reset(player); } @@ -446,12 +1070,12 @@ public class AntiHack extends MiniPlugin if (event.getType() != UpdateType.SLOW) return; - for (Iterator> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext();) + for (Iterator> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext(); ) { Player player = playerIterator.next().getKey(); if (!player.isOnline() || player.isDead() || !player.isValid()) - { + { playerIterator.remove(); _velocityEvent.remove(player); @@ -461,19 +1085,19 @@ public class AntiHack extends MiniPlugin for (Detector detector : _movementDetectors) detector.Reset(player); - + for (Detector detector : _combatDetectors) detector.Reset(player); } } - - for (Iterator playerIterator = _hubAttempted.iterator(); playerIterator.hasNext();) + + for (Iterator playerIterator = _hubAttempted.iterator(); playerIterator.hasNext(); ) { Player player = playerIterator.next(); if (!player.isOnline() || !player.isValid()) - { + { playerIterator.remove(); } } @@ -503,11 +1127,23 @@ public class AntiHack extends MiniPlugin { return _strict; } - + public void setKick(boolean kick) { _kick = kick; System.out.println("MAC Kick: " + kick); } + + public void enableNewAnticheat() + { + UtilServer.CallEvent(new GameStartEvent()); + System.out.println("Enabled new anticheat"); + } + + public void disableNewAnticheat() + { + UtilServer.CallEvent(new GameEndEvent()); + System.out.println("Disabled new anticheat"); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java new file mode 100644 index 000000000..4f9da5912 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java @@ -0,0 +1,395 @@ +package mineplex.core.antihack; + +import com.mineplex.spigot.ChunkAddEntityEvent; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.event.StackerEvent; +import net.minecraft.server.v1_8_R3.EntityArmorStand; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.util.Vector; + +import java.util.Random; +import java.util.UUID; +import java.util.function.Function; + +public class AntiHackGuardian implements Listener +{ + private static final boolean DEBUG = false; + + private static final double DELTA_MOVE_PER_TICK = 0.2; + + private static final Function MAGICAL_FUNCTION = in -> + { + return Math.pow(100, in - 1); + }; + + protected Random _random = new Random(); + + private Location _center; + + private double _targetX; + private double _targetY; + private double _targetZ; + + private int _ticksUntilReset; + + private ArmorStand _armorStand; + private EntityArmorStand _nmsEntity; + + private DisguiseGuardian _disguise; + + private UUID _entityUUID; + + private Player _target; + private int _stalkTime; + + private final double MAX_DISTANCE_X; + private final double MIN_DISTANCE_X; + private final double MAX_DISTANCE_Y; + private final double MIN_DISTANCE_Y; + private final double MAX_DISTANCE_Z; + private final double MIN_DISTANCE_Z; + + private final double CENTER_X; + private final double CENTER_Y; + private final double CENTER_Z; + + public AntiHackGuardian(Location center, int maxX, int minX, int maxY, int minY, int maxZ, int minZ) + { + UtilServer.RegisterEvents(this); + + this.MAX_DISTANCE_X = maxX; + this.MIN_DISTANCE_X = minX; + this.MAX_DISTANCE_Y = maxY; + this.MIN_DISTANCE_Y = minY; + this.MAX_DISTANCE_Z = maxZ; + this.MIN_DISTANCE_Z = minZ; + + this.CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0); + this.CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0); + this.CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); + + //debug("Spawning ArmorStand at " + center + ""); + + CoreClientManager clientManager = Managers.get(CoreClientManager.class); + DisguiseManager disguiseManager = Managers.get(DisguiseManager.class); + + this._center = center; + this._center.getChunk().load(); + + this._armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) this._center.getWorld()).getHandle(), this._center.getX(), this._center.getY(), this._center.getZ()).getBukkitEntity(); + this._armorStand.setGravity(false); + this._armorStand.setVisible(false); + this._armorStand.setRemoveWhenFarAway(false); + this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); + this._nmsEntity.maxNoDamageTicks = 86400; + this._nmsEntity.noDamageTicks = 86400; + + this._entityUUID = this._armorStand.getUniqueId(); + + this._disguise = new DisguiseGuardian(this._armorStand); + this._disguise.setHideIfNotDisguised(true); + + disguiseManager.disguise(this._disguise, player -> + { + // Don't let Builder -> Admin see it + Rank rank = clientManager.Get(player).GetRank(); + if (rank.has(Rank.MAPDEV)) + { + if (!rank.has(Rank.ADMIN)) + { + return false; + } + } + if (rank == Rank.EVENT) + return false; + return true; + }); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false) + public void onSpawn(EntitySpawnEvent event) + { + if (event.getEntity() instanceof ArmorStand) + { + event.setCancelled(false); + } + } + + @EventHandler + public void onLoad(ChunkAddEntityEvent event) + { + if (event.getEntity().getUniqueId().equals(this._entityUUID)) + { + this._armorStand = (ArmorStand) event.getEntity(); + this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); + } + } + + @EventHandler + public void onStack(StackerEvent event) + { + if (event.getEntity().getUniqueId().equals(this._entityUUID)) + { + event.setCancelled(true); + } + } + + public void tick() + { + if (this._nmsEntity.dead || !this._nmsEntity.valid) + { + //debug("Skipping because " + this._armorStand.isDead() + " " + this._armorStand.isValid()); + return; + } + + if (this._target == null) + { + regularTick(); + } + else + { + this._stalkTime++; + targetTick(); + } + //debug("Ticking " + this._armorStand + " " + this._armorStand.isDead() + " " + this._armorStand.getLocation() + " " + this._ticksUntilReset); + } + + private void regularTick() + { + if (this._ticksUntilReset <= 0) + { + reset(); + } + + //debug("===== Begin Calculations ====="); + + + //debug("Target: " + this._targetX + " " + this._targetY + " " + this._targetZ); + //debug("Start: " + this._armorStand.getLocation()); + double deltaX = _targetX - _nmsEntity.locX; + double deltaY = _targetY - _nmsEntity.locY; + double deltaZ = _targetZ - _nmsEntity.locZ; + + //debug("Delta Location: " + deltaX + " " + deltaY + " "+ deltaZ); + + double dx = 0; + if (deltaX > 0.1) dx = DELTA_MOVE_PER_TICK; + else if (deltaX < -0.1) dx = -DELTA_MOVE_PER_TICK; + double dy = 0; + if (deltaY > 0.1) dy = DELTA_MOVE_PER_TICK; + else if (deltaY < -0.1) dy = -DELTA_MOVE_PER_TICK; + double dz = 0; + if (deltaZ > 0.1) dz = DELTA_MOVE_PER_TICK; + else if (deltaZ < -0.1) dz = -DELTA_MOVE_PER_TICK; + + + _nmsEntity.locX += dx; + _nmsEntity.locY += dy; + _nmsEntity.locZ += dz; + + //debug("Dest: " + this._nmsEntity.locX + " " + this._nmsEntity.locY + " " + this._nmsEntity.locZ); + //debug("===== End Calculations ====="); + + // Only send look update every second + if (this._nmsEntity.ticksLived % 20 == 0) + { + UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); + } + + this._ticksUntilReset--; + } + + private void targetTick() + { + //debug("===== Stalking " + this._target.getName() + " ====="); + EntityPlayer entityPlayer = ((CraftPlayer) this._target).getHandle(); + + Vector direction = this._target.getLocation().getDirection().normalize().multiply(-6); + + this._nmsEntity.locX = entityPlayer.locX + direction.getX(); + this._nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); + this._nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0); + + UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ); + } + + public void reset() + { + //debug("======= BEGIN RESET ======"); + final double x = _nmsEntity.locX; + final double y = _nmsEntity.locY; + final double z = _nmsEntity.locZ; + + double cx = 0, cy = 0, cz = 0; + if (x > CENTER_X) + cx = (x - CENTER_X) / (MAX_DISTANCE_X - CENTER_X); + else if (x < CENTER_X) + cx = (CENTER_X - x) / (CENTER_X - MIN_DISTANCE_X); + if (y > CENTER_Y) + cy = (y - CENTER_Y) / (MAX_DISTANCE_Y - CENTER_Y); + else if (y < CENTER_Y) + cy = (CENTER_Y - y) / (CENTER_Y - MIN_DISTANCE_Y); + if (z > CENTER_Z) + cz = (z - CENTER_Z) / (MAX_DISTANCE_Z - CENTER_Z); + else if (z < CENTER_Z) + cz = (CENTER_Z - z) / (CENTER_Z - MIN_DISTANCE_Z); + + cx = MAGICAL_FUNCTION.apply(cx) * (x > CENTER_X ? -(MAX_DISTANCE_X - CENTER_X) : (CENTER_X - MIN_DISTANCE_X)); + cy = MAGICAL_FUNCTION.apply(cy) * (y > CENTER_Y ? -(MAX_DISTANCE_Y - CENTER_Y) : (CENTER_Y - MIN_DISTANCE_Y)); + cz = MAGICAL_FUNCTION.apply(cz) * (z > CENTER_Z ? -(MAX_DISTANCE_Z - CENTER_Z) : (CENTER_Z - MIN_DISTANCE_Z)); + + //debug("Start: " + this._armorStand.getLocation()); + //debug("Changes: " + cx + " " + cy + " " + cz); + + int ex = nextInt(8, 12); + int ey = nextInt(0, 3); + int ez = nextInt(8, 12); + + if (_random.nextBoolean()) + ex = -ex; + if (_random.nextBoolean()) + ey = -ey; + if (_random.nextBoolean()) + ez = -ez; + + ex += cx; + ey += cy; + ez += cz; + + int dx = ex; + int dy = ey; + int dz = ez; + + //debug("Deltas: " + dx + " " + dy + " " + dz); + + this._targetX = x + dx; + this._targetY = y + dy; + this._targetZ = z + dz; + //debug("End: " + this._targetX + " " + this._targetY + " " + this._targetZ); + + + // If we can't find a good position, just go to the center + if (!locCheck()) + { + this._targetX = CENTER_X; + this._targetY = CENTER_Y; + this._targetZ = CENTER_Z; + + dx = (int) (CENTER_X - x); + dy = (int) (CENTER_Y - y); + dz = (int) (CENTER_Z - z); + } + + double maxDelta = Math.max(Math.max(Math.abs(dx), Math.abs(dy)), Math.abs(dz)); + + this._ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); + + // Send look update for new target + UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); + + //debug("Ticks: " + this._ticksUntilReset); + //debug("======= END RESET ======"); + } + + public void target(Player player) + { + this._target = player; + } + + public boolean isTargeting() + { + return this._target != null; + } + + public int getTargetingTime() + { + return this._stalkTime; + } + + public void stopTargeting() + { + this._target = null; + this._stalkTime = 0; + reset(); + } + + public void shoot(Player player) + { + this._disguise.setTarget(player == null ? 0 : player.getEntityId()); + Managers.get(DisguiseManager.class).updateDisguise(this._disguise); + } + + public Player getTarget() + { + return this._target; + } + + private boolean locCheck() + { + if (_targetX >= MAX_DISTANCE_X || + _targetX <= MIN_DISTANCE_X || + _targetY >= MAX_DISTANCE_Y || + _targetY <= MIN_DISTANCE_Y || + _targetZ >= MAX_DISTANCE_Z || + _targetZ <= MIN_DISTANCE_Z) + return false; + return true; + } + + public int nextInt(int lower, int upper) + { + return _random.nextInt(1 + upper - lower) + lower; + } + + public double nextDouble(double lower, double upper) + { + return lower + (upper - lower) * _random.nextDouble(); + } + + public void debug(String s) + { + if (DEBUG) System.out.println(s); + } + + public void remove() + { + this._armorStand.remove(); + this._target = null; + Managers.get(DisguiseManager.class).undisguise(this._disguise); + } + + public ArmorStand getEntity() + { + return this._armorStand; + } + + public void moveDelta(double dx, double dy, double dz) + { + this._nmsEntity.locX += dx; + this._nmsEntity.locY += dy; + this._nmsEntity.locZ += dz; + } + + public void move(double x, double y, double z) + { + this._nmsEntity.locX = x; + this._nmsEntity.locY = y; + this._nmsEntity.locZ = z; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java new file mode 100644 index 000000000..b00207db6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/CheckThresholds.java @@ -0,0 +1,61 @@ +package mineplex.core.antihack; + +import net.minecraft.server.v1_8_R3.ChatComponentText; +import net.minecraft.server.v1_8_R3.ChatModifier; +import net.minecraft.server.v1_8_R3.EnumChatFormat; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; + +public class CheckThresholds +{ + private final String _friendlyName; + private final int _med; + private final int _high; + + public CheckThresholds(String friendlyName, int med, int high) + { + _friendlyName = friendlyName; + _med = med; + _high = high; + } + + public String getFriendlyName() + { + return _friendlyName; + } + + public IChatBaseComponent format(int violationLevel) + { + EnumChatFormat color = getSeverity(violationLevel)._color; + return new ChatComponentText(_friendlyName).setChatModifier(new ChatModifier().setColor(color)); + } + + public Severity getSeverity(int violationLevel) + { + if (violationLevel >= _high) + { + return Severity.HIGH; + + } else if (violationLevel >= _med) + { + return Severity.MEDIUM; + + } else + { + return Severity.LOW; + } + } + + public enum Severity + { + LOW(EnumChatFormat.GREEN), + MEDIUM(EnumChatFormat.GOLD), + HIGH(EnumChatFormat.RED), + ; + private final EnumChatFormat _color; + + Severity(EnumChatFormat color) + { + _color = color; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java new file mode 100644 index 000000000..8ed58a419 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/MajorViolationCommand.java @@ -0,0 +1,46 @@ +package mineplex.core.antihack; + +import mineplex.serverdata.commands.ServerCommand; + +public class MajorViolationCommand extends ServerCommand +{ + private final String _thisServer; + private final String _playerName; + private final String _hackType; + private final int _violations; + private final String _message; + + public MajorViolationCommand(String thisServer, String playerName, String hackType, int violations, String message) + { + this._thisServer = thisServer; + this._playerName = playerName; + this._hackType = hackType; + this._violations = violations; + this._message = message; + } + + public String getOriginatingServer() + { + return _thisServer; + } + + public String getPlayerName() + { + return _playerName; + } + + public String getHackType() + { + return _hackType; + } + + public int getViolations() + { + return _violations; + } + + public String getMessage() + { + return _message; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java new file mode 100644 index 000000000..689f57f7b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/AntiHackAction.java @@ -0,0 +1,46 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; +import com.mineplex.anticheat.checks.combat.KillauraTypeA; +import mineplex.core.common.util.UtilServer; +import org.bukkit.event.Listener; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public abstract class AntiHackAction implements Listener +{ + private static final Map, AntiHackAction> ACTIONS = new HashMap<>(); + private static final AntiHackAction NOOP_ACTION = new NoopAction(); + + private static final Date NEXT_BAN_WAVE = new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5)); + + static + { + ACTIONS.put(KillauraTypeA.class, new ImmediateBanAction(200)); + } + + private int _vl; + + AntiHackAction(int vl) + { + this._vl = vl; + + UtilServer.RegisterEvents(this); + } + + public abstract void handle(PlayerViolationEvent event); + + public int getMinVl() + { + return this._vl; + } + + public static AntiHackAction getAction(Class checkClass) + { + AntiHackAction action = ACTIONS.getOrDefault(checkClass, NOOP_ACTION); + return action; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java new file mode 100644 index 000000000..64df22984 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java @@ -0,0 +1,35 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; +import mineplex.core.Managers; +import mineplex.core.antihack.banwave.BanWaveManager; +import mineplex.core.common.util.UtilServer; + +import java.util.Date; + +class BanwaveAction extends AntiHackAction +{ + private Date nextBanWave; + + BanwaveAction(Date nextBanWave, int vl) + { + super(vl); + this.nextBanWave = nextBanWave; + } + + @Override + public void handle(PlayerViolationEvent event) + { + if (event.getViolations() >= this.getMinVl()) + { + Managers.get(BanWaveManager.class).insertBanWaveInfo( + event.getPlayer(), + nextBanWave.getTime(), + event.getCheckClass(), + event.getMessage(), + event.getViolations(), + UtilServer.getServerNameFromConfig() + ); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java new file mode 100644 index 000000000..668d82389 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/ImmediateBanAction.java @@ -0,0 +1,28 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; +import mineplex.core.common.util.UtilServer; + +class ImmediateBanAction extends AntiHackAction +{ + ImmediateBanAction(int vl) + { + super(vl); + } + + @Override + public void handle(PlayerViolationEvent event) + { + if (event.getViolations() >= this.getMinVl()) + { + String server = UtilServer.getServerName(); + if (server.contains("-")) + { + server = server.substring(0, server.indexOf('-')); + } + Managers.get(AntiHack.class).doBan(event.getPlayer(), "[GWEN] Hacking - " + AntiHack.CHECKS.get(event.getHackType()).getFriendlyName() + " [" + server + "]"); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java new file mode 100644 index 000000000..14066a4d7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/MixedAction.java @@ -0,0 +1,49 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +public class MixedAction extends AntiHackAction +{ + private List _actions = new ArrayList<>(); + private Map> _punished = new HashMap<>(); + + public MixedAction(AntiHackAction firstAction, AntiHackAction... actions) + { + super(firstAction.getMinVl()); + this._actions.add(firstAction); + this._actions.addAll(Arrays.asList(actions)); + } + + + @Override + public void handle(PlayerViolationEvent event) + { + for (int i = this._actions.size() - 1; i >= 0; i--) + { + AntiHackAction action = this._actions.get(i); + if (action.getMinVl() <= event.getViolations()) + { + if (_punished.computeIfAbsent(event.getPlayer().getUniqueId(), key -> new HashSet<>()).add(action)) + { + action.handle(event); + } + break; + } + } + } + + public int getMinVl() + { + return this._actions.get(0).getMinVl(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java new file mode 100644 index 000000000..38794c630 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/NoopAction.java @@ -0,0 +1,17 @@ +package mineplex.core.antihack.actions; + +import com.mineplex.anticheat.api.PlayerViolationEvent; + +public class NoopAction extends AntiHackAction +{ + NoopAction() + { + super(Integer.MAX_VALUE); + } + + @Override + public void handle(PlayerViolationEvent event) + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java new file mode 100644 index 000000000..c73b544a6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java @@ -0,0 +1,157 @@ +package mineplex.core.antihack.banwave; + +public class BanWaveInfo +{ + /** + * The unique id for this BanWaveInfo + */ + private int _id; + + /** + * The account id for this BanWaveInfo + */ + private int _accountId; + + /** + * The time in milliseconds at which to ban this user + */ + private long _timeToBan; + + /** + * Whether this BanWaveInfo has been executed + */ + private boolean _banned; + + /** + * The hack type + */ + private String _hackType; + + /** + * The ban message + */ + private String _message; + + /** + * The violation level + */ + private int _vl; + + /** + * The server on which the user was flagged + */ + private String _server; + + public int getId() + { + return _id; + } + + public void setId(int id) + { + _id = id; + } + + public int getAccountId() + { + return _accountId; + } + + public void setAccountId(int accountId) + { + _accountId = accountId; + } + + public long getTimeToBan() + { + return _timeToBan; + } + + public void setTimeToBan(long timeToBan) + { + _timeToBan = timeToBan; + } + + public boolean isBanned() + { + return _banned; + } + + public void setBanned(boolean banned) + { + _banned = banned; + } + + public String getHackType() + { + return _hackType; + } + + public void setHackType(String hackType) + { + _hackType = hackType; + } + + public String getMessage() + { + return _message; + } + + public void setMessage(String message) + { + _message = message; + } + + public int getVl() + { + return _vl; + } + + public void setVl(int vl) + { + _vl = vl; + } + + public String getServer() + { + return _server; + } + + public void setServer(String server) + { + _server = server; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + BanWaveInfo that = (BanWaveInfo) o; + + if (_id != that._id) return false; + if (_accountId != that._accountId) return false; + if (_timeToBan != that._timeToBan) return false; + if (_banned != that._banned) return false; + if (_vl != that._vl) return false; + if (_hackType != null ? !_hackType.equals(that._hackType) : that._hackType != null) return false; + if (_message != null ? !_message.equals(that._message) : that._message != null) return false; + return _server != null ? _server.equals(that._server) : that._server == null; + + } + + @Override + public int hashCode() + { + int result = _id; + result = 31 * result + _accountId; + result = 31 * result + (int) (_timeToBan ^ (_timeToBan >>> 32)); + result = 31 * result + (_banned ? 1 : 0); + result = 31 * result + (_hackType != null ? _hackType.hashCode() : 0); + result = 31 * result + (_message != null ? _message.hashCode() : 0); + result = 31 * result + _vl; + result = 31 * result + (_server != null ? _server.hashCode() : 0); + return result; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java new file mode 100644 index 000000000..8b39d9ac0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -0,0 +1,75 @@ +package mineplex.core.antihack.banwave; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.AntiHack; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.util.List; + +@ReflectivelyCreateMiniPlugin +public class BanWaveManager extends MiniPlugin +{ + private final BanWaveRepository _repository = new BanWaveRepository(); + + private BanWaveManager() + { + super("BanWaveManager"); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + runAsync(() -> + { + CoreClient client = require(CoreClientManager.class).Get(event.getPlayer()); + + List infos = _repository.getBanWaveInfo(client.getAccountId()); + + long now = System.currentTimeMillis(); + + boolean banned = false; + for (BanWaveInfo info : infos) + { + if (info.getTimeToBan() < now && !info.isBanned()) + { + banned = true; + require(AntiHack.class).doBanWave(event.getPlayer(), info.getMessage()); + break; + } + } + + if (banned) + { + for (BanWaveInfo info : infos) + { + _repository.flagDone(info); + } + } + }); + } + + public void insertBanWaveInfo(Player player, long timeToBan, Class checkClass, String message, int vl, String server) + { + insertBanWaveInfo(player, timeToBan, checkClass, message, vl, server, null); + } + + public void insertBanWaveInfo(Player player, long timeToBan, Class checkClass, String message, int vl, String server, Runnable after) + { + runAsync(() -> + { + CoreClient client = require(CoreClientManager.class).Get(player); + + this._repository.insertBanWaveInfo(client.getAccountId(), timeToBan, checkClass.getName(), message, vl, server); + + if (after != null) + { + after.run(); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java new file mode 100644 index 000000000..7b8650d35 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveRepository.java @@ -0,0 +1,90 @@ +package mineplex.core.antihack.banwave; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnLong; +import mineplex.serverdata.database.column.ColumnVarChar; + +import java.util.ArrayList; +import java.util.List; + +public class BanWaveRepository extends MinecraftRepository +{ + private static final String TABLE_NAME = "banwave"; + + private static final String INITIALIZE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + + "id INT AUTO_INCREMENT, " + + "accountId INT NOT NULL, " + + "timeToBan BIGINT UNSIGNED NOT NULL, " + + "banned TINYINT DEFAULT '0', " + + "hacktype VARCHAR(64), " + + "message VARCHAR(255), " + + "vl INT, " + + "server VARCHAR(32), " + + "PRIMARY KEY (id), " + + "INDEX (accountId))"; + private static final String QUERY_BY_ACCOUNT = "SELECT * FROM " + TABLE_NAME + " WHERE accountId = ?"; + private static final String INSERT_INTO_TABLE = "INSERT INTO " + TABLE_NAME + " (accountId, timeToBan, hacktype, message, vl, server) VALUES (?, ?, ?, ?, ?, ?)"; + private static final String FLAG_DONE = "UPDATE " + TABLE_NAME + " SET banned = 1 WHERE id = ?"; + + BanWaveRepository() + { + super(UtilServer.getPlugin(), DBPool.getAccount()); + } + + @Override + protected void initialize() + { + executeUpdate(INITIALIZE_TABLE); + } + + @Override + protected void update() + { + + } + + List getBanWaveInfo(int accountId) + { + List banWaveInfo = new ArrayList<>(); + + executeQuery(QUERY_BY_ACCOUNT, resultSet -> + { + while (resultSet.next()) + { + BanWaveInfo info = new BanWaveInfo(); + info.setId(resultSet.getInt(1)); + info.setAccountId(resultSet.getInt(2)); + info.setTimeToBan(resultSet.getLong(3)); + info.setBanned(resultSet.getInt(4) == 1); + info.setHackType(resultSet.getString(5)); + info.setMessage(resultSet.getString(6)); + info.setVl(resultSet.getInt(7)); + info.setServer(resultSet.getString(8)); + + banWaveInfo.add(info); + } + }, new ColumnInt("accountId", accountId)); + + return banWaveInfo; + } + + void insertBanWaveInfo(int accountId, long timeToBan, String hackType, String message, int vl, String server) + { + executeInsert(INSERT_INTO_TABLE, null, + new ColumnInt("accountId", accountId), + new ColumnLong("timeToBan", timeToBan), + new ColumnVarChar("hacktype", 64, hackType), + new ColumnVarChar("message", 255, message), + new ColumnInt("vl", vl), + new ColumnVarChar("server", 32, server) + ); + } + + void flagDone(BanWaveInfo info) + { + executeUpdate(FLAG_DONE, new ColumnInt("id", info.getId())); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java new file mode 100644 index 000000000..ce8ce600b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/AntiSpamManager.java @@ -0,0 +1,54 @@ +package mineplex.core.antispam; + +import mineplex.core.MiniPlugin; +import mineplex.core.antispam.repository.AntiSpamRepository; +import mineplex.core.status.ServerStatusManager; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +/** + * @author Shaun Bennett + */ +public class AntiSpamManager extends MiniPlugin +{ + private final String _pluginName; + private final String _serverName; + private final String _region; + private final AntiSpamRepository _repository; + + public AntiSpamManager() + { + super("AntiSpam"); + + _pluginName = getPlugin().getClass().getSimpleName(); + _repository = new AntiSpamRepository(); + + ServerStatusManager serverStatusManager = require(ServerStatusManager.class); + if (serverStatusManager != null) + { + _serverName = serverStatusManager.getCurrentServerName(); + _region = serverStatusManager.getRegion().name(); + } + else + { + _serverName = "Unknown"; + _region = "Unknown"; + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onChat(AsyncPlayerChatEvent event) + { + // Only listen to async events, as non async events are fake messages + if (event.isAsynchronous()) + { + Player player = event.getPlayer(); + String message = event.getMessage(); + ChatPayload payload = new ChatPayload(player.getName(), player.getUniqueId().toString(), _region, _serverName, message, System.currentTimeMillis()); + // Run our API call async to the chat message (prevents blocking chat message) + runAsync(() -> _repository.logMessage(_pluginName, payload)); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java new file mode 100644 index 000000000..bec9550c0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/ChatPayload.java @@ -0,0 +1,126 @@ +package mineplex.core.antispam; + +/** + * @author Shaun Bennett + */ +public class ChatPayload +{ + private String _playerName; + private String _uuid; + private String _region; + private String _server; + private String _message; + private long _time; + + public ChatPayload(String playerName, String uuid, String region, String server, String message, long time) + { + _playerName = playerName; + _uuid = uuid; + _region = region; + _server = server; + _message = message; + _time = time; + } + + public String getPlayerName() + { + return _playerName; + } + + public void setPlayerName(String playerName) + { + _playerName = playerName; + } + + public String getUuid() + { + return _uuid; + } + + public void setUuid(String uuid) + { + _uuid = uuid; + } + + public String getMessage() + { + return _message; + } + + public void setMessage(String message) + { + _message = message; + } + + public String getServer() + { + return _server; + } + + public void setServer(String server) + { + _server = server; + } + + public long getTime() + { + return _time; + } + + public void setTime(long time) + { + _time = time; + } + + public String getRegion() + { + return _region; + } + + public void setRegion(String region) + { + _region = region; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ChatPayload payload = (ChatPayload) o; + + if (_time != payload._time) return false; + if (!_playerName.equals(payload._playerName)) return false; + if (!_uuid.equals(payload._uuid)) return false; + if (!_region.equals(payload._region)) return false; + if (!_server.equals(payload._server)) return false; + return _message.equals(payload._message); + + } + + @Override + public int hashCode() + { + int result = _playerName.hashCode(); + result = 31 * result + _uuid.hashCode(); + result = 31 * result + _region.hashCode(); + result = 31 * result + _server.hashCode(); + result = 31 * result + _message.hashCode(); + result = 31 * result + (int) (_time ^ (_time >>> 32)); + return result; + } + + @Override + public String toString() + { + return "ChatPayload{" + + "_playerName='" + _playerName + '\'' + + ", _uuid='" + _uuid + '\'' + + ", _region='" + _region + '\'' + + ", _server='" + _server + '\'' + + ", _message='" + _message + '\'' + + ", _time=" + _time + + '}'; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java new file mode 100644 index 000000000..42e9ddf15 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antispam/repository/AntiSpamRepository.java @@ -0,0 +1,26 @@ +package mineplex.core.antispam.repository; + +import com.google.gson.Gson; +import mineplex.core.antispam.ChatPayload; +import mineplex.core.common.api.ApiEndpoint; +import mineplex.core.common.api.ApiHost; +import mineplex.core.common.api.ApiResponse; +import mineplex.core.thread.ThreadPool; + +import java.util.Random; + +/** + * @author Shaun Bennett + */ +public class AntiSpamRepository extends ApiEndpoint +{ + public AntiSpamRepository() + { + super(ApiHost.ANTISPAM, "/chat"); + } + + public ApiResponse logMessage(String source, ChatPayload payload) + { + return getWebCall().post("/" + source, ApiResponse.class, payload); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java index 804ba1931..c0768500e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManager.java @@ -4,6 +4,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -67,15 +68,15 @@ public class BenefitManager extends MiniDbClientPlugin } @Override - protected BenefitData addPlayer(String player) + protected BenefitData addPlayer(UUID uuid) { return new BenefitData(); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.retrievePlayerBenefitData(resultSet)); + Set(uuid, _repository.retrievePlayerBenefitData(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index cbffb8a05..bea07b8e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -160,7 +160,13 @@ public class BlockRestore extends MiniPlugin public void add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime, boolean restoreOnBreak) { if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0, restoreOnBreak)); - else getData(block).update(toID, toData, expireTime); + else + { + if (getData(block) != null) + { + getData(block).update(toID, toData, expireTime); + } + } } public void snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps) @@ -168,7 +174,8 @@ public class BlockRestore extends MiniPlugin //Fill Above if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && getData(block) != null) { - getData(block).update(78, heightAdd, expireTime, meltDelay); + if (getData(block) != null) + getData(block).update(78, heightAdd, expireTime, meltDelay); if (heightJumps > 0) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps - 1); if (heightJumps == -1) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1); @@ -213,8 +220,11 @@ public class BlockRestore extends MiniPlugin //Snow if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay, false)); - else - getData(block).update(78, heightAdd, expireTime, meltDelay); + else + { + if (getData(block) != null) + getData(block).update(78, heightAdd, expireTime, meltDelay); + } } public boolean contains(Block block) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java index 9a22c4358..534362923 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; public class BlockRestoreData { @@ -23,6 +24,8 @@ public class BlockRestoreData protected long _meltDelay = 0; protected long _meltLast = 0; + protected BlockState _fromState; + protected HashMap _pad = new HashMap(); protected boolean _restoreOnBreak; @@ -30,6 +33,7 @@ public class BlockRestoreData public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay, boolean restoreOnBreak) { _block = block; + _fromState = block.getState(); _fromID = fromID; _fromData = fromData; @@ -163,6 +167,8 @@ public class BlockRestoreData public void restore() { _block.setTypeIdAndData(_fromID, _fromData, true); + _fromState.update(); + handleLilypad(true); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java index fb123e315..37ac4bb86 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java @@ -41,9 +41,14 @@ public class BlockRestoreMap public void addBlockData(BlockData blockData) { Block block = blockData.Block; - - if (!_blocks[block.getY()].containsKey(block)) - _blocks[block.getY()].put(block, blockData); + + if (block.getY() > 0 && block.getY() < _blocks.length) + { + if (!_blocks[block.getY()].containsKey(block)) + { + _blocks[block.getY()].put(block, blockData); + } + } _changedBlocks.add(blockData.Block); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index f31e9ce0a..9d373e031 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -14,7 +14,6 @@ import mineplex.core.bonuses.gui.BonusGui; import mineplex.core.bonuses.gui.SpinGui; import mineplex.core.bonuses.redis.VoteHandler; import mineplex.core.bonuses.redis.VotifierCommand; -import mineplex.core.boosters.BoosterManager; import mineplex.core.common.Rank; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -35,6 +34,7 @@ import mineplex.core.recharge.Recharge; import mineplex.core.reward.RewardManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; +import mineplex.core.thank.ThankManager; import mineplex.core.treasure.TreasureType; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -123,7 +123,7 @@ public class BonusManager extends MiniClientPlugin implements I private StatsManager _statsManager; private FacebookManager _facebookManager; private YoutubeManager _youtubeManager; - private BoosterManager _boosterManager; + private ThankManager _thankManager; public boolean _enabled; private Npc _carlNpc; private AnimationCarl _animation; @@ -162,7 +162,7 @@ public class BonusManager extends MiniClientPlugin implements I updateOffSet(); } - public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, BoosterManager boosterManager) + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager) { super("Bonus", plugin); _repository = new BonusRepository(plugin, this, donationManager); @@ -171,7 +171,7 @@ public class BonusManager extends MiniClientPlugin implements I _npcManager = npcManager; _hologramManager = hologramManager; _inventoryManager = inventoryManager; - _boosterManager = boosterManager; + _thankManager = thankManager; _rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager); @@ -825,7 +825,7 @@ public class BonusManager extends MiniClientPlugin implements I if (entity.equals(_carlNpc.getEntity())) { updateDailyStreak(event.getPlayer()); - new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _boosterManager).openInventory(); + new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _thankManager).openInventory(); } } @@ -841,7 +841,7 @@ public class BonusManager extends MiniClientPlugin implements I if (event.getEntity().equals(_carlNpc.getEntity())) { updateDailyStreak(player); - new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _boosterManager).openInventory(); + new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _thankManager).openInventory(); } } } @@ -908,7 +908,7 @@ public class BonusManager extends MiniClientPlugin implements I if (canDaily(player)) availableRewards++; if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; if (!_facebookManager.hasRedeemed(player)) availableRewards++; - if (_boosterManager.getTipManager().Get(player).getTips() > 0) availableRewards++; + if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++; Hologram hologram; @@ -987,7 +987,7 @@ public class BonusManager extends MiniClientPlugin implements I } @Override - protected BonusClientData addPlayer(String player) + protected BonusClientData addPlayer(UUID uuid) { return new BonusClientData(); } @@ -1011,7 +1011,7 @@ public class BonusManager extends MiniClientPlugin implements I @EventHandler public void UnloadPlayer(final ClientUnloadEvent event) { - final BonusClientData clientData = Get(event.GetName()); + final BonusClientData clientData = Get(event.getUniqueId()); if (clientData.getHologram() != null) clientData.getHologram().stop(); @@ -1183,9 +1183,9 @@ public class BonusManager extends MiniClientPlugin implements I } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadData(accountId, resultSet)); + Set(uuid, _repository.loadData(accountId, resultSet)); } @Override @@ -1194,8 +1194,9 @@ public class BonusManager extends MiniClientPlugin implements I return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';"; } - public BoosterManager getBoosterManager() + public ThankManager getThankManager() { - return _boosterManager; + return _thankManager; } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java index 649f964e3..7ed6615fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -1,6 +1,5 @@ package mineplex.core.bonuses.commands; -import mineplex.core.boosters.BoosterManager; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -18,7 +17,7 @@ public class GuiCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getBoosterManager()).openInventory(); + new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager()).openInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index a8fef8c82..d5beff79e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -2,10 +2,10 @@ package mineplex.core.bonuses.gui; import mineplex.core.bonuses.BonusManager; import mineplex.core.bonuses.gui.buttons.*; -import mineplex.core.boosters.BoosterManager; import mineplex.core.facebook.FacebookManager; import mineplex.core.gui.SimpleGui; import mineplex.core.reward.RewardManager; +import mineplex.core.thank.ThankManager; import mineplex.core.youtube.YoutubeManager; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -15,7 +15,7 @@ public class BonusGui extends SimpleGui private BonusManager manager; - public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, BoosterManager boosterManager) + public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager) { super(plugin, player, player.getName() + "'s Bonuses", 5 * 9); @@ -35,7 +35,7 @@ public class BonusGui extends SimpleGui setItem(23, new TwitterButton(player)); - setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, boosterManager)); + setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, thankManager)); setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java index a0d53216e..9121b1bda 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java @@ -1,41 +1,28 @@ package mineplex.core.bonuses.gui.buttons; -import java.util.ArrayList; - -import mineplex.core.boosters.BoosterManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.gui.GuiItem; import mineplex.core.gui.ItemRefresher; import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.bonuses.BonusAmount; -import mineplex.core.bonuses.BonusClientData; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.bonuses.StreakRecord; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.Sound; +import mineplex.core.thank.ThankManager; +import org.bukkit.*; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; +import java.util.ArrayList; + public class ClaimTipsButton implements GuiItem, Listener { private ItemStack _item; @@ -45,12 +32,12 @@ public class ClaimTipsButton implements GuiItem, Listener private ItemRefresher _gui; private BonusManager _bonusManager; - private BoosterManager _boosterManager; + private ThankManager _thankManager; - public ClaimTipsButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager, BoosterManager boosterManager) + public ClaimTipsButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager, ThankManager thankManager) { _bonusManager = bonusManager; - _boosterManager = boosterManager; + _thankManager = thankManager; _player = player; _plugin = plugin; _gui = gui; @@ -72,12 +59,17 @@ public class ClaimTipsButton implements GuiItem, Listener @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Claim Tips Button", 1000, false, false)) + { + return; + } + if (isAvailable()) { _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); new LoadingWindow(getPlugin(), getPlayer(), 6*9); - _boosterManager.getTipManager().claimTips(getPlayer(), claimed -> { - if (claimed > 0) + _thankManager.claimThanks(getPlayer(), claimThankResult -> { + if (claimThankResult != null && claimThankResult.getClaimed() > 0) { // Woo, success! setItem(); @@ -87,17 +79,17 @@ public class ClaimTipsButton implements GuiItem, Listener new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Amplifier Thanks Collected"), "Thanks Collected", 6*9, 20*3, getGui()).openInventory(); } - UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(CurrencyType.TREASURE_SHARD, claimed) + " from Amplifiers!")); + UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimThankResult.getClaimed()) + " from " + F.elem(claimThankResult.getUniqueThanks()) + " players!")); // Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect _bonusManager.addPendingExplosion(getPlayer(), "RANK"); getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); } - else if (claimed == 0) + else if (claimThankResult != null && claimThankResult.getClaimed() == 0) { // No tips to claim if (getPlayer().getOpenInventory() != null) { - new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "No Thanks to Claim!"), "You have no thanks to claim!", 6*9, 20*3, getGui()).openInventory(); + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "No Thanks to Claim!"), "You have no thank to claim!", 6*9, 20*3, getGui()).openInventory(); } UtilPlayer.message(getPlayer(), F.main("Carl", "You have no rewards to claim!")); @@ -133,7 +125,7 @@ public class ClaimTipsButton implements GuiItem, Listener if (isAvailable()) { material = Material.EMERALD; - itemName = C.cGreen + C.Bold + "Game Amplifiers"; + itemName = C.cGreen + C.Bold + "Thank Rewards"; lore.add(" "); lore.add(C.cYellow + "Your Rewards"); lore.add(" " + C.cWhite + getTips() + " Treasure Shards"); @@ -143,10 +135,11 @@ public class ClaimTipsButton implements GuiItem, Listener else { material = Material.REDSTONE_BLOCK; - itemName = C.cRed + C.Bold + "Game Amplifiers"; + itemName = C.cRed + C.Bold + "Thank Rewards"; lore.add(" "); - lore.add(C.cGray + "Use Amplifiers to earn rewards"); + lore.add(C.cGray + "Earn Thank Rewards from players using /thank"); + lore.add(C.cGray + "on you, or by enabling Game Amplifiers."); lore.add(" "); lore.add(C.cWhite + "Get Amplifiers at " + C.cGreen + "mineplex.com/shop"); } @@ -167,7 +160,7 @@ public class ClaimTipsButton implements GuiItem, Listener private int getTips() { - return _boosterManager.getTipManager().Get(getPlayer()).getTips(); + return _thankManager.Get(_player).getThankToClaim(); } private boolean isAvailable() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java index ebc150b6c..f46ceca73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java @@ -13,6 +13,7 @@ import mineplex.core.gui.ItemRefresher; import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -69,6 +70,11 @@ public class DailyBonusButton implements GuiItem, Listener @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Carl Daily Bonus", 1000, false, false)) + { + return; + } + if (isAvailable()) { _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java index dfb707a05..29054f2a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java @@ -17,6 +17,7 @@ import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.poll.Poll; import mineplex.core.poll.PollManager; +import mineplex.core.recharge.Recharge; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -109,6 +110,11 @@ public class PollButton extends SimpleGui implements GuiItem { @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(getPlayer(), "Poll Main Button", 1000, false, false)) + { + return; + } + if (_poll == null) { getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f); @@ -195,6 +201,11 @@ public class PollButton extends SimpleGui implements GuiItem { @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(getPlayer(), "Poll Answer Button", 1000, false, false)) + { + return; + } + _create = true; _pollManager.answerPoll(getPlayer(), _poll, num + 1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java index 1f525f36b..31541dc59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java @@ -13,6 +13,7 @@ import mineplex.core.gui.ItemRefresher; import mineplex.core.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -78,6 +79,11 @@ public class RankBonusButton implements GuiItem, Listener { @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Claim Rank Bonus", 1000, false, false)) + { + return; + } + if (isAvailable() && _bonusManager.isPastAugust()) { _item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing..."); refreshItem(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java index dd741b450..4a7b1b10e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java @@ -5,6 +5,7 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.youtube.YoutubeManager; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -59,6 +60,11 @@ public class YoutubeButton implements GuiItem @Override public void click(ClickType clickType) { + if (!Recharge.Instance.use(_player, "Use Youtube Button", 1000, false, false)) + { + return; + } + _player.closeInventory(); final String message; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java index 4254f6594..eec3e3c22 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java @@ -1,6 +1,5 @@ package mineplex.core.boosters; -import com.mojang.authlib.properties.PropertyMap; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.command.BoosterCommand; @@ -10,7 +9,7 @@ import mineplex.core.boosters.event.BoosterItemGiveEvent; import mineplex.core.boosters.event.BoosterUpdateEvent; import mineplex.core.boosters.gui.BoosterShop; import mineplex.core.boosters.redis.BoosterUpdateRepository; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilGear; @@ -19,12 +18,12 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.thank.ThankManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; @@ -64,8 +63,8 @@ public class BoosterManager extends MiniPlugin private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; + private BoosterThankManager _boosterThankManager; - private BoosterTipManager _tipManager; private BoosterShop _shop; private String _boosterGroup; @@ -74,7 +73,7 @@ public class BoosterManager extends MiniPlugin private long _cacheLastUpdated; private Map> _boosterCache = new HashMap<>(); - public BoosterManager(JavaPlugin plugin, String boosterGroup, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager) + public BoosterManager(JavaPlugin plugin, String boosterGroup, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ThankManager thankManager) { super("Booster Manager", plugin); @@ -84,7 +83,7 @@ public class BoosterManager extends MiniPlugin _donationManager = donationManager; _inventoryManager = inventoryManager; - _tipManager = new BoosterTipManager(plugin, clientManager, donationManager); + _boosterThankManager = new BoosterThankManager(plugin, clientManager, thankManager); _shop = new BoosterShop(this, clientManager, donationManager); try @@ -335,9 +334,9 @@ public class BoosterManager extends MiniPlugin handleBoosterUpdate(event.getBoosterMap()); } - public BoosterTipManager getTipManager() + public BoosterThankManager getBoosterThankManager() { - return _tipManager; + return _boosterThankManager; } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java index 0cc567715..23ae2e6eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.shop.confirmation.ConfirmationCallback; import mineplex.core.shop.confirmation.ConfirmationProcessor; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; /** * @author Shaun Bennett @@ -21,6 +22,9 @@ public class BoosterProcessor implements ConfirmationProcessor _player = player; } + @Override + public void init(Inventory inventory) {} + @Override public void process(ConfirmationCallback callback) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java index a057c4071..25e8c2c64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterRepository.java @@ -7,6 +7,7 @@ import com.google.gson.JsonObject; import com.mojang.authlib.properties.PropertyMap; import mineplex.core.common.api.ApiEndpoint; import mineplex.core.common.api.ApiFieldNamingStrategy; +import mineplex.core.common.api.ApiHost; import mineplex.core.common.api.ApiResponse; import java.util.Arrays; @@ -23,7 +24,7 @@ public class BoosterRepository extends ApiEndpoint { public BoosterRepository() { - super("/booster", new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy()) + super(ApiHost.AMPLIFIERS, "/booster", new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy()) // .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()) .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java index 216130e12..44a429ac6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java @@ -15,11 +15,12 @@ public class BoosterCommand extends MultiCommandBase { public BoosterCommand(BoosterManager plugin) { - super(plugin, Rank.DEVELOPER, "amplifier", "booster"); + super(plugin, Rank.ALL, "amplifier", "booster"); AddCommand(new AddCommand(plugin)); AddCommand(new GuiCommand(plugin)); AddCommand(new ReloadCommand(plugin)); + AddCommand(new ThankCommand(plugin)); } @Override @@ -27,5 +28,6 @@ public class BoosterCommand extends MultiCommandBase { UtilPlayer.message(caller, F.help("amplifier add ", "Add an amplifier to that group", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("amplifier thank ", "Thank an Amplifier for a specific Booster Group", Rank.ALL)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java new file mode 100644 index 000000000..b6a379fc0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java @@ -0,0 +1,74 @@ +package mineplex.core.boosters.command; + +import mineplex.core.boosters.Booster; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.boosters.tips.BoosterThankManager; +import mineplex.core.boosters.tips.TipAddResult; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import org.apache.commons.lang3.StringUtils; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +/** + * @author Shaun Bennett + */ +public class ThankCommand extends CommandBase +{ + public ThankCommand(BoosterManager plugin) + { + super(plugin, Rank.ALL, "thank"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length == 0) + { + // try to thank the current amplifier group + String boosterGroup = Plugin.getBoosterGroup(); + if (boosterGroup == null || boosterGroup.length() <= 0) + { + UtilPlayer.message(caller, F.main("Amplifier", "You must specify an Amplifier Group")); + return; + } + + attemptToTipGroup(caller, boosterGroup); + } + else + { + String boosterGroup = StringUtils.join(args, ' '); + attemptToTipGroup(caller, boosterGroup); + } + } + + private void attemptToTipGroup(Player caller, String boosterGroup) + { + Booster booster = Plugin.getActiveBooster(boosterGroup); + if (booster == null) + { + // Give a friendly oops message + UtilPlayer.message(caller, F.main("Amplifier", "There was an error handling your request. Try again later")); + return; + } + else + { + Plugin.getBoosterThankManager().addTip(caller, booster, result -> + { + if (result == TipAddResult.SUCCESS) + { + UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got " + + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!"); + caller.playSound(caller.getLocation(), Sound.LEVEL_UP, 1f, 1f); + } + else if (result.getFriendlyMessage() != null) + { + UtilPlayer.message(caller, F.main("Amplifier", result.getFriendlyMessage())); + } + }); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java index 3a6315ec9..9e4ae655f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java @@ -4,7 +4,6 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.BoosterProcessor; -import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; @@ -115,8 +114,7 @@ public class BoosterPage extends ShopPageBase ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false); BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer()); - ConfirmationPage page = new ConfirmationPage<>(getPlugin(), getShop(), - getClientManager(), getDonationManager(), getPlayer(), this, processor, booster); + ConfirmationPage page = new ConfirmationPage<>(getPlayer(), this, processor, booster); getShop().openPageForPlayer(getPlayer(), page); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java new file mode 100644 index 000000000..c3ae99372 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankManager.java @@ -0,0 +1,93 @@ +package mineplex.core.boosters.tips; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.boosters.Booster; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.thank.ThankManager; +import mineplex.core.thank.ThankResult; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * This class handles "thanking" Amplifiers. This is a way of rewarding players for activating Amplifiers. + * + * @author Shaun Bennett + */ +public class BoosterThankManager extends MiniPlugin +{ + public static final int TIP_FOR_SPONSOR = 5; + public static final int TIP_FOR_TIPPER = 5; + + private BoosterThankRepository _repository; + private CoreClientManager _clientManager; + private ThankManager _thankManager; + + public BoosterThankManager(JavaPlugin plugin, CoreClientManager clientManager, ThankManager thankManager) + { + super("Amplifier Thanks", plugin); + + _clientManager = clientManager; + _repository = new BoosterThankRepository(plugin); + _thankManager = thankManager; + } + + /** + * Attempt to "Thank" an Amplifier. This checks with {@link BoosterThankRepository} if a player hasn't already + * thanked that Amplifier. If they havent, we proceed to use {@link ThankManager} to send a thank you to the player + * who activated that Amplifier. + * + * @param player The player sending the thanks + * @param booster The Amplifier to be thanked + * @param callback Callback with the result of sending the thanks + */ + public void addTip(Player player, Booster booster, Callback callback) + { + if (!Recharge.Instance.use(player, "Amplifier Thanks", 1000 * 5, false, false)) + { + UtilPlayer.message(player, F.main("Amplifier", "Please wait before trying that again")); + callback.run(TipAddResult.ON_COOLDOWN); + return; + } + + int accountId = _clientManager.getAccountId(player); + + // Break out if client manager has a bad account id + if (accountId == -1) + { + callback.run(TipAddResult.INVALID_ACCOUNT_ID); + return; + } + + // You can't tip yourself, silly! + if (accountId == booster.getAccountId()) + { + callback.run(TipAddResult.CANNOT_TIP_SELF); + return; + } + + runAsync(() -> + { + if (_repository.checkAmplifierThank(accountId, booster.getId())) + { + // We can thank that amplifier! + _thankManager.thankPlayer(booster.getPlayerName(), booster.getAccountId(), player.getName(), accountId, + TIP_FOR_SPONSOR, TIP_FOR_TIPPER, "Amplifier", true, thankResult -> + runSync(() -> callback.run(fromThankResult(thankResult)))); + } + else + { + runSync(() -> callback.run(TipAddResult.ALREADY_TIPPED_BOOSTER)); + } + }); + } + + + private TipAddResult fromThankResult(ThankResult result) + { + return result == ThankResult.SUCCESS ? TipAddResult.SUCCESS : TipAddResult.UNKNOWN_ERROR; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java new file mode 100644 index 000000000..8fd26265e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterThankRepository.java @@ -0,0 +1,52 @@ +package mineplex.core.boosters.tips; + +import mineplex.core.database.MinecraftRepository; +import mineplex.database.routines.AddTip; +import mineplex.database.routines.CheckAmplifierThank; +import mineplex.database.routines.ClaimTips; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * @author Shaun Bennett + */ +public class BoosterThankRepository extends MinecraftRepository +{ + public BoosterThankRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + } + + /** + * Checks the database if an accountId is allowed to thank a specific Amplifier. + * This will return true and update the database if the thank is okay, or false + * if that account ID has already thanked that Amplifier ID. + * + * @param accountId Account ID of the player trying to thank the Amplifier + * @param amplifierId The ID of the Amplifier the player is trying to thank + * @return True if the account id can thank the amplifier id, false otherwise + */ + public boolean checkAmplifierThank(int accountId, int amplifierId) + { + CheckAmplifierThank checkAmplifierThank = new CheckAmplifierThank(); + checkAmplifierThank.setInAccountId(accountId); + checkAmplifierThank.setInAmplifierId(amplifierId); + checkAmplifierThank.execute(jooq().configuration()); + return checkAmplifierThank.getCanThank() == 1; + } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java deleted file mode 100644 index be7f28ca9..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipManager.java +++ /dev/null @@ -1,130 +0,0 @@ -package mineplex.core.boosters.tips; - -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.boosters.Booster; -import mineplex.core.common.util.Callback; -import mineplex.core.donation.DonationManager; -import mineplex.core.recharge.Recharge; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.ResultSet; -import java.sql.SQLException; - -/** - * @author Shaun Bennett - */ -public class BoosterTipManager extends MiniDbClientPlugin -{ - public static final int TIP_FOR_SPONSOR = 5; - public static final int TIP_FOR_TIPPER = 5; - - private BoosterTipRepository _repository; - private DonationManager _donationManager; - - public BoosterTipManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) - { - super("Amplifier Thanks", plugin, clientManager); - - _donationManager = donationManager; - _repository = new BoosterTipRepository(plugin); - } - - public void addTip(Player player, Booster booster, Callback callback) - { - if (!Recharge.Instance.use(player, "Amplifier Thanks", 1000 * 60 * 10, true, false)) - { - callback.run(TipAddResult.ON_COOLDOWN); - return; - } - - int accountId = ClientManager.getAccountId(player); - - // Break out if client manager has a bad account id - if (accountId == -1) - { - callback.run(TipAddResult.INVALID_ACCOUNT_ID); - return; - } - - // You can't tip yourself, silly! - if (accountId == booster.getAccountId()) - { - callback.run(TipAddResult.CANNOT_TIP_SELF); - return; - } - - runAsync(() -> { - TipAddResult result; - if (_repository.addTip(accountId, booster.getAccountId(), booster.getId(), TIP_FOR_SPONSOR)) - { - _donationManager.rewardCoinsUntilSuccess(null, "Tips", player.getName(), accountId, TIP_FOR_TIPPER); - result = TipAddResult.SUCCESS; - } - else - result = TipAddResult.ALREADY_TIPPED_BOOSTER; - - runSync(() -> callback.run(result)); - }); - } - - /** - * Claim all tips for a player and add those tips to their account (Treasure Shards) - * This will call a database routine that handles the tip process. - * - * The callback will return -1 on a failed attempt or 0 if there was no tips to claim - * @param player The player with tips to claim - * @param callback Callback returning the amount of tips claimed - */ - public void claimTips(Player player, Callback callback) - { - String playerName = player.getName(); - int accountId = ClientManager.getAccountId(player); - - if (accountId == -1) - { - // uh oh, invalid account id! - if (callback != null) callback.run(-1); - } - - runAsync(() -> { - int tips = _repository.claimTips(accountId); - runSync(() -> { - if (tips > 0) - { - _donationManager.rewardCoinsUntilSuccess(null, "Tips", playerName, accountId, tips); - } - - // Reset tips back to 0 - if (Get(player) != null) Get(player).setTips(0); - if (callback != null) callback.run(tips); - }); - }); - } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT tips FROM Account.accountTip WHERE accountTip.accountId = " + accountId + ";"; - } - - @Override - protected PlayerTipData addPlayer(String player) - { - return new PlayerTipData(); - } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - PlayerTipData data = new PlayerTipData(); - - while (resultSet.next()) - { - data.setTips(resultSet.getInt(1)); - } - - Set(playerName, data); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java deleted file mode 100644 index 6ece1a5b2..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/BoosterTipRepository.java +++ /dev/null @@ -1,55 +0,0 @@ -package mineplex.core.boosters.tips; - -import mineplex.core.database.MinecraftRepository; -import mineplex.database.routines.AddTip; -import mineplex.database.routines.ClaimTips; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * @author Shaun Bennett - */ -public class BoosterTipRepository extends MinecraftRepository -{ - public static String LOG_TIP = "INSERT INTO Account.accountTipLogs (accountId, boosterId) VALUES (?, ?)"; - public static String ADD_TIP = "INSERT INTO Account.accountTip (accountId, tips) VALUES (?, ?) ON DUPLICATE KEY UPDATE tips = tips + ?"; - - public BoosterTipRepository(JavaPlugin plugin) - { - super(plugin, DBPool.getAccount()); - } - - public boolean addTip(int tipperId, int receiverId, int boosterId, int tipAmount) - { - AddTip addTip = new AddTip(); - addTip.setTipperAccountId(tipperId); - addTip.setBoosterAccountId(receiverId); - addTip.setBoosterId(boosterId); - addTip.setTipAmount(tipAmount); - addTip.execute(jooq().configuration()); - return addTip.getSuccess() == 1; - } - - public int claimTips(int accountId) - { - ClaimTips claimTips = new ClaimTips(); - claimTips.setAccountId_in(accountId); - claimTips.execute(jooq().configuration()); - return claimTips.getTipsClaimed(); - } - - @Override - protected void initialize() - { - - } - - @Override - protected void update() - { - - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java index 965a8e738..aa657b6e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/tips/TipAddResult.java @@ -7,6 +7,7 @@ public enum TipAddResult { ALREADY_TIPPED_BOOSTER("You have already thanked this Amplifier!"), INVALID_ACCOUNT_ID("Uh oh, something went wrong. Try relogging"), + UNKNOWN_ERROR("An error occurred. Try again later"), CANNOT_TIP_SELF("You can't thank yourself, silly!"), ON_COOLDOWN(null), SUCCESS(null); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java index 471bfe8e2..2bf237c43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java @@ -12,19 +12,13 @@ import mineplex.core.donation.DonationManager; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.stats.StatsManager; -import mineplex.core.thread.ThreadPool; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.Region; import mineplex.serverdata.redis.counter.GoalCounter; import mineplex.serverdata.redis.counter.GoalCounterListener; import mineplex.serverdata.servers.ConnectionData; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import java.io.File; import java.io.IOException; @@ -63,7 +57,7 @@ public class Fountain implements GoalCounterListener _name = name; _dataKey = dataKey; _location = location; - _hologram = new Hologram(hologramManager, location.clone().add(4, 3, -3), name).start(); + _hologram = new Hologram(hologramManager, new Location(location.getWorld(), -23, 75, 3), name).start(); _counter = new GoalCounter(writeConnection, readConnection, region, dataKey, goal); _counter.addListener(this); _brawlActive = false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java index d141e1997..8fb7009fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java @@ -3,17 +3,13 @@ package mineplex.core.brawl.fountain; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.brawl.fountain.command.FountainCommand; -import mineplex.core.brawl.fountain.gui.FountainShop; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.DonationManager; import mineplex.core.hologram.HologramManager; import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.Region; -import mineplex.serverdata.redis.counter.Counter; import mineplex.serverdata.servers.ConnectionData; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -22,12 +18,9 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; - /** * @author Shaun Bennett */ @@ -55,7 +48,7 @@ public class FountainManager extends MiniPlugin int goal = 70000000;//!new File("eu.dat").exists() ? 200000000 : 20000000; _gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"), new ConnectionData("10.3.203.80", 6377, ConnectionData.ConnectionType.SLAVE, "USRedis"), Region.ALL, - new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5), + new Location(world, -25.5, 73, 19.5), new Location(world, -35.5, 69, 1.5), C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java index 6018772f0..d0ba3e882 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java @@ -1,9 +1,8 @@ package mineplex.core.brawl.fountain; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.Material; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -14,14 +13,8 @@ public class GemFountainSalesPackage extends SalesPackageBase { super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1); - CurrencyCostMap.put(CurrencyType.GEM, gems); + CurrencyCostMap.put(GlobalCurrency.GEM, gems); KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java index cd1bf65a5..8e108093c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java @@ -2,8 +2,8 @@ package mineplex.core.brawl.fountain.command; import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -53,7 +53,7 @@ public class AddCommand extends CommandBase UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!")); } } - }, caller, "GemFountain.Add", CurrencyType.GEM, amount, false); + }, caller, "GemFountain.Add", GlobalCurrency.GEM, amount, false); } catch (NumberFormatException ex) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java index 61d5d8427..dc3fb9c64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java @@ -4,8 +4,8 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.brawl.fountain.Fountain; import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.brawl.fountain.gui.button.FountainAddButton; -import mineplex.core.common.CurrencyType; import mineplex.core.common.MaterialData; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; @@ -77,7 +77,7 @@ public class FountainPage extends ShopPageBase if (canAdd) { - int playerGems = getDonationManager().Get(getPlayer()).GetGems(); + int playerGems = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.GEM); ShopItem add1 = new ShopItem(Material.EMERALD, "Add 100 Gems", new String[]{}, 1, playerGems < 100, false); ShopItem add2 = new ShopItem(Material.EMERALD, "Add 1,000 Gems", new String[]{}, 64, playerGems < 1000, false); ShopItem add3 = new ShopItem(Material.EMERALD_BLOCK, "Add 10,000 Gems", new String[]{}, 1, playerGems < 10000, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java index c37c8c551..3dcc6ebd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java @@ -1,13 +1,12 @@ package mineplex.core.brawl.fountain.gui.button; -import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.brawl.fountain.GemFountainSalesPackage; import mineplex.core.brawl.fountain.gui.FountainPage; -import mineplex.core.brawl.fountain.gui.FountainShop; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageProcessor; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -30,13 +29,10 @@ public class FountainAddButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - _page.getShop().openPageForPlayer(player, new ConfirmationPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, _salesPackage, _page.getDonationManager(), () -> { - public void run() - { - _page.getPlugin().getGemFountain().increment(player, _gems, null); - _page.refresh(); - } - }, _page, _salesPackage, CurrencyType.GEM, player)); + _page.getPlugin().getGemFountain().increment(player, _gems, null); + _page.refresh(); + }), _salesPackage.buildIcon())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index effa0f484..c1857b7dc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -1,40 +1,5 @@ package mineplex.core.chat; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.Charset; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import java.util.function.Function; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.apache.commons.lang3.Validate; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -49,10 +14,44 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; import mineplex.core.incognito.IncognitoManager; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.apache.commons.lang3.Validate; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.Charset; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import java.util.function.Function; public class Chat extends MiniPlugin { @@ -69,7 +68,6 @@ public class Chat extends MiniPlugin private int _chatSlow = 0; private long _silenced = 0; - private boolean _threeSecondDelay = true; private List> _highPriorityFilters = new ArrayList<>(); private List> _lowPriorityFilters = new ArrayList<>(); @@ -213,7 +211,7 @@ public class Chat extends MiniPlugin { for (Iterator playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();) { - if (!_preferences.Get(playerIterator.next()).ShowChat) + if (!_preferences.get(playerIterator.next()).isActive(Preference.SHOW_CHAT)) playerIterator.remove(); } } @@ -349,15 +347,6 @@ public class Chat extends MiniPlugin event.setCancelled(true); return; } - else if (_threeSecondDelay && - _clientManager.Get(sender).GetRank() == Rank.ALL && - _achievements.getMineplexLevelNumber(sender, Rank.ALL) < 25 && - !Recharge.Instance.use(sender, "All Chat Message", 3000, false, false)) - { - UtilPlayer.message(sender, C.cYellow + "You can only chat once every 3 seconds to prevent spam."); - UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!"); - event.setCancelled(true); - } else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && !Recharge.Instance.use(sender, "Chat Message", 400, false, false)) { @@ -645,11 +634,6 @@ public class Chat extends MiniPlugin _playerLastMessage.remove(event.getPlayer().getUniqueId()); } - public void setThreeSecondDelay(boolean b) - { - _threeSecondDelay = b; - } - /** * If the function returns Boolean.TRUE then the message will be CANCELLED. */ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java index 271dbe895..94ec614e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java @@ -1,25 +1,23 @@ package mineplex.core.cosmetic.ui; -import mineplex.core.cosmetic.ui.page.*; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.messaging.PluginMessageListener; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.page.GadgetPage; +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.cosmetic.ui.page.PetTagPage; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.messaging.PluginMessageListener; public class CosmeticShop extends ShopBase implements PluginMessageListener { public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name) { - super(plugin, clientManager, donationManager, name, CurrencyType.GEM, CurrencyType.TREASURE_SHARD); + super(plugin, clientManager, donationManager, name); plugin.getPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.getPlugin(), "MC|ItemName", this); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java index c41b9915a..3d1039572 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java @@ -1,15 +1,13 @@ package mineplex.core.cosmetic.ui.button; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; -import mineplex.core.common.CurrencyType; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.cosmetic.ui.page.MountPage; import mineplex.core.mount.Mount; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.SalesPackageProcessor; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; public class MountButton implements IButton { @@ -25,13 +23,10 @@ public class MountButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { - _page.getShop().openPageForPlayer(player, new ConfirmationPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, _mount, _page.getDonationManager(), () -> { - public void run() - { - _page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1); - _page.refresh(); - } - }, _page, _mount, CurrencyType.TREASURE_SHARD, player)); + _page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1); + _page.refresh(); + }), _mount.buildIcon())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index 525594815..218390e2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -1,12 +1,7 @@ package mineplex.core.cosmetic.ui.page; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; @@ -19,6 +14,10 @@ import mineplex.core.gadget.types.ItemGadget; import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; /** * Created by shaun on 14-09-15. @@ -38,7 +37,7 @@ public class CostumePage extends GadgetPage for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.COSTUME)) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1) continue; OutfitGadget outfitGadget = ((OutfitGadget) gadget); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index b56d4cf8e..a5c62b29c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -1,12 +1,29 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.button.GadgetButton; +import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton; +import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton; +import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetChangeEvent; +import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.HatGadget; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.SalesPackageProcessor; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,26 +31,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton; -import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton; -import mineplex.core.cosmetic.ui.button.GadgetButton; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.gadgets.morph.MorphBlock; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.gadget.types.HatGadget; -import mineplex.core.gadget.types.ItemGadget; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ConfirmationPage; -import mineplex.core.shop.page.ShopPageBase; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class GadgetPage extends ShopPageBase { @@ -50,7 +50,7 @@ public class GadgetPage extends ShopPageBase for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM)) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3) continue; addGadget(gadget, slot); @@ -105,64 +105,64 @@ public class GadgetPage extends ShopPageBase if (!gadget.ownsGadget(getPlayer())) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { //Nothing } //Chest Unlocks - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -2 || gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -4) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -5) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -6) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -6) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Valentines Gifts"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -7) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -7) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Purchased from shop.mineplex.com"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Freedom Chests"); } //Rank Unlocks - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -10) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -11) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -12) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -13) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -178,12 +178,12 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cWhite + "You own " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getName())); // boolean canAffordAmmo = true; -// if (itemGadget.getAmmo().getCost(CurrencyType.Coins) > 0) +// if (itemGadget.getAmmo().getCost(GlobalCurrency.Coins) > 0) // { // itemLore.add(C.cBlack); -// itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().getDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().getCost(CurrencyType.Coins) + " Coins"); +// itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().getDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().getCost(GlobalCurrency.Coins) + " Coins"); // -// if (getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.Coins) >= itemGadget.getAmmo().getCost(CurrencyType.Coins)) +// if (getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.Coins) >= itemGadget.getAmmo().getCost(GlobalCurrency.Coins)) // { // itemLore.add(C.cGreen + "Right-Click To Purchase"); // } @@ -239,26 +239,26 @@ public class GadgetPage extends ShopPageBase } else { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this)); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); @@ -291,7 +291,7 @@ public class GadgetPage extends ShopPageBase if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) { gadgetItemStack = CountryFlag.USA.getBanner(); BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); @@ -314,7 +314,7 @@ public class GadgetPage extends ShopPageBase if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) { gadgetItemStack = CountryFlag.USA.getBanner(); BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); @@ -329,20 +329,20 @@ public class GadgetPage extends ShopPageBase } else { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this)); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); @@ -363,7 +363,7 @@ public class GadgetPage extends ShopPageBase { ItemGadget itemGadget = (ItemGadget)gadget; - if (itemGadget.getAmmo().getCost(CurrencyType.TREASURE_SHARD) < 0) + if (itemGadget.getAmmo().getCost(GlobalCurrency.TREASURE_SHARD) < 0) return; } @@ -372,14 +372,11 @@ public class GadgetPage extends ShopPageBase UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); return; } - getShop().openPageForPlayer(getPlayer(), new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() + getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), getDonationManager(), () -> { - public void run() - { - getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity())); - refresh(); - } - }, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), CurrencyType.TREASURE_SHARD, getPlayer())); + getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity())); + refresh(); + }), gadget.buildIcon())); } public void activateGadget(Player player, Gadget gadget) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 51ed4dd84..4ab38eae7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,24 +1,26 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; - -import mineplex.core.cosmetic.ui.button.open.*; -import org.bukkit.Material; -import org.bukkit.entity.Creature; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilText; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.button.open.OpenArrowTrails; +import mineplex.core.cosmetic.ui.button.open.OpenCostumes; +import mineplex.core.cosmetic.ui.button.open.OpenDeathAnimations; +import mineplex.core.cosmetic.ui.button.open.OpenDoubleJump; +import mineplex.core.cosmetic.ui.button.open.OpenGadgets; +import mineplex.core.cosmetic.ui.button.open.OpenGameModifiers; +import mineplex.core.cosmetic.ui.button.open.OpenHats; +import mineplex.core.cosmetic.ui.button.open.OpenMorphs; +import mineplex.core.cosmetic.ui.button.open.OpenMounts; +import mineplex.core.cosmetic.ui.button.open.OpenMusic; +import mineplex.core.cosmetic.ui.button.open.OpenParticles; +import mineplex.core.cosmetic.ui.button.open.OpenPets; +import mineplex.core.cosmetic.ui.button.open.OpenWinEffect; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -27,6 +29,16 @@ import mineplex.core.pet.Pet; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import org.bukkit.Material; +import org.bukkit.entity.Creature; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; public class Menu extends ShopPageBase { @@ -41,7 +53,7 @@ public class Menu extends ShopPageBase protected void buildPage() { // Treasure Shards - int treasureShards = getDonationManager().Get(getPlayer()).getCoins(); + int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD); List shardLore = new ArrayList(); shardLore.add(" "); @@ -100,7 +112,7 @@ public class Menu extends ShopPageBase Mount mountActive = getPlugin().getMountManager().getActive(getPlayer()); for (Mount mount : getPlugin().getMountManager().getMounts()) { - if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) + if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName())) { mountOwned++; } @@ -112,7 +124,7 @@ public class Menu extends ShopPageBase int petMax = 0; for (Pet pet : getPlugin().getPetManager().getFactory().GetPets()) { - NautHashMap pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); + Map pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); if (pets != null && pets.containsKey(pet.getPetType())) { petOwned++; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index bc84607ea..020297748 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -1,26 +1,25 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.button.MountButton; import mineplex.core.cosmetic.ui.button.activate.ActivateMountButton; import mineplex.core.cosmetic.ui.button.deactivate.DeactivateMountButton; -import mineplex.core.cosmetic.ui.button.MountButton; import mineplex.core.donation.DonationManager; import mineplex.core.mount.Mount; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class MountPage extends ShopPageBase { @@ -60,67 +59,67 @@ public class MountPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.addAll(Arrays.asList(mount.getDescription())); - if (!getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) + if (!getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName())) { - if (mount.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { //Nothing } //Chest Unlocks - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -2 || mount.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -3) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -4) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -5) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -6) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -6) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -7) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -7) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Freedom Chests"); } //Rank Unlocks - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -10) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -11) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -12) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -13) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); } } - if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) + if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName())) { if (mount.getActive().containsKey(getPlayer())) { @@ -139,20 +138,20 @@ public class MountPage extends ShopPageBase } else { - if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= mount.getCost(CurrencyType.TREASURE_SHARD)) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= mount.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, mount.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this)); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 8ecd60944..77b4c15ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -1,33 +1,16 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.server.v1_8_R3.Blocks; -import net.minecraft.server.v1_8_R3.ChatMessage; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.Items; -import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow; -import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; - -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.PetSorter; -import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton; -import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.cosmetic.ui.button.PetButton; import mineplex.core.cosmetic.ui.button.RenamePetButton; +import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton; +import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.donation.DonationManager; import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; @@ -35,6 +18,16 @@ import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.AnvilContainer; import mineplex.core.shop.page.ShopPageBase; +import net.minecraft.server.v1_8_R3.*; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class PetPage extends ShopPageBase { @@ -63,49 +56,49 @@ public class PetPage extends ShopPageBase //Chest Unlocks if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType())) { - if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { //Nothing } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -2 || pet.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -3) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -4) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -5) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } //Rank Unlocks - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -10) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -11) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -12) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -13) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -145,20 +138,20 @@ public class PetPage extends ShopPageBase //Not Owned else { - if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - - if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= pet.getCost(CurrencyType.TREASURE_SHARD)) + + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this)); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); @@ -194,7 +187,7 @@ public class PetPage extends ShopPageBase || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE) { - addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(CurrencyType.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(GlobalCurrency.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); } slot++; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index 27997f3a8..0a5c568fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -2,7 +2,7 @@ package mineplex.core.cosmetic.ui.page; import mineplex.cache.player.PlayerCache; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -15,11 +15,12 @@ import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.page.ShopPageBase; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -93,44 +94,42 @@ public class PetTagPage extends ShopPageBase } PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100); + final SalesPackageBase salesPackage = _petPurchase ? _pet : tag; _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); - - getShop().openPageForPlayer(getPlayer(), new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() + + getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () -> { - public void run() + PetChangeToken token = new PetChangeToken(); + + if (getClientManager().Get(getPlayer()) != null) + token.AccountId = getClientManager().Get(getPlayer()).getAccountId(); + else + token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId(); + + token.Name = getPlayer().getName(); + token.PetType = _pet.getPetType().toString(); + token.PetId = _pet.getPetType().ordinal(); + token.PetName = _tagName; + + PetToken petToken = new PetToken(); + petToken.PetType = token.PetType; + + if (_petPurchase) { - PetChangeToken token = new PetChangeToken(); - - if (getClientManager().Get(getPlayer()) != null) - token.AccountId = getClientManager().Get(getPlayer()).getAccountId(); - else - token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId(); - - token.Name = getPlayer().getName(); - token.PetType = _pet.getPetType().toString(); - token.PetId = _pet.getPetType().ordinal(); - token.PetName = _tagName; - - PetToken petToken = new PetToken(); - petToken.PetType = token.PetType; - - if (_petPurchase) - { - getPlugin().getPetManager().getRepository().AddPet(token); - getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType()); - } - else - { - getPlugin().getPetManager().getRepository().UpdatePet(token); - getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName); - } - - getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName); - - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); + getPlugin().getPetManager().getRepository().AddPet(token); + getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType()); } - }, null, _petPurchase ? _pet : tag, CurrencyType.TREASURE_SHARD, getPlayer())); + else + { + getPlugin().getPetManager().getRepository().UpdatePet(token); + getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName); + } + + getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName); + + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); + }), salesPackage.buildIcon())); } public void SetTagName(String tagName) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java index e892c9f4d..a759cdcbc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; @@ -55,6 +56,15 @@ public class Creature extends MiniPlugin return entity; } + public T SpawnEntity(Location location, Class entityType) + { + _spawnForce = true; + T entity = location.getWorld().spawn(location, entityType); + _spawnForce = false; + + return entity; + } + @EventHandler(priority = EventPriority.HIGHEST) public void eggThrow(PlayerEggThrowEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index 45893a07d..84e958429 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -2,6 +2,7 @@ package mineplex.core.customdata; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -26,14 +27,14 @@ public class CustomDataManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { PlayerCustomData data = new PlayerCustomData(_repository); while (resultSet.next()) { data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data")); } - Set(playerName, data); + Set(uuid, data); } @Override @@ -43,7 +44,7 @@ public class CustomDataManager extends MiniDbClientPlugin } @Override - protected PlayerCustomData addPlayer(String player) + protected PlayerCustomData addPlayer(UUID uuid) { return new PlayerCustomData(_repository); } @@ -56,7 +57,7 @@ public class CustomDataManager extends MiniDbClientPlugin if (accountId == -1) return; - runAsync(() -> _repository.saveData(name, accountId)); + runAsync(() -> _repository.saveData(name, player.getUniqueId(), accountId)); } public CorePlayer getCorePlayer(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java index 14600c963..7ef6ad563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -4,6 +4,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Map; +import java.util.UUID; import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; @@ -68,9 +69,9 @@ public class CustomDataRepository extends MinecraftRepository }); } - public void saveData(String name, int accountId) + public void saveData(String name, UUID uuid, int accountId) { - PlayerCustomData data = _customDataManager.Get(name); + PlayerCustomData data = _customDataManager.Get(uuid); for (Map.Entry entry : data.getDataMap().entrySet()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java index d407ec093..cd71bfcca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java @@ -12,6 +12,8 @@ import mineplex.core.common.util.Callback; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import java.util.UUID; + public class DelayedTask extends MiniClientPlugin { public static DelayedTask Instance; @@ -58,9 +60,9 @@ public class DelayedTask extends MiniClientPlugin } @Override - protected DelayedTaskClient addPlayer(String player) + protected DelayedTaskClient addPlayer(UUID uuid) { - return new DelayedTaskClient(Bukkit.getPlayer(player)); + return new DelayedTaskClient(Bukkit.getPlayer(uuid)); } public boolean HasTask(Player player, String task) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java index f84a661db..1fa8fca66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseFactory.java @@ -35,7 +35,7 @@ public class DisguiseFactory case PIG_ZOMBIE: return new DisguisePigZombie(disguised); case PLAYER: - return new DisguisePlayer(disguised); + throw new UnsupportedOperationException("Player disguises must be initialized via constructor"); case SHEEP: return new DisguiseSheep(disguised); case SKELETON: diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index be83461c2..282267d2b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -2,27 +2,46 @@ package mineplex.core.disguise; import com.mineplex.spigot.ChunkAddEntityEvent; import mineplex.core.MiniPlugin; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilEnt; +import mineplex.core.PlayerSelector; +import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.*; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTasks; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseBlock; +import mineplex.core.disguise.disguises.DisguiseInsentient; +import mineplex.core.disguise.disguises.DisguiseLiving; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketVerifier; -import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.*; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; +import net.minecraft.server.v1_8_R3.BlockBed; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.Chunk; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EntityTrackerEntry; +import net.minecraft.server.v1_8_R3.EnumDirection; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutBed; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; +import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_8_R3.WorldServer; +import net.minecraft.server.v1_8_R3.WorldSettings; import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.OfflinePlayer; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -30,443 +49,285 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.ChunkUnloadEvent; -import org.bukkit.plugin.java.JavaPlugin; -import java.lang.reflect.Field; -import java.util.*; -import java.util.Map.Entry; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Predicate; +/* + * notes: rabbit jump has been removed (PacketPlayOutEntityStatus) because it didn't work for 1.9+ anyways + * + * contact samczsun before you make any major changes + */ +@ReflectivelyCreateMiniPlugin public class DisguiseManager extends MiniPlugin implements IPacketHandler { - private NautHashMap _spawnPacketMap = new NautHashMap(); - private NautHashMap _movePacketMap = new NautHashMap(); - private NautHashMap _moveTempMap = new NautHashMap(); - private HashSet _goingUp = new HashSet(); - private NautHashMap _entityDisguiseMap = new NautHashMap(); - private NautHashMap> _disguisePlayerMap = new NautHashMap>(); - private HashSet _blockedNames = new HashSet(); - private NautHashMap> _futureDisguises = new NautHashMap>(); - private NautHashMap> _lastRabbitHop = new NautHashMap>(); + // A map of entityids which are disguised to their respective disguises + private Map> _spawnPacketMap = new HashMap<>(); + + // The map which stores entity UUIDs once they have been unloaded + private Map> _entityDisguiseMap = new HashMap<>(); + + // The map of which players should a disguise be shown to + private Map> _disguisePlayerMap = new HashMap<>(); + + private HashSet _blockedNames = new HashSet<>(); private boolean _handlingPacket = false; - private Field _xChunk; - private Field _zChunk; - - private Chunk _bedChunk; - private boolean _bedPackets; - - - public DisguiseManager(JavaPlugin plugin, PacketHandler packetHandler) + private DisguiseManager() { - super("Disguise Manager", plugin); + super("Disguise Manager"); - packetHandler.addPacketHandler(this, PacketPlayOutAnimation.class, PacketPlayOutBed.class, - PacketPlayOutEntityStatus.class, PacketPlayOutMapChunk.class, PacketPlayOutMapChunkBulk.class, - PacketPlayOutNamedEntitySpawn.class, PacketPlayOutPlayerInfo.class, - PacketPlayOutEntity.PacketPlayOutRelEntityMove.class, PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook.class, - PacketPlayOutSpawnEntity.class, PacketPlayOutEntityVelocity.class, PacketPlayOutEntityDestroy.class, - PacketPlayOutEntityTeleport.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntityLiving.class, - PacketPlayOutUpdateAttributes.class, PacketPlayOutEntityEquipment.class, PacketPlayOutNamedSoundEffect.class); + require(PacketHandler.class) + .addPacketHandler(this, + PacketPlayOutNamedEntitySpawn.class, + PacketPlayOutPlayerInfo.class, + PacketPlayOutSpawnEntity.class, + PacketPlayOutEntityMetadata.class, + PacketPlayOutSpawnEntityLiving.class, + PacketPlayOutUpdateAttributes.class, + PacketPlayOutEntityEquipment.class + ); - try - { - _bedChunk = new Chunk(((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(), 0, 0); - Field cSection = Chunk.class.getDeclaredField("sections"); - cSection.setAccessible(true); - - ChunkSection chunkSection = new ChunkSection(0, true); - Block block = Block.getById(Material.BED_BLOCK.getId()); - - // block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"),"byId") - // .get(null))[Material.BED_BLOCK.getId()]; - - for (BlockFace face : new BlockFace[] - { - BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH - }) - { - int x = 1 + face.getModX(); - int z = 1 + face.getModZ(); - - chunkSection.setType(x, 0, z, block.fromLegacyData(face.ordinal())); - chunkSection.a(x, 0, z, 0); - chunkSection.b(x, 0, z, 0); - } - - ChunkSection[] chunkSections = new ChunkSection[16]; - chunkSections[0] = chunkSection; - cSection.set(_bedChunk, chunkSections); - - // TODO -// _bedChunk.world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(); - - _xChunk = Chunk.class.getField("locX"); - _xChunk.setAccessible(true); - - _zChunk = Chunk.class.getField("locZ"); - _zChunk.setAccessible(true); - } - catch (IllegalArgumentException e) - { - e.printStackTrace(); - } - catch (NoSuchFieldException e) - { - e.printStackTrace(); - } - catch (SecurityException e) - { - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - } - - public void addFutureDisguise(DisguiseBase disguise, Player... players) - { - final int entityId = UtilEnt.getNewEntityId(false); - - _futureDisguises.put(entityId, new HashMap.SimpleEntry(disguise, players)); - - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - if (_futureDisguises.containsKey(entityId)) - { - Entry entry = _futureDisguises.remove(entityId); - - Entity entity = UtilEnt.getEntityById(entityId); - - if (entity != null) - { - entry.getKey().setEntity(entity); - - disguise(entry.getKey(), entry.getValue()); - } - } - } - }, 4); - } - - public void addViewerToDisguise(DisguiseBase disguise, Player player, boolean reapply) - { - _disguisePlayerMap.get(disguise).add(player); - - if (reapply) - refreshTrackers(disguise.GetEntity().getBukkitEntity(), new Player[] - { - player - }); + createBedChunk(); } + // We want to re-register entities that were reloaded by chunk loading @EventHandler - public void ChunkAddEntity(ChunkAddEntityEvent event) + public void onEntityAdd(ChunkAddEntityEvent event) { - DisguiseBase disguise = _entityDisguiseMap.get(event.getEntity().getUniqueId().toString()); + LinkedList disguises = _entityDisguiseMap.remove(event.getEntity().getUniqueId()); - if (disguise != null) + if (disguises != null) { - disguise.setEntity(event.getEntity()); - _spawnPacketMap.put(event.getEntity().getEntityId(), disguise); - _entityDisguiseMap.remove(event.getEntity().getUniqueId().toString()); - - if (disguise instanceof DisguiseRabbit) - { - _lastRabbitHop.put(disguise.GetEntityId(), new NautHashMap()); - } - } - } - - @EventHandler - public void chunkJoin(PlayerJoinEvent event) - { - if (!_bedPackets) - return; - - chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null); - } - - private void chunkMove(Player player, Location newLoc, Location oldLoc) - { - for (Packet packet : getChunkMovePackets(player, newLoc, oldLoc)) - { - UtilPlayer.sendPacket(player, packet); + disguises.forEach(disguise -> disguise.setEntity(event.getEntity())); + _spawnPacketMap.put(event.getEntity().getEntityId(), disguises); } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void chunkMove(PlayerMoveEvent event) - { - if (!_bedPackets) - return; - - Location to = event.getTo(); - Location from = event.getFrom(); - - int x1 = getChunk(to.getX()); - int z1 = getChunk(to.getZ()); - int x2 = getChunk(from.getX()); - int z2 = getChunk(from.getZ()); - - if (x1 != x2 || z1 != z2) - { - chunkMove(event.getPlayer(), to, from); - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void chunkTeleport(PlayerTeleportEvent event) - { - if (!_bedPackets) - return; - - Location to = event.getTo(); - Location from = event.getFrom(); - - if (to.getWorld() == from.getWorld()) - { - int x1 = getChunk(to.getX()); - int z1 = getChunk(to.getZ()); - - int x2 = getChunk(from.getX()); - int z2 = getChunk(from.getZ()); - - if (x1 != x2 || z1 != z2) - { - final Player player = event.getPlayer(); - final Location prev = new Location(to.getWorld(), x1, 0, z1); - - chunkMove(player, null, from); - - Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() - { - public void run() - { - if (!player.isOnline()) - { - return; - } - - Location loc = player.getLocation(); - - if (player.getWorld() != loc.getWorld()) - { - return; - } - - int x2 = getChunk(loc.getX()); - int z2 = getChunk(loc.getZ()); - - if (prev.getBlockX() == x2 && prev.getBlockZ() == z2 && loc.getWorld() == prev.getWorld()) - { - chunkMove(player, loc, null); - } - - refreshBedTrackers(player); - } - }); - } - } - } - - @EventHandler - public void ChunkUnload(ChunkUnloadEvent event) + public void onEntityRemove(ChunkUnloadEvent event) { + Set careAbout = new HashSet<>(); for (Entity entity : event.getChunk().getEntities()) { if (_spawnPacketMap.containsKey(entity.getEntityId())) { - _entityDisguiseMap.put(entity.getUniqueId().toString(), _spawnPacketMap.get(entity.getEntityId())); - _spawnPacketMap.remove(entity.getEntityId()); - _lastRabbitHop.remove(entity.getEntityId()); + careAbout.add(entity); } } - } - public void clearDisguises() - { - _spawnPacketMap.clear(); - _movePacketMap.clear(); - _moveTempMap.clear(); - _goingUp.clear(); - _entityDisguiseMap.clear(); - _disguisePlayerMap.clear(); - - if (_bedPackets) + // Run it a tick later so that if someone else happened to cancel the event, we won't fall for it + runSync(() -> { - unregisterBedChunk(); - } - } - - private boolean containsSpawnDisguise(Player owner, int entityId) - { - return _spawnPacketMap.containsKey(entityId) - && (_spawnPacketMap.get(entityId).Global || (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap - .get(_spawnPacketMap.get(entityId)).contains(owner))); - } - - public void disguise(DisguiseBase disguise, boolean refreshTrackers, Player... players) - { - if (!disguise.GetEntity().isAlive()) - return; - - if (!_bedPackets && disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null) - { - _bedPackets = true; - - for (Player player : Bukkit.getOnlinePlayers()) + for (Entity entity : careAbout) { - UtilPlayer.sendPacket(player, getBedChunkLoadPackets(player, player.getLocation())); - } - } - - if (players.length != 0) - { - disguise.Global = false; - } - - _spawnPacketMap.put(disguise.GetEntityId(), disguise); - _disguisePlayerMap.put(disguise, new HashSet()); - - if (disguise instanceof DisguiseRabbit) - { - _lastRabbitHop.put(disguise.GetEntityId(), new NautHashMap()); - } - - for (Player player : players) - addViewerToDisguise(disguise, player, false); - - if (disguise.GetEntity() instanceof EntityPlayer && disguise instanceof DisguisePlayer) - { - if (!(disguise.GetEntity()).getName().equalsIgnoreCase(((DisguisePlayer) disguise).getName())) - { - _blockedNames.add((disguise.GetEntity()).getName()); - } - } - - if (refreshTrackers) - { - refreshTrackers(disguise.GetEntity().getBukkitEntity(), - disguise.Global ? Bukkit.getOnlinePlayers().toArray(new Player[0]) : players); - } - } - - public void disguise(DisguiseBase disguise, Player... players) - { - disguise(disguise, true, players); - } - - public PacketPlayOutMapChunk[] getBedChunkLoadPackets(Player player, Location newLoc) - { - prepareChunk(newLoc); - - PacketPlayOutMapChunk[] packets = new PacketPlayOutMapChunk[2]; - - // Make unload - packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0); - - // Make load - packets[1] = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff'); - - return packets; - } - - public Packet getBedChunkUnloadPacket(Player player, Location oldLoc) - { - prepareChunk(oldLoc); - - return new PacketPlayOutMapChunk(_bedChunk, true, 0); - } - - private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise) - { - try - { - PacketPlayOutBed bedPacket = new PacketPlayOutBed(); - - bedPacket.a = playerDisguise.GetEntityId(); - - int chunkX = getChunk(recieving.getX()); - int chunkZ = getChunk(recieving.getZ()); - - bedPacket.b = new BlockPosition((chunkX * 16) + 1 + playerDisguise.getSleepingDirection().getModX(), 0, (chunkZ * 16) - + 1 + playerDisguise.getSleepingDirection().getModZ()); - - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity()); - - teleportPacket.c += (int) (0.35D * 32); - - return new Packet[] + if (!entity.isValid()) { - bedPacket, teleportPacket - }; - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - return null; + _entityDisguiseMap.put(entity.getUniqueId(), _spawnPacketMap.remove(entity.getEntityId())); + } + } + }); } - private int getChunk(double block) + private boolean containsSpawnDisguise(Player owner, DisguiseBase disguise) { - int chunk = (int) Math.floor(block / 16D) - 17; - chunk -= chunk % 8; - return chunk; + return disguise != null && (_disguisePlayerMap.containsKey(disguise) && _disguisePlayerMap.get(disguise).test(owner)); } - private ArrayList getChunkMovePackets(Player player, Location newLoc, Location oldLoc) + public void disguise(DisguiseBase disguise, Runnable after) { - ArrayList packets = new ArrayList(); + disguise(disguise, after, player -> true); + } - if (newLoc != null) + public void disguise(DisguiseBase disguise, Predicate accept) + { + disguise(disguise, null, accept); + } + + public void disguise(DisguiseBase disguise) + { + disguise(disguise, null, t -> true); + } + + public void disguise(DisguiseBase disguise, Runnable after, Predicate accept) + { + UtilTasks.onMainThread(() -> { - packets.addAll(Arrays.asList(getBedChunkLoadPackets(player, newLoc))); + // First, add everything to handle future disguises + DisguiseBase before = null; - EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + LinkedList disguises = _spawnPacketMap.computeIfAbsent(disguise.getEntityId(), key -> new LinkedList<>()); - for (Entry> entry : _disguisePlayerMap.entrySet()) + before = disguises.peekFirst(); + + disguises.addFirst(disguise); + + _disguisePlayerMap.put(disguise, accept); + + // If the entity hasn't been spawned in yet, try to spawn it in and if that fails, remove everything + + boolean spawnedIn = false; + + if (!disguise.getEntity().valid) { - if (entry.getKey().Global || entry.getValue().contains(player)) + disguise.attemptToSpawn(); + if (!disguise.getEntity().valid) { - EntityTrackerEntry tracker = getEntityTracker(entry.getKey().GetEntity()); + disguises.remove(disguise); + _disguisePlayerMap.remove(disguise); + return; + } + spawnedIn = true; + } - if (tracker != null && tracker.trackedPlayers.contains(nmsPlayer)) + if (before != null) + { + before.onTransfer(disguise); + } + + // todo figure out what this does + if (disguise.getEntity() instanceof EntityPlayer && disguise instanceof DisguisePlayer) + { + if (!(disguise.getEntity()).getName().equalsIgnoreCase(((DisguisePlayer) disguise).getName())) + { + _blockedNames.add(disguise.getEntity().getName()); + } + } + + if (!spawnedIn) + { + refreshTrackers(disguise.getEntity().getBukkitEntity()); + } + + disguise.onDisguise(true); + + if (after != null) + { + after.run(); + } + }).run(); + } + + public boolean undisguise(DisguiseBase originalDisguise) + { + return undisguise(originalDisguise, UndisguiseReason.EXPLICIT); + } + + public boolean undisguise(DisguiseBase originalDisguise, UndisguiseReason reason) + { + if (originalDisguise == null) return false; + if (originalDisguise.getEntity() == null) return false; + + net.minecraft.server.v1_8_R3.Entity entity = originalDisguise.getEntity(); + + LinkedList activeDisguises = this._spawnPacketMap.get(originalDisguise.getEntityId()); + + if (activeDisguises == null) return false; + + if (!activeDisguises.contains(originalDisguise)) return false; + + if (entity.getBukkitEntity() instanceof Player) + { + _blockedNames.remove(entity.getName()); + } + + Predicate test = _disguisePlayerMap.remove(originalDisguise); + + if (originalDisguise instanceof DisguisePlayer) + { + for (Player player : UtilServer.getPlayersCollection()) + { + if (test.test(player)) + { + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + entityPlayer.playerConnection.networkManager.handle(((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(true)); + if (reason != UndisguiseReason.QUIT) { - if (entry.getKey() instanceof DisguisePlayer - && ((DisguisePlayer) entry.getKey()).getSleepingDirection() != null) - { - - packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey()))); - } + entityPlayer.playerConnection.networkManager.handle(((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(false)); } } } } - if (oldLoc != null) + int index = activeDisguises.indexOf(originalDisguise); + + activeDisguises.remove(originalDisguise); + + if (activeDisguises.size() == 0) + _spawnPacketMap.remove(originalDisguise.getEntityId()); + + if (index == 0) { - packets.add(getBedChunkUnloadPacket(player, oldLoc)); + originalDisguise.onUndisguise(true); + if (activeDisguises.size() > 0) + { + activeDisguises.getFirst().onReturn(originalDisguise); + } + + if (reason != UndisguiseReason.QUIT) + { + refreshTrackers(entity.getBukkitEntity()); + } + } + else + { + originalDisguise.onUndisguise(false); } - return packets; + return true; } + @Deprecated + public void undisguise(Entity entity) + { + undisguise(getActiveDisguise(entity), UndisguiseReason.EXPLICIT); + } + + @Deprecated + /* + * @Deprecated Use getActiveDisguise instead + */ public DisguiseBase getDisguise(LivingEntity entity) + { + return getActiveDisguise(entity); + } + + public DisguiseBase getActiveDisguise(Entity entity) + { + return getActiveDisguise(entity.getEntityId()); + } + + public DisguiseBase getActiveDisguise(int entityId) + { + LinkedList list = _spawnPacketMap.get(entityId); + if (list != null && list.size() > 0) + { + return list.getFirst(); + } + return null; + } + + public LinkedList getAllDisguises(Entity entity) { return _spawnPacketMap.get(entity.getEntityId()); } private EntityTrackerEntry getEntityTracker(net.minecraft.server.v1_8_R3.Entity entity) { - return (EntityTrackerEntry) ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); + return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); } public void handle(PacketInfo packetInfo) @@ -478,69 +339,27 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler final Player owner = packetInfo.getPlayer(); final PacketVerifier packetVerifier = packetInfo.getVerifier(); - if (packet instanceof PacketPlayOutRelEntityMoveLook || packet instanceof PacketPlayOutRelEntityMove) - { - int entityId = -1; - - if (packet instanceof PacketPlayOutRelEntityMoveLook) - { - entityId = ((PacketPlayOutRelEntityMoveLook) packet).a; - }/* - else if (packet instanceof PacketPlayOutEntityLook) - { - entityId = ((PacketPlayOutEntityLook) packet).a; - }*/ - else if (packet instanceof PacketPlayOutRelEntityMove) - { - PacketPlayOutRelEntityMove rPacket = (PacketPlayOutRelEntityMove) packet; - - if (rPacket.b != 0 || rPacket.c != 0 || rPacket.d != 0) - { - entityId = rPacket.a; - } - } - /*else if (packet instanceof PacketPlayOutEntityTeleport) - { - entityId = ((PacketPlayOutEntityTeleport) packet).a; - }*/ - - if (_lastRabbitHop.containsKey(entityId)) - { - NautHashMap rabbitHops = _lastRabbitHop.get(entityId); - - if (rabbitHops != null) - { - long last = rabbitHops.containsKey(owner.getEntityId()) ? System.currentTimeMillis() - - rabbitHops.get(owner.getEntityId()) : 1000; - - if (last > 500 || last < 100) - { - rabbitHops.put(owner.getEntityId(), System.currentTimeMillis()); - - PacketPlayOutEntityStatus entityStatus = new PacketPlayOutEntityStatus(); - - entityStatus.a = entityId; - entityStatus.b = (byte) 1; - - handlePacket(entityStatus, packetVerifier); - } - } - } - } - if (packet instanceof PacketPlayOutPlayerInfo) { - for (PlayerInfoData info : ((PacketPlayOutPlayerInfo) packet).b) + PacketPlayOutPlayerInfo packetPlayOutPlayerInfo = ((PacketPlayOutPlayerInfo) packet); + Iterator iterator = packetPlayOutPlayerInfo.b.iterator(); + while (iterator.hasNext()) { - if (_blockedNames.contains(info.a().getName())) + PacketPlayOutPlayerInfo.PlayerInfoData next = iterator.next(); + if (_blockedNames.contains(next.a().getName())) { - packetInfo.setCancelled(true); - break; + iterator.remove(); } } + + if (packetPlayOutPlayerInfo.b.size() == 0) + { + packetInfo.setCancelled(true); + } } - else if (packet instanceof PacketPlayOutSpawnEntity || packet instanceof PacketPlayOutSpawnEntityLiving - || packet instanceof PacketPlayOutNamedEntitySpawn) + else if (packet instanceof PacketPlayOutSpawnEntity || + packet instanceof PacketPlayOutSpawnEntityLiving || + packet instanceof PacketPlayOutNamedEntitySpawn) { int entityId = -1; @@ -557,271 +376,128 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler entityId = ((PacketPlayOutNamedEntitySpawn) packet).a; } - if (_futureDisguises.containsKey(entityId)) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null) { - Entry entry = _futureDisguises.remove(entityId); - - Entity entity = UtilEnt.getEntityById(entityId); - - if (entity != null) + if (containsSpawnDisguise(owner, latestDisguise)) { - entry.getKey().setEntity(entity); + packetInfo.setCancelled(true); - boolean cancel = entry.getValue().length == 0; - - for (Player player : entry.getValue()) - { - if (player == owner) - { - cancel = true; - break; - } - } - - if (cancel) - { - packetInfo.setCancelled(true); - } - - disguise(entry.getKey(), false, entry.getValue()); + handleSpawnPackets(packetInfo.getVerifier(), latestDisguise); + } + else if (latestDisguise.isHideIfNotDisguised()) + { + packetInfo.setCancelled(true); } - } - - if (_spawnPacketMap.containsKey(entityId) - && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains( - owner))) - { - packetInfo.setCancelled(true); - - handleSpawnPackets(packetInfo, _spawnPacketMap.get(entityId)); } } else if (packet instanceof PacketPlayOutUpdateAttributes) { int entityId = ((PacketPlayOutUpdateAttributes) packet).a; - if (_spawnPacketMap.containsKey(entityId) - && owner.getEntityId() != entityId - && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains( - owner))) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise)) { // Crash clients with meta to a block id. - if (_spawnPacketMap.get(entityId) instanceof DisguiseBlock) + if (latestDisguise instanceof DisguiseBlock) packetInfo.setCancelled(true); } } - /* - * Why is this here??? - else if (packet instanceof PacketPlayOutAnimation) - { - int entityId = ((PacketPlayOutAnimation) packet).a; - - if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId) - { - packetInfo.setCancelled(true); - } - } - */ else if (packet instanceof PacketPlayOutEntityMetadata) { int entityId = ((PacketPlayOutEntityMetadata) packet).a; - if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && owner.getEntityId() != entityId) { - handlePacket(_spawnPacketMap.get(entityId).GetMetaDataPacket(), packetVerifier); packetInfo.setCancelled(true); + handlePacket(latestDisguise.getMetadataPacket(), packetVerifier); } } else if (packet instanceof PacketPlayOutEntityEquipment) { int entityId = ((PacketPlayOutEntityEquipment) packet).a; - if (containsSpawnDisguise(owner, entityId) && _spawnPacketMap.get(entityId) instanceof DisguiseInsentient) + DisguiseBase latestDisguise = getActiveDisguise(entityId); + + if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && latestDisguise instanceof DisguiseInsentient) { - if (!((DisguiseInsentient) _spawnPacketMap.get(entityId)).armorVisible() - && ((PacketPlayOutEntityEquipment) packet).b != 0) + if (!((DisguiseInsentient) latestDisguise).armorVisible() && ((PacketPlayOutEntityEquipment) packet).b != 0) { packetInfo.setCancelled(true); } } } - else if (packet instanceof PacketPlayOutEntityVelocity) - { - PacketPlayOutEntityVelocity velocityPacket = (PacketPlayOutEntityVelocity) packet; - - // Only for viewers - if (velocityPacket.a == owner.getEntityId()) - { - if (velocityPacket.c > 0) - _goingUp.add(velocityPacket.a); - } - else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0) - { - return; - } - else if (_spawnPacketMap.containsKey(velocityPacket.a)) - { - packetInfo.setCancelled(true); - } - } - else if (packet instanceof PacketPlayOutRelEntityMove) - { - final PacketPlayOutRelEntityMove movePacket = (PacketPlayOutRelEntityMove) packet; - - // Only for viewers - if (movePacket.a == owner.getEntityId()) - return; - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20) - { - _goingUp.remove(movePacket.a); - _movePacketMap.remove(movePacket.a); - } - - if (!containsSpawnDisguise(owner, movePacket.a)) - return; - - final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(); - velocityPacket.a = movePacket.a; - velocityPacket.b = movePacket.b * 100; - velocityPacket.c = movePacket.c * 100; - velocityPacket.d = movePacket.d * 100; - - if (_movePacketMap.containsKey(movePacket.a)) - { - PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a); - - velocityPacket.b = (int) (.8 * lastVelocityPacket.b); - velocityPacket.c = (int) (.8 * lastVelocityPacket.c); - velocityPacket.d = (int) (.8 * lastVelocityPacket.d); - } - - _movePacketMap.put(movePacket.a, velocityPacket); - - packetVerifier.bypassProcess(velocityPacket); - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20) - { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - packetVerifier.bypassProcess(velocityPacket); - } - }); - } - - if (_spawnPacketMap.get(movePacket.a) instanceof DisguiseBlock) - { - - } - } - else if (packet instanceof PacketPlayOutRelEntityMoveLook) - { - final PacketPlayOutRelEntityMoveLook movePacket = (PacketPlayOutRelEntityMoveLook) packet; - - // Only for viewers - if (movePacket.a == owner.getEntityId()) - return; - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20) - { - _goingUp.remove(movePacket.a); - _movePacketMap.remove(movePacket.a); - } - - if (!containsSpawnDisguise(owner, movePacket.a)) - return; - - final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(); - velocityPacket.a = movePacket.a; - velocityPacket.b = movePacket.b * 100; - velocityPacket.c = movePacket.c * 100; - velocityPacket.d = movePacket.d * 100; - - if (_movePacketMap.containsKey(movePacket.a)) - { - PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a); - - velocityPacket.b = (int) (.8 * lastVelocityPacket.b); - velocityPacket.c = (int) (.8 * lastVelocityPacket.c); - velocityPacket.d = (int) (.8 * lastVelocityPacket.d); - } - - _movePacketMap.put(movePacket.a, velocityPacket); - - packetVerifier.bypassProcess(velocityPacket); - - if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20) - { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - packetVerifier.bypassProcess(velocityPacket); - } - }); - } - } } private void handlePacket(Packet packet, PacketVerifier verifier) { + if (packet == null) return; _handlingPacket = true; verifier.process(packet); _handlingPacket = false; } - private void handleSpawnPackets(PacketInfo packetInfo, DisguiseBase disguise) + private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise) { - final Player player = packetInfo.getPlayer(); - - final PacketVerifier packetVerifier = packetInfo.getVerifier(); - if (disguise instanceof DisguisePlayer) { - final DisguisePlayer pDisguise = (DisguisePlayer) disguise; - handlePacket(pDisguise.getNewInfoPacket(true), packetVerifier); - - PacketPlayOutNamedEntitySpawn namePacket = pDisguise.spawnBeforePlayer(player.getLocation()); - - namePacket.i.watch(0, (byte) 32, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 32); - - handlePacket(namePacket, packetVerifier); - - if (pDisguise.getSleepingDirection() != null) + Packet infoPacket = pDisguise.getDisguiseInfoPackets(false); + if (infoPacket != null) { - for (Packet packet : getBedPackets(player.getLocation(), pDisguise)) - { - handlePacket(packet, packetVerifier); - } + handlePacket(infoPacket, packetVerifier); + } - } - else + infoPacket = pDisguise.getDisguiseInfoPackets(true); + if (infoPacket != null) { - handlePacket(new PacketPlayOutEntityTeleport(pDisguise.GetEntity()), packetVerifier); + handlePacket(infoPacket, packetVerifier); } + handlePacket(pDisguise.getSpawnPacket(), packetVerifier); + for (Packet packet : pDisguise.getEquipmentPackets()) { handlePacket(packet, packetVerifier); } - handlePacket(pDisguise.GetMetaDataPacket(), packetVerifier); + handlePacket(pDisguise.getMetadataPacket(), packetVerifier); - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + if (pDisguise.getSleepingDirection() != null) { - public void run() + for (Packet packet : getBedPackets(pDisguise)) { - handlePacket(pDisguise.getNewInfoPacket(false), packetVerifier); + handlePacket(packet, packetVerifier); } - }, 6); + } + + if (!pDisguise.showInTabList()) + { + Runnable r = () -> + { + PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(pDisguise.getProfile(), 0, WorldSettings.EnumGamemode.SURVIVAL, null); + playerInfoPacketRemove.b.add(dataRemove); + handlePacket(playerInfoPacketRemove, packetVerifier); + }; + if (pDisguise.getShowInTabListDelay() == 0) + { + r.run(); + } + else + { + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), r, pDisguise.getShowInTabListDelay()); + } + } } else { - handlePacket(disguise.GetSpawnPacket(), packetVerifier); + handlePacket(disguise.getSpawnPacket(), packetVerifier); if (disguise instanceof DisguiseLiving) { @@ -840,233 +516,80 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler return _spawnPacketMap.containsKey(entity.getEntityId()); } - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void PlayerQuit(PlayerQuitEvent event) { - for (DisguiseBase disguise : _disguisePlayerMap.keySet()) - { - _disguisePlayerMap.get(disguise).remove(event.getPlayer()); - } - - for (Integer disguise : _lastRabbitHop.keySet()) - { - _lastRabbitHop.get(disguise).remove(event.getPlayer().getEntityId()); - } - - undisguise(event.getPlayer()); + while (getActiveDisguise(event.getPlayer()) != null) + undisguise(getActiveDisguise(event.getPlayer()), UndisguiseReason.QUIT); } - private void prepareChunk(Location loc) + private void refreshTrackers(Entity entity) { - int chunkX = getChunk(loc.getX()); - int chunkZ = getChunk(loc.getZ()); + DisguiseBase activeDisguise = getActiveDisguise(entity); + Predicate tester = _disguisePlayerMap.getOrDefault(activeDisguise, test -> true); - try - { - _xChunk.set(_bedChunk, chunkX); - _zChunk.set(_bedChunk, chunkZ); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private void refreshBedTrackers(final Player player) - { - for (final DisguiseBase disguise : this._disguisePlayerMap.keySet()) - { - if (!(disguise instanceof DisguisePlayer) || ((DisguisePlayer) disguise).getSleepingDirection() == null) - { - continue; - } - - final EntityTrackerEntry entityTracker = getEntityTracker(disguise.GetEntity()); - - if (entityTracker != null) - { - if (!entityTracker.trackedPlayers.contains(((CraftPlayer) player).getHandle())) - { - continue; - } - - Packet destroyPacket = new PacketPlayOutEntityDestroy(new int[] - { - disguise.GetEntityId() - }); - - entityTracker.clear(((CraftPlayer) player).getHandle()); - - UtilPlayer.sendPacket(player, destroyPacket); - - final World world = disguise.GetEntity().getBukkitEntity().getWorld(); - - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - try - { - Entity entity = disguise.GetEntity().getBukkitEntity(); - - if (entity.getWorld() == world && entity.isValid()) - { - if (player.isOnline() && player.getWorld() == entity.getWorld()) - { - entityTracker.updatePlayer(((CraftPlayer) player).getHandle()); - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - }, 5); - } - } - } - - private void refreshTrackers(final Entity entity, final Player[] players) - { final EntityTrackerEntry entityTracker = getEntityTracker(((CraftEntity) entity).getHandle()); if (entityTracker != null) { - Packet destroyPacket = new PacketPlayOutEntityDestroy(new int[] - { - entity.getEntityId() - }); - - for (Player player : players) + if (entity.isValid()) { - entityTracker.clear(((CraftPlayer) player).getHandle()); - - UtilPlayer.sendPacket(player, destroyPacket); - } - - final World world = entity.getWorld(); - - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() + for (Player player : PlayerSelector.selectPlayers( + PlayerSelector.and( + PlayerSelector.inWorld(entity.getWorld()), + OfflinePlayer::isOnline, + tester + ) + ) + ) { - try + EntityPlayer handle = ((CraftPlayer) player).getHandle(); + entityTracker.clear(handle); + runSyncLater(() -> { - if (entity.getWorld() == world && entity.isValid()) - { - for (Player player : players) - { - if (player.isOnline() && player.getWorld() == entity.getWorld()) - { - entityTracker.updatePlayer(((CraftPlayer) player).getHandle()); - } - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - }, 5); - } - } - - public void removeViewerToDisguise(DisguiseBase disguise, Player player) - { - _disguisePlayerMap.get(disguise).remove(player); - - refreshTrackers(disguise.GetEntity().getBukkitEntity(), new Player[] - { - player - }); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void switchedWorld(PlayerChangedWorldEvent event) - { - if (!_bedPackets) - return; - - chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null); - } - - @EventHandler - public void TeleportDisguises(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - TimingManager.startTotal("Teleport Disguises"); - for (Player player : Bukkit.getOnlinePlayers()) - { - for (Player otherPlayer : Bukkit.getOnlinePlayers()) - { - if (player == otherPlayer) - continue; - - if (otherPlayer.getLocation().subtract(0, .5, 0).getBlock().getTypeId() != 0) - UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport( - ((CraftPlayer) otherPlayer).getHandle())); - } - } - TimingManager.stopTotal("Teleport Disguises"); - } - - public void undisguise(LivingEntity entity) - { - if (!_spawnPacketMap.containsKey(entity.getEntityId())) - return; - - _lastRabbitHop.remove(entity.getEntityId()); - DisguiseBase disguise = _spawnPacketMap.remove(entity.getEntityId()); - Collection players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.remove(disguise)); - - _movePacketMap.remove(entity.getEntityId()); - _moveTempMap.remove(entity.getEntityId()); - - if (entity instanceof Player) - { - _blockedNames.remove(((Player) entity).getName()); - } - - refreshTrackers(entity, players.toArray(new Player[0])); - - if (_bedPackets && disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null) - { - for (DisguiseBase dis : _disguisePlayerMap.keySet()) - { - if (dis instanceof DisguisePlayer && ((DisguisePlayer) dis).getSleepingDirection() != null) - { - return; + /* + * This is like, the hackiest shit ever. + * + * Basically, we need to delay by an arbitrary amount of ticks (in this case, 5) because of the client. + * + * In the client, the renderer renders batches of 16x16x16, and entites are stored in ChunkSections. + * However, the data structure used is a HashMultimap, and the hashCode() method for Entity simply returns its entity id + * + * Now, due to an unfortunate coincidence, sending a PacketPlayOutEntityDestroy does not immediately remove an entity from the client. + * Instead, it queues it for removal on the next tick (why tf). This means that if we send a destroy and spawn packet one after the other, + * the process looks something like this + * + * Received PacketPlayOutEntityDestroy + * Queue removal of original entity + * Received PacketPlayOutSpawnLivingEntity + * Register entity in ChunkSection (based on entity id) + * --- next tick --- + * Removal of original entity from ChunkSection (which is now the new disguised entity + * + * So, what can we do? + * + * We could do this, where we delay an arbitrary amount of time and hope that the client processes the tick. + * However, a better long term solution would be to rewrite entity ids properly + */ + entityTracker.updatePlayer(((CraftPlayer) player).getHandle()); + }, 5L); } } - - unregisterBedChunk(); - } - } - - private void unregisterBedChunk() - { - _bedPackets = false; - - for (Player player : Bukkit.getOnlinePlayers()) - { - chunkMove(player, null, player.getLocation()); } } public void updateDisguise(DisguiseBase disguise) { - Collection players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise)); - - for (Player player : players) + Predicate tester = _disguisePlayerMap.get(disguise); + for (Player player : Bukkit.getOnlinePlayers()) { - if (disguise.GetEntity() == ((CraftPlayer) player).getHandle()) - continue; + if (tester.test(player)) + { + if (disguise.getEntity() == ((CraftPlayer) player).getHandle()) + continue; - UtilPlayer.sendPacket(player, disguise.GetMetaDataPacket()); + UtilPlayer.sendPacket(player, disguise.getMetadataPacket()); + } } } @@ -1076,27 +599,154 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (event.getType() != UpdateType.SLOWER || _disguisePlayerMap.isEmpty()) return; - for (Iterator disguiseIterator = _disguisePlayerMap.keySet().iterator(); disguiseIterator.hasNext();) + for (Iterator disguiseIterator = _disguisePlayerMap.keySet().iterator(); disguiseIterator.hasNext(); ) { DisguiseBase disguise = disguiseIterator.next(); - if (!(disguise.GetEntity() instanceof EntityPlayer)) + if (!(disguise.getEntity() instanceof EntityPlayer)) continue; - EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity(); + EntityPlayer disguisedPlayer = (EntityPlayer) disguise.getEntity(); if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid) disguiseIterator.remove(); - else - { - for (Iterator playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();) - { - Player player = playerIterator.next(); - - if (!player.isOnline() || !player.isValid()) - playerIterator.remove(); - } - } } } + + public enum UndisguiseReason + { + EXPLICIT, + QUIT + } + + /* + * ================================= + * HERE BEGINS STUFF SOLELY TO DEAL + * WITH MAKING PLAYERS LOOK LIKE + * THEY'RE ON BEDS + * + * DON'T TOUCH UNLESS YOU KNOW + * EXACTLY WHAT YOU'RE DOING + * ================================= + */ + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void switchedWorld(PlayerChangedWorldEvent event) + { + chunkMove(event.getPlayer()); + } + + @EventHandler + public void chunkJoin(PlayerJoinEvent event) + { + chunkMove(event.getPlayer()); + } + + private void chunkMove(Player player) + { + List packets = new ArrayList<>(); + + PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff'); + chunk.a = BED_POS_NORTH[0] >> 4; + chunk.b = BED_POS_NORTH[2] >> 4; + + packets.add(chunk); + + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + + _spawnPacketMap.entrySet().stream() + .filter(entry -> entry.getValue().size() > 0 && entry.getValue().getFirst() instanceof DisguisePlayer && ((DisguisePlayer) entry.getValue().getFirst()).getSleepingDirection() != null) + .filter(entry -> this.containsSpawnDisguise(player, entry.getValue().getFirst())) + .forEach(entry -> + { + EntityTrackerEntry tracker = getEntityTracker(entry.getValue().getFirst().getEntity()); + + if (tracker != null && tracker.trackedPlayers.contains(nmsPlayer)) + { + packets.addAll(getBedPackets((DisguisePlayer) entry.getValue().getFirst())); + } + }); + + for (Packet packet : packets) + { + UtilPlayer.sendPacket(player, packet); + } + } + + /* + * Create the packets needed to make this DisguisePlayer appear as though laying on a bed + * + * fixme can we make this better at all?!?!?! + */ + private List getBedPackets(DisguisePlayer playerDisguise) + { + int[] coords = getCoordsFor(playerDisguise); + + List packets = new ArrayList<>(); + PacketPlayOutBed bedPacket = new PacketPlayOutBed(); + bedPacket.a = playerDisguise.getEntityId(); + bedPacket.b = new BlockPosition(coords[0], coords[1], coords[2]); + packets.add(bedPacket); + + int partitions = 3; + double posX = coords[0], posY = coords[1], posZ = coords[2]; + double targetX = playerDisguise.getEntity().locX, targetY = playerDisguise.getEntity().locY, targetZ = playerDisguise.getEntity().locZ; + + while (partitions > 1) + { + double d0 = posX + (targetX - posX) / (double) partitions; + double d1 = posY + (targetY - posY) / (double) partitions; + double d2 = posZ + (targetZ - posZ) / (double) partitions; + + + PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff'); + chunk.a = (int) Math.floor(d0) >> 4; + chunk.b = (int) Math.floor(d2) >> 4; + packets.add(chunk); + partitions--; + + posX = d0; + posY = d1; + posZ = d2; + } + + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.getEntity()); + packets.add(teleportPacket); + + return packets; + } + + + private static final int[] BED_POS_NORTH = {-29999999, 0, -29999999}; + private static final int[] BED_POS_SOUTH = {-29999999, 0, -29999998}; + private static final int[] BED_POS_EAST = {-29999999, 0, -29999997}; + private static final int[] BED_POS_WEST = {-29999999, 0, -29999996}; + + private Chunk _bedChunk; + + private void createBedChunk() + { + this._bedChunk = new Chunk(MinecraftServer.getServer().getWorld(), 0, 0); + this._bedChunk.a(new BlockPosition(BED_POS_NORTH[0], BED_POS_NORTH[1], BED_POS_NORTH[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.NORTH)); + this._bedChunk.a(new BlockPosition(BED_POS_SOUTH[0], BED_POS_SOUTH[1], BED_POS_SOUTH[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.SOUTH)); + this._bedChunk.a(new BlockPosition(BED_POS_EAST[0], BED_POS_EAST[1], BED_POS_EAST[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.EAST)); + this._bedChunk.a(new BlockPosition(BED_POS_WEST[0], BED_POS_WEST[1], BED_POS_WEST[2]), Blocks.BED.getBlockData().set(BlockBed.FACING, EnumDirection.WEST)); + } + + private int[] getCoordsFor(DisguisePlayer player) + { + BlockFace facing = player.getSleepingDirection(); + switch (facing) + { + case NORTH: + return BED_POS_SOUTH; + case SOUTH: + return BED_POS_NORTH; + case EAST: + return BED_POS_WEST; + case WEST: + return BED_POS_EAST; + } + throw new IllegalArgumentException("Unsupported blockface " + facing); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java deleted file mode 100644 index 3403768bb..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java +++ /dev/null @@ -1,34 +0,0 @@ -package mineplex.core.disguise; - -import mineplex.serverdata.data.Data; - -public class DisguisePlayerBean implements Data -{ - private int _accountID; - private String _disguisedPlayer; - private String _playerName; - public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs) - { - this._accountID = playerAccountID; - this._disguisedPlayer = disguiseAs; - this._playerName = playerName; - - } - public int getAccountID() - { - return _accountID; - } - public String getDisguisedPlayer() - { - return _disguisedPlayer; - } - public String getPlayerName() - { - return _playerName; - } - @Override - public String getDataId() - { - return _accountID+_playerName; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java deleted file mode 100644 index 82e27bb5f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.core.disguise; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.serverdata.Region; -import mineplex.serverdata.redis.RedisDataRepository; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -public class PlayerDisguiseManager extends MiniPlugin -{ - private CoreClientManager _clients; - private RedisDataRepository _redis; - public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients) - { - super("Player Disguise Manager", plugin); - this._clients = clients; - - _redis = new RedisDataRepository(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); - } - - @EventHandler - public void onDisguisedPlayerQuit(PlayerQuitEvent event) - { - CoreClient client = _clients.Get(event.getPlayer()); - if(client.isDisguised()) - { - _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours - } - } - - @EventHandler - public void onDisguisedPlayerJoin(PlayerJoinEvent event) - { - new BukkitRunnable() - { - @Override - public void run() - { - CoreClient client = _clients.Get(event.getPlayer()); - - if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE) - return; - - if(_redis.elementExists(client.getAccountId()+client.GetPlayerName())) - { - DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName()); - Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer())); - event.setJoinMessage(""); - } - } - }.runTaskLater(getPlugin(), 7); - } - - @EventHandler - public void onPlayerUndisguise(PlayerUndisguiseEvent event) - { - CoreClient client = _clients.Get(event.getPlayer()); - _redis.removeElement(client.getAccountId()+client.GetPlayerName()); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java index 547787e0d..d72e9aafb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java @@ -1,9 +1,11 @@ package mineplex.core.disguise.disguises; +import org.bukkit.entity.EntityType; + public abstract class DisguiseAmbient extends DisguiseInsentient { - public DisguiseAmbient(org.bukkit.entity.Entity entity) + public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity) { - super(entity); + super(entityType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java index 520ef6ff2..ed3cade7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java @@ -1,5 +1,6 @@ package mineplex.core.disguise.disguises; +import org.bukkit.entity.EntityType; import org.bukkit.util.Vector; import net.minecraft.server.v1_8_R3.EntityArmorStand; @@ -12,7 +13,7 @@ public class DisguiseArmorStand extends DisguiseInsentient { public DisguiseArmorStand(org.bukkit.entity.Entity entity) { - super(entity); + super(EntityType.ARMOR_STAND, entity); DataWatcher.a(10, (byte) 0, EntityArmorStand.META_ARMOR_OPTION, (byte) 0); @@ -47,7 +48,7 @@ public class DisguiseArmorStand extends DisguiseInsentient } @Override - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 5b325b952..7c742b3c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -1,12 +1,5 @@ package mineplex.core.disguise.disguises; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.entity.Player; - import mineplex.core.common.DummyEntity; import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; @@ -14,48 +7,72 @@ import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityTrackerEntry; import net.minecraft.server.v1_8_R3.IntHashMap; +import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; import net.minecraft.server.v1_8_R3.WorldServer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public abstract class DisguiseBase { protected Entity Entity; protected DataWatcher DataWatcher; - + private DisguiseBase _soundDisguise; - - public boolean Global = true; - - public DisguiseBase(org.bukkit.entity.Entity entity) - { - if (entity != null) + + private EntityType _disguiseType; + + /** + * Whether the disguised entity should be entirely hidden from a player if that player does not receive the disguise + */ + private boolean _hideIfNotDisguised = false; + + public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity) + { + if (entity == null) { - setEntity(entity); + throw new NullPointerException("Entity cannot be null (did you mean to pass in an unspawned entity?)"); } + this._disguiseType = entityType; + + setEntity(entity); + DataWatcher = new DataWatcher(new DummyEntity(null)); - DataWatcher.a(0, Byte.valueOf((byte) 0), Entity.META_ENTITYDATA, (byte) 0); - DataWatcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 300); + DataWatcher.a(0, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0); + DataWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 300); _soundDisguise = this; } + public void attemptToSpawn() + { + this.Entity.world.addEntity(this.Entity, CreatureSpawnEvent.SpawnReason.CUSTOM); + } + public void setEntity(org.bukkit.entity.Entity entity) { Entity = ((CraftEntity) entity).getHandle(); } - + public void UpdateDataWatcher() { - DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0)); - DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1)); + DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0)); + DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1)); } - - public abstract Packet GetSpawnPacket(); - public Packet GetMetaDataPacket() + public abstract Packet getSpawnPacket(); + + public Packet getMetadataPacket() { UpdateDataWatcher(); return new PacketPlayOutEntityMetadata(Entity.getId(), DataWatcher, true); @@ -71,7 +88,7 @@ public abstract class DisguiseBase if (tracker.get(Entity.getId()) == null) return; - Packet packet = GetMetaDataPacket(); + Packet packet = getMetadataPacket(); for (EntityPlayer player : tracker.get(Entity.getId()).trackedPlayers) { @@ -82,53 +99,99 @@ public abstract class DisguiseBase public void setSoundDisguise(DisguiseBase soundDisguise) { _soundDisguise = soundDisguise; - + if (_soundDisguise == null) _soundDisguise = this; } - + public void playHurtSound() { Entity.world.makeSound(Entity, _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); } - - public void playHurtSound(Location location) - { - Entity.world.makeSound(location.getX(), location.getY(), location.getZ(), _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); - } - public Entity GetEntity() + public Entity getEntity() { return Entity; } - public int GetEntityId() + public int getEntityId() { return Entity.getId(); } - + protected abstract String getHurtSound(); - + protected abstract float getVolume(); - + protected abstract float getPitch(); - + public List getTrackedPlayers() { List players = new ArrayList<>(); IntHashMap tracker = ((WorldServer) Entity.world).tracker.trackedEntities; - for(EntityPlayer ep : tracker.get(Entity.getId()).trackedPlayers) + if (tracker.get(Entity.getId()) == null) + { + System.out.println("Tracker did not contain " + Entity.getId() + " " + Entity.getCustomName() + " " + Entity.dead + " " + Entity.locX + " " + Entity.locY + " " + Entity.locZ); + return Collections.emptyList(); + } + for (EntityPlayer ep : tracker.get(Entity.getId()).trackedPlayers) { players.add(ep.getBukkitEntity()); } return players; } - + public void sendPacket(Packet... packet) { - for(Player p : getTrackedPlayers()) { - UtilPlayer.sendPacket(p, packet); + List trackedPlayers = getTrackedPlayers(); + for (Packet p : packet) + { + if (p instanceof PacketPlayOutPlayerInfo) + { + MinecraftServer.getServer().getPlayerList().sendAll(p); + } + else + { + for (Player player : trackedPlayers) + { + UtilPlayer.sendPacket(player, p); + } + } } } - + + public void onDisguise(boolean isActive) + { + + } + + public void onUndisguise(boolean wasActive) + { + + } + + public void onTransfer(DisguiseBase other) + { + + } + + public void onReturn(DisguiseBase other) + { + + } + + public void setHideIfNotDisguised(boolean hideIfNotDisguised) + { + this._hideIfNotDisguised = hideIfNotDisguised; + } + + public boolean isHideIfNotDisguised() + { + return this._hideIfNotDisguised; + } + + public EntityType getDisguiseType() + { + return this._disguiseType; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java index f0406a88e..735ae8914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java @@ -5,6 +5,7 @@ import java.util.Random; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import org.bukkit.entity.EntityType; public class DisguiseBlock extends DisguiseBase { @@ -15,7 +16,7 @@ public class DisguiseBlock extends DisguiseBase public DisguiseBlock(org.bukkit.entity.Entity entity, int blockId, int blockData) { - super(entity); + super(EntityType.FALLING_BLOCK, entity); _blockId = blockId; _blockData = blockData; @@ -32,7 +33,7 @@ public class DisguiseBlock extends DisguiseBase } @Override - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java index 530f69a5c..09b3d076a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java @@ -35,5 +35,4 @@ public class DisguiseCaveSpider extends DisguiseMonster { return "mob.spider.say"; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index a1db97615..2e00319f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -7,22 +7,13 @@ import org.bukkit.entity.*; public abstract class DisguiseCreature extends DisguiseInsentient { - private final EntityType _disguiseType; - public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); - - _disguiseType = disguiseType; - } - - public EntityType getDisguiseType() - { - return _disguiseType; + super(disguiseType, entity); } @SuppressWarnings("deprecation") - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java index 5a42eb867..344af0254 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java @@ -1,12 +1,13 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityHuman; +import org.bukkit.entity.EntityType; public abstract class DisguiseHuman extends DisguiseLiving { - public DisguiseHuman(org.bukkit.entity.Entity entity) + public DisguiseHuman(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); + super(disguiseType, entity); byte skin = 0; skin |= (1 << 0); //Enable Cape diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java index 349073a17..843af0c09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java @@ -4,14 +4,15 @@ import mineplex.core.common.*; import net.minecraft.server.v1_8_R3.EntityInsentient; import org.bukkit.*; +import org.bukkit.entity.EntityType; public abstract class DisguiseInsentient extends DisguiseLiving { private boolean _showArmor; - public DisguiseInsentient(org.bukkit.entity.Entity entity) + public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); + super(disguiseType, entity); DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false); DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, ""); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java index 0f426bf2d..2a1dd6ea2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java @@ -5,6 +5,7 @@ import java.util.Random; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import net.minecraft.server.v1_8_R3.EntityLiving; @@ -17,9 +18,9 @@ public abstract class DisguiseLiving extends DisguiseBase private boolean _invisible; private ItemStack[] _equipment = new ItemStack[5]; - public DisguiseLiving(org.bukkit.entity.Entity entity) + public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(entity); + super(disguiseType, entity); DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F); DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0); @@ -88,7 +89,7 @@ public abstract class DisguiseLiving extends DisguiseBase { PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(); - packet.a = GetEntityId(); + packet.a = getEntityId(); packet.b = nmsSlot; packet.c = CraftItemStack.asNMSCopy(itemstack); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index 3bbd587b7..e39715d04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -4,12 +4,13 @@ import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.EntityType; public class DisguiseMagmaCube extends DisguiseInsentient { public DisguiseMagmaCube(org.bukkit.entity.Entity entity) { - super(entity); + super(EntityType.MAGMA_CUBE, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } @@ -24,7 +25,7 @@ public class DisguiseMagmaCube extends DisguiseInsentient return DataWatcher.getByte(16); } - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index 3e114c350..a97cd2921 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -1,80 +1,180 @@ package mineplex.core.disguise.disguises; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.block.BlockFace; - import com.mojang.authlib.GameProfile; - +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.UtilPlayer; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.IntHashMap; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; +import mineplex.core.thread.ThreadPool; +import mineplex.core.utils.UtilGameProfile; +import net.minecraft.server.v1_8_R3.AttributeInstance; +import net.minecraft.server.v1_8_R3.AttributeMapServer; import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.IInventory; +import net.minecraft.server.v1_8_R3.ITileEntityContainer; import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MobEffect; import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutAbilities; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEffect; +import net.minecraft.server.v1_8_R3.PacketPlayOutExperience; +import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.WorldServer; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; +import net.minecraft.server.v1_8_R3.PacketPlayOutPosition; +import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateHealth; import net.minecraft.server.v1_8_R3.WorldSettings; +import org.bukkit.Bukkit; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerChangedWorldEvent; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; +import java.util.function.Supplier; public class DisguisePlayer extends DisguiseHuman { - private Entity _entity; - private GameProfile _profile; - private boolean _sneaking; - private BlockFace _sleeping; - private boolean _sendSkinToSelf; + private String _requestedUsername; - public DisguisePlayer(org.bukkit.entity.Entity entity) + // If _requestedSkinData is not null, that will be used + private SkinData _requestedSkinData; + private String _requestedSkin; + + private GameProfile _originalProfile; + private GameProfile _profile; + + private BlockFace _sleeping; + + private boolean _sendSkinToSelf = true; + private boolean _showInTabList = false; + private int _showInTabListDelay = 30; + + private DisguisePlayer(Entity entity) { - super(entity); - _entity = entity; + super(EntityType.PLAYER, entity); + this._originalProfile = entity instanceof Player ? UtilGameProfile.getGameProfile((Player) entity) : null; } - public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile) + /** + * Using this constructor, this DisguisePlayer will be given the same GameProfile as provided + */ + public DisguisePlayer(Entity entity, GameProfile gameProfile) { this(entity); - setProfile(profile); + this._profile = UtilGameProfile.clone(gameProfile); } - public void setProfile(GameProfile profile) + /** + * @param username The username to disguise this player as, AND the username of the player whose skin will be used + */ + public DisguisePlayer(Entity entity, String username) { - GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName()); - - newProfile.getProperties().putAll(profile.getProperties()); - - _profile = newProfile; + this(entity, username, username); + } + + /** + * @param username The username to disguise this entity as + * @param skin The username of the player whose skin will be used + */ + public DisguisePlayer(Entity entity, String username, String skin) + { + this(entity); + + this._requestedUsername = username; + this._requestedSkin = skin; + } + + public DisguisePlayer(Entity entity, String username, SkinData skinData) + { + this(entity); + + this._requestedUsername = username; + this._requestedSkinData = skinData; + } + + /** + * If this DisguisePlayer has been initialized with a requested username and requested skin, it must be initialized + * + * @param onComplete The Runnable which will be run once initialized. Can be null. It will be run on a separate thread if initialization took place, and the current thread if not + * + * @returns A Future which, upon completion, implies the task is done + */ + public Future initialize(Runnable onComplete) + { + if (this._profile != null && this._profile.isComplete()) + { + onComplete.run(); + return CompletableFuture.completedFuture(null); + } + + return ThreadPool.ASYNC.submit(() -> + { + try + { + GameProfile profileOfUsername = UtilGameProfile.getProfileByName(_requestedUsername, true, null).get(); + + if (_requestedSkinData == null) + { + GameProfile profileOfSkin = UtilGameProfile.getProfileByName(_requestedSkin, true, null).get(); + _requestedSkinData = SkinData.constructFromGameProfile(profileOfSkin, true, true); + } + + this._profile = new GameProfile(profileOfUsername.getId(), profileOfUsername.getName()); + this._profile.getProperties().put("textures", _requestedSkinData.getProperty()); + } + catch (Exception e) + { + // fixme handle + e.printStackTrace(); + } + finally + { + onComplete.run(); + } + }, null); + } + + public GameProfile getProfile() + { + return _profile; + } + + public void setSendSkinDataToSelf(boolean sendToSelf) + { + _sendSkinToSelf = sendToSelf; + } + + public boolean getSendSkinDataToSelf() + { + return _sendSkinToSelf; + } + + public void showInTabList(boolean show, int delay) + { + this._showInTabList = show; + this._showInTabListDelay = delay; } - - public GameProfile getProfile() - { - return _profile; - } - - public void setSkinData(SkinData skin) - { - _profile.getProperties().put("textures", skin.getProperty()); - } - - /** - * Currently not working. - */ - public void setSendSkinDataToSelf(boolean sendToSelf) - { - _sendSkinToSelf = sendToSelf; - } - - public boolean getSendSkinDataToSelf() - { - return _sendSkinToSelf; - } public BlockFace getSleepingDirection() { @@ -82,31 +182,44 @@ public class DisguisePlayer extends DisguiseHuman } /** - * Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need + * Don't use this if the disguise is already on as it will not work the way you want it to. Contact samczsun if you need * that added. + *

+ * BlockFace.NORTH = feet pointing north + * BlockFace.SOUTH = feet pointing south + * etc etc */ public void setSleeping(BlockFace sleeping) { _sleeping = sleeping; } - public void setSneaking(boolean sneaking) + public PacketPlayOutPlayerInfo getDisguiseInfoPackets(boolean add) { - _sneaking = sneaking; - } + if (!add && _originalProfile == null) + return null; - public boolean getSneaking() - { - return _sneaking; - } - - public Packet getNewInfoPacket(boolean add) - { PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); newDisguiseInfo.a = add ? EnumPlayerInfoAction.ADD_PLAYER : EnumPlayerInfoAction.REMOVE_PLAYER; - PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(_profile, 90, - WorldSettings.EnumGamemode.SURVIVAL, null); + PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(add ? _profile : _originalProfile, UtilMath.r(120), + getAppropriateGamemode(), null); + + newDisguiseInfo.b.add(info); + + return newDisguiseInfo; + } + + public Packet getUndisguiseInfoPackets(boolean remove) + { + if (!remove && _originalProfile == null) + return null; + + PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo(); + newDisguiseInfo.a = remove ? EnumPlayerInfoAction.REMOVE_PLAYER : EnumPlayerInfoAction.ADD_PLAYER; + + PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(remove ? _profile : _originalProfile, UtilMath.r(120), + getAppropriateGamemode(), null); newDisguiseInfo.b.add(info); @@ -120,32 +233,26 @@ public class DisguisePlayer extends DisguiseHuman byte b0 = DataWatcher.getByte(0); - if (_sneaking) + if (Entity.isSneaking()) + { DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)), EntityHuman.META_ENTITYDATA, (byte) (b0 | 1 << 1)); + } else + { DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))), EntityHuman.META_ENTITYDATA, (byte) (b0 & ~(1 << 1))); - } + } - public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation) - { - Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30)); - loc.setY(Math.max(loc.getY(), 0)); + if (Entity instanceof EntityPlayer) + { + EntityPlayer entityPlayer = (EntityPlayer) Entity; - PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); - packet.b = _profile.getId(); - packet.c = MathHelper.floor(loc.getX() * 32.0D); - packet.d = MathHelper.floor(loc.getY() * 32.0D); - packet.e = MathHelper.floor(loc.getZ() * 32.0D); - packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F)); - packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F)); - packet.i = DataWatcher; - - return packet; + DataWatcher.watch(10, entityPlayer.getDataWatcher().getByte(10), EntityPlayer.META_SKIN, entityPlayer.getDataWatcher().getByte(10)); + DataWatcher.watch(16, (byte) 0, EntityPlayer.META_CAPE, (byte) 1); + } } @Override - public PacketPlayOutNamedEntitySpawn GetSpawnPacket() + public PacketPlayOutNamedEntitySpawn getSpawnPacket() { PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); packet.a = Entity.getId(); @@ -153,8 +260,8 @@ public class DisguisePlayer extends DisguiseHuman packet.c = MathHelper.floor(Entity.locX * 32.0D); packet.d = MathHelper.floor(Entity.locY * 32.0D); packet.e = MathHelper.floor(Entity.locZ * 32.0D); - packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); + packet.f = (byte) ((int) ((Entity.isFakeHead() ? Entity.fakePitch : Entity.pitch) * 256.0F / 360.0F)); + packet.g = (byte) ((int) ((Entity.isFakeHead() ? Entity.fakePitch : Entity.pitch) * 256.0F / 360.0F)); packet.i = DataWatcher; return packet; @@ -164,18 +271,213 @@ public class DisguisePlayer extends DisguiseHuman { return _profile.getName(); } - - public void sendHit() - { - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = GetEntityId(); - packet.b = 0; - - sendPacket(packet); - } - public org.bukkit.entity.Entity getEntity() + public void sendHit() { - return _entity; + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = getEntityId(); + packet.b = 0; + + sendPacket(packet); + } + + @Override + public void onDisguise(boolean isActive) + { + if (this.Entity instanceof EntityPlayer) + { + if (_sendSkinToSelf) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + // First construct the packet which will remove the previous disguise from the tab list + PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(_originalProfile, entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoPacketRemove.b.add(dataRemove); + + // This packet will add the new disguised name into the tab list + // We have to create a new profile with the original ID because when we respawn the caller, their UUID stays the same + PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoPacket.b.add(data); + + // This packet does the magic. It forces a new player to be created client-side which causes the skin to reload + PacketPlayOutRespawn respawnPacket = new PacketPlayOutRespawn(entityPlayer.world.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), getAppropriateGamemode()); + + entityPlayer.playerConnection.networkManager.handle(playerInfoPacketRemove); + entityPlayer.playerConnection.networkManager.handle(playerInfoPacket); + entityPlayer.playerConnection.networkManager.handle(respawnPacket); + + update(entityPlayer); + } + } + } + + @Override + public void onUndisguise(boolean wasActive) + { + if (this.Entity instanceof EntityPlayer) + { + if (_sendSkinToSelf) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + // First construct the packet which will remove the previous disguise from the tab list + PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoPacketRemove.b.add(dataRemove); + + // This packet will add the new disguised name into the tab list + // We have to create a new profile with the original ID because when we respawn the caller, their UUID stays the same + + PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(_originalProfile, entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); + playerInfoPacket.b.add(data); + + // This packet does the magic. It forces a new player to be created client-side which causes the skin to reload + PacketPlayOutRespawn respawnPacket = new PacketPlayOutRespawn(entityPlayer.world.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), getAppropriateGamemode()); + + entityPlayer.playerConnection.networkManager.handle(playerInfoPacketRemove); + entityPlayer.playerConnection.networkManager.handle(playerInfoPacket); + entityPlayer.playerConnection.networkManager.handle(respawnPacket); + + update(entityPlayer); + } + } + } + + @Override + public void onTransfer(DisguiseBase disguise) + { + if (disguise instanceof DisguisePlayer) + { + if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.Entity instanceof EntityPlayer) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + PacketPlayOutPlayerInfo playerInfoRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoRemove.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); + playerInfoRemove.b.add(data); + + entityPlayer.playerConnection.networkManager.handle(playerInfoRemove); + } + } + } + + @EventHandler + public void onReturn(DisguiseBase disguise) + { + if (disguise instanceof DisguisePlayer) + { + if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.Entity instanceof EntityPlayer) + { + EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + + PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(((DisguisePlayer) disguise)._originalProfile, entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); + playerInfoPacket.b.add(data); + + entityPlayer.playerConnection.networkManager.handle(playerInfoPacket); + + PacketPlayOutPlayerInfo playerInfoAdd = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoAdd.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); + playerInfoAdd.b.add(dataRemove); + + entityPlayer.playerConnection.networkManager.handle(playerInfoAdd); + } + } + } + + public GameProfile getOriginalProfile() + { + return UtilGameProfile.clone(_originalProfile); + } + + private void update(EntityPlayer entityPlayer) + { + // And then we teleport them back to where they were + PacketPlayOutPosition positionPacket = new PacketPlayOutPosition(entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ, entityPlayer.yaw, entityPlayer.pitch, new HashSet<>()); + + // Allow them to fly again + PacketPlayOutAbilities packetPlayOutAbilities = new PacketPlayOutAbilities(entityPlayer.abilities); + + // Give them their exp again + PacketPlayOutExperience exp = new PacketPlayOutExperience(entityPlayer.exp, entityPlayer.expTotal, entityPlayer.expLevel); + + entityPlayer.playerConnection.networkManager.handle(positionPacket); + entityPlayer.playerConnection.networkManager.handle(packetPlayOutAbilities); + entityPlayer.playerConnection.networkManager.handle(exp); + if (entityPlayer.activeContainer != entityPlayer.defaultContainer) + { + IInventory inv = ((CraftInventory) entityPlayer.activeContainer.getBukkitView().getTopInventory()).getInventory(); + String name; + if (inv instanceof ITileEntityContainer) + { + name = ((ITileEntityContainer) inv).getContainerName(); + } + else + { + name = "minecraft:chest"; + } + + entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(entityPlayer.activeContainer.windowId, name, inv.getScoreboardDisplayName(), inv.getSize())); + } + entityPlayer.updateInventory(entityPlayer.activeContainer); + entityPlayer.playerConnection.networkManager.handle(new PacketPlayOutHeldItemSlot(entityPlayer.inventory.itemInHandIndex)); + + AttributeMapServer attributemapserver = (AttributeMapServer) entityPlayer.getAttributeMap(); + Set set = attributemapserver.getAttributes(); + + entityPlayer.getBukkitEntity().injectScaledMaxHealth(set, true); + + entityPlayer.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(entityPlayer.getBukkitEntity().getScaledHealth(), entityPlayer.getFoodData().getFoodLevel(), entityPlayer.getFoodData().getSaturationLevel())); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(entityPlayer.getId(), set)); + + for (MobEffect mobEffect : entityPlayer.getEffects()) + { + if (entityPlayer.playerConnection.networkManager.getVersion() > 47 || mobEffect.getEffectId() != 25) + entityPlayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityPlayer.getId(), mobEffect)); + } + } + + public boolean showInTabList() + { + return this._showInTabList; + } + + public int getShowInTabListDelay() + { + return this._showInTabListDelay; + } + + private WorldSettings.EnumGamemode getAppropriateGamemode() + { + if (Entity instanceof EntityPlayer) + { + return ((EntityPlayer) Entity).playerInteractManager.getGameMode(); + } + return WorldSettings.EnumGamemode.SURVIVAL; + } + + private GameProfile getSelfProfile() + { + GameProfile selfProfile = new GameProfile(getOriginalUUID(), this._profile.getName()); + selfProfile.getProperties().putAll(this._profile.getProperties()); + return selfProfile; + } + + private UUID getOriginalUUID() + { + if (this._originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY)) + { + try + { + return UUID.fromString(this._originalProfile.getProperties().get(PlayerDisguiseManager.ORIGINAL_UUID_KEY).iterator().next().getValue()); + } + catch (IllegalArgumentException ignored) + { + } + } + return this._originalProfile.getId(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java index 426949661..1ebe31ae6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java @@ -18,7 +18,7 @@ public class DisguiseRabbit extends DisguiseAnimal } @Override - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); @@ -75,5 +75,4 @@ public class DisguiseRabbit extends DisguiseAnimal return packet; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index 67e7547b0..a9f0b44f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -4,12 +4,13 @@ import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.EntityType; public class DisguiseSlime extends DisguiseInsentient { public DisguiseSlime(org.bukkit.entity.Entity entity) { - super(entity); + super(EntityType.SLIME, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } @@ -24,7 +25,7 @@ public class DisguiseSlime extends DisguiseInsentient return DataWatcher.getByte(16); } - public Packet GetSpawnPacket() + public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = Entity.getId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java new file mode 100644 index 000000000..1974687a7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -0,0 +1,33 @@ +package mineplex.core.disguise.playerdisguise; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +public class DisguiseCommand extends CommandBase implements Listener +{ + DisguiseCommand(PlayerDisguiseManager plugin) + { + super(plugin, Rank.ADMIN, new Rank[]{Rank.YOUTUBE, Rank.TWITCH}, "disguise"); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null || args.length == 0) + { + Plugin.undisguise(caller); + return; + } + if (args.length > 2) + { + UtilPlayer.message(caller, F.help("/disguise [username of skin]", "Disguise yourself as 'username' with optional skin belonging to 'username of skin'", Rank.ADMIN)); + return; + } + + Plugin.disguise(caller, args[0], args.length > 1 ? args[1] : args[0]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java new file mode 100644 index 000000000..ab7878e08 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguisePlayerBean.java @@ -0,0 +1,137 @@ +package mineplex.core.disguise.playerdisguise; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.PropertyMap; +import com.mojang.util.UUIDTypeAdapter; +import mineplex.serverdata.data.Data; + +import java.lang.reflect.Type; +import java.util.UUID; + +public class DisguisePlayerBean implements Data +{ + private static final Gson GSON; + + static + { + GSON = new GsonBuilder() + .registerTypeAdapter(GameProfile.class, new GameProfileSerializer()) + .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()) + .registerTypeAdapter(UUID.class, new UUIDTypeAdapter()) + .create(); + } + + private int _accountID; + private String _playerName; + + private String _disguisedPlayer; + private String _disguisedSkin; + + private String _serializedGameProfile; + + public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs, String disguiseSkin, GameProfile targetProfile) + { + this._accountID = playerAccountID; + this._playerName = playerName; + + this._disguisedPlayer = disguiseAs; + this._disguisedSkin = disguiseSkin; + + this._serializedGameProfile = serialize(targetProfile); + } + + public int getAccountID() + { + return _accountID; + } + + public String getDisguisedPlayer() + { + return _disguisedPlayer; + } + + public String getDisguisedSkin() + { + return this._disguisedSkin; + } + + public String getPlayerName() + { + return _playerName; + } + + @Override + public String getDataId() + { + return _accountID + _playerName; + } + + public GameProfile getGameProfile() + { + return deserialize(this._serializedGameProfile); + } + + private String serialize(GameProfile gameProfile) + { + return GSON.toJson(gameProfile); + } + + private GameProfile deserialize(String in) + { + return GSON.fromJson(in, GameProfile.class); + } + + private static class GameProfileSerializer implements JsonSerializer, JsonDeserializer + { + private GameProfileSerializer() + { + } + + public GameProfile deserialize(JsonElement var1, Type var2, JsonDeserializationContext var3) throws JsonParseException + { + JsonObject var4 = (JsonObject) var1; + UUID var5 = var4.has("id") ? (UUID) var3.deserialize(var4.get("id"), UUID.class) : null; + String var6 = var4.has("name") ? var4.getAsJsonPrimitive("name").getAsString() : null; + GameProfile gameProfile = new GameProfile(var5, var6); + + if (var4.has("properties")) + { + PropertyMap propertyMap = var3.deserialize(var4.get("properties"), PropertyMap.class); + gameProfile.getProperties().putAll(propertyMap); + } + + return gameProfile; + } + + public JsonElement serialize(GameProfile var1, Type var2, JsonSerializationContext var3) + { + JsonObject var4 = new JsonObject(); + + if (var1.getId() != null) + { + var4.add("id", var3.serialize(var1.getId())); + } + + if (var1.getName() != null) + { + var4.addProperty("name", var1.getName()); + } + + if (var1.getProperties() != null) + { + var4.add("properties", var3.serialize(var1.getProperties())); + } + + return var4; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java new file mode 100644 index 000000000..e7ff8c3d6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -0,0 +1,631 @@ +package mineplex.core.disguise.playerdisguise; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.disguise.playerdisguise.events.PlayerDisguisedEvent; +import mineplex.core.disguise.playerdisguise.events.PlayerPreDisguiseEvent; +import mineplex.core.disguise.playerdisguise.events.PlayerPreUndisguiseEvent; +import mineplex.core.disguise.playerdisguise.events.PlayerUndisguisedEvent; +import mineplex.core.event.JoinMessageBroadcastEvent; +import mineplex.core.friend.FriendManager; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; +import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.utils.UtilGameProfile; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.PlayerStatus; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PlayerList; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Consumer; + +@ReflectivelyCreateMiniPlugin +public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler +{ + public static final String ORIGINAL_UUID_KEY = "originalUUID"; + + private CoreClientManager _clients = require(CoreClientManager.class); + private DisguiseManager _disguise = require(DisguiseManager.class); + private Punish _punish = require(Punish.class); + private CosmeticManager _cosmetics = require(CosmeticManager.class); + private PreferencesManager _prefs = require(PreferencesManager.class); + + private RedisDataRepository _redis; + + // The list of usernames which cannot join because someone else is joining + private Set _cannotJoin = Collections.synchronizedSet(new HashSet<>()); + private Set _loggingIn = Collections.synchronizedSet(new HashSet<>()); + + private Set _pendingDisguise1 = new HashSet<>(); + + private PlayerDisguiseManager() + { + super("Player Disguise Manager"); + + _serverName = _plugin.getConfig().getString("serverstatus.name"); + + require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutPlayerInfo.class, PacketPlayOutNamedEntitySpawn.class); + + _redis = new RedisDataRepository<>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); + } + + @Override + public void addCommands() + { + this.addCommand(new DisguiseCommand(this)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void cleanup(PlayerQuitEvent event) + { + _cannotJoin.remove(event.getPlayer().getName().toLowerCase()); + _loggingIn.remove(event.getPlayer().getName().toLowerCase()); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDisguiserJoin(PlayerLoginEvent event) + { + for (DisguisePlayer disguisePlayer : _disguises.values()) + { + if (disguisePlayer.getProfile().getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + return; + } + } + + if (_cannotJoin.contains(event.getPlayer().getName().toLowerCase())) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + return; + } + + CoreClient client = _clients.Get(event.getPlayer().getUniqueId()); + + DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName()); + + if (bean != null) + { + Player player = Bukkit.getPlayerExact(bean.getDisguisedPlayer()); + if (player != null) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("You cannot join this server because you are disguised and the user is online!"); + return; + } + + if (_loggingIn.contains(bean.getDisguisedPlayer())) + { + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("You cannot join this server because you are disguised and the user is currently logging in!"); + return; + } + + _cannotJoin.add(bean.getDisguisedPlayer().toLowerCase()); + + runSyncLater(() -> + { + _cannotJoin.remove(bean.getDisguisedPlayer().toLowerCase()); + }, 800L); + } + else + { + _loggingIn.add(event.getPlayer().getName().toLowerCase()); + + runSyncLater(() -> _loggingIn.remove(event.getPlayer().getName().toLowerCase()), 800L); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void onDisguisedPlayerJoin(PlayerJoinEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + + if (_redis.elementExists(client.getAccountId() + client.getName())) + { + DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName()); + + if (bean.getGameProfile() != null) + { + _pendingDisguise1.add(event.getPlayer().getUniqueId()); + + runSyncLater(() -> + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "Attempting to disguise you as " + bean.getGameProfile().getName())); + disguise(event.getPlayer(), bean.getGameProfile()); + }, 1); + } + } + } + + @EventHandler + public void onJoinMessage(JoinMessageBroadcastEvent event) + { + if (_pendingDisguise1.contains(event.getPlayer().getUniqueId())) + { + CoreClient client = _clients.Get(event.getPlayer()); + DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName()); + + event.setUsername(bean.getDisguisedPlayer()); + } + } + + public void storeDisguiseData(Player player, String disguisedName, GameProfile gameProfile) + { + CoreClient client = _clients.Get(player); + _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.getName(), disguisedName, null, gameProfile), 60 * 60 * 12); // 12 hours + System.out.println("+=+=+=+=+=+=+"); + System.out.println("ADDING DISGUISE INFO FOR " + player.getName()); + System.out.println("+=+=+=+=+=+=+"); + } + + public void removeDisguiseData(Player player) + { + CoreClient client = _clients.Get(player); + _redis.removeElement(client.getAccountId() + client.getName()); + System.out.println("+=+=+=+=+=+=+"); + System.out.println("REMOVING DISGUISE INFO FOR " + player.getName()); + System.out.println("+=+=+=+=+=+=+"); + } + + + /* + * Maps players (their UUID) with their disguises + */ + private final Map _disguises = new HashMap<>(); + + /* + * Mapping of old username to disguised username + */ + private final Map _mapping = new HashMap<>(); + + /* + * A set of usernames which are currently being disguised + * This is to prevent two people from running /disguise at the same time + */ + private Set _pendingDisguise = Collections.synchronizedSet(new HashSet<>()); + + private final String _serverName; + + private RedisDataRepository _repository = new RedisDataRepository<>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), + Region.currentRegion(), PlayerStatus.class, "playerStatus"); + + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + _pendingDisguise1.remove(event.getPlayer().getUniqueId()); + _disguises.remove(event.getPlayer().getUniqueId()); + _mapping.remove(event.getPlayer().getName().toLowerCase()); + } + + private boolean isDisguised(Player player) + { + return _disguises.containsKey(player.getUniqueId()); + } + + public void allow(Player player) + { + _pendingDisguise1.remove(player.getUniqueId()); + } + + public DisguiseManager getDisguiseManager() + { + return this._disguise; + } + + public CoreClientManager getClientManager() + { + return this._clients; + } + + public Punish getPunishManager() + { + return this._punish; + } + + public CosmeticManager getCostmeticManager() + { + return this._cosmetics; + } + + public PreferencesManager getPreferencesManager() + { + return this._prefs; + } + + // DisguiseManager is too slow, we need to cancel it here first + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutPlayerInfo) + { + PacketPlayOutPlayerInfo packet = (PacketPlayOutPlayerInfo) packetInfo.getPacket(); + Iterator iterator = packet.b.iterator(); + while (iterator.hasNext()) + { + PacketPlayOutPlayerInfo.PlayerInfoData data = iterator.next(); + if (_pendingDisguise1.contains(data.a().getId())) + { + iterator.remove(); + } + } + + if (packet.b.isEmpty()) + { + packetInfo.setCancelled(true); + } + else + { + if (packet.a != PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER && packet.a != PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER) + { + for (PacketPlayOutPlayerInfo.PlayerInfoData data : packet.b) + { + Player player = Bukkit.getPlayerExact(data.a().getName()); + + if (player != null) + { + if (isDisguised(player)) + { + PacketPlayOutPlayerInfo custom = new PacketPlayOutPlayerInfo(); + custom.a = packet.a; + + GameProfile originalProfile = _disguises.get(player.getUniqueId()).getOriginalProfile(); + custom.b.add(custom.new PlayerInfoData(originalProfile, data.b, data.c, data.d())); + + ((CraftPlayer) player).getHandle().playerConnection.networkManager.handle(custom); + } + } + else + { + System.out.println("Null player while sending PlayerInfoData: " + data.a().getName()); + } + } + } + } + } + else if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn) + { + PacketPlayOutNamedEntitySpawn spawn = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket(); + if (_pendingDisguise1.contains(spawn.b)) + { + packetInfo.setCancelled(true); + } + } + } + + public void undisguise(Player caller) + { + if (!isDisguised(caller)) + { + if (getDisguiseManager().isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "You have been disguised by something else. Perhaps you are morphed?")); + } + else + { + UtilPlayer.message(caller, F.main("Disguise", "You are not disguised. You can disguise with /disguise [username of skin]")); + } + return; + } + + if (getDisguiseManager().getActiveDisguise(caller) != _disguises.get(caller.getUniqueId())) + { + UtilPlayer.message(caller, F.main("Disguise", "Could not undisguise as it is not your active disguise. Perhaps you are morphed?")); + return; + } + + PlayerPreUndisguiseEvent playerPreUndisguiseEvent = new PlayerPreUndisguiseEvent(caller); + UtilServer.CallEvent(playerPreUndisguiseEvent); + if (playerPreUndisguiseEvent.isCancelled()) + { + return; + } + + DisguisePlayer disguise = _disguises.remove(caller.getUniqueId()); + + GameProfile originalProfile = disguise.getOriginalProfile(); + GameProfile currentProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguise.getName()); + try + { + UtilGameProfile.changeName(currentProfile, originalProfile.getName()); + UtilGameProfile.changeId(currentProfile, originalProfile.getId()); + currentProfile.getProperties().clear(); + currentProfile.getProperties().putAll(originalProfile.getProperties()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguise.getProfile().getName()); + map.put(disguise.getOriginalProfile().getName(), disguise.getEntity()); + } + catch (Exception ex) + { + UtilPlayer.message(caller, F.main("Disguise", "Could not undisguise because something went terribly wrong :(")); + ex.printStackTrace(); + return; + } + + getDisguiseManager().undisguise(caller); + + GameProfile disguisedProfile = disguise.getProfile(); + + CoreClient client = getClientManager().Get(caller); + client.undisguise(); + + require(FriendManager.class).updatePlayerStatus(disguisedProfile.getName(), null); + require(FriendManager.class).updatePlayerStatus(originalProfile.getName(), new PlayerStatus(originalProfile.getName(), _serverName)); + getPreferencesManager().handlePlayerJoin(caller, true); + + require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName()); + + + _mapping.remove(disguise.getName().toLowerCase()); + + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); + getPluginManager().callEvent(new PlayerUndisguisedEvent(caller)); + removeDisguiseData(caller); + } + + public void disguise(Player caller, GameProfile requestedProfile) + { + if (getDisguiseManager().isDisguised(caller)) + { + if (isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + } + else + { + UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Perhaps you are morphed?")); + } + return; + } + + if (isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + return; + } + + String requestedUsername = requestedProfile.getName(); + + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + _cannotJoin.add(requestedUsername.toLowerCase()); + for (Player other : UtilServer.getPlayersCollection()) + { + if (other.getName().equalsIgnoreCase(requestedUsername)) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); + return; + } + } + } + + if (!_pendingDisguise.add(requestedUsername.toLowerCase())) + { + UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); + return; + } + + PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); + UtilServer.CallEvent(playerPreDisguiseEvent); + if (playerPreDisguiseEvent.isCancelled()) + { + UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); + _pendingDisguise.remove(requestedUsername.toLowerCase()); + return; + } + + CoreClient callerClient = getClientManager().Get(caller); + + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + Rank otherRank = Rank.ALL; + CoreClient other = new CoreClient(requestedUsername, requestedProfile.getId()); + try + { + getClientManager().LoadClient(other, requestedProfile.getId(), caller.getAddress().getAddress().getHostAddress()); + otherRank = other.GetRank(); + } + catch (NullPointerException exception) + { + other = null; + } + + if (otherRank.has(Rank.TWITCH)) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); + return; + } + + if (other != null) + { + PunishClient pclient = getPunishManager().GetClient(requestedUsername); + if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); + return; + } + } + + callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + + _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + + System.out.println("================="); + System.out.println("Disguising " + caller.getName() + " as:"); + System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); + System.out.println("Properties:"); + for (Map.Entry p : requestedProfile.getProperties().entries()) + { + System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); + System.out.println("\t" + p.getValue().getValue()); + System.out.println("\t" + p.getValue().getSignature()); + } + System.out.println("================="); + + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); + + try + { + UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); + UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguisePlayer.getOriginalProfile().getName()); + map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); + } + catch (Throwable t) + { + t.printStackTrace(); + } + + require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); + + callerProfile.getProperties().clear(); + callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); + callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); + + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getName(), null); + require(FriendManager.class).updatePlayerStatus(requestedUsername, new PlayerStatus(requestedUsername, _serverName)); + + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + + UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + + storeDisguiseData(caller, requestedUsername, requestedProfile); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + + _cannotJoin.remove(requestedUsername.toLowerCase()); + }); + } + else + { + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + ((CraftPlayer) caller).getProfile().getProperties().clear(); + ((CraftPlayer) caller).getProfile().getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + storeDisguiseData(caller, caller.getName(), requestedProfile); + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + }); + } + } + + public void disguise(Player caller, String requestedUsername, String requestedSkin) + { + if (!validateUsername(caller, requestedUsername)) return; + if (!validateUsername(caller, requestedSkin)) return; + + UtilGameProfile.getProfileByName(requestedUsername, true, requestedProfile -> + { + Consumer skinConsumer = requestedProfileSkin -> + { + SkinData skinData = SkinData.constructFromGameProfile(requestedProfileSkin, true, true); + requestedProfile.getProperties().clear(); + requestedProfile.getProperties().put("textures", skinData.getProperty()); + + disguise(caller, requestedProfile); + }; + + if (!requestedUsername.equalsIgnoreCase(requestedSkin)) + { + UtilGameProfile.getProfileByName(requestedSkin, true, skinConsumer); + } + else + { + skinConsumer.accept(UtilGameProfile.clone(requestedProfile)); + } + }); + } + + private boolean validateUsername(Player caller, String username) + { + String replaced = UtilGameProfile.legalize(username); + if (!replaced.equals(username)) + { + UtilPlayer.message(caller, F.main(getName(), "The chosen username of '" + username + "' is not valid")); + return false; + } + + if (username.length() > 16) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of '" + username + "' is " + F.count(String.valueOf(username.length() - 16)) + " characters too long!")); + return false; + } + + if (username.length() <= 0) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of '" + username + "' must be longer than 0 characters")); + return false; + } + + return true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java new file mode 100644 index 000000000..260cfe11e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerDisguisedEvent.java @@ -0,0 +1,32 @@ +package mineplex.core.disguise.playerdisguise.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerDisguisedEvent extends Event +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + + public PlayerDisguisedEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java new file mode 100644 index 000000000..b0ccbd4f3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreDisguiseEvent.java @@ -0,0 +1,54 @@ +package mineplex.core.disguise.playerdisguise.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerPreDisguiseEvent extends Event implements Cancellable +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + private String _requestedUsername; + private boolean _cancelled; + + public PlayerPreDisguiseEvent(Player disguisee, String requestedUsername) + { + this._player = disguisee; + this._requestedUsername = requestedUsername; + } + + public Player getPlayer() + { + return _player; + } + + public String getRequestedUsername() + { + return this._requestedUsername; + } + + @Override + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean b) + { + this._cancelled = b; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java new file mode 100644 index 000000000..a490b2f8b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerPreUndisguiseEvent.java @@ -0,0 +1,47 @@ +package mineplex.core.disguise.playerdisguise.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerPreUndisguiseEvent extends Event implements Cancellable +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + private boolean _cancelled; + + public PlayerPreUndisguiseEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + @Override + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean b) + { + this._cancelled = b; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerUndisguisedEvent.java similarity index 73% rename from Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java rename to Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerUndisguisedEvent.java index ad8d9a9d0..4820ffeea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/events/PlayerUndisguisedEvent.java @@ -1,14 +1,14 @@ -package mineplex.core.disguise; +package mineplex.core.disguise.playerdisguise.events; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -public class PlayerUndisguiseEvent extends Event +public class PlayerUndisguisedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private Player _player; - public PlayerUndisguiseEvent(Player disguisee) + public PlayerUndisguisedEvent(Player disguisee) { this._player = disguisee; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index fd0862c9d..260ce09cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -1,36 +1,30 @@ package mineplex.core.donation; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.Queue; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import com.google.gson.Gson; - import mineplex.cache.player.PlayerCache; -import mineplex.core.MiniDbClientPlugin; +import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.command.ShardCommand; import mineplex.core.donation.command.GemCommand; -import mineplex.core.donation.command.GoldCommand; -import mineplex.core.donation.command.SetGoldCommand; +import mineplex.core.donation.command.ShardCommand; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; -public class DonationManager extends MiniDbClientPlugin +import java.util.LinkedList; +import java.util.Queue; +import java.util.UUID; + +public class DonationManager extends MiniClientPlugin { private final int MAX_GIVE_ATTEMPTS = 10; @@ -38,17 +32,24 @@ public class DonationManager extends MiniDbClientPlugin private NautHashMap> _gemQueue = new NautHashMap>(); private NautHashMap> _coinQueue = new NautHashMap>(); - private NautHashMap> _goldQueue = new NautHashMap>(); private Queue _coinAttemptQueue; + private final CoreClientManager _clientManager; public DonationManager(JavaPlugin plugin, CoreClientManager clientManager, String webAddress) { - super("Donation", plugin, clientManager); + super("Donation", plugin); _repository = new DonationRepository(plugin, webAddress); _coinAttemptQueue = new LinkedList<>(); + + _clientManager = clientManager; + } + + public CoreClientManager getClientManager() + { + return _clientManager; } @Override @@ -57,8 +58,6 @@ public class DonationManager extends MiniDbClientPlugin // TODO: Re-add commands? Where are command implementations, seen as missing at the moment. addCommand(new GemCommand(this)); addCommand(new ShardCommand(this)); - addCommand(new GoldCommand(this)); - addCommand(new SetGoldCommand(this)); } @EventHandler @@ -70,18 +69,18 @@ public class DonationManager extends MiniDbClientPlugin private void LoadDonor(DonorTokenWrapper token, UUID uuid) { - Get(token.Name).loadToken(token.DonorToken); + Get(uuid).loadToken(token.DonorToken); //_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins()); } - public void purchaseUnknownSalesPackage(Callback callback, Player player, String packageName, CurrencyType currencyType, int cost, boolean oneTimePurchase) + public void purchaseUnknownSalesPackage(Callback callback, Player player, String packageName, GlobalCurrency currencyType, int cost, boolean oneTimePurchase) { - PurchaseUnknownSalesPackage(callback, player.getName(), getClientManager().getAccountId(player), packageName, currencyType, cost, oneTimePurchase); + PurchaseUnknownSalesPackage(callback, player.getName(), _clientManager.getAccountId(player), packageName, currencyType, cost, oneTimePurchase); } - public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost, boolean oneTimePurchase) + public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final GlobalCurrency currencyType, final int cost, boolean oneTimePurchase) { - final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null; + final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(Bukkit.getPlayerExact(name)) : null; if (donor != null) { @@ -112,8 +111,8 @@ public class DonationManager extends MiniDbClientPlugin } }, name, accountId, packageName, currencyType, cost); } - - public void PurchaseKnownSalesPackage(final Callback callback, final String name, final UUID uuid, final int cost, final int salesPackageId) + + public void PurchaseKnownSalesPackage(final Callback callback, final String name, final UUID uuid, final int cost, final int salesPackageId) { _repository.PurchaseKnownSalesPackage(new Callback() { @@ -121,20 +120,20 @@ public class DonationManager extends MiniDbClientPlugin { if (response == TransactionResponse.Success) { - Donor donor = Get(name); + Donor donor = Get(uuid); if (donor != null) { donor.AddSalesPackagesOwned(salesPackageId); } } - + if (callback != null) callback.run(response); } }, name, uuid.toString(), cost, salesPackageId); } - + public void RewardGems(Callback callback, String caller, String name, UUID uuid, int amount) { RewardGems(callback, caller, name, uuid, amount, true); @@ -150,11 +149,11 @@ public class DonationManager extends MiniDbClientPlugin { if (updateTotal) { - Donor donor = Get(name); + Donor donor = Get(uuid); if (donor != null) { - donor.AddGems(amount); + donor.addBalance(GlobalCurrency.GEM, amount); } } } @@ -178,10 +177,10 @@ public class DonationManager extends MiniDbClientPlugin _gemQueue.get(player).put(caller, totalAmount); //Do Temp Change - Donor donor = Get(player.getName()); + Donor donor = Get(player.getUniqueId()); if (donor != null) - donor.AddGems(amount); + donor.addBalance(GlobalCurrency.GEM, amount); } @EventHandler @@ -241,7 +240,7 @@ public class DonationManager extends MiniDbClientPlugin if (donor != null) { - donor.addCoins(amount); + donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount); } } } @@ -265,10 +264,10 @@ public class DonationManager extends MiniDbClientPlugin _coinQueue.get(player).put(caller, totalAmount); //Do Temp Change - Donor donor = Get(player.getName()); + Donor donor = Get(player.getUniqueId()); if (donor != null) - donor.addCoins(amount); + donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount); } @EventHandler @@ -295,7 +294,7 @@ public class DonationManager extends MiniDbClientPlugin continue; if (player.isOnline() && player.isValid()) - RewardCoins(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false); + RewardCoins(null, caller, player.getName(), _clientManager.Get(player).getAccountId(), total, false); else { Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() @@ -334,11 +333,11 @@ public class DonationManager extends MiniDbClientPlugin { if (success) { - Donor donor = Get(data.getPlayerName()); + Donor donor = Get(data.getUuid()); if (donor != null) { - donor.addCoins(data.getGiveAmount()); + donor.addBalance(GlobalCurrency.TREASURE_SHARD, data.getGiveAmount()); } if (data.getCallback() != null) data.getCallback().run(true); @@ -367,165 +366,15 @@ public class DonationManager extends MiniDbClientPlugin } } - - public void rewardGold(Callback callback, String caller, Player player, int amount) - { - rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), amount); - } - - public void rewardGold(Callback callback, String caller, String name, int accountId, int amount) - { - rewardGold(callback, caller, name, accountId, amount, true); - } - - public void rewardGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) - { - _repository.rewardGold(new Callback() - { - public void run(Boolean success) - { - if (success) - { - if (updateTotal) - { - Donor donor = Get(name); - - if (donor != null) - { - donor.addGold(amount); - } - } - } - else - { - System.out.println("REWARD GOLD FAILED..."); - } - - if (callback != null) - callback.run(success); - } - }, caller, name, accountId, amount); - } - - public void setGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) - { - _repository.setGold(new Callback() - { - public void run(Boolean success) - { - if (success) - { - if (updateTotal) - { - Donor donor = Get(name); - - if (donor != null) - { - donor.setGold(amount); - } - } - } - else - { - System.out.println("SET GOLD FAILED..."); - } - - if (callback != null) - callback.run(success); - } - }, caller, name, accountId, amount); - } - - public void RewardGoldLater(final String caller, final Player player, final int amount) - { - if (!_goldQueue.containsKey(player)) - _goldQueue.put(player, new NautHashMap()); - - int totalAmount = amount; - - if (_goldQueue.get(player).containsKey(caller)) - totalAmount += _goldQueue.get(player).get(caller); - - _goldQueue.get(player).put(caller, totalAmount); - - //Do Temp Change - Donor donor = Get(player.getName()); - - if (donor != null) - donor.addGold(amount); - } - - @EventHandler - public void updateGoldQueue(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOWER) - return; - - for (Player player : _goldQueue.keySet()) - { - updateGoldQueue(null, player); - } - - //Clean - _goldQueue.clear(); - } - - public void updateGoldQueue(final Callback callback, final Player player) - { - String tempCaller = null; - int tempTotal = 0; - - for (String curCaller : _goldQueue.get(player).keySet()) - { - tempCaller = curCaller; - tempTotal += _goldQueue.get(player).get(curCaller); - } - - final String caller = tempCaller; - final int total = tempTotal; - - if (caller == null) - return; - - if (player.isOnline() && player.isValid()) - rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false); - else - { - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - rewardGold(callback, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false); - } - }); - } - - System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]"); - - //Clean - _goldQueue.get(player).clear(); - } public void applyKits(String playerName) { _repository.applyKits(playerName); } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - Get(playerName).setGold(_repository.retrieveDonorInfo(resultSet).getGold()); - } @Override - protected Donor addPlayer(String player) + protected Donor addPlayer(UUID uuid) { return new Donor(); } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT gold FROM accounts WHERE id = '" + accountId + "';"; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index 692b9cdb5..c2282a3b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -1,18 +1,18 @@ package mineplex.core.donation; -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.repository.token.CoinTransactionToken; import mineplex.core.donation.repository.token.DonorToken; import mineplex.core.donation.repository.token.TransactionToken; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class Donor { - private int _gems; - private int _coins; - private int _gold; + private final Map _balances = new HashMap<>(); private boolean _donated; private List _salesPackagesOwned = new ArrayList(); private List _unknownSalesPackagesOwned = new ArrayList(); @@ -25,8 +25,8 @@ public class Donor public void loadToken(DonorToken token) { - _gems = token.Gems; - _coins = token.Coins; + _balances.put(GlobalCurrency.GEM, token.Gems); + _balances.put(GlobalCurrency.TREASURE_SHARD, token.Coins); _donated = token.Donated; _salesPackagesOwned = token.SalesPackages; @@ -34,12 +34,7 @@ public class Donor _transactions = token.Transactions; _coinTransactions = token.CoinRewards; } - - public int GetGems() - { - return _gems; - } - + public List GetSalesPackagesOwned() { return _salesPackagesOwned; @@ -65,49 +60,21 @@ public class Donor return _donated; } - public void DeductCost(int cost, CurrencyType currencyType) + public void DeductCost(int cost, GlobalCurrency currencyType) { - switch (currencyType) - { - case GEM: - _gems -= cost; - _update = true; - break; - case TREASURE_SHARD: - _coins -= cost; - _update = true; - break; - case GOLD: - _gold -= cost; - _update = true; - break; - default: - break; - } + addBalance(currencyType, -cost); } - public int GetBalance(CurrencyType currencyType) + public int getBalance(GlobalCurrency currencyType) { - switch (currencyType) - { - case GEM: - return _gems; - case TREASURE_SHARD: - return _coins; - case GOLD: - return _gold; - case TOKEN: - return 0; - default: - return 0; - } + return _balances.getOrDefault(currencyType, 0); } - public void AddGems(int gems) + public void addBalance(GlobalCurrency currencyType, int amount) { - _gems += gems; + _balances.merge(currencyType, amount, Integer::sum); } - + public boolean OwnsUnknownPackage(String packageName) { return _unknownSalesPackagesOwned.contains(packageName); @@ -144,33 +111,9 @@ public class Donor return false; } - public int getCoins() - { - return _coins; - } - - public void addCoins(int amount) - { - _coins += amount; - } - - public void addGold(int amount) - { - _gold = Math.max(0, _gold + amount); - } - - public void setGold(int amount) - { - _gold = Math.max(0, amount); - } - public List getCoinTransactions() { return _coinTransactions; } - public int getGold() - { - return _gold; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java index cbe9dc269..f606a607c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java @@ -36,18 +36,13 @@ public class ShardCommand extends CommandBase } else if (target == null) { - Plugin.getClientManager().loadClientByName(targetName, new Runnable() + Plugin.getClientManager().loadClientByName(targetName, client -> { - public void run() + if (client != null) + rewardCoins(caller, null, targetName, client.getAccountId(), coinsString); + else { - CoreClient client = Plugin.getClientManager().Get(targetName); - - if (client != null) - rewardCoins(caller, null, targetName, client.getAccountId(), coinsString); - else - { - UtilPlayer.message(caller, F.main("Shards", "Could not find player " + F.name(targetName))); - } + UtilPlayer.message(caller, F.main("Shards", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 414e23118..a73791657 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -1,24 +1,20 @@ package mineplex.core.donation.repository; -import java.sql.ResultSet; -import java.sql.SQLException; - -import mineplex.core.database.MinecraftRepository; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.Currency; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.DatabaseRunnable; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.core.donation.Donor; +import mineplex.core.database.MinecraftRepository; import mineplex.core.donation.repository.token.GemRewardToken; import mineplex.core.donation.repository.token.PurchaseToken; import mineplex.core.donation.repository.token.UnknownPurchaseToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.util.TransactionResponse; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.DatabaseRunnable; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; public class DonationRepository extends MinecraftRepository { @@ -26,8 +22,6 @@ public class DonationRepository extends MinecraftRepository private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);"; private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;"; - private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;"; - private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;"; private String _webAddress; @@ -70,12 +64,12 @@ public class DonationRepository extends MinecraftRepository }), "Error purchasing known sales package in DonationRepository : "); } - public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost) + public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final Currency currencyType, final int cost) { final UnknownPurchaseToken token = new UnknownPurchaseToken(); token.AccountName = name; token.SalesPackageName = packageName; - token.CoinPurchase = currencyType == CurrencyType.TREASURE_SHARD; + token.CoinPurchase = currencyType == GlobalCurrency.TREASURE_SHARD; token.Cost = cost; token.Premium = false; @@ -85,15 +79,11 @@ public class DonationRepository extends MinecraftRepository { if (response == TransactionResponse.Success) { - if (currencyType == CurrencyType.TREASURE_SHARD) + if (currencyType == GlobalCurrency.TREASURE_SHARD) { executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnInt("id", accountId)); //executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost)); } - else if (currencyType == CurrencyType.GOLD) - { - executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId)); - } } Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() @@ -184,35 +174,6 @@ public class DonationRepository extends MinecraftRepository }), "Error updating player coin amount in DonationRepository : "); } - public void rewardGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) - { - handleDatabaseCall(new DatabaseRunnable(new Runnable() - { - public void run() - { - ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0); - boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0; - callback.run(success); - } - }), "Error updating player gold amount in DonationRepository : "); - } - - public void setGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) - { - if (gold < 0) - { - throw new IllegalArgumentException("gold cannot be negative"); - } - handleDatabaseCall(new DatabaseRunnable(new Runnable() - { - public void run() - { - boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; - callback.run(success); - } - }), "Error updating player gold amount in DonationRepository : "); - } - @Override protected void initialize() { @@ -240,16 +201,4 @@ public class DonationRepository extends MinecraftRepository { new AsyncJsonWebCall(_webAddress + "PlayerAccount/ApplyKits").Execute(playerName); } - - public Donor retrieveDonorInfo(ResultSet resultSet) throws SQLException - { - Donor donor = new Donor(); - - while (resultSet.next()) - { - donor.setGold(resultSet.getInt(1)); - } - - return donor; - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index cbfec07b9..e46c10f59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -2,6 +2,7 @@ package mineplex.core.elo; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -114,15 +115,15 @@ public class EloManager extends MiniDbClientPlugin } @Override - protected EloClientData addPlayer(String player) + protected EloClientData addPlayer(UUID uuid) { return new EloClientData(); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java b/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java index 51849c397..b1f180cdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/energy/Energy.java @@ -16,6 +16,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.energy.event.EnergyEvent; import mineplex.core.energy.event.EnergyEvent.EnergyChangeReason; +import java.util.UUID; + public class Energy extends MiniClientPlugin { private double _baseEnergy = 180; @@ -137,7 +139,7 @@ public class Energy extends MiniClientPlugin } @Override - protected ClientEnergy addPlayer(String player) + protected ClientEnergy addPlayer(UUID uuid) { return new ClientEnergy(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java new file mode 100644 index 000000000..be57e5da2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/event/JoinMessageBroadcastEvent.java @@ -0,0 +1,47 @@ +package mineplex.core.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/* + * This event is called when the join message is about to be sent + */ +public class JoinMessageBroadcastEvent extends Event +{ + private static final HandlerList HANDLERS = new HandlerList(); + + private Player _player; + private String _username; + + public JoinMessageBroadcastEvent(Player player) + { + this._player = player; + this._username = player.getName(); + } + + public Player getPlayer() + { + return this._player; + } + + public String getUsername() + { + return this._username; + } + + public void setUsername(String username) + { + this._username = username; + } + + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index b950fb05e..dedb8c37b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -17,6 +17,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java index 4f1e56d17..83b402573 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java @@ -2,6 +2,7 @@ package mineplex.core.facebook; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -106,16 +107,16 @@ public class FacebookManager extends MiniDbClientPlugin } @Override - protected FacebookClient addPlayer(String player) + protected FacebookClient addPlayer(UUID uuid) { return new FacebookClient(false); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { boolean hasRow = resultSet.next(); - Set(playerName, new FacebookClient(hasRow)); + Set(uuid, new FacebookClient(hasRow)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 355aa3407..99a168f9f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -1,12 +1,5 @@ package mineplex.core.friend; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -24,16 +17,25 @@ import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendRepository; import mineplex.core.friend.data.FriendStatus; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - +import mineplex.serverdata.data.PlayerStatus; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + public class FriendManager extends MiniDbClientPlugin { private static FriendSorter _friendSorter = new FriendSorter(); @@ -70,7 +72,7 @@ public class FriendManager extends MiniDbClientPlugin } @Override - protected FriendData addPlayer(String player) + protected FriendData addPlayer(UUID uuid) { return new FriendData(); } @@ -269,7 +271,7 @@ public class FriendManager extends MiniDbClientPlugin if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) continue; - if (!_preferenceManager.Get(caller).PendingFriendRequests && friend.Status == FriendStatusType.Pending) + if (!_preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS) && friend.Status == FriendStatusType.Pending) continue; gotAFriend = true; @@ -399,10 +401,21 @@ public class FriendManager extends MiniDbClientPlugin return false; } - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + + public void updatePlayerStatus(String playerName, PlayerStatus status) { - Set(playerName, _repository.loadClientInformation(resultSet)); + _repository.updatePlayerStatus(playerName, status); + } + + public PlayerStatus getStatus(String playerName) + { + return _repository.getStatus(playerName); + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java index c7706ddd1..e75cff044 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -1,12 +1,11 @@ package mineplex.core.friend.command; -import org.bukkit.entity.Player; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; import mineplex.core.friend.FriendManager; import mineplex.core.friend.ui.FriendsGUI; +import mineplex.core.preferences.Preference; +import org.bukkit.entity.Player; public class AddFriend extends CommandBase { @@ -20,7 +19,7 @@ public class AddFriend extends CommandBase { if (args == null || args.length < 1) { - if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI) + if (Plugin.getPreferenceManager().get(caller).isActive(Preference.FRIENDS_DISPLAY_INVENTORY_UI)) { new FriendsGUI(Plugin, caller); } @@ -31,14 +30,11 @@ public class AddFriend extends CommandBase } else { - _commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() + _commandCenter.GetClientManager().checkPlayerName(caller, args[0], result -> { - public void run(String result) + if (result != null) { - if (result != null) - { - Plugin.addFriend(caller, result); - } + Plugin.addFriend(caller, result); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java index 14c3b37ed..c0cc87554 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java @@ -1,5 +1,6 @@ package mineplex.core.friend.command; +import mineplex.core.preferences.Preference; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -19,15 +20,15 @@ public class FriendsDisplay extends CommandBase @Override public void Execute(Player caller, final String[] args) { - UserPreferences preferences = Plugin.getPreferenceManager().Get(caller); + UserPreferences preferences = Plugin.getPreferenceManager().get(caller); - preferences.friendDisplayInventoryUI = !preferences.friendDisplayInventoryUI; + preferences.toggle(Preference.FRIENDS_DISPLAY_INVENTORY_UI); - Plugin.getPreferenceManager().savePreferences(caller); + Plugin.getPreferenceManager().save(preferences); caller.playSound(caller.getLocation(), Sound.NOTE_PLING, 1, 1.6f); - if (preferences.friendDisplayInventoryUI) + if (preferences.isActive(Preference.FRIENDS_DISPLAY_INVENTORY_UI)) { Plugin.runAsync(() -> new FriendsGUI(Plugin, caller)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index e26721864..81cf0b4eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -14,7 +14,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.NautHashMap; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.friend.FriendStatusType; @@ -183,7 +182,7 @@ public class FriendRepository extends MinecraftRepository /** * @param playerName - the name of the player whose current server status is being fetched - * @return the {@link MinecraftServer} name that the player matching {@code playerName} + * @return the name that the player matching {@code playerName} * is currently online on, if they are online, null otherwise. */ public String fetchPlayerServer(String playerName) @@ -192,4 +191,21 @@ public class FriendRepository extends MinecraftRepository return (status == null) ? null : status.getServer(); } + + public void updatePlayerStatus(String playerName, PlayerStatus status) + { + if (status != null) + { + _repository.addElement(status, 60 * 60 * 8); + } + else + { + _repository.removeElement(playerName.toLowerCase()); + } + } + + public PlayerStatus getStatus(String playerName) + { + return _repository.getElement(playerName.toLowerCase()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index c60d7594e..5bac4e047 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -1,30 +1,20 @@ package mineplex.core.gadget; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.function.Predicate; -import mineplex.core.gadget.commands.LockCosmeticsCommand; -import mineplex.core.gadget.event.GadgetChangeEvent; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; -import mineplex.core.gadget.gadgets.hat.*; -import mineplex.core.gadget.gadgets.morph.*; -import mineplex.core.gadget.gadgets.outfit.windupsuit.*; -import mineplex.core.gadget.gadgets.particle.*; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.wineffect.*; -import mineplex.core.gadget.persistence.UserGadgetPersistence; -import mineplex.core.gadget.set.*; -import mineplex.core.gadget.types.*; -import mineplex.core.incognito.events.IncognitoHidePlayerEvent; -import mineplex.core.incognito.events.IncognitoStatusChangeEvent; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -44,46 +34,55 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.commands.AmmoCommand; +import mineplex.core.gadget.commands.LockCosmeticsCommand; import mineplex.core.gadget.commands.UnlockCosmeticsCommand; +import mineplex.core.gadget.event.GadgetChangeEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; +import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; +import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; +import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; import mineplex.core.gadget.gadgets.death.music.DeathMusic; import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; +import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitGameModifier; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; +import mineplex.core.gadget.gadgets.hat.HatItem; +import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemBatGun; import mineplex.core.gadget.gadgets.item.ItemBow; import mineplex.core.gadget.gadgets.item.ItemCoal; @@ -101,6 +100,22 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.morph.MorphBat; +import mineplex.core.gadget.gadgets.morph.MorphBlaze; +import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.gadgets.morph.MorphBunny; +import mineplex.core.gadget.gadgets.morph.MorphChicken; +import mineplex.core.gadget.gadgets.morph.MorphCow; +import mineplex.core.gadget.gadgets.morph.MorphCreeper; +import mineplex.core.gadget.gadgets.morph.MorphEnderman; +import mineplex.core.gadget.gadgets.morph.MorphPig; +import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; +import mineplex.core.gadget.gadgets.morph.MorphSlime; +import mineplex.core.gadget.gadgets.morph.MorphSnowman; +import mineplex.core.gadget.gadgets.morph.MorphTitan; +import mineplex.core.gadget.gadgets.morph.MorphUncleSam; +import mineplex.core.gadget.gadgets.morph.MorphVillager; +import mineplex.core.gadget.gadgets.morph.MorphWither; import mineplex.core.gadget.gadgets.outfit.OutfitTeam; import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots; import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate; @@ -110,20 +125,67 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager; +import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleFairy; +import mineplex.core.gadget.gadgets.particle.ParticleFireRings; +import mineplex.core.gadget.gadgets.particle.ParticleLegend; +import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; +import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; +import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; +import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; +import mineplex.core.gadget.gadgets.particle.ParticleYinYang; +import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; +import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; +import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; +import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames; +import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap; +import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike; +import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan; +import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium; +import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; +import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails; +import mineplex.core.gadget.persistence.UserGadgetPersistence; +import mineplex.core.gadget.set.SetCandyCane; +import mineplex.core.gadget.set.SetCupidsLove; +import mineplex.core.gadget.set.SetEmerald; +import mineplex.core.gadget.set.SetFreedom; +import mineplex.core.gadget.set.SetFrostLord; +import mineplex.core.gadget.set.SetHowlingWinds; +import mineplex.core.gadget.set.SetMusic; +import mineplex.core.gadget.set.SetParty; +import mineplex.core.gadget.set.SetShadow; +import mineplex.core.gadget.set.SetTitan; +import mineplex.core.gadget.set.SetVampire; +import mineplex.core.gadget.set.SetWisdom; import mineplex.core.gadget.set.suits.SetRaveSuit; import mineplex.core.gadget.set.suits.SetSpaceSuit; +import mineplex.core.gadget.types.ArrowEffectGadget; +import mineplex.core.gadget.types.DeathEffectGadget; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetSet; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.GameModifierGadget; +import mineplex.core.gadget.types.HatGadget; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.gadget.types.MusicGadget; +import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.types.WinEffectGadget; import mineplex.core.hologram.HologramManager; +import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.mount.MountManager; import mineplex.core.mount.event.MountActivateEvent; @@ -160,6 +222,8 @@ public class GadgetManager extends MiniPlugin private boolean _hideParticles = false; private int _activeItemSlot = 3; private boolean _gadgetsEnabled = true; + + private Set _gadgetCollideWhitelist = new HashSet<>(); public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, @@ -740,7 +804,7 @@ public class GadgetManager extends MiniPlugin return _mountManager; } - public boolean collideEvent(Player shooter, Gadget gadget, Player other) + public boolean collideEvent(Player shooter, Gadget gadget, Entity other) { GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(shooter, gadget, other); @@ -796,6 +860,46 @@ public class GadgetManager extends MiniPlugin { _lastMove.remove(event.getEntity()); } + + + @EventHandler(priority = EventPriority.LOW) + public void onGadgetCollide(GadgetCollideEntityEvent event) + { + if(event.getOther() instanceof Player) + { + event.setCancelled(false); + return; + } + if(isAffectedByGadgets(event.getOther())) + { + event.setCancelled(false); + } + } + + /** + * @param e The entity to check + * @return Returns true if the entity is affected by gadgets like snowballs, flesh hooks etc + */ + public boolean isAffectedByGadgets(Entity e) + { + return _gadgetCollideWhitelist.contains(e); + } + + /** + * Set whether or not the given entity should be affected by gadgets by snowball, flesh hooks etc + * By default only players and naturally spawned entities are affected. + */ + public void setAffectedByGadgets(Entity e, boolean affected) + { + if(affected) + { + _gadgetCollideWhitelist.add(e); + } + else + { + _gadgetCollideWhitelist.remove(e); + } + } public void setActive(Player player, Gadget gadget) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java index 9135d6f38..4f7a4df5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java @@ -54,21 +54,15 @@ public class AmmoCommand extends CommandBase { if (target == null) { - _plugin.getClientManager().loadClientByName(targetName, new Runnable() + _plugin.getClientManager().loadClientByName(targetName, loadedProfile -> { - @Override - public void run() + if (loadedProfile != null) { - CoreClient client = _plugin.getClientManager().Get(targetName); - - if (client != null) - { - addAmmo(caller, client.GetPlayer(), gadget, amount); - } - else - { - UtilPlayer.message(caller, F.main("Ammo", "Could not find player " + F.name(targetName))); - } + addAmmo(caller, loadedProfile.GetPlayer(), gadget, amount); + } + else + { + UtilPlayer.message(caller, F.main("Ammo", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java index 1fc07c933..36bdfd764 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -89,7 +89,7 @@ public class LockCosmeticsCommand extends CommandBase Item clientItem = _plugin.getInventoryManager().getItem(gadget.getName()); if (clientItem == null) continue; - _plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1)); + _plugin.getInventoryManager().Get(caller).removeItem(new ClientItem(clientItem, 1)); removed++; } } @@ -108,7 +108,7 @@ public class LockCosmeticsCommand extends CommandBase Item clientItem = _plugin.getInventoryManager().getItem(mount.getName()); if (clientItem == null) continue; - _plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1)); + _plugin.getInventoryManager().Get(caller).removeItem(new ClientItem(clientItem, 1)); removed++; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java index 0fab27166..f297c13c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java @@ -2,12 +2,16 @@ package mineplex.core.gadget.event; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import mineplex.core.gadget.types.Gadget; -public class GadgetCollideEntityEvent extends Event +/** + * An event called when a gadget used by a player collides with an entity. By default, only players are effected (event is cancelled). + */ +public class GadgetCollideEntityEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @@ -15,7 +19,7 @@ public class GadgetCollideEntityEvent extends Event private Gadget _gadget; private Entity _other; - private boolean _cancelled = false; + private boolean _cancelled = true; public GadgetCollideEntityEvent(Player player, Gadget gadget, Entity other) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java index 71d36ba62..4f6f3b421 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java @@ -1,10 +1,7 @@ package mineplex.core.gadget.gadgets; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.shop.item.SalesPackageBase; +import org.bukkit.Material; public class Ammo extends SalesPackageBase { @@ -16,9 +13,4 @@ public class Ammo extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java index c8751e8c6..7c95f445b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java @@ -36,4 +36,12 @@ public class SongData return false; } -} + + /** + * Forces this song's jukebox to revert to air + */ + public void disable() + { + Block.setType(Material.AIR); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java index 57938844b..6bada9d2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java @@ -45,7 +45,7 @@ public class ArrowTrailTitan extends ArrowEffectGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java index 1d4fd7b3e..375384371 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java @@ -34,7 +34,7 @@ public class DeathTitan extends DeathEffectGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java index 2282001f2..9de6ce64f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java @@ -39,7 +39,7 @@ public class DoubleJumpTitan extends DoubleJumpEffectGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java index f0c658846..67aa5cc1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java @@ -1,16 +1,5 @@ package mineplex.core.gadget.gadgets.item; -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -18,18 +7,29 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashMap; public class ItemBatGun extends ItemGadget { @@ -102,7 +102,7 @@ public class ItemBatGun extends ItemGadget if (other.equals(cur)) continue; - if (!Manager.getPreferencesManager().Get(other).HubGames || !Manager.getPreferencesManager().Get(other).ShowPlayers) + if (!Manager.getPreferencesManager().get(other).isActive(Preference.HUB_GAMES) || !Manager.getPreferencesManager().get(other).isActive(Preference.SHOW_PLAYERS)) continue; if (!Recharge.Instance.usable(other, "Hit by Bat")) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java index 4f53d1384..01904e133 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java @@ -13,9 +13,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; @@ -66,9 +66,8 @@ public class ItemFleshHook extends ItemGadget implements IThrown if (target == null) return; - if (target instanceof Player) - if (Manager.collideEvent(player, this, (Player) target)) - return; + if (Manager.collideEvent(player, this, target)) + return; //Pull UtilAction.velocity(target, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java index 9e27220e4..eeaf89b60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java @@ -14,7 +14,6 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; @@ -53,9 +52,8 @@ public class ItemSnowball extends ItemGadget if(!_snowballs.containsKey(ball)) return; - GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowballs.remove(ball), this, event.getEntity()); - - if(gevent.isCancelled()) return; + if(Manager.collideEvent(_snowballs.remove(ball), this, event.getEntity())) return; + UtilAction.velocity(event.getEntity(), event.getDamager().getVelocity().normalize().add(new Vector(0,0.5,0)).multiply(0.5)); event.getDamager().getWorld().playSound(event.getDamager().getLocation(), Sound.STEP_SNOW, 1, 0.5f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java index 5a3e85f68..29641ce98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java @@ -59,7 +59,7 @@ public class MorphBat extends MorphGadget implements IThrown this.ApplyArmor(player, message); DisguiseBat disguise = new DisguiseBat(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java index 0708fe148..75dc613cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java @@ -42,7 +42,7 @@ public class MorphBlaze extends MorphGadget this.ApplyArmor(player, message); DisguiseBlaze disguise = new DisguiseBlaze(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -84,7 +84,7 @@ public class MorphBlaze extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java index 762dc9a7c..2c6be003f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java @@ -1,14 +1,18 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.Sound; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.disguise.disguises.DisguiseRabbit; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.*; import org.bukkit.FireworkEffect.Type; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -21,28 +25,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.disguises.DisguiseRabbit; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; public class MorphBunny extends MorphGadget { @@ -70,7 +55,7 @@ public class MorphBunny extends MorphGadget this.ApplyArmor(player, message); DisguiseRabbit disguise = new DisguiseRabbit(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); @@ -150,8 +135,8 @@ public class MorphBunny extends MorphGadget if (!UtilEvent.isAction(event, ActionType.L)) return; - - if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.TREASURE_SHARD) < 500) + + if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < 500) { UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards.")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java index 20c997d91..74faab8a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java @@ -48,7 +48,7 @@ public class MorphChicken extends MorphGadget this.ApplyArmor(player, message); DisguiseChicken disguise = new DisguiseChicken(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java index 652c35330..734d8f0e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java @@ -36,7 +36,7 @@ public class MorphCow extends MorphGadget this.ApplyArmor(player, message); DisguiseCow disguise = new DisguiseCow(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index 149c59a82..e0dd79087 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -50,7 +50,7 @@ public class MorphCreeper extends MorphGadget this.ApplyArmor(player, message); DisguiseCreeper disguise = new DisguiseCreeper(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -171,7 +171,7 @@ public class MorphCreeper extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java index 59e7d9e2f..0c8bcc296 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java @@ -47,7 +47,7 @@ public class MorphEnderman extends MorphGadget this.ApplyArmor(player, message); DisguiseEnderman disguise = new DisguiseEnderman(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index 5a0e4f4c2..dbf439dc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -49,7 +49,7 @@ public class MorphPig extends MorphGadget this.ApplyArmor(player, message); DisguisePig disguise = new DisguisePig(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -84,7 +84,7 @@ public class MorphPig extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ULTRA)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index ae4aa8913..1faab01c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -34,7 +34,7 @@ public class MorphPumpkinKing extends MorphGadget DisguiseSkeleton disguise = new DisguiseSkeleton(player); disguise.showArmor(); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); disguise.SetSkeletonType(SkeletonType.WITHER); Manager.getDisguiseManager().disguise(disguise); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java index 7ea51f3f0..bd7400c2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java @@ -48,7 +48,7 @@ public class MorphSlime extends MorphGadget this.ApplyArmor(player, message); DisguiseSlime disguise = new DisguiseSlime(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java index 3996d5626..dada28da5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java @@ -19,15 +19,14 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSnowman; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargeData; @@ -60,7 +59,7 @@ public class MorphSnowman extends MorphGadget this.ApplyArmor(player, message); DisguiseSnowman disguise = new DisguiseSnowman(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -143,10 +142,8 @@ public class MorphSnowman extends MorphGadget if (!_snowball.containsKey(proj)) return; - GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowball.remove(proj), this, event.getEntity()); - - if(gevent.isCancelled()) return; - + if(Manager.collideEvent(_snowball.remove(proj), this, event.getEntity())) return; + UtilAction.velocity(event.getEntity(), proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index c2bcd1cc7..f2ef8d5d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -63,7 +63,7 @@ public class MorphTitan extends MorphGadget this.ApplyArmor(player, message); DisguiseGuardian disguise = new DisguiseGuardian(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); disguise.setElder(true); Manager.getDisguiseManager().disguise(disguise); @@ -228,7 +228,7 @@ public class MorphTitan extends MorphGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java index 44cad0b25..e5fa3bca1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java @@ -1,22 +1,32 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.UUID; - import com.mojang.authlib.GameProfile; import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.WeakHashMap; public class MorphUncleSam extends MorphGadget { + private Map _disguises = new HashMap<>(); public MorphUncleSam(GadgetManager manager) { @@ -37,12 +47,15 @@ public class MorphUncleSam extends MorphGadget { this.ApplyArmor(player, message); - DisguisePlayer disguisePlayer = new DisguisePlayer(player); - disguisePlayer.setProfile(new GameProfile(UUID.randomUUID(), C.cRed + "Uncle " + C.cBlue + "Sam")); - SkinData uncleSam = SkinData.UNCLE_SAM; - disguisePlayer.setSkinData(uncleSam); - disguisePlayer.setSendSkinDataToSelf(true); + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.UNCLE_SAM.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); Manager.getDisguiseManager().disguise(disguisePlayer); + + this._disguises.put(player.getUniqueId(), disguisePlayer); } @Override @@ -50,7 +63,7 @@ public class MorphUncleSam extends MorphGadget { this.RemoveArmor(player); - Manager.getDisguiseManager().undisguise(player); + Manager.getDisguiseManager().undisguise(this._disguises.remove(player.getUniqueId())); } @EventHandler @@ -71,4 +84,9 @@ public class MorphUncleSam extends MorphGadget UtilFirework.playFreedomFirework(player.getLocation().clone().add(0, 2, 0)); } + @EventHandler + public void quit(PlayerQuitEvent event) + { + this._disguises.remove(event.getPlayer().getUniqueId()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java index 3480504e3..e0f9edd70 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java @@ -1,8 +1,16 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.HashSet; -import java.util.Iterator; - +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.disguise.disguises.DisguiseVillager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; import org.bukkit.Material; @@ -12,27 +20,12 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.disguise.disguises.DisguiseVillager; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.MorphGadget; +import java.util.HashSet; +import java.util.Iterator; public class MorphVillager extends MorphGadget implements IThrown { @@ -58,7 +51,7 @@ public class MorphVillager extends MorphGadget implements IThrown this.ApplyArmor(player, message); DisguiseVillager disguise = new DisguiseVillager(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); } @@ -80,8 +73,8 @@ public class MorphVillager extends MorphGadget implements IThrown if (!UtilEvent.isAction(event, ActionType.L)) return; - - if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.GEM) < 20) + + if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.GEM) < 20) { UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems.")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index 505551d3b..682b79bd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -64,7 +64,7 @@ public class MorphWither extends MorphGadget player.setHealth(300); DisguiseWither disguise = new DisguiseWither(player); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); //disguise.setCustomNameVisible(true); Manager.getDisguiseManager().disguise(disguise); @@ -184,7 +184,7 @@ public class MorphWither extends MorphGadget // TODO HARDCODED Wither Morph Database Item Id - 550 if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { - Manager.getInventoryManager().Get(event.getPlayer().getName()).addItem(new ClientItem(new Item(550, getName()), 1)); + Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(550, getName()), 1)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java index adfef82bc..2c851cced 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java @@ -1,6 +1,8 @@ package mineplex.core.gadget.gadgets.outfit.ravesuit; import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.bukkit.Color; import org.bukkit.Material; @@ -24,8 +26,7 @@ import mineplex.core.updater.event.UpdateEvent; public class OutfitRaveSuit extends OutfitGadget { - - private HashMap _colorPhase = new HashMap(); + private Map _colorPhase = new HashMap<>(); public OutfitRaveSuit(GadgetManager manager, String name, int cost, ArmorSlot slot, Material mat, byte data) @@ -39,14 +40,14 @@ public class OutfitRaveSuit extends OutfitGadget public void enableCustom(Player player, boolean message) { applyArmor(player, message); - _colorPhase.put(player.getName(), -1); + _colorPhase.put(player.getUniqueId(), -1); } @Override public void disableCustom(Player player, boolean message) { removeArmor(player, message); - _colorPhase.remove(player.getName()); + _colorPhase.remove(player.getUniqueId()); } @EventHandler @@ -109,14 +110,14 @@ public class OutfitRaveSuit extends OutfitGadget } //Rainbow - int phase = _colorPhase.get(player.getName()); + int phase = _colorPhase.get(player.getUniqueId()); LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); if (phase == -1) { meta.setColor(Color.fromRGB(250, 0, 0)); - _colorPhase.put(player.getName(), 0); + _colorPhase.put(player.getUniqueId(), 0); } //Red > Yellow else if (phase == 0) @@ -124,7 +125,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(250, Math.min(250, meta.getColor().getGreen() + 25), 0)); if (meta.getColor().getGreen() >= 250) - _colorPhase.put(player.getName(), 1); + _colorPhase.put(player.getUniqueId(), 1); } //Yellow > Green else if (phase == 1) @@ -132,7 +133,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(Math.max(0, meta.getColor().getRed() - 25), 250, 0)); if (meta.getColor().getRed() <= 0) - _colorPhase.put(player.getName(), 2); + _colorPhase.put(player.getUniqueId(), 2); } //Green > Blue else if (phase == 2) @@ -140,7 +141,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(0, Math.max(0, meta.getColor().getGreen() - 25), Math.min(250, meta.getColor().getBlue() + 25))); if (meta.getColor().getGreen() <= 0) - _colorPhase.put(player.getName(), 3); + _colorPhase.put(player.getUniqueId(), 3); } //Blue > Red else if (phase == 3) @@ -148,7 +149,7 @@ public class OutfitRaveSuit extends OutfitGadget meta.setColor(Color.fromRGB(Math.min(250, meta.getColor().getRed() + 25), 0, Math.max(0, meta.getColor().getBlue() - 25))); if (meta.getColor().getBlue() <= 0) - _colorPhase.put(player.getName(), 0); + _colorPhase.put(player.getUniqueId(), 0); } stack.setItemMeta(meta); @@ -158,7 +159,7 @@ public class OutfitRaveSuit extends OutfitGadget @EventHandler public void playerQuit(PlayerQuitEvent event) { - _colorPhase.remove(event.getPlayer().getName()); + _colorPhase.remove(event.getPlayer().getUniqueId()); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java index 1b3751877..9da1505f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java @@ -56,7 +56,7 @@ public class ParticleKronos extends ParticleGadget /*Until it becomes purchasable*/if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.TITAN)) //if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index e1f76d435..f99338a75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -42,7 +42,7 @@ public class ParticleLegend extends ParticleGadget // TODO HARDCODED Legendary Aura Database Item Id - 552 if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { - Manager.getInventoryManager().Get(event.getPlayer().getName()).addItem(new ClientItem(new Item(552, getName()), 1)); + Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(552, getName()), 1)); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java index f2df819c8..973c54471 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java @@ -96,7 +96,7 @@ public class ParticleTitan extends ParticleGadget { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java index 1f16ff559..9b5836cfe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java @@ -115,9 +115,9 @@ public class WinEffectBabyChicken extends WinEffectGadget } else if(_tick == 20*2) { - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); - _npc.GetEntity().getBukkitEntity().remove(); + _npc.getEntity().getBukkitEntity().remove(); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, loc.clone().add(0, 1, 0), 0.3f, 0.6f, 0.3f, 0.07f, 200, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, loc.clone().add(0, 0.3, 0), 0.7f, 0.1f, 0.7f, 0.07f, 200, ViewDist.NORMAL); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java index ec02b82b9..18b3fb26d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java @@ -45,7 +45,7 @@ public class WinEffectFireworks extends WinEffectGadget start.setDirection(new Vector(1, 0, 0)); _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) @@ -65,7 +65,7 @@ public class WinEffectFireworks extends WinEffectGadget if(event.getType() != UpdateType.SEC) return; if(!isRunning()) return; - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); UtilFirework.launchFirework(loc, Type.values()[UtilMath.r(Type.values().length)], Color.fromRGB(UtilMath.r(255*255*255)), UtilMath.random.nextBoolean(), UtilMath.random.nextBoolean(), new Vector(0,0,0), 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java index 8a99612eb..8a0760799 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFlames.java @@ -49,7 +49,7 @@ public class WinEffectFlames extends WinEffectGadget start.setDirection(new Vector(1, 0, 0)); _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) @@ -69,12 +69,12 @@ public class WinEffectFlames extends WinEffectGadget if(!isRunning()) return; if(event.getType() == UpdateType.FASTEST) { - UtilParticle.PlayParticleToAll(ParticleType.FLAME, _npc.GetEntity().getBukkitEntity().getLocation(), null, 0.1f, 50, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, _npc.getEntity().getBukkitEntity().getLocation(), null, 0.1f, 50, ViewDist.NORMAL); } if(event.getType() == UpdateType.FASTEST) { - Entity e = _npc.GetEntity().getBukkitEntity(); + Entity e = _npc.getEntity().getBukkitEntity(); if(_nextSound == 0) e.getWorld().playSound(e.getLocation(), Sound.FIRE, 3, UtilMath.random.nextFloat()*2); if(_nextSound == 1) e.getWorld().playSound(e.getLocation(), Sound.LAVA, 1.5f, UtilMath.random.nextFloat()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java index 0f05294b6..6624ce9a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectLavaTrap.java @@ -63,7 +63,7 @@ public class WinEffectLavaTrap extends WinEffectGadget Location loc = getBaseLocation().add(f).add(r); loc.setDirection(getBaseLocation().subtract(loc).toVector()); - ((ArmorStand)getNPC(_nonTeam.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true); + ((ArmorStand)getNPC(_nonTeam.get(index), loc).getEntity().getBukkitEntity()).setGravity(true); } for(int index = 0; index < _team.size(); index++) @@ -79,7 +79,7 @@ public class WinEffectLavaTrap extends WinEffectGadget Location loc = getBaseLocation().add(f).add(r); loc.setDirection(getBaseLocation().subtract(loc).toVector()); - ((ArmorStand)getNPC(_team.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true); + ((ArmorStand)getNPC(_team.get(index), loc).getEntity().getBukkitEntity()).setGravity(true); } } @@ -101,7 +101,7 @@ public class WinEffectLavaTrap extends WinEffectGadget Location loc = getBaseLocation(); loc.setDirection(_lever.getLocation().add(0.5, 0, 0.5).subtract(loc.clone().add(0, 1.8, 0)).toVector()); - playerNPC.GetEntity().getBukkitEntity().teleport(loc); + playerNPC.getEntity().getBukkitEntity().teleport(loc); } if(_tick == 20*3) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java index ddc1638b0..6657102c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectMrPunchMan.java @@ -45,7 +45,7 @@ public class WinEffectMrPunchMan extends WinEffectGadget for(int i = 0; i < _other.size(); i++) { - _playersLeft.add((ArmorStand) getNPC(_other.get(i), circle.get(i)).GetEntity().getBukkitEntity()); + _playersLeft.add((ArmorStand) getNPC(_other.get(i), circle.get(i)).getEntity().getBukkitEntity()); } _nextHit = getNextHit() + 1000; @@ -64,9 +64,9 @@ public class WinEffectMrPunchMan extends WinEffectGadget ArmorStand player = _playersLeft.get(0); - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); loc.setDirection(player.getLocation().subtract(loc).toVector()); - _npc.GetEntity().getBukkitEntity().teleport(loc); + _npc.getEntity().getBukkitEntity().teleport(loc); _npc.sendHit(); @@ -93,7 +93,7 @@ public class WinEffectMrPunchMan extends WinEffectGadget @Override public void finish() { - _npc.GetEntity().getBukkitEntity().remove(); + _npc.getEntity().getBukkitEntity().remove(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java index 5a4973f1f..34b7077e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java @@ -1,7 +1,5 @@ package mineplex.core.gadget.gadgets.wineffect; -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -11,8 +9,6 @@ import mineplex.core.common.animation.AnimationPoint; import mineplex.core.common.animation.AnimatorEntity; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; @@ -36,7 +32,7 @@ public class WinEffectPodium extends WinEffectGadget { _npc = getNPC(this._player, getBaseLocation()); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); animator.addPoint(new AnimationPoint( 20, new Vector(0,0,0), new Vector(-1, 0.5, 0))); animator.addPoint(new AnimationPoint( 40, new Vector(0,0,0), new Vector( 0, 0.5,-1))); @@ -45,7 +41,7 @@ public class WinEffectPodium extends WinEffectGadget animator.setRepeat(true); - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); loc.setDirection(new Vector(0, 0.5, 1)); animator.start(loc); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java index 0480418db..6539f59c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectRiseOfTheElderGuardian.java @@ -90,7 +90,7 @@ public class WinEffectRiseOfTheElderGuardian extends WinEffectGadget { for(DisguiseGuardian g : _guardians) { - g.setTarget(_npcPlayer.GetEntityId()); + g.setTarget(_npcPlayer.getEntityId()); Manager.getDisguiseManager().updateDisguise(g); } } @@ -116,7 +116,7 @@ public class WinEffectRiseOfTheElderGuardian extends WinEffectGadget Manager.getDisguiseManager().updateDisguise(g); } - ArmorStand stand = (ArmorStand) _npcPlayer.GetEntity().getBukkitEntity(); + ArmorStand stand = (ArmorStand) _npcPlayer.getEntity().getBukkitEntity(); Manager.getDisguiseManager().undisguise(stand); @@ -134,7 +134,7 @@ public class WinEffectRiseOfTheElderGuardian extends WinEffectGadget { for(DisguiseGuardian g : _guardians) { - g.GetEntity().getBukkitEntity().remove(); + g.getEntity().getBukkitEntity().remove(); } _guardians.clear(); _guardians = null; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java index 536f8f539..42a8c5115 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectSnowTrails.java @@ -48,7 +48,7 @@ public class WinEffectSnowTrails extends WinEffectGadget start.setDirection(new Vector(1, 0, 0)); _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.GetEntity().getBukkitEntity()); + AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) @@ -69,7 +69,7 @@ public class WinEffectSnowTrails extends WinEffectGadget if(event.getType() != UpdateType.TICK) return; - Location loc = _npc.GetEntity().getBukkitEntity().getLocation(); + Location loc = _npc.getEntity().getBukkitEntity().getLocation(); UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, loc.clone().add(0, 1, 0), 0.3f, 1, 0.3f, 0, 20, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, loc.clone().add(0, 0.2, 0), 0.6f, 0.2f, 0.6f, 0, 20, ViewDist.NORMAL); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index 20742f4f3..b76e4e86b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -1,17 +1,13 @@ package mineplex.core.gadget.types; -import java.util.HashSet; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetAppliedEvent; -import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.GadgetDisableEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.shop.item.SalesPackageBase; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -19,6 +15,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.HashSet; + public abstract class Gadget extends SalesPackageBase implements Listener { public GadgetManager Manager; @@ -152,21 +150,15 @@ public abstract class Gadget extends SalesPackageBase implements Listener UtilPlayer.message(player, F.main("Gadget", "You disabled " + F.elem(getName()) + ".")); } - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } - public boolean ownsGadget(Player player) { if(isFree() || _free) return true; - if(Manager.getDonationManager().Get(player.getName()).OwnsUnknownPackage(getName())) { return true; } + if(Manager.getDonationManager().Get(player).OwnsUnknownPackage(getName())) { return true; } if(Manager.getInventoryManager().Get(player).getItemCount(getName()) > 0) { return true; } for(String alt : _alternativePackageNames) { - if(Manager.getDonationManager().Get(player.getName()).OwnsUnknownPackage(alt)) { return true; } + if(Manager.getDonationManager().Get(player).OwnsUnknownPackage(alt)) { return true; } if(Manager.getInventoryManager().Get(player).getItemCount(alt) > 0) { return true; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index 6c647876c..fb63ac704 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -15,7 +15,6 @@ import mineplex.core.gadget.GadgetManager; public abstract class HatGadget extends OutfitGadget { - private ItemStack _hat; private HatType _hatType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java index 7e103aa6c..708e5e5a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MusicGadget.java @@ -3,17 +3,6 @@ package mineplex.core.gadget.types; import java.util.ArrayList; import java.util.Iterator; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetAppliedEvent; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.gadget.gadgets.SongData; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; @@ -21,6 +10,19 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.world.ChunkUnloadEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetAppliedEvent; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.gadget.gadgets.SongData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class MusicGadget extends Gadget { @@ -127,6 +129,23 @@ public class MusicGadget extends Gadget } } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void chunkUnload(ChunkUnloadEvent event) + { + Iterator songIterator = _songs.iterator(); + + while (songIterator.hasNext()) + { + SongData song = songIterator.next(); + + if (song.Block.getChunk().equals(event.getChunk())) + { + song.disable(); + songIterator.remove(); + } + } + } public boolean canPlayAt(Location location) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 7be83f481..c328c1517 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -285,10 +285,10 @@ public abstract class WinEffectGadget extends Gadget stand.setMaxHealth(2048); stand.setHealth(2048); stand.setGravity(false); - + GameProfile profile = new GameProfile(UUID.randomUUID(), player.getName()); profile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); - + DisguisePlayer disguise = new DisguisePlayer(stand, profile); Manager.getDisguiseManager().disguise(disguise); return disguise; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java index 9d86ffa9c..e6f562472 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java @@ -161,9 +161,9 @@ public class GiveawayManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadPlayerGiveaway(resultSet)); + Set(uuid, _repository.loadPlayerGiveaway(resultSet)); } @Override @@ -173,7 +173,7 @@ public class GiveawayManager extends MiniDbClientPlugin } @Override - protected PlayerGiveawayData addPlayer(String player) + protected PlayerGiveawayData addPlayer(UUID uuid) { return new PlayerGiveawayData(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index 5e2d8803e..b06707ed2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -42,7 +42,7 @@ public class Hologram { private boolean _makeSpawnPackets = true; private Packet[] _packets1_8; private Packet[] _packets1_9; - private HashSet _playersInList = new HashSet(); + private HashSet _playersInList = new HashSet<>(); private ArrayList _playersTracking = new ArrayList(); private boolean _removeEntityDeath; private HologramTarget _target = HologramTarget.BLACKLIST; @@ -84,13 +84,13 @@ public class Hologram { * Adds the player to the Hologram to be effected by Whitelist or Blacklist */ public Hologram addPlayer(Player player) { - return addPlayer(player.getName()); + return addPlayer(player.getUniqueId()); } /** * Adds the player to the Hologram to be effected by Whitelist or Blacklist */ - public Hologram addPlayer(String player) { + public Hologram addPlayer(UUID player) { _playersInList.add(player); return this; } @@ -109,14 +109,7 @@ public class Hologram { * Is there a player entry in the hologram for Whitelist and Blacklist */ public boolean containsPlayer(Player player) { - return _playersInList.contains(player.getName()); - } - - /** - * Is there a player entry in the hologram for Whitelist and Blacklist - */ - public boolean containsPlayer(String player) { - return _playersInList.contains(player); + return _playersInList.contains(player.getUniqueId()); } protected Packet getDestroyPacket() { @@ -295,14 +288,14 @@ public class Hologram { * Whitelist or Blacklist */ public Hologram removePlayer(Player player) { - return removePlayer(player.getName()); + return removePlayer(player.getUniqueId()); } /** * Removes the player from the Hologram so they are no longer effected by * Whitelist or Blacklist */ - public Hologram removePlayer(String player) { + public Hologram removePlayer(UUID player) { _playersInList.remove(player); return this; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index 15c0fca39..774544f7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -5,6 +5,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.UUID; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -80,7 +81,7 @@ public class IgnoreManager extends MiniDbClientPlugin } @Override - protected IgnoreData addPlayer(String player) + protected IgnoreData addPlayer(UUID uuid) { return new IgnoreData(); } @@ -230,9 +231,9 @@ public class IgnoreManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 2594b4188..6242b48ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -25,6 +25,7 @@ import org.bukkit.plugin.java.JavaPlugin; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; public class IncognitoManager extends MiniDbClientPlugin { @@ -191,7 +192,7 @@ public class IncognitoManager extends MiniDbClientPlugin UtilPlayer.message(player, " "); } - protected IncognitoClient addPlayer(String player) + protected IncognitoClient addPlayer(UUID uuid) { return new IncognitoClient(); } @@ -208,11 +209,11 @@ public class IncognitoManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { while (resultSet.next()) { - Get(playerName).Status = resultSet.getInt("status") == 1; + Get(uuid).Status = resultSet.getInt("status") == 1; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java index b648ba36b..71f0406c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java @@ -5,6 +5,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.incognito.IncognitoManager; +import mineplex.core.preferences.Preference; import org.bukkit.entity.Player; public class IncognitoToggleCommand extends CommandBase @@ -18,7 +19,7 @@ public class IncognitoToggleCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (Plugin.getPreferences().Get(caller).Invisibility && !Plugin.Get(caller).Status) + if (Plugin.getPreferences().get(caller).isActive(Preference.INVISIBILITY) && !Plugin.Get(caller).Status) { UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled.")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java new file mode 100644 index 000000000..90609b397 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java @@ -0,0 +1,84 @@ +package mineplex.core.interactions; + +import mineplex.core.MiniPlugin; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event.Result; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; + +/** + * Manages interactions with Armor stands, paintings, and in the main hub, taking items out of chests. + */ +public class NewInteractionsManager extends MiniPlugin +{ + + public NewInteractionsManager() + { + super("Interactions Manager"); + registerEvents(this); + } + + @EventHandler + public void onInteract(PlayerArmorStandManipulateEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onClickBrewingStand(PlayerInteractEvent event) + { + if(event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.BREWING_STAND) + { + event.setCancelled(true); + event.setUseInteractedBlock(Result.DENY); + } + } + + @EventHandler + public void onPainting(HangingBreakEvent event) + { + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onChestInteract(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + Inventory inventory = event.getClickedInventory(); + + if(inventory == null) + { + return; + } + + if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) + { + return; + } + + if(inventory.getType() != InventoryType.CHEST) + { + return; + } + + if(inventory.getSize() != 27 && inventory.getSize() != 54) + { + return; + } + + if(inventory.getTitle() != null) + { + return; + } + + event.setCancelled(true); + event.setResult(Result.DENY); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index d3a3c4107..32d51fd55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -1,27 +1,5 @@ package mineplex.core.inventory; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.EnchantingInventory; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.cache.player.PlayerCache; import mineplex.cache.player.PlayerInfo; import mineplex.core.MiniDbClientPlugin; @@ -33,6 +11,26 @@ import mineplex.core.inventory.data.InventoryRepository; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class InventoryManager extends MiniDbClientPlugin { @@ -266,7 +264,7 @@ public class InventoryManager extends MiniDbClientPlugin @EventHandler public void onInventoryClick(final InventoryClickEvent event) { - if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING) + if (event.getClickedInventory() == null || event.getClickedInventory().getType() != InventoryType.ENCHANTING) { return; } @@ -343,7 +341,7 @@ public class InventoryManager extends MiniDbClientPlugin } @Override - protected ClientInventory addPlayer(String player) + protected ClientInventory addPlayer(UUID uuid) { return new ClientInventory(); } @@ -355,9 +353,9 @@ public class InventoryManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet, _itemIdNameMap)); + Set(uuid, _repository.loadClientInformation(resultSet, _itemIdNameMap)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java new file mode 100644 index 000000000..666099f18 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java @@ -0,0 +1,70 @@ +package mineplex.core.menu; + +import mineplex.core.MiniPlugin; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * An abstract class for managing buttons inside of menus + */ +public abstract class Button +{ + + private ItemStack _item; + private T _plugin; + + public Button(ItemStack item, T plugin) + { + _item = item; + _plugin = plugin; + } + + public Button(ItemStack itemStack) + { + _item = itemStack; + _plugin = null; + } + + /** + * The method called when a players clicks the slot + * + * @param player The player who clicked + * @param clickType Tge type of click + */ + public abstract void onClick(Player player, ClickType clickType); + + /** + * Called when clicking on a specific item is needed, rather than just the slot + * Empty by default + * + * @param player The player who clicked + * @param clickType Tge type of click + * @param item The ItemStack clicked + */ + public void onClick(Player player, ClickType clickType, ItemStack item) + { + + } + + public boolean useItemClick() + { + return false; + } + + public ItemStack getItemStack() + { + return _item; + } + + public void setItemStack(ItemStack item) + { + _item = item; + } + + public T getPlugin() + { + return _plugin; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/IconButton.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/IconButton.java similarity index 64% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/IconButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/menu/IconButton.java index 0e80c09cd..738472006 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/IconButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/IconButton.java @@ -1,7 +1,5 @@ -package mineplex.core.party.ui.button; +package mineplex.core.menu; -import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -13,9 +11,9 @@ import org.bukkit.inventory.ItemStack; public class IconButton extends Button { - public IconButton(ItemStack item, PartyManager plugin) + public IconButton(ItemStack item) { - super(item, plugin); + super(item); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/Menu.java similarity index 61% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/Menu.java rename to Plugins/Mineplex.Core/src/mineplex/core/menu/Menu.java index 3775d46e9..6871c92d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/Menu.java @@ -1,10 +1,7 @@ -package mineplex.core.party.ui; +package mineplex.core.menu; -import mineplex.core.common.util.C; +import mineplex.core.MiniPlugin; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.button.IconButton; -import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; import org.bukkit.DyeColor; import org.bukkit.Material; @@ -20,26 +17,20 @@ import java.util.UUID; /** * A class to manage dynamic creation of GUI's */ -public abstract class Menu +public abstract class Menu { - protected static final Button PANE = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE) - .setTitle(" ") - .setData(DyeColor.LIGHT_BLUE.getWoolData()) - .build(), null); - - protected static final Button PURCHASE_MORE_SLOTS = new IconButton(new ItemBuilder(Material.REDSTONE_BLOCK) - .setTitle(C.cRed + C.Bold + "Locked!") - .setLore(" ", C.cGray + "Purchase a rank @ mineplex.com/shop", C.cGray + "Purchasing a rank increases your", C.cGray + "party size to allow 10 people!") - .build(), null); + private final ItemStack PANE = new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(" ").setData(DyeColor.LIGHT_BLUE.getWoolData()).build(); protected static final Button[] EMPTY = new Button[54]; - protected static Map MENUS = new HashMap<>(); - private String _name; + protected static final Map MENUS = new HashMap<>(); + private final String _name; + private final T _plugin; + private boolean _useClose = false; private Button[] _buttons; - protected PartyManager _plugin; + private Player _player; - public Menu(String name, PartyManager plugin) + public Menu(String name, T plugin) { _name = name; _buttons = EMPTY; @@ -51,50 +42,14 @@ public abstract class Menu return MENUS.get(name); } - /** - * Create an icon (no click action) - * - * @param item The itemstack ti display - * @return The created button - */ - protected Button create(ItemStack item) + public T getPlugin() { - return new IconButton(item, _plugin); + return _plugin; } public String getName() { - return ChatColor.translateAlternateColorCodes('&', _name); - } - - public Button[] addPanes(Button[] buttons) - { - for (int i = 0; i < 9; i++) - { - if (buttons[i] == null) - { - buttons[i] = PANE; - } - - if(buttons.length == 9) - { - continue; - } - - if (buttons[i + buttons.length - 9] == null) - { - buttons[i + buttons.length - 9] = PANE; - } - - if (i == 0 || i == 8) - { - for (int a = 9; a < buttons.length; a += 9) - { - buttons[i + a] = PANE; - } - } - } - return buttons; + return _name; } /** @@ -105,6 +60,7 @@ public abstract class Menu */ public void open(Player player) { + _player = player; setButtons(setUp(player)); if (MENUS.get(player.getUniqueId()) != null) @@ -115,7 +71,7 @@ public abstract class Menu MENUS.put(player.getUniqueId(), this); int size = (_buttons.length + 8) / 9 * 9; - Inventory inventory = Bukkit.createInventory(player, size, getName()); + Inventory inventory = Bukkit.createInventory(player, size, _name); for (int i = 0; i < _buttons.length; i++) { @@ -173,9 +129,8 @@ public abstract class Menu * * @param slot The slot to set the new button * @param button The reference to the button - * @param player The player whose GUI we'll be updating */ - public void setButton(int slot, Button button, Player player) + public void setButton(int slot, Button button) { try { @@ -184,24 +139,22 @@ public abstract class Menu { ignored.printStackTrace(); } - update(player); + update(); } /** * Refresh the players view, allows to change what the player sees, without opening and closing the GUI - * - * @param player The player whose view you wish to update */ - public void update(Player player) + public void update() { - InventoryView view = player.getOpenInventory(); + InventoryView view = _player.getOpenInventory(); if (view == null) { return; } - if (!view.getTitle().equalsIgnoreCase(getName())) + if (!view.getTitle().equalsIgnoreCase(_name)) { return; } @@ -222,25 +175,23 @@ public abstract class Menu /** * Reset this players current menu's buttons and refresh the page - * - * @param player The player whose view you wish to update */ - public void resetAndUpdate(Player player) + public void resetAndUpdate() { - InventoryView view = player.getOpenInventory(); + InventoryView view = _player.getOpenInventory(); if (view == null) { return; } - if (!view.getTitle().equalsIgnoreCase(getName())) + if (!view.getTitle().equalsIgnoreCase(_name)) { return; } Inventory inventory = view.getTopInventory(); - Button[] buttons = setUp(player); + Button[] buttons = setUp(_player); for (int i = 0; i < buttons.length; i++) { if (buttons[i] == null) @@ -254,19 +205,56 @@ public abstract class Menu } } - - public void setTitle(String title) + protected Button[] pane(Button[] buttons) { - _name = title; + for (int i = 0; i < 9; i++) + { + if (buttons[i] == null) + { + buttons[i] = new IconButton(PANE); + } + + if (buttons[i + buttons.length - 9] == null) + { + buttons[i + buttons.length - 9] = new IconButton(PANE); + } + + if (i == 0 || i == 8) + { + for (int a = 0; a < buttons.length; a += 9) + { + if (buttons[i + a] == null) + { + buttons[i + a] = new IconButton(PANE); + } + } + } + } + return buttons; } public void onClose(Player player) { - MENUS.remove(player.getUniqueId()); + } public static Menu remove(UUID uniqueId) { return MENUS.remove(uniqueId); } + + public Player getPlayer() + { + return _player; + } + + public boolean isUseClose() + { + return _useClose; + } + + public void setUseClose(boolean useClose) + { + _useClose = useClose; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/MenuListener.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuListener.java similarity index 60% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/MenuListener.java rename to Plugins/Mineplex.Core/src/mineplex/core/menu/MenuListener.java index fb28a5a7c..132d68e9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/MenuListener.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuListener.java @@ -1,12 +1,11 @@ -package mineplex.core.party.ui; +package mineplex.core.menu; -import mineplex.core.party.ui.button.PartyMemberIcon; -import mineplex.core.party.ui.menus.PartyOwnerMenu; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; /** * Listener for the Menu system @@ -41,17 +40,37 @@ public class MenuListener implements Listener return; } - if(button instanceof PartyMemberIcon) + if(button.useItemClick()) { - if(!(gui instanceof PartyOwnerMenu)) - { - return; - } - ((PartyMemberIcon) button).onClick(player, event.getCurrentItem()); + button.onClick(player, event.getClick(), event.getCurrentItem()); return; } button.onClick(player, event.getClick()); } + @EventHandler + public void onClose(InventoryCloseEvent event) + { + String name = event.getInventory().getName(); + Player player = (Player) event.getPlayer(); + Menu gui = Menu.get(player.getUniqueId()); + + if (gui == null) + { + return; + } + + if (!gui.getName().equalsIgnoreCase(name)) + { + return; + } + + if(gui.isUseClose()) + { + gui.onClose(player); + gui.setUseClose(false); + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java new file mode 100644 index 000000000..c16022a61 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java @@ -0,0 +1,18 @@ +package mineplex.core.menu; + +import mineplex.core.MiniPlugin; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * + */ +public class MenuManager extends MiniPlugin +{ + + public MenuManager(JavaPlugin plugin) + { + super("Menu Manager", plugin); + getPluginManager().registerEvents(new MenuListener(), plugin); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 3faaee528..63c3e632e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -4,18 +4,28 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.friend.FriendManager; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; -import mineplex.core.message.commands.*; -import mineplex.core.message.redis.AnnouncementHandler; -import mineplex.core.message.redis.MessageHandler; +import mineplex.core.message.commands.AdminCommand; +import mineplex.core.message.commands.AnnounceCommand; +import mineplex.core.message.commands.MessageAdminCommand; +import mineplex.core.message.commands.MessageCommand; +import mineplex.core.message.commands.ResendAdminCommand; +import mineplex.core.message.commands.ResendCommand; import mineplex.core.message.redis.RedisMessage; import mineplex.core.message.redis.RedisMessageCallback; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Punish; import mineplex.core.punish.PunishClient; @@ -62,14 +72,35 @@ public class MessageManager extends MiniClientPlugin _chat = chat; _serverName = getPlugin().getConfig().getString("serverstatus.name"); - MessageHandler messageHandler = new MessageHandler(this); + ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, command -> + { + Rank rank; + try + { + rank = Rank.valueOf(command.getRank()); + } + catch (Exception e) + { + e.printStackTrace(); + return; + } - ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, - new AnnouncementHandler(clientManager)); + String message = command.getMessage(); - ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler); - ServerCommandManager.getInstance() - .registerCommandType("RedisMessageCallback", RedisMessageCallback.class, messageHandler); + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_clientManager.hasRank(player, rank)) + { + if (command.getDisplayTitle()) + UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player); + + UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); + } + } + }); + + ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, this::receiveMessage); + ServerCommandManager.getInstance().registerCommandType("RedisMessageCallback", RedisMessageCallback.class, this::receiveMessageCallback); } public void addCommands() @@ -87,10 +118,10 @@ public class MessageManager extends MiniClientPlugin } @Override - protected ClientMessage addPlayer(String player) + protected ClientMessage addPlayer(UUID uuid) { - Set(player, new ClientMessage()); - return Get(player); + Set(uuid, new ClientMessage()); + return Get(uuid); } public boolean canMessage(Player from, Player to) @@ -115,7 +146,7 @@ public class MessageManager extends MiniClientPlugin public String canReceiverMessageThem(String sender, Player target) { // If the receiver has turned off private messaging and the sender isn't a mod - if (!_preferences.Get(target).PrivateMessaging) + if (!_preferences.get(target).isActive(Preference.PRIVATE_MESSAGING)) { return C.cPurple + target.getName() + " has private messaging disabled."; @@ -215,15 +246,10 @@ public class MessageManager extends MiniClientPlugin Get(from).LastToTime = System.currentTimeMillis(); // Chiss or defek7 - if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("AlexTheCoder")) + if (GetClientManager().Get(to).GetRank() == Rank.DEVELOPER) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); - UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); - } - if (to.getName().equals("xXVevzZXx")) - { - UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); - UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly."); + UtilPlayer.message(from, C.cPurple + "Please be patient if they do not reply instantly."); } // Log @@ -240,7 +266,7 @@ public class MessageManager extends MiniClientPlugin public void DoMessageAdmin(Player from, Player to, String message) { // Inform - UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).getRealOrDisguisedRank()) + " " + to.getName() + " " + C.cPurple + message); // Inform Admins @@ -250,8 +276,8 @@ public class MessageManager extends MiniClientPlugin { if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) { - UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple - + " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message); + UtilPlayer.message(staff, F.rank(_clientManager.Get(from).getRealOrDisguisedRank()) + " " + from.getName() + C.cPurple + + " -> " + F.rank(_clientManager.Get(to).getRealOrDisguisedRank()) + " " + to.getName() + " " + C.cPurple + message); } } } @@ -260,7 +286,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastAdminTo = to.getName(); // Send - UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + " " + UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).getRealOrDisguisedRank()) + " " + from.getName() + " " + C.cPurple + message); // Sound @@ -343,8 +369,13 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?")); } - public void receiveMessage(Player to, RedisMessage globalMessage) + public void receiveMessage(RedisMessage globalMessage) { + Player to = Bukkit.getPlayerExact(globalMessage.getTarget()); + + if (to == null) + return; + if (globalMessage.isStaffMessage()) { // Message the receiver @@ -353,7 +384,7 @@ public class MessageManager extends MiniClientPlugin to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); - String toRank = F.rank(_clientManager.Get(to).GetRank()); + String toRank = F.rank(_clientManager.Get(to).getRealOrDisguisedRank()); // Message the sender RedisMessageCallback message = new RedisMessageCallback(globalMessage, true, to.getName(), @@ -436,7 +467,7 @@ public class MessageManager extends MiniClientPlugin if (message.isStaffMessage() && message.getLastReplied() != null) { - String recevierRank = F.rank(_clientManager.Get(target).GetRank()); + String recevierRank = F.rank(_clientManager.Get(target).getRealOrDisguisedRank()); // Inform Admins for (Player staff : UtilServer.getPlayers()) @@ -520,7 +551,7 @@ public class MessageManager extends MiniClientPlugin // If this is a message inside the server if (to != null) { - if (_incognitoManager.Get(to).Status && !_clientManager.Get(sender.getName()).GetRank().has(Rank.HELPER)) + if (_incognitoManager.Get(to).Status && !_clientManager.Get(sender.getUniqueId()).GetRank().has(Rank.HELPER)) { UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); return; @@ -570,7 +601,7 @@ public class MessageManager extends MiniClientPlugin playerTarget, message, // Include the sender's rank if this is a admin message. So we can format the receivers chat. - adminMessage ? F.rank(_clientManager.Get(sender).GetRank()) : null); + adminMessage ? F.rank(_clientManager.Get(sender).getRealOrDisguisedRank()) : null); final UUID uuid = globalMessage.getUUID(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 78ff81799..24cd9db26 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -42,7 +42,7 @@ public class AdminCommand extends CommandBase String message = F.combine(args, 0, null, false); //Inform - UtilPlayer.message(caller, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); + UtilPlayer.message(caller, F.rank(Plugin.GetClientManager().Get(caller).getRealOrDisguisedRank()) + " " + caller.getName() + " " + C.cPurple + message); //Send for (Player to : UtilServer.getPlayers()) @@ -51,7 +51,7 @@ public class AdminCommand extends CommandBase { if (!to.equals(caller)) - UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); + UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).getRealOrDisguisedRank()) + " " + caller.getName() + " " + C.cPurple + message); if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java deleted file mode 100644 index 3715bc60f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package mineplex.core.message.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.message.MessageManager; - -public class AdminMessageCommand extends CommandBase -{ - public AdminMessageCommand(MessageManager plugin) - { - super(plugin, Rank.SNR_MODERATOR, "am"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args == null || args.length == 0) - { - Plugin.Help(caller); - } - else - { - if (args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing.")); - return; - } - - // Parse Message - String message = "Beep!"; - if (args.length > 1) - { - message = F.combine(args, 1, null, false); - } - else - { - message = Plugin.GetRandomMessage(); - } - - Plugin.sendMessage(caller, args[0], message, false, true); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java index cdacc6ef3..738bf5e9d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -12,7 +12,7 @@ public class MessageAdminCommand extends CommandBase { public MessageAdminCommand(MessageManager plugin) { - super(plugin, Rank.ALL, "ma"); + super(plugin, Rank.HELPER, "ma"); } @Override @@ -20,30 +20,11 @@ public class MessageAdminCommand extends CommandBase { if (args == null || args.length == 0) { - Plugin.Help(caller); + UtilPlayer.message(caller, F.help(Plugin.getName(), "/ma [message]", GetRequiredRank())); } else { - if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true)) - return; - - if (args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing.")); - return; - } - - // Parse Message - String message = "Beep!"; - if (args.length > 1) - { - message = F.combine(args, 1, null, false); - } - else - { - message = Plugin.GetRandomMessage(); - } - + String message = args.length > 1 ? F.combine(args, 1, null, false) : Plugin.GetRandomMessage(); Plugin.sendMessage(caller, args[0], message, false, true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java deleted file mode 100644 index 6901ad162..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -package mineplex.core.message.redis; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.serverdata.commands.AnnouncementCommand; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class AnnouncementHandler implements CommandCallback -{ - private CoreClientManager _clientManager; - - public AnnouncementHandler(CoreClientManager clientManager) - { - _clientManager = clientManager; - } - - public void run(ServerCommand command) - { - if (command instanceof AnnouncementCommand) - { - AnnouncementCommand announcementCommand = (AnnouncementCommand)command; - - Rank rank; - try - { - rank = Rank.valueOf(announcementCommand.getRank()); - } - catch (Exception e) - { - e.printStackTrace(); - return; - } - - String message = announcementCommand.getMessage(); - - for (Player player : Bukkit.getOnlinePlayers()) - { - if (_clientManager.hasRank(player, rank)) - { - if (announcementCommand.getDisplayTitle()) - UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player); - - UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); - } - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java deleted file mode 100644 index d42424a9f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/MessageHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package mineplex.core.message.redis; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import mineplex.core.message.MessageManager; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -public class MessageHandler implements CommandCallback -{ - private MessageManager _messageManager; - - public MessageHandler(MessageManager messageManager) - { - _messageManager = messageManager; - } - - public void run(ServerCommand command) - { - if (command instanceof RedisMessage) - { - RedisMessage message = (RedisMessage) command; - - Player target = Bukkit.getPlayerExact(message.getTarget()); - - if (target != null) - { - _messageManager.receiveMessage(target, message); - } - } - else if (command instanceof RedisMessageCallback) - { - - _messageManager.receiveMessageCallback((RedisMessageCallback) command); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 47c37044a..802b3d643 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -36,7 +36,7 @@ public class LagMeter extends MiniPlugin private boolean _timingsRunning; private boolean _timingsPasted; private long _timingsStarted; - + private HashSet _monitoring = new HashSet(); public LagMeter(JavaPlugin plugin, CoreClientManager clientManager) @@ -86,7 +86,7 @@ public class LagMeter extends MiniPlugin long now = System.currentTimeMillis(); _ticksPerSecond = 1000D / (now - _lastRun) * 20D; - + sendUpdates(); if (_count % 30 == 0) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java index b63bea8d9..9735c3a20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java @@ -1,8 +1,10 @@ package mineplex.core.mount; -import java.util.HashMap; -import java.util.HashSet; - +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -12,12 +14,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.mount.event.MountActivateEvent; -import mineplex.core.shop.item.SalesPackageBase; +import java.util.HashMap; +import java.util.HashSet; public abstract class Mount extends SalesPackageBase implements Listener { @@ -35,12 +33,6 @@ public abstract class Mount extends SalesPackageBase implem Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin()); } - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } - public final void enable(Player player) { MountActivateEvent gadgetEvent = new MountActivateEvent(player, this); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java index bf17e7716..2233a9baf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -108,7 +108,7 @@ public class MountDragon extends DragonMount { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java index 5ee7e2377..9bd3f4f07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java @@ -137,7 +137,7 @@ public class MountTitan extends Mount { if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(getName()); + Manager.getDonationManager().Get(event.getPlayer()).AddUnknownSalesPackagesOwned(getName()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java b/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java index 40d547a39..d93a7358f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/movement/Movement.java @@ -10,6 +10,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import java.util.UUID; + public class Movement extends MiniClientPlugin { public Movement(JavaPlugin plugin) @@ -40,7 +42,7 @@ public class Movement extends MiniClientPlugin } @Override - protected ClientMovement addPlayer(String player) + protected ClientMovement addPlayer(UUID uuid) { return new ClientMovement(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 64cb728bd..a139ba368 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -1,11 +1,5 @@ package mineplex.core.notifier; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -14,8 +8,10 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.PreferencesManager; -import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; public class NotificationManager extends MiniPlugin { @@ -60,7 +56,7 @@ public class NotificationManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (!_preferencesManager.Get(player).DisableAds) + if (_preferencesManager.getClientManager().Get(player).GetRank() == Rank.ALL) { player.sendMessage(C.cWhite + " "); player.sendMessage(C.cRedB + " MASSIVE WINTER SALE"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java index d8076b1cf..9b874b74a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java @@ -2,6 +2,7 @@ package mineplex.core.packethandler; import com.mineplex.spigot.PacketProcessor; import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; import net.minecraft.server.v1_8_R3.Packet; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -9,7 +10,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; import java.util.ArrayList; import java.util.HashMap; @@ -21,6 +21,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; +@ReflectivelyCreateMiniPlugin public class PacketHandler extends MiniPlugin { private Map _playerVerifierMap = new HashMap<>(); @@ -28,9 +29,9 @@ public class PacketHandler extends MiniPlugin private Map, Set> _forceMainThread = new HashMap<>(); private Map, Map>> _packetHandlers = new HashMap<>(); - public PacketHandler(JavaPlugin plugin) + private PacketHandler() { - super("PacketHandler", plugin); + super("PacketHandler"); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java index 0eb36e2d7..87ec559c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java @@ -39,4 +39,9 @@ public class PacketVerifier implements IPacketVerifier { return _packetHandler.handlePacket(new PacketInfo(_owner, packet, this)); } + + public Player getOwner() + { + return this._owner; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java b/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java index 0cccd2bc9..1826241a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java @@ -1,6 +1,7 @@ package mineplex.core.party; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import org.bukkit.entity.Player; import java.text.MessageFormat; @@ -44,10 +45,25 @@ public enum Lang PARTY_FULL("Error: Your party is full!"), SERVER_CLOSED("Error: Your server is closed and you cannot invite players to join it right now!"), SERVER_FULL("Error: Your server is full and you cannot invite more players to join it right now!"), - PLAYER_IN_DIFFERENT_PARTY("Error: {0} is in a different party.") - + PLAYER_IN_DIFFERENT_PARTY("Error: {0} is in a different party."), + + PARTNER_ALREADY_INVITED("Error: You have already invited {0} to be your partner for {1}."), + PARTNER_NO_GAME("Error: {0} is not a valid game name."), + PARTNER_NO_PLAYER("Error: You didn't specify a player to partner with."), + PARTNER_NOT_ONLINE("Error: {0} is not on your server!"), + PARTNER_PLAYER_NOT_REQUESTED("Error: {0} hasn't made a partner request with you yet!"), + PARTNER_USAGE("Usage: /teampref accept/deny ."), + PARTNER_HOVER_TEXT_ACCEPT("Click to be {0}''s partner for {1}."), + PARTNER_HOVER_TEXT_DENY("Click to decline being {0}''s partner for {1}."), + PARTNER_REQUEST_SENT("Partner request sent to {0} for {1}."), + PARTNER_REQUEST_RECEIVED("Partner request from {0} for {1}."), + PARTNER_REQUEST_DENIED_SENDER("{0} has declined your partner request for {1}."), + PARTNER_REQUEST_DENIED_PLAYER("You have denied {0}''s partner request for {1}."), + PARTNER_REQUEST_ACCEPT_SENDER("{0} has accepted your partner request for {1}."), + PARTNER_REQUEST_ACCEPT_PLAYER("You have accepted {0}''s partner request for {1}."), ; - + + private String _message; Lang(String message) @@ -55,6 +71,16 @@ public enum Lang _message = message; } + public String toString(String... args) + { + return getFormatted(args); + } + + public void sendHeader(Player player, String header, String... args) + { + player.sendMessage(F.main(header, getFormatted(args))); + } + public void send(Player player, String... args) { player.sendMessage(C.mHead + "Party> " + getFormatted(args)); @@ -65,16 +91,16 @@ public enum Lang party.sendMessage(C.mHead + "Party> " + getFormatted(args)); } - private String getFormatted(String[] args) + private String getFormatted(String... args) { String color = C.mBody; - if(args.length == 0) + if (args == null || args.length == 0) { return color + _message; } - if(_message.startsWith("Error:")) + if (_message.startsWith("Error:")) { color = C.cRed; } @@ -83,7 +109,7 @@ public enum Lang String[] coloredArgs = new String[args.length]; - for(int i = 0; i < args.length; i++) + for (int i = 0; i < args.length; i++) { coloredArgs[i] = C.cYellow + args[i] + color; } @@ -96,4 +122,4 @@ public enum Lang return message; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java index b5eb8ee63..4c7640728 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java @@ -31,14 +31,14 @@ public class Party private transient boolean _alreadyTeamed = false; /** - * The standard size for parties, for ALL {@code {@link mineplex.core.common.Rank}} + * The maximum amount of players a party can have. */ - private static final int PARTY_MIN_SIZE = 5; + private static final int PARTY_MAX_SIZE = 16; /** - * An upgraded size for the party, given to donators and staff. + * Partners that have already been placed */ - private static final int PARTY_MAX_SIZE = 10; + private transient final List _teamed; /** * The current leader of this party @@ -65,12 +65,17 @@ public class Party */ private int _size; + /** + * Team preferences + */ + private Map> _preferences; + /** * Empty constructor for GSON */ public Party() { - + _teamed = Lists.newArrayList(); } /** @@ -84,7 +89,10 @@ public class Party _members = Lists.newArrayList(); _invites = Maps.newHashMap(); _members.add(owner); + _teamed = Lists.newArrayList(); _membersByUUID = Lists.newArrayList(); + _preferences = Maps.newHashMap(); + _membersByUUID.add(Bukkit.getPlayerExact(owner).getUniqueId()); } public String getOwner() @@ -119,6 +127,38 @@ public class Party return _owner; } + /** + * Gets the players preferred teammate for a game + * + * @param player The player's UUID + * @return His team preference + */ + public String getPartner(UUID player, String game) + { + Map prefs = _preferences.get(player); + if (prefs == null) + { + prefs = Maps.newHashMap(); + _preferences.put(player, prefs); + return null; + } + return prefs.get(game); + } + + /** + * Set a player's partner preference + * + * @param player The player + * @param game The name of the game + * @param partner The name of his partner + */ + public void setPartner(Player player, String game, String partner) + { + Map prefs = _preferences.getOrDefault(player.getUniqueId(), Maps.newHashMap()); + prefs.put(game, partner); + _preferences.put(player.getUniqueId(), prefs); + } + /** * Send's a message to the party * @@ -126,7 +166,7 @@ public class Party */ public void sendMessage(String message) { - getMembers().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message)); + getMembersByUUID().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message)); } public int getSize() @@ -179,10 +219,12 @@ public class Party bukkitPlayer.closeInventory(); return; } + if(_members.size() <= 0) { return; } + if(reason == PartyRemoveReason.LEFT) { if(player.equalsIgnoreCase(_owner) && _members.size() > 1) @@ -196,10 +238,12 @@ public class Party Lang.REMOVE_PLAYER.send(this, player); return; } + if(reason == PartyRemoveReason.OTHER) { return; } + if(reason == PartyRemoveReason.KICKED) { Lang.REMOVE_PLAYER_KICK.send(this, player); @@ -265,13 +309,26 @@ public class Party */ public boolean contains(String name) { - for(String s : _members) + for (UUID member : _membersByUUID) { - if(s.equalsIgnoreCase(name)) + if (Bukkit.getPlayer(member).getName().equalsIgnoreCase(name)) { return true; } } return false; } + + public boolean isAlreadyTeamed(UUID uuid) + { + return _teamed.contains(uuid); + } + + public void setTeamed(Player... players) + { + for (Player player : players) + { + _teamed.add(player.getUniqueId()); + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java index a6cb19271..9f88df666 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java @@ -1,11 +1,13 @@ package mineplex.core.party; import mineplex.core.common.Rank; +import mineplex.core.menu.Menu; import mineplex.core.party.constants.PartyRemoveReason; import mineplex.core.party.event.PartyMemberKickGUIEvent; +import mineplex.core.party.event.PartySendToServerEvent; import mineplex.core.party.event.PartyTransferOwnerEvent; -import mineplex.core.party.ui.Menu; import mineplex.core.portal.ServerTransferEvent; +import mineplex.serverdata.data.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -34,8 +36,6 @@ public class PartyEventListener implements Listener { Player player = event.getPlayer(); - player.getInventory().setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM); - String partyName = _plugin.getInviteManager().getPartyWaiting(player.getUniqueId()); if (partyName == null) @@ -109,7 +109,7 @@ public class PartyEventListener implements Listener Player clicked = Bukkit.getPlayerExact(event.getPlayerClicked()); Lang.REMOVED.send(clicked); _plugin.getMethodManager().removeFromParty(clicked, PartyRemoveReason.KICKED); - Menu.get(event.getOwner().getUniqueId()).resetAndUpdate(event.getOwner()); + Menu.get(event.getOwner().getUniqueId()).resetAndUpdate(); } @EventHandler @@ -128,6 +128,7 @@ public class PartyEventListener implements Listener return; } + event.setParty(party); event.setCancel(true); if (!party.getOwner().equalsIgnoreCase(player.getName())) @@ -136,8 +137,21 @@ public class PartyEventListener implements Listener return; } - _plugin.getJoinManager().requestServerJoin(event.getServer(), party); + String server = event.getServer(); + if(server.equalsIgnoreCase("Lobby")) + { + return; + } + _plugin.getJoinManager().requestServerJoin(event.getServer(), party); + } + + @EventHandler + public void onSend(PartySendToServerEvent event) + { + Party party = event.getParty(); + MinecraftServer server = event.getMinecraftServer(); + _plugin.getRedisManager().sendPartyInfo(server.getName(), party); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 918d3f8b6..13d20aca5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -10,9 +10,9 @@ import mineplex.core.party.manager.PartyInviteManager; import mineplex.core.party.manager.PartyJoinManager; import mineplex.core.party.manager.PartyMethodManager; import mineplex.core.party.manager.PartyRedisManager; -import mineplex.core.party.ui.MenuListener; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.serverdata.Region; import mineplex.serverdata.Utility; import mineplex.serverdata.servers.ServerManager; import org.bukkit.Material; @@ -20,6 +20,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; import java.util.Map; import java.util.UUID; @@ -58,6 +59,8 @@ public class PartyManager extends MiniPlugin * A map of owner (name) -> party server wide */ private final Map _parties = Maps.newHashMap(); + private final Region _region; + public PartyManager(JavaPlugin plugin, Portal portal, CoreClientManager clientManager, PreferencesManager preferenceManager) { @@ -77,8 +80,9 @@ public class PartyManager extends MiniPlugin _methodManager = new PartyMethodManager(this); addCommand(new PartyCommand(this)); - getPluginManager().registerEvents(new MenuListener(), getPlugin()); new PartyEventListener(this); + _region = !new File("eu.dat").exists() ? Region.US : Region.EU; + } public Party getParty(String party) @@ -150,4 +154,10 @@ public class PartyManager extends MiniPlugin { return _parties; } + + public Region getRegion() + { + return _region; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java new file mode 100644 index 000000000..ad27de3fa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java @@ -0,0 +1,167 @@ +package mineplex.core.party.command; + +import com.google.common.collect.Maps; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.game.GameDisplay; +import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.Map; +import java.util.UUID; + +/** + * Unused for now. + */ +public class TeamPreferenceCommand extends CommandBase +{ + + private static final String[] ARGS = { + "teampref", + "teamprefs", + "teamp", + "tprefs", + "teampreferences" + }; + + private final String ACCEPT = "accept"; + private final String DENY = "deny"; + + private final String ACCEPT_COMMAND = "/teamprefs accept "; + private final String DENY_COMMAND = "/teamprefs deny "; + + private final String HEADER = "Partners"; + + //Player, Partner, GameName + private Map> INVITES = Maps.newHashMap(); + + public TeamPreferenceCommand(PartyManager plugin) + { + super(plugin, Rank.ALL, ARGS); + } + + @Override + public void Execute(Player player, String[] args) + { + if (args.length < 2) + { + Lang.PARTNER_USAGE.sendHeader(player, HEADER); + return; + } + + String arg = args[0]; + + if (arg.equalsIgnoreCase(ACCEPT) || arg.equalsIgnoreCase(DENY)) + { + Party party = Plugin.getParty(player); + + if (party == null) + { + Lang.NO_PARTY.send(player); + return; + } + + String inviter = args[1]; + boolean accept = arg.equalsIgnoreCase(ACCEPT); + Player inviterPlayer = Bukkit.getPlayerExact(inviter); + + if (inviterPlayer == null) + { + Lang.PARTNER_NOT_ONLINE.sendHeader(player, HEADER, inviter); + return; + } + + Map sent = INVITES.get(inviterPlayer.getUniqueId()); + + if (sent == null || sent.isEmpty()) + { + Lang.PARTNER_PLAYER_NOT_REQUESTED.sendHeader(player, HEADER, inviter); + return; + } + + if (sent.get(player.getName()) == null) + { + Lang.PARTNER_PLAYER_NOT_REQUESTED.sendHeader(player, HEADER, inviter); + return; + } + + String gameName = sent.remove(player.getName()); + + if (!accept) + { + Lang.PARTNER_REQUEST_DENIED_PLAYER.send(player, inviterPlayer.getName(), gameName); + Lang.PARTNER_REQUEST_DENIED_SENDER.send(inviterPlayer, player.getName(), gameName); + return; + } + + Lang.PARTNER_REQUEST_ACCEPT_PLAYER.send(player, inviterPlayer.getName(), gameName); + Lang.PARTNER_REQUEST_ACCEPT_SENDER.send(inviterPlayer, player.getName(), gameName); + party.setPartner(player, gameName, inviterPlayer.getName()); + party.setPartner(inviterPlayer, gameName, player.getName()); + return; + } + + Player target = Bukkit.getPlayerExact(arg); + String gameName = ""; + String[] game = new String[args.length - 2]; + System.arraycopy(args, 2, game, 0, game.length); + + for (String s : game) + { + gameName += s + " "; + } + + gameName = gameName.trim(); + + GameDisplay gameDisplay = GameDisplay.matchName(gameName); + + if (gameDisplay == null) + { + Lang.PARTNER_NO_GAME.sendHeader(player, HEADER, gameName); + return; + } + + gameName = gameDisplay.getName(); + + if (alreadyInvited(player, gameName, target.getName())) + { + Lang.PARTNER_ALREADY_INVITED.sendHeader(player, HEADER, target.getName(), gameName); + return; + } + + sendRequest(player, gameName, target); + } + + private void sendRequest(Player player, String game, Player partner) + { + invite(player, game, partner); + String gameName = C.cGreen + (game); + String playerName = C.cGreen + (player.getName()); + String partnerName = C.cGreen + (partner.getName()); + String acceptCommand = ACCEPT_COMMAND + player.getName(); + String declineCommand = DENY_COMMAND + player.getName(); + String acceptText = Lang.PARTNER_HOVER_TEXT_ACCEPT.toString(playerName, gameName); + String declineText = Lang.PARTNER_HOVER_TEXT_DENY.toString(playerName, gameName); + Lang.PARTNER_REQUEST_SENT.sendHeader(player, HEADER, partnerName, gameName); + Lang.PARTNER_REQUEST_RECEIVED.sendHeader(partner, HEADER, playerName, gameName); + UtilPlayer.sendAcceptOrDeny(partner, HEADER, acceptCommand, acceptText, declineCommand, declineText, null, null); + } + + private boolean alreadyInvited(Player player, String game, String partner) + { + Map sent = INVITES.get(player.getUniqueId()); + return !(sent == null || sent.isEmpty()) && sent.get(partner).equalsIgnoreCase(game); + } + + private void invite(Player player, String game, Player partner) + { + Map sent = INVITES.getOrDefault(player.getUniqueId(), Maps.newHashMap()); + sent.put(partner.getName(), game); + INVITES.put(player.getUniqueId(), sent); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/event/PartySendToServerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/party/event/PartySendToServerEvent.java new file mode 100644 index 000000000..604db6eb7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/event/PartySendToServerEvent.java @@ -0,0 +1,44 @@ +package mineplex.core.party.event; + +import mineplex.core.party.Party; +import mineplex.serverdata.data.MinecraftServer; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * + */ +public class PartySendToServerEvent extends Event +{ + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Party _party; + private final MinecraftServer _minecraftServer; + + public PartySendToServerEvent(Party party, MinecraftServer minecraftServer) + { + _party = party; + _minecraftServer = minecraftServer; + } + + public Party getParty() + { + return _party; + } + + @Override + public HandlerList getHandlers() + { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() + { + return HANDLER_LIST; + } + + public MinecraftServer getMinecraftServer() + { + return _minecraftServer; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index 27b9dedd0..bfff39b40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -17,6 +17,7 @@ import net.md_5.bungee.api.chat.ClickEvent.Action; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; @@ -114,7 +115,7 @@ public class PartyInviteManager */ public void handleInviteRequest(String sender, String target, String serverFrom) { - Player player = Bukkit.getPlayer(target); + Player player = Bukkit.getPlayerExact(target); if (player == null) { //Shouldn't happen, as a "findPLayer" packet will be sent out first. @@ -124,6 +125,7 @@ public class PartyInviteManager inviteTo(player.getUniqueId(), sender, sender, serverFrom); Lang.INVITE_RECEIVED.send(player, sender); sendAcceptOrDeny(player, sender); + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java index 9226ce9c6..88a7ef29c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java @@ -8,6 +8,7 @@ import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.party.constants.JoinResponseReason; import mineplex.core.party.redis.RedisMessageType; +import mineplex.serverdata.servers.ServerManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -32,6 +33,27 @@ public class PartyJoinManager _transferring = Lists.newArrayList(); } + /** + * Scans through the party to check if all players are some form of VIP + * If the party contains even 1 non-vip, the party cannot be sent to a full server + * + * @param party The party + * @return true if the party contains all VIP's false if it contains even 1 non-vip + */ + public boolean canJoinFullServer(Party party) + { + List players = party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList()); + for (Player player : players) + { + Rank rank = _plugin.getClientManager().Get(player).GetRank(); + if (rank == Rank.ALL) + { + return false; + } + } + return true; + } + /** * Initiates a request to join a server for a specific party * @@ -40,17 +62,7 @@ public class PartyJoinManager */ public void requestServerJoin(String server, Party party) { - boolean canJoinFull = true; - List players = party.getMembers().stream().map(Bukkit::getPlayer).collect(Collectors.toList()); - for (Player player : players) - { - Rank rank = _plugin.getClientManager().Get(player).GetRank(); - if (rank == Rank.ALL) - { - canJoinFull = false; - break; - } - } + boolean canJoinFull = canJoinFullServer(party); _plugin.getRedisManager().publish(server, RedisMessageType.PREJOIN_SERVER_REQUEST, _plugin.getServerName(), party.getOwner(), "" + party.getMembers().size(), "" + canJoinFull); } @@ -75,7 +87,7 @@ public class PartyJoinManager return; } } - + ServerManager.getServerRepository(_plugin.getRegion()).getServerStatus(_plugin.getServerName()).incrementPlayerCount(partySize); _plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.SUCCESS.name(), _plugin.getServerName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java index 4d2a5c21e..548a15b6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java @@ -2,11 +2,12 @@ package mineplex.core.party.manager; import com.google.common.collect.Lists; import mineplex.core.common.util.F; +import mineplex.core.menu.Menu; import mineplex.core.party.Lang; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.party.constants.PartyRemoveReason; -import mineplex.core.party.ui.Menu; +import mineplex.core.preferences.Preference; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -43,18 +44,39 @@ public class PartyMethodManager return; } - boolean can = Bukkit.getMaxPlayers() >= _plugin.getPlugin().getServer().getOnlinePlayers().size(); - if(!can) + if(party != null) { - Lang.SERVER_FULL.send(caller); - return; + if(!party.getOwner().equalsIgnoreCase(caller.getName())) + { + Lang.NOT_OWNER.send(caller); + return; + } + if(_plugin.getInviteManager().isInvitedTo(possible.getUniqueId(), party.getName())) + { + Lang.ALREADY_INVITED.send(caller, target); + return; + } + if(party.getMembers().contains(target)) + { + Lang.ALREADY_MEMBER.send(caller, target); + return; + } + if(_plugin.getParty(target) != null) + { + Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target); + return; + } + if(party.getMembers().size() >= party.getSize()) + { + Lang.PARTY_FULL.send(caller); + return; + } } //Same Server if (possible != null) { - - if(!_plugin.getPreferencesManager().Get(possible).PartyRequests) + if(!_plugin.getPreferencesManager().get(possible).isActive(Preference.PARTY_REQUESTS)) { caller.sendMessage(F.main("Party> ", F.name(target) + " is not accepting invites at this time.")); return; @@ -75,32 +97,6 @@ public class PartyMethodManager Lang.INVITE_SUCCESS_PLAYER.send(caller, possible.getName()); } else { - if(!party.getOwner().equalsIgnoreCase(caller.getName())) - { - Lang.NOT_OWNER.send(caller); - return; - } - if(_plugin.getInviteManager().isInvitedTo(possible.getUniqueId(), party.getName())) - { - Lang.ALREADY_INVITED.send(caller, target); - return; - } - if(party.getMembers().contains(target)) - { - Lang.ALREADY_MEMBER.send(caller, target); - return; - } - if(_plugin.getParty(target) != null) - { - Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target); - return; - } - if(party.getMembers().size() >= party.getSize()) - { - Lang.PARTY_FULL.send(caller); - return; - } - Lang.SUCCESS_INVITE.send(party, caller.getName(), target); } @@ -113,6 +109,14 @@ public class PartyMethodManager _plugin.getInviteManager().sendAcceptOrDeny(possible, caller.getName()); return; } + //Only perform this when I actually need to. + boolean can = Bukkit.getMaxPlayers() >= _plugin.getPlugin().getServer().getOnlinePlayers().size(); + if(!can) + { + Lang.SERVER_FULL.send(caller); + return; + } + //Not on the same server _plugin.getRedisManager().findAndInvite(target, caller.getName()); } @@ -316,7 +320,7 @@ public class PartyMethodManager { List members = Lists.newArrayList(party.getMembersByUUID()); Lang.DISBANDED_BY_OWNER.send(party); - members.stream().forEach(player -> removeFromParty(player, PartyRemoveReason.DISBANDED_BY_OWNER)); + members.forEach(player -> removeFromParty(player, PartyRemoveReason.DISBANDED_BY_OWNER)); party.getMembers().clear(); party.getMembersByUUID().clear(); _plugin.removeParty(party); @@ -325,13 +329,18 @@ public class PartyMethodManager public void transferOwner(String newOwner, String oldOwner) { Party party = _plugin.getParties().remove(oldOwner); + if(party == null) { return; } + _plugin.getParties().put(newOwner, party); party.setOwner(newOwner); party.getMembers().remove(oldOwner); party.getMembers().add(oldOwner); + UUID uuid = Bukkit.getPlayerExact(oldOwner).getUniqueId(); + party.getMembersByUUID().remove(uuid); + party.getMembersByUUID().add(uuid); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index 4f1d01473..461b303ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -12,6 +12,7 @@ import mineplex.core.party.constants.JoinResponseReason; import mineplex.core.party.event.PartyDataReceivedEvent; import mineplex.core.party.redis.PartyRedisListener; import mineplex.core.party.redis.RedisMessageType; +import mineplex.core.preferences.Preference; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -120,7 +121,7 @@ public class PartyRedisManager return; } - if(!_plugin.getPreferencesManager().Get(player).PartyRequests) + if(!_plugin.getPreferencesManager().get(player).isActive(Preference.PARTY_REQUESTS)) { publish(first, RedisMessageType.INVITE_PLAYER_NOT_ACCEPTING_INVITES, _serverName, player.getName(), player.getUniqueId().toString(), third); return; @@ -139,12 +140,7 @@ public class PartyRedisManager case PLAYER_FIND_RESPONSE: UUID uuid = UUID.fromString(third); - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); if (_plugin.getInviteManager().isInvitedTo(uuid, inviter.getName())) @@ -177,12 +173,7 @@ public class PartyRedisManager private void handleNotAccepting(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); inviter.sendMessage(F.main("Party", F.name(second) + " is not accepting invites at this time.")); @@ -190,13 +181,7 @@ public class PartyRedisManager private void handleAlreadyIn(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } - + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); Lang.ALREADY_IN.send(inviter, second); } @@ -215,6 +200,11 @@ public class PartyRedisManager @Override public void run() { + if(!TASKS.containsKey(player)) + { + cancel(); + return; + } TASKS.remove(player); Player senderPlayer = Bukkit.getPlayerExact(sender); if (senderPlayer == null) @@ -293,4 +283,14 @@ public class PartyRedisManager { return FIND_PLAYERS_CHANNEL; } + + public void cancelTask(String player) + { + BukkitTask task = TASKS.remove(player); + + if (task != null) + { + task.cancel(); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java deleted file mode 100644 index fe5d4468d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.core.party.ui; - -import mineplex.core.party.PartyManager; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -/** - * An abstract class for managing buttons inside of menus - */ -public abstract class Button -{ - - private ItemStack _item; - private PartyManager _plugin; - - public Button(ItemStack item, PartyManager plugin) - { - this._item = item; - _plugin = plugin; - } - - /** - * The method called when a players clicks the slot - * - * @param player The player who clicked - */ - public abstract void onClick(Player player, ClickType clickType); - - public ItemStack getItemStack() - { - return _item; - } - - public void setItemStack(ItemStack item) - { - this._item = item; - } - - public PartyManager getPlugin() - { - return _plugin; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java new file mode 100644 index 000000000..e66709c56 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java @@ -0,0 +1,27 @@ +package mineplex.core.party.ui; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; +import mineplex.core.menu.Menu; +import mineplex.core.party.PartyManager; +import org.bukkit.Material; + +/** + * A class to manage dynamic creation of GUI's + */ +public abstract class PartyMenu extends Menu +{ + + protected static final Button PURCHASE_MORE_SLOTS = new IconButton(new ItemBuilder(Material.REDSTONE_BLOCK) + .setTitle(C.cRed + C.Bold + "Locked!") + .setLore(" ", C.cGray + "Purchase a rank @ mineplex.com/shop", C.cGray + "Purchasing a rank increases your", C.cGray + "party size to allow 10 people!") + .build()); + + public PartyMenu(String name, PartyManager plugin) + { + super(name, plugin); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java index 1b409a082..174a46ab6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; /** * Leaves a players current party */ -public class LeavePartyButton extends Button +public class LeavePartyButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK) @@ -36,4 +36,4 @@ public class LeavePartyButton extends Button player.closeInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java index 463754279..6fee7b430 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java @@ -1,14 +1,14 @@ package mineplex.core.party.ui.button.tools; +import mineplex.core.menu.Button; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.inventory.ItemStack; /** * A wrapper for all buttons which need to interact with a specific party */ -public abstract class PartyButton extends Button +public abstract class PartyButton extends Button { private Party _party; @@ -23,4 +23,4 @@ public abstract class PartyButton extends Button { return _party; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java new file mode 100644 index 000000000..4d788b0c5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java @@ -0,0 +1,40 @@ +package mineplex.core.party.ui.button.tools; + +import mineplex.core.common.util.C; +import mineplex.core.game.GameDisplay; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.party.PartyManager; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * + */ +public class SelectPartnerGameButton extends Button +{ + + private static final String COMMAND = "/teamprefs "; + + private final String _partner; + private final String _gameName; + + public SelectPartnerGameButton(GameDisplay gameDisplay, String partner, PartyManager plugin) + { + super(new ItemBuilder(gameDisplay.getMaterial()) + .setTitle(C.cYellow + gameDisplay.getName()) + .setData(gameDisplay.getMaterialData()) + .build(), plugin); + _partner = partner; + _gameName = gameDisplay.getName(); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + player.chat(COMMAND + _partner + " " + _gameName); + Menu.get(player.getUniqueId()).setUseClose(true); + player.closeInventory(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java index 6ac82bc6a..4fe6bce85 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java @@ -1,9 +1,8 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.menus.PartyMainMenu; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +12,7 @@ import org.bukkit.inventory.ItemStack; /** * Sends a player back to the main page */ -public class BackButton extends Button +public class BackButton extends Button { private static ItemStack ITEM = new ItemBuilder(Material.BED) @@ -29,6 +28,6 @@ public class BackButton extends Button public void onClick(Player player, ClickType clickType) { player.closeInventory(); - new PartyMainMenu(getPlugin()).open(player); + player.chat("/party"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java index e39faaca2..7ae041d6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java @@ -1,9 +1,9 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; +import mineplex.core.menu.Button; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Deny's all invites currently pending */ -public class DenyAllButton extends Button +public class DenyAllButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK) @@ -32,4 +32,4 @@ public class DenyAllButton extends Button getPlugin().getInviteManager().getAllInvites(player).forEach(inviteData -> getPlugin().getMethodManager().respondToInvite(player, inviteData.getInvitedTo(), false)); new PartyInvitesMenu(getPlugin()).open(player); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java index 2a2e5d4ff..cdceafdea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.input.InviteFilterMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Filters all current pending invites and displays only the results to a player */ -public class FilterButton extends Button +public class FilterButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG) @@ -22,8 +22,8 @@ public class FilterButton extends Button C.cGray + "Click to bring up an Anvil GUI", C.cGray + "where you type and filter", C.cGray + "Party invites by their name", - " ", - C.cGreen + "Input \"Clear Filter\" to remove the filter") + " ", + C.cGreen + "Input \"Clear Filter\" to remove the filter") .build(); public FilterButton(PartyManager plugin) @@ -36,11 +36,11 @@ public class FilterButton extends Button super(new ItemBuilder(Material.NAME_TAG) .setTitle(C.cYellow + "Filter Invites") .setLore(" ", C.cWhite + "Active Filter: " + C.cGreen + filter, " ", - C.cGray + "Click to bring up an Anvil GUI", - C.cGray + "where you type and filter", - C.cGray + "Party invites by their name", - " ", - C.cGreen + "Input \"Clear Filter\" to remove the filter") + C.cGray + "Click to bring up an Anvil GUI", + C.cGray + "where you type and filter", + C.cGray + "Party invites by their name", + " ", + C.cGreen + "Input \"Clear Filter\" to remove the filter") .setGlow(true) .build(), plugin); } @@ -51,4 +51,4 @@ public class FilterButton extends Button new InviteFilterMenu(getPlugin(), player, null).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java index edc97abb3..01478575f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -11,7 +11,7 @@ import org.bukkit.event.inventory.ClickType; /** * Represents an invitation, to which a player can accept or deny */ -public class InviteButton extends Button +public class InviteButton extends Button { private String _name; @@ -39,4 +39,4 @@ public class InviteButton extends Button } player.closeInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java index 1b370911e..386cf1962 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java @@ -2,10 +2,10 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.button.IconButton; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,7 +17,7 @@ import java.util.List; /** * Shows the next page of invites for a player */ -public class NextPageButton extends Button +public class NextPageButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.SIGN).setTitle(C.cYellow + "Next Page").build(); @@ -37,13 +37,13 @@ public class NextPageButton extends Button _menu.setCurrentPage(_menu.getCurrentPage() + 1); if(_menu.getCurrentPage() == _menu.getPagesNeeded()) { - _menu.setButton(53, new IconButton(new ItemStack(Material.AIR), getPlugin())); + _menu.setButton(53, new IconButton(new ItemStack(Material.AIR))); } List data = _menu.getDataForPage(_menu.getCurrentPage()); for(int i = 0; i < data.size(); i++) { _menu.setButton(i + _menu.getStartingSlot(), new InviteButton(data.get(i).getInvitedTo(), getPlugin())); } - _menu.update(player); + _menu.update(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java index 3400a86cd..e0bf5d315 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java @@ -2,10 +2,10 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.button.IconButton; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,7 +17,7 @@ import java.util.List; /** * Shows the previous page of invites for a player */ -public class PrevPageButton extends Button +public class PrevPageButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.SIGN).setTitle(C.cYellow + "Previous Page").build(); @@ -36,13 +36,13 @@ public class PrevPageButton extends Button _menu.setCurrentPage(_menu.getCurrentPage() - 1); if(_menu.getCurrentPage() == 0) { - _menu.setButton(45, new IconButton(new ItemStack(Material.AIR), getPlugin())); + _menu.setButton(45, new IconButton(new ItemStack(Material.AIR))); } List data = _menu.getDataForPage(_menu.getCurrentPage()); for(int i = 0; i < data.size(); i++) { _menu.setButton(i + _menu.getStartingSlot(), new InviteButton(data.get(i).getInvitedTo(), getPlugin())); } - _menu.update(player); + _menu.update(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java index 162912d7b..42bab9475 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.main; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.input.PartyInvitePlayerMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Invites a player to a new party */ -public class InvitePlayerButton extends Button +public class InvitePlayerButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG) @@ -31,4 +31,4 @@ public class InvitePlayerButton extends Button { new PartyInvitePlayerMenu(getPlugin(), player, null).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java index 3ae1c6cf7..6e934cef2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.main; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Opens the {@code {@link PartyInvitesMenu}} */ -public class ViewInvitesButton extends Button +public class ViewInvitesButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.BOOK) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java index e010089bd..72bad2bed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java @@ -33,4 +33,4 @@ public class AddPlayerButton extends PartyButton new PartyInvitePlayerMenu(getPlugin(), player, getParty()).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java index 5c6ad0923..ce2afa915 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.owner; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; /** * Disbands a party */ -public class DisbandPartyButton extends Button +public class DisbandPartyButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.BARRIER) @@ -35,4 +35,4 @@ public class DisbandPartyButton extends Button getPlugin().getMethodManager().disband(player); player.closeInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java index 03f02fed2..48069adf2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java @@ -4,7 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.party.Party; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.tools.PartyButton; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -51,6 +51,6 @@ public class KickPlayerButton extends PartyButton { setItemStack(ITEM_OFF); } - Menu.get(player.getUniqueId()).update(player); + PartyMenu.get(player.getUniqueId()).update(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java index dbbd0a032..5c2fed842 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java @@ -32,4 +32,4 @@ public class SelectServerButton extends PartyButton { UtilServer.getPluginManager().callEvent(new PartySelectServerEvent(player)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java index 5d49eae44..2f0ca501c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java @@ -20,7 +20,7 @@ public class TransferOwnerButton extends PartyButton private static final ItemStack ITEM = new ItemBuilder(Material.BOOK_AND_QUILL) .setTitle(C.cYellow + "Transfer Ownership") .setLore(" ", C.cGray + "Transfers ownership of the party", C.cGray + "to another player", - " ", C.cDRed + "This cannot be undone!") + " ", C.cDRed + "This cannot be undone!") .build(); public TransferOwnerButton(Party party, PartyManager plugin) @@ -33,4 +33,4 @@ public class TransferOwnerButton extends PartyButton { new PartyTransferOwnerMenu(getPlugin(), player, getParty()).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java new file mode 100644 index 000000000..2d0c9989b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java @@ -0,0 +1,55 @@ +package mineplex.core.party.ui.menus; + +import mineplex.core.game.GameDisplay; +import mineplex.core.menu.Button; +import mineplex.core.party.PartyManager; +import mineplex.core.party.ui.PartyMenu; +import mineplex.core.party.ui.button.tools.SelectPartnerGameButton; +import org.bukkit.entity.Player; + +/** + * + */ +public class PartnerRequestMenu extends PartyMenu +{ + + private final GameDisplay[] GAMES = { + GameDisplay.SurvivalGamesTeams, + GameDisplay.SkywarsTeams, + GameDisplay.UHC, + GameDisplay.SmashTeams, + }; + + private final int INV_SIZE = 54; + private final int START_SLOT = 20; + private final int END_SLOT = 24; + private final int START_SLOT_SECOND = 29; + + private final String _partner; + + public PartnerRequestMenu(String partner, PartyManager plugin) + { + super("Select a game", plugin); + _partner = partner; + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[INV_SIZE]; + + int slot = START_SLOT; + + for (GameDisplay gameDisplay : GAMES) + { + if (slot > END_SLOT) + { + slot = START_SLOT_SECOND; + } + + buttons[slot++] = new SelectPartnerGameButton(gameDisplay, _partner, getPlugin()); + } + + return pane(buttons); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java index eb0e4f626..bfbe08da1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java @@ -5,12 +5,16 @@ import com.google.common.collect.Maps; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; -import mineplex.core.party.ui.button.IconButton; -import mineplex.core.party.ui.button.tools.invite.*; +import mineplex.core.party.ui.PartyMenu; +import mineplex.core.party.ui.button.tools.invite.BackButton; +import mineplex.core.party.ui.button.tools.invite.DenyAllButton; +import mineplex.core.party.ui.button.tools.invite.FilterButton; +import mineplex.core.party.ui.button.tools.invite.InviteButton; +import mineplex.core.party.ui.button.tools.invite.NextPageButton; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.Sound; @@ -23,14 +27,15 @@ import java.util.stream.Collectors; /** * The menu showing all pending invites for a player */ -public class PartyInvitesMenu extends Menu +public class PartyInvitesMenu extends PartyMenu { private final IconButton NO_INVITES = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE) .setData(DyeColor.RED.getWoolData()) .setTitle(C.cRedB + "No Invites") - .build(), null); + .build()); + private final int INV_SIZE = 54; private final int SLOTS_PER_PAGE = 27; private final int STARTING_SLOT = 18; private final int BACK_BUTTON_SLOT = 0; @@ -59,12 +64,12 @@ public class PartyInvitesMenu extends Menu @Override protected Button[] setUp(Player player) { - Button[] buttons = new Button[54]; + Button[] buttons = new Button[INV_SIZE]; boolean showFiltered = false; - buttons[BACK_BUTTON_SLOT] = new BackButton(_plugin); + buttons[BACK_BUTTON_SLOT] = new BackButton(getPlugin()); - List all = (List) _plugin.getInviteManager().getAllInvites(player); + List all = (List) getPlugin().getInviteManager().getAllInvites(player); if (all == null || all.isEmpty()) { @@ -73,18 +78,18 @@ public class PartyInvitesMenu extends Menu buttons[i] = NO_INVITES; } player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); - return addPanes(buttons); + return pane(buttons); } - buttons[DENY_ALL_BUTTON_SLOW] = new DenyAllButton(_plugin); + buttons[DENY_ALL_BUTTON_SLOW] = new DenyAllButton(getPlugin()); if (_filterBy == null || _filterBy.isEmpty()) { - buttons[FILTER_BUTTON_SLOT] = new FilterButton(_plugin); + buttons[FILTER_BUTTON_SLOT] = new FilterButton(getPlugin()); } else { showFiltered = true; - buttons[FILTER_BUTTON_SLOT] = new FilterButton(_filterBy, _plugin); + buttons[FILTER_BUTTON_SLOT] = new FilterButton(_filterBy, getPlugin()); } if (showFiltered) @@ -100,10 +105,10 @@ public class PartyInvitesMenu extends Menu .setData(DyeColor.RED.getWoolData()) .setTitle(C.cRedB + "No Invites Found") .setLore(" ", C.cGray + "The filter " + F.name(_filterBy) + " had no results.") - .build(), _plugin); + .build()); } player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); - return addPanes(buttons); + return pane(buttons); } _data = all; @@ -117,7 +122,7 @@ public class PartyInvitesMenu extends Menu pagesNeeded++; size -= SLOTS_PER_PAGE; } - buttons[NEXT_PAGE_SLOT] = new NextPageButton(this, _plugin); + buttons[NEXT_PAGE_SLOT] = new NextPageButton(this, getPlugin()); _pagesNeeded = pagesNeeded; _pagesOfData = Maps.newHashMap(); @@ -146,12 +151,12 @@ public class PartyInvitesMenu extends Menu for (int i = 0; i < all.size(); i++) { String to = all.get(i).getInvitedTo(); - buttons[STARTING_SLOT + i] = new InviteButton(to, _plugin); + buttons[STARTING_SLOT + i] = new InviteButton(to, getPlugin()); } } - return addPanes(buttons); + return pane(buttons); } public void setButton(int slot, Button button) @@ -188,4 +193,4 @@ public class PartyInvitesMenu extends Menu { return _pagesNeeded; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java index 619e2f1f7..055203db3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java @@ -1,8 +1,8 @@ package mineplex.core.party.ui.menus; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.tools.main.InvitePlayerButton; import mineplex.core.party.ui.button.tools.main.ViewInvitesButton; import org.bukkit.entity.Player; @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; /** * The main GUI for parties. */ -public class PartyMainMenu extends Menu +public class PartyMainMenu extends PartyMenu { private final int INV_SIZE = 9; @@ -28,9 +28,9 @@ public class PartyMainMenu extends Menu { Button[] buttons = new Button[INV_SIZE]; - buttons[INVITE_PLAYER_BUTTON_SLOT] = new InvitePlayerButton(_plugin); - buttons[VIEW_INVITES_BUTTON_SLOT] = new ViewInvitesButton(_plugin); + buttons[INVITE_PLAYER_BUTTON_SLOT] = new InvitePlayerButton(getPlugin()); + buttons[VIEW_INVITES_BUTTON_SLOT] = new ViewInvitesButton(getPlugin()); return buttons; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java index 70380082e..563cfaef4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java @@ -1,9 +1,9 @@ package mineplex.core.party.ui.menus; +import mineplex.core.menu.Button; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.PartyMemberIcon; import mineplex.core.party.ui.button.tools.LeavePartyButton; import mineplex.core.party.ui.button.tools.owner.AddPlayerButton; @@ -11,24 +11,32 @@ import mineplex.core.party.ui.button.tools.owner.DisbandPartyButton; import mineplex.core.party.ui.button.tools.owner.KickPlayerButton; import mineplex.core.party.ui.button.tools.owner.SelectServerButton; import mineplex.core.party.ui.button.tools.owner.TransferOwnerButton; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.List; +import java.util.UUID; + /** * The display menu for managing parties by the owner */ -public class PartyOwnerMenu extends Menu +public class PartyOwnerMenu extends PartyMenu { - + + private final int INV_SIZE = 54; + private final int OWNER_HEAD_SLOT = 13; private final int STARTING_SLOT = 20; private final int CUT_OFF_SLOT = 25; + private final int CUT_OFF_SLOT_2 = 34; private final int SKIP_TO_SLOT = 29; + private final int SKIP_TO_SLOT_2 = 38; private final int ADD_PLAYER_BUTTON_SLOT = 1; private final int KICK_PLAYER_BUTTON_SLOT = 4; private final int TRANSFER_OWNER_BUTTON_SLOT = 7; private final int SELECT_SERVER_BUTTON_SLOT = 46; private final int LEAVE_PARTY_BUTTON_SLOT = 49; private final int DISBAND_PARTY_BUTTON_SLOW = 52; - + private Party _party; public PartyOwnerMenu(Party party, PartyManager plugin) @@ -45,41 +53,39 @@ public class PartyOwnerMenu extends Menu @Override protected Button[] setUp(Player player) { - Button[] buttons = new Button[54]; + Button[] buttons = new Button[INV_SIZE]; //Tools - buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(_plugin, _party); + buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(getPlugin(), _party); //Kick player buttons[KICK_PLAYER_BUTTON_SLOT] = new KickPlayerButton(_party); //Transfer ownership - buttons[TRANSFER_OWNER_BUTTON_SLOT] = new TransferOwnerButton(_party, _plugin); + buttons[TRANSFER_OWNER_BUTTON_SLOT] = new TransferOwnerButton(_party, getPlugin()); //Go to server buttons[SELECT_SERVER_BUTTON_SLOT] = new SelectServerButton(_party); //Leave party - buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin); + buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(getPlugin()); //Disband - buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(_plugin); + buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(getPlugin()); + + List members = _party.getMembers(); + members.remove(_party.getOwner()); + buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true); int slot = STARTING_SLOT; //Players - for (int i = 0; i < _party.getMembers().size(); i++) + for (String member: members) { if (slot == CUT_OFF_SLOT) { slot = SKIP_TO_SLOT; - } - String member = _party.getMembers().get(i); - buttons[slot++] = new PartyMemberIcon(member, _party, member.equalsIgnoreCase(_party.getOwner())); - } - - if(_party.getSize() == 5) - { - for(int i = 29; i < 34; i++) + } else if (slot == CUT_OFF_SLOT_2) { - buttons[i] = PURCHASE_MORE_SLOTS; + slot = SKIP_TO_SLOT_2; } + + buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayerExact(member).getName(), _party, false); } - - return addPanes(buttons); + return pane(buttons); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java index 5fc4cff5b..f907b7875 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java @@ -1,26 +1,34 @@ package mineplex.core.party.ui.menus; +import mineplex.core.menu.Button; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.PartyMemberIcon; import mineplex.core.party.ui.button.tools.LeavePartyButton; import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.List; +import java.util.UUID; + /** * The menu a player see's when he is a member, and not an owner, of a party. */ -public class PartyViewMenu extends Menu +public class PartyViewMenu extends PartyMenu { + private final int INV_SIZE = 54; + private final int OWNER_HEAD_SLOT = 13; private final int STARTING_SLOT = 20; private final int CUT_OFF_SLOT = 25; + private final int CUT_OFF_SLOT_2 = 34; private final int SKIP_TO_SLOT = 29; + private final int SKIP_TO_SLOT_2 = 38; private final int LEAVE_PARTY_BUTTON_SLOT = 3; private final int SUGGEST_PLAYER_BUTTON_SLOT = 5; - + private Party _party; public PartyViewMenu(Party party, PartyManager plugin) @@ -32,24 +40,31 @@ public class PartyViewMenu extends Menu @Override protected Button[] setUp(Player player) { - Button[] buttons = new Button[54]; + Button[] buttons = new Button[INV_SIZE]; //Tools - buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin); + buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(getPlugin()); //Suggest Player - buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, _plugin); + buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, getPlugin()); + + List members = _party.getMembers(); + members.remove(_party.getOwner()); + buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true); int slot = STARTING_SLOT; //Players - for (int i = 0; i < _party.getMembers().size(); i++) + for (String member : members) { if (slot == CUT_OFF_SLOT) { slot = SKIP_TO_SLOT; + } else if (slot == CUT_OFF_SLOT_2) + { + slot = SKIP_TO_SLOT_2; } - String member = _party.getMembers().get(i); - buttons[slot++] = new PartyMemberIcon(member, _party, member.equalsIgnoreCase(_party.getOwner())); + + buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false); } - return addPanes(buttons); + return pane(buttons); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 65d95c26a..06667e96d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -23,7 +23,7 @@ public class HostEventServerCommand extends CommandBase if(Plugin.getClients().Get(caller).isDisguised()) { - UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!")); return; } Plugin.hostServer(caller, caller.getName(), true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index 8fe9045d6..1c85b6dfc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -23,7 +23,7 @@ public class HostServerCommand extends CommandBase if(Plugin.getClients().Get(caller).isDisguised()) { - UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't create a MPS while you are disguised!")); return; } Plugin.hostServer(caller, caller.getName(), false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java index 0ae459e78..e6f918520 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java @@ -1,12 +1,10 @@ package mineplex.core.pet; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.pet.repository.token.PetSalesToken; import mineplex.core.shop.item.SalesPackageBase; - import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; public class Pet extends SalesPackageBase { @@ -19,7 +17,7 @@ public class Pet extends SalesPackageBase _name = name; _petType = petType; - CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, cost); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); KnownPackage = false; } @@ -38,10 +36,4 @@ public class Pet extends SalesPackageBase { return _name; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java index e24136065..f33ed7e5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java @@ -6,15 +6,16 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.pet.repository.token.ClientPetToken; import mineplex.core.pet.repository.token.PetToken; +import java.util.HashMap; +import java.util.Map; + public class PetClient { - private NautHashMap _pets; + private Map _pets = new HashMap<>(); private int _petNameTagCount; public void load(ClientPetToken token) { - _pets = new NautHashMap(); - for (PetToken petToken : token.Pets) { if (petToken.PetName == null) @@ -26,7 +27,7 @@ public class PetClient _petNameTagCount = Math.max(0, token.PetNameTagCount); } - public NautHashMap getPets() + public Map getPets() { return _pets; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java index 162b53a01..ca38ba1a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java @@ -1,11 +1,9 @@ package mineplex.core.pet; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.shop.item.SalesPackageBase; - import org.bukkit.Material; -import org.bukkit.entity.Player; public class PetExtra extends SalesPackageBase { @@ -18,7 +16,7 @@ public class PetExtra extends SalesPackageBase _name = name; _material = material; - CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, cost); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); KnownPackage = false; OneTimePurchaseOnly = false; @@ -38,9 +36,4 @@ public class PetExtra extends SalesPackageBase { return _material; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index d5f48d43b..5b5442191 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -3,6 +3,7 @@ package mineplex.core.pet; import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -190,21 +191,21 @@ public class PetManager extends MiniClientPlugin { _creatureModule.SetForce(true); - DisguiseWither witherDisguise = new DisguiseWither(null); - - witherDisguise.setInvulTime(530); - - _disguiseManager.addFutureDisguise(witherDisguise); - pet = (Creature) location.getWorld().spawnEntity(location, EntityType.SILVERFISH); UtilEnt.silence(pet, true); + DisguiseWither witherDisguise = new DisguiseWither(pet); + + witherDisguise.setInvulTime(530); + Creature silverfish = (Creature) _creatureModule.SpawnEntity(location, EntityType.SILVERFISH); UtilEnt.Vegetate(silverfish, true); UtilEnt.silence(silverfish, true); - ((LivingEntity) silverfish).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); + silverfish.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); pet.setPassenger(silverfish); + _disguiseManager.disguise(witherDisguise); + _creatureModule.SetForce(false); } //Default Spawn @@ -442,11 +443,11 @@ public class PetManager extends MiniClientPlugin { ClientPetTokenWrapper token = new Gson().fromJson(event.GetResponse(), ClientPetTokenWrapper.class); - Get(token.Name).load(token.DonorToken); + Get(event.getUniqueId()).load(token.DonorToken); } @Override - protected PetClient addPlayer(String player) + protected PetClient addPlayer(UUID uuid) { return new PetClient(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index 64abfc3cf..12cd6f22e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -51,7 +51,7 @@ public class PollManager extends MiniDbClientPlugin } @Override - protected PlayerPollData addPlayer(String player) + protected PlayerPollData addPlayer(UUID uuid) { return new PlayerPollData(); } @@ -228,9 +228,9 @@ public class PollManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadPollData(resultSet)); + Set(uuid, _repository.loadPollData(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 813744f5d..0e872a0c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -1,18 +1,6 @@ package mineplex.core.portal; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.HashSet; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.plugin.java.JavaPlugin; - +import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -21,6 +9,9 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.event.PartySendToServerEvent; import mineplex.core.portal.Commands.SendCommand; import mineplex.core.portal.Commands.ServerCommand; import mineplex.serverdata.Region; @@ -30,6 +21,20 @@ import mineplex.serverdata.commands.TransferCommand; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ServerRepository; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Random; public class Portal extends MiniPlugin { @@ -47,10 +52,10 @@ public class Portal extends MiniPlugin public Portal(JavaPlugin plugin, CoreClientManager clientManager, String serverName) { super("Portal", plugin); - + instance = this; _clientManager = clientManager; - + _region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; _serverName = serverName; _repository = ServerManager.getServerRepository(_region); @@ -91,37 +96,85 @@ public class Portal extends MiniPlugin ServerTransferEvent event = new ServerTransferEvent(player, serverName, draggedByParty); Bukkit.getPluginManager().callEvent(event); - final boolean override = serverName.equalsIgnoreCase("Lobby"); + final boolean override = serverName.equalsIgnoreCase("Lobby") || serverName.equalsIgnoreCase("ClansHub"); final Rank playerRank = _clientManager.Get(player).GetRank(); - if(event.isCancel() && !event.isDraggedByParty()) + if (event.getParty() != null && override) { + Party party = event.getParty(); + if(!party.getOwner().equalsIgnoreCase(player.getName())) + { + Lang.NOT_OWNER_SERVER.send(player); + return; + } + sendParty(party); + return; + } + + if (event.getParty() != null && serverName.toUpperCase().startsWith("CLANS-")) + { + event.getParty().sendMessage(F.main(getName(), "You cannot join Clans while in a party!")); return; } if (override) { sendPlayer(player, serverName); + return; } - else + if (event.isCancel()) { - runAsync(() -> { - final MinecraftServer server = _repository.getServerStatus(serverName); + return; + } - if (server == null) - return; + runAsync(() -> { + final MinecraftServer server = _repository.getServerStatus(serverName); - Bukkit.getServer().getScheduler().runTask(_plugin, () -> { - if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) - { - sendPlayer(player, serverName); - } + if (server == null) + return; + + Bukkit.getServer().getScheduler().runTask(_plugin, () -> { + if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) + { + sendPlayer(player, serverName); + } else UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is full!")); - }); }); + }); + } + + private void sendParty(Party party) + { + ServerRepository repository = ServerManager.getServerRepository(_region); + MinecraftServer best = null; + List serverList = Lists.newArrayList(repository.getServersByGroup("Lobby")); + int lowest = Integer.MAX_VALUE; + for (MinecraftServer server : serverList) + { + int playercount = server.getPlayerCount(); + if (playercount < 20) + { + continue; + } + if (playercount < lowest) + { + lowest = playercount; + if (best == null) + { + best = server; + } + } } + if (best == null) + { + //Well, fuck. + best = serverList.get(new Random().nextInt(serverList.size())); + } + + PartySendToServerEvent serverEvent = new PartySendToServerEvent(party, best); + getPluginManager().callEvent(serverEvent); } public static void transferPlayer(String playerName, String serverName) @@ -195,4 +248,6 @@ public class Portal extends MiniPlugin UtilPlayer.message(player, F.main(getName(), "You have been sent from " + C.cGold + _serverName + C.cGray + " to " + C.cGold + serverName)); } + + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java index e2dc4c667..8a19c65c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java @@ -1,5 +1,6 @@ package mineplex.core.portal; +import mineplex.core.party.Party; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -10,6 +11,7 @@ public class ServerTransferEvent extends Event private static final HandlerList _handlers = new HandlerList(); private Player _player; private String _server; + private Party _party; private boolean _draggedByParty; private boolean _cancel; @@ -59,4 +61,14 @@ public class ServerTransferEvent extends Event { _cancel = cancel; } + + public Party getParty() + { + return _party; + } + + public void setParty(Party party) + { + _party = party; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java index 32b8907f0..991d1e677 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/TransferHandler.java @@ -4,7 +4,6 @@ import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.ServerCommand; import mineplex.serverdata.commands.ServerTransfer; import mineplex.serverdata.commands.TransferCommand; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java new file mode 100644 index 000000000..6ca197cca --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -0,0 +1,113 @@ +package mineplex.core.preferences; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.bukkit.Material; + +import java.util.List; +import java.util.Map; + +/** + * All ID's are assigned by enum order. + *

+ * Key: + * Default value: The value this is set at if the user has not toggled it + * Category: Determines which sub menu, along with permissions to view, this preference falls to + * Icon: The material representation in the GUI + * Name: The string shown to players in the menu and for toggling + * Lore: A description of the preference + */ +public enum Preference +{ + + HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Player Stacker"), + SHOW_PLAYERS(true, PreferenceCategory.USER, Material.EYE_OF_ENDER, "Hub Player Visibility"), + SHOW_CHAT(true, PreferenceCategory.USER, Material.PAPER, "Player Chat"), + PRIVATE_MESSAGING(true, PreferenceCategory.USER, Material.MAP, "Private Messaging"), + PARTY_REQUESTS(true, PreferenceCategory.USER, Material.SKULL_ITEM, "Party Requests"), + + INVISIBILITY(false, PreferenceCategory.EXCLUSIVE, Material.NETHER_STAR, "Hub Invisibility & Flight"), + FORCE_FIELD(false, PreferenceCategory.EXCLUSIVE, Material.SLIME_BALL, "Hub Forcefield"), + GLOBAL_GWEN_REPORTS(true, PreferenceCategory.EXCLUSIVE, Material.PAPER, "Global GWEN Reports"), + SHOW_USER_REPORTS(false, PreferenceCategory.EXCLUSIVE, Material.BOOK, "User Reports"), + IGNORE_VELOCITY(false, PreferenceCategory.EXCLUSIVE, Material.SADDLE, "Hub Ignore Velocity"), + + PENDING_FRIEND_REQUESTS(true, PreferenceCategory.FRIEND, Material.RED_ROSE, "Show Pending Friend Requests"), + FRIENDS_DISPLAY_INVENTORY_UI(true, PreferenceCategory.FRIEND, Material.CHEST, "Display Friend GUI"), + + CLAN_TIPS(true, PreferenceCategory.MISC, Material.IRON_SWORD, "Show Clan Tips"), + HUB_MUSIC(true, PreferenceCategory.MISC, Material.NOTE_BLOCK, "Hub Music"), + + //AUTO_JOIN_NEXT_GAME(true, PreferenceCategory.GAME_PLAY, Material.DIAMOND_SWORD, "Auto Join Next Game"), + //COUNTDOWN_ON_CLICK(true, PreferenceCategory.GAME_PLAY, Material.EMERALD, "Countdown to Join"), + ; + private static final Map PREFERENCE_MAP = Maps.newHashMap(); + private static final Map> PREFERENCES_BY_CATEGORY = Maps.newHashMap(); + + static + { + int id = 0; + for (Preference preference : values()) + { + preference._id = ++id; + PREFERENCE_MAP.put(preference._id, preference); + List preferences = PREFERENCES_BY_CATEGORY.getOrDefault(preference._category, Lists.newArrayList()); + preferences.add(preference); + PREFERENCES_BY_CATEGORY.put(preference._category, preferences); + } + + } + + private int _id; + private final boolean _default; + private final PreferenceCategory _category; + private final Material _icon; + private final String _name; + private final String[] _lore; + + Preference(boolean defaultSetting, PreferenceCategory category, Material icon, String name, String... lore) + { + _default = defaultSetting; + _category = category; + _icon = icon; + _name = name; + _lore = lore; + } + + public String getName() + { + return _name; + } + + public Material getIcon() + { + return _icon; + } + + public int getId() + { + return _id; + } + + public boolean getDefaultValue() + { + return _default; + } + + public String[] getLore() + { + return _lore; + } + + public static List getByCategory(PreferenceCategory category) + { + return PREFERENCES_BY_CATEGORY.get(category); + } + + public static Preference get(int id) + { + return PREFERENCE_MAP.get(id); + } + + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java new file mode 100644 index 000000000..113d2d26b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java @@ -0,0 +1,42 @@ +package mineplex.core.preferences; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public enum PreferenceCategory +{ + + USER("User", Material.PAPER), + EXCLUSIVE("Exclusive", Material.DIAMOND), + //GAME_PLAY("Game Mechanic", Material.REDSTONE_COMPARATOR), + MISC("Miscellaneous", Material.COMPASS), + FRIEND("Friend", Material.CHEST), + ; + + private String _name; + private ItemStack _itemStack; + + PreferenceCategory(String name, Material icon) + { + _name = name + " Preferences"; + _itemStack = new ItemBuilder(icon) + .setTitle(C.cYellow + _name) + .build(); + } + + public ItemStack getItem() + { + return _itemStack; + } + + public String getName() + { + return _name; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 07592704a..ca98268ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -1,9 +1,21 @@ package mineplex.core.preferences; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map.Entry; - +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.command.PreferencesCommand; +import mineplex.core.preferences.ui.PreferenceMainMenu; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -11,77 +23,152 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.donation.DonationManager; -import mineplex.core.incognito.IncognitoManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.preferences.command.PreferencesCommand; -import mineplex.core.preferences.ui.ExclusivePreferencesShop; -import mineplex.core.preferences.ui.PreferencesShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.lang.reflect.Field; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; -public class PreferencesManager extends MiniDbClientPlugin +public class PreferencesManager extends MiniPlugin implements ILoginProcessor { - private PreferencesRepository _repository; - private PreferencesShop _shop; - private ExclusivePreferencesShop _exclusiveShop; + private final PreferencesRepository _repository; + private final CoreClientManager _clientManager; + private final IncognitoManager _incognitoManager; - private IncognitoManager _incognitoManager; + private final Set _saveBuffer = Sets.newHashSet(); + private final Map _preferences = Maps.newHashMap(); - private NautHashMap _saveBuffer = new NautHashMap(); - public boolean GiveItem; - - public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager) + + public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager) { - super("Preferences", plugin, clientManager); - - _repository = new PreferencesRepository(plugin); - _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); - _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); + super("Preferences", plugin); + + _repository = new PreferencesRepository(this); + _clientManager = clientManager; _incognitoManager = incognito; + _clientManager.addStoredProcedureLoginProcessor(this); - _exclusiveShop.setPreferencesShop(_shop); - addCommand(new PreferencesCommand(this)); } - - @Override - protected UserPreferences addPlayer(String player) + + @EventHandler + public void onQuit(PlayerQuitEvent event) { - return new UserPreferences(); + Player player = event.getPlayer(); + int accountId = _clientManager.getAccountId(player); + _repository.saveUserPreferences(_preferences.remove(accountId)); } - public void savePreferences(Player caller) - { - _saveBuffer.put(caller.getUniqueId().toString(), Get(caller)); - } - @EventHandler public void givePlayerItem(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + handlePlayerJoin(player, false); + } + + @EventHandler + public void storeBuffer(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + if(_saveBuffer.isEmpty()) + { + return; + } + + List buffer = Lists.newArrayList(_saveBuffer); + + buffer.forEach(_repository::saveUserPreferences); + + buffer.clear(); + _saveBuffer.clear(); + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerInteract(PlayerInteractEvent event) + { + if (!GiveItem) + { + return; + } + + if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR) + { + openMenu(event.getPlayer()); + event.setCancelled(true); + } + } + + public UserPreferences get(Player player) + { + UserPreferences preferences = _preferences.get(_clientManager.getAccountId(player)); + if(preferences == null) + { + preferences = new UserPreferences(_clientManager.getAccountId(player)); + } + return preferences; + } + + public void save(UserPreferences preferences) + { + _saveBuffer.add(preferences); + } + + public IncognitoManager getIncognitoManager() + { + return _incognitoManager; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public void openMenu(Player player) + { + new PreferenceMainMenu(this).open(player); + } + + public void handlePlayerJoin(Player player, boolean force) { if (!GiveItem) return; - - Player player = event.getPlayer(); - - if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM)) + + if (!UtilGear.isMat(player.getInventory().getItem(8), Material.SKULL_ITEM) || force) { ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "My Profile"); SkullMeta meta = ((SkullMeta) item.getItemMeta()); - meta.setOwner(player.getName()); + try + { + Field profileField = meta.getClass().getDeclaredField("profile"); + profileField.setAccessible(true); + profileField.set(meta, UtilGameProfile.getGameProfile(player)); + } + catch (Throwable t) + { + t.printStackTrace(); + } + finally + { + if (!meta.hasOwner()) + { + meta.setOwner(player.getName()); + } + } item.setItemMeta(meta); player.getInventory().setItem(8, item); @@ -89,64 +176,28 @@ public class PreferencesManager extends MiniDbClientPlugin UtilInv.Update(player); } } - - @EventHandler - public void storeBuffer(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOW) - return; - - final NautHashMap bufferCopy = new NautHashMap(); - - for (Entry entry : _saveBuffer.entrySet()) - { - bufferCopy.put(entry.getKey(), entry.getValue()); - } - - _saveBuffer.clear(); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - _repository.saveUserPreferences(bufferCopy); - } - }); - } - @EventHandler(priority = EventPriority.LOWEST) - public void playerInteract(PlayerInteractEvent event) + public void set(int accountId, UserPreferences preferences) { - if (!GiveItem) - return; - - if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR) - { - _shop.attemptShopOpen(event.getPlayer()); - - event.setCancelled(true); - } - } - - public void openShop(Player caller) - { - _shop.attemptShopOpen(caller); + _preferences.put(accountId, preferences); } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + UserPreferences preferences = new UserPreferences(accountId); + while (resultSet.next()) + { + Preference preference = Preference.get(resultSet.getInt("preference")); + boolean value = resultSet.getInt("value") == 1; + preferences.set(preference, value); + } + _preferences.put(accountId, preferences); } @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds, showUserReports FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; - } - - public IncognitoManager getIncognitoManager() - { - return _incognitoManager; + return "SELECT * FROM `preferences` WHERE `accountId` = " + accountId + ";"; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index a0ac20836..0363d05ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -1,140 +1,136 @@ package mineplex.core.preferences; +import mineplex.core.database.MinecraftRepository; +import mineplex.core.progression.util.SQLStatement; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; + import java.sql.Connection; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map.Entry; - -import mineplex.core.database.MinecraftRepository; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.common.util.NautHashMap; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnVarChar; public class PreferencesRepository extends MinecraftRepository { - // 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, ignoreVelocity BOOL - // NOT NULL DEFAULT 0, showUserReports 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 UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ?, showUserReports = ? WHERE uuid=?;"; - - public PreferencesRepository(JavaPlugin plugin) + + private static String UPSERT_ACCOUNT = "INSERT INTO `preferences` VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE `value`= ?"; + private final String GET_PREFS = "SELECT * FROM `preferences` WHERE `accountId` = ?"; + + private final PreferencesManager _manager; + + public PreferencesRepository(PreferencesManager plugin) { - super(plugin, DBPool.getAccount()); + super(plugin.getPlugin(), DBPool.getAccount()); + _manager = plugin; } - + @Override protected void initialize() { - // executeUpdate(CREATE_ACCOUNT_TABLE); } @Override protected void update() { } - - public void saveUserPreferences(NautHashMap preferences) - { - try (Connection connection = getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);) - { - for (Entry entry : preferences.entrySet()) - { - preparedStatement.setBoolean(1, entry.getValue().HubGames); - preparedStatement.setBoolean(2, entry.getValue().ShowPlayers); - preparedStatement.setBoolean(3, entry.getValue().ShowChat); - preparedStatement.setBoolean(4, entry.getValue().FriendChat); - preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging); - preparedStatement.setBoolean(6, entry.getValue().PartyRequests); - preparedStatement.setBoolean(7, entry.getValue().Invisibility); - preparedStatement.setBoolean(8, entry.getValue().HubForcefield); - preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); - preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); - preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); - preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); - preparedStatement.setBoolean(13, entry.getValue().ClanTips); - preparedStatement.setBoolean(14, entry.getValue().HubMusic); - preparedStatement.setBoolean(15, entry.getValue().DisableAds); - preparedStatement.setBoolean(16, entry.getValue().ShowUserReports); - System.out.println(">> " + entry.getValue().ClanTips); - preparedStatement.setString(17, entry.getKey()); - - preparedStatement.addBatch(); - } - int[] rowsAffected = preparedStatement.executeBatch(); - int i = 0; - - for (Entry entry : preferences.entrySet()) - { - if (rowsAffected[i] < 1) - { - executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, entry.getKey())); - - preparedStatement.setBoolean(1, entry.getValue().HubGames); - preparedStatement.setBoolean(2, entry.getValue().ShowPlayers); - preparedStatement.setBoolean(3, entry.getValue().ShowChat); - preparedStatement.setBoolean(4, entry.getValue().FriendChat); - preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging); - preparedStatement.setBoolean(6, entry.getValue().PartyRequests); - preparedStatement.setBoolean(7, entry.getValue().Invisibility); - preparedStatement.setBoolean(8, entry.getValue().HubForcefield); - preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); - preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); - preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); - preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); - preparedStatement.setBoolean(13, entry.getValue().ClanTips); - preparedStatement.setBoolean(14, entry.getValue().HubMusic); - preparedStatement.setBoolean(15, entry.getValue().DisableAds); - preparedStatement.setBoolean(16, entry.getValue().ShowUserReports); - System.out.println(">> " + entry.getValue().ClanTips); - preparedStatement.setString(17, entry.getKey()); - preparedStatement.execute(); - } - - i++; - } - } - catch (Exception exception) + /** + * Save a player's preferences in SQL + * + * @param preferences The player's specific {@code {@link UserPreferences}} instance + */ + public void saveUserPreferences(UserPreferences preferences) + { + async(() -> { - exception.printStackTrace(); - } + int accountId = preferences.getAccountId(); + try (Connection connection = getConnection()) + { + for (Preference preference : Preference.values()) + { + int value = preferences.isActive(preference) ? 1 : 0; + int id = preference.getId(); + PreparedStatement statement = new SQLStatement(UPSERT_ACCOUNT) + .set(1, accountId).set(2, id).set(3, value).set(4, value) + .prepare(connection); + executeUpdate(statement); + } + } catch (SQLException e) + { + e.printStackTrace(); + } + }); } - public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException + /** + * This method is run on the main thread, as we need this information to be laoded before a player joins + * It's also not the true main thread, as it's being called on AsyncPlayerPreLoginEvent + * If, for whatever reason, you need this information sometime differently, please call this async. + * + * @param accountId The player's accountID + * @return A loaded preference for the player + */ + public UserPreferences loadClientInformation(int accountId) { - final UserPreferences preferences = new UserPreferences(); + UserPreferences preferences = new UserPreferences(accountId); - if (resultSet.next()) + executeQuery(GET_PREFS, resultSet -> { - preferences.HubGames = resultSet.getBoolean(1); - preferences.ShowPlayers = resultSet.getBoolean(2); - preferences.ShowChat = resultSet.getBoolean(3); - preferences.FriendChat = resultSet.getBoolean(4); - preferences.PrivateMessaging = resultSet.getBoolean(5); - preferences.PartyRequests = resultSet.getBoolean(6); - preferences.Invisibility = resultSet.getBoolean(7); - preferences.HubForcefield = resultSet.getBoolean(8); - preferences.ShowMacReports = resultSet.getBoolean(9); - preferences.IgnoreVelocity = resultSet.getBoolean(10); - preferences.PendingFriendRequests = resultSet.getBoolean(11); - preferences.friendDisplayInventoryUI = resultSet.getBoolean(12); - preferences.ClanTips = resultSet.getBoolean(13); - preferences.HubMusic = resultSet.getBoolean(14); - preferences.DisableAds = resultSet.getBoolean(15); - preferences.ShowUserReports = resultSet.getBoolean(16); - } - + while (resultSet.next()) + { + Preference preference = Preference.get(resultSet.getInt("preference")); + boolean value = resultSet.getInt("value") == 1; + preferences.set(preference, value); + } + }, new ColumnInt("accountId", accountId)); + return preferences; } + + /** + * Load a clients data async and then update the local reference + * + * @param accountId The player's accountID + */ + public void loadClientInformationAsync(int accountId) + { + async(() -> { + UserPreferences preferences = loadClientInformation(accountId); + _manager.set(accountId, preferences); + }); + } + + public void async(Runnable runnable) + { + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), runnable); + } + + /** + * Internal method for updating the table + * + * @param preparedStatement The statement to execute + * @return The amount of rows effected + */ + private int executeUpdate(PreparedStatement preparedStatement) + { + try + { + return preparedStatement.executeUpdate(); + } catch (SQLException e) + { + e.printStackTrace(); + return -1; + } finally + { + try + { + if (preparedStatement != null) + { + preparedStatement.close(); + } + } catch (SQLException e) + { + e.printStackTrace(); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index f6ef8efba..f54b38994 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -1,22 +1,49 @@ package mineplex.core.preferences; +import com.google.common.collect.Maps; + +import java.util.Map; + public class UserPreferences { - public boolean FilterChat = true; - public boolean HubGames = true; - public boolean ShowPlayers = true; - public boolean ShowChat = true; - public boolean FriendChat = true; - public boolean PrivateMessaging = true; - public boolean PartyRequests = true; - public boolean Invisibility = false; - public boolean HubForcefield = false; - public boolean ShowMacReports = false; - public boolean ShowUserReports = false; - public boolean IgnoreVelocity = false; - public boolean PendingFriendRequests = true; - public boolean friendDisplayInventoryUI = true; - public boolean ClanTips = true; - public volatile boolean HubMusic = true; - public boolean DisableAds = false; + + private int _accountId; + private Map _preferences; + + public UserPreferences(int accountId) + { + _accountId = accountId; + _preferences = Maps.newHashMap(); + } + + public boolean isActive(Preference preference) + { + return _preferences.getOrDefault(preference, preference.getDefaultValue()); + } + + public void toggle(Preference preference) + { + boolean enabled = _preferences.getOrDefault(preference, preference.getDefaultValue()); + _preferences.put(preference, !enabled); + } + + public void enable(Preference preference) + { + _preferences.put(preference, true); + } + + public void disable(Preference preference) + { + _preferences.put(preference, false); + } + + public void set(Preference preference, boolean value) + { + _preferences.put(preference, value); + } + + public int getAccountId() + { + return _accountId; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java index 0bd180f84..a1506b911 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java @@ -1,12 +1,9 @@ package mineplex.core.preferences.command; -import org.bukkit.entity.Player; - -import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.PreferencesManager; +import org.bukkit.entity.Player; public class PreferencesCommand extends CommandBase { @@ -18,6 +15,6 @@ public class PreferencesCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.openShop(caller); + Plugin.openMenu(caller); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java deleted file mode 100644 index 26ece8cbe..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ /dev/null @@ -1,227 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilUI; -import mineplex.core.donation.DonationManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.preferences.UserPreferences; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; - -public class ExclusivePreferencesPage extends ShopPageBase -{ - private IButton _toggleHubInvisibility; - private IButton _toggleHubForcefield; - private IButton _toggleHubIgnoreVelocity; - private IButton _toggleMacReports; - private IButton _toggleUserReports; - - private boolean _hubInvisibilityToggled; - private boolean _hubForcefieldToggled; - private boolean _hubIgnoreVelocityToggled; - private boolean _macReportsToggled; - private boolean _userReportsToggled; - - private PreferencesShop _preferencesShop; - - public ExclusivePreferencesPage(PreferencesManager plugin, ExclusivePreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, PreferencesShop preferencesShop) - { - super(plugin, shop, clientManager, donationManager, name, player, 54); - - _preferencesShop = preferencesShop; - - createButtons(); - buildPage(); - } - - private void createButtons() - { - _toggleHubInvisibility = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubInvisibility(player); - } - }; - - _toggleHubForcefield = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubForcefield(player); - } - }; - - _toggleMacReports = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleMacReports(player); - } - }; - - _toggleUserReports = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleUserReports(player); - } - }; - - _toggleHubIgnoreVelocity = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubIgnoreVelocity(player); - } - }; - } - - @Override - public void playerClosed() - { - super.playerClosed(); - if (preferencesChanged()) - { - getPlugin().savePreferences(getPlayer()); - } - } - - @Override - protected void buildPage() - { - clear(); - - UserPreferences userPreferences = getPlugin().Get(getPlayer()); - Rank rank = getClientManager().Get(getPlayer()).GetRank(); - - addButton(45, new ShopItem(Material.REDSTONE_COMPARATOR, (byte) 0, C.cAqua + "/prefs", new String[] { C.cGold + "Return back to the regular preferences" }, 1, false, false), new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - player.closeInventory(); - _preferencesShop.attemptShopOpen(player); - } - }); - - if (rank.has(Rank.ADMIN) || rank == Rank.JNR_DEV) - { - int[] indices = UtilUI.getIndicesFor(5, 0, 2); - - buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility); - buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield); - buildPreference(indices[2], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports); - buildPreference(indices[3], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - buildPreference(indices[4], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports); - } - else if (rank.has(Rank.MODERATOR)) - { - int[] indices = UtilUI.getIndicesFor(3, 0, 2); - - buildPreference(indices[0], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports); - buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - buildPreference(indices[2], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports); - } - else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH) - { - int[] indices = UtilUI.getIndicesFor(3, 0, 2); - - buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility & Flight", userPreferences.Invisibility, _toggleHubInvisibility); - buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield); - buildPreference(indices[2], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - } - else if (rank == Rank.YOUTUBE_SMALL) - { - int[] indices = UtilUI.getIndicesFor(2, 0, 2); - buildPreference(indices[0], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield); - buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - } - } - - private void toggleHubForcefield(org.bukkit.entity.Player player) - { - getPlugin().Get(player).HubForcefield = !getPlugin().Get(player).HubForcefield; - _hubForcefieldToggled = !_hubForcefieldToggled; - buildPage(); - } - - private void toggleHubInvisibility(org.bukkit.entity.Player player) - { - if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status && /* Hub Invis & Incognito stuck prevention */ !getPlugin().Get(player).Invisibility) - { - UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode.")); - return; - } - - getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility; - - // Dont save for Mod/SnrMod - prevents them just being invis 24/7 - if (getPlugin().Get(player).Invisibility) - { - if (getClient().GetRank().has(Rank.ADMIN) || getClient().GetRank() == Rank.YOUTUBE || getClient().GetRank() == Rank.YOUTUBE_SMALL || getClient().GetRank() == Rank.TWITCH) - { - _hubInvisibilityToggled = !_hubInvisibilityToggled; - } - } - - player.setFlying(false); - player.setAllowFlight(false); - - buildPage(); - } - - private void toggleMacReports(org.bukkit.entity.Player player) - { - getPlugin().Get(player).ShowMacReports = !getPlugin().Get(player).ShowMacReports; - _macReportsToggled = !_macReportsToggled; - buildPage(); - } - - private void toggleUserReports(org.bukkit.entity.Player player) - { - getPlugin().Get(player).ShowUserReports = !getPlugin().Get(player).ShowUserReports; - _userReportsToggled = !_userReportsToggled; - buildPage(); - } - - private void toggleHubIgnoreVelocity(org.bukkit.entity.Player player) - { - getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity; - _hubIgnoreVelocityToggled = !_hubIgnoreVelocityToggled; - buildPage(); - } - - private void buildPreference(int index, Material material, String name, boolean preference, IButton button) - { - buildPreference(index, material, (byte) 0, name, preference, button); - } - - private void buildPreference(int index, Material material, byte data, String name, boolean preference, IButton button) - { - String[] description = new String[] { "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), ChatColor.RED + " ", ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") }; - - addButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - addButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte) 10 : (byte) 8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - } - - public boolean preferencesChanged() - { - return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled || _userReportsToggled; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java deleted file mode 100644 index ba8ec291a..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java +++ /dev/null @@ -1,29 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; - -public class ExclusivePreferencesShop extends ShopBase -{ - private PreferencesShop _preferencesShop; - - public ExclusivePreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager) - { - super(plugin, clientManager, donationManager, "Exclusive Preferences"); - } - - public void setPreferencesShop(PreferencesShop preferencesShop) - { - _preferencesShop = preferencesShop; - } - - @Override - protected ShopPageBase> buildPagesFor(Player player) - { - return new ExclusivePreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), "Exclusive Preferences", player, _preferencesShop); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java new file mode 100644 index 000000000..cbe2b23b1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java @@ -0,0 +1,67 @@ +package mineplex.core.preferences.ui; + +import com.google.common.collect.Lists; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilUI; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.PreferenceCategory; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.ui.buttons.CategoryButton; +import org.bukkit.entity.Player; + +import java.util.List; + +/** + * + */ +public class PreferenceMainMenu extends Menu +{ + + private final int INV_SIZE_MAX = 54; + private final int INV_SIZE_MIN = 45; + + private final int[] SLOTS_MAX = { + 20, 22, 24, 30, 32 + }; + + private final int[] SLOTS_MIN = { + 19, 21, 23, 25 + }; + + + public PreferenceMainMenu(PreferencesManager plugin) + { + super("My Preferences", plugin); + } + + @Override + protected Button[] setUp(Player player) + { + Rank rank = getPlugin().getClientManager().Get(player).GetRank(); + boolean exclusive = rank.has(Rank.HELPER) || rank == Rank.YOUTUBE_SMALL || rank == Rank.YOUTUBE || rank == Rank.TWITCH; + + Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN]; + + List list = Lists.newArrayList(PreferenceCategory.values()); + + if(!exclusive) + { + list.remove(PreferenceCategory.EXCLUSIVE); + } + + int[] slots = UtilUI.getIndicesFor(list.size(), 1, 4, 1); + + int size = list.size(); + + for(int i = 0; i < size; i++) + { + int slot = slots[i]; + PreferenceCategory category = list.get(i); + buttons[slot] = new CategoryButton(category, getPlugin()); + } + + return pane(buttons); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java deleted file mode 100644 index 7c88c9e71..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ /dev/null @@ -1,265 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilUI; -import mineplex.core.donation.DonationManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.preferences.UserPreferences; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; - -public class PreferencesPage extends ShopPageBase -{ - private IButton _toggleHubGames; - private IButton _toggleHubPlayers; - private IButton _toggleChat; - private IButton _togglePrivateChat; - private IButton _toggleHubPartyRequests; - private IButton _togglePendingFriendRequests; - private IButton _toggleClanTips; - private IButton _toggleHubMusic; - private IButton _toggleDisableAds; - - private boolean _hubGamesToggled; - private boolean _hubPlayersToggled; - private boolean _hubChatToggled; - private boolean _hubPrivateChatToggled; - private boolean _hubPartyRequestsToggled; - private boolean _pendingFriendRequestsToggled; - private boolean _clanTipsToggled; - private boolean _hubMusicToggled; - private boolean _disableAdsToggled; - - private ExclusivePreferencesShop _exclusiveShop; - - public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, ExclusivePreferencesShop exclusiveShop) - { - super(plugin, shop, clientManager, donationManager, name, player, 54); - - _exclusiveShop = exclusiveShop; - - createButtons(); - buildPage(); - } - - private void createButtons() - { - _toggleHubGames = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubGames(player); - } - }; - _toggleClanTips = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleClanTips(player); - } - }; - - _toggleHubPlayers = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubPlayers(player); - } - }; - - _toggleChat = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleChat(player); - } - }; - - _togglePrivateChat = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - togglePrivateChat(player); - } - }; - - _toggleHubPartyRequests = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubPartyRequests(player); - } - }; - - _togglePendingFriendRequests = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - togglePendingFriendRequests(player); - } - }; - - _toggleHubMusic = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubMusic(player); - } - }; - - _toggleDisableAds = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleDisableAds(player); - } - }; - } - - private void toggleHubMusic(Player player) - { - getPlugin().Get(player).HubMusic = !getPlugin().Get(player).HubMusic; - _hubMusicToggled = !_hubMusicToggled; - buildPage(); - } - - private void toggleDisableAds(Player player) - { - getPlugin().Get(player).DisableAds = !getPlugin().Get(player).DisableAds; - _disableAdsToggled = !_disableAdsToggled; - buildPage(); - } - - - private void toggleHubPartyRequests(Player player) - { - getPlugin().Get(player).PartyRequests = !getPlugin().Get(player).PartyRequests; - _hubPartyRequestsToggled = !_hubPartyRequestsToggled; - buildPage(); - } - - private void togglePendingFriendRequests(Player player) - { - getPlugin().Get(player).PendingFriendRequests = !getPlugin().Get(player).PendingFriendRequests; - _pendingFriendRequestsToggled = !_pendingFriendRequestsToggled; - buildPage(); - } - - private void togglePrivateChat(Player player) - { - getPlugin().Get(player).PrivateMessaging = !getPlugin().Get(player).PrivateMessaging; - _hubPrivateChatToggled = !_hubPrivateChatToggled; - buildPage(); - } - - private void toggleChat(Player player) - { - getPlugin().Get(player).ShowChat = !getPlugin().Get(player).ShowChat; - _hubChatToggled = !_hubChatToggled; - buildPage(); - } - - private void toggleHubPlayers(Player player) - { - getPlugin().Get(player).ShowPlayers = !getPlugin().Get(player).ShowPlayers; - _hubPlayersToggled = !_hubPlayersToggled; - buildPage(); - } - - private void toggleClanTips(Player player) - { - getPlugin().Get(player).ClanTips = !getPlugin().Get(player).ClanTips; - _clanTipsToggled = !_clanTipsToggled; - buildPage(); - } - - private void toggleHubGames(Player player) - { - getPlugin().Get(player).HubGames = !getPlugin().Get(player).HubGames; - _hubGamesToggled = !_hubGamesToggled; - buildPage(); - } - - @Override - public void playerClosed() - { - super.playerClosed(); - - System.out.println("Prefs have changed: " + preferencesChanged()); - if (preferencesChanged()) - { - getPlugin().savePreferences(getPlayer()); - } - } - - @Override - protected void buildPage() - { - clear(); - - UserPreferences userPreferences = getPlugin().Get(getPlayer()); - Rank rank = getClientManager().Get(getPlayer()).GetRank(); - - int amount = rank.has(Rank.ULTRA) ? 9 : 8; - int[] indices = UtilUI.getIndicesFor(amount, 0, 2); - - buildPreference(indices[0], Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames); - buildPreference(indices[1], Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers); - buildPreference(indices[2], Material.PAPER, "Player Chat", userPreferences.ShowChat, _toggleChat); - buildPreference(indices[3], Material.EMPTY_MAP, "Private Messaging", userPreferences.PrivateMessaging, _togglePrivateChat); - buildPreference(indices[4], Material.SKULL_ITEM, (byte) 3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests); - buildPreference(indices[5], Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests); - buildPreference(indices[6], Material.IRON_SWORD, "Show Clan Tips", userPreferences.ClanTips, _toggleClanTips); - buildPreference(indices[7], Material.NOTE_BLOCK, "Hub Music", userPreferences.HubMusic, _toggleHubMusic); - if (rank.has(Rank.ULTRA)) - buildPreference(indices[8], Material.BARRIER, "Disable Ads", userPreferences.DisableAds, _toggleDisableAds); - - if (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.YOUTUBE_SMALL) - { - addButton(53, new ShopItem(Material.DIAMOND, (byte) 0, C.cAqua + "Exclusive Preferences", new String[]{C.cGold + "This will open a page of preferences", C.cGold + "that are only available to you."}, 1, false, false), new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - player.closeInventory(); - _exclusiveShop.attemptShopOpen(player); - } - }); - } - } - - private void buildPreference(int index, Material material, String name, boolean preference, IButton button) - { - buildPreference(index, material, (byte) 0, name, preference, button); - } - - private void buildPreference(int index, Material material, byte data, String name, boolean preference, IButton button) - { - String[] description = new String[] { "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), ChatColor.RED + " ", ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") }; - - addButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - addButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte) 10 : (byte) 8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - } - - public boolean preferencesChanged() - { - return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled || _hubMusicToggled || _disableAdsToggled; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java deleted file mode 100644 index e3b172414..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java +++ /dev/null @@ -1,25 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; - -public class PreferencesShop extends ShopBase -{ - private ExclusivePreferencesShop _exclusiveShop; - - public PreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager, ExclusivePreferencesShop exclusiveShop) - { - super(plugin, clientManager, donationManager, "My Preferences"); - _exclusiveShop = exclusiveShop; - } - - @Override - protected ShopPageBase> buildPagesFor(Player player) - { - return new PreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), "My Preferences", player, _exclusiveShop); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java new file mode 100644 index 000000000..4ae6d6491 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java @@ -0,0 +1,41 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.PreferencesManager; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class BackButton extends Button +{ + + private static ItemStack ITEM = new ItemBuilder(Material.BED) + .setTitle(ChatColor.GRAY + "\u21FD Go Back") + .build(); + + public BackButton(PreferencesManager plugin) + { + super(ITEM, plugin); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + Menu.get(player.getUniqueId()).setUseClose(false); + + player.closeInventory(); + + getPlugin().openMenu(player); + + getPlugin().save(getPlugin().get(player)); + + Menu.get(player.getUniqueId()).setUseClose(true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java new file mode 100644 index 000000000..efcbc3770 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java @@ -0,0 +1,29 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.menu.Button; +import mineplex.core.preferences.PreferenceCategory; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.ui.menus.PreferenceMenu; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * + */ +public class CategoryButton extends Button +{ + + private PreferenceCategory _category; + + public CategoryButton(PreferenceCategory category, PreferencesManager plugin) + { + super(category.getItem(), plugin); + _category = category; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + new PreferenceMenu(_category, getPlugin()).open(player); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java new file mode 100644 index 000000000..e22daeff5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java @@ -0,0 +1,63 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.UserPreferences; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class PreferenceButton extends Button +{ + + protected final Preference _preference; + protected final UserPreferences _user; + private final ItemStack _disabled; + private final ItemStack _enabled; + + public PreferenceButton(UserPreferences user, Preference preference, PreferencesManager plugin) + { + super(null, plugin); + _preference = preference; + _user = user; + + Material icon = preference.getIcon(); + boolean head = icon == Material.SKULL_ITEM; + + _disabled = new ItemBuilder(preference.getIcon()) + .setTitle(C.cRed + preference.getName()) + .setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable") + .setData(head ? (short) 3 : 0) + .build(); + + _enabled = new ItemBuilder(preference.getIcon()) + .setTitle(C.cGreen + preference.getName()) + .setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable") + .setData(head ? (short) 3 : 0) + .build(); + + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _user.toggle(_preference); + Menu.get(player.getUniqueId()).resetAndUpdate(); + } + + @Override + public ItemStack getItemStack() + { + return _user.isActive(_preference) ? _enabled : _disabled; + } + + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java new file mode 100644 index 000000000..886091a16 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java @@ -0,0 +1,43 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.UserPreferences; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class PreferenceDyeButton extends PreferenceButton +{ + + private final ItemStack _disabledDye; + private final ItemStack _enabledDye; + + public PreferenceDyeButton(UserPreferences user, Preference preference, PreferencesManager plugin) + { + super(user, preference, plugin); + + _disabledDye = new ItemBuilder(Material.INK_SACK) + .setData(DyeColor.GRAY.getDyeData()) + .setTitle(C.cRed + preference.getName()) + .setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable") + .build(); + + _enabledDye = new ItemBuilder(Material.INK_SACK) + .setData(DyeColor.LIME.getDyeData()) + .setTitle(C.cGreen + preference.getName()) + .setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable") + .build(); + } + + @Override + public ItemStack getItemStack() + { + return _user.isActive(_preference) ? _enabledDye : _disabledDye; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java new file mode 100644 index 000000000..08aef8b47 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java @@ -0,0 +1,86 @@ +package mineplex.core.preferences.ui.menus; + +import com.google.common.collect.Lists; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilUI; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferenceCategory; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.UserPreferences; +import mineplex.core.preferences.ui.buttons.BackButton; +import mineplex.core.preferences.ui.buttons.PreferenceButton; +import mineplex.core.preferences.ui.buttons.PreferenceDyeButton; +import org.bukkit.entity.Player; + +import java.util.List; + +/** + * + */ +public class PreferenceMenu extends Menu +{ + + private final int INV_SIZE = 54; + + private final PreferenceCategory _category; + + public PreferenceMenu(PreferenceCategory category, PreferencesManager plugin) + { + super(category.getName(), plugin); + _category = category; + setUseClose(true); + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[INV_SIZE]; + + List preferences = Lists.newArrayList(Preference.getByCategory(_category)); + Rank rank = getPlugin().getClientManager().Get(player).GetRank(); + UserPreferences user = getPlugin().get(player); + + if (_category == PreferenceCategory.EXCLUSIVE && !rank.has(Rank.ADMIN) && rank != Rank.JNR_DEV) + { + if (rank.has(Rank.HELPER) && !rank.has(Rank.ADMIN)) + { + preferences.remove(Preference.INVISIBILITY); + preferences.remove(Preference.FORCE_FIELD); + } + else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH) + { + preferences.remove(Preference.GLOBAL_GWEN_REPORTS); + preferences.remove(Preference.SHOW_USER_REPORTS); + } + else if (rank == Rank.YOUTUBE_SMALL) + { + preferences.remove(Preference.GLOBAL_GWEN_REPORTS); + preferences.remove(Preference.SHOW_USER_REPORTS); + preferences.remove(Preference.INVISIBILITY); + } + } + + int[] slots = UtilUI.getIndicesFor(preferences.size(), 1, 4, 1); + + for(int i = 0; i < preferences.size(); i++) + { + int slot = slots[i]; + Preference preference = preferences.get(i); + buttons[slot] = new PreferenceButton(user, preference, getPlugin()); + buttons[slot + 9] = new PreferenceDyeButton(user, preference, getPlugin()); + } + + buttons[0] = new BackButton(getPlugin()); + + return pane(buttons); + } + + @Override + public void onClose(Player player) + { + remove(player.getUniqueId()); + getPlugin().save(getPlugin().get(player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java index a9eb96818..8a59bcac1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java @@ -5,11 +5,10 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mineplex.core.ReflectivelyCreateMiniPlugin; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -29,17 +28,16 @@ import mineplex.serverdata.Region; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; +@ReflectivelyCreateMiniPlugin public class ProfileCacheManager extends MiniPlugin implements GameProfileRepository { - private static ProfileCacheManager INSTANCE; - private YggdrasilGameProfileRepository _mojangProfileRepository; private RedisDataRepository _profileRepository; private Gson _gson; - public ProfileCacheManager(JavaPlugin plugin) + private ProfileCacheManager() { - super("Profile Cache", plugin); + super("Profile Cache"); _profileRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), Region.ALL, ProfileData.class, "profileCacheRepo"); @@ -67,10 +65,11 @@ public class ProfileCacheManager extends MiniPlugin implements GameProfileReposi System.out.println("Are you using the correct modified Craftbukkit?"); System.out.println("================================================"); } - - INSTANCE = this; } + /** + * Tries to get a GameProfile; guaranteed to be an unique instance + */ public GameProfile attemptToLoadProfile(String playerName) { ProfileData profile = _profileRepository.getElement(playerName.toLowerCase()); @@ -134,9 +133,4 @@ public class ProfileCacheManager extends MiniPlugin implements GameProfileReposi ProfileData data = new ProfileData(profile.getId(), profile.getName(), _gson.toJson(profile.getProperties())); _profileRepository.addElement(data, 60 * 60 * 24); // 1 day } - - public static ProfileCacheManager getInstance() - { - return INSTANCE; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java index 4c3a962ea..19b1dff5b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java @@ -4,9 +4,10 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.progression.data.PlayerKit; import mineplex.core.progression.data.PlayerKitDataManager; -import mineplex.core.progression.gui.MenuListener; import org.bukkit.plugin.java.JavaPlugin; +import java.util.UUID; + /** * The main class, process logins and loads data. */ @@ -23,7 +24,6 @@ public class KitProgressionManager extends MiniClientPlugin _dataManager = new PlayerKitDataManager(); _kitProgressionRepository = new KitProgressionRepository(this); _coreClientManager = clientManager; - getPlugin().getServer().getPluginManager().registerEvents(new MenuListener(), getPlugin()); } public CoreClientManager getClientManager() @@ -31,9 +31,8 @@ public class KitProgressionManager extends MiniClientPlugin return _coreClientManager; } - @Override - protected PlayerKit addPlayer(String player) + protected PlayerKit addPlayer(UUID uuid) { return null; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionRepository.java index 7978eaa0d..35e6ca273 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionRepository.java @@ -148,6 +148,38 @@ public class KitProgressionRepository extends MinecraftRepository }); } + /** + * Possibly remove + * @param uuid + */ + public void loadInfoSync(UUID uuid) + { + PlayerKit playerKit = new PlayerKit(uuid); + try (Connection connection = getConnection()) + { + PreparedStatement preparedStatement = new SQLStatement(QUERY_KITS).set(1, uuid).prepare(connection); + ResultSet resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) + { + String kitId = resultSet.getString("kitId"); + + int level = resultSet.getInt("level"); + int xp = resultSet.getInt("xp"); + int upgradeLevel = resultSet.getInt("upgrade_level"); + boolean def = resultSet.getInt("default") == 1; + + playerKit.setLevel(level, kitId); + playerKit.setXp(xp, kitId); + playerKit.setUpgradeLevel(upgradeLevel, kitId); + playerKit.setDefault(def, kitId); + } + } catch (SQLException e) + { + e.printStackTrace(); + } + + _kitProgressionManager.getDataManager().add(playerKit); + } @SuppressWarnings("Duplicates") public void getInfo(UUID uuid) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java index 7ea77ef52..ec55bfb35 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java @@ -1,16 +1,17 @@ package mineplex.core.progression; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.progression.data.KitAbilityDetail; -import mineplex.core.progression.math.Calculations; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import java.util.List; -import java.util.UUID; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.progression.math.Calculations; /** * The API class all kits with the new system must use @@ -49,11 +50,20 @@ public interface ProgressiveKit /** * This method gives the GUI information to display about the kit's upgrades and what they do * This information is being directly displayed in a GUI, so make sure it looks good - * For more information, see the {@link KitAbilityDetail} class * - * @return The map of upgrades and their details + * @return The map of upgrade level to a list of upgrade details */ - List getAbilityDetails(); + Map> getUpgradeDetails(); + + /** + * Determines whether or not the kit UI is displayed with "Coming Soon" or actual upgrade details. + * + * @return true if the menu should populate from {@code getAbilityDetails} + */ + default boolean showUpgrades() + { + return false; + } /** * Retrieve the current level of this kit diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitAbilityDetail.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitAbilityDetail.java deleted file mode 100644 index b88519c41..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitAbilityDetail.java +++ /dev/null @@ -1,38 +0,0 @@ -package mineplex.core.progression.data; - -import org.bukkit.Material; - -/** - * General wrapper for Ability Details (The display properties of this kits Abilities) for a GUI - * The purpose is to limit the amount of hard coded data Kit's do and make it as flexible as possible. - */ -public class KitAbilityDetail -{ - - private Material _icon; - private String _displayName; - private String[] _description; - - public KitAbilityDetail(Material icon, String displayName, String[] description) - { - _icon = icon; - _displayName = displayName; - _description = description; - } - - public String getDisplayName() - { - return _displayName; - } - - public Material getIcon() - { - return _icon; - } - - public String[] getDescription() - { - return _description; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/PlayerKitDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/PlayerKitDataManager.java index faa5641f0..c1263dcd4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/PlayerKitDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/PlayerKitDataManager.java @@ -20,7 +20,7 @@ public class PlayerKitDataManager public PlayerKit get(UUID uuid) { - return _dataMapAccountUUID.get(uuid); + return _dataMapAccountUUID.getOrDefault(uuid, new PlayerKit(uuid)); } public void add(PlayerKit playerKit) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java deleted file mode 100644 index 5e172ce91..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java +++ /dev/null @@ -1,36 +0,0 @@ -package mineplex.core.progression.gui; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -/** - * An abstract class for managing buttons inside of menus - */ -public abstract class Button -{ - - private ItemStack _item; - - public Button(ItemStack item) - { - this._item = item; - } - - /** - * The method called when a players clicks the slot - * - * @param player The player who clicked - */ - public abstract void onClick(Player player); - - public ItemStack getItemStack() - { - return _item; - } - - public void setItemStack(ItemStack item) - { - this._item = item; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java deleted file mode 100644 index e2089e9ff..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java +++ /dev/null @@ -1,191 +0,0 @@ -package mineplex.core.progression.gui; - -import mineplex.core.progression.gui.buttons.misc.IconButton; -import net.md_5.bungee.api.ChatColor; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -/** - * A class to manage dynamic creation of GUI's - */ -public abstract class Menu -{ - - protected static final Button[] EMPTY = new Button[45]; - protected static Map MENUS = new HashMap<>(); - private String _name; - protected Button[] _buttons; - - public Menu(String name) - { - _name = name; - _buttons = EMPTY; - } - - public static Menu get(UUID name) - { - return MENUS.get(name); - } - - - /** - * Create an icon (no click action) - * - * @param item The itemstack ti display - * @return The created button - */ - protected Button create(ItemStack item) - { - return new IconButton(item); - } - - public String getName() - { - return ChatColor.translateAlternateColorCodes('&', _name); - } - - /** - * Open and setup the inventory for the player to view - * Store a reference to it inside a map for retrieving later - * - * @param player The player who we wish to show the GUI to - */ - public void open(Player player) - { - setButtons(setUp()); - - if (MENUS.get(player.getUniqueId()) != null) - { - MENUS.remove(player.getUniqueId()); - } - - MENUS.put(player.getUniqueId(), this); - - int size = (_buttons.length + 8) / 9 * 9; - Inventory inventory = Bukkit.createInventory(player, size, getName()); - - for (int i = 0; i < _buttons.length; i++) - { - if (_buttons[i] == null) - { - continue; - } - - ItemStack item = _buttons[i].getItemStack(); - - inventory.setItem(i, item); - } - player.openInventory(inventory); - } - - /** - * Set up the GUI with buttons - * - * @return The setup button array - */ - protected abstract Button[] setUp(); - - public Button[] getButtons() - { - return _buttons; - } - - public void setButtons(Button[] buttons) - { - _buttons = buttons; - } - - /** - * Retrieve the button based off the slot - * - * @param slot The slot in the inventory - * @return The button corresponding to that slot - */ - public Button getButton(int slot) - { - try - { - return _buttons[slot]; - } catch (ArrayIndexOutOfBoundsException e) - { - //There isn't a button there, so no need to throw an error - //e.printStackTrace(); - return null; - } - } - - /** - * Replace a button, or create a new button dynamically - * Update the players GUI - * - * @param slot The slot to set the new button - * @param button The reference to the button - * @param player The player whose GUI we'll be updating - */ - public void setButton(int slot, Button button, Player player) - { - try - { - _buttons[slot] = button; - } catch (ArrayIndexOutOfBoundsException ignored) - { - ignored.printStackTrace(); - } - update(player); - } - - /** - * Refresh the players view, allows to change what the player sees, without opening and closing the GUI - * - * @param player The player whose view you wish to update - */ - public void update(Player player) - { - InventoryView view = player.getOpenInventory(); - - if (view == null) - { - return; - } - - if (!view.getTitle().equalsIgnoreCase(getName())) - { - return; - } - - Inventory inventory = view.getTopInventory(); - for (int i = 0; i < _buttons.length; i++) - { - if (_buttons[i] == null) - { - continue; - } - - ItemStack item = _buttons[i].getItemStack(); - - inventory.setItem(i, item); - } - } - - public void setTitle(String title) - { - _name = title; - } - - public void onClose(Player player) - { - MENUS.remove(player.getUniqueId()); - } - - public static Menu remove(UUID uniqueId) - { - return MENUS.remove(uniqueId); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java deleted file mode 100644 index 3fc59c542..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.core.progression.gui; - -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; - -/** - * Listener for the Menu system - */ -public class MenuListener implements Listener -{ - - @EventHandler - public void onClick(InventoryClickEvent event) - { - String name = event.getInventory().getName(); - Player player = (Player) event.getWhoClicked(); - Menu gui = Menu.get(player.getUniqueId()); - - if (gui == null) - { - return; - } - - if (!gui.getName().equalsIgnoreCase(name)) - { - return; - } - - Button button = gui.getButton(event.getRawSlot()); - - event.setCancelled(true); - event.setResult(Event.Result.DENY); - - if (button == null) - { - return; - } - - button.onClick(player); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java deleted file mode 100644 index 817d1a8bf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java +++ /dev/null @@ -1,50 +0,0 @@ -package mineplex.core.progression.gui.buttons; - -import com.google.common.collect.Lists; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.progression.data.KitAbilityDetail; -import mineplex.core.progression.gui.buttons.misc.IconButton; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; -import java.util.List; - -/** - * Representing this kits Abilities in a GUI - */ -public class KitAbilityButton extends IconButton -{ - - private ItemStack _item; - - public KitAbilityButton(KitAbilityDetail detail) - { - super(null); - - ItemBuilder builder = new ItemBuilder(detail.getIcon()); - - builder.setTitle(detail.getDisplayName()); - - List lore = Lists.newArrayList(" "); - - lore.addAll(Arrays.asList(detail.getDescription())); - lore.add(" "); - - builder.setLore(lore.toArray(new String[lore.size()])); - - _item = builder.build(); - } - - @Override - public ItemStack getItemStack() - { - return _item; - } - - @Override - public void setItemStack(ItemStack item) - { - _item = item; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java index 6614e2528..7b3ff477f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java @@ -1,21 +1,27 @@ package mineplex.core.progression.gui.buttons; +import mineplex.core.menu.Button; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; import org.bukkit.inventory.ItemStack; /** * Similar to KitMenu, this helps with organizing buttons related to kits * Since they all share common features. */ -public abstract class KitButton extends Button +public abstract class KitButton extends Button { private ProgressiveKit _kit; public KitButton(ProgressiveKit kit, ItemStack itemStack) { - super(itemStack); + this(kit, itemStack, null); + } + + public KitButton(ProgressiveKit kit, ItemStack itemStack, KitProgressionManager plugin) + { + super(itemStack, plugin); _kit = kit; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java index 24b94d19a..d29f09c20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java @@ -7,6 +7,7 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.progression.ProgressiveKit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.List; @@ -68,7 +69,7 @@ public class KitIconButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { getKit().onSelected(player.getUniqueId()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java index efaafd3cd..12be52d5a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java @@ -6,6 +6,7 @@ import net.md_5.bungee.api.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; /** @@ -37,7 +38,7 @@ public class KitPermanentDefaultButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { getKit().onSelected(player.getUniqueId()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java index acdf770fc..b6b302c98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java @@ -8,6 +8,7 @@ import net.md_5.bungee.api.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; /** * This manages selecting of the kit for the current game. @@ -31,7 +32,7 @@ public class KitSelectButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { getKit().onSelected(player.getUniqueId()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java index cc73ff690..e2922a50d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java @@ -1,10 +1,11 @@ package mineplex.core.progression.gui.buttons; import mineplex.core.common.util.F; +import mineplex.core.menu.Menu; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Menu; import org.bukkit.Sound; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.UUID; @@ -16,21 +17,19 @@ public class KitUpgradeButton extends KitButton { private int _upgradeLevel; - private String _upggradeName; - public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel, String upggradeName) + public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel) { super(kit, itemStack); _upgradeLevel = upgradeLevel; - _upggradeName = upggradeName; } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { UUID uuid = player.getUniqueId(); - if (!getKit().canPurchaseUpgrade(uuid, _upgradeLevel)) + if (!getKit().canPurchaseUpgrade(uuid, _upgradeLevel) || getKit().ownsUpgrade(uuid, _upgradeLevel)) { player.playSound(player.getLocation(), Sound.ITEM_BREAK, 10.0F, 1.0F); player.sendMessage(F.main("Kit Progression", "You cannot purchase this upgrade!")); @@ -41,7 +40,7 @@ public class KitUpgradeButton extends KitButton player.playSound(player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f); - player.sendMessage(F.main("Kit Progression", "Purchased " + _upggradeName)); + player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + getKit().getDisplayName() + " level " + _upgradeLevel)); Menu.remove(uuid); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java new file mode 100644 index 000000000..911a8087d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java @@ -0,0 +1,55 @@ +package mineplex.core.progression.gui.buttons; + +import com.google.common.collect.Lists; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.IconButton; +import mineplex.core.progression.math.Calculations; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import java.util.List; + +/** + * Representing this kits Abilities in a GUI + */ +public class KitUpgradeDetailsButton extends IconButton +{ + + private ItemStack _item; + + public KitUpgradeDetailsButton(int level, List details) + { + super(null); + + ItemBuilder builder = new ItemBuilder(Material.SLIME_BALL); + + builder.setTitle(C.cYellow + "Level " + level + " upgrades"); + + List lore = Lists.newArrayList(" "); + + for (String detail : details) + { + lore.add(C.cGray + detail); + } + + lore.add(""); + lore.add(C.cGray + "Unlocks at kit level " + C.cGreen + Calculations.getLevelRequiredFor(level)); + builder.setLore(lore.toArray(new String[lore.size()])); + + _item = builder.build(); + } + + @Override + public ItemStack getItemStack() + { + return _item; + } + + @Override + public void setItemStack(ItemStack item) + { + _item = item; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java index d8792c357..0bd36086c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java @@ -2,6 +2,7 @@ package mineplex.core.progression.gui.buttons; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.gui.guis.KitInformationTrackerMenu; import mineplex.core.progression.gui.guis.KitMenu; @@ -9,12 +10,11 @@ import mineplex.core.progression.math.Calculations; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import static mineplex.core.common.util.UtilServer.getPlugin; - /** * This is the button for upgrades. It'll flash when one is available * Displays information regarding upgrades on hover @@ -31,9 +31,9 @@ public class KitUpgradeMenuButton extends KitButton private boolean _flash; private BukkitTask _task; - public KitUpgradeMenuButton(ProgressiveKit kit, Player player) + public KitUpgradeMenuButton(ProgressiveKit kit, Player player, KitProgressionManager plugin) { - super(kit, null); + super(kit, null, plugin); _item = ITEM_STACK; //The current upgrade level out of 5 for this kit @@ -50,13 +50,19 @@ public class KitUpgradeMenuButton extends KitButton //This ONLY flashes if their next upgrade level isn't their same one. _flash = Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel); + ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer); + + if(kit.showUpgrades()) + { + ItemBuilder builder = lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel, color, diff); + builder.setTitle(C.cYellow + "Upgrade Level " + upgradeLevel); + _item = builder.build(); + } + if (_flash) { flash(); } - - ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer); - } @Override @@ -73,7 +79,7 @@ public class KitUpgradeMenuButton extends KitButton private void flash() { - this._task = new BukkitRunnable() + _task = new BukkitRunnable() { private ItemStack itemClone = ITEM_STACK.clone(); @@ -103,20 +109,20 @@ public class KitUpgradeMenuButton extends KitButton resetItem = true; } - }.runTaskTimer(getPlugin(), 0L, 10L); + }.runTaskTimer(getPlugin().getPlugin(), 0L, 10L); } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { - this._flash = false; + _flash = false; if (_task != null) { - this._task.cancel(); + _task.cancel(); } - KitMenu menu = new KitInformationTrackerMenu(getKit()); + KitMenu menu = new KitInformationTrackerMenu(getKit(), getPlugin()); menu.open(player); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java index c96cc3a08..11fd5fbba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java @@ -9,6 +9,7 @@ import mineplex.core.progression.math.Calculations; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.List; @@ -87,9 +88,9 @@ public class KitXPButton extends KitButton @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { - KitMenu menu = new KitInformationTrackerMenu(getKit()); + KitMenu menu = new KitInformationTrackerMenu(getKit(), getPlugin()); menu.open(player); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java index 11dd54c5a..be6519c88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java @@ -1,17 +1,19 @@ package mineplex.core.progression.gui.buttons.misc; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.progression.gui.Button; +import mineplex.core.menu.Button; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.gui.guis.KitMenu; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; /** * This button take you back to the specified menu */ -public class BackButton extends Button +public class BackButton extends Button { private static ItemStack ITEM = new ItemBuilder(Material.BED) @@ -22,7 +24,7 @@ public class BackButton extends Button public BackButton(KitMenu toMenu) { - super(ITEM); + super(ITEM, null); _toMenu = toMenu; } @@ -33,7 +35,7 @@ public class BackButton extends Button } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { _toMenu.open(player); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java deleted file mode 100644 index 36de05e7c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java +++ /dev/null @@ -1,23 +0,0 @@ -package mineplex.core.progression.gui.buttons.misc; - -import mineplex.core.progression.gui.Button; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -/** - * A button designed for purely cosmetic reasons, but has no impact when clicked. - */ -public class IconButton extends Button -{ - - public IconButton(ItemStack item) - { - super(item); - } - - @Override - public void onClick(Player player) - { - - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java index f46165e34..8124a5f48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java @@ -1,11 +1,20 @@ package mineplex.core.progression.gui.guis; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; -import mineplex.core.progression.gui.buttons.*; -import mineplex.core.progression.gui.buttons.misc.IconButton; +import mineplex.core.progression.gui.buttons.KitIconButton; +import mineplex.core.progression.gui.buttons.KitPermanentDefaultButton; +import mineplex.core.progression.gui.buttons.KitSelectButton; +import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton; +import mineplex.core.progression.gui.buttons.KitUpgradeMenuButton; +import mineplex.core.progression.gui.buttons.KitXPButton; import org.bukkit.entity.Player; +import java.util.List; +import java.util.Map; + /** * This is the main menu a player sees when we selects an NPC Kit * Displays the most important information about this kit @@ -25,13 +34,13 @@ public class KitDisplayMenu extends KitMenu 7, 8, 16, 17 }; - public KitDisplayMenu(ProgressiveKit kit) + public KitDisplayMenu(ProgressiveKit kit, KitProgressionManager plugin) { - super(kit); + super(kit, plugin); } @Override - public Button[] setup(Player player) + public Button[] setUp(Player player) { Button[] buttons = new Button[51]; @@ -39,7 +48,7 @@ public class KitDisplayMenu extends KitMenu setUpIcon(buttons, player); - setUpDetails(buttons); + setUpDetails(buttons, player); setUpNextMenuButtons(buttons, player); @@ -55,7 +64,7 @@ public class KitDisplayMenu extends KitMenu private void setUpNextMenuButtons(Button[] buttons, Player player) { buttons[48] = new KitXPButton(getKit(), player); - buttons[50] = new KitUpgradeMenuButton(getKit(), player); + buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin()); } /** @@ -70,12 +79,22 @@ public class KitDisplayMenu extends KitMenu /** * Set up the details (info) regarding the upgrades to this kit - * Lines commented out due to waiting to release upgrades * * @param buttons The array of buttons we're modifying */ - private void setUpDetails(Button[] buttons) + private void setUpDetails(Button[] buttons, Player player) { + if(getKit().showUpgrades()) + { + Map> details = getKit().getUpgradeDetails(); + int index = 0; + for(int i : UPGRADE_SLOTS) + { + buttons[i] = new KitUpgradeDetailsButton(index + 1, details.get(index++)); + } + return; + } + for (int i : UPGRADE_SLOTS) { buttons[i] = new IconButton(COMING_SOON); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java index 89b0708cf..992490c69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java @@ -3,10 +3,13 @@ package mineplex.core.progression.gui.guis; import com.google.common.collect.Lists; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; +import mineplex.core.progression.gui.buttons.KitUpgradeButton; +import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton; import mineplex.core.progression.gui.buttons.misc.BackButton; -import mineplex.core.progression.gui.buttons.misc.IconButton; import mineplex.core.progression.math.Calculations; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -15,6 +18,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -42,17 +46,17 @@ public class KitInformationTrackerMenu extends KitMenu 47, 48, 49, 50, 51 }; - public KitInformationTrackerMenu(ProgressiveKit kit) + public KitInformationTrackerMenu(ProgressiveKit kit, KitProgressionManager plugin) { - super(kit); + super(kit, plugin); } @Override - public Button[] setup(Player player) + public Button[] setUp(Player player) { Button[] buttons = new Button[52]; - buttons[0] = new BackButton(new KitDisplayMenu(getKit())); + buttons[0] = new BackButton(new KitDisplayMenu(getKit(), getPlugin())); setUpXP(buttons, player); @@ -137,13 +141,46 @@ public class KitInformationTrackerMenu extends KitMenu } /** - * Set up the row of Dyes / Music discs symbolizing the players upgrade advancement + * Set up the row of items symbolizing the players upgrade advancement * * @param buttons The array of buttons we're modifying * @param player The player whose data we'll be using */ private void setUpUpgrade(Button[] buttons, Player player) { + if(getKit().showUpgrades()) + { + Map> details = getKit().getUpgradeDetails(); + + int index = 0; + for(int i : UPGRADE_SLOTS) + { + List list = details.get(index++); + KitUpgradeDetailsButton detailsButton = new KitUpgradeDetailsButton(index, list); + ItemBuilder itemStack = new ItemBuilder(detailsButton.getItemStack()); + + if (getKit().ownsUpgrade(player.getUniqueId(), index)) + { + itemStack.addLore(C.cRed + "You already own this upgrade!"); + } + else if (getKit().canPurchaseUpgrade(player.getUniqueId(), index)) + { + itemStack.setGlow(true); + itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems"); + itemStack.addLore(C.cGreen + "Click to purchase this upgrade!"); + } + else + { + itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems"); + itemStack.addLore(C.cRed + "You cannot purchase this upgrade!"); + } + + KitUpgradeButton upgradeButton = new KitUpgradeButton(getKit(), itemStack.build(), index); + buttons[i] = upgradeButton; + } + return; + } + for (int i : UPGRADE_SLOTS) { buttons[i] = new IconButton(COMING_SOON); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java index 4c546aa7b..316c480de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java @@ -1,21 +1,18 @@ package mineplex.core.progression.gui.guis; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Menu; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; -import mineplex.core.progression.gui.Menu; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; /** * An implementation of {@link Menu} corresponding to kits */ -public abstract class KitMenu extends Menu +public abstract class KitMenu extends Menu { /** @@ -30,72 +27,14 @@ public abstract class KitMenu extends Menu private ProgressiveKit _kit; - public KitMenu(ProgressiveKit kit) + public KitMenu(ProgressiveKit kit, KitProgressionManager manager) { - super(kit.getDisplayName()); + super(kit.getDisplayName(), manager); _kit = kit; } - /** - * Set up a menu based on the specific player - * - * @param player The player who we want to tailor the GUI to - * @return The setup arrangement of buttons - */ - public abstract Button[] setup(Player player); - - /** - * Open a GUI tailored to the player - * - * @param player The player who we wish to show the GUI to - */ - @Override - public void open(Player player) - { - this.setButtons(setup(player)); - - if (MENUS.get(player.getUniqueId()) != null) - { - MENUS.remove(player.getUniqueId()); - } - - MENUS.put(player.getUniqueId(), this); - - int size = (this._buttons.length + 8) / 9 * 9; - Inventory inventory = Bukkit.createInventory(player, size, getName()); - - for (int i = 0; i < _buttons.length; i++) - { - if (_buttons[i] == null) - { - continue; - } - - ItemStack item = _buttons[i].getItemStack(); - - inventory.setItem(i, item); - } - player.openInventory(inventory); - } - - /** - * Get the kit specific to this GUI - * - * @return This GUI's kit - */ public ProgressiveKit getKit() { return _kit; } - - /** - * We don't want to use this, as we may require per player GUI's - * @return The arrangement of buttons - */ - @Override - public Button[] setUp() - { - return new Button[45]; - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java index be4c2f959..b4a6ac726 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java @@ -186,7 +186,6 @@ public class Calculations return 100; } - @SuppressWarnings("Duplicates") public static int getLevelRequiredFor(int upgradeLevel) { switch (upgradeLevel) @@ -205,4 +204,15 @@ public class Calculations return -1; } + + /** + * Get the number of gems required to purchase an upgrade from the upgrade level + * + * @param upgradeLevel The upgrade level (1-5) + * @return The integer value of the number of gems required to purchase an upgrade + */ + public static int getGemsCost(int upgradeLevel) + { + return GEMS_FOR_UPGRADE.get(getLevelRequiredFor(upgradeLevel)); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java index 12dbee6b4..07b4e54e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java @@ -88,6 +88,15 @@ public class ProjectileManager extends MiniPlugin sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult)); } + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, double charge) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, charge)); + } + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult) @@ -133,14 +142,14 @@ public class ProjectileManager extends MiniPlugin } public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, - long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, - Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) { _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, - expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, - sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); + expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); } - + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult, List canHit) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 31aee43b1..16213685f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -62,6 +62,8 @@ public class ProjectileUser private UpdateType _effectRate = UpdateType.TICK; private double _hitboxGrow; + + private double _charge; private List _canHit; @@ -104,6 +106,47 @@ public class ProjectileUser _canHit = null; } + public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup, + Sound sound, float soundVolume, float soundPitch, + Effect effect, int effectData, UpdateType effectRate, + ParticleType particle, float particleX, float particleY, + float particleZ, float particleS, int particleC, double hitboxMult, double charge) + { + Throw = throwInput; + + _thrown = thrown; + _thrower = thrower; + _callback = callback; + + _expireTime = expireTime; + _startTime = System.currentTimeMillis(); + + _hitPlayer = hitPlayer; + _hitNonPlayerEntity = hitNonPlayerEntity; + _hitBlock = hitBlock; + _idle = idle; + _pickup = pickup; + + _sound = sound; + _soundVolume = soundVolume; + _soundPitch = soundPitch; + _particle = particle; + _particleX = particleX; + _particleY = particleY; + _particleZ = particleZ; + _particleS = particleS; + _particleC = particleC; + _effect = effect; + _effectData = effectData; + _effectRate = effectRate; + + _hitboxGrow = hitboxMult; + _canHit = null; + + _charge = charge; + } + public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup, Sound sound, float soundVolume, float soundPitch, @@ -142,6 +185,7 @@ public class ProjectileUser _hitboxGrow = hitboxMult; _canHit = canHit; } + public void effect(UpdateEvent event) { @@ -311,6 +355,11 @@ public class ProjectileUser return false; } + + public double getCharge() + { + return _charge; + } public IThrown getIThrown() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java index 9f566aa2a..65e7affe0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java @@ -2,8 +2,13 @@ package mineplex.core.punish.Command; import java.util.Iterator; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import mineplex.core.account.CoreClient; +import mineplex.core.common.util.F; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -48,20 +53,41 @@ public class PunishCommand extends CommandBase final String finalReason = reason; //Match exact online first - Player target = UtilPlayer.searchExact(playerName); + Player target = Bukkit.getPlayerExact(playerName); + if (target != null) { - Plugin.GetRepository().LoadPunishClient(playerName, new Callback() + AtomicBoolean wasDisguised = new AtomicBoolean(false); + AtomicReference originalName = new AtomicReference<>(playerName); + AtomicReference disguisedName = new AtomicReference<>(playerName); + + CoreClient client = Plugin.GetClients().Get(target.getUniqueId()); + if (!client.getName().equals(target.getName())) { - public void run(PunishClientToken clientToken) + // Has to be the only possibility, but.... + if (client.isDisguised() && client.getDisguisedAs().equalsIgnoreCase(playerName)) { - Plugin.LoadClient(clientToken); - new PunishPage(Plugin, caller, playerName, finalReason); + originalName.set(client.getName()); + disguisedName.set(client.getDisguisedAs()); + wasDisguised.set(true); } + else + { + UtilPlayer.message(caller, F.main("Punish", "An unexpected error occured. Please contact a developer immediately")); + return; + } + } + + Plugin.GetRepository().LoadPunishClient(originalName.get(), clientToken -> + { + Plugin.LoadClient(clientToken); + new PunishPage(Plugin, caller, originalName.get(), finalReason, wasDisguised.get(), originalName.get(), disguisedName.get()); }); return; } + + String finalPlayerName = playerName; //Check repo Plugin.GetRepository().MatchPlayerName(new Callback>() @@ -72,7 +98,7 @@ public class PunishCommand extends CommandBase for (String match : matches) { - if (match.equalsIgnoreCase(playerName)) + if (match.equalsIgnoreCase(finalPlayerName)) { matchedExact = true; } @@ -82,7 +108,7 @@ public class PunishCommand extends CommandBase { for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) { - if (!matchIterator.next().equalsIgnoreCase(playerName)) + if (!matchIterator.next().equalsIgnoreCase(finalPlayerName)) { matchIterator.remove(); } @@ -103,12 +129,12 @@ public class PunishCommand extends CommandBase public void run(PunishClientToken clientToken) { Plugin.LoadClient(clientToken); - new PunishPage(Plugin, caller, target, finalReason); + new PunishPage(Plugin, caller, target, finalReason, false, null, null); } }); } - }, caller, playerName, true); + }, caller, finalPlayerName, true); } }, playerName); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 0ce793810..84fead023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -2,6 +2,7 @@ package mineplex.core.punish; import java.util.HashMap; +import mineplex.core.account.CoreClient; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -162,14 +163,31 @@ public class Punish extends MiniPlugin AddPunishment(playerName, category, reason, caller == null ? null : caller.getName(), severity, ban, duration, false); } - public void AddPunishment(final String playerName, final Category category, final String reason, final String callerName, final int severity, boolean ban, long duration, final boolean silent) + public void AddPunishment(String playerName, final Category category, final String reason, String callerName, final int severity, boolean ban, long duration, final boolean silent) { + Player player = Bukkit.getPlayerExact(playerName); + if (player != null) + { + CoreClient client = _clientManager.Get(player); + playerName = client.getName(); + } + + String finalPlayerName = playerName; + + Player caller = callerName == null ? null : Bukkit.getPlayerExact(callerName); + if (caller != null) + { + CoreClient client = _clientManager.Get(caller); + callerName = client.getName(); + } + + String finalCallerName = callerName; + if (!_punishClients.containsKey(playerName.toLowerCase())) { _punishClients.put(playerName.toLowerCase(), new PunishClient()); } - final Player caller = (callerName == null ? null : UtilPlayer.searchExact(callerName)); final PunishmentSentence sentence = !ban ? PunishmentSentence.Mute : PunishmentSentence.Ban; final long finalDuration = duration; @@ -183,16 +201,16 @@ public class Punish extends MiniPlugin if (banResult == PunishmentResponse.AccountDoesNotExist) { if (caller != null) - caller.sendMessage(F.main(getName(), "Account with name " + F.elem(playerName) + " does not exist.")); + caller.sendMessage(F.main(getName(), "Account with name " + F.elem(finalPlayerName) + " does not exist.")); else - System.out.println(F.main(getName(), "Account with name " + F.elem(playerName) + " does not exist.")); + System.out.println(F.main(getName(), "Account with name " + F.elem(finalPlayerName) + " does not exist.")); } else if (banResult == PunishmentResponse.InsufficientPrivileges) { if (caller != null) - caller.sendMessage(F.main(getName(), "You have insufficient rights to punish " + F.elem(playerName) + ".")); + caller.sendMessage(F.main(getName(), "You have insufficient rights to punish " + F.elem(finalPlayerName) + ".")); else - System.out.println(F.main(getName(), "You have insufficient rights to punish " + F.elem(playerName) + ".")); + System.out.println(F.main(getName(), "You have insufficient rights to punish " + F.elem(finalPlayerName) + ".")); } else if (banResult == PunishmentResponse.Punished) { @@ -201,7 +219,7 @@ public class Punish extends MiniPlugin if (sentence == PunishmentSentence.Ban) { if (caller == null) - System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " banned " + F.elem(playerName) + " because of " + F.elem(reason) + " for " + durationString + ".")); + System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " banned " + F.elem(finalPlayerName) + " because of " + F.elem(reason) + " for " + durationString + ".")); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { @@ -211,23 +229,22 @@ public class Punish extends MiniPlugin "\n" + C.cWhite + reason + "\n" + C.cDGreen + "Unfairly banned? Appeal at " + C.cGreen + "www.mineplex.com/appeals"; - Player target = UtilPlayer.searchOnline(null, playerName, false); - if (target != null) - target.kickPlayer(kickReason); + if (player != null) + player.kickPlayer(kickReason); else - new mineplex.serverdata.commands.PunishCommand(playerName, true, false, kickReason).publish(); + new mineplex.serverdata.commands.PunishCommand(finalPlayerName, true, false, kickReason).publish(); } }); if (!silent) { - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + ".")); + informOfPunish(finalPlayerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + finalPlayerName + " for " + durationString + ".")); } } else { if (caller == null) - System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(playerName) + " because of " + F.elem(reason) + " for " + + System.out.println(F.main(getName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(finalPlayerName) + " because of " + F.elem(reason) + " for " + durationString + ".")); //Warning @@ -235,28 +252,27 @@ public class Punish extends MiniPlugin { if (!silent) { - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + playerName + ".")); + informOfPunish(finalPlayerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a friendly warning to " + finalPlayerName + ".")); } } else { if (!silent) { - informOfPunish(playerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + ".")); + informOfPunish(finalPlayerName, F.main(getName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + finalPlayerName + " for " + durationString + ".")); } } //Inform - Player target = UtilPlayer.searchExact(playerName); - if (target != null) + if (player != null) { - UtilPlayer.message(target, F.main("Punish", F.elem(C.cGray + C.Bold + "Reason: ") + reason)); - target.playSound(target.getLocation(), Sound.CAT_MEOW, 1f, 1f); + UtilPlayer.message(player, F.main("Punish", F.elem(C.cGray + C.Bold + "Reason: ") + reason)); + player.playSound(player.getLocation(), Sound.CAT_MEOW, 1f, 1f); } else - new mineplex.serverdata.commands.PunishCommand(playerName, false, finalDuration != 0, F.main("Punish", F.elem(C.cGray + C.Bold + (finalDuration != 0 ? "Mute" : "Warning") + " Reason: ") + reason)).publish(); + new mineplex.serverdata.commands.PunishCommand(finalPlayerName, false, finalDuration != 0, F.main("Punish", F.elem(C.cGray + C.Bold + (finalDuration != 0 ? "Mute" : "Warning") + " Reason: ") + reason)).publish(); - _repository.LoadPunishClient(playerName, new Callback() + _repository.LoadPunishClient(finalPlayerName, new Callback() { public void run(PunishClientToken token) { @@ -268,7 +284,7 @@ public class Punish extends MiniPlugin } - }, playerName, category.toString(), sentence, reason, duration, callerName == null ? "Mineplex Anti-Cheat" : callerName, severity); + }, playerName, category.toString(), sentence, reason, duration, finalCallerName == null ? "Mineplex Anti-Cheat" : finalCallerName, severity); } private void informOfPunish(String punishee, String msg) @@ -306,7 +322,8 @@ public class Punish extends MiniPlugin public void RemovePunishment(int punishmentId, String target, final Player admin, String reason, Callback callback) { - _repository.RemovePunishment(callback, punishmentId, target, reason, admin.getName()); + CoreClient client = _clientManager.Get(admin); + _repository.RemovePunishment(callback, punishmentId, target, reason, client.getName()); } public void RemoveBan(String name, String reason) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java index d18f837a2..bdbbce7e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java @@ -7,12 +7,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import mineplex.core.Managers; import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; @@ -43,6 +46,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener private Player _player; private String _target; private String _reason; + private boolean _wasDisguised; + private String _originalName; + private String _disguisedName; private ShopItem _chatOffenseButton; private ShopItem _exploitingButton; private ShopItem _hackingButton; @@ -50,7 +56,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener private ShopItem _permMuteButton; private ShopItem _permBanButton; - public PunishPage(Punish plugin, Player player, String target, String reason) + public PunishPage(Punish plugin, Player player, String target, String reason, boolean wasDisguised, String originalName, String disguisedName) { super(null, 54, " Punish"); @@ -60,6 +66,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener _player = player; _target = target; _reason = reason; + _wasDisguised = wasDisguised; + _originalName = originalName; + _disguisedName = disguisedName; BuildPage(); @@ -247,7 +256,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener , 1, false, true), new PunishButton(this, Category.Hacking, 2, true, getDuration(Category.Hacking, 2, offenseMap))); - int flightSeverity = (AntiHack.Instance.isStrict() ? 3 : 2); + int flightSeverity = (Managers.get(AntiHack.class).isStrict() ? 3 : 2); AddButton(41, new ShopItem(Material.INK_SACK, (byte)1, "Severity 3",new String[] @@ -309,6 +318,21 @@ public class PunishPage extends CraftInventoryCustom implements Listener }); } + if (_wasDisguised) + { + ShopItem disguiseWarning = new ShopItem(Material.NETHER_STAR, "Disguise Warning", UtilText.splitLinesToArray(new String[] { + ChatColor.RESET + "The player you are attempting to punish is disguised.", + ChatColor.RESET + "Original Name: " + ChatColor.GREEN + ChatColor.BOLD + _originalName, + ChatColor.RESET + "Disguised Name: " + ChatColor.GREEN + ChatColor.BOLD + _disguisedName, + }, LineFormat.LORE), 1, true, true); + disguiseWarning.addGlow(); + + AddButton(8, disguiseWarning, (player, clickType) -> + { + + }); + } + Collections.sort(punishments, new PunishmentSorter()); int slot = 45; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index e0dc88f93..e4f74fed4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -1,13 +1,5 @@ package mineplex.core.report; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - import com.google.gson.Gson; import com.google.gson.JsonObject; import mineplex.core.account.CoreClientManager; @@ -21,10 +13,11 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.report.command.ReportHandlerNotification; -import mineplex.core.report.command.ReportNotificationCallback; import mineplex.core.report.command.ReportNotification; +import mineplex.core.report.command.ReportNotificationCallback; import mineplex.core.report.task.ReportHandlerMessageTask; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; @@ -33,16 +26,22 @@ import mineplex.serverdata.Utility; import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.redis.RedisDataRepository; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.java.JavaPlugin; - import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.exceptions.JedisConnectionException; +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + /** * ReportManager hooks into a synchronized network-wide report system * with methods for updating/fetching/closing reports in real time. @@ -155,7 +154,7 @@ public class ReportManager public boolean canReport(Player player) { - PlayerStats playerStats = _statsManager.Get(player.getName()); + PlayerStats playerStats = _statsManager.Get(player); long abusiveReportsCount = playerStats.getStat(ReportResult.ABUSIVE.getStatName()); return abusiveReportsCount < ABUSE_BAN_THRESHOLD; } @@ -356,7 +355,7 @@ public class ReportManager public boolean hasReportNotifications(Player player) { boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.MODERATOR); - boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports; + boolean hasReportNotifications = _preferencesManager.get(player).isActive(Preference.SHOW_USER_REPORTS); return isStaff && hasReportNotifications; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index 9589502eb..f869a2d5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -61,7 +61,7 @@ public class PetReward extends UnknownPackageReward @Override public boolean canGiveReward(Player player) { - if (_donationManager.Get(player.getName()) == null) + if (_donationManager.Get(player) == null) { System.out.println("Could not give reward " + getPackageName() + " to Offline Player: " + player.getName()); return false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index 51a54d3ea..edbc18dfe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -1,14 +1,13 @@ package mineplex.core.reward.rewards; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.DonationManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * Created by shaun on 14-09-12. @@ -34,7 +33,7 @@ public class UnknownPackageReward extends Reward @Override protected RewardData giveRewardCustom(Player player, RewardType type) { - _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, CurrencyType.TREASURE_SHARD, 0, true); + _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, GlobalCurrency.TREASURE_SHARD, 0, true); return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _name, _itemStack, getRarity()); } @@ -42,13 +41,13 @@ public class UnknownPackageReward extends Reward @Override public boolean canGiveReward(Player player) { - if (_donationManager.Get(player.getName()) == null) + if (_donationManager.Get(player) == null) { System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName()); return false; } - return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); + return !_donationManager.Get(player).OwnsUnknownPackage(_packageName); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java new file mode 100644 index 000000000..d0324884d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java @@ -0,0 +1,260 @@ +package mineplex.core.scoreboard; + +import org.apache.commons.lang3.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + *

+ * This is a Mineplex Scoreboard, featuring new and improved Anti Flicker™ technology
+ *
+ * To use, you must first define some {@link ScoreboardLine}s. Each ScoreboardLine must
+ *   be unique and implement {@link java.lang.Object#equals} and {@link java.lang.Object#hashCode}.
+ *   ScoreboardLines are only considered equal if both {@link java.lang.Object#equals} and {@link java.lang.Object#hashCode} are equal
+ *
+ * Once you've defined your ScoreboardLines, simply register them using {@link #register}. If you wish to remove a line, simply use {@link #unregister}
+ *
+ * Once you have finished registering and unregistering your lines, call {@link #recalculate} to push all the line changes to the actual scoreboard.
+ *   Please note that you must call {@link #recalculate} before doing any writing
+ *
+ * Once the line changes have been pushed, you can begin writing. First, get the {@link ScoreboardElement} by calling {@link #get} with your ScoreboardLine
+ *   Then, with the ScoreboardElement, call {@link ScoreboardElement#write} with a string of length up to 72 characters, including color codes
+ *
+ * Please note that some restrictions apply. If you have two line that are the same when substringed 16-56, then only one can be added
+ *   Most of the time the implementation will deal with collisions, but if it is unable to an {@link IllegalArgumentException} will be raised
+ * 
+ */ +public class MineplexScoreboard +{ + // The list of legal trackers (we use color codes followed by a reset to hide them) + private static final char[] CHARS = "1234567890abcdefklmnor".toCharArray(); + + // The owner + private final Player _owner; + + // The underlying scoreboard + private final Scoreboard _scoreboard; + + // The sidebar + private final Objective _sidebar; + + // The list of available trackers, implemented as a queue + private final LinkedList _availableTrackers = new LinkedList<>(); + + // The list of registered lines, which have been calculated, in the order of registration + // The ScoreboardLine at index 0 is the one at the top of the scoreboard + private final List _calculated = new ArrayList<>(); + // The map of registered lines to their writable elements + private final Map _calculatedMap = new HashMap<>(); + + // The list of buffered lines + private final List _buffered = new ArrayList<>(); + + /** + * Creates a MineplexScoreboard with no owner + */ + public MineplexScoreboard() + { + this(null); + } + + /** + * Creates a MineplexScoreboard with the given owner + */ + public MineplexScoreboard(Player owner) + { + this._owner = owner; + this._scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + + this._sidebar = _scoreboard.registerNewObjective("sidebar", "sidebar"); + this._sidebar.setDisplaySlot(DisplaySlot.SIDEBAR); + + for (char c : CHARS) + { + _availableTrackers.add(String.valueOf(ChatColor.COLOR_CHAR) + String.valueOf(c) + ChatColor.RESET.toString()); + } + } + + /** + * Registers the given {@link ScoreboardLine}, placing it at the bottom of the scoreboard, so to speak + * + * @param line The ScoreboardLine to register + * @returns The same instance, to allow chaining + */ + public MineplexScoreboard register(ScoreboardLine line) + { + this._buffered.add(line); + return this; + } + + /** + * Registers the given {@link ScoreboardLine} {@code line}, but only after the ScoreboardLine {@code after} + * + * @param line The ScoreboardLine to register + * @param after The ScoreboardLine to register {@code line} after + * @return The same instance, to allow chaining + */ + public MineplexScoreboard registerAfter(ScoreboardLine line, ScoreboardLine after) + { + int index = _buffered.indexOf(after); + if (index == -1) + { + throw new IllegalStateException("Could not locate line: " + after); + } + _buffered.add(index, line); + return this; + } + + /** + * Unregisters the given {@link ScoreboardLine} from this scoreboard + * + * @param line The ScoreboardLine to unregister + * @return The same instance, to allow chaining + */ + public MineplexScoreboard unregister(ScoreboardLine line) + { + _buffered.remove(line); + return this; + } + + /** + * Recalculates and pushes line changes to the {@link org.bukkit.scoreboard.Scoreboard} + */ + public void recalculate() + { + // Starting fresh + if (this._calculated.size() == 0) + { + for (int i = 0; i < this._buffered.size() && !_availableTrackers.isEmpty(); i++) + { + String tracker = _availableTrackers.pop(); + ScoreboardLine line = this._buffered.get(i); + this._calculated.add(line); + this._calculatedMap.put(line, new ScoreboardElement(this, this._sidebar, line, tracker, this._buffered.size() - i)); + } + } + // Otherwise compute deltas + else + { + // Delete all removed lines + for (ScoreboardLine calculated : this._calculated) + { + if (!this._buffered.contains(calculated)) + { + ScoreboardElement element = get(calculated); + element.delete(); + } + } + + Map prevCalculatedMap = new HashMap<>(_calculatedMap); + + _calculated.clear(); + _calculatedMap.clear(); + + for (int i = 0; i < this._buffered.size(); i++) + { + ScoreboardLine line = this._buffered.get(i); + ScoreboardElement element = prevCalculatedMap.get(line); + int expectedScore = this._buffered.size() - i; + + // existing + if (element != null) + { + Score score = this._sidebar.getScore(element.getTracker()); + if (score.getScore() != expectedScore) + { + score.setScore(expectedScore); + element.setLineNumber(expectedScore); + } + + this._calculated.add(line); + this._calculatedMap.put(line, element); + } + // new + else + { + String tracker = _availableTrackers.pop(); + this._calculated.add(line); + this._calculatedMap.put(line, new ScoreboardElement(this, this._sidebar, line, tracker, expectedScore)); + } + } + } + + this._buffered.clear(); + this._buffered.addAll(this._calculated); + } + + /** + * Determines whether a {@link ScoreboardLine} is currently registered or not + * + * @param line The ScoreboardLine to check + * @return True if {@code line} is registered, and false if not + */ + public boolean isRegistered(ScoreboardLine line) + { + return _calculatedMap.containsKey(line); + } + + /** + * Gets the {@link ScoreboardElement} associated with the {@link ScoreboardLine} + * + * @param line The registered ScoreboardLine + * + * @return The ScoreboardElement, which can be written to + */ + public ScoreboardElement get(ScoreboardLine line) + { + return this._calculatedMap.get(line); + } + + /** + * Gets the owner of this scoreboard + * + * @return The owner, or null if no owner was provided + */ + public Player getOwner() + { + return this._owner; + } + + /** + * Sets the sidebar, or objective, name. This will be not be buffered, but updated instantly + * + * @param sidebarName The new String to be written to the sidebar + */ + public void setSidebarName(String sidebarName) + { + if (!StringUtils.equals(this._sidebar.getName(), sidebarName)) + { + this._sidebar.setDisplayName(sidebarName); + } + } + + /** + * Gets the underlying {@link org.bukkit.scoreboard.Scoreboard} instance, because you're a hacky person + * + * @return The Scoreboard that you want to screw around with + */ + public Scoreboard getHandle() + { + return this._scoreboard; + } + + void returnTracker(String tracker) + { + this._availableTrackers.add(tracker); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java new file mode 100644 index 000000000..e86b873d8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardElement.java @@ -0,0 +1,242 @@ +package mineplex.core.scoreboard; + +import org.apache.commons.lang3.StringUtils; +import org.bukkit.ChatColor; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Team; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +// fixme bulk send prefix/suffix packets? +public class ScoreboardElement +{ + private static final Set CUSTOM_TRACKER_TRACKER = new HashSet<>(); + + private static final AtomicInteger COUNTER = new AtomicInteger(); + + private MineplexScoreboard _scoreboard; + private Objective _sidebar; + + private ScoreboardLine _line; + + private Team _team; + + private String _tracker; + + private String _customTracker; + + private String _oldValue; + + private int _lineNumber; + + public ScoreboardElement(MineplexScoreboard scoreboard, Objective sidebar, ScoreboardLine line, String tracker, int lineNumber) + { + this._scoreboard = scoreboard; + this._sidebar = sidebar; + this._line = line; + this._tracker = tracker; + this._team = scoreboard.getHandle().registerNewTeam("SBE" + String.valueOf(COUNTER.getAndIncrement())); + this._team.addEntry(this._tracker); + this._lineNumber = lineNumber; + this._sidebar.getScore(_tracker).setScore(this._lineNumber); + } + + public void write(int value) + { + write(String.valueOf(value)); + } + + public void write(String value) + { + if (value.equals(this._oldValue)) return; + + this._oldValue = value; + + if (value.length() <= 16) + { + if (!StringUtils.equals(this._team.getPrefix(), value)) + _team.setPrefix(value); + if (!StringUtils.equals(this._team.getSuffix(), "")) + _team.setSuffix(""); + + clearCustomTracker(); + } + else + { + String left = value.substring(0, 16); + String right = value.substring(16); + String ending = ChatColor.getLastColors(left); + right = ending + right; + if (right.length() <= 16) + { + if (!StringUtils.equals(this._team.getPrefix(), left)) + _team.setPrefix(left); + if (!StringUtils.equals(this._team.getSuffix(), right)) + _team.setSuffix(right); + + clearCustomTracker(); + } + else + { + right = value.substring(16); + + // ensure unique custom trackers + if (right.length() <= 40) + { + if (_customTracker == null || !_customTracker.equals(right)) + { + if (!CUSTOM_TRACKER_TRACKER.add(right)) + { + String resets = ChatColor.RESET.toString(); + while (!CUSTOM_TRACKER_TRACKER.add(resets + ending + right)) + { + resets += ChatColor.RESET.toString(); + } + + right = resets + ending + right; + } + } + } + + if (right.length() <= 40) + { + if (this._customTracker == null) + { + this._customTracker = right; + + this._scoreboard.getHandle().resetScores(this._tracker); + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + } + else if (!right.equals(this._customTracker)) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + this._team.removeEntry(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + + this._customTracker = right; + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + } + + if (!StringUtils.equals(this._team.getPrefix(), left)) + this._team.setPrefix(left); + if (!StringUtils.equals(this._team.getSuffix(), "")) + this._team.setSuffix(""); + } + else + { + CUSTOM_TRACKER_TRACKER.remove(right); + + String middle = right.substring(0, 40); + right = right.substring(40); + + if (_customTracker == null || !_customTracker.equals(middle)) + { + if (!CUSTOM_TRACKER_TRACKER.add(middle)) + { + String resets = ChatColor.RESET.toString(); + while (!CUSTOM_TRACKER_TRACKER.add(resets + ending + middle)) + { + resets += ChatColor.RESET.toString(); + } + + middle = resets + ending + middle; + + if (middle.length() > 40) + { + right = right + middle.substring(40); + middle = middle.substring(0, 40); + } + } + } + + if (right.length() <= 16) + { + if (this._customTracker == null) + { + this._customTracker = middle; + + this._scoreboard.getHandle().resetScores(this._tracker); + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + + } + else if (!middle.equals(this._customTracker)) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + this._team.removeEntry(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + + this._customTracker = middle; + + this._team.addEntry(this._customTracker); + this._sidebar.getScore(this._customTracker).setScore(this._lineNumber); + } + + if (!StringUtils.equals(this._team.getPrefix(), left)) + this._team.setPrefix(left); + if (!StringUtils.equals(this._team.getSuffix(), right)) + this._team.setSuffix(right); + } + else + { + throw new IllegalArgumentException("The following scoreboard line is too damn long: " + value); + } + } + } + } + } + + protected Team getHandle() + { + return this._team; + } + + protected String getTracker() + { + if (this._customTracker != null) + return this._customTracker; + return _tracker; + } + + public void setLineNumber(int lineNumber) + { + this._lineNumber = lineNumber; + this._sidebar.getScore(getTracker()).setScore(this._lineNumber); + } + + public void delete() + { + this._team.unregister(); + this._scoreboard.getHandle().resetScores(this._tracker); + if (this._customTracker != null) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + } + this._scoreboard.returnTracker(this._tracker); + this._team = null; + this._scoreboard = null; + this._tracker = null; + } + + private void clearCustomTracker() + { + if (this._customTracker != null) + { + this._scoreboard.getHandle().resetScores(this._customTracker); + this._team.removeEntry(this._customTracker); + CUSTOM_TRACKER_TRACKER.remove(this._customTracker); + this._customTracker = null; + + this._team.addEntry(this._tracker); + this._sidebar.getScore(this._tracker).setScore(this._lineNumber); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java new file mode 100644 index 000000000..6e9db2e69 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardLine.java @@ -0,0 +1,5 @@ +package mineplex.core.scoreboard; + +public interface ScoreboardLine +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java index ca76fa1e8..18b64a420 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardManager.java @@ -1,180 +1,99 @@ package mineplex.core.scoreboard; -import java.util.HashMap; -import java.util.Iterator; - -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.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.incognito.IncognitoManager; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scoreboard.Team; -public class ScoreboardManager extends MiniPlugin -{ - private CoreClientManager _clientManager; - private DonationManager _donationManager; - private IncognitoManager _incognito; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; - //This stores current scoreboard for the player - private HashMap _playerScoreboards = new HashMap(); +public abstract class ScoreboardManager extends MiniPlugin +{ + private final Map _scoreboards = new HashMap<>(); - //Scoreboards (can be shared between players) - private HashMap _scoreboards = new HashMap(); + private int _scoreboardTick = 0; - //Title - private String _title = " MINEPLEX "; - private int _shineIndex; - private boolean _shineDirection = true; - - public ScoreboardManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognito) + public ScoreboardManager(JavaPlugin plugin) { super("Scoreboard Manager", plugin); - - _clientManager = clientManager; - _donationManager = donationManager; - _incognito = incognito; } - public CoreClientManager getClients() + @EventHandler (priority = EventPriority.LOW) + public void onJoin(PlayerJoinEvent event) { - return _clientManager; + MineplexScoreboard scoreboard = new MineplexScoreboard(event.getPlayer()); + + this._scoreboards.put(event.getPlayer().getUniqueId(), scoreboard); + + setup(scoreboard); + draw(scoreboard); + + event.getPlayer().setScoreboard(scoreboard.getHandle()); + + handlePlayerJoin(event.getPlayer()); } - public DonationManager getDonation() + @EventHandler (priority = EventPriority.HIGHEST) + public void onQuit(PlayerQuitEvent event) { - return _donationManager; + this._scoreboards.remove(event.getPlayer().getUniqueId()); + handlePlayerQuit(event.getPlayer()); } - public String getTitle() + public MineplexScoreboard get(Player player) { - return _title; - } - - public void setTitle(String title) - { - _title = title; - _shineIndex = 0; - } - - protected PlayerScoreboard createScoreboard(Player player) - { - return new PlayerScoreboard(this, player); + return _scoreboards.get(player.getUniqueId()); } @EventHandler - public void playerJoin(PlayerJoinEvent event) + public void UpdateScoreboard(UpdateEvent event) { - PlayerScoreboard scoreboard = createScoreboard(event.getPlayer()); - scoreboard.assignScoreboard(event.getPlayer()); - _playerScoreboards.put(event.getPlayer(), scoreboard); - } - - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _playerScoreboards.remove(event.getPlayer()); - } - - public void draw() - { - Iterator playerIterator = _playerScoreboards.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - //Offline - if (!player.isOnline()) - { - playerIterator.remove(); - continue; - } - - _playerScoreboards.get(player).draw(this, player); - } - } - - public PlayerScoreboard getCurrentScoreboard(Player player) - { - return _playerScoreboards.get(player); - } - - public ScoreboardData getData(String scoreboardName, boolean create) - { - if (!create) - return _scoreboards.get(scoreboardName); - - if (!_scoreboards.containsKey(scoreboardName)) - _scoreboards.put(scoreboardName, new ScoreboardData()); - - return _scoreboards.get(scoreboardName); - } - - @EventHandler - public void updateTitle(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) + if (event.getType() != UpdateType.TICK) return; - - String out; - if (_shineDirection) - { - out = C.cGold + C.Bold; - } - else - { - out = C.cWhite + C.Bold; - } + _scoreboardTick = (_scoreboardTick + 1) % 3; - for (int i = 0; i < _title.length(); i++) - { - char c = _title.charAt(i); + if (_scoreboardTick != 0) + return; - if (_shineDirection) - { - if (i == _shineIndex) - out += C.cYellow + C.Bold; - - if (i == _shineIndex + 1) - out += C.cWhite + C.Bold; - } - else - { - if (i == _shineIndex) - out += C.cYellow + C.Bold; - - if (i == _shineIndex + 1) - out += C.cGold + C.Bold; - } - - out += c; - } - - for (PlayerScoreboard ps : _playerScoreboards.values()) - { - ps.setTitle(out); - } - - _shineIndex++; - - if (_shineIndex == _title.length() * 2) - { - _shineIndex = 0; - _shineDirection = !_shineDirection; - } + _scoreboards.values().forEach(this::draw); } - public IncognitoManager getIncognitoManager() + public void handlePlayerJoin(Player player) { - return _incognito; + handlePlayerJoin(player.getName()); + } + + /* + * Used in DisguisePlayer! + */ + public abstract void handlePlayerJoin(String player); + + public void handlePlayerQuit(Player player) + { + handlePlayerQuit(player.getName()); + } + + public abstract void handlePlayerQuit(String player); + + public abstract void setup(MineplexScoreboard scoreboard); + + public abstract void draw(MineplexScoreboard scoreboard); + + public Map getScoreboards() + { + return Collections.unmodifiableMap(this._scoreboards); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java new file mode 100644 index 000000000..dfd1b4267 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/WritableMineplexScoreboard.java @@ -0,0 +1,144 @@ +package mineplex.core.scoreboard; + +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + *
+ * The WritableMineplexScoreboard is a version of the MineplexScoreboard which does not require you to
+ * register your own lines, but instead allows you to write to it as if it were a canvas.
+ *
+ * As soon as the class is created, it is ready to be written to
+ *
+ * The general process of using this class is something like the following:
+ *
+ * * Call {@link #write} up to 15 times for each line in the scoreboard
+ * * When ready, call {@link #draw} to draw the lines onto the scoreboard
+ * * Upon drawing, the buffer of lines will be cleared. This allows you to use {@link #write} again, starting from scratch
+ *
+ * This class is optimized to minimize updates when possible, so it is alright to redraw the same line
+ *   over and over; they will not be sent to the player
+ * 
+ */ +public class WritableMineplexScoreboard extends MineplexScoreboard +{ + // The constant list of 15 lines which will be used + private final List _lines; + + // The list of lines currently buffered for drawing + private final List _bufferedLines = new ArrayList<>(15); + + // The list of lines which were drawn in the last draw + private final List _drawnLines = new ArrayList<>(15); + + /** + * Creates a new WritableMineplexScoreboard with no owner + */ + public WritableMineplexScoreboard() + { + this(null); + } + + /** + * Creates a new WritableMineplexScoreboard with the specified owner + * + * @param owner The owner of this scoreboard + */ + public WritableMineplexScoreboard(Player owner) + { + super(owner); + + List lines = new ArrayList<>(); + for (int i = 0; i < 15; i++) + { + lines.add(new WritableScoreboardLine()); + } + _lines = Collections.unmodifiableList(lines); + } + + /** + * Appends the given line to the buffer. This will not update the scoreboard + * + * @param line The line to buffer + */ + public void write(String line) + { + _bufferedLines.add(line); + } + + /** + * Appends a blank line to the buffer + */ + public void writeNewLine() + { + write(""); + } + + /** + * Draws the currently buffered lines to the actual scoreboard, then flushes the buffers to allow rewriting + */ + public void draw() + { + if (_bufferedLines.size() > 15) + { + throw new IllegalStateException("Too many lines! (" + _bufferedLines.size() + " > 15)"); + } + + if (_bufferedLines.size() > _drawnLines.size()) + { + for (int i = _drawnLines.size(); i < _bufferedLines.size(); i++) + { + super.register(_lines.get(i)); + } + } + else if (_bufferedLines.size() < _drawnLines.size()) + { + for (int i = _bufferedLines.size(); i < _drawnLines.size(); i++) + { + super.unregister(_lines.get(i)); + } + } + + recalculate(); + + for (int i = 0; i < _bufferedLines.size(); i++) + { + get(_lines.get(i)).write(_bufferedLines.get(i)); + } + + this._drawnLines.clear(); + this._drawnLines.addAll(this._bufferedLines); + this._bufferedLines.clear(); + } + + /** + * Resets the currently buffered lines + */ + public void reset() + { + this._bufferedLines.clear(); + } + + @Override + public MineplexScoreboard register(ScoreboardLine line) + { + throw new IllegalArgumentException("You cannot register lines with a WritableMineplexScoreboard!"); + } + + @Override + public MineplexScoreboard unregister(ScoreboardLine line) + { + throw new IllegalArgumentException("You cannot unregister lines with a WritableMineplexScoreboard!"); + } + + /** + * Simply an implementation of ScoreboardLine. More may be added later for metadata purposes + */ + private class WritableScoreboardLine implements ScoreboardLine + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java deleted file mode 100644 index 5f97e8798..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java +++ /dev/null @@ -1,20 +0,0 @@ -package mineplex.core.scoreboard.elements; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.scoreboard.ScoreboardManager; - -public class ScoreboardElementGoldCount implements ScoreboardElement -{ - @Override - public List getLines(ScoreboardManager manager, Player player, List out) - { - List output = new ArrayList(); - output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + ""); - return output; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index f57097c2d..576e37ffd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -56,7 +56,7 @@ public class ServerConfiguration extends MiniPlugin @EventHandler public void onPlayerLogin(PlayerLoginEvent event) { - if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) event.disallow(Result.KICK_OTHER, "This is a staff only server."); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index 31a6065c9..a20567c0b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -1,12 +1,13 @@ package mineplex.core.shop; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.donation.DonationManager; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; +import mineplex.core.shop.page.ShopPageBase; import net.minecraft.server.v1_8_R3.EntityPlayer; - import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory; @@ -22,22 +23,13 @@ import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.DonationManager; -import mineplex.core.npc.event.NpcDamageByEntityEvent; -import mineplex.core.npc.event.NpcInteractEntityEvent; -import mineplex.core.shop.page.ShopPageBase; +import java.util.HashSet; public abstract class ShopBase implements Listener { private NautHashMap _errorThrottling; private NautHashMap _purchaseBlock; - private List _availableCurrencyTypes = new ArrayList(); - private PluginType _plugin; private CoreClientManager _clientManager; private DonationManager _donationManager; @@ -46,7 +38,7 @@ public abstract class ShopBase implements Listene private HashSet _openedShop = new HashSet(); - public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes) + public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name) { _plugin = plugin; _clientManager = clientManager; @@ -56,18 +48,10 @@ public abstract class ShopBase implements Listene _playerPageMap = new NautHashMap>>(); _errorThrottling = new NautHashMap(); _purchaseBlock = new NautHashMap(); - - if (currencyTypes != null && currencyTypes.length > 0) - _availableCurrencyTypes.addAll(Arrays.asList(currencyTypes)); - + _plugin.registerEvents(this); } - public List getAvailableCurrencyTypes() - { - return _availableCurrencyTypes; - } - @EventHandler(priority = EventPriority.LOWEST) public void onPlayerDamageEntity(NpcDamageByEntityEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java index 5bcdcfb82..67a43b2e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java @@ -31,11 +31,21 @@ public class ConfirmationPage returnPage, ConfirmationProcessor processor, ItemStack displayItem) + public ConfirmationPage(Player player, ShopPageBase returnPage, ConfirmationProcessor processor, ItemStack displayItem) + { + super(returnPage.getPlugin(), returnPage.getShop(), returnPage.getClientManager(), returnPage.getDonationManager(), "Confirmation", player); + + _returnPage = returnPage; + _displayItem = displayItem; + _processor = processor; + + buildPage(); + } + + public ConfirmationPage(Player player, PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, ConfirmationProcessor processor, ItemStack displayItem) { super(plugin, shop, clientManager, donationManager, "Confirmation", player); - _returnPage = returnPage; _displayItem = displayItem; _processor = processor; @@ -49,6 +59,8 @@ public class ConfirmationPage CurrencyCostMap; + protected NautHashMap CurrencyCostMap; protected boolean KnownPackage = true; protected boolean OneTimePurchaseOnly = true; @@ -41,7 +41,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins, int quantity) { - CurrencyCostMap = new NautHashMap(); + CurrencyCostMap = new NautHashMap<>(); Name = name; DisplayName = name; @@ -49,12 +49,10 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack _displayMaterial = material; _displayData = displayData; - CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, coins); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, coins); Quantity = quantity; } - public abstract void sold(Player player, CurrencyType currencyType); - @Override public String getName() { @@ -68,7 +66,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack } @Override - public int getCost(CurrencyType currencyType) + public int getCost(GlobalCurrency currencyType) { return CurrencyCostMap.containsKey(currencyType) ? CurrencyCostMap.get(currencyType) : 0; } @@ -105,7 +103,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack if (token.Gems > 0) { - CurrencyCostMap.put(CurrencyType.GEM, token.Gems); + CurrencyCostMap.put(GlobalCurrency.GEM, token.Gems); } } @@ -133,4 +131,9 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack { DisplayName = name; } + + public ItemStack buildIcon() + { + return new ItemBuilder(_displayMaterial).setData(_displayData).setTitle(DisplayName).addLore(Description).build(); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java new file mode 100644 index 000000000..8fd1e6fd2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java @@ -0,0 +1,70 @@ +package mineplex.core.shop.item; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationProcessor; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +public class SalesPackageProcessor implements ConfirmationProcessor { + private final GlobalCurrency _currencyType; + private final SalesPackageBase _salesItem; + private final DonationManager _donationManager; + private final Player _player; + private final Runnable _runAfterPurchase; + + public SalesPackageProcessor(Player player, GlobalCurrency currencyType, SalesPackageBase salesItem, DonationManager donationManager, Runnable runAfterPurchase) + { + _currencyType = currencyType; + _salesItem = salesItem; + _donationManager = donationManager; + _player = player; + _runAfterPurchase = runAfterPurchase; + } + + @Override + public void init(Inventory inventory) + { + inventory.setItem(4, new ItemBuilder(_currencyType.getDisplayMaterial()).setTitle(_currencyType.getPrefix()).addLore(C.cGray + _salesItem.getCost(_currencyType) + " " + _currencyType.getPrefix() + " will be", C.cGray + "deducted from your account balance").build()); + } + + @Override + public void process(ConfirmationCallback callback) + { + if (_salesItem.isKnown()) + { + _donationManager.PurchaseKnownSalesPackage(response -> showResults(callback, response), _player.getName(), _player.getUniqueId(), _salesItem.getCost(_currencyType), _salesItem.getSalesPackageId()); + } + else + { + _donationManager.PurchaseUnknownSalesPackage(response -> showResults(callback, response), _player.getName(), _donationManager.getClientManager().Get(_player).getAccountId(), _salesItem.getName(), _currencyType, _salesItem.getCost(_currencyType), _salesItem.oneTimePurchase()); + } + } + + private void showResults(ConfirmationCallback callback, TransactionResponse response) + { + switch (response) + { + case Failed: + callback.reject("There was an error processing your request."); + break; + case AlreadyOwns: + callback.reject("You already own this package."); + break; + case InsufficientFunds: + callback.reject("Your account has insufficient funds."); + break; + case Success: + callback.resolve("Your purchase was successful."); + + if (_runAfterPurchase != null) + _runAfterPurchase.run(); + + break; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java deleted file mode 100644 index 75102a07b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ /dev/null @@ -1,328 +0,0 @@ -package mineplex.core.shop.page; - -import mineplex.core.MiniPlugin; -import mineplex.core.donation.DonationManager; -import mineplex.core.server.util.TransactionResponse; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.SalesPackageBase; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; - - - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -public class ConfirmationPage> extends ShopPageBase implements Runnable -{ - private Runnable _runnable; - private ShopPageBase _returnPage; - private SalesPackageBase _salesItem; - private int _okSquareSlotStart; - private boolean _processing; - private int _progressCount; - private ShopItem _progressItem; - private int _taskId; - - public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Runnable runnable, ShopPageBase returnPage, SalesPackageBase salesItem, CurrencyType currencyType, Player player) - { - super(plugin, shop, clientManager, donationManager, " Confirmation", player); - - _runnable = runnable; - _returnPage = returnPage; - _salesItem = salesItem; - setCurrencyType(currencyType); - _progressItem = new ShopItem(Material.LAPIS_BLOCK, (byte)11, ChatColor.BLUE + "Processing", null, 1, false, true); - _okSquareSlotStart = 27; - - if (getShop().canPlayerAttemptPurchase(player)) - { - buildPage(); - } - else - { - buildErrorPage(new String[]{ChatColor.RED + "You have attempted too many invalid transactions.", ChatColor.RED + "Please wait 10 seconds before retrying."}); - _taskId = plugin.getScheduler().scheduleSyncRepeatingTask(plugin.getPlugin(), this, 2L, 2L); - } - } - - protected void buildPage() - { - this.getInventory().setItem(22, new ShopItem(_salesItem.getDisplayMaterial(), (byte)0, _salesItem.getDisplayName(), _salesItem.getDescription(), 1, false, true).getHandle()); - - IButton okClicked = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - okClicked(player); - } - }; - - IButton cancelClicked = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - cancelClicked(player); - } - }; - - buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), okClicked); - buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), cancelClicked); - - this.getInventory().setItem(4, new ShopItem(getCurrencyType().getDisplayMaterial(), (byte)0, getCurrencyType().getPrefix(), new String[] { C.cGray + _salesItem.getCost(getCurrencyType()) + " " + getCurrencyType().getPrefix() + " will be", C.cGray + "deducted from your account balance." }, 1, false, true).getHandle()); - } - - protected void okClicked(Player player) - { - processTransaction(); - } - - protected void cancelClicked(Player player) - { - getPlugin().getScheduler().cancelTask(_taskId); - - if (_returnPage != null) - getShop().openPageForPlayer(player, _returnPage); - else - { - player.closeInventory(); - } - - } - - private void buildSquareAt(int slot, ShopItem item, IButton button) - { - addButton(slot, item, button); - addButton(slot + 1, item, button); - addButton(slot + 2, item, button); - - slot += 9; - - addButton(slot, item, button); - addButton(slot + 1, item, button); - addButton(slot + 2, item, button); - - slot += 9; - - addButton(slot, item, button); - addButton(slot + 1, item, button); - addButton(slot + 2, item, button); - } - - private void processTransaction() - { - for (int i=_okSquareSlotStart; i < 54; i++) - { - getButtonMap().remove(i); - clear(i); - } - - _processing = true; - - if (getCurrencyType() == CurrencyType.GOLD) - { - int goldCount = getDonationManager().Get(getPlayer()).getGold(); - int cost = _salesItem.getCost(getCurrencyType()); - - if (cost > goldCount) - showResultsPage(TransactionResponse.InsufficientFunds); - else - { - getDonationManager().rewardGold(new Callback() - { - @Override - public void run(Boolean data) - { - if (data) - { - showResultsPage(TransactionResponse.Success); - getPlayer().playSound(getPlayer().getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - else - { - showResultsPage(TransactionResponse.Failed); - } - } - }, "Energy Purchase", getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), -cost); - - } - - } - else - { - if (_salesItem.isKnown()) - { - getDonationManager().PurchaseKnownSalesPackage(new Callback() - { - public void run(TransactionResponse response) - { - showResultsPage(response); - } - }, getPlayer().getName(), getPlayer().getUniqueId(), _salesItem.getCost(getCurrencyType()), _salesItem.getSalesPackageId()); - } - else - { - getDonationManager().PurchaseUnknownSalesPackage(new Callback() - { - public void run(TransactionResponse response) - { - showResultsPage(response); - } - }, getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), _salesItem.getName(), getCurrencyType(), _salesItem.getCost(getCurrencyType()), _salesItem.oneTimePurchase()); - } - } - - _taskId = getPlugin().getScheduler().scheduleSyncRepeatingTask(getPlugin().getPlugin(), this, 2L, 2L); - } - - private void showResultsPage(TransactionResponse response) - { - _processing = false; - - switch (response) - { - case Failed: - buildErrorPage(ChatColor.RED + "There was an error processing your request."); - getShop().addPlayerProcessError(getPlayer()); - break; - case AlreadyOwns: - buildErrorPage(ChatColor.RED + "You already own this package."); - getShop().addPlayerProcessError(getPlayer()); - break; - case InsufficientFunds: - buildErrorPage(ChatColor.RED + "Your account has insufficient funds."); - getShop().addPlayerProcessError(getPlayer()); - break; - case Success: - _salesItem.sold(getPlayer(), getCurrencyType()); - - buildSuccessPage("Your purchase was successful."); - - if (_runnable != null) - _runnable.run(); - - break; - default: - break; - } - - _progressCount = 0; - } - - private void buildErrorPage(String... message) - { - IButton returnButton = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - cancelClicked(player); - } - }; - - ShopItem item = new ShopItem(Material.REDSTONE_BLOCK, (byte)0, ChatColor.RED + "" + ChatColor.UNDERLINE + "ERROR", message, 1, false, true); - for (int i = 0; i < this.getSize(); i++) - { - addButton(i, item, returnButton); - } - - getPlayer().playSound(getPlayer().getLocation(), Sound.BLAZE_DEATH, 1, .1f); - } - - private void buildSuccessPage(String message) - { - IButton returnButton = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - cancelClicked(player); - } - }; - - ShopItem item = new ShopItem(Material.EMERALD_BLOCK, (byte)0, ChatColor.GREEN + message, null, 1, false, true); - for (int i = 0; i < this.getSize(); i++) - { - addButton(i, item, returnButton); - } - - getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, .9f); - } - - @Override - public void playerClosed() - { - super.playerClosed(); - - Bukkit.getScheduler().cancelTask(_taskId); - - if (_returnPage != null && getShop() != null) - getShop().setCurrentPageForPlayer(getPlayer(), _returnPage); - } - - @Override - public void run() - { - if (_processing) - { - if (_progressCount == 9) - { - for (int i=45; i < 54; i++) - { - clear(i); - } - - _progressCount = 0; - } - - setItem(45 + _progressCount, _progressItem); - } - else - { - if (_progressCount >= 20) - { - try - { - Bukkit.getScheduler().cancelTask(_taskId); - - if (_returnPage != null && getShop() != null) - { - getShop().openPageForPlayer(getPlayer(), _returnPage); - } - else if (getPlayer() != null) - { - getPlayer().closeInventory(); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - dispose(); - } - } - } - - _progressCount++; - } - - @Override - public void dispose() - { - super.dispose(); - - Bukkit.getScheduler().cancelTask(_taskId); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index e68b0c594..ec53f2357 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -1,5 +1,13 @@ package mineplex.core.shop.page; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilInv; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.item.IButton; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom; @@ -11,16 +19,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilInv; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.item.IButton; - public abstract class ShopPageBase> extends CraftInventoryCustom implements Listener { protected PluginType _plugin; @@ -29,7 +27,6 @@ public abstract class ShopPageBase _buttonMap; protected boolean _showCurrency = false; @@ -52,27 +49,6 @@ public abstract class ShopPageBase(); _client = _clientManager.Get(player); - - if (shop.getAvailableCurrencyTypes().size() > 0) - { - _currencyType = shop.getAvailableCurrencyTypes().get(0); - } - } - - protected void changeCurrency(Player player) - { - playAcceptSound(player); - - int currentIndex = _shop.getAvailableCurrencyTypes().indexOf(_currencyType); - - if (currentIndex + 1 < _shop.getAvailableCurrencyTypes().size()) - { - _currencyType = _shop.getAvailableCurrencyTypes().get(currentIndex + 1); - } - else - { - _currencyType = _shop.getAvailableCurrencyTypes().get(0); - } } protected abstract void buildPage(); @@ -237,16 +213,6 @@ public abstract class ShopPageBase getButtonMap() { return _buttonMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 52d19ec1e..6d6094c31 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -3,6 +3,7 @@ package mineplex.core.stats; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -300,14 +301,9 @@ public class StatsManager extends MiniDbClientPlugin { return _stats.get(statName); } - - public void replacePlayerHack(String playerName, PlayerStats playerStats) - { - Set(playerName, playerStats); - } - + @Override - protected PlayerStats addPlayer(String player) + protected PlayerStats addPlayer(UUID uuid) { return new PlayerStats(); } @@ -326,9 +322,9 @@ public class StatsManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java index d7815f41b..688a8aaa8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -40,17 +40,12 @@ public class GiveStatCommand extends CommandBase if (player == null) { - Plugin.getClientManager().loadClientByName(args[0], new Runnable() + Plugin.getClientManager().loadClientByName(args[0], client -> { - public void run() - { - final CoreClient client = Plugin.getClientManager().Get(args[0]); - - if (client != null) - Plugin.incrementStat(client.getAccountId(), statName, Long.parseLong(args[args.length - 1])); - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + args[0] + "'s account!")); - } + if (client != null) + Plugin.incrementStat(client.getAccountId(), statName, Long.parseLong(args[args.length - 1])); + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + args[0] + "'s account!")); }); } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java index a8075985a..a5784bd2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -68,23 +68,17 @@ public class MasterBuilderUnban extends CommandBase caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); return; } - Plugin.getClientManager().loadClientByName(target, new Runnable() + Plugin.getClientManager().loadClientByName(target, theClient -> { - @Override - public void run() + if(theClient != null) { - CoreClient theClient = Plugin.getClientManager().Get(target); - - if(theClient != null) - { - Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat - caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); - } - else - { - caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); - return; - } + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); + return; } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index ef09c15cb..a5dc99212 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -49,7 +49,7 @@ public class TaskManager extends MiniDbClientPlugin } @Override - protected TaskClient addPlayer(String playerName) + protected TaskClient addPlayer(UUID uuid) { return new TaskClient(); } @@ -100,7 +100,7 @@ public class TaskManager extends MiniDbClientPlugin return false; } - return Get(player.getName()).TasksCompleted.contains(_tasks.get(taskName)); + return Get(player).TasksCompleted.contains(_tasks.get(taskName)); } } @@ -110,7 +110,7 @@ public class TaskManager extends MiniDbClientPlugin { if (_tasks.containsKey(taskName)) { - Get(player.getName()).TasksCompleted.add(_tasks.get(taskName)); + Get(player).TasksCompleted.add(_tasks.get(taskName)); } } @@ -126,7 +126,7 @@ public class TaskManager extends MiniDbClientPlugin { if (_tasks.containsKey(taskName)) { - Get(player.getName()).TasksCompleted.remove(_tasks.get(taskName)); + Get(player).TasksCompleted.remove(_tasks.get(taskName)); } } } @@ -140,9 +140,9 @@ public class TaskManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - Set(playerName, _repository.loadClientInformation(resultSet)); + Set(uuid, _repository.loadClientInformation(resultSet)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index db766014d..0b7ba2cfa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -1,18 +1,7 @@ package mineplex.core.teleport; -import java.util.LinkedList; -import java.util.UUID; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.teleport.command.LocateCommand; -import mineplex.core.teleport.command.TeleportCommand; -import mineplex.core.teleport.event.MineplexTeleportEvent; -import mineplex.core.teleport.redis.RedisLocate; -import mineplex.core.teleport.redis.RedisLocateCallback; -import mineplex.core.teleport.redis.RedisLocateHandler; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; @@ -20,40 +9,77 @@ import mineplex.core.common.jsonchat.HoverEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; +import mineplex.core.teleport.command.LocateCommand; +import mineplex.core.teleport.command.TeleportCommand; +import mineplex.core.teleport.event.MineplexTeleportEvent; +import mineplex.core.teleport.redis.RedisLocate; +import mineplex.core.teleport.redis.RedisLocateCallback; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.ServerCommandManager; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.UUID; public class Teleport extends MiniPlugin { - private LinkedList teleportList = new LinkedList(); - private NautHashMap> _tpHistory = new NautHashMap>(); - private NautHashMap _failedRedisLocates = new NautHashMap(); + private Map _failedRedisLocates = new HashMap<>(); + + private LinkedList teleportList = new LinkedList<>(); + private Map> _tpHistory = new HashMap<>(); private String _serverName; private CoreClientManager _clientManager; public Teleport(JavaPlugin plugin, CoreClientManager clientManager) { super("Teleport", plugin); - + _serverName = getPlugin().getConfig().getString("serverstatus.name"); _clientManager = clientManager; - RedisLocateHandler locateHandler = new RedisLocateHandler(this); + ServerCommandManager.getInstance().registerCommandType("RedisLocate", RedisLocate.class, command -> + { + Player target = Bukkit.getPlayerExact(command.getTarget()); + if (target != null) + { + RedisLocateCallback callback = new RedisLocateCallback(command, _serverName, target.getName()); + callback.publish(); + } + }); + ServerCommandManager.getInstance().registerCommandType("RedisLocateCallback", RedisLocateCallback.class, callback -> + { + Integer taskId = _failedRedisLocates.remove(callback.getUUID()); + if (taskId != null) + { + getScheduler().cancelTask(taskId); + } - ServerCommandManager.getInstance().registerCommandType("RedisLocate", RedisLocate.class, locateHandler); - ServerCommandManager.getInstance().registerCommandType("RedisLocateCallback", RedisLocateCallback.class, locateHandler); + Player player = Bukkit.getPlayer(callback.getReceivingPlayerId()); + + if (player != null) + { + ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Locate" + "> " + C.mBody + "Located [" + C.mElem + + callback.getLocatedPlayer() + C.mBody + "] at "); + + message.add(C.cBlue + callback.getServer()).click(ClickEvent.RUN_COMMAND, + "/server " + callback.getServer()); + + message.hover(HoverEvent.SHOW_TEXT, "Teleport to " + callback.getServer()); + + message.sendToPlayer(player); + } + }); } @Override @@ -62,75 +88,41 @@ public class Teleport extends MiniPlugin addCommand(new TeleportCommand(this)); addCommand(new LocateCommand(this)); } - - public void handleLocateCallback(RedisLocateCallback callback) - { - BukkitRunnable runnable = _failedRedisLocates.remove(callback.getUUID()); - - if (runnable != null) - { - runnable.cancel(); - } - - Player player = Bukkit.getPlayerExact(callback.getReceivingPlayer()); - - if (player != null) - { - ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Locate" + "> " + C.mBody + "Located [" + C.mElem - + callback.getLocatedPlayer() + C.mBody + "] at "); - - message.add(C.cBlue + callback.getServer()).click(ClickEvent.RUN_COMMAND, - "/server " + callback.getServer()); - - message.hover(HoverEvent.SHOW_TEXT, "Teleport to " + callback.getServer()); - message.sendToPlayer(player); - } - } - public void locatePlayer(final Player player, final String target) { Player targetPlayer = Bukkit.getPlayerExact(target); - + if (targetPlayer != null) { UtilPlayer.message(player, F.main("Locate", C.mBody + " [" + C.mElem + target + C.mBody + "] is in the same server!")); return; } - - RedisLocate locate = new RedisLocate(_serverName, player.getName(), target); - final UUID uuid = locate.getUUID(); - - BukkitRunnable runnable = new BukkitRunnable() - { - @Override - public void run() - { - _failedRedisLocates.remove(uuid); - UtilPlayer.message(player, F.main("Locate", C.mBody + "Failed to locate [" + C.mElem + target + C.mBody + "].")); - } - - }; - - _failedRedisLocates.put(uuid, runnable); - runnable.runTaskLater(_plugin, 40); - + RedisLocate locate = new RedisLocate(_serverName, player.getName(), player.getUniqueId(), _clientManager.Get(player).GetRank().name(), target); locate.publish(); + + int id = getScheduler().runTaskLater(_plugin, () -> + { + _failedRedisLocates.remove(locate.getUUID()); + UtilPlayer.message(player, F.main("Locate", C.mBody + "Failed to locate [" + C.mElem + target + C.mBody + "].")); + }, 40L).getTaskId(); + + _failedRedisLocates.put(locate.getUUID(), id); } @EventHandler - public void UnloadHistory(ClientUnloadEvent event) + public void unloadHistory(ClientUnloadEvent event) { _tpHistory.remove(event.GetName()); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - + return; + if (teleportList.isEmpty()) return; @@ -145,7 +137,7 @@ public class Teleport extends MiniPlugin if (from.equals("%ALL%")) for (Player cur : UtilServer.getPlayers()) listA.add(cur); - //Normal + //Normal else listA = UtilPlayer.matchOnline(caller, from, true); @@ -171,7 +163,7 @@ public class Teleport extends MiniPlugin { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to themself."); mB = F.main("Teleport", "You teleported " + F.elem(pA.getName()) + " to yourself."); - } + } else { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + F.elem(pB.getName()) + "."); @@ -199,7 +191,7 @@ public class Teleport extends MiniPlugin { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to themself."); mB = F.main("Teleport", "You teleported " + F.elem(listA.size() + " Players") + " to yourself."); - } + } else { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + F.elem(pB.getName()) + "."); @@ -207,22 +199,22 @@ public class Teleport extends MiniPlugin } //Register - if (first) - Add(pA, pB.getLocation(), mA, true, caller, mB, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); - + if (first) + Add(pA, pB.getLocation(), mA, true, caller, mB, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); + else Add(pA, pB.getLocation(), mA, true, caller, null, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); - + first = false; } } - public void playerToLoc(Player caller, String target, String sX, String sY, String sZ) + public void playerToLoc(Player caller, String target, String sX, String sY, String sZ) { playerToLoc(caller, target, caller.getWorld().getName(), sX, sY, sZ); } - - public void playerToLoc(Player caller, String target, String world, String sX, String sY, String sZ) + + public void playerToLoc(Player caller, String target, String world, String sX, String sY, String sZ) { Player player = UtilPlayer.searchOnline(caller, target, true); @@ -250,8 +242,9 @@ public class Teleport extends MiniPlugin //Inform String mA = null; - if (caller == player) mA = F.main("Teleport", "You teleported to " + UtilWorld.locToStrClean(loc) + "."); - else mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + UtilWorld.locToStrClean(loc) + "."); + if (caller == player) mA = F.main("Teleport", "You teleported to " + UtilWorld.locToStrClean(loc) + "."); + else + mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + UtilWorld.locToStrClean(loc) + "."); //Register Add(player, loc, mA, true, caller, null, player.getName() + " teleported to " + UtilWorld.locToStrClean(loc) + " via " + caller.getName()); @@ -267,33 +260,35 @@ public class Teleport extends MiniPlugin { teleportList.addLast(new Teleporter(this, pA, pB, mA, mB, loc, record, log)); } - + public void TP(Player player, Location getLocation) { TP(player, getLocation, true); } - - public void TP(Player player, Location loc, boolean dettach) + + public void TP(Player player, Location loc, boolean dettach) { //Event MineplexTeleportEvent event = new MineplexTeleportEvent(player, loc); UtilServer.getServer().getPluginManager().callEvent(event); - + if (event.isCancelled()) return; - + + _tpHistory.computeIfAbsent(player.getName(), key -> new LinkedList<>()).addFirst(player.getLocation()); + if (dettach) { player.eject(); player.leaveVehicle(); } - + player.setFallDistance(0); UtilAction.zeroVelocity(player); - + player.teleport(loc); } - + public LinkedList GetTPHistory(Player player) { return _tpHistory.get(player.getName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java index 8cacaac53..d630a78ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java @@ -7,13 +7,19 @@ import mineplex.serverdata.commands.ServerCommand; public class RedisLocate extends ServerCommand { private String _sender; + private UUID _senderUUID; + private String _senderRank; private String _sendingServer; + private String _target; + private UUID _uuid = UUID.randomUUID(); - public RedisLocate(String sendingServer, String sender, String target) + public RedisLocate(String sendingServer, String sender, UUID senderUUID, String senderRank, String target) { _sender = sender; + _senderUUID = senderUUID; + _senderRank = senderRank; _target = target; _sendingServer = sendingServer; } @@ -37,4 +43,9 @@ public class RedisLocate extends ServerCommand { return _uuid; } + + public UUID getSenderId() + { + return _senderUUID; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java index 1c18f27f8..d841a188a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java @@ -9,12 +9,15 @@ public class RedisLocateCallback extends ServerCommand private String _locatedPlayer; private String _server; private String _receivingPlayer; + private UUID _receivingPlayerUUID; + private UUID _uuid; public RedisLocateCallback(RedisLocate command, String server, String targetName) { _uuid = command.getUUID(); _receivingPlayer = command.getSender(); + _receivingPlayerUUID = command.getSenderId(); _locatedPlayer = targetName; _server = server; @@ -36,6 +39,11 @@ public class RedisLocateCallback extends ServerCommand return _receivingPlayer; } + public UUID getReceivingPlayerId() + { + return _receivingPlayerUUID; + } + public UUID getUUID() { return _uuid; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java deleted file mode 100644 index 82694bda2..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package mineplex.core.teleport.redis; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import mineplex.core.teleport.Teleport; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -public class RedisLocateHandler implements CommandCallback -{ - private Teleport _plugin; - private String _serverName; - - public RedisLocateHandler(Teleport plugin) - { - _plugin = plugin; - _serverName = _plugin.getPlugin().getConfig().getString("serverstatus.name"); - } - - @Override - public void run(ServerCommand command) - { - if (command instanceof RedisLocate) - { - RedisLocate locate = (RedisLocate) command; - - Player target = Bukkit.getPlayerExact(locate.getTarget()); - - if (target != null) - { - RedisLocateCallback callback = new RedisLocateCallback(locate, _serverName, target.getName()); - callback.publish(); - } - } - else if (command instanceof RedisLocateCallback) - { - _plugin.handleLocateCallback((RedisLocateCallback) command); - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java new file mode 100644 index 000000000..c57c977da --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ClaimThankResult.java @@ -0,0 +1,26 @@ +package mineplex.core.thank; + +/** + * @author Shaun Bennett + */ +public class ClaimThankResult +{ + private final int _claimed; + private final int _uniqueThanks; + + public ClaimThankResult(int claimed, int uniqueThanks) + { + _claimed = claimed; + _uniqueThanks = uniqueThanks; + } + + public int getClaimed() + { + return _claimed; + } + + public int getUniqueThanks() + { + return _uniqueThanks; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java new file mode 100644 index 000000000..2a25ead78 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankData.java @@ -0,0 +1,24 @@ +package mineplex.core.thank; + +/** + * @author Shaun Bennett + */ +public class ThankData +{ + private int _thankToClaim; + + public ThankData(int thankToClaim) + { + _thankToClaim = thankToClaim; + } + + public int getThankToClaim() + { + return _thankToClaim; + } + + public void setThankToClaim(int thankToClaim) + { + _thankToClaim = thankToClaim; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java new file mode 100644 index 000000000..e671e93ea --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -0,0 +1,195 @@ +package mineplex.core.thank; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.thank.command.ThankCommand; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +/** + * This class handles /thank and amplifier thanks, along with allowing players to claim the rewards they earn + */ +public class ThankManager extends MiniDbClientPlugin +{ + public static final int DEFAULT_RECEIVER_REWARD = 5; + public static final int DEFAULT_SENDER_REWARD = 5; + + private DonationManager _donationManager; + + private ThankRepository _thankRepository; + + public ThankManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super("Thanks", plugin, clientManager); + + _donationManager = donationManager; + + _thankRepository = new ThankRepository(plugin); + } + + @Override + public void addCommands() + { + addCommand(new ThankCommand(this)); + } + + /** + * Attempt to thank a player. This can be used to distribute rewards to players, give players rewards for using + * amplifiers, and allow players to thank anyone inside a game. + * + * @param receiver The player who is being thanked + * @param sender The player thanking receiver + * @param receiverReward The Treasure Shard reward for the receiver + * @param senderReward The Treasure Shard reward for the sender + * @param reason The reason that player is being thanked + * @param ignoreCooldown Should we ignore all thank cooldowns + * @param callback Callback for processing the result + */ + public void thankPlayer(Player receiver, Player sender, int receiverReward, int senderReward, String reason, boolean ignoreCooldown, Callback callback) + { + if (!Recharge.Instance.use(sender, "Thank Player", 1000 * 5, false, false)) + { + UtilPlayer.message(sender, F.main("Thank", "Please wait before trying that again")); + callback.run(ThankResult.COOLDOWN_RECHARGE); + return; + } + + int senderAccountId = ClientManager.getAccountId(sender); + int receiverAccountId = ClientManager.getAccountId(receiver); + thankPlayer(receiver.getName(), receiverAccountId, sender.getName(), senderAccountId, receiverReward, senderReward, reason, ignoreCooldown, result -> + { + if (result == ThankResult.SUCCESS) + { + // Reload their thank data if the player is online! + runAsync(() -> { + try + { + Set(receiver, _thankRepository.getThankData(receiverAccountId)); + } catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + callback.run(result); + }); + } + + /** + * Called when a player wants to "claim" all pending rewards that they haven't claimed yet + * + * @param player The player claiming their thank rewards + * @param callback Callback with the result of the claim + */ + public void claimThanks(Player player, Callback callback) + { + int accountId = ClientManager.getAccountId(player); + + if (accountId == -1) + { + callback.run(null); + return; + } + + runAsync(() -> { + try + { + ClaimThankResult result = _thankRepository.claimThank(accountId); + runSync(() -> { + if (result != null && result.getClaimed() > 0) Set(player, new ThankData(0)); + callback.run(result); + }); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + runSync(() -> callback.run(null)); + } + }); + } + + /** + * Attempt to thank a player. This can be used to distribute rewards to players, give players rewards for using + * amplifiers, and allow players to thank anyone inside a game. + * + * @param receiverName Name of the player being thanked + * @param receiverAccountId Account id of the player being thanked + * @param senderName Name of the player sending the thanks + * @param senderAccountId Account id of the player sending the thanks + * @param receiverReward The Treasure Shard reward for the receiver + * @param senderReward The Treasure Shard reward for the sender + * @param reason The reason that player is being thanked + * @param ignoreCooldown Should we ignore all thank cooldowns + * @param callback Callback for processing the result + */ + public void thankPlayer(String receiverName, int receiverAccountId, String senderName, int senderAccountId, int receiverReward, int senderReward, String reason, boolean ignoreCooldown, Callback callback) + { + // Break out on bad account id + if (senderAccountId == -1 || receiverAccountId == -1) + { + callback.run(ThankResult.INVALID_ACCOUNT_ID); + return; + } + + // You can't thank yourself, silly! + if (receiverAccountId == senderAccountId) + { + callback.run(ThankResult.CANNOT_THANK_SELF); + return; + } + + runAsync(() -> { + try + { + boolean success = _thankRepository.thank(receiverAccountId, senderAccountId, receiverReward, reason, ignoreCooldown); + + runSync(() -> { + if (success) + { + _donationManager.rewardCoinsUntilSuccess(null, "Thank", receiverName, receiverAccountId, receiverReward); + _donationManager.rewardCoinsUntilSuccess(null, "Thank", senderName, senderAccountId, senderReward); + } + + callback.run(success ? ThankResult.SUCCESS : ThankResult.COOLDOWN_DATABASE); + }); + } + catch (RuntimeException ex) + { + ex.printStackTrace(); + runSync(() -> callback.run(ThankResult.DATABASE_ERROR)); + } + }); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT SUM(thankAmount) FROM accountThankTransactions WHERE receiverId = " + accountId + " AND claimed = FALSE;"; + } + + @Override + public void processLoginResultSet(String playerName, UUID playerUUID, int accountId, ResultSet resultSet) throws SQLException + { + if (resultSet.next()) + { + int thankToClaim = resultSet.getInt(1); + Set(playerUUID, new ThankData(thankToClaim)); + } + } + + @Override + protected ThankData addPlayer(UUID player) + { + return new ThankData(0); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java new file mode 100644 index 000000000..d426009fa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankRepository.java @@ -0,0 +1,75 @@ +package mineplex.core.thank; + +import mineplex.core.database.MinecraftRepository; +import mineplex.database.routines.AddThank; +import mineplex.database.routines.ClaimThank; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.plugin.java.JavaPlugin; +import org.jooq.Configuration; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ThankRepository extends MinecraftRepository +{ + private static final String GET_THANK_DATA = "SELECT SUM(thankAmount) FROM accountThankTransactions WHERE receiverId = ? AND claimed = FALSE"; + + public ThankRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + } + + @Override + protected void initialize() + { + } + + @Override + protected void update() + { + + } + + public boolean thank(int receiverAccountId, int senderAccountId, int thankAmount, String reason, boolean ignoreCooldown) + { + AddThank addThank = new AddThank(); + addThank.setInReceiverAccountId(receiverAccountId); + addThank.setInSenderAccountId(senderAccountId); + addThank.setInThankAmount(thankAmount); + addThank.setInReason(reason); + addThank.setInIgnoreCooldown(ignoreCooldown ? (byte) 1 : 0); + + addThank.execute(jooq().configuration()); + return addThank.getSuccess() == 1; + } + + public ClaimThankResult claimThank(int accountId) + { + ClaimThank claimThank = new ClaimThank(); + claimThank.setInAccountId(accountId); + claimThank.execute(jooq().configuration()); + return new ClaimThankResult(claimThank.getAmountClaimed(), claimThank.getUniqueThank()); + } + + /** + * Get ThankData for an accountId. This is used to reload ThankData when a player is thanked on live servers + * @param accountId The account id of the player + * @return {@link ThankData} for that player + */ + public ThankData getThankData(int accountId) throws SQLException + { + ThankData thankData = new ThankData(0); + + executeQuery(GET_THANK_DATA, resultSet -> + { + if (resultSet != null && resultSet.next()) + { + thankData.setThankToClaim(resultSet.getInt(1)); + } + }, new ColumnInt("receiverId", accountId)); + + return thankData; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java new file mode 100644 index 000000000..8b0c8e6c3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankResult.java @@ -0,0 +1,14 @@ +package mineplex.core.thank; + +/** + * @author Shaun Bennett + */ +public enum ThankResult +{ + COOLDOWN_RECHARGE, + COOLDOWN_DATABASE, + SUCCESS, + INVALID_ACCOUNT_ID, + DATABASE_ERROR, + CANNOT_THANK_SELF +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java new file mode 100644 index 000000000..ac26750e1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java @@ -0,0 +1,74 @@ +package mineplex.core.thank.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.thank.ThankManager; +import mineplex.core.thank.ThankResult; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +/** + * @author Shaun Bennett + */ +public class ThankCommand extends CommandBase +{ + public ThankCommand(ThankManager plugin) + { + super(plugin, Rank.ALL, "thank"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length != 1) + { + UtilPlayer.message(caller, F.main("Thank", "Usage: " + F.elem("/thank "))); + return; + } + + String playerName = args[0]; + Player player = UtilPlayer.searchOnline(caller, playerName, true); + if (player != null) + { + Plugin.thankPlayer(player, caller, ThankManager.DEFAULT_RECEIVER_REWARD, ThankManager.DEFAULT_SENDER_REWARD, + "ThankCommand", false, result -> + { + String message; + + switch (result) + { + case SUCCESS: + message = "You thanked " + F.name(player.getName()) + " and earned " + F.currency(GlobalCurrency.TREASURE_SHARD, ThankManager.DEFAULT_SENDER_REWARD) + "!"; + break; + case CANNOT_THANK_SELF: + message = "You cannot thank yourself!"; + break; + case COOLDOWN_DATABASE: + message = "You can only /thank once per day!"; + break; + case COOLDOWN_RECHARGE: + message = null; + break; + default: + message = "An error occurred. Try again later"; + } + + if (message != null) + { + UtilPlayer.message(caller, F.main("Thank", message)); + } + + if (result == ThankResult.SUCCESS && player.isOnline()) + { + UtilPlayer.message(player, F.main("Thank", F.name(caller.getName()) + " used " + F.elem("/thank") + " on you! +" + F.currency(GlobalCurrency.TREASURE_SHARD, ThankManager.DEFAULT_RECEIVER_REWARD) + "!")); + UtilPlayer.message(player, F.main("Thank", "You can claim your reward at " + F.name("Carl the Creeper"))); + player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1f, 1.2f); + } + }); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java similarity index 82% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java index 6a63bf257..7655e3bc4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java @@ -1,4 +1,4 @@ -package mineplex.core.scoreboard; +package mineplex.core.thereallyoldscoreboardapiweshouldremove; import java.util.ArrayList; @@ -96,36 +96,39 @@ public class PlayerScoreboard for (int i=0 ; i i) + if ((15-i) >= 0) { - String oldLine = _currentLines.get(i); + //Get New Line + String newLine = lines.get(i); - if (oldLine.equals(newLine)) + //Check if Unchanged + if (_currentLines.size() > i) + { + String oldLine = _currentLines.get(i); + + if (oldLine.equals(newLine)) + continue; + } + + // Ignore extra lines + if (i >= _teamNames.length) continue; + + //Update + Team team = _scoreboard.getTeam(_teamNames[i]); + if (team == null) + { + System.out.println("Scoreboard Error: Line Team Not Found!"); + return; + } + + //Set Line Prefix/Suffix + team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); + team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); + + //Line + _sideObjective.getScore(_teamNames[i]).setScore(15-i); } - - // Ignore extra lines - if (i >= _teamNames.length) - continue; - - //Update - Team team = _scoreboard.getTeam(_teamNames[i]); - if (team == null) - { - System.out.println("Scoreboard Error: Line Team Not Found!"); - return; - } - - //Set Line Prefix/Suffix - team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); - team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); - - //Line - _sideObjective.getScore(_teamNames[i]).setScore(15-i); } //Hide Old Unused @@ -133,7 +136,10 @@ public class PlayerScoreboard { for (int i=lines.size() ; i<_currentLines.size() ; i++) { - _scoreboard.resetScores(_teamNames[i]); + if (i < _teamNames.length) + { + _scoreboard.resetScores(_teamNames[i]); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardData.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardData.java index 1881d7357..3353e7309 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardData.java @@ -1,8 +1,8 @@ -package mineplex.core.scoreboard; +package mineplex.core.thereallyoldscoreboardapiweshouldremove; import java.util.ArrayList; -import mineplex.core.scoreboard.elements.*; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.*; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -96,11 +96,6 @@ public class ScoreboardData _elements.add(new ScoreboardElementText(" ")); } - public void writePlayerGold() - { - _elements.add(new ScoreboardElementGoldCount()); - } - public void writePlayerGems() { _elements.add(new ScoreboardElementGemCount()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java new file mode 100644 index 000000000..418399855 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/ScoreboardManager.java @@ -0,0 +1,180 @@ +package mineplex.core.thereallyoldscoreboardapiweshouldremove; + +import java.util.HashMap; +import java.util.Iterator; + +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.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ScoreboardManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private IncognitoManager _incognito; + + //This stores current scoreboard for the player + private HashMap _playerScoreboards = new HashMap(); + + //Scoreboards (can be shared between players) + private HashMap _scoreboards = new HashMap(); + + //Title + private String _title = " MINEPLEX "; + private int _shineIndex; + private boolean _shineDirection = true; + + public ScoreboardManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognito) + { + super("Scoreboard Manager", plugin); + + _clientManager = clientManager; + _donationManager = donationManager; + _incognito = incognito; + } + + public CoreClientManager getClients() + { + return _clientManager; + } + + public DonationManager getDonation() + { + return _donationManager; + } + + public String getTitle() + { + return _title; + } + + public void setTitle(String title) + { + _title = title; + _shineIndex = 0; + } + + protected PlayerScoreboard createScoreboard(Player player) + { + return new PlayerScoreboard(this, player); + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + PlayerScoreboard scoreboard = createScoreboard(event.getPlayer()); + scoreboard.assignScoreboard(event.getPlayer()); + _playerScoreboards.put(event.getPlayer(), scoreboard); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerScoreboards.remove(event.getPlayer()); + } + + public void draw() + { + Iterator playerIterator = _playerScoreboards.keySet().iterator(); + + while (playerIterator.hasNext()) + { + Player player = playerIterator.next(); + + //Offline + if (!player.isOnline()) + { + playerIterator.remove(); + continue; + } + + _playerScoreboards.get(player).draw(this, player); + } + } + + public PlayerScoreboard getCurrentScoreboard(Player player) + { + return _playerScoreboards.get(player); + } + + public ScoreboardData getData(String scoreboardName, boolean create) + { + if (!create) + return _scoreboards.get(scoreboardName); + + if (!_scoreboards.containsKey(scoreboardName)) + _scoreboards.put(scoreboardName, new ScoreboardData()); + + return _scoreboards.get(scoreboardName); + } + + @EventHandler + public void updateTitle(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + String out; + + if (_shineDirection) + { + out = C.cGold + C.Bold; + } + else + { + out = C.cWhite + C.Bold; + } + + for (int i = 0; i < _title.length(); i++) + { + char c = _title.charAt(i); + + if (_shineDirection) + { + if (i == _shineIndex) + out += C.cYellow + C.Bold; + + if (i == _shineIndex + 1) + out += C.cWhite + C.Bold; + } + else + { + if (i == _shineIndex) + out += C.cYellow + C.Bold; + + if (i == _shineIndex + 1) + out += C.cGold + C.Bold; + } + + out += c; + } + + for (PlayerScoreboard ps : _playerScoreboards.values()) + { + ps.setTitle(out); + } + + _shineIndex++; + + if (_shineIndex == _title.length() * 2) + { + _shineIndex = 0; + _shineDirection = !_shineDirection; + } + } + + public IncognitoManager getIncognitoManager() + { + return _incognito; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElement.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElement.java similarity index 55% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElement.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElement.java index cdb8a2e9b..b5dfee821 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElement.java @@ -1,10 +1,10 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.List; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public interface ScoreboardElement { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementCoinCount.java similarity index 52% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementCoinCount.java index a11dd46fc..63e200a01 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementCoinCount.java @@ -1,20 +1,19 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.scoreboard.ScoreboardManager; - public class ScoreboardElementCoinCount implements ScoreboardElement { @Override public List getLines(ScoreboardManager manager, Player player, List out) { List output = new ArrayList(); - output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.TREASURE_SHARD) + ""); + output.add(manager.getDonation().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) + ""); return output; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementGemCount.java similarity index 53% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementGemCount.java index c4566a6c3..31a013ed0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementGemCount.java @@ -1,20 +1,19 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.scoreboard.ScoreboardManager; - public class ScoreboardElementGemCount implements ScoreboardElement { @Override public List getLines(ScoreboardManager manager, Player player, List out) { List output = new ArrayList(); - output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.GEM) + ""); + output.add(manager.getDonation().Get(player).getBalance(GlobalCurrency.GEM) + ""); return output; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementRank.java similarity index 50% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementRank.java index 93af0af7e..17f4629bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementRank.java @@ -1,4 +1,4 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.ArrayList; import java.util.List; @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.entity.Player; import mineplex.core.common.Rank; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public class ScoreboardElementRank implements ScoreboardElement { @@ -19,11 +19,11 @@ public class ScoreboardElementRank implements ScoreboardElement { output.add(manager.getClients().Get(player).GetRank().Name); } - else if (manager.getDonation().Get(player.getName()).OwnsUnknownPackage("SuperSmashMobs ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("Survival Games ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("Minigames ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("CastleSiege ULTRA") || - manager.getDonation().Get(player.getName()).OwnsUnknownPackage("Champions ULTRA")) + else if (manager.getDonation().Get(player).OwnsUnknownPackage("SuperSmashMobs ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("Survival Games ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("Minigames ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("CastleSiege ULTRA") || + manager.getDonation().Get(player).OwnsUnknownPackage("Champions ULTRA")) { output.add("Single Ultra"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementScores.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementScores.java similarity index 89% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementScores.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementScores.java index 73ced3d5b..cce770b87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementScores.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementScores.java @@ -1,4 +1,4 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.ArrayList; import java.util.HashMap; @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public class ScoreboardElementScores implements ScoreboardElement { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementText.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementText.java similarity index 75% rename from Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementText.java rename to Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementText.java index b17be47ce..f9d4d99e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementText.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/elements/ScoreboardElementText.java @@ -1,11 +1,11 @@ -package mineplex.core.scoreboard.elements; +package mineplex.core.thereallyoldscoreboardapiweshouldremove.elements; import java.util.ArrayList; import java.util.List; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; public class ScoreboardElementText implements ScoreboardElement { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java index 4166c6a36..26b9cc491 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java @@ -44,9 +44,9 @@ public class TournamentManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uid, int accountId, ResultSet resultSet) throws SQLException { - ClientTournamentData clientData = Get(playerName); + ClientTournamentData clientData = Get(uid); while (resultSet.next()) { @@ -80,7 +80,7 @@ public class TournamentManager extends MiniDbClientPlugin } @Override - protected ClientTournamentData addPlayer(String player) + protected ClientTournamentData addPlayer(UUID uuid) { return new ClientTournamentData(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java index 07db4d582..1967124d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java @@ -1,20 +1,18 @@ package mineplex.core.tournament.ui; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import mineplex.core.tournament.TournamentManager; import mineplex.core.tournament.ui.page.MainMenu; +import org.bukkit.entity.Player; public class TournamentShop extends ShopBase { public TournamentShop(TournamentManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Tournaments", CurrencyType.GEM); + super(plugin, clientManager, donationManager, "Tournaments"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java index 8ab2aa019..bd4162932 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java @@ -1,10 +1,7 @@ package mineplex.core.treasure; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.shop.item.SalesPackageBase; +import org.bukkit.Material; public class ChestPackage extends SalesPackageBase { @@ -15,10 +12,4 @@ public class ChestPackage extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java index 06ecab631..30ef863f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java @@ -1,11 +1,8 @@ package mineplex.core.treasure; +import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.shop.item.SalesPackageBase; /** * Created by shaun on 14-09-18. @@ -19,10 +16,4 @@ public class TreasureKey extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index a2cc71f46..7c6f86666 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -1,9 +1,28 @@ package mineplex.core.treasure; -import java.util.List; - +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.reward.RewardPool; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramInteraction; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.treasure.gui.TreasureShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -21,28 +40,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramInteraction; -import mineplex.core.hologram.HologramManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.reward.Reward; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.treasure.gui.TreasureShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.util.List; public class TreasureLocation implements Listener { @@ -69,8 +67,7 @@ public class TreasureLocation implements Listener _hologramManager = hologramManager; _statusManager = statusManager; _currentTreasure = null; - _hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold - + "Open Treasure"); + _hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 1.5, 0.5), C.cGreen + C.Bold + "Open Treasure"); _hologram.setInteraction(new HologramInteraction() { @@ -401,4 +398,18 @@ public class TreasureLocation implements Listener { _shop.attemptShopOpen(player); } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + builder.append("TesureLoc: ").append(_chestBlock.getX()).append(" : ").append(_chestBlock.getY()).append(" : ").append(_chestBlock.getZ()); + builder.append("BlockLocs: ["); + for(Block block : _chestSpawns) + { + builder.append("BlockLoc: ").append(block.getX()).append(" : ").append(block.getY()).append(" : ").append(block.getZ()).append(",\n"); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 2b82b9779..3827c26e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -1,30 +1,30 @@ package mineplex.core.treasure; -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.gadget.GadgetManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - +import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardPool; -import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.ArrayList; +import java.util.List; /** * Created by Shaun on 8/27/2014. @@ -52,61 +52,33 @@ public class TreasureManager extends MiniPlugin World world = Bukkit.getWorlds().get(0); - _treasureLocations = new ArrayList(); + _treasureLocations = new ArrayList<>(); { - Block chestBlock = world.getBlockAt(-19, 72, -19); - Block chestLoc1 = world.getBlockAt(-16, 72, -20); - Block chestLoc2 = world.getBlockAt(-18, 72, -22); - Block chestLoc3 = world.getBlockAt(-20, 72, -22); - Block chestLoc4 = world.getBlockAt(-22, 72, -20); - Block chestLoc5 = world.getBlockAt(-22, 72, -18); - Block chestLoc6 = world.getBlockAt(-20, 72, -16); - Block chestLoc7 = world.getBlockAt(-18, 72, -16); - Block chestLoc8 = world.getBlockAt(-16, 72, -18); - Location resetLocation = new Location(world, -23.5, 72, -23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(-31, 73, -11); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, -26.5, 72, -11.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } { - Block chestBlock = world.getBlockAt(19, 72, 19); - Block chestLoc1 = world.getBlockAt(16, 72, 20); - Block chestLoc2 = world.getBlockAt(18, 72, 22); - Block chestLoc3 = world.getBlockAt(20, 72, 22); - Block chestLoc4 = world.getBlockAt(22, 72, 20); - Block chestLoc5 = world.getBlockAt(22, 72, 18); - Block chestLoc6 = world.getBlockAt(20, 72, 16); - Block chestLoc7 = world.getBlockAt(18, 72, 16); - Block chestLoc8 = world.getBlockAt(16, 72, 18); - Location resetLocation = new Location(world, 23.5, 72, 23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(-22, 73, -34); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, -22.5, 72, -29.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } { - Block chestBlock = world.getBlockAt(19, 72, -19); - Block chestLoc1 = world.getBlockAt(16, 72, -20); - Block chestLoc2 = world.getBlockAt(18, 72, -22); - Block chestLoc3 = world.getBlockAt(20, 72, -22); - Block chestLoc4 = world.getBlockAt(22, 72, -20); - Block chestLoc5 = world.getBlockAt(22, 72, -18); - Block chestLoc6 = world.getBlockAt(20, 72, -16); - Block chestLoc7 = world.getBlockAt(18, 72, -16); - Block chestLoc8 = world.getBlockAt(16, 72, -18); - Location resetLocation = new Location(world, 23.5, 72, -23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(22, 75, -34); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, 19.5, 74, -30.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } { - Block chestBlock = world.getBlockAt(-19, 72, 19); - Block chestLoc1 = world.getBlockAt(-16, 72, 20); - Block chestLoc2 = world.getBlockAt(-18, 72, 22); - Block chestLoc3 = world.getBlockAt(-20, 72, 22); - Block chestLoc4 = world.getBlockAt(-22, 72, 20); - Block chestLoc5 = world.getBlockAt(-22, 72, 18); - Block chestLoc6 = world.getBlockAt(-20, 72, 16); - Block chestLoc7 = world.getBlockAt(-18, 72, 16); - Block chestLoc8 = world.getBlockAt(-16, 72, 18); - Location resetLocation = new Location(world, -23.5, 72, 23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(31, 74, -11); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, 27.5, 73, -15.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } for (TreasureLocation treasureLocation : _treasureLocations) @@ -115,13 +87,34 @@ public class TreasureManager extends MiniPlugin } } + private Block[] setup(Block chestBlock) + { + List locations = Lists.newArrayList(new Location(chestBlock.getWorld(), chestBlock.getX() + 3, chestBlock.getY(), chestBlock.getZ() - 1), + new Location(chestBlock.getWorld(), chestBlock.getX() + 3, chestBlock.getY(), chestBlock.getZ() + 1), + new Location(chestBlock.getWorld(), chestBlock.getX() - 3, chestBlock.getY(), chestBlock.getZ() - 1), + new Location(chestBlock.getWorld(), chestBlock.getX() - 3, chestBlock.getY(), chestBlock.getZ() + 1), + new Location(chestBlock.getWorld(), chestBlock.getX() - 1, chestBlock.getY(), chestBlock.getZ() + 3), + new Location(chestBlock.getWorld(), chestBlock.getX() + 1, chestBlock.getY(), chestBlock.getZ() - 3), + new Location(chestBlock.getWorld(), chestBlock.getX() + 1, chestBlock.getY(), chestBlock.getZ() + 3), + new Location(chestBlock.getWorld(), chestBlock.getX() - 1, chestBlock.getY(), chestBlock.getZ() - 3)); + + Block[] blocks = new Block[locations.size()]; + for (int i = 0; i < blocks.length; i++) + { + blocks[i] = locations.get(i).getBlock(); + } + return blocks; + } + @Override public void disable() { for (TreasureLocation treasureLocation : _treasureLocations) { treasureLocation.cleanup(); + HandlerList.unregisterAll(treasureLocation); } + _treasureLocations.clear(); } public void addOpenStat(Player player, TreasureType treasureType) @@ -129,11 +122,17 @@ public class TreasureManager extends MiniPlugin _statsManager.incrementStat(player, "Global.Treasure." + treasureType.getStatName(), 1); } + public void addTreasureLocation(TreasureLocation loc) + { + _treasureLocations.add(loc); + _plugin.getServer().getPluginManager().registerEvents(loc, _plugin); + } + public Reward[] getRewards(Player player, RewardPool.Type pool, RewardType rewardType) { return _rewardManager.getRewards(player, pool, rewardType); } - + public boolean hasItemsToGivePlayer(RewardPool.Type pool, Player player) { return _rewardManager.hasItemsToGivePlayer(pool, player); @@ -146,10 +145,14 @@ public class TreasureManager extends MiniPlugin Treasure treasure = treasureLocation.getCurrentTreasure(); if (treasure == null) + { continue; + } if (treasure.getPlayer().equals(player)) + { return true; + } } return false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index f62bd83cc..4276e57ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -1,18 +1,20 @@ package mineplex.core.treasure.gui; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; +import mineplex.core.treasure.ChestPackage; import mineplex.core.treasure.TreasureType; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; -import mineplex.core.treasure.ChestPackage; - public class BuyChestButton implements IButton { private InventoryManager _inventoryManager; @@ -40,6 +42,11 @@ public class BuyChestButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Buy Treasure Chest", 1000, false, false)) + { + return; + } + if (_chestType == TreasureType.FREEDOM) { if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) @@ -59,15 +66,11 @@ public class BuyChestButton implements IButton player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); return; } - if(_inventoryManager.getClientManager().Get(player).isDisguised()) + SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost); + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () -> { - UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); - return; - } - _page.getShop().openPageForPlayer(player, new ConfirmationPage<>( - _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), () -> { - _inventoryManager.addItemToInventory(player, _chestName, 1); - _page.refresh(); - }, _page, new ChestPackage(_chestName, _chestMat, _chestCost), CurrencyType.TREASURE_SHARD, player)); + _inventoryManager.addItemToInventory(player, _chestName, 1); + _page.refresh(); + }), salesPackage.buildIcon())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java index 1914e2b8b..e280643e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java @@ -3,6 +3,7 @@ package mineplex.core.treasure.gui; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.core.treasure.TreasureLocation; import mineplex.core.treasure.TreasureType; @@ -24,6 +25,11 @@ public class OpenTreasureButton implements IButton @Override public void onClick(Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Open Treasure Chest", 1000, false, false)) + { + return; + } + _treasureLocation.attemptOpenTreasure(player, _treasureType); player.closeInventory(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index c05c9a774..e1648228c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -1,8 +1,11 @@ package mineplex.core.treasure.gui; -import java.util.ArrayList; -import java.util.List; - +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; @@ -11,24 +14,21 @@ import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.inventory.InventoryManager; import mineplex.core.mount.Mount; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.treasure.TreasureType; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.donation.DonationManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.treasure.TreasureLocation; -import mineplex.core.treasure.TreasureManager; -import mineplex.core.treasure.TreasureType; +import java.util.ArrayList; +import java.util.List; public class TreasurePage extends ShopPageBase { @@ -50,7 +50,7 @@ public class TreasurePage extends ShopPageBase @Override protected void buildPage() { - int treasureShards = getDonationManager().Get(getPlayer()).getCoins(); + int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD); int basicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OLD.getItemName()); int heroicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ANCIENT.getItemName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java new file mode 100644 index 000000000..4d48e4ccc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java @@ -0,0 +1,177 @@ +package mineplex.core.utils; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.mojang.authlib.GameProfile; +import mineplex.core.Managers; +import mineplex.core.profileCache.ProfileCacheManager; +import mineplex.core.thread.ThreadPool; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.UUID; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.regex.Pattern; + +public class UtilGameProfile +{ + private static final Cache TEXTURES = CacheBuilder.newBuilder() + .expireAfterWrite(5, TimeUnit.MINUTES) + .concurrencyLevel(4) + .build(); + + /** + * Get a {@link GameProfile} given a username. + * + * If you desperately must block the current thread, you may pass a null Consumer and use Future.get() + * + * @param username The username of the player + * @param nonNull If true, an OfflinePlayer GameProfile will be returned should the username not be valid + * @param fetched The Consumer which will receive the GameProfile instance. This Consumer will not be called on the main thread + * + * @return The GameProfile - always an unique instance + */ + public static Future getProfileByName(String username, boolean nonNull, Consumer fetched) + { + return ThreadPool.ASYNC.submit(() -> + { + // First, try to load it from the redis cache + GameProfile gameProfile = Managers.get(ProfileCacheManager.class).attemptToLoadProfile(username); + + if (gameProfile == null) + { + gameProfile = MinecraftServer.getServer().getUserCache().getProfile(username); + + // This profile is not guaranteed to be unique, and we don't want to be modifying the cache... + if (gameProfile != null) + { + gameProfile = clone(gameProfile); + } + } + + // We've found the profile + if (gameProfile != null) + { + if (!gameProfile.getProperties().containsKey("textures")) + { + // There are no textures in the GameProfile and we have not yet tried to load it + if (TEXTURES.getIfPresent(gameProfile.getId()) == null) + { + TEXTURES.put(gameProfile.getId(), true); + + // Try to fill it and cache the profile + MinecraftServer.getServer().aD().fillProfileProperties(gameProfile, true); + Managers.get(ProfileCacheManager.class).cacheProfile(gameProfile); + } + } + } + + // If a nonnull GameProfile is requested, then we'll use the default OfflinePlayer UUID format + if (gameProfile == null && nonNull) + { + gameProfile = new GameProfile(EntityPlayer.b(username), username); + } + + // Clone it one last time in case some Mojang API changes and we're left scratching our heads + // wondering why everything suddenly broke + gameProfile = clone(gameProfile); + + if (fetched != null) + { + fetched.accept(gameProfile); + } + + return gameProfile; + }); + } + + /** + * Clones a GameProfile + * + * @param input The GameProfile to clone + * + * @return A copy of the GameProfile + */ + public static GameProfile clone(GameProfile input) + { + GameProfile newProfile = new GameProfile(input.getId(), input.getName()); + newProfile.getProperties().putAll(input.getProperties()); + return newProfile; + } + + // Pattern to remove all non alphanumeric + underscore letters + private static final Pattern LEGAL_USERNAME = Pattern.compile("[^A-Za-z0-9_]"); + + /** + * Convert a string to a legal username equivalent + * + * @param in The original username + * + * @returns A legal version of the username (with illegal characters stripped out + */ + public static String legalize(String in) + { + return LEGAL_USERNAME.matcher(in).replaceAll(""); + } + + private static final Field GAME_PROFILE_NAME_FIELD; + private static final Field GAME_PROFILE_ID_FIELD; + + static + { + try + { + GAME_PROFILE_NAME_FIELD = GameProfile.class.getDeclaredField("name"); + GAME_PROFILE_NAME_FIELD.setAccessible(true); + GAME_PROFILE_ID_FIELD = GameProfile.class.getDeclaredField("id"); + GAME_PROFILE_ID_FIELD.setAccessible(true); + + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(GAME_PROFILE_NAME_FIELD, GAME_PROFILE_NAME_FIELD.getModifiers() & ~Modifier.FINAL); + modifiersField.setInt(GAME_PROFILE_ID_FIELD, GAME_PROFILE_ID_FIELD.getModifiers() & ~Modifier.FINAL); + + GameProfile testProfile = new GameProfile(UUID.randomUUID(), "Testing"); + String changedName = "TestSuccessful"; + UUID changedUUID = UUID.randomUUID(); + changeName(testProfile, changedName); + changeId(testProfile, changedUUID); + if (!testProfile.getName().equals(changedName)) + { + throw new RuntimeException("Could not change name of test GameProfile: Got " + testProfile.getName() + ", expected " + changedName); + } + if (!testProfile.getId().equals(changedUUID)) + { + throw new RuntimeException("Could not change UUID of test GameProfile: Got " + testProfile.getId() + ", expected " + changedUUID); + } + } + catch (ReflectiveOperationException ex) + { + throw new RuntimeException(ex); + } + } + + public static void changeName(GameProfile gameProfile, String changedName) throws ReflectiveOperationException + { + GAME_PROFILE_NAME_FIELD.set(gameProfile, changedName); + } + + public static void changeId(GameProfile gameProfile, UUID newUUID) throws ReflectiveOperationException + { + GAME_PROFILE_ID_FIELD.set(gameProfile, newUUID); + } + + /** + * Gets the GameProfile of a player, cloned + */ + public static GameProfile getGameProfile(Player player) + { + return clone(((CraftPlayer) player).getProfile()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java b/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java index 5683c4b20..fd68c2475 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/youtube/YoutubeManager.java @@ -14,6 +14,7 @@ import java.sql.SQLException; import java.time.LocalDate; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.UUID; public class YoutubeManager extends MiniDbClientPlugin { @@ -60,13 +61,13 @@ public class YoutubeManager extends MiniDbClientPlugin } @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { boolean hasRow = resultSet.next(); if (hasRow) - Set(playerName, new YoutubeClient(resultSet.getDate(1).toLocalDate())); + Set(uuid, new YoutubeClient(resultSet.getDate(1).toLocalDate())); else - Set(playerName, new YoutubeClient(null)); + Set(uuid, new YoutubeClient(null)); } @Override @@ -76,7 +77,7 @@ public class YoutubeManager extends MiniDbClientPlugin } @Override - protected YoutubeClient addPlayer(String player) + protected YoutubeClient addPlayer(UUID uuid) { return new YoutubeClient(null); } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Account.java b/Plugins/Mineplex.Database/src/mineplex/database/Account.java index c9e7b6499..97cffe5a9 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Account.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Account.java @@ -16,7 +16,7 @@ package mineplex.database; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Account extends org.jooq.impl.SchemaImpl implements java.io.Serializable, java.lang.Cloneable { - private static final long serialVersionUID = -1965384171; + private static final long serialVersionUID = 1890093529; /** * The reference instance of Account @@ -39,6 +39,7 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali private final java.util.List> getTables0() { return java.util.Arrays.>asList( + mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank, mineplex.database.tables.AccountAuth.accountAuth, mineplex.database.tables.AccountClan.accountClan, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions, @@ -56,11 +57,14 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.Accounts.accounts, mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountTasks.accountTasks, + mineplex.database.tables.AccountThank.accountThank, + mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountTip.accountTip, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipLogs.accountTipLogs, mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountValentinesGift.accountValentinesGift, + mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode, mineplex.database.tables.ActiveTournaments.activeTournaments, mineplex.database.tables.BattlePets.battlePets, mineplex.database.tables.Bonus.bonus, @@ -68,13 +72,16 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.BotSpam.botSpam, mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.ClanAlliances.clanAlliances, + mineplex.database.tables.ClanBanners.clanBanners, mineplex.database.tables.ClanBans.clanBans, mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanMember.clanMember, mineplex.database.tables.ClanNameBlacklist.clanNameBlacklist, mineplex.database.tables.Clans.clans, mineplex.database.tables.ClanServer.clanServer, + mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClanShopItem.clanShopItem, + mineplex.database.tables.ClansNetherPortals.clansNetherPortals, mineplex.database.tables.ClansOutposts.clansOutposts, mineplex.database.tables.ClansPvpTimer.clansPvpTimer, mineplex.database.tables.ClansSiegeWeapons.clansSiegeWeapons, @@ -95,13 +102,14 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.Items.items, mineplex.database.tables.Kitpreferences.kitpreferences, mineplex.database.tables.KitProgression.kitProgression, - mineplex.database.tables.Kit_progression.kit_progression, mineplex.database.tables.Mail.mail, mineplex.database.tables.Mailbox.mailbox, + mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage, mineplex.database.tables.Npcs.npcs, mineplex.database.tables.Packages.packages, mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.Polls.polls, + mineplex.database.tables.PowerPlayClub.powerPlayClub, mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankedBans.rankedBans, mineplex.database.tables.ReportTickets.reportTickets, @@ -121,6 +129,8 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali mineplex.database.tables.TournamentLB.TournamentLB, mineplex.database.tables.Tournaments.tournaments, mineplex.database.tables.TournamentTeams.tournamentTeams, - mineplex.database.tables.Transactions.transactions); + mineplex.database.tables.Transactions.transactions, + mineplex.database.tables.Unicodereplacer.unicodereplacer, + mineplex.database.tables.Youtube.youtube); } } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java index 84db331ea..3b8624355 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Keys.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Keys.java @@ -35,6 +35,7 @@ public class Keys { public static final org.jooq.Identity IDENTITY_accountPurchases = Identities0.IDENTITY_accountPurchases; public static final org.jooq.Identity IDENTITY_accounts = Identities0.IDENTITY_accounts; public static final org.jooq.Identity IDENTITY_accountTasks = Identities0.IDENTITY_accountTasks; + public static final org.jooq.Identity IDENTITY_accountThankTransactions = Identities0.IDENTITY_accountThankTransactions; public static final org.jooq.Identity IDENTITY_accountTipClaimLogs = Identities0.IDENTITY_accountTipClaimLogs; public static final org.jooq.Identity IDENTITY_accountTransactions = Identities0.IDENTITY_accountTransactions; public static final org.jooq.Identity IDENTITY_battlePets = Identities0.IDENTITY_battlePets; @@ -48,6 +49,7 @@ public class Keys { public static final org.jooq.Identity IDENTITY_clans = Identities0.IDENTITY_clans; public static final org.jooq.Identity IDENTITY_clanServer = Identities0.IDENTITY_clanServer; public static final org.jooq.Identity IDENTITY_clanShopItem = Identities0.IDENTITY_clanShopItem; + public static final org.jooq.Identity IDENTITY_clansNetherPortals = Identities0.IDENTITY_clansNetherPortals; public static final org.jooq.Identity IDENTITY_clanTerritory = Identities0.IDENTITY_clanTerritory; public static final org.jooq.Identity IDENTITY_clanWar = Identities0.IDENTITY_clanWar; public static final org.jooq.Identity IDENTITY_customData = Identities0.IDENTITY_customData; @@ -76,11 +78,14 @@ public class Keys { public static final org.jooq.Identity IDENTITY_tournaments = Identities0.IDENTITY_tournaments; public static final org.jooq.Identity IDENTITY_tournamentTeams = Identities0.IDENTITY_tournamentTeams; public static final org.jooq.Identity IDENTITY_transactions = Identities0.IDENTITY_transactions; + public static final org.jooq.Identity IDENTITY_unicodereplacer = Identities0.IDENTITY_unicodereplacer; + public static final org.jooq.Identity IDENTITY_youtube = Identities0.IDENTITY_youtube; // ------------------------------------------------------------------------- // UNIQUE and PRIMARY KEY definitions // ------------------------------------------------------------------------- + public static final org.jooq.UniqueKey KEY_accountAmplifierThank_PRIMARY = UniqueKeys0.KEY_accountAmplifierThank_PRIMARY; public static final org.jooq.UniqueKey KEY_accountAuth_PRIMARY = UniqueKeys0.KEY_accountAuth_PRIMARY; public static final org.jooq.UniqueKey KEY_accountClan_PRIMARY = UniqueKeys0.KEY_accountClan_PRIMARY; public static final org.jooq.UniqueKey KEY_accountCoinTransactions_PRIMARY = UniqueKeys0.KEY_accountCoinTransactions_PRIMARY; @@ -104,11 +109,14 @@ public class Keys { public static final org.jooq.UniqueKey KEY_accounts_uuidIndex = UniqueKeys0.KEY_accounts_uuidIndex; public static final org.jooq.UniqueKey KEY_accountStat_PRIMARY = UniqueKeys0.KEY_accountStat_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTasks_PRIMARY = UniqueKeys0.KEY_accountTasks_PRIMARY; + public static final org.jooq.UniqueKey KEY_accountThank_PRIMARY = UniqueKeys0.KEY_accountThank_PRIMARY; + public static final org.jooq.UniqueKey KEY_accountThankTransactions_PRIMARY = UniqueKeys0.KEY_accountThankTransactions_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTip_PRIMARY = UniqueKeys0.KEY_accountTip_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTipClaimLogs_PRIMARY = UniqueKeys0.KEY_accountTipClaimLogs_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTipLogs_PRIMARY = UniqueKeys0.KEY_accountTipLogs_PRIMARY; public static final org.jooq.UniqueKey KEY_accountTransactions_PRIMARY = UniqueKeys0.KEY_accountTransactions_PRIMARY; public static final org.jooq.UniqueKey KEY_accountValentinesGift_PRIMARY = UniqueKeys0.KEY_accountValentinesGift_PRIMARY; + public static final org.jooq.UniqueKey KEY_accountWebsiteLinkCode_PRIMARY = UniqueKeys0.KEY_accountWebsiteLinkCode_PRIMARY; public static final org.jooq.UniqueKey KEY_activeTournaments_PRIMARY = UniqueKeys0.KEY_activeTournaments_PRIMARY; public static final org.jooq.UniqueKey KEY_battlePets_PRIMARY = UniqueKeys0.KEY_battlePets_PRIMARY; public static final org.jooq.UniqueKey KEY_bonus_PRIMARY = UniqueKeys0.KEY_bonus_PRIMARY; @@ -117,6 +125,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_botSpam_unique_text = UniqueKeys0.KEY_botSpam_unique_text; public static final org.jooq.UniqueKey KEY_chatsnap_PRIMARY = UniqueKeys0.KEY_chatsnap_PRIMARY; public static final org.jooq.UniqueKey KEY_clanAlliances_PRIMARY = UniqueKeys0.KEY_clanAlliances_PRIMARY; + public static final org.jooq.UniqueKey KEY_clanBanners_PRIMARY = UniqueKeys0.KEY_clanBanners_PRIMARY; public static final org.jooq.UniqueKey KEY_clanBans_PRIMARY = UniqueKeys0.KEY_clanBans_PRIMARY; public static final org.jooq.UniqueKey KEY_clanEnemies_PRIMARY = UniqueKeys0.KEY_clanEnemies_PRIMARY; public static final org.jooq.UniqueKey KEY_clanEnemies_unique_clanId = UniqueKeys0.KEY_clanEnemies_unique_clanId; @@ -126,8 +135,10 @@ public class Keys { public static final org.jooq.UniqueKey KEY_clans_clanName = UniqueKeys0.KEY_clans_clanName; public static final org.jooq.UniqueKey KEY_clanServer_PRIMARY = UniqueKeys0.KEY_clanServer_PRIMARY; public static final org.jooq.UniqueKey KEY_clanServer_unique_serverName = UniqueKeys0.KEY_clanServer_unique_serverName; + public static final org.jooq.UniqueKey KEY_clansGold_PRIMARY = UniqueKeys0.KEY_clansGold_PRIMARY; public static final org.jooq.UniqueKey KEY_clanShopItem_PRIMARY = UniqueKeys0.KEY_clanShopItem_PRIMARY; public static final org.jooq.UniqueKey KEY_clanShopItem_shop_page_slot_UNIQUE = UniqueKeys0.KEY_clanShopItem_shop_page_slot_UNIQUE; + public static final org.jooq.UniqueKey KEY_clansNetherPortals_PRIMARY = UniqueKeys0.KEY_clansNetherPortals_PRIMARY; public static final org.jooq.UniqueKey KEY_clansOutposts_PRIMARY = UniqueKeys0.KEY_clansOutposts_PRIMARY; public static final org.jooq.UniqueKey KEY_clansPvpTimer_PRIMARY = UniqueKeys0.KEY_clansPvpTimer_PRIMARY; public static final org.jooq.UniqueKey KEY_clansSiegeWeapons_PRIMARY = UniqueKeys0.KEY_clansSiegeWeapons_PRIMARY; @@ -154,7 +165,6 @@ public class Keys { public static final org.jooq.UniqueKey KEY_items_name_UNIQUE = UniqueKeys0.KEY_items_name_UNIQUE; public static final org.jooq.UniqueKey KEY_items_uniqueNameCategoryIndex = UniqueKeys0.KEY_items_uniqueNameCategoryIndex; public static final org.jooq.UniqueKey KEY_kitProgression_PRIMARY = UniqueKeys0.KEY_kitProgression_PRIMARY; - public static final org.jooq.UniqueKey KEY_kit_progression_PRIMARY = UniqueKeys0.KEY_kit_progression_PRIMARY; public static final org.jooq.UniqueKey KEY_mail_PRIMARY = UniqueKeys0.KEY_mail_PRIMARY; public static final org.jooq.UniqueKey KEY_mailbox_PRIMARY = UniqueKeys0.KEY_mailbox_PRIMARY; public static final org.jooq.UniqueKey KEY_npcs_PRIMARY = UniqueKeys0.KEY_npcs_PRIMARY; @@ -162,6 +172,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_playerMap_PRIMARY = UniqueKeys0.KEY_playerMap_PRIMARY; public static final org.jooq.UniqueKey KEY_playerMap_playerIndex = UniqueKeys0.KEY_playerMap_playerIndex; public static final org.jooq.UniqueKey KEY_polls_PRIMARY = UniqueKeys0.KEY_polls_PRIMARY; + public static final org.jooq.UniqueKey KEY_powerPlayClub_PRIMARY = UniqueKeys0.KEY_powerPlayClub_PRIMARY; public static final org.jooq.UniqueKey KEY_rankBenefits_PRIMARY = UniqueKeys0.KEY_rankBenefits_PRIMARY; public static final org.jooq.UniqueKey KEY_rankedBans_PRIMARY = UniqueKeys0.KEY_rankedBans_PRIMARY; public static final org.jooq.UniqueKey KEY_reportTickets_PRIMARY = UniqueKeys0.KEY_reportTickets_PRIMARY; @@ -183,11 +194,15 @@ public class Keys { public static final org.jooq.UniqueKey KEY_tournaments_PRIMARY = UniqueKeys0.KEY_tournaments_PRIMARY; public static final org.jooq.UniqueKey KEY_tournamentTeams_PRIMARY = UniqueKeys0.KEY_tournamentTeams_PRIMARY; public static final org.jooq.UniqueKey KEY_transactions_PRIMARY = UniqueKeys0.KEY_transactions_PRIMARY; + public static final org.jooq.UniqueKey KEY_unicodereplacer_PRIMARY = UniqueKeys0.KEY_unicodereplacer_PRIMARY; + public static final org.jooq.UniqueKey KEY_unicodereplacer_unicode = UniqueKeys0.KEY_unicodereplacer_unicode; + public static final org.jooq.UniqueKey KEY_youtube_PRIMARY = UniqueKeys0.KEY_youtube_PRIMARY; // ------------------------------------------------------------------------- // FOREIGN KEY definitions // ------------------------------------------------------------------------- + public static final org.jooq.ForeignKey accountAmplifierThank_accounts_id_fk = ForeignKeys0.accountAmplifierThank_accounts_id_fk; public static final org.jooq.ForeignKey accountAuth_accounts_id_fk = ForeignKeys0.accountAuth_accounts_id_fk; public static final org.jooq.ForeignKey FK_ACT_ACCOUNTS_ID = ForeignKeys0.FK_ACT_ACCOUNTS_ID; public static final org.jooq.ForeignKey CUSTOMDATA_ACCOUNT = ForeignKeys0.CUSTOMDATA_ACCOUNT; @@ -208,6 +223,9 @@ public class Keys { public static final org.jooq.ForeignKey accountStat_stat = ForeignKeys0.accountStat_stat; public static final org.jooq.ForeignKey ACCOUNTTASKS_ACCOUNTID = ForeignKeys0.ACCOUNTTASKS_ACCOUNTID; public static final org.jooq.ForeignKey ACCOUNTTASKS_TASKID = ForeignKeys0.ACCOUNTTASKS_TASKID; + public static final org.jooq.ForeignKey accountThank_accounts_id_fk = ForeignKeys0.accountThank_accounts_id_fk; + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk2 = ForeignKeys0.accountThankTransactions_accounts_id_fk2; + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk = ForeignKeys0.accountThankTransactions_accounts_id_fk; public static final org.jooq.ForeignKey accountTips_accounts_id_fk = ForeignKeys0.accountTips_accounts_id_fk; public static final org.jooq.ForeignKey accountTipClaimLogs_accounts_id_fk = ForeignKeys0.accountTipClaimLogs_accounts_id_fk; public static final org.jooq.ForeignKey accountTipLogs_accounts_id_fk = ForeignKeys0.accountTipLogs_accounts_id_fk; @@ -215,18 +233,23 @@ public class Keys { public static final org.jooq.ForeignKey ACCOUNTTRANSACTIONS_TRANSACTIONID = ForeignKeys0.ACCOUNTTRANSACTIONS_TRANSACTIONID; public static final org.jooq.ForeignKey accountValentines_sender_fk = ForeignKeys0.accountValentines_sender_fk; public static final org.jooq.ForeignKey accountValentines_target_fk = ForeignKeys0.accountValentines_target_fk; + public static final org.jooq.ForeignKey accountWebsiteLinkCode_ibfk_1 = ForeignKeys0.accountWebsiteLinkCode_ibfk_1; public static final org.jooq.ForeignKey bonus_ibfk_1 = ForeignKeys0.bonus_ibfk_1; public static final org.jooq.ForeignKey bonusLogAccountId = ForeignKeys0.bonusLogAccountId; public static final org.jooq.ForeignKey bonusLogItemId = ForeignKeys0.bonusLogItemId; + public static final org.jooq.ForeignKey clansGold_ibfk_1 = ForeignKeys0.clansGold_ibfk_1; + public static final org.jooq.ForeignKey clansGold_ibfk_2 = ForeignKeys0.clansGold_ibfk_2; public static final org.jooq.ForeignKey ELORATING_ACCOUNTID = ForeignKeys0.ELORATING_ACCOUNTID; public static final org.jooq.ForeignKey facebook_accounts_id_fk = ForeignKeys0.facebook_accounts_id_fk; public static final org.jooq.ForeignKey gadgets_ibfk_1 = ForeignKeys0.gadgets_ibfk_1; public static final org.jooq.ForeignKey mail_ibfk_1 = ForeignKeys0.mail_ibfk_1; public static final org.jooq.ForeignKey mailbox_ibfk_1 = ForeignKeys0.mailbox_ibfk_1; + public static final org.jooq.ForeignKey powerPlayClub_ibfk_1 = ForeignKeys0.powerPlayClub_ibfk_1; public static final org.jooq.ForeignKey rankBenefits_ibfk_1 = ForeignKeys0.rankBenefits_ibfk_1; public static final org.jooq.ForeignKey titanGiveaway_ibfk_1 = ForeignKeys0.titanGiveaway_ibfk_1; public static final org.jooq.ForeignKey TEAM_TOURNAMENT_KEY = ForeignKeys0.TEAM_TOURNAMENT_KEY; public static final org.jooq.ForeignKey TEAM_TOURNAMENT_ACCOUNT_ID = ForeignKeys0.TEAM_TOURNAMENT_ACCOUNT_ID; + public static final org.jooq.ForeignKey youtube_ibfk_1 = ForeignKeys0.youtube_ibfk_1; // ------------------------------------------------------------------------- // [#1459] distribute members to avoid static initialisers > 64kb @@ -247,6 +270,7 @@ public class Keys { public static org.jooq.Identity IDENTITY_accountPurchases = createIdentity(mineplex.database.tables.AccountPurchases.accountPurchases, mineplex.database.tables.AccountPurchases.accountPurchases.id); public static org.jooq.Identity IDENTITY_accounts = createIdentity(mineplex.database.tables.Accounts.accounts, mineplex.database.tables.Accounts.accounts.id); public static org.jooq.Identity IDENTITY_accountTasks = createIdentity(mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.id); + public static org.jooq.Identity IDENTITY_accountThankTransactions = createIdentity(mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.id); public static org.jooq.Identity IDENTITY_accountTipClaimLogs = createIdentity(mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs.id); public static org.jooq.Identity IDENTITY_accountTransactions = createIdentity(mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.id); public static org.jooq.Identity IDENTITY_battlePets = createIdentity(mineplex.database.tables.BattlePets.battlePets, mineplex.database.tables.BattlePets.battlePets.petId); @@ -260,6 +284,7 @@ public class Keys { public static org.jooq.Identity IDENTITY_clans = createIdentity(mineplex.database.tables.Clans.clans, mineplex.database.tables.Clans.clans.id); public static org.jooq.Identity IDENTITY_clanServer = createIdentity(mineplex.database.tables.ClanServer.clanServer, mineplex.database.tables.ClanServer.clanServer.id); public static org.jooq.Identity IDENTITY_clanShopItem = createIdentity(mineplex.database.tables.ClanShopItem.clanShopItem, mineplex.database.tables.ClanShopItem.clanShopItem.id); + public static org.jooq.Identity IDENTITY_clansNetherPortals = createIdentity(mineplex.database.tables.ClansNetherPortals.clansNetherPortals, mineplex.database.tables.ClansNetherPortals.clansNetherPortals.id); public static org.jooq.Identity IDENTITY_clanTerritory = createIdentity(mineplex.database.tables.ClanTerritory.clanTerritory, mineplex.database.tables.ClanTerritory.clanTerritory.id); public static org.jooq.Identity IDENTITY_clanWar = createIdentity(mineplex.database.tables.ClanWar.clanWar, mineplex.database.tables.ClanWar.clanWar.id); public static org.jooq.Identity IDENTITY_customData = createIdentity(mineplex.database.tables.CustomData.customData, mineplex.database.tables.CustomData.customData.id); @@ -288,9 +313,12 @@ public class Keys { public static org.jooq.Identity IDENTITY_tournaments = createIdentity(mineplex.database.tables.Tournaments.tournaments, mineplex.database.tables.Tournaments.tournaments.id); public static org.jooq.Identity IDENTITY_tournamentTeams = createIdentity(mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.id); public static org.jooq.Identity IDENTITY_transactions = createIdentity(mineplex.database.tables.Transactions.transactions, mineplex.database.tables.Transactions.transactions.id); + public static org.jooq.Identity IDENTITY_unicodereplacer = createIdentity(mineplex.database.tables.Unicodereplacer.unicodereplacer, mineplex.database.tables.Unicodereplacer.unicodereplacer.id); + public static org.jooq.Identity IDENTITY_youtube = createIdentity(mineplex.database.tables.Youtube.youtube, mineplex.database.tables.Youtube.youtube.accountId); } private static class UniqueKeys0 extends org.jooq.impl.AbstractKeys { + public static final org.jooq.UniqueKey KEY_accountAmplifierThank_PRIMARY = createUniqueKey(mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.accountId, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.amplifierId); public static final org.jooq.UniqueKey KEY_accountAuth_PRIMARY = createUniqueKey(mineplex.database.tables.AccountAuth.accountAuth, mineplex.database.tables.AccountAuth.accountAuth.id); public static final org.jooq.UniqueKey KEY_accountClan_PRIMARY = createUniqueKey(mineplex.database.tables.AccountClan.accountClan, mineplex.database.tables.AccountClan.accountClan.id); public static final org.jooq.UniqueKey KEY_accountCoinTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions.id); @@ -314,11 +342,14 @@ public class Keys { public static final org.jooq.UniqueKey KEY_accounts_uuidIndex = createUniqueKey(mineplex.database.tables.Accounts.accounts, mineplex.database.tables.Accounts.accounts.uuid); public static final org.jooq.UniqueKey KEY_accountStat_PRIMARY = createUniqueKey(mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.accountId, mineplex.database.tables.AccountStat.accountStat.statId); public static final org.jooq.UniqueKey KEY_accountTasks_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.id); + public static final org.jooq.UniqueKey KEY_accountThank_PRIMARY = createUniqueKey(mineplex.database.tables.AccountThank.accountThank, mineplex.database.tables.AccountThank.accountThank.accountId); + public static final org.jooq.UniqueKey KEY_accountThankTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.id); public static final org.jooq.UniqueKey KEY_accountTip_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTip.accountTip, mineplex.database.tables.AccountTip.accountTip.accountId); public static final org.jooq.UniqueKey KEY_accountTipClaimLogs_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs.id); public static final org.jooq.UniqueKey KEY_accountTipLogs_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTipLogs.accountTipLogs, mineplex.database.tables.AccountTipLogs.accountTipLogs.accountId, mineplex.database.tables.AccountTipLogs.accountTipLogs.boosterId); public static final org.jooq.UniqueKey KEY_accountTransactions_PRIMARY = createUniqueKey(mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.id); public static final org.jooq.UniqueKey KEY_accountValentinesGift_PRIMARY = createUniqueKey(mineplex.database.tables.AccountValentinesGift.accountValentinesGift, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.senderId, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.targetId); + public static final org.jooq.UniqueKey KEY_accountWebsiteLinkCode_PRIMARY = createUniqueKey(mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.accountId); public static final org.jooq.UniqueKey KEY_activeTournaments_PRIMARY = createUniqueKey(mineplex.database.tables.ActiveTournaments.activeTournaments, mineplex.database.tables.ActiveTournaments.activeTournaments.name); public static final org.jooq.UniqueKey KEY_battlePets_PRIMARY = createUniqueKey(mineplex.database.tables.BattlePets.battlePets, mineplex.database.tables.BattlePets.battlePets.petId); public static final org.jooq.UniqueKey KEY_bonus_PRIMARY = createUniqueKey(mineplex.database.tables.Bonus.bonus, mineplex.database.tables.Bonus.bonus.accountId); @@ -327,6 +358,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_botSpam_unique_text = createUniqueKey(mineplex.database.tables.BotSpam.botSpam, mineplex.database.tables.BotSpam.botSpam.text); public static final org.jooq.UniqueKey KEY_chatsnap_PRIMARY = createUniqueKey(mineplex.database.tables.Chatsnap.chatsnap, mineplex.database.tables.Chatsnap.chatsnap.id); public static final org.jooq.UniqueKey KEY_clanAlliances_PRIMARY = createUniqueKey(mineplex.database.tables.ClanAlliances.clanAlliances, mineplex.database.tables.ClanAlliances.clanAlliances.id); + public static final org.jooq.UniqueKey KEY_clanBanners_PRIMARY = createUniqueKey(mineplex.database.tables.ClanBanners.clanBanners, mineplex.database.tables.ClanBanners.clanBanners.clanId); public static final org.jooq.UniqueKey KEY_clanBans_PRIMARY = createUniqueKey(mineplex.database.tables.ClanBans.clanBans, mineplex.database.tables.ClanBans.clanBans.id); public static final org.jooq.UniqueKey KEY_clanEnemies_PRIMARY = createUniqueKey(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.id); public static final org.jooq.UniqueKey KEY_clanEnemies_unique_clanId = createUniqueKey(mineplex.database.tables.ClanEnemies.clanEnemies, mineplex.database.tables.ClanEnemies.clanEnemies.clanId); @@ -336,8 +368,10 @@ public class Keys { public static final org.jooq.UniqueKey KEY_clans_clanName = createUniqueKey(mineplex.database.tables.Clans.clans, mineplex.database.tables.Clans.clans.serverId, mineplex.database.tables.Clans.clans.name); public static final org.jooq.UniqueKey KEY_clanServer_PRIMARY = createUniqueKey(mineplex.database.tables.ClanServer.clanServer, mineplex.database.tables.ClanServer.clanServer.id); public static final org.jooq.UniqueKey KEY_clanServer_unique_serverName = createUniqueKey(mineplex.database.tables.ClanServer.clanServer, mineplex.database.tables.ClanServer.clanServer.serverName); + public static final org.jooq.UniqueKey KEY_clansGold_PRIMARY = createUniqueKey(mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClansGold.clansGold.serverId, mineplex.database.tables.ClansGold.clansGold.id); public static final org.jooq.UniqueKey KEY_clanShopItem_PRIMARY = createUniqueKey(mineplex.database.tables.ClanShopItem.clanShopItem, mineplex.database.tables.ClanShopItem.clanShopItem.id); public static final org.jooq.UniqueKey KEY_clanShopItem_shop_page_slot_UNIQUE = createUniqueKey(mineplex.database.tables.ClanShopItem.clanShopItem, mineplex.database.tables.ClanShopItem.clanShopItem.shopName, mineplex.database.tables.ClanShopItem.clanShopItem.shopPage, mineplex.database.tables.ClanShopItem.clanShopItem.slot); + public static final org.jooq.UniqueKey KEY_clansNetherPortals_PRIMARY = createUniqueKey(mineplex.database.tables.ClansNetherPortals.clansNetherPortals, mineplex.database.tables.ClansNetherPortals.clansNetherPortals.id); public static final org.jooq.UniqueKey KEY_clansOutposts_PRIMARY = createUniqueKey(mineplex.database.tables.ClansOutposts.clansOutposts, mineplex.database.tables.ClansOutposts.clansOutposts.uniqueId); public static final org.jooq.UniqueKey KEY_clansPvpTimer_PRIMARY = createUniqueKey(mineplex.database.tables.ClansPvpTimer.clansPvpTimer, mineplex.database.tables.ClansPvpTimer.clansPvpTimer.accountId); public static final org.jooq.UniqueKey KEY_clansSiegeWeapons_PRIMARY = createUniqueKey(mineplex.database.tables.ClansSiegeWeapons.clansSiegeWeapons, mineplex.database.tables.ClansSiegeWeapons.clansSiegeWeapons.uniqueId); @@ -364,7 +398,6 @@ public class Keys { public static final org.jooq.UniqueKey KEY_items_name_UNIQUE = createUniqueKey(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.name); public static final org.jooq.UniqueKey KEY_items_uniqueNameCategoryIndex = createUniqueKey(mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.name, mineplex.database.tables.Items.items.categoryId); public static final org.jooq.UniqueKey KEY_kitProgression_PRIMARY = createUniqueKey(mineplex.database.tables.KitProgression.kitProgression, mineplex.database.tables.KitProgression.kitProgression.uuid, mineplex.database.tables.KitProgression.kitProgression.kitId); - public static final org.jooq.UniqueKey KEY_kit_progression_PRIMARY = createUniqueKey(mineplex.database.tables.Kit_progression.kit_progression, mineplex.database.tables.Kit_progression.kit_progression.account_id, mineplex.database.tables.Kit_progression.kit_progression.kit_id); public static final org.jooq.UniqueKey KEY_mail_PRIMARY = createUniqueKey(mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.id); public static final org.jooq.UniqueKey KEY_mailbox_PRIMARY = createUniqueKey(mineplex.database.tables.Mailbox.mailbox, mineplex.database.tables.Mailbox.mailbox.id); public static final org.jooq.UniqueKey KEY_npcs_PRIMARY = createUniqueKey(mineplex.database.tables.Npcs.npcs, mineplex.database.tables.Npcs.npcs.id); @@ -372,6 +405,7 @@ public class Keys { public static final org.jooq.UniqueKey KEY_playerMap_PRIMARY = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.id); public static final org.jooq.UniqueKey KEY_playerMap_playerIndex = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.playerName); public static final org.jooq.UniqueKey KEY_polls_PRIMARY = createUniqueKey(mineplex.database.tables.Polls.polls, mineplex.database.tables.Polls.polls.id); + public static final org.jooq.UniqueKey KEY_powerPlayClub_PRIMARY = createUniqueKey(mineplex.database.tables.PowerPlayClub.powerPlayClub, mineplex.database.tables.PowerPlayClub.powerPlayClub.accountId, mineplex.database.tables.PowerPlayClub.powerPlayClub.kvKey); public static final org.jooq.UniqueKey KEY_rankBenefits_PRIMARY = createUniqueKey(mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankBenefits.rankBenefits.id); public static final org.jooq.UniqueKey KEY_rankedBans_PRIMARY = createUniqueKey(mineplex.database.tables.RankedBans.rankedBans, mineplex.database.tables.RankedBans.rankedBans.accountId); public static final org.jooq.UniqueKey KEY_reportTickets_PRIMARY = createUniqueKey(mineplex.database.tables.ReportTickets.reportTickets, mineplex.database.tables.ReportTickets.reportTickets.reportId); @@ -393,9 +427,13 @@ public class Keys { public static final org.jooq.UniqueKey KEY_tournaments_PRIMARY = createUniqueKey(mineplex.database.tables.Tournaments.tournaments, mineplex.database.tables.Tournaments.tournaments.id); public static final org.jooq.UniqueKey KEY_tournamentTeams_PRIMARY = createUniqueKey(mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.id); public static final org.jooq.UniqueKey KEY_transactions_PRIMARY = createUniqueKey(mineplex.database.tables.Transactions.transactions, mineplex.database.tables.Transactions.transactions.id); + public static final org.jooq.UniqueKey KEY_unicodereplacer_PRIMARY = createUniqueKey(mineplex.database.tables.Unicodereplacer.unicodereplacer, mineplex.database.tables.Unicodereplacer.unicodereplacer.id); + public static final org.jooq.UniqueKey KEY_unicodereplacer_unicode = createUniqueKey(mineplex.database.tables.Unicodereplacer.unicodereplacer, mineplex.database.tables.Unicodereplacer.unicodereplacer.unicode); + public static final org.jooq.UniqueKey KEY_youtube_PRIMARY = createUniqueKey(mineplex.database.tables.Youtube.youtube, mineplex.database.tables.Youtube.youtube.accountId); } private static class ForeignKeys0 extends org.jooq.impl.AbstractKeys { + public static final org.jooq.ForeignKey accountAmplifierThank_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.accountId); public static final org.jooq.ForeignKey accountAuth_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountAuth.accountAuth, mineplex.database.tables.AccountAuth.accountAuth.accountId); public static final org.jooq.ForeignKey FK_ACT_ACCOUNTS_ID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions, mineplex.database.tables.AccountCoinTransactions.accountCoinTransactions.accountId); public static final org.jooq.ForeignKey CUSTOMDATA_ACCOUNT = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountCustomData.accountCustomData, mineplex.database.tables.AccountCustomData.accountCustomData.accountId); @@ -416,6 +454,9 @@ public class Keys { public static final org.jooq.ForeignKey accountStat_stat = createForeignKey(mineplex.database.Keys.KEY_stats_PRIMARY, mineplex.database.tables.AccountStat.accountStat, mineplex.database.tables.AccountStat.accountStat.statId); public static final org.jooq.ForeignKey ACCOUNTTASKS_ACCOUNTID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.accountId); public static final org.jooq.ForeignKey ACCOUNTTASKS_TASKID = createForeignKey(mineplex.database.Keys.KEY_tasks_PRIMARY, mineplex.database.tables.AccountTasks.accountTasks, mineplex.database.tables.AccountTasks.accountTasks.taskId); + public static final org.jooq.ForeignKey accountThank_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountThank.accountThank, mineplex.database.tables.AccountThank.accountThank.accountId); + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk2 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.receiverId); + public static final org.jooq.ForeignKey accountThankTransactions_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountThankTransactions.accountThankTransactions, mineplex.database.tables.AccountThankTransactions.accountThankTransactions.senderId); public static final org.jooq.ForeignKey accountTips_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTip.accountTip, mineplex.database.tables.AccountTip.accountTip.accountId); public static final org.jooq.ForeignKey accountTipClaimLogs_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs, mineplex.database.tables.AccountTipClaimLogs.accountTipClaimLogs.accountId); public static final org.jooq.ForeignKey accountTipLogs_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountTipLogs.accountTipLogs, mineplex.database.tables.AccountTipLogs.accountTipLogs.accountId); @@ -423,17 +464,22 @@ public class Keys { public static final org.jooq.ForeignKey ACCOUNTTRANSACTIONS_TRANSACTIONID = createForeignKey(mineplex.database.Keys.KEY_transactions_PRIMARY, mineplex.database.tables.AccountTransactions.accountTransactions, mineplex.database.tables.AccountTransactions.accountTransactions.transactionId); public static final org.jooq.ForeignKey accountValentines_sender_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountValentinesGift.accountValentinesGift, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.senderId); public static final org.jooq.ForeignKey accountValentines_target_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountValentinesGift.accountValentinesGift, mineplex.database.tables.AccountValentinesGift.accountValentinesGift.targetId); + public static final org.jooq.ForeignKey accountWebsiteLinkCode_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.accountId); public static final org.jooq.ForeignKey bonus_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Bonus.bonus, mineplex.database.tables.Bonus.bonus.accountId); public static final org.jooq.ForeignKey bonusLogAccountId = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.BonusLog.bonusLog, mineplex.database.tables.BonusLog.bonusLog.accountId); public static final org.jooq.ForeignKey bonusLogItemId = createForeignKey(mineplex.database.Keys.KEY_items_PRIMARY, mineplex.database.tables.BonusLog.bonusLog, mineplex.database.tables.BonusLog.bonusLog.itemId); + public static final org.jooq.ForeignKey clansGold_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_clanServer_PRIMARY, mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClansGold.clansGold.serverId); + public static final org.jooq.ForeignKey clansGold_ibfk_2 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.ClansGold.clansGold, mineplex.database.tables.ClansGold.clansGold.id); public static final org.jooq.ForeignKey ELORATING_ACCOUNTID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.EloRating.eloRating, mineplex.database.tables.EloRating.eloRating.accountId); public static final org.jooq.ForeignKey facebook_accounts_id_fk = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Facebook.facebook, mineplex.database.tables.Facebook.facebook.accountId); public static final org.jooq.ForeignKey gadgets_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Gadgets.gadgets, mineplex.database.tables.Gadgets.gadgets.accountId); public static final org.jooq.ForeignKey mail_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Mail.mail, mineplex.database.tables.Mail.mail.accountId); public static final org.jooq.ForeignKey mailbox_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Mailbox.mailbox, mineplex.database.tables.Mailbox.mailbox.accountId); + public static final org.jooq.ForeignKey powerPlayClub_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.PowerPlayClub.powerPlayClub, mineplex.database.tables.PowerPlayClub.powerPlayClub.accountId); public static final org.jooq.ForeignKey rankBenefits_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.RankBenefits.rankBenefits, mineplex.database.tables.RankBenefits.rankBenefits.accountId); public static final org.jooq.ForeignKey titanGiveaway_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.TitanGiveaway.titanGiveaway, mineplex.database.tables.TitanGiveaway.titanGiveaway.accountId); public static final org.jooq.ForeignKey TEAM_TOURNAMENT_KEY = createForeignKey(mineplex.database.Keys.KEY_tournaments_PRIMARY, mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.tournamentId); public static final org.jooq.ForeignKey TEAM_TOURNAMENT_ACCOUNT_ID = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.TournamentTeams.tournamentTeams, mineplex.database.tables.TournamentTeams.tournamentTeams.accountId); + public static final org.jooq.ForeignKey youtube_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.Youtube.youtube, mineplex.database.tables.Youtube.youtube.accountId); } } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java index af540cee5..e4d6ad2b1 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Routines.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Routines.java @@ -28,6 +28,21 @@ public class Routines { return p.getSuccess(); } + /** + * Call Account.addThank + */ + public static java.lang.Byte callAddthank(org.jooq.Configuration configuration, java.lang.Integer inReceiverAccountId, java.lang.Integer inSenderAccountId, java.lang.Integer inThankAmount, java.lang.String inReason, java.lang.Byte inIgnoreCooldown) { + mineplex.database.routines.AddThank p = new mineplex.database.routines.AddThank(); + p.setInReceiverAccountId(inReceiverAccountId); + p.setInSenderAccountId(inSenderAccountId); + p.setInThankAmount(inThankAmount); + p.setInReason(inReason); + p.setInIgnoreCooldown(inIgnoreCooldown); + + p.execute(configuration); + return p.getSuccess(); + } + /** * Call Account.addTip */ @@ -42,6 +57,18 @@ public class Routines { return p.getSuccess(); } + /** + * Call Account.checkAmplifierThank + */ + public static java.lang.Byte callCheckamplifierthank(org.jooq.Configuration configuration, java.lang.Integer inAccountId, java.lang.Integer inAmplifierId) { + mineplex.database.routines.CheckAmplifierThank p = new mineplex.database.routines.CheckAmplifierThank(); + p.setInAccountId(inAccountId); + p.setInAmplifierId(inAmplifierId); + + p.execute(configuration); + return p.getCanThank(); + } + /** * Call Account.check_daily */ @@ -105,6 +132,17 @@ public class Routines { return p; } + /** + * Call Account.claimThank + */ + public static mineplex.database.routines.ClaimThank callClaimthank(org.jooq.Configuration configuration, java.lang.Integer inAccountId) { + mineplex.database.routines.ClaimThank p = new mineplex.database.routines.ClaimThank(); + p.setInAccountId(inAccountId); + + p.execute(configuration); + return p; + } + /** * Call Account.claimTips */ diff --git a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java index f4c26f567..c65a8a1c7 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/Tables.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/Tables.java @@ -16,6 +16,11 @@ package mineplex.database; @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Tables { + /** + * The table Account.accountAmplifierThank + */ + public static final mineplex.database.tables.AccountAmplifierThank accountAmplifierThank = mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank; + /** * The table Account.accountAuth */ @@ -101,6 +106,16 @@ public class Tables { */ public static final mineplex.database.tables.AccountTasks accountTasks = mineplex.database.tables.AccountTasks.accountTasks; + /** + * The table Account.accountThank + */ + public static final mineplex.database.tables.AccountThank accountThank = mineplex.database.tables.AccountThank.accountThank; + + /** + * The table Account.accountThankTransactions + */ + public static final mineplex.database.tables.AccountThankTransactions accountThankTransactions = mineplex.database.tables.AccountThankTransactions.accountThankTransactions; + /** * The table Account.accountTip */ @@ -126,6 +141,11 @@ public class Tables { */ public static final mineplex.database.tables.AccountValentinesGift accountValentinesGift = mineplex.database.tables.AccountValentinesGift.accountValentinesGift; + /** + * The table Account.accountWebsiteLinkCode + */ + public static final mineplex.database.tables.AccountWebsiteLinkCode accountWebsiteLinkCode = mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode; + /** * The table Account.activeTournaments */ @@ -161,6 +181,11 @@ public class Tables { */ public static final mineplex.database.tables.ClanAlliances clanAlliances = mineplex.database.tables.ClanAlliances.clanAlliances; + /** + * The table Account.clanBanners + */ + public static final mineplex.database.tables.ClanBanners clanBanners = mineplex.database.tables.ClanBanners.clanBanners; + /** * The table Account.clanBans */ @@ -191,11 +216,21 @@ public class Tables { */ public static final mineplex.database.tables.ClanServer clanServer = mineplex.database.tables.ClanServer.clanServer; + /** + * The table Account.clansGold + */ + public static final mineplex.database.tables.ClansGold clansGold = mineplex.database.tables.ClansGold.clansGold; + /** * The table Account.clanShopItem */ public static final mineplex.database.tables.ClanShopItem clanShopItem = mineplex.database.tables.ClanShopItem.clanShopItem; + /** + * The table Account.clansNetherPortals + */ + public static final mineplex.database.tables.ClansNetherPortals clansNetherPortals = mineplex.database.tables.ClansNetherPortals.clansNetherPortals; + /** * The table Account.clansOutposts */ @@ -296,11 +331,6 @@ public class Tables { */ public static final mineplex.database.tables.KitProgression kitProgression = mineplex.database.tables.KitProgression.kitProgression; - /** - * The table Account.kit_progression - */ - public static final mineplex.database.tables.Kit_progression kit_progression = mineplex.database.tables.Kit_progression.kit_progression; - /** * The table Account.mail */ @@ -311,6 +341,11 @@ public class Tables { */ public static final mineplex.database.tables.Mailbox mailbox = mineplex.database.tables.Mailbox.mailbox; + /** + * The table Account.nonPremiumJoinMessage + */ + public static final mineplex.database.tables.NonPremiumJoinMessage nonPremiumJoinMessage = mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage; + /** * The table Account.npcs */ @@ -331,6 +366,11 @@ public class Tables { */ public static final mineplex.database.tables.Polls polls = mineplex.database.tables.Polls.polls; + /** + * The table Account.powerPlayClub + */ + public static final mineplex.database.tables.PowerPlayClub powerPlayClub = mineplex.database.tables.PowerPlayClub.powerPlayClub; + /** * The table Account.rankBenefits */ @@ -430,4 +470,14 @@ public class Tables { * The table Account.transactions */ public static final mineplex.database.tables.Transactions transactions = mineplex.database.tables.Transactions.transactions; + + /** + * The table Account.unicodereplacer + */ + public static final mineplex.database.tables.Unicodereplacer unicodereplacer = mineplex.database.tables.Unicodereplacer.unicodereplacer; + + /** + * The table Account.youtube + */ + public static final mineplex.database.tables.Youtube youtube = mineplex.database.tables.Youtube.youtube; } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java new file mode 100644 index 000000000..584e2c830 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/AddThank.java @@ -0,0 +1,106 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AddThank extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -344701696; + + /** + * The parameter Account.addThank.inReceiverAccountId. + */ + public static final org.jooq.Parameter inReceiverAccountId = createParameter("inReceiverAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.addThank.inSenderAccountId. + */ + public static final org.jooq.Parameter inSenderAccountId = createParameter("inSenderAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.addThank.inThankAmount. + */ + public static final org.jooq.Parameter inThankAmount = createParameter("inThankAmount", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.addThank.inReason. + */ + public static final org.jooq.Parameter inReason = createParameter("inReason", org.jooq.impl.SQLDataType.VARCHAR.length(32), false); + + /** + * The parameter Account.addThank.inIgnoreCooldown. + */ + public static final org.jooq.Parameter inIgnoreCooldown = createParameter("inIgnoreCooldown", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * The parameter Account.addThank.success. + */ + public static final org.jooq.Parameter success = createParameter("success", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * Create a new routine call instance + */ + public AddThank() { + super("addThank", mineplex.database.Account.Account); + + addInParameter(inReceiverAccountId); + addInParameter(inSenderAccountId); + addInParameter(inThankAmount); + addInParameter(inReason); + addInParameter(inIgnoreCooldown); + addOutParameter(success); + } + + /** + * Set the inReceiverAccountId parameter IN value to the routine + */ + public void setInReceiverAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.AddThank.inReceiverAccountId, value); + } + + /** + * Set the inSenderAccountId parameter IN value to the routine + */ + public void setInSenderAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.AddThank.inSenderAccountId, value); + } + + /** + * Set the inThankAmount parameter IN value to the routine + */ + public void setInThankAmount(java.lang.Integer value) { + setValue(mineplex.database.routines.AddThank.inThankAmount, value); + } + + /** + * Set the inReason parameter IN value to the routine + */ + public void setInReason(java.lang.String value) { + setValue(mineplex.database.routines.AddThank.inReason, value); + } + + /** + * Set the inIgnoreCooldown parameter IN value to the routine + */ + public void setInIgnoreCooldown(java.lang.Byte value) { + setValue(mineplex.database.routines.AddThank.inIgnoreCooldown, value); + } + + /** + * Get the success parameter OUT value from the routine + */ + public java.lang.Byte getSuccess() { + return getValue(success); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java new file mode 100644 index 000000000..2fd338361 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/CheckAmplifierThank.java @@ -0,0 +1,67 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class CheckAmplifierThank extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 522346006; + + /** + * The parameter Account.checkAmplifierThank.inAccountId. + */ + public static final org.jooq.Parameter inAccountId = createParameter("inAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.checkAmplifierThank.inAmplifierId. + */ + public static final org.jooq.Parameter inAmplifierId = createParameter("inAmplifierId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.checkAmplifierThank.canThank. + */ + public static final org.jooq.Parameter canThank = createParameter("canThank", org.jooq.impl.SQLDataType.TINYINT, false); + + /** + * Create a new routine call instance + */ + public CheckAmplifierThank() { + super("checkAmplifierThank", mineplex.database.Account.Account); + + addInParameter(inAccountId); + addInParameter(inAmplifierId); + addOutParameter(canThank); + } + + /** + * Set the inAccountId parameter IN value to the routine + */ + public void setInAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.CheckAmplifierThank.inAccountId, value); + } + + /** + * Set the inAmplifierId parameter IN value to the routine + */ + public void setInAmplifierId(java.lang.Integer value) { + setValue(mineplex.database.routines.CheckAmplifierThank.inAmplifierId, value); + } + + /** + * Get the canThank parameter OUT value from the routine + */ + public java.lang.Byte getCanThank() { + return getValue(canThank); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java b/Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java new file mode 100644 index 000000000..d88ec80e7 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/routines/ClaimThank.java @@ -0,0 +1,67 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.routines; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClaimThank extends org.jooq.impl.AbstractRoutine implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 856582355; + + /** + * The parameter Account.claimThank.inAccountId. + */ + public static final org.jooq.Parameter inAccountId = createParameter("inAccountId", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.claimThank.amountClaimed. + */ + public static final org.jooq.Parameter amountClaimed = createParameter("amountClaimed", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * The parameter Account.claimThank.uniqueThank. + */ + public static final org.jooq.Parameter uniqueThank = createParameter("uniqueThank", org.jooq.impl.SQLDataType.INTEGER, false); + + /** + * Create a new routine call instance + */ + public ClaimThank() { + super("claimThank", mineplex.database.Account.Account); + + addInParameter(inAccountId); + addOutParameter(amountClaimed); + addOutParameter(uniqueThank); + } + + /** + * Set the inAccountId parameter IN value to the routine + */ + public void setInAccountId(java.lang.Integer value) { + setValue(mineplex.database.routines.ClaimThank.inAccountId, value); + } + + /** + * Get the amountClaimed parameter OUT value from the routine + */ + public java.lang.Integer getAmountClaimed() { + return getValue(amountClaimed); + } + + /** + * Get the uniqueThank parameter OUT value from the routine + */ + public java.lang.Integer getUniqueThank() { + return getValue(uniqueThank); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java new file mode 100644 index 000000000..5e3e7f0b5 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountAmplifierThank.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountAmplifierThank extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -810649551; + + /** + * The reference instance of Account.accountAmplifierThank + */ + public static final mineplex.database.tables.AccountAmplifierThank accountAmplifierThank = new mineplex.database.tables.AccountAmplifierThank(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountAmplifierThankRecord.class; + } + + /** + * The column Account.accountAmplifierThank.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountAmplifierThank.amplifierId. + */ + public final org.jooq.TableField amplifierId = createField("amplifierId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountAmplifierThank.time. + */ + public final org.jooq.TableField time = createField("time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * Create a Account.accountAmplifierThank table reference + */ + public AccountAmplifierThank() { + this("accountAmplifierThank", null); + } + + /** + * Create an aliased Account.accountAmplifierThank table reference + */ + public AccountAmplifierThank(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank); + } + + private AccountAmplifierThank(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountAmplifierThank(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountAmplifierThank_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountAmplifierThank_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountAmplifierThank_accounts_id_fk); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountAmplifierThank as(java.lang.String alias) { + return new mineplex.database.tables.AccountAmplifierThank(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountAmplifierThank rename(java.lang.String name) { + return new mineplex.database.tables.AccountAmplifierThank(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java new file mode 100644 index 000000000..1ede4b1b3 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThank.java @@ -0,0 +1,104 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThank extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -1744584483; + + /** + * The reference instance of Account.accountThank + */ + public static final mineplex.database.tables.AccountThank accountThank = new mineplex.database.tables.AccountThank(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountThankRecord.class; + } + + /** + * The column Account.accountThank.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountThank.thanks. + */ + public final org.jooq.TableField thanks = createField("thanks", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * Create a Account.accountThank table reference + */ + public AccountThank() { + this("accountThank", null); + } + + /** + * Create an aliased Account.accountThank table reference + */ + public AccountThank(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountThank.accountThank); + } + + private AccountThank(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountThank(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountThank_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountThank_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountThank_accounts_id_fk); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountThank as(java.lang.String alias) { + return new mineplex.database.tables.AccountThank(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountThank rename(java.lang.String name) { + return new mineplex.database.tables.AccountThank(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java new file mode 100644 index 000000000..dafbe15d1 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountThankTransactions.java @@ -0,0 +1,147 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThankTransactions extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 809892717; + + /** + * The reference instance of Account.accountThankTransactions + */ + public static final mineplex.database.tables.AccountThankTransactions accountThankTransactions = new mineplex.database.tables.AccountThankTransactions(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountThankTransactionsRecord.class; + } + + /** + * The column Account.accountThankTransactions.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountThankTransactions.receiverId. + */ + public final org.jooq.TableField receiverId = createField("receiverId", org.jooq.impl.SQLDataType.INTEGER, this, ""); + + /** + * The column Account.accountThankTransactions.senderId. + */ + public final org.jooq.TableField senderId = createField("senderId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountThankTransactions.thankAmount. + */ + public final org.jooq.TableField thankAmount = createField("thankAmount", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.reason. + */ + public final org.jooq.TableField reason = createField("reason", org.jooq.impl.SQLDataType.VARCHAR.length(32), this, ""); + + /** + * The column Account.accountThankTransactions.ignoreCooldown. + */ + public final org.jooq.TableField ignoreCooldown = createField("ignoreCooldown", org.jooq.impl.SQLDataType.TINYINT.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.claimed. + */ + public final org.jooq.TableField claimed = createField("claimed", org.jooq.impl.SQLDataType.TINYINT.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.sentTime. + */ + public final org.jooq.TableField sentTime = createField("sentTime", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * The column Account.accountThankTransactions.claimTime. + */ + public final org.jooq.TableField claimTime = createField("claimTime", org.jooq.impl.SQLDataType.TIMESTAMP, this, ""); + + /** + * Create a Account.accountThankTransactions table reference + */ + public AccountThankTransactions() { + this("accountThankTransactions", null); + } + + /** + * Create an aliased Account.accountThankTransactions table reference + */ + public AccountThankTransactions(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountThankTransactions.accountThankTransactions); + } + + private AccountThankTransactions(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountThankTransactions(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_accountThankTransactions; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountThankTransactions_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountThankTransactions_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountThankTransactions_accounts_id_fk2, mineplex.database.Keys.accountThankTransactions_accounts_id_fk); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountThankTransactions as(java.lang.String alias) { + return new mineplex.database.tables.AccountThankTransactions(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountThankTransactions rename(java.lang.String name) { + return new mineplex.database.tables.AccountThankTransactions(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java new file mode 100644 index 000000000..9afc65380 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountWebsiteLinkCode.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountWebsiteLinkCode extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 2114439433; + + /** + * The reference instance of Account.accountWebsiteLinkCode + */ + public static final mineplex.database.tables.AccountWebsiteLinkCode accountWebsiteLinkCode = new mineplex.database.tables.AccountWebsiteLinkCode(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountWebsiteLinkCodeRecord.class; + } + + /** + * The column Account.accountWebsiteLinkCode.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountWebsiteLinkCode.confirmationCode. + */ + public final org.jooq.TableField confirmationCode = createField("confirmationCode", org.jooq.impl.SQLDataType.CHAR.length(6).nullable(false), this, ""); + + /** + * The column Account.accountWebsiteLinkCode.date. + */ + public final org.jooq.TableField date = createField("date", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, ""); + + /** + * Create a Account.accountWebsiteLinkCode table reference + */ + public AccountWebsiteLinkCode() { + this("accountWebsiteLinkCode", null); + } + + /** + * Create an aliased Account.accountWebsiteLinkCode table reference + */ + public AccountWebsiteLinkCode(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode); + } + + private AccountWebsiteLinkCode(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountWebsiteLinkCode(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountWebsiteLinkCode_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountWebsiteLinkCode_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountWebsiteLinkCode_ibfk_1); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountWebsiteLinkCode as(java.lang.String alias) { + return new mineplex.database.tables.AccountWebsiteLinkCode(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountWebsiteLinkCode rename(java.lang.String name) { + return new mineplex.database.tables.AccountWebsiteLinkCode(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java new file mode 100644 index 000000000..737c017b1 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClanBanners.java @@ -0,0 +1,101 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClanBanners extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -633858329; + + /** + * The reference instance of Account.clanBanners + */ + public static final mineplex.database.tables.ClanBanners clanBanners = new mineplex.database.tables.ClanBanners(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ClanBannersRecord.class; + } + + /** + * The column Account.clanBanners.clanId. + */ + public final org.jooq.TableField clanId = createField("clanId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clanBanners.baseColor. + */ + public final org.jooq.TableField baseColor = createField("baseColor", org.jooq.impl.SQLDataType.VARCHAR.length(15), this, ""); + + /** + * The column Account.clanBanners.patterns. + */ + public final org.jooq.TableField patterns = createField("patterns", org.jooq.impl.SQLDataType.VARCHAR.length(300), this, ""); + + /** + * Create a Account.clanBanners table reference + */ + public ClanBanners() { + this("clanBanners", null); + } + + /** + * Create an aliased Account.clanBanners table reference + */ + public ClanBanners(java.lang.String alias) { + this(alias, mineplex.database.tables.ClanBanners.clanBanners); + } + + private ClanBanners(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private ClanBanners(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_clanBanners_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_clanBanners_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.ClanBanners as(java.lang.String alias) { + return new mineplex.database.tables.ClanBanners(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.ClanBanners rename(java.lang.String name) { + return new mineplex.database.tables.ClanBanners(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java new file mode 100644 index 000000000..a8618fea5 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansGold.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansGold extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 950104617; + + /** + * The reference instance of Account.clansGold + */ + public static final mineplex.database.tables.ClansGold clansGold = new mineplex.database.tables.ClansGold(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ClansGoldRecord.class; + } + + /** + * The column Account.clansGold.serverId. + */ + public final org.jooq.TableField serverId = createField("serverId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clansGold.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clansGold.gold. + */ + public final org.jooq.TableField gold = createField("gold", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * Create a Account.clansGold table reference + */ + public ClansGold() { + this("clansGold", null); + } + + /** + * Create an aliased Account.clansGold table reference + */ + public ClansGold(java.lang.String alias) { + this(alias, mineplex.database.tables.ClansGold.clansGold); + } + + private ClansGold(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private ClansGold(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_clansGold_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_clansGold_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.clansGold_ibfk_1, mineplex.database.Keys.clansGold_ibfk_2); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.ClansGold as(java.lang.String alias) { + return new mineplex.database.tables.ClansGold(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.ClansGold rename(java.lang.String name) { + return new mineplex.database.tables.ClansGold(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java new file mode 100644 index 000000000..200912a7d --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/ClansNetherPortals.java @@ -0,0 +1,114 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansNetherPortals extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -1556693012; + + /** + * The reference instance of Account.clansNetherPortals + */ + public static final mineplex.database.tables.ClansNetherPortals clansNetherPortals = new mineplex.database.tables.ClansNetherPortals(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.ClansNetherPortalsRecord.class; + } + + /** + * The column Account.clansNetherPortals.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.clansNetherPortals.cornerOne. + */ + public final org.jooq.TableField cornerOne = createField("cornerOne", org.jooq.impl.SQLDataType.VARCHAR.length(30), this, ""); + + /** + * The column Account.clansNetherPortals.cornerTwo. + */ + public final org.jooq.TableField cornerTwo = createField("cornerTwo", org.jooq.impl.SQLDataType.VARCHAR.length(30), this, ""); + + /** + * The column Account.clansNetherPortals.returnPortal. + */ + public final org.jooq.TableField returnPortal = createField("returnPortal", org.jooq.impl.SQLDataType.TINYINT, this, ""); + + /** + * Create a Account.clansNetherPortals table reference + */ + public ClansNetherPortals() { + this("clansNetherPortals", null); + } + + /** + * Create an aliased Account.clansNetherPortals table reference + */ + public ClansNetherPortals(java.lang.String alias) { + this(alias, mineplex.database.tables.ClansNetherPortals.clansNetherPortals); + } + + private ClansNetherPortals(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private ClansNetherPortals(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_clansNetherPortals; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_clansNetherPortals_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_clansNetherPortals_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.ClansNetherPortals as(java.lang.String alias) { + return new mineplex.database.tables.ClansNetherPortals(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.ClansNetherPortals rename(java.lang.String name) { + return new mineplex.database.tables.ClansNetherPortals(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java deleted file mode 100644 index 836eaf7c7..000000000 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/Kit_progression.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * This class is generated by jOOQ - */ -package mineplex.database.tables; - -/** - * This class is generated by jOOQ. - */ -@javax.annotation.Generated( - value = { - "http://www.jooq.org", - "jOOQ version:3.5.2" - }, - comments = "This class is generated by jOOQ" -) -@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class Kit_progression extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { - - private static final long serialVersionUID = 144258751; - - /** - * The reference instance of Account.kit_progression - */ - public static final mineplex.database.tables.Kit_progression kit_progression = new mineplex.database.tables.Kit_progression(); - - /** - * The class holding records for this type - */ - @Override - public java.lang.Class getRecordType() { - return mineplex.database.tables.records.Kit_progressionRecord.class; - } - - /** - * The column Account.kit_progression.account_id. - */ - public final org.jooq.TableField account_id = createField("account_id", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, ""); - - /** - * The column Account.kit_progression.kit_id. - */ - public final org.jooq.TableField kit_id = createField("kit_id", org.jooq.impl.SQLDataType.VARCHAR.length(64).nullable(false).defaulted(true), this, ""); - - /** - * The column Account.kit_progression.level. - */ - public final org.jooq.TableField level = createField("level", org.jooq.impl.SQLDataType.INTEGER, this, ""); - - /** - * The column Account.kit_progression.xp. - */ - public final org.jooq.TableField xp = createField("xp", org.jooq.impl.SQLDataType.INTEGER, this, ""); - - /** - * The column Account.kit_progression.upgrade_level. - */ - public final org.jooq.TableField upgrade_level = createField("upgrade_level", org.jooq.impl.SQLDataType.INTEGER, this, ""); - - /** - * The column Account.kit_progression.default. - */ - public final org.jooq.TableField default_ = createField("default", org.jooq.impl.SQLDataType.TINYINT, this, ""); - - /** - * Create a Account.kit_progression table reference - */ - public Kit_progression() { - this("kit_progression", null); - } - - /** - * Create an aliased Account.kit_progression table reference - */ - public Kit_progression(java.lang.String alias) { - this(alias, mineplex.database.tables.Kit_progression.kit_progression); - } - - private Kit_progression(java.lang.String alias, org.jooq.Table aliased) { - this(alias, aliased, null); - } - - private Kit_progression(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { - super(alias, mineplex.database.Account.Account, aliased, parameters, ""); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.UniqueKey getPrimaryKey() { - return mineplex.database.Keys.KEY_kit_progression_PRIMARY; - } - - /** - * {@inheritDoc} - */ - @Override - public java.util.List> getKeys() { - return java.util.Arrays.>asList(mineplex.database.Keys.KEY_kit_progression_PRIMARY); - } - - /** - * {@inheritDoc} - */ - @Override - public mineplex.database.tables.Kit_progression as(java.lang.String alias) { - return new mineplex.database.tables.Kit_progression(alias, this); - } - - /** - * Rename this table - */ - public mineplex.database.tables.Kit_progression rename(java.lang.String name) { - return new mineplex.database.tables.Kit_progression(name, null); - } -} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java new file mode 100644 index 000000000..16d497ab8 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/NonPremiumJoinMessage.java @@ -0,0 +1,75 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class NonPremiumJoinMessage extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 1100695916; + + /** + * The reference instance of Account.nonPremiumJoinMessage + */ + public static final mineplex.database.tables.NonPremiumJoinMessage nonPremiumJoinMessage = new mineplex.database.tables.NonPremiumJoinMessage(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.NonPremiumJoinMessageRecord.class; + } + + /** + * The column Account.nonPremiumJoinMessage.message. + */ + public final org.jooq.TableField message = createField("message", org.jooq.impl.SQLDataType.CLOB, this, ""); + + /** + * Create a Account.nonPremiumJoinMessage table reference + */ + public NonPremiumJoinMessage() { + this("nonPremiumJoinMessage", null); + } + + /** + * Create an aliased Account.nonPremiumJoinMessage table reference + */ + public NonPremiumJoinMessage(java.lang.String alias) { + this(alias, mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage); + } + + private NonPremiumJoinMessage(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private NonPremiumJoinMessage(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.NonPremiumJoinMessage as(java.lang.String alias) { + return new mineplex.database.tables.NonPremiumJoinMessage(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.NonPremiumJoinMessage rename(java.lang.String name) { + return new mineplex.database.tables.NonPremiumJoinMessage(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java new file mode 100644 index 000000000..148384d3f --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/PowerPlayClub.java @@ -0,0 +1,109 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class PowerPlayClub extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = -521671017; + + /** + * The reference instance of Account.powerPlayClub + */ + public static final mineplex.database.tables.PowerPlayClub powerPlayClub = new mineplex.database.tables.PowerPlayClub(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.PowerPlayClubRecord.class; + } + + /** + * The column Account.powerPlayClub.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.powerPlayClub.kvKey. + */ + public final org.jooq.TableField kvKey = createField("kvKey", org.jooq.impl.SQLDataType.VARCHAR.length(255).nullable(false), this, ""); + + /** + * The column Account.powerPlayClub.kvValue. + */ + public final org.jooq.TableField kvValue = createField("kvValue", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * Create a Account.powerPlayClub table reference + */ + public PowerPlayClub() { + this("powerPlayClub", null); + } + + /** + * Create an aliased Account.powerPlayClub table reference + */ + public PowerPlayClub(java.lang.String alias) { + this(alias, mineplex.database.tables.PowerPlayClub.powerPlayClub); + } + + private PowerPlayClub(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private PowerPlayClub(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_powerPlayClub_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_powerPlayClub_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.powerPlayClub_ibfk_1); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.PowerPlayClub as(java.lang.String alias) { + return new mineplex.database.tables.PowerPlayClub(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.PowerPlayClub rename(java.lang.String name) { + return new mineplex.database.tables.PowerPlayClub(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java new file mode 100644 index 000000000..5e9e15ac0 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Unicodereplacer.java @@ -0,0 +1,119 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Unicodereplacer extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 613849358; + + /** + * The reference instance of Account.unicodereplacer + */ + public static final mineplex.database.tables.Unicodereplacer unicodereplacer = new mineplex.database.tables.Unicodereplacer(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.UnicodereplacerRecord.class; + } + + /** + * The column Account.unicodereplacer.id. + */ + public final org.jooq.TableField id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.unicodereplacer.unicode. + */ + public final org.jooq.TableField unicode = createField("unicode", org.jooq.impl.SQLDataType.VARCHAR.length(4), this, ""); + + /** + * The column Account.unicodereplacer.replacement. + */ + public final org.jooq.TableField replacement = createField("replacement", org.jooq.impl.SQLDataType.VARCHAR.length(8), this, ""); + + /** + * The column Account.unicodereplacer.created_by. + */ + public final org.jooq.TableField created_by = createField("created_by", org.jooq.impl.SQLDataType.VARCHAR.length(64), this, ""); + + /** + * The column Account.unicodereplacer.removed_by. + */ + public final org.jooq.TableField removed_by = createField("removed_by", org.jooq.impl.SQLDataType.VARCHAR.length(64), this, ""); + + /** + * Create a Account.unicodereplacer table reference + */ + public Unicodereplacer() { + this("unicodereplacer", null); + } + + /** + * Create an aliased Account.unicodereplacer table reference + */ + public Unicodereplacer(java.lang.String alias) { + this(alias, mineplex.database.tables.Unicodereplacer.unicodereplacer); + } + + private Unicodereplacer(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private Unicodereplacer(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_unicodereplacer; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_unicodereplacer_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_unicodereplacer_PRIMARY, mineplex.database.Keys.KEY_unicodereplacer_unicode); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.Unicodereplacer as(java.lang.String alias) { + return new mineplex.database.tables.Unicodereplacer(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.Unicodereplacer rename(java.lang.String name) { + return new mineplex.database.tables.Unicodereplacer(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java new file mode 100644 index 000000000..e150be718 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/Youtube.java @@ -0,0 +1,112 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Youtube extends org.jooq.impl.TableImpl implements java.io.Serializable, java.lang.Cloneable { + + private static final long serialVersionUID = 1588929727; + + /** + * The reference instance of Account.youtube + */ + public static final mineplex.database.tables.Youtube youtube = new mineplex.database.tables.Youtube(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.YoutubeRecord.class; + } + + /** + * The column Account.youtube.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.youtube.clicktime. + */ + public final org.jooq.TableField clicktime = createField("clicktime", org.jooq.impl.SQLDataType.DATE, this, ""); + + /** + * Create a Account.youtube table reference + */ + public Youtube() { + this("youtube", null); + } + + /** + * Create an aliased Account.youtube table reference + */ + public Youtube(java.lang.String alias) { + this(alias, mineplex.database.tables.Youtube.youtube); + } + + private Youtube(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private Youtube(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Identity getIdentity() { + return mineplex.database.Keys.IDENTITY_youtube; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_youtube_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_youtube_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.youtube_ibfk_1); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.Youtube as(java.lang.String alias) { + return new mineplex.database.tables.Youtube(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.Youtube rename(java.lang.String name) { + return new mineplex.database.tables.Youtube(name, null); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java new file mode 100644 index 000000000..0e6af2e8e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountAmplifierThankRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountAmplifierThankRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = 1203692620; + + /** + * Setter for Account.accountAmplifierThank.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountAmplifierThank.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountAmplifierThank.amplifierId. + */ + public void setAmplifierId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountAmplifierThank.amplifierId. + */ + public java.lang.Integer getAmplifierId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.accountAmplifierThank.time. + */ + public void setTime(java.sql.Timestamp value) { + setValue(2, value); + } + + /** + * Getter for Account.accountAmplifierThank.time. + */ + public java.sql.Timestamp getTime() { + return (java.sql.Timestamp) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.amplifierId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank.time; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getAmplifierId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value3() { + return getTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord value2(java.lang.Integer value) { + setAmplifierId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord value3(java.sql.Timestamp value) { + setTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountAmplifierThankRecord values(java.lang.Integer value1, java.lang.Integer value2, java.sql.Timestamp value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountAmplifierThankRecord + */ + public AccountAmplifierThankRecord() { + super(mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank); + } + + /** + * Create a detached, initialised AccountAmplifierThankRecord + */ + public AccountAmplifierThankRecord(java.lang.Integer accountId, java.lang.Integer amplifierId, java.sql.Timestamp time) { + super(mineplex.database.tables.AccountAmplifierThank.accountAmplifierThank); + + setValue(0, accountId); + setValue(1, amplifierId); + setValue(2, time); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java new file mode 100644 index 000000000..6b932a8f2 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankRecord.java @@ -0,0 +1,159 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThankRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record2 { + + private static final long serialVersionUID = -183734569; + + /** + * Setter for Account.accountThank.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountThank.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountThank.thanks. + */ + public void setThanks(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountThank.thanks. + */ + public java.lang.Integer getThanks() { + return (java.lang.Integer) getValue(1); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record2 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 fieldsRow() { + return (org.jooq.Row2) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 valuesRow() { + return (org.jooq.Row2) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountThank.accountThank.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountThank.accountThank.thanks; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getThanks(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankRecord value2(java.lang.Integer value) { + setThanks(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankRecord values(java.lang.Integer value1, java.lang.Integer value2) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountThankRecord + */ + public AccountThankRecord() { + super(mineplex.database.tables.AccountThank.accountThank); + } + + /** + * Create a detached, initialised AccountThankRecord + */ + public AccountThankRecord(java.lang.Integer accountId, java.lang.Integer thanks) { + super(mineplex.database.tables.AccountThank.accountThank); + + setValue(0, accountId); + setValue(1, thanks); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java new file mode 100644 index 000000000..d4cd2c004 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountThankTransactionsRecord.java @@ -0,0 +1,439 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountThankTransactionsRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record9 { + + private static final long serialVersionUID = -1604313652; + + /** + * Setter for Account.accountThankTransactions.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountThankTransactions.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountThankTransactions.receiverId. + */ + public void setReceiverId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountThankTransactions.receiverId. + */ + public java.lang.Integer getReceiverId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.accountThankTransactions.senderId. + */ + public void setSenderId(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.accountThankTransactions.senderId. + */ + public java.lang.Integer getSenderId() { + return (java.lang.Integer) getValue(2); + } + + /** + * Setter for Account.accountThankTransactions.thankAmount. + */ + public void setThankAmount(java.lang.Integer value) { + setValue(3, value); + } + + /** + * Getter for Account.accountThankTransactions.thankAmount. + */ + public java.lang.Integer getThankAmount() { + return (java.lang.Integer) getValue(3); + } + + /** + * Setter for Account.accountThankTransactions.reason. + */ + public void setReason(java.lang.String value) { + setValue(4, value); + } + + /** + * Getter for Account.accountThankTransactions.reason. + */ + public java.lang.String getReason() { + return (java.lang.String) getValue(4); + } + + /** + * Setter for Account.accountThankTransactions.ignoreCooldown. + */ + public void setIgnoreCooldown(java.lang.Byte value) { + setValue(5, value); + } + + /** + * Getter for Account.accountThankTransactions.ignoreCooldown. + */ + public java.lang.Byte getIgnoreCooldown() { + return (java.lang.Byte) getValue(5); + } + + /** + * Setter for Account.accountThankTransactions.claimed. + */ + public void setClaimed(java.lang.Byte value) { + setValue(6, value); + } + + /** + * Getter for Account.accountThankTransactions.claimed. + */ + public java.lang.Byte getClaimed() { + return (java.lang.Byte) getValue(6); + } + + /** + * Setter for Account.accountThankTransactions.sentTime. + */ + public void setSentTime(java.sql.Timestamp value) { + setValue(7, value); + } + + /** + * Getter for Account.accountThankTransactions.sentTime. + */ + public java.sql.Timestamp getSentTime() { + return (java.sql.Timestamp) getValue(7); + } + + /** + * Setter for Account.accountThankTransactions.claimTime. + */ + public void setClaimTime(java.sql.Timestamp value) { + setValue(8, value); + } + + /** + * Getter for Account.accountThankTransactions.claimTime. + */ + public java.sql.Timestamp getClaimTime() { + return (java.sql.Timestamp) getValue(8); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record9 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row9 fieldsRow() { + return (org.jooq.Row9) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row9 valuesRow() { + return (org.jooq.Row9) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.receiverId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.senderId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.thankAmount; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field5() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.reason; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field6() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.ignoreCooldown; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field7() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.claimed; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field8() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.sentTime; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field9() { + return mineplex.database.tables.AccountThankTransactions.accountThankTransactions.claimTime; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getReceiverId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getSenderId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value4() { + return getThankAmount(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value5() { + return getReason(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Byte value6() { + return getIgnoreCooldown(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Byte value7() { + return getClaimed(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value8() { + return getSentTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value9() { + return getClaimTime(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value2(java.lang.Integer value) { + setReceiverId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value3(java.lang.Integer value) { + setSenderId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value4(java.lang.Integer value) { + setThankAmount(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value5(java.lang.String value) { + setReason(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value6(java.lang.Byte value) { + setIgnoreCooldown(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value7(java.lang.Byte value) { + setClaimed(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value8(java.sql.Timestamp value) { + setSentTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord value9(java.sql.Timestamp value) { + setClaimTime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountThankTransactionsRecord values(java.lang.Integer value1, java.lang.Integer value2, java.lang.Integer value3, java.lang.Integer value4, java.lang.String value5, java.lang.Byte value6, java.lang.Byte value7, java.sql.Timestamp value8, java.sql.Timestamp value9) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountThankTransactionsRecord + */ + public AccountThankTransactionsRecord() { + super(mineplex.database.tables.AccountThankTransactions.accountThankTransactions); + } + + /** + * Create a detached, initialised AccountThankTransactionsRecord + */ + public AccountThankTransactionsRecord(java.lang.Integer id, java.lang.Integer receiverId, java.lang.Integer senderId, java.lang.Integer thankAmount, java.lang.String reason, java.lang.Byte ignoreCooldown, java.lang.Byte claimed, java.sql.Timestamp sentTime, java.sql.Timestamp claimTime) { + super(mineplex.database.tables.AccountThankTransactions.accountThankTransactions); + + setValue(0, id); + setValue(1, receiverId); + setValue(2, senderId); + setValue(3, thankAmount); + setValue(4, reason); + setValue(5, ignoreCooldown); + setValue(6, claimed); + setValue(7, sentTime); + setValue(8, claimTime); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java new file mode 100644 index 000000000..c71003242 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountWebsiteLinkCodeRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountWebsiteLinkCodeRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = -505757434; + + /** + * Setter for Account.accountWebsiteLinkCode.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountWebsiteLinkCode.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountWebsiteLinkCode.confirmationCode. + */ + public void setConfirmationCode(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.accountWebsiteLinkCode.confirmationCode. + */ + public java.lang.String getConfirmationCode() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.accountWebsiteLinkCode.date. + */ + public void setDate(java.sql.Timestamp value) { + setValue(2, value); + } + + /** + * Getter for Account.accountWebsiteLinkCode.date. + */ + public java.sql.Timestamp getDate() { + return (java.sql.Timestamp) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.confirmationCode; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode.date; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getConfirmationCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Timestamp value3() { + return getDate(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord value2(java.lang.String value) { + setConfirmationCode(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord value3(java.sql.Timestamp value) { + setDate(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountWebsiteLinkCodeRecord values(java.lang.Integer value1, java.lang.String value2, java.sql.Timestamp value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountWebsiteLinkCodeRecord + */ + public AccountWebsiteLinkCodeRecord() { + super(mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode); + } + + /** + * Create a detached, initialised AccountWebsiteLinkCodeRecord + */ + public AccountWebsiteLinkCodeRecord(java.lang.Integer accountId, java.lang.String confirmationCode, java.sql.Timestamp date) { + super(mineplex.database.tables.AccountWebsiteLinkCode.accountWebsiteLinkCode); + + setValue(0, accountId); + setValue(1, confirmationCode); + setValue(2, date); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java new file mode 100644 index 000000000..5ae2da306 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClanBannersRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClanBannersRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = 830973431; + + /** + * Setter for Account.clanBanners.clanId. + */ + public void setClanId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.clanBanners.clanId. + */ + public java.lang.Integer getClanId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.clanBanners.baseColor. + */ + public void setBaseColor(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.clanBanners.baseColor. + */ + public java.lang.String getBaseColor() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.clanBanners.patterns. + */ + public void setPatterns(java.lang.String value) { + setValue(2, value); + } + + /** + * Getter for Account.clanBanners.patterns. + */ + public java.lang.String getPatterns() { + return (java.lang.String) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.ClanBanners.clanBanners.clanId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.ClanBanners.clanBanners.baseColor; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.ClanBanners.clanBanners.patterns; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getClanId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getBaseColor(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value3() { + return getPatterns(); + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord value1(java.lang.Integer value) { + setClanId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord value2(java.lang.String value) { + setBaseColor(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord value3(java.lang.String value) { + setPatterns(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClanBannersRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ClanBannersRecord + */ + public ClanBannersRecord() { + super(mineplex.database.tables.ClanBanners.clanBanners); + } + + /** + * Create a detached, initialised ClanBannersRecord + */ + public ClanBannersRecord(java.lang.Integer clanId, java.lang.String baseColor, java.lang.String patterns) { + super(mineplex.database.tables.ClanBanners.clanBanners); + + setValue(0, clanId); + setValue(1, baseColor); + setValue(2, patterns); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java new file mode 100644 index 000000000..3f693103c --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansGoldRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansGoldRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = -90641108; + + /** + * Setter for Account.clansGold.serverId. + */ + public void setServerId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.clansGold.serverId. + */ + public java.lang.Integer getServerId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.clansGold.id. + */ + public void setId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.clansGold.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.clansGold.gold. + */ + public void setGold(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.clansGold.gold. + */ + public java.lang.Integer getGold() { + return (java.lang.Integer) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.ClansGold.clansGold.serverId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.ClansGold.clansGold.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.ClansGold.clansGold.gold; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getServerId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getGold(); + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord value1(java.lang.Integer value) { + setServerId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord value2(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord value3(java.lang.Integer value) { + setGold(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansGoldRecord values(java.lang.Integer value1, java.lang.Integer value2, java.lang.Integer value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ClansGoldRecord + */ + public ClansGoldRecord() { + super(mineplex.database.tables.ClansGold.clansGold); + } + + /** + * Create a detached, initialised ClansGoldRecord + */ + public ClansGoldRecord(java.lang.Integer serverId, java.lang.Integer id, java.lang.Integer gold) { + super(mineplex.database.tables.ClansGold.clansGold); + + setValue(0, serverId); + setValue(1, id); + setValue(2, gold); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java new file mode 100644 index 000000000..018a7a89e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/ClansNetherPortalsRecord.java @@ -0,0 +1,239 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ClansNetherPortalsRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record4 { + + private static final long serialVersionUID = -1366559485; + + /** + * Setter for Account.clansNetherPortals.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.clansNetherPortals.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.clansNetherPortals.cornerOne. + */ + public void setCornerOne(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.clansNetherPortals.cornerOne. + */ + public java.lang.String getCornerOne() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.clansNetherPortals.cornerTwo. + */ + public void setCornerTwo(java.lang.String value) { + setValue(2, value); + } + + /** + * Getter for Account.clansNetherPortals.cornerTwo. + */ + public java.lang.String getCornerTwo() { + return (java.lang.String) getValue(2); + } + + /** + * Setter for Account.clansNetherPortals.returnPortal. + */ + public void setReturnPortal(java.lang.Byte value) { + setValue(3, value); + } + + /** + * Getter for Account.clansNetherPortals.returnPortal. + */ + public java.lang.Byte getReturnPortal() { + return (java.lang.Byte) getValue(3); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record4 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row4 fieldsRow() { + return (org.jooq.Row4) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row4 valuesRow() { + return (org.jooq.Row4) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.cornerOne; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.cornerTwo; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.ClansNetherPortals.clansNetherPortals.returnPortal; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getCornerOne(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value3() { + return getCornerTwo(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Byte value4() { + return getReturnPortal(); + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value2(java.lang.String value) { + setCornerOne(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value3(java.lang.String value) { + setCornerTwo(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord value4(java.lang.Byte value) { + setReturnPortal(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ClansNetherPortalsRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3, java.lang.Byte value4) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ClansNetherPortalsRecord + */ + public ClansNetherPortalsRecord() { + super(mineplex.database.tables.ClansNetherPortals.clansNetherPortals); + } + + /** + * Create a detached, initialised ClansNetherPortalsRecord + */ + public ClansNetherPortalsRecord(java.lang.Integer id, java.lang.String cornerOne, java.lang.String cornerTwo, java.lang.Byte returnPortal) { + super(mineplex.database.tables.ClansNetherPortals.clansNetherPortals); + + setValue(0, id); + setValue(1, cornerOne); + setValue(2, cornerTwo); + setValue(3, returnPortal); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java deleted file mode 100644 index b38e32b8c..000000000 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/Kit_progressionRecord.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * This class is generated by jOOQ - */ -package mineplex.database.tables.records; - -/** - * This class is generated by jOOQ. - */ -@javax.annotation.Generated( - value = { - "http://www.jooq.org", - "jOOQ version:3.5.2" - }, - comments = "This class is generated by jOOQ" -) -@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class Kit_progressionRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record6 { - - private static final long serialVersionUID = 1893691977; - - /** - * Setter for Account.kit_progression.account_id. - */ - public void setAccount_id(java.lang.Integer value) { - setValue(0, value); - } - - /** - * Getter for Account.kit_progression.account_id. - */ - public java.lang.Integer getAccount_id() { - return (java.lang.Integer) getValue(0); - } - - /** - * Setter for Account.kit_progression.kit_id. - */ - public void setKit_id(java.lang.String value) { - setValue(1, value); - } - - /** - * Getter for Account.kit_progression.kit_id. - */ - public java.lang.String getKit_id() { - return (java.lang.String) getValue(1); - } - - /** - * Setter for Account.kit_progression.level. - */ - public void setLevel(java.lang.Integer value) { - setValue(2, value); - } - - /** - * Getter for Account.kit_progression.level. - */ - public java.lang.Integer getLevel() { - return (java.lang.Integer) getValue(2); - } - - /** - * Setter for Account.kit_progression.xp. - */ - public void setXp(java.lang.Integer value) { - setValue(3, value); - } - - /** - * Getter for Account.kit_progression.xp. - */ - public java.lang.Integer getXp() { - return (java.lang.Integer) getValue(3); - } - - /** - * Setter for Account.kit_progression.upgrade_level. - */ - public void setUpgrade_level(java.lang.Integer value) { - setValue(4, value); - } - - /** - * Getter for Account.kit_progression.upgrade_level. - */ - public java.lang.Integer getUpgrade_level() { - return (java.lang.Integer) getValue(4); - } - - /** - * Setter for Account.kit_progression.default. - */ - public void setDefault(java.lang.Byte value) { - setValue(5, value); - } - - /** - * Getter for Account.kit_progression.default. - */ - public java.lang.Byte getDefault() { - return (java.lang.Byte) getValue(5); - } - - // ------------------------------------------------------------------------- - // Primary key information - // ------------------------------------------------------------------------- - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Record2 key() { - return (org.jooq.Record2) super.key(); - } - - // ------------------------------------------------------------------------- - // Record6 type implementation - // ------------------------------------------------------------------------- - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Row6 fieldsRow() { - return (org.jooq.Row6) super.fieldsRow(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Row6 valuesRow() { - return (org.jooq.Row6) super.valuesRow(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field1() { - return mineplex.database.tables.Kit_progression.kit_progression.account_id; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field2() { - return mineplex.database.tables.Kit_progression.kit_progression.kit_id; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field3() { - return mineplex.database.tables.Kit_progression.kit_progression.level; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field4() { - return mineplex.database.tables.Kit_progression.kit_progression.xp; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field5() { - return mineplex.database.tables.Kit_progression.kit_progression.upgrade_level; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field6() { - return mineplex.database.tables.Kit_progression.kit_progression.default_; - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value1() { - return getAccount_id(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.String value2() { - return getKit_id(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value3() { - return getLevel(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value4() { - return getXp(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value5() { - return getUpgrade_level(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Byte value6() { - return getDefault(); - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value1(java.lang.Integer value) { - setAccount_id(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value2(java.lang.String value) { - setKit_id(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value3(java.lang.Integer value) { - setLevel(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value4(java.lang.Integer value) { - setXp(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value5(java.lang.Integer value) { - setUpgrade_level(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord value6(java.lang.Byte value) { - setDefault(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Kit_progressionRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.Integer value3, java.lang.Integer value4, java.lang.Integer value5, java.lang.Byte value6) { - return this; - } - - // ------------------------------------------------------------------------- - // Constructors - // ------------------------------------------------------------------------- - - /** - * Create a detached Kit_progressionRecord - */ - public Kit_progressionRecord() { - super(mineplex.database.tables.Kit_progression.kit_progression); - } - - /** - * Create a detached, initialised Kit_progressionRecord - */ - public Kit_progressionRecord(java.lang.Integer account_id, java.lang.String kit_id, java.lang.Integer level, java.lang.Integer xp, java.lang.Integer upgrade_level, java.lang.Byte default_) { - super(mineplex.database.tables.Kit_progression.kit_progression); - - setValue(0, account_id); - setValue(1, kit_id); - setValue(2, level); - setValue(3, xp); - setValue(4, upgrade_level); - setValue(5, default_); - } -} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java new file mode 100644 index 000000000..1c1396a12 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/NonPremiumJoinMessageRecord.java @@ -0,0 +1,107 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class NonPremiumJoinMessageRecord extends org.jooq.impl.TableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record1 { + + private static final long serialVersionUID = 988609111; + + /** + * Setter for Account.nonPremiumJoinMessage.message. + */ + public void setMessage(java.lang.String value) { + setValue(0, value); + } + + /** + * Getter for Account.nonPremiumJoinMessage.message. + */ + public java.lang.String getMessage() { + return (java.lang.String) getValue(0); + } + + // ------------------------------------------------------------------------- + // Record1 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row1 fieldsRow() { + return (org.jooq.Row1) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row1 valuesRow() { + return (org.jooq.Row1) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage.message; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value1() { + return getMessage(); + } + + /** + * {@inheritDoc} + */ + @Override + public NonPremiumJoinMessageRecord value1(java.lang.String value) { + setMessage(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public NonPremiumJoinMessageRecord values(java.lang.String value1) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached NonPremiumJoinMessageRecord + */ + public NonPremiumJoinMessageRecord() { + super(mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage); + } + + /** + * Create a detached, initialised NonPremiumJoinMessageRecord + */ + public NonPremiumJoinMessageRecord(java.lang.String message) { + super(mineplex.database.tables.NonPremiumJoinMessage.nonPremiumJoinMessage); + + setValue(0, message); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java new file mode 100644 index 000000000..cea0382f0 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/PowerPlayClubRecord.java @@ -0,0 +1,199 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class PowerPlayClubRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { + + private static final long serialVersionUID = 1651396391; + + /** + * Setter for Account.powerPlayClub.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.powerPlayClub.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.powerPlayClub.kvKey. + */ + public void setKvKey(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.powerPlayClub.kvKey. + */ + public java.lang.String getKvKey() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.powerPlayClub.kvValue. + */ + public void setKvValue(java.lang.Integer value) { + setValue(2, value); + } + + /** + * Getter for Account.powerPlayClub.kvValue. + */ + public java.lang.Integer getKvValue() { + return (java.lang.Integer) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.PowerPlayClub.powerPlayClub.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.PowerPlayClub.powerPlayClub.kvKey; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.PowerPlayClub.powerPlayClub.kvValue; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getKvKey(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value3() { + return getKvValue(); + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord value2(java.lang.String value) { + setKvKey(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord value3(java.lang.Integer value) { + setKvValue(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PowerPlayClubRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.Integer value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached PowerPlayClubRecord + */ + public PowerPlayClubRecord() { + super(mineplex.database.tables.PowerPlayClub.powerPlayClub); + } + + /** + * Create a detached, initialised PowerPlayClubRecord + */ + public PowerPlayClubRecord(java.lang.Integer accountId, java.lang.String kvKey, java.lang.Integer kvValue) { + super(mineplex.database.tables.PowerPlayClub.powerPlayClub); + + setValue(0, accountId); + setValue(1, kvKey); + setValue(2, kvValue); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java new file mode 100644 index 000000000..591491a4e --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/UnicodereplacerRecord.java @@ -0,0 +1,279 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UnicodereplacerRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record5 { + + private static final long serialVersionUID = -155015394; + + /** + * Setter for Account.unicodereplacer.id. + */ + public void setId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.unicodereplacer.id. + */ + public java.lang.Integer getId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.unicodereplacer.unicode. + */ + public void setUnicode(java.lang.String value) { + setValue(1, value); + } + + /** + * Getter for Account.unicodereplacer.unicode. + */ + public java.lang.String getUnicode() { + return (java.lang.String) getValue(1); + } + + /** + * Setter for Account.unicodereplacer.replacement. + */ + public void setReplacement(java.lang.String value) { + setValue(2, value); + } + + /** + * Getter for Account.unicodereplacer.replacement. + */ + public java.lang.String getReplacement() { + return (java.lang.String) getValue(2); + } + + /** + * Setter for Account.unicodereplacer.created_by. + */ + public void setCreated_by(java.lang.String value) { + setValue(3, value); + } + + /** + * Getter for Account.unicodereplacer.created_by. + */ + public java.lang.String getCreated_by() { + return (java.lang.String) getValue(3); + } + + /** + * Setter for Account.unicodereplacer.removed_by. + */ + public void setRemoved_by(java.lang.String value) { + setValue(4, value); + } + + /** + * Getter for Account.unicodereplacer.removed_by. + */ + public java.lang.String getRemoved_by() { + return (java.lang.String) getValue(4); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record5 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row5 fieldsRow() { + return (org.jooq.Row5) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row5 valuesRow() { + return (org.jooq.Row5) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.id; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.unicode; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.replacement; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field4() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.created_by; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field5() { + return mineplex.database.tables.Unicodereplacer.unicodereplacer.removed_by; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value2() { + return getUnicode(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value3() { + return getReplacement(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value4() { + return getCreated_by(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.String value5() { + return getRemoved_by(); + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value1(java.lang.Integer value) { + setId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value2(java.lang.String value) { + setUnicode(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value3(java.lang.String value) { + setReplacement(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value4(java.lang.String value) { + setCreated_by(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord value5(java.lang.String value) { + setRemoved_by(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public UnicodereplacerRecord values(java.lang.Integer value1, java.lang.String value2, java.lang.String value3, java.lang.String value4, java.lang.String value5) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached UnicodereplacerRecord + */ + public UnicodereplacerRecord() { + super(mineplex.database.tables.Unicodereplacer.unicodereplacer); + } + + /** + * Create a detached, initialised UnicodereplacerRecord + */ + public UnicodereplacerRecord(java.lang.Integer id, java.lang.String unicode, java.lang.String replacement, java.lang.String created_by, java.lang.String removed_by) { + super(mineplex.database.tables.Unicodereplacer.unicodereplacer); + + setValue(0, id); + setValue(1, unicode); + setValue(2, replacement); + setValue(3, created_by); + setValue(4, removed_by); + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java new file mode 100644 index 000000000..13fc1242f --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/YoutubeRecord.java @@ -0,0 +1,159 @@ +/** + * This class is generated by jOOQ + */ +package mineplex.database.tables.records; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class YoutubeRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record2 { + + private static final long serialVersionUID = -581486771; + + /** + * Setter for Account.youtube.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.youtube.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.youtube.clicktime. + */ + public void setClicktime(java.sql.Date value) { + setValue(1, value); + } + + /** + * Getter for Account.youtube.clicktime. + */ + public java.sql.Date getClicktime() { + return (java.sql.Date) getValue(1); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record1 key() { + return (org.jooq.Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record2 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 fieldsRow() { + return (org.jooq.Row2) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row2 valuesRow() { + return (org.jooq.Row2) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.Youtube.youtube.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.Youtube.youtube.clicktime; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.sql.Date value2() { + return getClicktime(); + } + + /** + * {@inheritDoc} + */ + @Override + public YoutubeRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public YoutubeRecord value2(java.sql.Date value) { + setClicktime(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public YoutubeRecord values(java.lang.Integer value1, java.sql.Date value2) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached YoutubeRecord + */ + public YoutubeRecord() { + super(mineplex.database.tables.Youtube.youtube); + } + + /** + * Create a detached, initialised YoutubeRecord + */ + public YoutubeRecord(java.lang.Integer accountId, java.sql.Date clicktime) { + super(mineplex.database.tables.Youtube.youtube); + + setValue(0, accountId); + setValue(1, clicktime); + } +} diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 3c569acb1..e0296c21b 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -1,24 +1,10 @@ package mineplex.enjinTranslator; -import java.text.SimpleDateFormat; -import java.util.AbstractMap; -import java.util.Date; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.UUID; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UUIDFetcher; @@ -28,6 +14,19 @@ import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.enjinTranslator.purchase.PurchaseManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import java.text.SimpleDateFormat; +import java.util.AbstractMap; +import java.util.Date; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.UUID; public class Enjin extends MiniPlugin implements CommandExecutor { @@ -86,31 +85,23 @@ public class Enjin extends MiniPlugin implements CommandExecutor { final String name = args[1]; - _clientManager.loadClientByName(name, new Runnable() + _clientManager.loadClientByName(name, client -> { - public void run() + if (client == null) { - final CoreClient client = _clientManager.Get(name); - - if (client == null) - { - System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", isn't in our database."); - } + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", isn't in our database."); + } + else + { + UUID uuid = null; + + if (_cachedUUIDs.containsKey(name)) + uuid = _cachedUUIDs.get(name).getKey(); else { - UUID uuid = null; - - if (_cachedUUIDs.containsKey(name)) - uuid = _cachedUUIDs.get(name).getKey(); - else - { - // Fails if not in DB and if duplicate. - uuid = _clientManager.loadUUIDFromDB(name); - - if (uuid == null) - uuid = UUIDFetcher.getUUIDOf(name); - } - + // Fails if not in DB and if duplicate. + uuid = _clientManager.loadUUIDFromDB(name); + if (uuid == null) { System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID."); @@ -120,23 +111,26 @@ public class Enjin extends MiniPlugin implements CommandExecutor final UUID playerUUID = uuid; _cachedUUIDs.put(name, new AbstractMap.SimpleEntry(playerUUID, System.currentTimeMillis() + 240000)); - - if (!checkForBoosterPurchase(args, name, playerUUID, client)) + + if (!checkForClansPurchase(args, name, client)) { - if (!checkForCoinPurchase(args, name, playerUUID, client)) + if (!checkForBoosterPurchase(args, name, playerUUID, client)) { - if (!checkForRankPurchase(args, name, playerUUID, client)) + if (!checkForCoinPurchase(args, name, playerUUID, client)) { - if (!checkForPurchase(args, name, client)) + if (!checkForRankPurchase(args, name, playerUUID, client)) { - StringBuilder sb = new StringBuilder(); - - for (String arg : args) + if (!checkForPurchase(args, name, client)) { - sb.append(arg + " "); - } + StringBuilder sb = new StringBuilder(); - System.out.println("Received Command : " + sb.toString()); + for (String arg : args) + { + sb.append(arg + " "); + } + + System.out.println("Received Command : " + sb.toString()); + } } } } @@ -167,32 +161,23 @@ public class Enjin extends MiniPlugin implements CommandExecutor protected boolean checkForRankPurchase(String[] args, final String name, final UUID playerUUID, final CoreClient client) { if (args.length != 4 || !args[0].equalsIgnoreCase("rank")) - return false;; + return false; final Rank rank = mineplex.core.common.Rank.valueOf(args[2]); final boolean perm = Boolean.parseBoolean(args[3]); - _clientManager.loadClientByName(name, new Runnable() + _clientManager.loadClientByName(name, loadedClient -> { - public void run() + if (rank == Rank.ALL || loadedClient.GetRank() == Rank.ALL || !loadedClient.GetRank().has(rank) || loadedClient.GetRank() == rank) { - if (rank == Rank.ALL || _clientManager.Get(name).GetRank() == Rank.ALL || !_clientManager.Get(name).GetRank().has(rank) || _clientManager.Get(name).GetRank() == rank) - { - _clientManager.SaveRank(new Callback() - { - public void run(Rank data) - { - _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, data == rank); - } - }, name, playerUUID, rank, perm); - - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month.")); - } - else - { - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month.")); - _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, false); - } + _clientManager.SaveRank(data -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, data == rank), name, playerUUID, rank, perm); + + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month.")); + } + else + { + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month.")); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, false); } }); @@ -243,7 +228,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, amount, data == TransactionResponse.Success); } } - }, name, client.getAccountId(), amount == 1 ? packageName : packageName + " " + amount, CurrencyType.GEM, 0, false); + }, name, client.getAccountId(), amount == 1 ? packageName : packageName + " " + amount, GlobalCurrency.GEM, 0, false); return true; } @@ -293,4 +278,71 @@ public class Enjin extends MiniPlugin implements CommandExecutor return true; } + + protected boolean checkForClansPurchase(String[] args, final String name, final CoreClient client) + { + if (args.length >= 3 && args[0].equalsIgnoreCase("clansBanner")) + { + String purchase = "Clan Banner Usage"; + if (args[2].equalsIgnoreCase("true")) + { + purchase = "Clan Banner Editor"; + } + final String packageName = purchase; + + _donationManager.PurchaseUnknownSalesPackage(new Callback() + { + public void run(TransactionResponse data) + { + if (data == TransactionResponse.Success) + { + _inventoryManager.addItemToInventoryForOffline(new Callback() + { + public void run(Boolean success) + { + if (success) + { + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, true); + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received their " + packageName + " access."); + } + else + { + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + packageName + ". Queuing for run later."); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, false); + } + } + }, client.getAccountId(), packageName, 1); + } + else + { + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " 1" + ". Queuing for run later."); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, data == TransactionResponse.Success); + } + } + }, name, client.getAccountId(), packageName, GlobalCurrency.GEM, 0, false); + //enjin_mineplex clansBanner AlexTheCoder true + return true; + } + if (args.length >= 4 && args[0].equalsIgnoreCase("clansAmplifier")) + { + //enjin_mineplex clansAmplifier AlexTheCoder 20 1 + final String item = "Rune Amplifier " + args[2]; + final int amount = Integer.parseInt(args[3]); + + _inventoryManager.addItemToInventoryForOffline(new Callback() + { + public void run (Boolean response) + { + if (response) + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " rune amplifiers."); + else + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " rune amplifiers. Queuing for run later."); + + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), item, amount, response); + } + }, client.getAccountId(), item, amount); + } + + return false; + } } diff --git a/Plugins/Mineplex.Game.Clans/plugin.yml b/Plugins/Mineplex.Game.Clans/plugin.yml index 7365566e7..0d9f0bb90 100644 --- a/Plugins/Mineplex.Game.Clans/plugin.yml +++ b/Plugins/Mineplex.Game.Clans/plugin.yml @@ -1,3 +1,4 @@ name: Clans main: mineplex.game.clans.Clans -version: 0.1 \ No newline at end of file +version: 1.0 +loadbefore: [MineplexAnticheat] \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 6895d2741..1f4f4189c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,25 +1,20 @@ package mineplex.game.clans; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; -import mineplex.core.chatsnap.SnapshotManager; -import mineplex.core.chatsnap.SnapshotPlugin; -import mineplex.core.chatsnap.publishing.SnapshotPublisher; import mineplex.core.command.CommandCenter; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Pair; import mineplex.core.common.events.ServerShutdownEvent; +import mineplex.core.creature.Creature; import mineplex.core.delayedtask.DelayedTask; +import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.explosion.Explosion; @@ -39,8 +34,6 @@ import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; -import mineplex.core.report.ReportManager; -import mineplex.core.report.ReportPlugin; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.spawn.Spawn; @@ -60,10 +53,18 @@ import mineplex.game.clans.shop.pvp.PvpShop; import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.world.WorldManager; import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; + +import static mineplex.core.Managers.require; public class Clans extends JavaPlugin { - public static final String VERSION = "Beta 1.0"; + public static final String MAP = "Map 1"; private String WEB_CONFIG = "webServer"; // Modules @@ -74,11 +75,13 @@ public class Clans extends JavaPlugin @Override public void onEnable() { + Bukkit.setSpawnRadius(0); + // Configs getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); saveConfig(); - + String webServerAddress = getConfig().getString(WEB_CONFIG); // Logger.initialize(this); @@ -101,10 +104,10 @@ public class Clans extends JavaPlugin new FallingBlocks(this); new ServerConfiguration(this, _clientManager); - - PacketHandler packetHandler = new PacketHandler(this); + + PacketHandler packetHandler = require(PacketHandler.class); IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager); incognito.setPreferencesManager(preferenceManager); @@ -117,12 +120,92 @@ public class Clans extends JavaPlugin Teleport teleport = new Teleport(this, _clientManager); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - + ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); - + Punish punish = new Punish(this, webServerAddress, _clientManager); - AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); - AntiHack.Instance.setKick(false); + + DisguiseManager disguiseManager = require(DisguiseManager.class); + Creature creature = new Creature(this); + + AntiHack antiHack = require(AntiHack.class); + antiHack.setKick(false); + Bukkit.getScheduler().runTask(this, antiHack::enableNewAnticheat); + + { + // West Shop + int maxX = -385; + int minX = -462; + int maxY = 100; + int minY = 90; + int maxZ = 46; + int minZ = -30; + Location spawn = new Location(Bukkit.getWorld("world"), -422, 95, 8); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // East Shop + int maxX = 385; + int minX = -463; + int maxY = 100; + int minY = 90; + int maxZ = 31; + int minZ = -46; + Location spawn = new Location(Bukkit.getWorld("world"), 424, 95, -8); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // North Spawn + int maxX = 25; + int minX = -8; + int maxY = 215; + int minY = 205; + int maxZ = -376; + int minZ = -410; + Location spawn = new Location(Bukkit.getWorld("world"), 9, 210, -393); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // South Spawn + int maxX = 25; + int minX = -8; + int maxY = 215; + int minY = 205; + int maxZ = 407; + int minZ = 373; + Location spawn = new Location(Bukkit.getWorld("world"), 8, 210, 390); + for (int i = 0; i < 10; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } + + { + // Fields + int maxX = 50; + int minX = -60; + int maxY = 110; + int minY = 100; + int maxZ = 70; + int minZ = -70; + Location spawn = new Location(Bukkit.getWorld("world"), 0, 100, 0); + for (int i = 0; i < 40; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); + } + } BlockRestore blockRestore = new BlockRestore(this); @@ -137,7 +220,7 @@ public class Clans extends JavaPlugin new MemoryFix(this); new FoodDupeFix(this); new Explosion(this, blockRestore); - new InventoryManager(this, _clientManager); + InventoryManager inventory = new InventoryManager(this, _clientManager); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); resourcePackManager.setResourcePack(new Pair[] { @@ -154,7 +237,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); @@ -170,10 +253,10 @@ public class Clans extends JavaPlugin // Disable item merging ((CraftWorld) world).getHandle().spigotConfig.itemMerge = 0; } - + //Updates new Updater(this); - + MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); } @@ -201,8 +284,8 @@ public class Clans extends JavaPlugin getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } - public static String version() + public static String getMap() { - return VERSION; + return MAP; } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index f7df176ea..a07074f98 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -363,9 +363,6 @@ public class ClanInfo } stringList.add(F.value("Members", members)); - // Protected - stringList.add(F.value("TNT Protection", getProtected())); - return stringList; } @@ -506,25 +503,6 @@ public class ClanInfo return isOnlineNow(); } - public String getProtected() - { - for (ClansPlayer cur : getMembers().values()) - if (cur.isOnline()) - return C.cRed + "No - Clan Members are Online"; - - if (UtilTime.elapsed(_lastOnline.getTime(), Clans.getOnlineTime())) - return C.cGreen + "Yes - Clan Members are Offline"; - - return C.cGold - + "No, " - + UtilTime.convertString(Clans.getOnlineTime() - (System.currentTimeMillis() - _lastOnline.getTime()), 1, - TimeUnit.FIT) + " to Protection"; - } - - public boolean isProtected() { - return getProtected().startsWith(C.cGreen + "Yes"); - } - public TntGenerator getGenerator() { return _generator; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 4f2c6e166..c89a9ff9d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -1,24 +1,24 @@ package mineplex.game.clans.clans; -import java.util.LinkedList; - -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import net.minecraft.server.v1_8_R3.EnumDirection; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.LinkedList; public class ClanTips extends MiniPlugin { @@ -44,7 +44,7 @@ public class ClanTips extends MiniPlugin final Player player = event.getPlayer(); final String newTerritory = event.getNewTerritory(); - if (_preferences.Get(player).ClanTips) + if (_preferences.get(player).isActive(Preference.CLAN_TIPS)) { if (newTerritory.equals("Fields")) { @@ -113,7 +113,7 @@ public class ClanTips extends MiniPlugin return; } - if (!_preferences.Get(player).ClanTips && !tip._ignorePreferences) + if (!_preferences.get(player).isActive(Preference.CLAN_TIPS) && !tip._ignorePreferences) { return; } @@ -191,14 +191,14 @@ public class ClanTips extends MiniPlugin new String[] { C.cDAquaB + "Lost War Point", C.cAqua + "You were killed by another Clan and they have gained 1 War Point against you.", - C.cAqua + "If your War Points with them reaches -20, they will get to invade your Territory, giving them full access for 15 minutes." + C.cAqua + "If your War Points with them reaches -25, they will get to besiege your Territory, giving them access to cannon it for 30 minutes." }), DOMINANCE_NOOICE( new String[] { C.cDAquaB + "Gained War Point", C.cAqua + "You killed someone in another Clan and you have gained 1 War Point against them.", - C.cAqua + "If your War Points with them reaches +20, you will get to invade their Territory, giving you full access for 15 minutes." + C.cAqua + "If your War Points with them reaches +25, you will get to besiege their Territory, giving you access to cannon it for 30 minutes." }), ENERGY( @@ -226,8 +226,8 @@ public class ClanTips extends MiniPlugin }), ENTER_NETHER( new String[] { - C.cDAqua + "The Nether", - C.cAqua + "Welcome to the Nether. This is a very scary place full of fire and is a place for people to battle to the death! TODO: Write something better about the nether here" + C.cDRedB + "The Nether", + C.cRed + "The Nether is a dangerous place full of powerful mobs and hazardous terrain! However, the mobs here drop powerful Ancient Runes, which can be used to strengthen your gear, making your clan even more fearsome than before!" }), ; @@ -242,7 +242,7 @@ public class ClanTips extends MiniPlugin TipType(String[] messages, boolean ignorePreferences) { - _messages = new LinkedList(); + _messages = new LinkedList<>(); for (String message : messages) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 4f0017ea9..3b8c45896 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -1,12 +1,7 @@ package mineplex.game.clans.clans; -import java.sql.ResultSet; -import java.sql.SQLException; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -17,7 +12,9 @@ import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.war.ClanWarData; -import mineplex.serverdata.database.ResultSetCallable; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; public class ClansAdmin { @@ -341,19 +338,80 @@ public class ClansAdmin { ClanWarData war = clan.getWarData(clanAgainst); -// war.set -// -// Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> { -// UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); -// }); + if (war != null) + { + war.set(clan.getName(), war.getClanAPoints() - value); + + Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + }); + } + else + { + UtilPlayer.message(caller, F.main("Clans Admin", "There is no war between those two clans!")); + return; + } } else if (operation.equalsIgnoreCase("set")) { + ClanWarData war = clan.getWarData(clanAgainst); + if (war != null) + { + war.set(clanAgainst.getName(), value); + + Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + }); + } + else + { + Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback() + { + @Override + public void run(ClanWarData data) + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + } + }); + } } else if (operation.equalsIgnoreCase("add")) { + ClanWarData war = clan.getWarData(clanAgainst); + if (war != null) + { + war.set(clanAgainst.getName(), war.getClanAPoints() + value); + + Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + }); + } + else + { + Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback() + { + @Override + public void run(ClanWarData data) + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + } + }); + } } else { @@ -709,13 +767,7 @@ public class ClansAdmin ClanInfo clientClan = getMimic(caller, true); if (clientClan == null) - return; - - if (clientClan.getClaims() >= clientClan.getClaimsMax()) - { - UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan cannot claim more Territory.")); return; - } String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); @@ -730,8 +782,12 @@ public class ClansAdmin //Task Clans.getClanDataAccess().claim(clientClan.getName(), chunk, caller.getName(), false); - + //Inform + if (clientClan.getClaims() >= clientClan.getClaimsMax()) + { + UtilPlayer.message(caller, F.main("Clans Admin", "You have claimed for that clan past their normal limit.")); + } UtilPlayer.message(caller, F.main("Clans Admin", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clientClan.inform(caller.getName() + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java deleted file mode 100644 index a669ca6f4..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package mineplex.game.clans.clans; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerJoinEvent; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.task.TaskManager; -import mineplex.game.clans.Clans; - -public class ClansBetaManager extends MiniPlugin -{ - public ClansBetaManager(ClansManager manager, TaskManager taskManager) - { - super("Clans Beta", manager.getPlugin()); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onPlayerJoin(final PlayerJoinEvent event) - { - UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans " + Clans.VERSION); - - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 7ec9d898a..c7dbf9104 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -1,17 +1,19 @@ package mineplex.game.clans.clans; import java.sql.Timestamp; -import java.util.Arrays; import java.util.Iterator; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World.Environment; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -22,18 +24,25 @@ import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestoreData; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -45,15 +54,19 @@ import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.siege.weapon.projectile.event.CraterExplodeEvent; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ClansGame extends MiniPlugin { + private static final int CLICKS_TO_OPEN_TRAPPED = 10; private ClansManager _clans; public ClansGame(JavaPlugin plugin, ClansManager clans) @@ -61,6 +74,46 @@ public class ClansGame extends MiniPlugin super("Clans Game", plugin); _clans = clans; + setupSafes(); + } + + private void setupSafes() + { + Iterator it = Bukkit.getServer().recipeIterator(); + while (it.hasNext()) + { + Recipe recipe = it.next(); + if (recipe != null && recipe.getResult().getType() == Material.TRAPPED_CHEST) + { + it.remove(); + } + } + + ShapedRecipe safe = new ShapedRecipe(new ItemBuilder(Material.TRAPPED_CHEST).setAmount(1).setTitle(C.cDGray + "Safe").build()) + .shape(new String[] {"III", "ICI", "III"}) + .setIngredient('I', Material.IRON_INGOT) + .setIngredient('C', Material.CHEST); + + Bukkit.addRecipe(safe); + } + + public static boolean isDupedFromClassShop(ItemStack item) + { + if (item == null || item.getType() == Material.AIR) + { + return false; + } + if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) + { + return false; + } + String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).toUpperCase(); + if (name.contains("APPLY DEFAULT BUILD") || name.contains("APPLY BUILD") || name.contains("EDIT BUILD") || name.contains("DELETE BUILD")) + { + return true; + } + + return false; } @EventHandler(ignoreCancelled = true) @@ -78,6 +131,11 @@ public class ClansGame extends MiniPlugin } } + @EventHandler + public void onEnchant(EnchantItemEvent event) + { + event.setCancelled(true); + } @EventHandler(priority = EventPriority.LOW) public void BlockBurn(BlockBurnEvent event) @@ -96,9 +154,44 @@ public class ClansGame extends MiniPlugin { if (event.isCancelled()) return; - if (event.getBlock().getType() != Material.LADDER) return; + if (isDupedFromClassShop(event.getItemInHand())) + { + event.setCancelled(true); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + { + UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getPlayer().getName() + " just tried to use a duped item/block!"); + } + } + final int slot = event.getPlayer().getInventory().getHeldItemSlot(); + ClansManager.getInstance().runSyncLater(() -> + { + event.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR)); + event.getPlayer().updateInventory(); + }, 1L); + + return; + } - if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) return; + if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) + { + if (_clans.getClanUtility().getOwner(event.getBlock().getLocation()) != null) + { + if (event.getBlock().getType() == Material.HOPPER && (event.getBlock().getRelative(BlockFace.UP).getType() == Material.CHEST || event.getBlock().getRelative(BlockFace.UP).getType() == Material.TRAPPED_CHEST)) + { + if (_clans.getClanUtility().getRole(event.getPlayer()) == ClanRole.RECRUIT) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "Recruits cannot siphon items out of chests with a hopper!")); + event.setCancelled(true); + } + } + } + + return; + } + + if (event.getBlock().getType() != Material.LADDER) return; final Block block = event.getBlock(); @@ -230,10 +323,41 @@ public class ClansGame extends MiniPlugin return; } - if (_clans.getWarManager().allowFromInvade(event.getBlock().getLocation(), event.getPlayer())) + if (_clans.getClan(event.getPlayer()) != null && _clans.getClanUtility().isClaimed(event.getBlock().getLocation())) { - // Allow because of invasion - return; + if (_clans.getWarManager().isBeingBesiegedBy(_clans.getClanUtility().getOwner(event.getBlock().getLocation()), _clans.getClan(event.getPlayer()))) + { + if (event.getBlock().getType() == Material.CHEST) + { + return; + } + if (event.getBlock().getType() == Material.TRAPPED_CHEST) + { + if (Recharge.Instance.use(event.getPlayer(), "Chest Crack", 1000, true, false)) + { + int clicksRemain = CLICKS_TO_OPEN_TRAPPED; + if (event.getBlock().hasMetadata("CLICKS - " + event.getPlayer().getName())) + { + clicksRemain = event.getBlock().getMetadata("CLICKS - " + event.getPlayer().getName()).get(0).asInt(); + event.getBlock().removeMetadata("CLICKS - " + event.getPlayer().getName(), _clans.getPlugin()); + } + + clicksRemain--; + if (clicksRemain > 0) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You must try to break that chest " + clicksRemain + " more times before it will yield!")); + event.getBlock().setMetadata("CLICKS - " + event.getPlayer().getName(), new FixedMetadataValue(_clans.getPlugin(), clicksRemain)); + } + else + { + return; + } + } + + event.setCancelled(true); + return; + } + } } // Disallow @@ -287,10 +411,41 @@ public class ClansGame extends MiniPlugin Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(); if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation(); - if (_clans.getWarManager().allowFromInvade(loc, event.getPlayer())) + if (_clans.getClan(player) != null && _clans.getClanUtility().isClaimed(loc)) { - // Allow because of invasion - return; + if (_clans.getWarManager().isBeingBesiegedBy(_clans.getClanUtility().getOwner(loc), _clans.getClan(player))) + { + if (loc.getBlock().getType() == Material.CHEST) + { + return; + } + if (loc.getBlock().getType() == Material.TRAPPED_CHEST) + { + if (Recharge.Instance.use(player, "Chest Crack", 1000, true, false)) + { + int clicksRemain = CLICKS_TO_OPEN_TRAPPED; + if (loc.getBlock().hasMetadata("CLICKS - " + player.getName())) + { + clicksRemain = loc.getBlock().getMetadata("CLICKS - " + player.getName()).get(0).asInt(); + loc.getBlock().removeMetadata("CLICKS - " + player.getName(), _clans.getPlugin()); + } + + clicksRemain--; + if (clicksRemain > 0) + { + UtilPlayer.message(player, F.main("Clans", "You must try to open that chest " + clicksRemain + " more times before it will yield!")); + loc.getBlock().setMetadata("CLICKS - " + player.getName(), new FixedMetadataValue(_clans.getPlugin(), clicksRemain)); + } + else + { + return; + } + } + + event.setCancelled(true); + return; + } + } } // Borderlands @@ -499,7 +654,7 @@ public class ClansGame extends MiniPlugin { ClanTerritory claim = _clans.getClanUtility().getClaim(event.getBlockPlaced().getLocation()); - if (claim != null && (claim.Owner.equals("Spawn") || claim.Owner.equals("Shops"))) + if (claim != null && (claim.Owner.equals("Spawn") || claim.Owner.equals("Shops") || claim.Owner.equals("Fields") || _clans.getClanUtility().getAccess(event.getPlayer(), event.getBlockPlaced().getLocation()) != ClanRelation.SELF)) { event.setCancelled(true); } @@ -564,17 +719,26 @@ public class ClansGame extends MiniPlugin ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation()); if (clan == null) return; - - if (_clans.getWarManager().isBeingInvaded(clan)) - { - // Allow because of invasion - return; - } - if (!clan.isProtected()) - event.setCancelled(true); - else - clan.inform(C.cRed + "Your Territory is under attack!", null); + clan.inform(C.cRed + "Your Territory is under attack!", null); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Explosion(CraterExplodeEvent event) + { + for (Block block : event.getBlocks()) + { + ClanInfo clan = _clans.getClanUtility().getOwner(block.getLocation()); + if (clan == null) + { + return; + } + + if (Recharge.Instance.use(event.getShooter(), "TNT TERRITORY ALERT", 1000, false, false)) + { + clan.inform(C.cRed + "Your Territory is under attack!", null); + } + } } @EventHandler @@ -774,4 +938,30 @@ public class ClansGame extends MiniPlugin } } } -} + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickupSafe(PlayerPickupItemEvent event) + { + Item item = event.getItem(); + ItemStack stack = item.getItemStack(); + if (stack.getType() == Material.TRAPPED_CHEST) + { + event.setCancelled(true); + item.remove(); + UtilInv.insert(event.getPlayer(), new ItemBuilder(Material.TRAPPED_CHEST).setAmount(stack.getAmount()).setTitle(C.cDGray + "Safe").build()); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickupSafe(InventoryPickupItemEvent event) + { + Item item = event.getItem(); + ItemStack stack = item.getItemStack(); + if (stack.getType() == Material.TRAPPED_CHEST) + { + event.setCancelled(true); + item.remove(); + event.getInventory().addItem(new ItemBuilder(Material.TRAPPED_CHEST).setAmount(stack.getAmount()).setTitle(C.cDGray + "Safe").build()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 08157bd5d..1d2f3fe1c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1,16 +1,60 @@ package mineplex.game.clans.clans; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.TimeZone; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.vehicle.VehicleEnterEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; + +import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.events.PlayerMessageEvent; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.creature.Creature; import mineplex.core.creature.event.CreatureSpawnCustomEvent; import mineplex.core.disguise.DisguiseManager; @@ -22,6 +66,8 @@ import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.menu.MenuManager; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -36,11 +82,19 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.ban.ClansBanManager; -import mineplex.game.clans.clans.commands.*; +import mineplex.game.clans.clans.banners.BannerManager; +import mineplex.game.clans.clans.commands.ClanManagementCommand; +import mineplex.game.clans.clans.commands.ClansAllyChatCommand; +import mineplex.game.clans.clans.commands.ClansChatCommand; +import mineplex.game.clans.clans.commands.ClansCommand; +import mineplex.game.clans.clans.commands.KillCommand; +import mineplex.game.clans.clans.commands.MapCommand; +import mineplex.game.clans.clans.commands.RegionsCommand; +import mineplex.game.clans.clans.commands.SpeedCommand; import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; @@ -75,6 +129,7 @@ import mineplex.game.clans.gameplay.HiddenChestManager; import mineplex.game.clans.gameplay.safelog.SafeLog; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.restart.RestartManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorial.TutorialManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -82,8 +137,8 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; -import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; @@ -96,30 +151,6 @@ import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.serverdata.commands.ServerCommandManager; -import net.md_5.bungee.api.ChatColor; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.*; -import org.bukkit.event.vehicle.VehicleEnterEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.util.*; public class ClansManager extends MiniClientPluginimplements IRelation { @@ -153,6 +184,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private GearManager _gearManager; private LootManager _lootManager; private DonationManager _donationManager; + private InventoryManager _inventoryManager; private NetherManager _netherManager; private DamageManager _damageManager; private SiegeManager _siegeManager; @@ -166,6 +198,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati private mineplex.game.clans.legacytutorial.TutorialManager _legacyTutorial; private ClassManager _classManager; + private BannerManager _bannerManager; + private AmplifierManager _amplifierManager; public ClassManager getClassManager() { @@ -206,21 +240,21 @@ public class ClansManager extends MiniClientPluginimplements IRelati public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; - private ClansBanManager _clansBans; + private PacketHandler _packetHandler; public ClanTips ClanTips; // Spawn area - public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager, String webServerAddress) { super("Clans Manager", plugin); _instance = this; - - _clansBans = clansBans; _punish = punish; + _packetHandler = packetHandler; + _incognitoManager = incognitoManager; _serverName = serverName; _clientManager = clientManager; @@ -233,15 +267,14 @@ public class ClansManager extends MiniClientPluginimplements IRelati _warManager = new WarManager(plugin, this); _donationManager = donationManager; + _inventoryManager = inventoryManager; _blacklist = new ClansBlacklist(plugin); - _goldManager = new GoldManager(this, _clientManager, donationManager); _gearManager = gearManager; _lootManager = new LootManager(gearManager, _goldManager); - _disguiseManager = new DisguiseManager(plugin, packetHandler); - Creature creature = new Creature(plugin); - _npcManager = new NpcManager(plugin, creature); + _disguiseManager = Managers.get(DisguiseManager.class); + _npcManager = new NpcManager(plugin, Managers.get(Creature.class)); _condition = new SkillConditionManager(plugin); _damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); _damageManager.addCommand(new KillCommand(_damageManager)); @@ -266,8 +299,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati new SupplyDropManager(plugin, this); new InvseeManager(this); - - _explosion = new Explosion(plugin, blockRestore); + new MenuManager(plugin); + + _explosion = Managers.get(Explosion.class); _warPointEvasion = new WarPointEvasion(plugin); // new ClansLoginManager(getPlugin(), clientManager, _serverName); @@ -278,7 +312,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // TODO: Re-enable customtagfix with NCP update? // new CustomTagFix(plugin, packetHandler); - new Field(plugin, creature, _condition, this, energy, serverName); + new Field(plugin, Managers.get(Creature.class), _condition, this, energy, serverName); // Required managers to be initialized new Spawn(plugin, this); @@ -289,8 +323,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati new ClanEnergyTracker(plugin, this); // new StuckManager(this); - new ClansBetaManager(this, _taskManager); - new PotatoManager(plugin, this); new Weapon(plugin, energy); @@ -346,8 +378,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); - EloManager eloManager = new EloManager(plugin, _clientManager); - AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager, incognitoManager, eloManager); + EloManager eloManager = Managers.get(EloManager.class); + AchievementManager achievementManager = Managers.get(AchievementManager.class); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); @@ -355,11 +387,15 @@ public class ClansManager extends MiniClientPluginimplements IRelati _playTracker = new Playtime(this, statsManager); - _legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler); - _scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, _tutorial, clientManager, donationManager); _clanDataAccess = new ClansDataAccessLayer(this, _scoreboard); + _bannerManager = new BannerManager(plugin); + + _goldManager = new GoldManager(this, _clientManager, donationManager, _clanDataAccess); + + _legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler); + for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { loadClan(token); @@ -413,8 +449,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Location location : welcomeHolograms) { Hologram hologram = new Hologram(hologramManager, location, - C.cGreenB + "Welcome to Clans Beta", - C.cWhite + "Please be aware there may be bugs", + C.cGreenB + "Welcome to Clans!", C.cWhite + "Type " + C.cYellow + "/clan" + C.cWhite + " to get started!" ); hologram.start(); @@ -422,7 +457,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati _siegeManager = new SiegeManager(this); -// _netherManager = new NetherManager(this); + _netherManager = new NetherManager(this); + _amplifierManager = new AmplifierManager(plugin); + + new RestartManager(plugin); } @Override @@ -450,6 +488,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (ClanTerritoryToken territoryToken : clanToken.Territories) _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); + + _bannerManager.loadBanner(clan); } public DisguiseManager getDisguiseManager() @@ -481,6 +521,16 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _donationManager; } + + public GoldManager getGoldManager() + { + return _goldManager; + } + + public InventoryManager getInventoryManager() + { + return _inventoryManager; + } public ItemMapManager getItemMapManager() { @@ -492,6 +542,21 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _explosion; } + public PacketHandler getPacketHandler() + { + return _packetHandler; + } + + public BannerManager getBannerManager() + { + return _bannerManager; + } + + public AmplifierManager getAmplifierManager() + { + return _amplifierManager; + } + public int getInviteExpire() { return _inviteExpire; @@ -602,6 +667,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void Join(PlayerJoinEvent event) { event.setJoinMessage(null); + UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans!"); if (_incognitoManager.Get(event.getPlayer()).Status) { @@ -740,7 +806,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati continue; } - UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is on version: " + F.elem(Clans.version()))); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is running Mineplex Clans version " + _plugin.getDescription().getVersion() + "!")); event.setCancelled(true); } } @@ -1000,7 +1066,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati } @Override - protected ClientClan addPlayer(String player) + protected ClientClan addPlayer(UUID uuid) { return new ClientClan(); } @@ -1132,6 +1198,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati _worldEvent.onDisable(); _goldManager.onDisable(); _playTracker.onDisable(); + _bannerManager.onDisable(); + _amplifierManager.onDisable(); + _netherManager.onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) @@ -1160,8 +1229,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon"); - event.setKickMessage("Clans Beta is full! Try again soon"); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); + event.setKickMessage("This Clans server is full! Try again soon"); } else { @@ -1184,7 +1253,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { if (event.getMessage().toLowerCase().equals("/lobby") || event.getMessage().toLowerCase().equals("/hub") || event.getMessage().toLowerCase().equals("/leave")) { - Portal.getInstance().sendPlayerToServer(event.getPlayer(), "Lobby"); + Portal.getInstance().sendPlayerToServer(event.getPlayer(), "ClansHub"); event.setCancelled(true); } } 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 ff6c1fc70..5b225e410 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 @@ -608,6 +608,12 @@ public class ClansUtility return; } + if (_clansManager.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(_clansManager.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + ".")); + return; + } + if (!_clansManager.Get(caller).canJoin()) { UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - _clansManager.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java new file mode 100644 index 000000000..4623bbe65 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java @@ -0,0 +1,47 @@ +package mineplex.game.clans.clans.amplifiers; + +import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; + +import org.bukkit.entity.Player; + +/** + * Data class for active amplifiers + */ +public class Amplifier +{ + private Player _owner; + private long _end; + + public Amplifier(Player owner, AmplifierType type) + { + _owner = owner; + _end = System.currentTimeMillis() + type.getDuration(); + } + + /** + * Gets the owner of the amplifier + * @return This amplifier's owner + */ + public Player getOwner() + { + return _owner; + } + + /** + * Gets the remaining duration of this amplifier + * @return How much time is left before this amplifier expires + */ + public long getRemainingTime() + { + return Math.max(0, _end - System.currentTimeMillis()); + } + + /** + * Checks whether this amplifier has run out of time + * @return Whether this amplifier has run out of time + */ + public boolean isEnded() + { + return System.currentTimeMillis() >= _end; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java new file mode 100644 index 000000000..a50ff3366 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.clans.amplifiers; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +import org.bukkit.entity.Player; + +/** + * Main amplifier command + */ +public class AmplifierCommand extends CommandBase +{ + public AmplifierCommand(AmplifierManager plugin) + { + super(plugin, Rank.ALL, "amplifier", "runeamplifier"); + } + + @Override + public void Execute(Player caller, String[] args) + { + new AmplifierGUI(caller, Plugin); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java new file mode 100644 index 000000000..b62061957 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java @@ -0,0 +1,197 @@ +package mineplex.game.clans.clans.amplifiers; + +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +/** + * GUI manager for amplifiers + */ +public class AmplifierGUI implements Listener +{ + private Player _viewer; + private AmplifierManager _manager; + private Inventory _inventory; + private final HashMap _items = new HashMap<>(); + private final HashMap _boundSlots = new HashMap<>(); + private AmplifierType _selected; + + public AmplifierGUI(Player viewer, AmplifierManager manager) + { + _viewer = viewer; + _manager = manager; + _inventory = Bukkit.createInventory(viewer, 9, C.cClansNether + "Rune Amplifiers"); + Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + + propagate(); + open(); + } + + /** + * Gets the owner of this specific inventory + * @return The owner of this inventory + */ + public Player getViewer() + { + return _viewer; + } + + /** + * Fetches all the items registered as buttons in this inventory gui + * @return A list of the items registered as buttons in this inventory gui + */ + public HashMap getItems() + { + return _items; + } + + /** + * Fills the gui with buttons + */ + public void propagate() + { + getItems().clear(); + Integer slot = 0; + for (AmplifierType type : AmplifierType.values()) + { + int owned = _manager.getAmountOwned(getViewer(), type); + owned = Math.max(owned, 0); + getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(Math.min(owned, 1)).setTitle(type.getDisplayName()).setLore(F.elem(owned) + " Owned").build()); + _boundSlots.put(slot, type); + slot++; + } + refresh(); + } + + /** + * Fils the confirmation menu with buttons + */ + public void propagateConfirmation() + { + getItems().clear(); + _boundSlots.clear(); + getItems().put(3, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 5).setTitle(C.cGreen + "Confirm").build()); + getItems().put(5, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 14).setTitle(C.cRed + "Cancel").build()); + refresh(); + } + + /** + * Handles players clicking on buttons + * @param slot The slot clicked on + * @param type The type of click + */ + public void onClick(Integer slot, ClickType type) + { + if (_boundSlots.containsKey(slot)) + { + if (_manager.hasActiveAmplifier()) + { + UtilPlayer.message(getViewer(), F.main(_manager.getName(), "An amplifier is already active!")); + _manager.runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + } + else + { + _selected = _boundSlots.get(slot); + if (_manager.getAmountOwned(getViewer(), _selected) > 0) + { + propagateConfirmation(); + } + else + { + UtilPlayer.message(getViewer(), F.main(_manager.getName(), "You do not have enough of that amplifier! Purchase some at http://www.mineplex.com/shop!")); + } + } + return; + } + + if (slot == 3) + { + _manager.runSyncLater(() -> + { + _manager.useAmplifier(getViewer(), _selected); + getViewer().closeInventory(); + }, 1L); + } + if (slot == 5) + { + _selected = null; + propagate(); + } + } + + /** + * Opens this inventory to its viewer + */ + public void open() + { + _viewer.openInventory(_inventory); + } + + /** + * Updates the GUI's visuals to match registered button items + */ + public void refresh() + { + _inventory.clear(); + for (Integer slot : _items.keySet()) + { + _inventory.setItem(slot, _items.get(slot)); + } + for (Integer slot = 0; slot < _inventory.getSize(); slot++) + { + if (!_items.containsKey(slot)) + { + _inventory.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(C.cGray).setData((short)7).build()); + } + } + _viewer.updateInventory(); + } + + @EventHandler + public void handleClick(InventoryClickEvent event) + { + if (event.getClickedInventory() == null || !event.getClickedInventory().equals(_inventory)) + { + return; + } + if (!_viewer.getName().equals(event.getWhoClicked().getName())) + { + return; + } + event.setCancelled(true); + Integer slot = event.getSlot(); + if (!_items.containsKey(slot)) + { + return; + } + onClick(slot, event.getClick()); + } + + @EventHandler + public void onClose(InventoryCloseEvent event) + { + if (event.getPlayer().getUniqueId().equals(_viewer.getUniqueId())) + { + HandlerList.unregisterAll(this); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java new file mode 100644 index 000000000..00d0073cc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -0,0 +1,155 @@ +package mineplex.game.clans.clans.amplifiers; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Manager for using amplifiers in clans + */ +public class AmplifierManager extends MiniPlugin +{ + public static final double AMPLIFIER_RUNE_DROP_MULTIPLIER = 2; + private static final String AMPLIFIER_NAME = "Rune Amplifier"; + private Amplifier _active; + + public AmplifierManager(JavaPlugin plugin) + { + super("Rune Amplifiers", plugin); + + addCommand(new AmplifierCommand(this)); + } + + /** + * Checks whether there is an amplifier active on this server + * @return Whether there is an amplifier active on this server + */ + public boolean hasActiveAmplifier() + { + return _active != null; + } + + /** + * Checks how many of a certain amplifier type a player owns + * @param player The player to check + * @param type The type of amplifier to check for + * @return The amount of amplifiers of that type owned + */ + public int getAmountOwned(Player player, AmplifierType type) + { + return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getFullItemName()); + } + + /** + * Makes a player use an amplifier + * @param user The player to use the amplifier + * @param type The type of amplifier to use + */ + public void useAmplifier(Player user, AmplifierType type) + { + if (getAmountOwned(user, type) < 1) + { + return; + } + if (hasActiveAmplifier()) + { + return; + } + ClansManager.getInstance().getInventoryManager().addItemToInventory(user, type.getFullItemName(), -1); + UtilTextMiddle.display(C.cClansNether + AMPLIFIER_NAME, "Has been activated by " + F.elem(user.getName())); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " has been activated on this server by " + F.elem(user.getName()) + " for " + F.elem(UtilTime.MakeStr(type.getDuration())) + "!")); + _active = new Amplifier(user, type); + runSyncLater(() -> + { + ClansManager.getInstance().getNetherManager().spawnPortal(type.getDuration()); + }, 60L); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (_active != null && _active.isEnded()) + { + Bukkit.broadcastMessage(F.main(getName(), "The " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner().getName()) + " has run out! You can purchase another at http://www.mineplex.com/shop!")); + _active = null; + } + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_active != null) + { + runSyncLater(() -> + { + if (_active != null) + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner().getName()) + " is active on this server with " + F.elem(UtilTime.MakeStr(_active.getRemainingTime())) + " remaining!")); + } + }, 40L); + } + } + + /** + * Enum containing different types of amplifiers recognized by code + */ + public static enum AmplifierType + { + TWENTY("20", "Twenty Minute Amplifier", UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)), + SIXTY("60", "One Hour Amplifier", UtilTime.convert(60, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + + private String _extension, _display; + private long _duration; + + private AmplifierType(String extension, String displayName, long duration) + { + _extension = extension; + _display = C.cClansNether + displayName; + _duration = duration; + } + + /** + * Gets the full name of this amplifier as recognized by the inventory database + * @return The full name of this amplifier as recognized by the inventory database + */ + public String getFullItemName() + { + return AMPLIFIER_NAME + " " + _extension; + } + + /** + * Gets the display name for this amplifier in this GUI + * @return The display name for this amplifier in this GUI + */ + public String getDisplayName() + { + return _display; + } + + /** + * Gets the total duration for this type of amplifier + * @return The total duration for this type of amplifier + */ + public long getDuration() + { + return _duration; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 62e7be42a..b519c1448 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -1,23 +1,52 @@ package mineplex.game.clans.clans.ban; +import java.util.HashMap; +import java.util.UUID; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ban.commands.ClansBanCommand; +import mineplex.game.clans.clans.ban.commands.FreezeCommand; +import mineplex.game.clans.clans.ban.commands.UnfreezeCommand; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class ClansBanManager extends MiniPlugin { + private static final long FREEZE_MESSAGE_INTERVAL = 10000; private final CoreClientManager _clientManager; private final DonationManager _donationManager; private final ClansBanRepository _repository; + private final HashMap _frozen = new HashMap<>(); public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { @@ -34,6 +63,8 @@ public class ClansBanManager extends MiniPlugin public void addCommands() { addCommand(new ClansBanCommand(this)); + addCommand(new FreezeCommand(this)); + addCommand(new UnfreezeCommand(this)); } public CoreClientManager getClientManager() @@ -74,6 +105,202 @@ public class ClansBanManager extends MiniPlugin } } catch (Exception ignored) {} } + + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerQuitEvent event) + { + Float walkSpeed = _frozen.remove(event.getPlayer().getUniqueId()); + if (walkSpeed != null) + { + event.getPlayer().setWalkSpeed(walkSpeed); + event.getPlayer().removePotionEffect(PotionEffectType.JUMP); + for (Player staff : UtilServer.GetPlayers()) + { + if (_clientManager.hasRank(staff, Rank.HELPER)) + { + UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!")); + } + } + } + } + + @EventHandler + public void onMove(PlayerMoveEvent event) + { + if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) + { + event.setCancelled(true); + event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0)); + } + } + + @EventHandler + public void onDisplayFreezeMessage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (UUID frozenUUID : _frozen.keySet()) + { + Player frozen = Bukkit.getPlayer(frozenUUID); + if (Recharge.Instance.use(frozen, "Freeze Message", FREEZE_MESSAGE_INTERVAL, false, false)) + { + String border = C.cGray + C.Strike + "-----------------------------------------------------"; + String sq = "\u2589"; + + UtilPlayer.message(frozen, border); + UtilPlayer.message(frozen, C.Reset + ""); + UtilPlayer.message(frozen, C.cWhite + sq + sq + sq + sq + C.cRed + sq + C.cWhite + sq + sq + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + sq + C.cRed + sq + C.cBlack + sq + C.cRed + sq + C.cWhite + sq + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + C.cRed + sq + C.cGold + sq + sq + sq + C.cGold + sq + sq + C.cRed + sq + C.cWhite + sq); + UtilPlayer.message(frozen, C.cRed + sq + C.cGold + sq + sq + sq + C.cBlack + sq + C.cGold + sq + sq + sq + C.cRed + sq); + UtilPlayer.message(frozen, C.cRed + sq + sq + sq + sq + sq + sq + sq + sq + sq); + UtilPlayer.message(frozen, C.Reset + ""); + UtilPlayer.message(frozen, C.cRed + "You have been frozen by a staff member!"); + UtilPlayer.message(frozen, C.cRed + "Do not log out or you will be banned!"); + UtilPlayer.message(frozen, C.Reset + ""); + UtilPlayer.message(frozen, border); + } + } + } + + @EventHandler + public void handleMobs(EntityTargetLivingEntityEvent event) + { + if (event.getTarget() instanceof Player) + { + Player player = (Player) event.getTarget(); + if (isFrozen(player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(event.GetCause() == DamageCause.PROJECTILE); + Player damagee = event.GetDamageePlayer(); + + if (damager != null && isFrozen(damager)) + { + event.SetCancelled("Frozen Attacker"); + UtilPlayer.message(damager, F.main(getName(), "You cannot attack others while frozen!")); + } + if (damagee != null && isFrozen(damagee)) + { + event.SetCancelled("Frozen Damagee"); + if (damager != null) + { + UtilPlayer.message(damager, F.main(getName(), "You cannot attack " + F.elem(damagee.getName()) + " while they are frozen!")); + } + } + } + + @EventHandler + public void onUseSkill(SkillTriggerEvent event) + { + if (isFrozen(event.GetPlayer())) + { + event.SetCancelled(true); + UtilPlayer.message(event.GetPlayer(), F.main(getName(), "You cannot use " + F.skill(event.GetSkillName()) + " while frozen!")); + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (isFrozen(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot break blocks while frozen!")); + } + } + + @EventHandler + public void onPlace(BlockPlaceEvent event) + { + if (isFrozen(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot place blocks while frozen!")); + } + } + + @EventHandler + public void onTpHome(ClansCommandExecutedEvent event) + { + if (event.getCommand().equalsIgnoreCase("tphome")) + { + if (isFrozen(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while frozen!")); + } + } + } + + /** + * Checks if a player is frozen + * @param player The player to check + * @return Whether the player is frozen + */ + public boolean isFrozen(Player player) + { + return _frozen.containsKey(player.getUniqueId()); + } + + /** + * Freezes a player + * @param player The player to freeze + * @param staff The staff member who froze them + */ + public void freeze(Player player, Player staff) + { + _frozen.put(player.getUniqueId(), player.getWalkSpeed()); + player.setWalkSpeed(0); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); + for (Player alert : UtilServer.GetPlayers()) + { + if (_clientManager.hasRank(alert, Rank.HELPER)) + { + UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!")); + } + } + } + + /** + * Unfreezes a player + * @param player The player to unfreeze + * @param staff The staff member who unfroze them + */ + public void unfreeze(Player player, Player staff) + { + Float walkSpeed = _frozen.remove(player.getUniqueId()); + if (walkSpeed != null) + { + player.setWalkSpeed(walkSpeed); + player.removePotionEffect(PotionEffectType.JUMP); + for (Player alert : UtilServer.GetPlayers()) + { + if (_clientManager.hasRank(alert, Rank.HELPER)) + { + UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!")); + continue; + } + if (alert.getName().equals(player.getName())) + { + UtilPlayer.message(alert, F.main(getName(), "You have been unfrozen!")); + } + } + } + } public void unban(ClansBanClient target, ClansBan ban, Callback callback) { @@ -87,4 +314,4 @@ public class ClansBanManager extends MiniPlugin callback.run(target); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java index 39923ea27..e43c9f130 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -22,7 +22,7 @@ public class ClansBanCommand extends CommandBase { if (args == null || args.length < 1) { - UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans."); + UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); } else if (args.length > 1) { @@ -52,7 +52,7 @@ public class ClansBanCommand extends CommandBase } else { - UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans."); + UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java new file mode 100644 index 000000000..fedad6275 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.ban.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ban.ClansBanManager; + +import org.bukkit.entity.Player; + +/** + * Command to freeze players + */ +public class FreezeCommand extends CommandBase +{ + public FreezeCommand(ClansBanManager plugin) + { + super(plugin, Rank.CMOD, "freeze"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length < 1) + { + UtilPlayer.message(caller, C.cBlue + "/freeze " + C.cGray + " - " + C.cYellow + "Freezes a player, restricting their movement and ability to interact with the game."); + } + else if (args.length > 0) + { + Player target = UtilPlayer.searchOnline(caller, args[0], true); + if (target == null) + { + return; + } + if (Plugin.isFrozen(target)) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(args[0]) + " is already frozen!")); + return; + } + Plugin.freeze(target, caller); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java new file mode 100644 index 000000000..7114d0e79 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.ban.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ban.ClansBanManager; + +import org.bukkit.entity.Player; + +/** + * Command to unfreeze players + */ +public class UnfreezeCommand extends CommandBase +{ + public UnfreezeCommand(ClansBanManager plugin) + { + super(plugin, Rank.CMOD, "unfreeze"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length < 1) + { + UtilPlayer.message(caller, C.cBlue + "/unfreeze " + C.cGray + " - " + C.cYellow + "Unfreezes a player, restoring their movement and ability to interact with the game."); + } + else if (args.length > 0) + { + Player target = UtilPlayer.searchOnline(caller, args[0], true); + if (target == null) + { + return; + } + if (!Plugin.isFrozen(target)) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(args[0]) + " is not frozen!")); + return; + } + Plugin.unfreeze(target, caller); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java new file mode 100644 index 000000000..0acc79e5d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -0,0 +1,241 @@ +package mineplex.game.clans.clans.banners; + +import java.util.HashMap; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.command.BannerCommand; +import mineplex.game.clans.core.repository.ClanTerritory; +import net.minecraft.server.v1_8_R3.MinecraftServer; + +/** + * Manager class for cosmetic clans banners + */ +public class BannerManager extends MiniPlugin +{ + public final HashMap LoadedBanners = new HashMap<>(); + private final BlockFace[] _radial = { BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST }; + private BannerRepository _repo; + + public BannerManager(JavaPlugin plugin) + { + super("Clan Banners", plugin); + _repo = new BannerRepository(plugin, this); + + new BannerPacketManager(); + addCommand(new BannerCommand(this)); + } + + /** + * Checks what type of banner unlock a player has + * @param player The player to check + * @return The type of banner unlock a player has + */ + public int getBannerUnlockLevel(Player player) + { + int level = 0; + if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("Clan Banner Usage")) + { + level = 1; + } + if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("Clan Banner Editor")) + { + level = 2; + } + if (ClansManager.getInstance().getClientManager().hasRank(player, Rank.ADMIN)) + { + level = 2; + } + return level; + } + + /** + * Loads a banner for a clan + * @param clan The clan whose banner to load + */ + public void loadBanner(ClanInfo clan) + { + _repo.loadBanner(LoadedBanners, clan); + } + + /** + * Saves a banner to the database + * @param banner The banner to save + */ + public void saveBanner(ClanBanner banner) + { + _repo.saveBanner(banner); + } + + /** + * Deletes a clan's banner + * @param clan The clan whose banner to delete + */ + public void deleteBanner(ClanInfo clan) + { + _repo.deleteBanner(clan); + LoadedBanners.remove(clan.getName()); + } + + /** + * Deletes a clan banner + * @param banner The banner to delete + */ + public void deleteBanner(ClanBanner banner) + { + deleteBanner(banner.getClan()); + } + + /** + * Places a clans banner for a player + * @param placing The player who placed the banner + * @param banner The banner to place + */ + public void placeBanner(Player placing, ClanBanner banner) + { + Block block = placing.getLocation().getBlock(); + BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, true); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) + { + ClanTerritory claim = ClansManager.getInstance().getClanUtility().getClaim(block.getLocation()); + if (claim != null && !claim.Owner.equals(banner.getClan().getName())) + { + UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there.")); + return; + } + ClansManager.getInstance().getBlockRestore().restore(block); + if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))) + { + if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false)) + { + return; + } + block.setType(Material.STANDING_BANNER); + Banner state = (Banner) block.getState(); + state.setBaseColor(banner.getBaseColor()); + state.setPatterns(((BannerMeta)banner.getBanner().getItemMeta()).getPatterns()); + org.bukkit.material.Banner data = (org.bukkit.material.Banner) state.getData(); + try + { + data.setFacingDirection(_radial[Math.round(placing.getLocation().getYaw() / 45f) & 0x7]); + } + catch (Exception e) + { + e.printStackTrace(); + } + state.setData(data); + state.update(); + } + else + { + UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there.")); + return; + } + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER) + { + event.setCancelled(true); + event.getBlock().setType(Material.AIR); + } + } + + @EventHandler + public void onDropBanner(BlockPhysicsEvent event) + { + if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onCraftBanner(PrepareItemCraftEvent event) + { + if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BANNER) + { + return; + } + + event.getInventory().setResult(null); + } + + @EventHandler + public void onCraftBanner(CraftItemEvent event) + { + if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BANNER) + { + return; + } + + event.setCancelled(true); + } + + @EventHandler + public void onJoinWithBanner(PlayerJoinEvent event) + { + if (MinecraftServer.getServer().recentTps[0] < 19) + { + return; + } + runSyncLater(() -> + { + for (ItemStack item : event.getPlayer().getInventory().getContents()) + { + if (item != null && item.getType() == Material.BANNER) + { + event.getPlayer().getInventory().remove(item); + } + } + }, 20); + } + + @EventHandler + public void onPickupBanner(PlayerPickupItemEvent event) + { + if (event.getItem().getItemStack().getType() == Material.BANNER) + { + event.setCancelled(true); + event.getItem().remove(); + } + } + + @EventHandler + public void onPickupBanner(PlayerDropItemEvent event) + { + if (event.getItemDrop().getItemStack().getType() == Material.BANNER) + { + event.getItemDrop().remove(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java new file mode 100644 index 000000000..43121fea0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java @@ -0,0 +1,113 @@ +package mineplex.game.clans.clans.banners; + +import java.lang.reflect.Field; +import java.util.HashMap; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + +/** + * Handler for banner wearing packets + */ +public class BannerPacketManager implements Listener +{ + private Field _itemField; + private static BannerPacketManager Instance; + private final HashMap _wearing = new HashMap<>(); + + public BannerPacketManager() + { + try + { + _itemField = PacketPlayOutSetSlot.class.getDeclaredField("c"); + _itemField.setAccessible(true); + + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + Instance = this; + } + + /** + * Fetches the registered loaded instance of this class + * @return The loaded instance of this class + */ + public static BannerPacketManager getInstance() + { + return Instance; + } + + /** + * Toggles a player wearing their clan's banner + * @param player The player to toggle for + * @param banner The banner to toggle + */ + public void toggleBanner(Player player, ItemStack banner) + { + if (_wearing.containsKey(player)) + { + IPacketHandler bannerHandler = _wearing.remove(player); + ClansManager.getInstance().getPacketHandler().removePacketHandler(bannerHandler); + for (Player refresh : Bukkit.getOnlinePlayers()) + { + ItemStack helmet = new ItemStack(Material.AIR); + if (player.getInventory().getHelmet() != null) + { + helmet = player.getInventory().getHelmet(); + } + UtilPlayer.sendPacket(refresh, new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(helmet))); + } + } + else + { + IPacketHandler bannerHandler = new IPacketHandler() + { + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutEntityEquipment) + { + PacketPlayOutEntityEquipment equip = (PacketPlayOutEntityEquipment) packetInfo.getPacket(); + + if (equip.a == player.getEntityId() && equip.b == 4) + { + equip.c = CraftItemStack.asNMSCopy(banner); + } + } + } + }; + _wearing.put(player, bannerHandler); + ClansManager.getInstance().getPacketHandler().addPacketHandler(bannerHandler, PacketPlayOutEntityEquipment.class); + for (Player refresh : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(refresh, new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(banner))); + } + } + } + + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + if (_wearing.containsKey(event.getPlayer())) + { + ClansManager.getInstance().getPacketHandler().removePacketHandler(_wearing.remove(event.getPlayer())); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java new file mode 100644 index 000000000..62cc5ec3f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java @@ -0,0 +1,84 @@ +package mineplex.game.clans.clans.banners; + +import org.bukkit.DyeColor; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; + +/** + * Data class for clans banner patterns + */ +public class BannerPattern +{ + private int _layer; + private DyeColor _color; + private PatternType _type; + + public BannerPattern(int layer, DyeColor color, PatternType type) + { + _layer = layer; + _color = color; + _type = type; + } + + public BannerPattern(int layer) + { + _layer = layer; + _color = null; + _type = null; + } + + /** + * Gets the layer this pattern occupies on the clan's banner + * @return The layer this pattern occupies on the clan's banner + */ + public int getLayer() + { + return _layer; + } + + /** + * Gets the Bukkit version of this banner pattern + * @return The Bukkit version of this banner pattern, or null if this is not a fully configured pattern + */ + public Pattern getBukkitPattern() + { + if (_color == null || _type == null) + { + return null; + } + + return new Pattern(_color, _type); + } + + /** + * Gets the form this banner pattern will take in the database + * @return The form this banner pattern will take in the database + */ + public String getDatabaseForm() + { + if (_color == null || _type == null) + { + return "Blank"; + } + + return _color.toString() + "," + _type.toString(); + } + + /** + * Sets the color of this banner pattern + * @param color The color to set this pattern to + */ + public void setColor(DyeColor color) + { + _color = color; + } + + /** + * Sets the design of this banner pattern + * @param color The design to set this pattern to + */ + public void setPatternType(PatternType type) + { + _type = type; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java new file mode 100644 index 000000000..f9c2b41aa --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java @@ -0,0 +1,126 @@ +package mineplex.game.clans.clans.banners; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.database.MinecraftRepository; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +import org.bukkit.DyeColor; +import org.bukkit.block.banner.PatternType; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Database repository class for banners + */ +public class BannerRepository extends MinecraftRepository +{ + private static final String CREATE = "CREATE TABLE IF NOT EXISTS clanBanners (clanId INT NOT NULL," + + "baseColor VARCHAR(15)," + + "patterns VARCHAR(300)," + + "PRIMARY KEY (clanId));"; + + private static final String GET_BANNER_BY_CLAN = "SELECT * FROM clanBanners WHERE clanId=? LIMIT 1;"; + private static final String INSERT_BANNER = "INSERT INTO clanBanners (clanId, baseColor, patterns) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE baseColor=VALUES(baseColor), patterns=VALUES(patterns);"; + private static final String DELETE_BANNER = "DELETE FROM clanBanners WHERE clanId=?;"; + + private BannerManager _bannerManager; + + public BannerRepository(JavaPlugin plugin, BannerManager bannerManager) + { + super(plugin, DBPool.getAccount()); + _bannerManager = bannerManager; + } + + /** + * Loads a banner for a certain clan into a given hashmap + * @param map The hashmap to load the banner into + * @param clan The clan whose banner to fetch + */ + public void loadBanner(final HashMap map, ClanInfo clan) + { + _bannerManager.runAsync(() -> + { + executeQuery(GET_BANNER_BY_CLAN, resultSet -> + { + while(resultSet.next()) + { + DyeColor baseColor = DyeColor.valueOf(resultSet.getString("baseColor")); + List patternStrs = Arrays.asList(resultSet.getString("patterns").split("/")); + LinkedList patterns = new LinkedList<>(); + int layer = 1; + for (String patternStr : patternStrs) + { + if (patternStr.equalsIgnoreCase("Blank")) + { + patterns.add(new BannerPattern(layer)); + } + else + { + try + { + DyeColor patternColor = DyeColor.valueOf(patternStr.split(",")[0]); + PatternType patternType = PatternType.valueOf(patternStr.split(",")[1]); + patterns.add(new BannerPattern(layer, patternColor, patternType)); + } + catch (Exception e) + { + e.printStackTrace(); + patterns.add(new BannerPattern(layer)); + } + } + layer++; + } + map.put(clan.getName(), new ClanBanner(_bannerManager, clan, baseColor, patterns)); + } + }, new ColumnInt("clanId", clan.getId())); + }); + } + + /** + * Saves a banner into the database + * @param banner The banner to save + */ + public void saveBanner(ClanBanner banner) + { + _bannerManager.runAsync(() -> + { + String patternStr = ""; + for (BannerPattern pattern : banner.getPatterns()) + { + if (!patternStr.equalsIgnoreCase("")) + { + patternStr = patternStr + "/"; + } + patternStr = patternStr + pattern.getDatabaseForm(); + } + executeUpdate(INSERT_BANNER, new ColumnInt("clanId", banner.getClan().getId()), new ColumnVarChar("baseColor", 15, banner.getBaseColor().toString()), new ColumnVarChar("patterns", 300, patternStr)); + }); + } + + /** + * Deletes a banner from the database + * @param clan The clan whose banner to delete + */ + public void deleteBanner(ClanInfo clan) + { + _bannerManager.runAsync(() -> + { + executeUpdate(DELETE_BANNER, new ColumnInt("clanId", clan.getId())); + }); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE); + } + + @Override + protected void update() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java new file mode 100644 index 000000000..5a12ab688 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java @@ -0,0 +1,113 @@ +package mineplex.game.clans.clans.banners; + +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClanInfo; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import com.google.common.collect.Lists; + +/** + * Data class for clan banners + */ +public class ClanBanner +{ + private BannerManager _manager; + private ClanInfo _clan; + private DyeColor _baseColor; + private LinkedList _patterns; + + public ClanBanner(BannerManager manager, ClanInfo clan, DyeColor baseColor, LinkedList patterns) + { + _manager = manager; + _clan = clan; + _baseColor = baseColor; + _patterns = patterns; + } + + /** + * Gets the clan that owns this banner + * @return The clan that owns this banner + */ + public ClanInfo getClan() + { + return _clan; + } + + /** + * Gets the base color for this banner + * @return The base color for this banner + */ + public DyeColor getBaseColor() + { + return _baseColor; + } + + /** + * Gets this banner's patterns + * @return This banner's patterns + */ + public LinkedList getPatterns() + { + return _patterns; + } + + /** + * Gets the ItemStack representation of this banner + * @return The ItemStack representation of this banner + */ + public ItemStack getBanner() + { + ItemStack banner = new ItemStack(Material.BANNER); + BannerMeta im = (BannerMeta) banner.getItemMeta(); + + im.setDisplayName(C.cGray + _clan.getName() + "'s Banner"); + im.setBaseColor(_baseColor); + List patterns = Lists.newArrayList(); + for (BannerPattern bp : _patterns) + { + if (bp.getBukkitPattern() != null) + { + patterns.add(bp.getBukkitPattern()); + } + } + im.setPatterns(patterns); + banner.setItemMeta(im); + + return banner; + } + + /** + * Sets the base color of this banner + * @param color The color to set + */ + public void setBaseColor(DyeColor color) + { + _baseColor = color; + } + + /** + * Saves this banner to the database + */ + public void save() + { + _manager.saveBanner(this); + } + + /** + * Places this banner on the ground + * @param player The player to place the banner for + */ + public void place(Player player) + { + _manager.placeBanner(player, this); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java new file mode 100644 index 000000000..dab08ae35 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java @@ -0,0 +1,66 @@ +package mineplex.game.clans.clans.banners.command; + +import java.util.LinkedList; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; + +import org.bukkit.DyeColor; +import org.bukkit.entity.Player; + +/** + * Main banner usage command + */ +public class BannerCommand extends CommandBase +{ + public BannerCommand(BannerManager plugin) + { + super(plugin, Rank.ALL, "banner"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (ClansManager.getInstance().getClan(caller) == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not in a Clan!")); + return; + } + ClanInfo clan = ClansManager.getInstance().getClan(caller); + + if (Plugin.getBannerUnlockLevel(caller) < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not purchased the ability to use Clan banners! Buy it at http://www.mineplex.com/shop!")); + return; + } + if (!Plugin.LoadedBanners.containsKey(clan.getName())) + { + if (Plugin.getBannerUnlockLevel(caller) >= 2 && clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER) + { + LinkedList patterns = new LinkedList<>(); + for (int i = 0; i < 12; i++) + { + patterns.add(new BannerPattern(i + 1)); + } + ClanBanner banner = new ClanBanner(Plugin, clan, DyeColor.WHITE, patterns); + Plugin.LoadedBanners.put(clan.getName(), banner); + banner.save(); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Your Clan does not have a set banner!")); + return; + } + } + new NonEditOverviewGUI(caller, Plugin.LoadedBanners.get(clan.getName())); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java new file mode 100644 index 000000000..0c6b5e684 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java @@ -0,0 +1,123 @@ +package mineplex.game.clans.clans.banners.gui; + +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +/** + * Base class to manage banner guis + */ +public abstract class BannerGUI implements Listener +{ + private Player _viewer; + private Inventory _inventory; + private final HashMap _items = new HashMap<>(); + + public BannerGUI(Player viewer, String pageName, int slots) + { + _viewer = viewer; + _inventory = Bukkit.createInventory(viewer, slots, pageName); + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + /** + * Gets the owner of this specific inventory + * @return The owner of this inventory + */ + public Player getViewer() + { + return _viewer; + } + + /** + * Fetches all the items registered as buttons in this inventory gui + * @return A list of the items registered as buttons in this inventory gui + */ + public HashMap getItems() + { + return _items; + } + + /** + * Fills the gui with buttons + */ + public abstract void propagate(); + + /** + * Handles players clicking on buttons + * @param slot The slot clicked on + * @param type The type of click + */ + public abstract void onClick(Integer slot, ClickType type); + + /** + * Opens this inventory to its viewer + */ + public void open() + { + _viewer.openInventory(_inventory); + } + + /** + * Updates the GUI's visuals to match registered button items + */ + public void refresh() + { + _inventory.clear(); + for (Integer slot : _items.keySet()) + { + _inventory.setItem(slot, _items.get(slot)); + } + for (Integer slot = 0; slot < _inventory.getSize(); slot++) + { + if (!_items.containsKey(slot)) + { + _inventory.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(C.cGray).setData((short)7).build()); + } + } + _viewer.updateInventory(); + } + + @EventHandler + public void handleClick(InventoryClickEvent event) + { + if (event.getClickedInventory() == null || !event.getClickedInventory().equals(_inventory)) + { + return; + } + if (!_viewer.getName().equals(event.getWhoClicked().getName())) + { + return; + } + event.setCancelled(true); + Integer slot = event.getSlot(); + if (!_items.containsKey(slot)) + { + return; + } + onClick(slot, event.getClick()); + } + + @EventHandler + public void onClose(InventoryCloseEvent event) + { + if (event.getPlayer().getUniqueId().equals(_viewer.getUniqueId())) + { + HandlerList.unregisterAll(this); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java new file mode 100644 index 000000000..cc3a93bff --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java @@ -0,0 +1,78 @@ +package mineplex.game.clans.clans.banners.gui.creation; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * GUI manager for selecting a banner's base color + */ +public class BaseColorSelectionGUI extends BannerGUI +{ + private ClanBanner _banner; + + public BaseColorSelectionGUI(Player viewer, ClanBanner banner) + { + super(viewer, "Background Color", 27); + _banner = banner; + + propagate(); + open(); + } + + @Override + public void propagate() + { + Integer slot = 1; + for (short data = 0; data <= 15; data++) + { + getItems().put(slot, new ItemBuilder(Material.INK_SACK).setData(data).setTitle(C.cGray).build()); + if ((slot + 1) == 8) + { + slot = 10; + } + else if ((slot + 1) == 17) + { + slot = 21; + } + else if ((slot + 1) == 22) + { + slot = 23; + } + else + { + slot++; + } + } + refresh(); + } + + @SuppressWarnings("deprecation") + @Override + public void onClick(Integer slot, ClickType type) + { + if (getItems().get(slot).getType() == Material.INK_SACK) + { + DyeColor color = DyeColor.getByDyeData(getItems().get(slot).getData().getData()); + _banner.setBaseColor(color); + _banner.save(); + + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new OverviewGUI(getViewer(), _banner); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java new file mode 100644 index 000000000..3daef4b68 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java @@ -0,0 +1,80 @@ +package mineplex.game.clans.clans.banners.gui.creation; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * GUI manager for selecting a banner pattern's base color + */ +public class PatternColorSelectionGUI extends BannerGUI +{ + private ClanBanner _banner; + private int _bannerPos; + + public PatternColorSelectionGUI(Player viewer, ClanBanner banner, int bannerPosition) + { + super(viewer, "Pattern Color", 27); + _banner = banner; + _bannerPos = bannerPosition; + + propagate(); + open(); + } + + @Override + public void propagate() + { + Integer slot = 1; + for (short data = 0; data <= 15; data++) + { + getItems().put(slot, new ItemBuilder(Material.INK_SACK).setData(data).setTitle(C.cGray).build()); + if ((slot + 1) == 8) + { + slot = 10; + } + else if ((slot + 1) == 17) + { + slot = 21; + } + else if ((slot + 1) == 22) + { + slot = 23; + } + else + { + slot++; + } + } + refresh(); + } + + @SuppressWarnings("deprecation") + @Override + public void onClick(Integer slot, ClickType type) + { + if (getItems().get(slot).getType() == Material.INK_SACK) + { + DyeColor color = DyeColor.getByDyeData(getItems().get(slot).getData().getData()); + BannerPattern pattern = _banner.getPatterns().get(_bannerPos); + pattern.setColor(color); + + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new PatternTypeSelectionGUI(getViewer(), _banner, _bannerPos, color); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java new file mode 100644 index 000000000..587d0deab --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java @@ -0,0 +1,87 @@ +package mineplex.game.clans.clans.banners.gui.creation; + +import java.util.LinkedList; + +import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +/** + * GUI manager for selecting a banner pattern's design + */ +public class PatternTypeSelectionGUI extends BannerGUI +{ + private ClanBanner _banner; + private int _bannerPos; + private DyeColor _color; + + public PatternTypeSelectionGUI(Player viewer, ClanBanner banner, int bannerPosition, DyeColor patternColor) + { + super(viewer, "Pattern Color", 45); + _banner = banner; + _bannerPos = bannerPosition; + _color = patternColor; + + propagate(); + open(); + } + + @Override + public void propagate() + { + for (int i = 0; i < PatternType.values().length; i++) + { + ItemStack item = new ItemStack(Material.BANNER); + BannerMeta im = (BannerMeta) item.getItemMeta(); + im.setBaseColor(_banner.getBaseColor()); + LinkedList patterns = new LinkedList<>(); + for (int patternId = 0; patternId < _bannerPos; patternId++) + { + BannerPattern show = _banner.getPatterns().get(patternId); + if (show.getBukkitPattern() != null) + { + patterns.add(show.getBukkitPattern()); + } + } + patterns.add(new Pattern(_color, PatternType.values()[i])); + im.setPatterns(patterns); + im.setDisplayName(C.cGray); + item.setItemMeta(im); + getItems().put(i, item); + } + refresh(); + } + + @Override + public void onClick(Integer slot, ClickType ctype) + { + if (getItems().get(slot).getType() == Material.BANNER) + { + PatternType type = ((BannerMeta)getItems().get(slot).getItemMeta()).getPatterns().get(Math.min(_bannerPos, ((BannerMeta)getItems().get(slot).getItemMeta()).getPatterns().size() - 1)).getPattern(); + BannerPattern pattern = _banner.getPatterns().get(_bannerPos); + pattern.setPatternType(type); + _banner.save(); + + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new OverviewGUI(getViewer(), _banner); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java new file mode 100644 index 000000000..b7862d8ee --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java @@ -0,0 +1,82 @@ +package mineplex.game.clans.clans.banners.gui.nonedit; + +import java.util.Arrays; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPacketManager; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +/** + * GUI manager for viewing a banner usage overview + */ +public class NonEditOverviewGUI extends BannerGUI +{ + private ClanBanner _banner; + + public NonEditOverviewGUI(Player viewer, ClanBanner banner) + { + super(viewer, "Clan Banner", 9); + _banner = banner; + + propagate(); + open(); + } + + @Override + public void propagate() + { + ItemStack banner = _banner.getBanner().clone(); + ItemMeta im = banner.getItemMeta(); + im.setDisplayName(C.cGreen + "Clan Banner"); + im.setLore(Arrays.asList(new String[] {F.elem("Left Click") + " to toggle wearing your banner", F.elem("Right Click") + " to place down your banner"})); + banner.setItemMeta(im); + getItems().put(4, banner); + + if (_banner.getClan().getMembers().get(getViewer().getUniqueId()).getRole() == ClanRole.LEADER && ClansManager.getInstance().getBannerManager().getBannerUnlockLevel(getViewer()) >= 2) + { + getItems().put(8, new ItemBuilder(Material.ANVIL).setTitle(C.cGold + "Edit Your Banner").build()); + } + refresh(); + } + + @Override + public void onClick(Integer slot, ClickType type) + { + if (slot == 4) + { + if (type == ClickType.LEFT) + { + BannerPacketManager.getInstance().toggleBanner(getViewer(), _banner.getBanner()); + UtilPlayer.message(getViewer(), F.main("Clan Banners", "You have toggled your banner!")); + } + else if (type == ClickType.RIGHT) + { + _banner.place(getViewer()); + } + } + if (slot == 8) + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new OverviewGUI(getViewer(), _banner); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java new file mode 100644 index 000000000..a60ba1886 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java @@ -0,0 +1,124 @@ +package mineplex.game.clans.clans.banners.gui.overview; + +import java.util.Arrays; + +import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.creation.BaseColorSelectionGUI; +import mineplex.game.clans.clans.banners.gui.creation.PatternColorSelectionGUI; +import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.MaterialData; + +/** + * GUI manager for overviewing a banner's design + */ +public class OverviewGUI extends BannerGUI +{ + private static final int MAX_BANNER_LAYERS = 12; + private static final int PATTERN_DISPLAY_START_SLOT = 27; + private final ClanBanner _banner; + + public OverviewGUI(Player viewer, ClanBanner banner) + { + super(viewer, "Clan Banner", 45); + _banner = banner; + + propagate(); + open(); + } + + @Override + @SuppressWarnings("deprecation") + public void propagate() + { + getItems().put(4, _banner.getBanner()); + ItemStack color = new MaterialData(Material.INK_SACK, _banner.getBaseColor().getDyeData()).toItemStack(1); + ItemMeta colorMeta = color.getItemMeta(); + colorMeta.setDisplayName(C.cGray); + color.setItemMeta(colorMeta); + getItems().put(22, color); + Integer slot = PATTERN_DISPLAY_START_SLOT; + for (int i = 0; i < MAX_BANNER_LAYERS; i++) + { + ItemStack item = new ItemStack(Material.INK_SACK, 1, (short)8); + if (i < _banner.getPatterns().size()) + { + BannerPattern pattern = _banner.getPatterns().get(i); + if (pattern.getBukkitPattern() != null) + { + ItemStack representation = new ItemStack(Material.BANNER); + BannerMeta im = (BannerMeta) representation.getItemMeta(); + im.setBaseColor(_banner.getBaseColor()); + im.setDisplayName(C.cGray); + im.setPatterns(Arrays.asList(pattern.getBukkitPattern())); + representation.setItemMeta(im); + item = representation; + } + } + getItems().put(slot, item); + slot++; + } + refresh(); + } + + @Override + public void onClick(Integer slot, ClickType type) + { + if (slot == 4) + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new NonEditOverviewGUI(getViewer(), _banner); + }, 2L); + } + if (slot == 22) + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new BaseColorSelectionGUI(getViewer(), _banner); + }, 2L); + } + if (slot >= PATTERN_DISPLAY_START_SLOT) + { + if (type == ClickType.RIGHT) + { + _banner.getPatterns().get(slot - PATTERN_DISPLAY_START_SLOT).setColor(null); + ClansManager.getInstance().runSyncLater(() -> + { + getItems().clear(); + propagate(); + refresh(); + }, 1L); + } + else + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new PatternColorSelectionGUI(getViewer(), _banner, slot - PATTERN_DISPLAY_START_SLOT); + }, 2L); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java index cda7ab480..baf413b43 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java @@ -1,40 +1,14 @@ package mineplex.game.clans.clans.commands; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInput; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClanRole; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.ClientClan; -import mineplex.game.clans.items.CustomItem; -import mineplex.game.clans.items.GearManager; -import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; -import mineplex.game.clans.items.attributes.weapon.FrostedAttribute; -import mineplex.game.clans.items.attributes.weapon.SharpAttribute; -import mineplex.game.clans.items.legendaries.LegendaryItem; -import mineplex.game.clans.items.legendaries.WindBlade; + +import org.bukkit.entity.Player; public class ClanManagementCommand extends CommandBase { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 059e55d54..db1320461 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -349,6 +349,12 @@ public class ClansCommand extends CommandBase return; } + if (Plugin.getTutorial().inTutorial(caller)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot invite others while in a tutorial.")); + return; + } + if (args.length < 2) { UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee.")); @@ -925,6 +931,13 @@ public class ClansCommand extends CommandBase return; } + if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(caller).GetLastCombatEngaged(), 15000)) + { + long remain = _clansManager.getCombatManager().Get(caller).GetLastCombatEngaged() + 15000 - System.currentTimeMillis(); + UtilPlayer.message(caller, F.main("Clans", "You are combat tagged for " + F.elem(UtilTime.MakeStr(remain)) + "!")); + return; + } + // Event ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "tphome"); UtilServer.getServer().getPluginManager().callEvent(event); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 7432c7a66..ff64efdb3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.commands; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; import org.bukkit.ChatColor; @@ -69,7 +70,7 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor } @Override - public void processLoginResultSet(final String playerName, int accountId, ResultSet resultSet) throws SQLException + public void processLoginResultSet(final String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { if (_enabled) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index 611838bd7..7f9b6f85a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -1,15 +1,14 @@ package mineplex.game.clans.clans.commands; -import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.classcombat.Skill.Global.Recharge; -import org.bukkit.entity.Player; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.entity.Player; + public class KillCommand extends CommandBase { public KillCommand(DamageManager plugin) @@ -35,9 +34,14 @@ public class KillCommand extends CommandBase UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding")); return; } + if (ClansManager.getInstance().getClanUtility().isSafe(caller.getLocation()) || (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn"))) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!")); + return; + } UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); caller.setHealth(0D); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java index 39815a0f8..e6fa820b5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java @@ -1,15 +1,15 @@ package mineplex.game.clans.clans.gui.button; import mineplex.core.common.util.UtilServer; +import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.TextComponent; + import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.shop.item.IButton; - public class ClanCreateButton implements IButton { public ClanCreateButton() @@ -20,6 +20,14 @@ public class ClanCreateButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)); + if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)).isCancelled()) + { + return; + } + + TextComponent message = new TextComponent("Click Here to create a Clan!"); + message.setColor(ChatColor.AQUA); + message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/c create ")); + player.spigot().sendMessage(message); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java index 5550d370a..e38ed4b1b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java @@ -65,7 +65,6 @@ public class ClanWhoPage extends ClanPageBase lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT) + " ago on " + UtilTime.when(_lookupClan.getDateCreated().getTime())); lore.add(C.Reset + C.cYellow + "Members " + C.cWhite + _lookupClan.getOnlinePlayerCount() + "/" + _lookupClan.getMembers().size()); lore.add(C.Reset + C.cYellow + "Territory " + C.cWhite + _lookupClan.getClaims() + "/" + _lookupClan.getClaimsMax()); - lore.add(C.Reset + C.cYellow + "TNT Protection " + C.cWhite + _lookupClan.getProtected()); if (clanInfo != null) { lore.add(C.Reset + C.cYellow + "Your War Points " + C.cWhite + clanInfo.getFormattedWarPoints(_lookupClan)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java index 69283e71a..61fcf7cd7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java @@ -110,17 +110,20 @@ public class InvseeInventory implements Listener else { // This should always work - _targetPlayer = Bukkit.getOfflinePlayer(_uuid); - updateInventory(); + if (_uuid.equals(event.getPlayer().getUniqueId())) + { + _targetPlayer = Bukkit.getOfflinePlayer(_uuid); + updateInventory(); + } } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void on(InventoryOpenEvent event) { - if (event.getPlayer().getUniqueId().equals(_targetPlayer.getUniqueId()) && !_canOpenInventory) + if (event.getPlayer().getUniqueId().equals(_uuid) && !_canOpenInventory) { - event.setCancelled(true); + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> {event.getPlayer().closeInventory();}, 20); } } @@ -295,7 +298,7 @@ public class InvseeInventory implements Listener } } - /* + /** * Update the player inventory and invsee inventory. * * @param targetClick If true, then it means the player being invseen has modified their inventory. Otherwise, it's the admin who has modified something diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java index c65d2cd33..343871074 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java @@ -17,7 +17,7 @@ public class GearLoot implements ILoot @Override public void dropLoot(Location location) { - _gearManager.spawnItem(location); + _gearManager.spawnItem(location.clone().add(0, 3, 0)); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java index 03707ad93..82875cea8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java @@ -1,8 +1,11 @@ package mineplex.game.clans.clans.loot; +import org.bukkit.Color; import org.bukkit.Location; +import org.bukkit.FireworkEffect.Type; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.game.clans.items.economy.GoldToken; @@ -23,7 +26,8 @@ public class GoldTokenLoot implements ILoot int gold = _minGold + UtilMath.r(_maxGold - _minGold); GoldToken token = new GoldToken(gold); - location.getWorld().dropItemNaturally(location, token.toItemStack()); + UtilFirework.playFirework(location.clone().add(0, 3, 0), Type.BALL, Color.YELLOW, true, false); + location.getWorld().dropItemNaturally(location.clone().add(0, 3, 0), token.toItemStack()); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java index 49143cff6..3e7735e01 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.murder; import java.util.Arrays; import java.util.List; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; @@ -204,7 +205,7 @@ public class MurderManager extends MiniClientPlugin } @Override - protected ClientMurder addPlayer(String player) + protected ClientMurder addPlayer(UUID uuid) { return new ClientMurder(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java new file mode 100644 index 000000000..815897c4e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -0,0 +1,313 @@ +package mineplex.game.clans.clans.nether; + +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.potion.PotionEffectType; + +import com.google.common.collect.Lists; + +/** + * Data and listener class for individual nether portals opened by bosses + */ +public class BossNetherPortal implements Listener +{ + private static final int SECONDS_UNTIL_PORTAL = 5; + private List _frame = Lists.newArrayList(); + private List _portal = Lists.newArrayList(); + private Location _loc; + private Location[] _corners; + private boolean _returnPortal; + private byte _portalFacing; + private LinkedList _closeWarnings = new LinkedList<>(); + + public boolean Open = false; + public long Expire = -1; + + public BossNetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal) + { + int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); + int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY()); + int minY = Math.min(firstCorner.getBlockY(), secondCorner.getBlockY()); + int maxZ = Math.max(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + int minZ = Math.min(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + if (minX == maxX) + { + if ((y != minY && y != maxY) && (z != minZ && z != maxZ)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + else + { + if ((x != minX && x != maxX) && (y != minY && y != maxY)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + } + } + } + + _loc = new Location(firstCorner.getWorld(), minX + ((maxX - minX) / 2), maxY, minZ + ((maxZ - minZ) / 2)); + _corners = new Location[] {firstCorner, secondCorner}; + _returnPortal = returnPortal; + + if (maxX == minX) + { + _portalFacing = (byte)2; + } + else + { + _portalFacing = (byte)0; + } + } + + private boolean isInPortal(Block block) + { + return _frame.contains(block) || _portal.contains(block); + } + + /** + * Gets the center location of this portal + * @return The center location of this portal + */ + public Location getLocation() + { + return _loc; + } + + /** + * Gets the corners of this portal + * @return An array of the corners of this portal + */ + public Location[] getCorners() + { + return _corners; + } + + /** + * Checks if this portal is a return portal + * @return Whether this portal is a return portal + */ + public boolean isReturnPortal() + { + return _returnPortal; + } + + /** + * Opens this portal for a given duration + * @param duration The duration to hold the portal open for + */ + @SuppressWarnings("deprecation") + public void open(long duration) + { + if (Open) + { + if (Expire != -1) + { + Expire = Expire + duration; + } + } + else + { + if (!_returnPortal) + { + Expire = System.currentTimeMillis() + duration; + } + Open = true; + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + for (Block block : _frame) + { + block.setType(Material.OBSIDIAN); + } + for (Block block : _portal) + { + block.setType(Material.PORTAL); + block.setData(_portalFacing); + } + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); + } + } + + /** + * Closes this portal and clears away its blocks + */ + public void close() + { + Open = false; + Expire = -1; + for (Block block : _portal) + { + block.setType(Material.AIR); + } + for (Block block : _frame) + { + block.setType(Material.AIR); + } + HandlerList.unregisterAll(this); + _closeWarnings.clear(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBreak(BlockDamageEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setInstaBreak(false); + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy a " + F.clansNether("Nether Portal"))); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void playerPortalEvent(PlayerPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void entityPortalEvent(EntityPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onEnterPortal(EntityPortalEnterEvent event) + { + if (event.getEntity() instanceof Player) + { + if (isInPortal(event.getLocation().getBlock())) + { + Bukkit.getScheduler().runTaskLater(ClansManager.getInstance().getPlugin(), () -> + { + if (isInPortal(event.getEntity().getLocation().getBlock())) + { + if (isReturnPortal()) + { + ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity()); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity())); + ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); + ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); + UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); + }, 20); + } + else + { + ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); + } + } + }, SECONDS_UNTIL_PORTAL * 20); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void handleExpiration(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (Open && Expire != -1) + { + Long warning = -1L; + for (Long test : _closeWarnings) + { + if ((Expire - System.currentTimeMillis()) < warning) + { + warning = test; + break; + } + } + if (warning != -1) + { + _closeWarnings.remove(warning); + Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!")); + } + } + if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) + { + close(); + ClansManager.getInstance().getNetherManager().BossPortals.remove(this); + } + } + + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + if (event.getChunk().getX() == _loc.getChunk().getX() && event.getChunk().getZ() == _loc.getChunk().getZ()) + { + event.setCancelled(true); + } + } +} \ No newline at end of file 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 b17121c43..a14a74b58 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 @@ -1,6 +1,7 @@ package mineplex.game.clans.clans.nether; -import java.io.File; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; import org.bukkit.Bukkit; @@ -9,110 +10,326 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.WorldBorder; +import org.bukkit.WorldCreator; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; +import mineplex.core.common.generator.VoidGenerator; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilCollections; -import mineplex.core.common.util.UtilFile; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.nether.command.ForceTeleportCommand; +import mineplex.game.clans.clans.nether.command.PortalCommand; +import mineplex.game.clans.clans.nether.data.ClaimData; +import mineplex.game.clans.clans.nether.miniboss.NetherMinibossManager; +import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +/** + * Manager for all nether features + */ public class NetherManager extends MiniPlugin { - private ClansManager _clansManager; - + private static final long PORTAL_OPEN_DURATION = UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + 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 PortalRepository _repo; + private NetherMinibossManager _miniboss; private World _netherWorld; + private List _portals = Lists.newArrayList(); + public List BossPortals = Lists.newArrayList(); + private List _returnPortals = Lists.newArrayList(); + public HashMap InNether = new HashMap<>(); + public HashMap OverworldOrigins = new HashMap<>(); + public HashMap Claiming = new HashMap<>(); - private List _portals = Lists.newArrayList(); - - private File _portalCfg; - - public NetherManager(ClansManager clansManager) + public NetherManager(ClansManager manager) { - super("Nether Manager", clansManager.getPlugin()); - _clansManager = clansManager; - - _portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "nether.cfg"); + super("Nether", manager.getPlugin()); begin(); + _miniboss = new NetherMinibossManager(this); + addCommand(new PortalCommand(this)); + addCommand(new ForceTeleportCommand(this)); } - public void begin() + private void begin() { - _netherWorld = Bukkit.getWorld("world_nether"); - + if (Bukkit.getWorld("nether") == null) + { + WorldCreator creator = new WorldCreator("nether"); + creator.generator(new VoidGenerator()); + Bukkit.createWorld(creator); + } + _netherWorld = Bukkit.getWorld("nether"); + _netherWorld.setSpawnLocation(43, 135, 113); WorldBorder worldBorder = _netherWorld.getWorldBorder(); worldBorder.setCenter(0, 0); - worldBorder.setSize(200 * 2); + worldBorder.setSize(800 * 2); - parsePortals(); + _repo = new PortalRepository(getPlugin(), this); + loadPortals(); } - private void parsePortals() + private void loadPortals() { - String data = UtilFile.read(_portalCfg); - - if (data.length() < 5) + _repo.loadPortals(); + } + + @Override + public void disable() + { + closePortals(); + for (Player player : InNether.keySet()) { - return; + player.teleport(Spawn.getNorthSpawn()); + } + InNether.clear(); + } + + /** + * Get the manager for nether miniboss + * @return The loaded Nether Miniboss manager + */ + public NetherMinibossManager getMinibossManager() + { + return _miniboss; + } + + /** + * Gets the Nether world + * @return The Nether world + */ + public World getNetherWorld() + { + return _netherWorld; + } + + /** + * Checks if a player is in the nether + * @param player The player to check + * @return Whether the player is in the nether + */ + public boolean isInNether(Player player) + { + return player.getWorld().equals(_netherWorld); + } + + /** + * Gets the place a player will exit the nether + * @param player The player to check + * @return The place the player will exit the nether + */ + public Location getReturnLocation(Player player) + { + Location defaultLoc = Spawn.getWestTown(); + if (UtilMath.random.nextDouble() <= .5) + { + defaultLoc = Spawn.getEastTown(); + } + return OverworldOrigins.getOrDefault(player, defaultLoc); + } + + /** + * Fetches the nether portal with the given id + * @param id The id of the portal + * @return The nether portal with the given id + */ + public NetherPortal getPortal(int id) + { + for (NetherPortal portal : _portals) + { + if (portal.getId() == id) + { + return portal; + } } - UtilCollections.forEach(data.split("\n"), string -> string.trim(), sPortal -> { - - String[] destinations = sPortal.split(">>"); - - Location from = UtilWorld.strToLoc(destinations[0]); - Location to = UtilWorld.strToLoc(destinations[1].split(":")[0]); - - Portal portal = Portal.create(from, to, UtilWorld.strToLoc(to.getWorld().getName() + "," + destinations[1].split(":")[1])); - - if (portal == null) + return null; + } + + /** + * Loads a nether portal into the manager + * @param portal The portal to load + */ + public void addPortal(NetherPortal portal) + { + _portals.add(portal); + if (portal.isReturnPortal()) + { + _returnPortals.add(portal); + } + _portals.sort(new Comparator() + { + public int compare(NetherPortal o1, NetherPortal o2) { - log("FAILED TO LOAD PORTAL [" + sPortal + "]"); - } - else - { - _portals.add(portal); + if (o1.getId() > o2.getId()) + { + return 1; + } + return -1; } }); } - - - @EventHandler - public void cmd(PlayerCommandPreprocessEvent event) + + /** + * Deletes a nether portal and removes it from the database + * @param portal The portal to remove + */ + public void deletePortal(NetherPortal portal) { - if (!_clansManager.getClientManager().hasRank(event.getPlayer(), Rank.JNR_DEV)) + portal.close(); + _portals.remove(portal); + _returnPortals.remove(portal); + _repo.deletePortal(portal.getId()); + } + + /** + * Spawns a nether portal for a given duration + * @param duration The duration to maintain the portal for + */ + public void spawnPortal(long duration) + { + if (_portals.isEmpty() || _returnPortals.isEmpty()) { return; } - - if (event.getMessage().startsWith("/nether")) + List available = Lists.newArrayList(); + available.addAll(_portals); + for (NetherPortal remove : _returnPortals) { - event.getPlayer().teleport(new Location(_netherWorld, 0, 90, 0)); - event.setCancelled(true); + available.remove(remove); } + if (available.isEmpty()) + { + return; + } + NetherPortal portal = available.get(UtilMath.r(available.size())); + portal.open(duration); + for (NetherPortal returnPortal : _returnPortals) + { + returnPortal.open(-1); + } + UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(duration)) + "!")); + } + + /** + * Spawns a portal for the default remain duration + */ + public void spawnPortal() + { + spawnPortal(PORTAL_OPEN_DURATION); + } + + /** + * Spawns a nether portal when a boss dies + * @param bossSpawn The location where the boss spawned in + */ + public void spawnBossPortal(Location bossSpawn) + { + if (_returnPortals.isEmpty()) + { + return; + } + BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(2, 0, 0), false); + portal.open(PORTAL_OPEN_DURATION); + for (NetherPortal returnPortal : _returnPortals) + { + returnPortal.open(-1); + } + UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(PORTAL_OPEN_DURATION)) + "!")); + } + + /** + * Creates a portal with the player's stored corners + * @param creator The creator of the portal + * @param returnPortal Whether the portal is a return portal + */ + public void createPortal(Player creator, boolean returnPortal) + { + if (Claiming.getOrDefault(creator, new ClaimData()).getTotalSelected() < 2) + { + UtilPlayer.message(creator, F.main(getName(), "You do not have a top and bottom corner selected!")); + return; + } + + ClaimData data = Claiming.remove(creator); + _repo.addPortal(UtilWorld.locToStr(data.getFirstCorner().getLocation()), UtilWorld.locToStr(data.getSecondCorner().getLocation()), returnPortal); + UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!")); + } + + /** + * Closes all portals and clears away their blocks + */ + public void closePortals() + { + for (NetherPortal portal : _portals) + { + portal.close(); + } + for (BossNetherPortal portal : BossPortals) + { + portal.close(); + } + BossPortals.clear(); + } + + /** + * Displays a list of all portals to a player + * @param player The player to display the list to + */ + public void showPortalList(Player player) + { + UtilPlayer.message(player, F.main(getName(), "Portal List:")); + for (NetherPortal portal : _portals) + { + UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + portal.getId() + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", ""))); + } + } + + /** + * Gives a player a portal claim wand + * @param player The player to give the wand to + */ + public void giveWand(Player player) + { + player.getInventory().addItem(CLAIM_WAND.clone()); + UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!")); } @EventHandler @@ -120,7 +337,6 @@ public class NetherManager extends MiniPlugin { Block block = event.getBlock(); Player player = event.getPlayer(); - ItemStack item = player.getItemInHand(); if (player.getGameMode() == GameMode.CREATIVE) { @@ -132,28 +348,8 @@ public class NetherManager extends MiniPlugin return; } - _portals - .stream() - .filter(portal -> UtilAlg.getAverageBlockLocation(portal.getToBlocks()).distance(block.getLocation()) < 15) - .limit(1) - .forEach(portal -> { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to break this block.")); - event.setCancelled(true); - }); - - if (!item.getType().equals(Material.GOLD_PICKAXE)) - { - UtilPlayer.message(player, F.main("Clans", "You can only break blocks in the Nether with a " + F.elem("Golden Pickaxe") + ".")); - event.setCancelled(true); - return; - } - - if (block.getType().equals(Material.OBSIDIAN) || block.getType().equals(Material.PORTAL)) - { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to break this block.")); - event.setCancelled(true); - return; - } + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build in " + F.clansNether("The Nether") + "!")); } @EventHandler @@ -161,7 +357,6 @@ public class NetherManager extends MiniPlugin { Block block = event.getBlock(); Player player = event.getPlayer(); - ItemStack item = player.getItemInHand(); if (player.getGameMode() == GameMode.CREATIVE) { @@ -173,28 +368,32 @@ public class NetherManager extends MiniPlugin return; } - if (!UtilItem.isFromNether(item)) + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build in " + F.clansNether("The Nether") + "!")); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPortal(PlayerPortalEvent event) + { + if (event.getTo() == null || event.getTo().getWorld().equals(_netherWorld)) { - UtilPlayer.message(player, F.main("Clans", "You can only place blocks here that come from " + F.clansNether("The Nether") + ".")); - event.setCancelled(true); return; } - - _portals - .stream() - .filter(portal -> UtilAlg.getAverageBlockLocation(portal.getToBlocks()).distance(block.getLocation()) < 15) - .limit(1) - .forEach(portal -> { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to place blocks here.")); - event.setCancelled(true); - }); - - if (block.getType().equals(Material.OBSIDIAN) || block.getType().equals(Material.PORTAL)) + event.setCancelled(true); + runSyncLater(() -> { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to place blocks here.")); - event.setCancelled(true); - return; - } + InNether.remove(event.getPlayer()); + event.getPlayer().teleport(getReturnLocation(event.getPlayer())); + OverworldOrigins.remove(event.getPlayer()); + event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + }, 1); + } + + @EventHandler + public void onPortal(EntityPortalEvent event) + { + event.setCancelled(true); } @EventHandler @@ -202,76 +401,132 @@ public class NetherManager extends MiniPlugin { if (event.getType() == UpdateType.FAST) { + List netherKeys = Lists.newArrayList(); + netherKeys.addAll(InNether.keySet()); + for (Player player : netherKeys) + { + if (System.currentTimeMillis() >= InNether.get(player)) + { + InNether.remove(player); + if (isInNether(player)) + { + player.teleport(getReturnLocation(player)); + OverworldOrigins.remove(player); + player.removePotionEffect(PotionEffectType.NIGHT_VISION); + UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!")); + } + } + else + { + if (!player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) + { + int ticks = (int)((InNether.get(player) - System.currentTimeMillis()) / 1000) * 20; + player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, ticks, 0)); + } + } + } + UtilServer.getPlayersCollection() - .stream() - .filter(player -> player.getWorld().equals(_netherWorld)) - .forEach(player -> { - player.setCompassTarget(new Location(_netherWorld, -200.d + UtilMath.r(400), player.getLocation().getY(), -200.d + UtilMath.r(400))); - _clansManager.getItemMapManager().removeMap(player); - }); - } - - if (event.getType() == UpdateType.SLOW) - { - _portals.forEach(portal -> { - portal.getFromObsidianBlocks().forEach(block -> UtilBlock.setSilent(block, Material.OBSIDIAN)); - portal.getFromPortalBlocks().forEach(block -> UtilBlock.setSilent(block, Material.PORTAL)); - - portal.getToObsidianBlocks().forEach(block -> UtilBlock.setSilent(block, Material.OBSIDIAN)); - portal.getToPortalBlocks().forEach(block -> UtilBlock.setSilent(block, Material.PORTAL)); - }); + .stream() + .filter(player -> isInNether(player)) + .forEach(player -> + { + ClansManager.getInstance().getItemMapManager().removeMap(player); + }); } } - @EventHandler(priority = EventPriority.HIGHEST) - public void onPortal(PlayerPortalEvent event) + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerQuitEvent event) { - Player player = event.getPlayer(); - Location location = player.getLocation(); - - ClanTerritory territory = _clansManager.getClanUtility().getClaim(location); - - if (event.getTo().getWorld().equals(_netherWorld)) + if (isInNether(event.getPlayer())) { - if (territory != null && territory.Owner.equals("Borderlands")) + InNether.remove(event.getPlayer()); + event.getPlayer().teleport(getReturnLocation(event.getPlayer())); + OverworldOrigins.remove(event.getPlayer()); + event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); + } + Claiming.remove(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDie(PlayerDeathEvent event) + { + InNether.remove(event.getEntity()); + OverworldOrigins.remove(event.getEntity()); + Claiming.remove(event.getEntity()); + } + + @EventHandler + public void onTpHome(ClansCommandExecutedEvent event) + { + if (event.getCommand().equalsIgnoreCase("tphome")) + { + if (isInNether(event.getPlayer())) { - _portals - .stream() - .filter(portal -> - portal.getFromPortalBlocks() - .stream() - .filter(block -> player.getLocation().distance(block.getLocation()) <= 2) - .iterator().hasNext() - ).limit(1) - .forEach(portal -> { - event.setTo(portal.getToOut()); - _clansManager.ClanTips.displayTip(TipType.ENTER_NETHER, player); - }); + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while in " + F.clansNether("The Nether") + "!")); } } - else + } + + @EventHandler + public void onDropWand(PlayerDropItemEvent event) + { + ItemStack item = event.getItemDrop().getItemStack(); + if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(CLAIM_WAND_NAME)) { - _portals - .stream() - .filter(portal -> - portal.getToPortalBlocks() - .stream() - .filter(block -> player.getLocation().distance(block.getLocation()) <= 2) - .iterator().hasNext() - ).limit(1) - .forEach(portal -> { - event.setTo(UtilAlg.getAverageBlockLocation(portal.getFromPortalBlocks())); - }); + runSyncLater(() -> + { + event.getItemDrop().remove(); + }, 1L); } } - public World getNetherWorld() + @EventHandler + public void onUseWand(PlayerInteractEvent event) { - return _netherWorld; + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) + { + return; + } + if (!event.hasBlock() || !event.hasItem()) + { + return; + } + if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.ADMIN)) + { + return; + } + ItemStack item = event.getItem(); + if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(CLAIM_WAND_NAME)) + { + Block block = event.getClickedBlock(); + if (!Claiming.containsKey(event.getPlayer())) + { + Claiming.put(event.getPlayer(), new ClaimData()); + } + ClaimData data = Claiming.get(event.getPlayer()); + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + data.setSecondCorner(block); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have selected the Portal's second corner!")); + } + else + { + data.setFirstCorner(block); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have selected the Portal's first corner!")); + } + event.setCancelled(true); + } } - - public boolean isInNether(Player player) + + @EventHandler + public void onBossDeath(EventCreatureDeathEvent event) { - return player.getWorld().equals(_netherWorld); + if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) + { + spawnBossPortal(event.getCreature().getEvent().getCenterLocation().clone().subtract(0, 1, 0)); + } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java new file mode 100644 index 000000000..2e3ea55d4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -0,0 +1,323 @@ +package mineplex.game.clans.clans.nether; + +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.potion.PotionEffectType; + +import com.google.common.collect.Lists; + +/** + * Data and listener class for individual nether portals + */ +public class NetherPortal implements Listener +{ + private static final int SECONDS_UNTIL_PORTAL = 5; + private int _id; + private List _frame = Lists.newArrayList(); + private List _portal = Lists.newArrayList(); + private Location _loc; + private Location[] _corners; + private boolean _returnPortal; + private byte _portalFacing; + private LinkedList _closeWarnings = new LinkedList<>(); + + public boolean Open = false; + public long Expire = -1; + + public NetherPortal(int id, Location firstCorner, Location secondCorner, boolean returnPortal) + { + _id = id; + int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); + int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY()); + int minY = Math.min(firstCorner.getBlockY(), secondCorner.getBlockY()); + int maxZ = Math.max(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + int minZ = Math.min(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + if (minX == maxX) + { + if ((y != minY && y != maxY) && (z != minZ && z != maxZ)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + else + { + if ((x != minX && x != maxX) && (y != minY && y != maxY)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + } + } + } + + _loc = new Location(firstCorner.getWorld(), minX + ((maxX - minX) / 2), maxY, minZ + ((maxZ - minZ) / 2)); + _corners = new Location[] {firstCorner, secondCorner}; + _returnPortal = returnPortal; + + if (maxX == minX) + { + _portalFacing = (byte)2; + } + else + { + _portalFacing = (byte)0; + } + } + + private boolean isInPortal(Block block) + { + return _frame.contains(block) || _portal.contains(block); + } + + /** + * Gets the id of this portal + * @return This portal's id + */ + public int getId() + { + return _id; + } + + /** + * Gets the center location of this portal + * @return The center location of this portal + */ + public Location getLocation() + { + return _loc; + } + + /** + * Gets the corners of this portal + * @return An array of the corners of this portal + */ + public Location[] getCorners() + { + return _corners; + } + + /** + * Checks if this portal is a return portal + * @return Whether this portal is a return portal + */ + public boolean isReturnPortal() + { + return _returnPortal; + } + + /** + * Opens this portal for a given duration + * @param duration The duration to hold the portal open for + */ + @SuppressWarnings("deprecation") + public void open(long duration) + { + if (Open) + { + if (Expire != -1) + { + Expire = Expire + duration; + } + } + else + { + if (!_returnPortal) + { + Expire = System.currentTimeMillis() + duration; + } + Open = true; + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + for (Block block : _frame) + { + block.setType(Material.OBSIDIAN); + } + for (Block block : _portal) + { + block.setType(Material.PORTAL); + block.setData(_portalFacing); + } + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); + } + } + + /** + * Closes this portal and clears away its blocks + */ + public void close() + { + Open = false; + Expire = -1; + for (Block block : _portal) + { + block.setType(Material.AIR); + } + for (Block block : _frame) + { + block.setType(Material.AIR); + } + HandlerList.unregisterAll(this); + _closeWarnings.clear(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBreak(BlockDamageEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setInstaBreak(false); + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy a " + F.clansNether("Nether Portal"))); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void playerPortalEvent(PlayerPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void entityPortalEvent(EntityPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onEnterPortal(EntityPortalEnterEvent event) + { + if (event.getEntity() instanceof Player) + { + if (isInPortal(event.getLocation().getBlock())) + { + Bukkit.getScheduler().runTaskLater(ClansManager.getInstance().getPlugin(), () -> + { + if (isInPortal(event.getEntity().getLocation().getBlock())) + { + if (isReturnPortal()) + { + ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity()); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity())); + ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); + ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); + UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); + }, 20); + } + else + { + ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); + } + } + }, SECONDS_UNTIL_PORTAL * 20); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void handleExpiration(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (Open && Expire != -1) + { + Long warning = -1L; + for (Long test : _closeWarnings) + { + if ((Expire - System.currentTimeMillis()) < test) + { + warning = test; + break; + } + } + if (warning != -1) + { + _closeWarnings.remove(warning); + Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!")); + } + } + if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) + { + close(); + } + } + + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + if (event.getChunk().getX() == _loc.getChunk().getX() && event.getChunk().getZ() == _loc.getChunk().getZ()) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java deleted file mode 100644 index 362599881..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java +++ /dev/null @@ -1,143 +0,0 @@ -package mineplex.game.clans.clans.nether; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; - -import com.google.common.collect.Lists; - -import mineplex.core.common.util.UtilBlock; - -public class Portal -{ - private List _fromPortalBlocks; - private List _fromObsidianBlocks; - - private List _toPortalBlocks; - private List _toObsidianBlocks; - - private List _fromBlocks; - private List _toBlocks; - - private Location _toOut; - - public final boolean Success; - - public Portal(Location from, Location to, Location toOut) - { - _fromPortalBlocks = Lists.newArrayList(); - _fromObsidianBlocks = Lists.newArrayList(); - - _toPortalBlocks = Lists.newArrayList(); - _toObsidianBlocks = Lists.newArrayList(); - - _toOut = toOut; - - if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock())) - { - if (!isValidPortalBlock(from.getBlock())) - from = UtilBlock.getInRadius(from.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); - - if (!isValidPortalBlock(to.getBlock())) - to = UtilBlock.getInRadius(to.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); - - if (to == null || from == null) - { - System.out.println("[PORTAL] INVALID PORTAL PROVIDED (" + from + " --> " + to + ")"); - - Success = false; - - return; - } - } - - for (Block other : UtilBlock.getInRadius(from, 25).keySet()) - { - if (other.getType() == Material.OBSIDIAN) - { - _fromObsidianBlocks.add(other); - } - else if (other.getType() == Material.PORTAL) - { - _fromPortalBlocks.add(other); - } - } - - for (Block other : UtilBlock.getInRadius(to, 7.5d).keySet()) - { - if (other.getType() == Material.OBSIDIAN) - { - _toObsidianBlocks.add(other); - } - else if (other.getType() == Material.PORTAL) - { - _toPortalBlocks.add(other); - } - } - - _fromBlocks = new ArrayList<>(); - _toBlocks = new ArrayList<>(); - - _fromBlocks.addAll(_fromObsidianBlocks); - _fromBlocks.addAll(_fromPortalBlocks); - _toBlocks.addAll(_toObsidianBlocks); - _toBlocks.addAll(_toPortalBlocks); - - Success = true; - } - - public Location getToOut() - { - return _toOut; - } - - public List getFromPortalBlocks() - { - return _fromPortalBlocks; - } - - public List getFromObsidianBlocks() - { - return _fromObsidianBlocks; - } - - public List getToPortalBlocks() - { - return _toPortalBlocks; - } - - public List getToObsidianBlocks() - { - return _toObsidianBlocks; - } - - public List getFromBlocks() - { - return _fromBlocks; - } - - public List getToBlocks() - { - return _toBlocks; - } - - private boolean isValidPortalBlock(Block block) - { - return block.getType() == Material.OBSIDIAN || block.getType() == Material.PORTAL; - } - - public static Portal create(Location from, Location to, Location toOut) - { - Portal portal = new Portal(from, to, toOut); - - if (!portal.Success) - { - return null; - } - - return portal; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java new file mode 100644 index 000000000..6074de105 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java @@ -0,0 +1,109 @@ +package mineplex.game.clans.clans.nether; + +import mineplex.core.common.util.UtilWorld; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnBoolean; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Database repository class for nether portals + */ +public class PortalRepository extends MinecraftRepository +{ + private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansNetherPortals (id INT NOT NULL AUTO_INCREMENT," + + "cornerOne VARCHAR(30)," + + "cornerTwo VARCHAR(30)," + + "returnPortal BOOL," + + "PRIMARY KEY (id));"; + + private static final String GET_PORTALS = "SELECT * FROM clansNetherPortals;"; + private static final String INSERT_PORTAL = "INSERT INTO clansNetherPortals (cornerOne, cornerTwo, returnPortal) VALUES (?, ?, ?);"; + private static final String DELETE_PORTAL = "DELETE FROM clansNetherPortals WHERE id=?;"; + + private NetherManager _nether; + + public PortalRepository(JavaPlugin plugin, NetherManager portalManager) + { + super(plugin, DBPool.getAccount()); + + _nether = portalManager; + } + + /** + * Loads all stored portals + */ + public void loadPortals() + { + _nether.runAsync(() -> + { + executeQuery(GET_PORTALS, resultSet -> + { + while (resultSet.next()) + { + final int id = resultSet.getInt("id"); + final String cornerOne = resultSet.getString("cornerOne"); + final String cornerTwo = resultSet.getString("cornerTwo"); + final boolean returnPortal = resultSet.getBoolean("returnPortal"); + + _nether.runSync(() -> + { + NetherPortal portal = new NetherPortal(id, UtilWorld.strToLoc(cornerOne), UtilWorld.strToLoc(cornerTwo), returnPortal); + _nether.addPortal(portal); + }); + } + }); + }); + } + + /** + * Adds a portal into the database and loaded portals + * @param cornerOne The serialized first corner of the portal + * @param cornerTwo The serialized second corner of the portal + * @param returnPortal Whether the portal is a return portal + */ + public void addPortal(final String cornerOne, final String cornerTwo, final boolean returnPortal) + { + _nether.runAsync(() -> + { + executeInsert(INSERT_PORTAL, resultSet -> + { + while (resultSet.next()) + { + final int id = resultSet.getInt(1); + _nether.runSync(() -> + { + NetherPortal portal = new NetherPortal(id, UtilWorld.strToLoc(cornerOne), UtilWorld.strToLoc(cornerTwo), returnPortal); + _nether.addPortal(portal); + }); + } + }, new ColumnVarChar("cornerOne", 30, cornerOne), new ColumnVarChar("cornerTwo", 30, cornerTwo), new ColumnBoolean("returnPortal", returnPortal)); + }); + } + + /** + * Deletes the portal with the given id from the database + * @param id The id of the portal to delete + */ + public void deletePortal(final int id) + { + _nether.runAsync(() -> + { + executeUpdate(DELETE_PORTAL, new ColumnInt("id", id)); + }); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE); + } + + @Override + protected void update() + { + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java new file mode 100644 index 000000000..d6a456fad --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java @@ -0,0 +1,27 @@ +package mineplex.game.clans.clans.nether.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +/** + * Command to close all nether portals + */ +public class CloseCommand extends CommandBase +{ + public CloseCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "close"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Closing all " + F.clansNether("Nether Portals") + "!")); + Plugin.closePortals(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java new file mode 100644 index 000000000..c7395e4f3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java @@ -0,0 +1,39 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +/** + * Command to create a nether portal + */ +public class CreateCommand extends CommandBase +{ + public CreateCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "create"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Boolean returnPortal = null; + try + { + returnPortal = Boolean.parseBoolean(args[0]); + } + catch (Exception e) {} + + if (returnPortal == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); + return; + } + + Plugin.createPortal(caller, returnPortal); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java new file mode 100644 index 000000000..cb513218c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -0,0 +1,40 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.game.clans.clans.nether.NetherPortal; + +import org.bukkit.entity.Player; + +/** + * Command to delete a nether portal + */ +public class DeleteCommand extends CommandBase +{ + public DeleteCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "delete", "remove"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Integer id = null; + try + { + id = Integer.parseInt(args[0]); + } + catch (Exception e) {} + if (id == null || Plugin.getPortal(id) == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); + return; + } + NetherPortal portal = Plugin.getPortal(id); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal") + " with ID " + id + "!")); + Plugin.deletePortal(portal); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java new file mode 100644 index 000000000..0bc4ac0be --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -0,0 +1,70 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.game.clans.spawn.Spawn; + +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; + +/** + * Command to artificially portal + */ +public class ForceTeleportCommand extends CommandBase +{ + public ForceTeleportCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "forcePortal"); + } + + @Override + public void Execute(Player caller, String[] args) + { + boolean natural = false; + + if (args.length > 0 && (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("false"))) + { + natural = Boolean.parseBoolean(args[0]); + } + + if (Plugin.isInNether(caller)) + { + if (natural) + { + Plugin.InNether.remove(caller); + caller.teleport(Plugin.getReturnLocation(caller)); + Plugin.OverworldOrigins.remove(caller); + caller.removePotionEffect(PotionEffectType.NIGHT_VISION); + UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getCombatManager().Get(caller).SetLastCombatEngaged(System.currentTimeMillis()); + }, 20); + } + else + { + caller.teleport(Spawn.getNorthSpawn()); + } + } + else + { + if (natural) + { + Plugin.InNether.put(caller, System.currentTimeMillis() + UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + caller.teleport(Plugin.getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller); + } + else + { + caller.teleport(Plugin.getNetherWorld().getSpawnLocation()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java new file mode 100644 index 000000000..d475cf342 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +/** + * Command to list all nether portals + */ +public class ListCommand extends CommandBase +{ + public ListCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "list"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.showPortalList(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java new file mode 100644 index 000000000..f39d5276f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java @@ -0,0 +1,37 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +/** + * Base portal command + */ +public class PortalCommand extends MultiCommandBase +{ + public PortalCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "netherportal", "portal"); + AddCommand(new CreateCommand(plugin)); + AddCommand(new DeleteCommand(plugin)); + AddCommand(new ListCommand(plugin)); + AddCommand(new SpawnCommand(plugin)); + AddCommand(new CloseCommand(plugin)); + AddCommand(new WandCommand(plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " spawn", "Forces a Nether Portal to spawn", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " close", "Closes all Nether Portals", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " list", "Lists all loaded Nether Portals", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " wand", "Gives you a Nether Portal claim wand", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " create", "Creates a Nether Portal with the corners you have selected", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " delete", "Deletes a loaded Nether Portal", Rank.ADMIN)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java new file mode 100644 index 000000000..2763dff60 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java @@ -0,0 +1,27 @@ +package mineplex.game.clans.clans.nether.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +/** + * Command to open a nether portal + */ +public class SpawnCommand extends CommandBase +{ + public SpawnCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "spawn"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Spawning a " + F.clansNether("Nether Portal" + "!"))); + Plugin.spawnPortal(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java new file mode 100644 index 000000000..ef57df1db --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +/** + * Command to give yourself a portal creation wand + */ +public class WandCommand extends CommandBase +{ + public WandCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "wand"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.giveWand(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java new file mode 100644 index 000000000..96570e1be --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java @@ -0,0 +1,66 @@ +package mineplex.game.clans.clans.nether.data; + +import org.bukkit.block.Block; + +/** + * Data class to hold specified player portal corners + */ +public class ClaimData +{ + private Block _first, _second; + + /** + * Fetches the first selected corner + * @return The first selected corner + */ + public Block getFirstCorner() + { + return _first; + } + + /** + * Fetches the second selected corner + * @return The second selected corner + */ + public Block getSecondCorner() + { + return _second; + } + + /** + * Fetches the total count of selected corners + * @return The number of selected corners + */ + public int getTotalSelected() + { + int total = 2; + if (_first == null) + { + total--; + } + if (_second == null) + { + total--; + } + + return total; + } + + /** + * Sets the first selected corner + * @param block The block to set the corner to + */ + public void setFirstCorner(Block block) + { + _first = block; + } + + /** + * Sets the first selected corner + * @param block The block to set the corner to + */ + public void setSecondCorner(Block block) + { + _second = block; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java new file mode 100644 index 000000000..d33ad0de6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java @@ -0,0 +1,89 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +/** + * Manager class for managing boss fireballs + */ +public class MinibossFireball implements Listener +{ + private static final double FIREBALL_EXPLOSION_RANGE = 5; + private static final float SOUND_VOLUME = 1f; + private static final float SOUND_PITCH = 0.8f; + private static final double STRENGTH_MULTIPLIER = 1.6; + private static final double VERT_MULTIPLIER = 0.8; + + public MinibossFireball() + { + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + @EventHandler + public void onHit(ProjectileHitEvent event) + { + Projectile proj = event.getEntity(); + + if (!(proj instanceof LargeFireball)) + { + return; + } + if (!proj.hasMetadata("MINIBOSS_FIREBALL")) + { + return; + } + + HashMap hitMap = UtilEnt.getInRadius(proj.getLocation(), FIREBALL_EXPLOSION_RANGE); + for (LivingEntity cur : hitMap.keySet()) + { + double range = hitMap.get(cur); + + ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 7 * range, false, false); + ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 10, false, true); + UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()), + STRENGTH_MULTIPLIER * range, false, 0, VERT_MULTIPLIER * range, 1.2, true); + } + } + + /** + * Checks if the given projectile is a boss fireball + * @param entity The projectile to check + * @return Whether the given projectile is a boss fireball + */ + public static boolean isFireball(Projectile entity) + { + return entity.hasMetadata("MINIBOSS_FIREBALL"); + } + + /** + * Makes an entity shoot a fireball + * @param shooter The entity to shoot from + */ + public static void launchFireball(LivingEntity shooter) + { + LargeFireball ball = shooter.launchProjectile(LargeFireball.class); + ball.setShooter(shooter); + ball.setIsIncendiary(false); + ball.setYield(0); + ball.setBounce(false); + ball.teleport(shooter.getEyeLocation().add(shooter.getLocation().getDirection().multiply(1))); + ball.setVelocity(new Vector(0,0,0)); + ball.setMetadata("MINIBOSS_FIREBALL", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), shooter)); + shooter.getWorld().playSound(shooter.getLocation(), Sound.GHAST_FIREBALL, SOUND_VOLUME, SOUND_PITCH); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java new file mode 100644 index 000000000..4cebeeb60 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java @@ -0,0 +1,128 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import java.util.Arrays; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.world.ChunkUnloadEvent; + +/** + * Base class for nether minibosses + * @param The type of entity this boss will use + */ +public abstract class NetherMiniBoss implements Listener +{ + private Mob _entity; + private EntityType _type; + private String _name; + private double _maxHealth; + private Location _spawn; + + public NetherMiniBoss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + _name = displayName; + _maxHealth = maxHealth; + _spawn = spawn; + _type = type; + + spawn(); + } + + @SuppressWarnings("unchecked") + private void spawn() + { + _entity = (Mob) _spawn.getWorld().spawnEntity(_spawn, _type); + _entity.setMaxHealth(_maxHealth); + _entity.setHealth(_maxHealth); + _entity.setCustomName(_name); + _entity.setCustomNameVisible(true); + + customSpawn(); + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + /** + * Fetches the entity for this boss + * @return The entity for this boss + */ + public Mob getEntity() + { + return _entity; + } + + /** + * Method called after the entity spawns + */ + public void customSpawn() {}; + + /** + * Method called when the entity dies + * @param deathLocation The location where the entity died + */ + public void customDeath(Location deathLocation) {}; + + /** + * Method called when the entity despawns for non-death reasons + */ + public void customDespawn() {}; + + /** + * Method called for updating every 10 ticks + */ + public void update() {}; + + @EventHandler + public void onDeath(EntityDeathEvent event) + { + if (event.getEntity().equals(_entity)) + { + event.setDroppedExp(0); + event.getDrops().clear(); + HandlerList.unregisterAll(this); + customDeath(event.getEntity().getLocation()); + } + } + + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + if (Arrays.asList(event.getChunk().getEntities()).contains(_entity)) + { + HandlerList.unregisterAll(this); + _entity.remove(); + customDespawn(); + return; + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (!_entity.isValid()) + { + HandlerList.unregisterAll(this); + customDespawn(); + return; + } + + if (_entity.getFireTicks() > 0) + { + _entity.setFireTicks(-1); + } + update(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java new file mode 100644 index 000000000..5f28115a4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -0,0 +1,127 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.world.ChunkUnloadEvent; + +import com.google.common.collect.Lists; + +/** + * Manager to handle miniboss spawning in the nether + */ +public class NetherMinibossManager implements Listener +{ + private static final long MINIBOSS_SPAWN_RATE = 10000; + private NetherManager _manager; + private HashMap _spawns = new HashMap<>(); + private long _lastSpawned; + private boolean _allowSpawn = false; + + public NetherMinibossManager(NetherManager manager) + { + _manager = manager; + new MinibossFireball(); + manager.runSyncLater(() -> + { + List sort = Lists.newArrayList(); + sort.add(new Location(manager.getNetherWorld(), -18, 142, 61)); + sort.add(new Location(manager.getNetherWorld(), -39, 133, -25)); + sort.add(new Location(manager.getNetherWorld(), -102, 133, -99)); + sort.add(new Location(manager.getNetherWorld(), -27, 141, -140)); + sort.add(new Location(manager.getNetherWorld(), 32, 143, -95)); + sort.add(new Location(manager.getNetherWorld(), 43, 134, 22)); + sort.add(new Location(manager.getNetherWorld(), 102, 141, -31)); + sort.add(new Location(manager.getNetherWorld(), 151, 136, 34)); + sort.sort(new Comparator() + { + public int compare(Location o1, Location o2) + { + if (UtilMath.offset2d(o1, manager.getNetherWorld().getSpawnLocation()) < UtilMath.offset(o2, manager.getNetherWorld().getSpawnLocation())) + { + return -1; + } + return 1; + } + }); + for (int i = 0; i < 3; i++) + { + _spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.ARCHER); + } + for (int i = 3; i < 6; i++) + { + _spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.WARRIOR); + } + for (int i = 6; i < 8; i++) + { + _spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.GHAST); + } + Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + }, 20L); + } + + private void spawnAttacker(Location loc) + { + NetherMinibossType bossType = _spawns.get(loc); + + _allowSpawn = true; + bossType.getNewInstance(loc); + _allowSpawn = false; + } + + @EventHandler + public void onSpawnNormal(EntitySpawnEvent event) + { + if (event.getEntity() instanceof LivingEntity && _manager.getNetherWorld().equals(event.getLocation().getWorld())) + { + if (!_allowSpawn) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.LOW) + public void onUnload(ChunkUnloadEvent event) + { + if (_manager.getNetherWorld().equals(event.getWorld())) + { + if (!_manager.InNether.isEmpty()) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void onSpawnThreat(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (!_manager.InNether.isEmpty() && UtilTime.elapsed(_lastSpawned, MINIBOSS_SPAWN_RATE)) + { + _lastSpawned = System.currentTimeMillis(); + for (Location spawn : _spawns.keySet()) + { + spawnAttacker(spawn); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java new file mode 100644 index 000000000..938810015 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -0,0 +1,49 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import mineplex.game.clans.clans.nether.miniboss.bosses.ArcherMiniboss; +import mineplex.game.clans.clans.nether.miniboss.bosses.GhastMiniboss; +import mineplex.game.clans.clans.nether.miniboss.bosses.WarriorMiniboss; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; + +/** + * Enum with all types of nether minibosses + */ +public enum NetherMinibossType +{ + GHAST("Ghast", 25D, EntityType.GHAST, GhastMiniboss.class), + WARRIOR("Undead Warrior", 30D, EntityType.ZOMBIE, WarriorMiniboss.class), + ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class) + ; + + private Class _code; + private String _name; + private Double _maxHealth; + private EntityType _type; + + private NetherMinibossType(String name, Double maxHealth, EntityType type, Class code) + { + _name = name; + _maxHealth = maxHealth; + _type = type; + _code = code; + } + + /** + * Creates a new instance of this miniboss at a given location + * @param spawn The location to spawn the boss in + * @return The instance of the miniboss + */ + public NetherMiniBoss getNewInstance(Location spawn) + { + try + { + return _code.getConstructor(String.class, Double.class, Location.class, EntityType.class).newInstance(_name, _maxHealth, spawn, _type); + } + catch (Exception e) + { + return null; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java new file mode 100644 index 000000000..72ce7c439 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -0,0 +1,203 @@ +package mineplex.game.clans.clans.nether.miniboss.bosses; + +import java.util.Random; + +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +/** + * Class for running an individual Archer miniboss + */ +public class ArcherMiniboss extends NetherMiniBoss +{ + private static final int BARBED_LEVEL = 1; + private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; + + public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + @Override + public void customSpawn() + { + Skeleton entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setItemInHand(new ItemStack(Material.BOW)); + eq.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + eq.setItemInHandDropChance(0.f); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; + } + if (new Random().nextDouble() <= runeDropChance) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bowShoot(EntityShootBowEvent event) + { + if (BARBED_LEVEL == 0) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + if (event.getEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + event.getProjectile().setMetadata("BARBED_ARROW", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), 2)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile projectile = event.GetProjectile(); + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + + if (projectile == null) + { + return; + } + + if (!projectile.hasMetadata("BARBED_ARROW")) + { + return; + } + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (!getEntity().equals(damager)) + { + return; + } + + // Level + if (BARBED_LEVEL == 0) + { + return; + } + + Player damageePlayer = event.GetDamageePlayer(); + + if (damageePlayer != null) + { + damageePlayer.setSprinting(false); + } + + // Damage + event.AddMod(damager.getName(), "Barbed Arrows", projectile.getMetadata("BARBED_ARROW").get(0).asDouble(), false); + + // Condition + ClansManager.getInstance().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java new file mode 100644 index 000000000..45133db1c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -0,0 +1,129 @@ +package mineplex.game.clans.clans.nether.miniboss.bosses; + +import java.util.Random; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; +import mineplex.game.clans.clans.nether.miniboss.MinibossFireball; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; + +/** + * Class for running an individual Ghast miniboss + */ +public class GhastMiniboss extends NetherMiniBoss +{ + private static final long MAIN_FIREBALL_COOLDOWN = 5000; + private static final long FIREBALL_LAUNCH_RATE = 500; + private static final int FIREBALLS_PER_USE = 5; + private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; + private static final double MAX_TARGET_RANGE = 25; + private long _lastFireballUse; + private int _fireballsRemaining; + + public GhastMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + private void tryFireballVolley() + { + if (_fireballsRemaining > 0) + { + if (UtilTime.elapsed(_lastFireballUse, FIREBALL_LAUNCH_RATE)) + { + _fireballsRemaining--; + _lastFireballUse = System.currentTimeMillis(); + MinibossFireball.launchFireball(getEntity()); + } + } + else + { + if (UtilTime.elapsed(_lastFireballUse, MAIN_FIREBALL_COOLDOWN)) + { + _fireballsRemaining = FIREBALLS_PER_USE; + } + } + } + + @Override + public void customSpawn() + { + _lastFireballUse = System.currentTimeMillis(); + _fireballsRemaining = 0; + } + + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; + } + if (new Random().nextDouble() <= runeDropChance) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } + } + + @Override + public void update() + { + Player target = null; + for (Player test : UtilPlayer.getInRadius(getEntity().getLocation(), MAX_TARGET_RANGE).keySet()) + { + if (test.getGameMode() == GameMode.SURVIVAL && !ClansManager.getInstance().getIncognitoManager().Get(test).Hidden) + { + target = test; + break; + } + } + if (target != null) + { + UtilEnt.LookAt(getEntity(), target.getLocation()); + tryFireballVolley(); + } + } + + @EventHandler + public void onShoot(ProjectileLaunchEvent event) + { + if (event.getEntity().getShooter() != null && event.getEntity().getShooter().equals(getEntity())) + { + if (!(event.getEntity() instanceof LargeFireball)) + { + event.setCancelled(true); + } + ClansManager.getInstance().runSyncLater(() -> + { + if (event.getEntity() == null || event.getEntity().isDead() || !event.getEntity().isValid()) + { + return; + } + if (!MinibossFireball.isFireball(event.getEntity())) + { + event.getEntity().remove(); + } + }, 1L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java new file mode 100644 index 000000000..df682506a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -0,0 +1,150 @@ +package mineplex.game.clans.clans.nether.miniboss.bosses; + +import java.util.Random; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +/** + * Class for running an individual Warrior miniboss + */ +public class WarriorMiniboss extends NetherMiniBoss +{ + private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; + private static final double LEAP_CHANCE = .9; + private static final double LEAP_MIN_DIST = 3; + private static final double LEAP_MAX_DIST = 16; + private static final float SOUND_VOLUME = 1f; + private static final float SOUND_PITCH = 2f; + + public WarriorMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + @Override + public void customSpawn() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.IRON_HELMET)); + eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + eq.setBoots(new ItemStack(Material.IRON_BOOTS)); + eq.setItemInHand(new ItemStack(Material.STONE_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; + } + if (new Random().nextDouble() <= runeDropChance) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } + } + + @Override + public void update() + { + if (Math.random() < LEAP_CHANCE) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= LEAP_MIN_DIST || dist > LEAP_MAX_DIST) + return; + + + double power = 0.8 + (1.2 * ((dist-3)/13d)); //Im sorry connor but i have no idea what those numbers are for <3 + + //Leap + UtilAction.velocity(zombie, UtilAlg.getTrajectory(zombie, zombie.getTarget()), + power, false, 0, 0.2, 1, true); + + //Effect + zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, SOUND_VOLUME, SOUND_PITCH); + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java index 606c1ec68..50ad63fdf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java @@ -166,21 +166,6 @@ public class ObserverManager extends MiniPlugin public boolean canEnterObserverMode(Player player, boolean notify) { - if (_clansManager.getClientManager().hasRank(player, Rank.CMOD)) - { - return true; - } - - ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation()); - - if (territory == null || !territory.isSafe(player.getLocation())) - { - if (notify) - UtilPlayer.message(player, F.main("Observer", "You must be in a Safe Zone to use observer mode!")); - - return false; - } - return true; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index c64fd698a..f85a8fe52 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -14,6 +14,8 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; +import java.util.UUID; + public class Playtime extends MiniClientPlugin { private StatsManager _statsManager; @@ -45,7 +47,7 @@ public class Playtime extends MiniClientPlugin @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - Set(event.getPlayer(), addPlayer(event.getPlayer().getName())); + Set(event.getPlayer(), addPlayer(event.getPlayer().getUniqueId())); } @EventHandler @@ -73,9 +75,9 @@ public class Playtime extends MiniClientPlugin } @Override - protected PlayingClient addPlayer(String player) + protected PlayingClient addPlayer(UUID uuid) { - return new PlayingClient(Bukkit.getPlayer(player), TaskManager.Instance); + return new PlayingClient(Bukkit.getPlayer(uuid), TaskManager.Instance); } // Seconds diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 6c9424634..55debe953 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -1,49 +1,30 @@ package mineplex.game.clans.clans.regions; -import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; -import java.util.List; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.WorldBorder; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansDataAccessLayer; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.WorldBorder; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + public class ClansRegions extends MiniPlugin { public final static String DEFAULT_WORLD_NAME = "world"; public final static int SPAWN_RADIUS = 3; // Radius of spawn claim area (measured in chunks) - public final static int SHOP_RADIUS = 5; // Radius of shop claim area (measured in chunks) + public final static int SHOP_RADIUS = 6; // Radius of shop claim area (measured in chunks) public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks) public final static int BORDERLANDS_RADIUS = 85; // Radius of borderlands claim area (measured in chunks) - public static final int BORDER_RADIUS = 1319; + public static final int BORDER_RADIUS = 1250; private ClansManager _manager; private World _world; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index c3e213da9..29950b8db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -11,8 +11,8 @@ import org.bukkit.scoreboard.Team; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilText; -import mineplex.core.scoreboard.PlayerScoreboard; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.PlayerScoreboard; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility.ClanRelation; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index de615ec5f..d3e6f3bc4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -9,9 +9,9 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.OnlineRankUpdateEvent; import mineplex.core.donation.DonationManager; -import mineplex.core.scoreboard.PlayerScoreboard; -import mineplex.core.scoreboard.ScoreboardData; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.PlayerScoreboard; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardData; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; @@ -44,7 +44,7 @@ public class ClansScoreboardManager extends ScoreboardManager private void init() { - setTitle("Clans " + Clans.VERSION); + setTitle("Clans " + Clans.getMap()); ScoreboardData data = getData("default", true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java index 5252cb23d..5d5bbafea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java @@ -1,17 +1,18 @@ package mineplex.game.clans.clans.scoreboard.elements; -import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + public class ScoreboardElementClan implements ScoreboardElement { private ClansManager _clansManager; @@ -24,22 +25,28 @@ public class ScoreboardElementClan implements ScoreboardElement @Override public List getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); + List output = Lists.newArrayList(); ClanInfo clanInfo = _clansManager.getClan(player); if (clanInfo != null) { - output.add(C.cYellow + "Clan " + C.cWhite + clanInfo.getName()); - output.add(C.cYellow + "Online " + C.cWhite + clanInfo.getOnlinePlayers().size() + "/" + clanInfo.getMembers().size()); - + output.add(C.cYellowB + "Clan"); + output.add(_clansManager.getClanUtility().mRel(_clansManager.getRelation(player, player), clanInfo.getName(), false)); + output.add(" "); // Energy if (clanInfo.getEnergyCostPerMinute() > 0) - output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); + { + output.add(C.cYellowB + "Clan Energy"); + output.add(C.cGreen + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); + output.add(" "); + } } else { - output.add(C.cYellow + "You are not in a Clan"); + output.add(C.cYellowB + "Clan"); + output.add("No Clan"); + output.add(" "); } return output; 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 5b6cb24f4..3fb06b2f0 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 @@ -1,18 +1,18 @@ package mineplex.game.clans.clans.scoreboard.elements; -import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.core.repository.ClanTerritory; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + public class ScoreboardElementPlayer implements ScoreboardElement { private ClansManager _clansManager; @@ -25,11 +25,14 @@ public class ScoreboardElementPlayer implements ScoreboardElement @Override public List getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); - output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + ""); - String regionString = C.xWilderness + "Wilderness"; + List output = Lists.newArrayList(); + output.add(C.cYellowB + "Gold"); + output.add(C.cGold + _clansManager.getGoldManager().Get(player).getBalance()); - output.add(" "); + output.add(" "); + + output.add(C.cYellowB + "Territory"); + String regionString = C.xWilderness + "Wilderness"; ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation()); if (claim != null) { @@ -41,17 +44,18 @@ public class ScoreboardElementPlayer implements ScoreboardElement //Trust if (relation == ClansUtility.ClanRelation.ALLY_TRUST) + { regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; - + } } -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// regionString = C.cRed + "The Nether"; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + regionString = C.cClansNether + "The Nether"; + } output.add(regionString); - + return output; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java index 0c6fb35d5..c427499ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java @@ -1,19 +1,15 @@ package mineplex.game.clans.clans.scoreboard.elements; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; +import mineplex.game.clans.clans.ClansManager; +import org.bukkit.entity.Player; + import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilServer; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility; -import mineplex.game.clans.core.repository.ClanTerritory; - public class ScoreboardElementPlayerCount implements ScoreboardElement { private ClansManager _clansManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 1c26486b8..4c0b4939f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -1,15 +1,5 @@ package mineplex.game.clans.clans.siege; -import org.bukkit.Location; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockPlaceEvent; - -import com.google.gson.Gson; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -21,6 +11,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.siege.command.GiveWeaponCommand; import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; @@ -30,6 +21,16 @@ import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; import net.minecraft.server.v1_8_R3.Material; +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockPlaceEvent; + +import com.google.gson.Gson; + public class SiegeManager extends MiniPlugin { private ClansManager _clansManager; @@ -79,6 +80,8 @@ public class SiegeManager extends MiniPlugin }) ) ); + + addCommand(new GiveWeaponCommand(this)); } @EventHandler @@ -222,12 +225,12 @@ public class SiegeManager extends MiniPlugin public boolean trySpawnCannon(Player player, Location location) { -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); -// -// return false; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } if (!_clansManager.isInClan(player)) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java new file mode 100644 index 000000000..2a2589632 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java @@ -0,0 +1,26 @@ +package mineplex.game.clans.clans.siege.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.siege.SiegeManager; +import mineplex.game.clans.clans.siege.weapon.Cannon; + +public class GiveWeaponCommand extends CommandBase +{ + public GiveWeaponCommand(SiegeManager plugin) + { + super(plugin, Rank.ADMIN, "giveweapon", "siegeweapon", "givecannon"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilInv.insert(caller, Cannon.CANNON_ITEM.clone()); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have been given a cannon!")); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 6f2a19718..09ed9dcbc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -235,27 +235,24 @@ public class Outpost implements Listener { if (getState() == OutpostState.LIVE) { - do + if (event.getClickedBlock() == null) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (!UtilItem.isDoor(event.getClickedBlock().getType())) + return; + + if (_ownerClan.isMember(event.getPlayer())) + return; + + if (UtilAlg.inBoundingBox(event.getClickedBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner)) { - if (event.getClickedBlock() == null) - break; - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) - break; - - if (!UtilItem.isDoor(event.getClickedBlock().getType())) - break; - - if (_ownerClan.isMember(event.getPlayer())) - break; - - if (UtilAlg.inBoundingBox(event.getClickedBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner)) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot open the doors of this Outpost.")); - event.setCancelled(true); - return; - } - } while(false); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot open the doors of this Outpost.")); + event.setCancelled(true); + return; + } } if (getState() != OutpostState.AWAITING) @@ -266,24 +263,23 @@ public class Outpost implements Listener if (getLifetime() <= 2000) return; - - - if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP.")); - return; - } - - if (!_ownerClan.equals(_ownerClan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); - return; - } if (event.getClickedBlock() != null && _origin.equals(event.getClickedBlock().getLocation())) { if (event.getClickedBlock().getType().equals(Material.BEACON)) { + if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP.")); + return; + } + + if (!_ownerClan.equals(_ownerClan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); + return; + } + _origin.getBlock().setType(Material.AIR); beginConstruction(); } @@ -464,6 +460,14 @@ public class Outpost implements Listener UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1.f, 0, ViewDist.NORMAL); } + + if (_state == OutpostState.LIVE) + { + if (UtilTime.elapsed(_timeSpawned, MAX_LIFETIME)) + { + kill(); + } + } } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index c2f382bf4..559fc6b4b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -68,12 +68,12 @@ public class OutpostManager extends MiniPlugin public boolean spawnOutpost(Player player, Location location, OutpostType type) { -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); -// -// return false; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } if (!_clansManager.isInClan(player)) { @@ -228,7 +228,7 @@ public class OutpostManager extends MiniPlugin public Outpost Get(ClanInfo clan) { - return clan == null ? null : _outposts.get(clan.getName().toLowerCase()); + return clan == null ? null : _outposts.get(clan.getName()); } public void queueForRemoval(String name) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index 0dc3b7a9a..fab2296fb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -22,6 +23,7 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -36,6 +38,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansGame; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; @@ -216,6 +220,7 @@ public class Cannon extends SiegeWeapon })); } + @SuppressWarnings("deprecation") @EventHandler protected void InventoryClick(InventoryClickEvent event) { @@ -224,7 +229,7 @@ public class Cannon extends SiegeWeapon return; } - if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_RIGHT) + if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_LEFT) { if(_inventory.getViewers().contains(event.getWhoClicked())) { @@ -282,6 +287,19 @@ public class Cannon extends SiegeWeapon { event.setCancelled(true); } + else if (event.getSlot() == _ammunitionSlot && ClansGame.isDupedFromClassShop(event.getCursor())) + { + event.setCancelled(true); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + { + UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getWhoClicked().getName() + " just tried to use a duped item/block!"); + } + } + event.setCursor(new ItemStack(Material.AIR)); + ((Player)event.getWhoClicked()).updateInventory(); + } } private void updateInventory() @@ -425,7 +443,7 @@ public class Cannon extends SiegeWeapon return new double[] { yAdd, hMult }; } - @EventHandler + /*@EventHandler public void explosionEffects(SiegeWeaponExplodeEvent event) { List blocks = Stream.generate(() -> UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 4 * getPowerLevel()).getBlock()) @@ -446,5 +464,5 @@ public class Cannon extends SiegeWeapon false, false ); - } + }*/ } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index c09ec8f6d..4f6602afa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.siege.weapon; import java.util.UUID; import org.apache.commons.lang.Validate; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -487,6 +488,12 @@ public abstract class SiegeWeapon implements Listener protected void handleLeftClick(Player player) { + if (player.getGameMode() == GameMode.CREATIVE && player.isSneaking()) + { + removeHealth(getHealth()); + return; + } + if (_lastLeft == -1) { _lastLeft = System.currentTimeMillis(); @@ -801,8 +808,6 @@ public abstract class SiegeWeapon implements Listener return; } - System.out.println(event.getAction()); - if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { handleRightClick(event.getPlayer()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java index e53e6abd4..bb61ae4ce 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/TntProjectile.java @@ -20,7 +20,7 @@ public class TntProjectile extends WeaponProjectile super(weapon, origin, yawRot, yVel, xMulti); } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.LOWEST) public void onTntExplode(EntityExplodeEvent event) { if (event.getEntity().equals(_projectileEntity)) @@ -59,5 +59,4 @@ public class TntProjectile extends WeaponProjectile return tnt; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 7f270cd9a..d3c8049af 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -1,155 +1,120 @@ package mineplex.game.clans.clans.siege.weapon.projectile; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map.Entry; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import com.google.common.collect.Lists; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; +import mineplex.game.clans.clans.siege.weapon.projectile.event.CraterExplodeEvent; import mineplex.game.clans.core.repository.ClanTerritory; -import net.minecraft.server.v1_8_R3.Explosion; -public class Crater implements Listener +public class Crater { - public static final Material CHARRED_TYPE = Material.OBSIDIAN; - private final SiegeWeapon _weapon; private final Location _origin; - - private final long _birthTime; - - private final List _blocks; + private final Player _cause; public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin) { _weapon = weapon; _origin = origin; - - _birthTime = System.currentTimeMillis(); - _blocks = new ArrayList<>(); - - UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin()); - + _cause = projectile.getShooter(); createExplosion(); } - @EventHandler - public void updateEffects(UpdateEvent event) + @SuppressWarnings("deprecation") + private void createExplosion() { - if (event.getType() != UpdateType.TICK) + List blocks = Lists.newArrayList(); + List noRepeats = Lists.newArrayList(); + for (Block block : UtilBlock.getExplosionBlocks(_origin, 2.6f, false)) { - return; - } - - _blocks.stream().filter(block -> block.Type == CHARRED_TYPE).forEach(block -> { - long lifetime = System.currentTimeMillis() - _birthTime; - - long max = 80000; - - if (block.Location.getBlock().getType() != CHARRED_TYPE) + String locID = block.getLocation().getX() + " " + block.getLocation().getY() + " " + block.getLocation().getZ(); + if (noRepeats.contains(locID)) { - return; - } - - // Water touching the charred blocks - if (UtilBlock.getInRadius(block.Location, 1.6).keySet().stream().filter(water -> water.getType() == Material.WATER).iterator().hasNext()) - { - return; - } - - if (lifetime < max) - { - UtilParticle.PlayParticleToAll(ParticleType.FLAME, block.Location.clone().add(.5, 1, .5), new Vector(0, 0, 0), .0f, 3, ViewDist.MAX); - UtilParticle.PlayParticleToAll(lifetime >= max / 1.4 ? ParticleType.SMOKE : ParticleType.LARGE_SMOKE, block.Location.clone().add(.5, .8, .5), new Vector(0, 0, 0), .0f, 1, ViewDist.MAX); + continue; } else { - HandlerList.unregisterAll(this); + noRepeats.add(locID); } - }); - } - - private void createExplosion() - { - ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(_origin); - - if (terr != null && !ClansManager.getInstance().getBlacklist().allowed(terr.Owner)) - { - return; + if (block.getType() == Material.AIR || block.isLiquid()) + { + continue; + } + ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(block.getLocation()); + + if (terr != null) + { + if (!ClansManager.getInstance().getBlacklist().allowed(terr.Owner)) + { + continue; + } + ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr); + if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner())) + { + continue; + } + } + blocks.add(block); } - boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f); - - boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6; - - if (explosion) + ClansManager.getInstance().runSyncLater(() -> { - for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet()) + CraterExplodeEvent event = UtilServer.CallEvent(new CraterExplodeEvent(_weapon, _cause, _origin, blocks)); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _origin, null, 0, 1, ViewDist.NORMAL); + for (Block block : event.getBlocks()) { - boolean charred = false; - double dist = block.getLocation().distance(_origin); - - if (floating) + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) { - if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE) - && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) - && Math.random() > 0.79) + block.breakNaturally(); + } + else if (block.getType() == Material.SMOOTH_BRICK) + { + if (block.getData() != 2) { - charred = true; + block.setTypeIdAndData(98, (byte)2, true); + } + else + { + block.breakNaturally(); } } else { - if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR) - && !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE) - && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) - && Math.random() > 0.79) + if (Math.random() <= .3) { - charred = true; + block.breakNaturally(); + } + else + { + block.setType(Material.AIR); } } - - if (block.getType().equals(Material.SMOOTH_BRICK)) - { - charred = false; - } - - if (block.getType().equals(Material.BEDROCK)) - { - charred = false; - } - - if (charred) - { - CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0); - - charredBlock.set(); - - _blocks.add(charredBlock); - } } + }, 1L); + + HashMap hitMap = UtilEnt.getInRadius(_origin, 3.5); + for (LivingEntity hit : hitMap.keySet()) + { + ClansManager.getInstance().getDamageManager().NewDamageEvent(hit, _cause, null, DamageCause.ENTITY_EXPLOSION, 7 / hitMap.get(hit), true, true, false, _cause.getName(), "Siege Cannon"); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java index 6ba7ae951..a305dfd20 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java @@ -85,6 +85,12 @@ public abstract class WeaponProjectile implements Listener } die(); + return; + } + + if (_projectileEntity.getTicksLived() > (15 * 20)) + { + die(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java new file mode 100644 index 000000000..b2a97834f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/event/CraterExplodeEvent.java @@ -0,0 +1,78 @@ +package mineplex.game.clans.clans.siege.weapon.projectile.event; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; + +/** + * Event called when a Crater explodes + */ +public class CraterExplodeEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private SiegeWeapon _weapon; + private Player _shooter; + private Location _origin; + private List _blocks; + + public CraterExplodeEvent(SiegeWeapon weapon, Player shooter, Location explosionOrigin, List blocks) + { + _weapon = weapon; + _shooter = shooter; + _origin = explosionOrigin; + _blocks = blocks; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + /** + * Gets the Siege Weapon that shot the projectile which created this crater + * @return The Siege Weapon that shot the projectile which created this crater + */ + public SiegeWeapon getWeapon() + { + return _weapon; + } + + /** + * Gets the player responsible for this crater + * @return The player responsible for this crater + */ + public Player getShooter() + { + return _shooter; + } + + /** + * Gets the location where this explosion originated + * @return The origin point of this explosion + */ + public Location getExplosionOrigin() + { + return _origin; + } + + /** + * Gets a list of all blocks affected by this explosion + * @return A list of all blocks affected by this explosion + */ + public List getBlocks() + { + return _blocks; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 39a1e2680..592c61a42 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -7,12 +7,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -20,8 +14,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; @@ -31,10 +25,18 @@ import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.war.command.WarPointsCommand; -import mineplex.game.clans.clans.war.event.WarInvasionEndEvent; -import mineplex.game.clans.clans.war.event.WarInvasionStartEvent; +import mineplex.game.clans.clans.war.event.WarSiegeEndEvent; +import mineplex.game.clans.clans.war.event.WarSiegeStartEvent; import mineplex.game.clans.core.war.ClanWarData; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.plugin.java.JavaPlugin; + public class WarManager extends MiniPlugin implements ScoreboardElement { public static final int WAR_START_POINTS = 0; @@ -45,18 +47,17 @@ public class WarManager extends MiniPlugin implements ScoreboardElement private final ClansManager _clansManager; /** - * Map of the active war invasions. This is indexed by the clan that is being invaded on - * We will need to access this when blocks are broken in the invaded on clan's land! + * Map of the active war sieges. This is indexed by the clan that is being besieged */ - private Map> _invadedMap; - private Map> _invaderMap; + private Map> _besiegedMap; + private Map> _besiegerMap; public WarManager(JavaPlugin plugin, ClansManager clansManager) { super("ClanWar Manager", plugin); _clansManager = clansManager; - _invadedMap = new HashMap>(); - _invaderMap = new HashMap>(); + _besiegedMap = new HashMap<>(); + _besiegerMap = new HashMap<>(); } public ClansManager getClansManager() @@ -64,41 +65,38 @@ public class WarManager extends MiniPlugin implements ScoreboardElement return _clansManager; } - public List getInvasionsOn(ClanInfo invaded) + public List getSiegesOn(ClanInfo besieged) { - return _invadedMap.get(invaded.getName()); + return _besiegedMap.get(besieged.getName()); } - public List getInvasionsFor(ClanInfo invader) + public List getSiegesFor(ClanInfo besieger) { - return _invaderMap.get(invader.getName()); + return _besiegerMap.get(besieger.getName()); } - public boolean isBeingInvaded(ClanInfo clanInfo) + public boolean isBeingBesieged(ClanInfo clanInfo) { - List invasions = _invadedMap.get(clanInfo.getName()); - return invasions != null && !invasions.isEmpty(); + List sieges = _besiegedMap.get(clanInfo.getName()); + return sieges != null && !sieges.isEmpty(); } - public boolean isInvading(ClanInfo clanInfo) + public boolean isBesieging(ClanInfo clanInfo) { - List invasions = _invaderMap.get(clanInfo.getName()); - return invasions != null && !invasions.isEmpty(); + List sieges = _besiegerMap.get(clanInfo.getName()); + return sieges != null && !sieges.isEmpty(); } - - public boolean allowFromInvade(Location location, Player player) + + public boolean isBeingBesiegedBy(ClanInfo besieged, ClanInfo besieger) { - ClanInfo clanInfo = _clansManager.getClanUtility().getOwner(location); - ClanInfo playerClan = _clansManager.getClan(player); - if (clanInfo != null) + List sieges = _besiegedMap.get(besieged.getName()); + if (sieges != null && !sieges.isEmpty()) { - List invasions = _invadedMap.get(clanInfo.getName()); - if (invasions != null) + for (WarSiege siege : sieges) { - for (WarInvasion invasion : invasions) + if (siege.getBesiegingClan().equals(besieger.getName())) { - if (invasion.getInvaderClan().equals(playerClan.getName())) - return true; + return true; } } } @@ -106,14 +104,6 @@ public class WarManager extends MiniPlugin implements ScoreboardElement return false; } - /** - * Clear all invasions against clan. This is typically used for when a clan is deleted - */ -// public void clearInvasions(String clan) -// { -// List invasions = -// } - @EventHandler public void handleDeath(final ClansPlayerDeathEvent event) { @@ -184,106 +174,107 @@ public class WarManager extends MiniPlugin implements ScoreboardElement private void checkWarComplete(ClanWarData war) { - String invaderClan = null; - String invadedClan = null; + String besiegerClan = null; + String besiegedClan = null; if (war.getClanAPoints() >= WAR_FINISH_POINTS) { - // Clan A invades Clan B - invaderClan = war.getClanA(); - invadedClan = war.getClanB(); + besiegerClan = war.getClanA(); + besiegedClan = war.getClanB(); } else if (war.getClanBPoints() >= WAR_FINISH_POINTS) { - // Clan B invades Clan A - invaderClan = war.getClanB(); - invadedClan = war.getClanA(); + besiegerClan = war.getClanB(); + besiegedClan = war.getClanA(); } - if (invadedClan != null && invaderClan != null) + if (besiegedClan != null && besiegerClan != null) { // Reset War to 0:0 war.resetPoints(); war.setCooldown(WAR_COOLDOWN); - WarInvasion invasion = new WarInvasion(invadedClan, invaderClan); - startInvasion(invasion); + WarSiege siege = new WarSiege(besiegedClan, besiegerClan); + startSiege(siege); } } - private void startInvasion(WarInvasion invasion) + private void startSiege(WarSiege siege) { - String invaded = invasion.getInvadedClan(); - String invader = invasion.getInvaderClan(); + String besieged = siege.getBesiegedClan(); + String besieger = siege.getBesiegingClan(); - addInvasion(invaded, invasion, _invadedMap); - addInvasion(invader, invasion, _invaderMap); + addSiege(besieged, siege, _besiegedMap); + addSiege(besieger, siege, _besiegerMap); - WarInvasionStartEvent event = new WarInvasionStartEvent(invasion); + WarSiegeStartEvent event = new WarSiegeStartEvent(siege); UtilServer.getServer().getPluginManager().callEvent(event); } - private void addInvasion(String name, WarInvasion invasion, Map> invasionMap) + private void addSiege(String name, WarSiege siege, Map> siegeMap) { - if (invasionMap.containsKey(name)) + if (siegeMap.containsKey(name)) { - invasionMap.get(name).add(invasion); + siegeMap.get(name).add(siege); } else { - LinkedList invasions = new LinkedList(); - invasions.add(invasion); - invasionMap.put(name, invasions); + LinkedList sieges = new LinkedList<>(); + sieges.add(siege); + siegeMap.put(name, sieges); } } @EventHandler - public void clearInvasions(UpdateEvent event) + public void clearSieges(UpdateEvent event) { if (event.getType() != UpdateType.SEC) return; long currentTime = System.currentTimeMillis(); - Iterator>> iterator = _invadedMap.entrySet().iterator(); + Iterator>> iterator = _besiegedMap.entrySet().iterator(); while (iterator.hasNext()) { - List invasions = iterator.next().getValue(); - Iterator invasionIterator = invasions.iterator(); - while (invasionIterator.hasNext()) + List sieges = iterator.next().getValue(); + Iterator siegeIterator = sieges.iterator(); + while (siegeIterator.hasNext()) { - WarInvasion invasion = invasionIterator.next(); - if (currentTime >= invasion.getEndTime()) + WarSiege siege = siegeIterator.next(); + if (currentTime >= siege.getEndTime()) { - WarInvasionEndEvent endEvent = new WarInvasionEndEvent(invasion); + WarSiegeEndEvent endEvent = new WarSiegeEndEvent(siege); Bukkit.getServer().getPluginManager().callEvent(endEvent); - List invaderList = _invaderMap.get(invasion.getInvaderClan()); - if (invaderList != null) + List besiegerList = _besiegerMap.get(siege.getBesiegingClan()); + if (besiegerList != null) { - invaderList.remove(invasion); - if (invaderList.isEmpty()) _invaderMap.remove(invasion.getInvaderClan()); + besiegerList.remove(siege); + if (besiegerList.isEmpty()) + { + _besiegerMap.remove(siege.getBesiegingClan()); + } } - invasionIterator.remove(); + siegeIterator.remove(); } } - if (invasions.isEmpty()) + if (sieges.isEmpty()) iterator.remove(); } } @EventHandler - public void onInvasionStart(WarInvasionStartEvent event) + public void onSiegeStart(WarSiegeStartEvent event) { - Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + " can now invade " + F.elem(event.getWarInvasion().getInvadedClan()))); + Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarSiege().getBesiegingClan()) + " can now besiege " + F.elem(event.getWarSiege().getBesiegedClan()))); } @EventHandler - public void onInvasionEnd(WarInvasionEndEvent event) + public void onSiegeEnd(WarSiegeEndEvent event) { - Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvadedClan()) + " has ended.")); + Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarSiege().getBesiegingClan()) + "'s siege against " + F.elem(event.getWarSiege().getBesiegedClan()) + " has ended.")); } @@ -297,9 +288,29 @@ public class WarManager extends MiniPlugin implements ScoreboardElement public void cancelDisband(ClanDisbandedEvent event) { ClanInfo clan = event.getClan(); - if (isBeingInvaded(clan) || isInvading(clan)) + if (isBeingBesieged(clan) || isBesieging(clan)) + { + UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of a siege")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlaceTNT(BlockPlaceEvent event) + { + if (event.getBlockPlaced().getType() == Material.TNT) + { + event.setCancelled(true); + event.setBuild(false); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "TNT cannot be used outside of a siege cannon!")); + } + } + + @EventHandler + public void onTNTDispense(BlockDispenseEvent event) + { + if (event.getItem().getType() == Material.TNT) { - UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of an invasion")); event.setCancelled(true); } } @@ -313,32 +324,32 @@ public class WarManager extends MiniPlugin implements ScoreboardElement if (clan != null) { - List invadedList = _invadedMap.get(clan.getName()); - List invaderList = _invaderMap.get(clan.getName()); + List besiegedList = _besiegedMap.get(clan.getName()); + List besiegerList = _besiegerMap.get(clan.getName()); - if (invaderList != null && !invaderList.isEmpty()) + if (besiegerList != null && !besiegerList.isEmpty()) { - for (WarInvasion invasion : invaderList) + for (WarSiege siege : besiegerList) { element.add(" "); - element.add(C.cPurpleB + "Invading"); - element.add(" " + invasion.getInvadedClan()); - element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); + element.add(C.cPurpleB + "Besieging"); + element.add(" " + siege.getBesiegedClan()); + element.add(" " + UtilTime.convertString(Math.max(siege.getTimeLeft(), 0), 1, UtilTime.TimeUnit.FIT)); } } - if (invadedList != null && !invadedList.isEmpty()) + if (besiegedList != null && !besiegedList.isEmpty()) { - for (WarInvasion invasion : invadedList) + for (WarSiege siege : besiegedList) { element.add(" "); - element.add(C.cRedB + "Invaded"); - element.add(" " + invasion.getInvaderClan()); - element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); + element.add(C.cRedB + "Besieged"); + element.add(" " + siege.getBesiegingClan()); + element.add(" " + UtilTime.convertString(Math.max(siege.getTimeLeft(), 0), 1, UtilTime.TimeUnit.FIT)); } } } return element; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarInvasion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarSiege.java similarity index 54% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarInvasion.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarSiege.java index 1358aa376..12f124c72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarInvasion.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarSiege.java @@ -1,16 +1,16 @@ package mineplex.game.clans.clans.war; -public class WarInvasion +public class WarSiege { - private String _invadedClan; - private String _invaderClan; + private String _besiegedClan; + private String _besiegingClan; private long _startTime; private long _endTime; - public WarInvasion(String invadedClan, String invaderClan) + public WarSiege(String besiegedClan, String besiegingClan) { - _invadedClan = invadedClan; - _invaderClan = invaderClan; + _besiegedClan = besiegedClan; + _besiegingClan = besiegingClan; _startTime = System.currentTimeMillis(); _endTime = _startTime + WarManager.INVADE_LENGTH; } @@ -20,14 +20,14 @@ public class WarInvasion return _endTime - System.currentTimeMillis(); } - public String getInvadedClan() + public String getBesiegedClan() { - return _invadedClan; + return _besiegedClan; } - public String getInvaderClan() + public String getBesiegingClan() { - return _invaderClan; + return _besiegingClan; } public long getStartTime() @@ -39,4 +39,4 @@ public class WarInvasion { return _endTime; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionEndEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeEndEvent.java similarity index 52% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionEndEvent.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeEndEvent.java index 048ed8dd1..dcd300afb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionEndEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeEndEvent.java @@ -1,29 +1,29 @@ package mineplex.game.clans.clans.war.event; +import mineplex.game.clans.clans.war.WarSiege; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.game.clans.clans.war.WarInvasion; - /** - * Called when a war invasion is ended + * Called when a war siege is ended */ -public class WarInvasionEndEvent extends Event +public class WarSiegeEndEvent extends Event { - private WarInvasion _warInvasion; + private WarSiege _warSiege; - public WarInvasionEndEvent(WarInvasion warInvasion) + public WarSiegeEndEvent(WarSiege warSiege) { - _warInvasion = warInvasion; + _warSiege = warSiege; } - public WarInvasion getWarInvasion() + public WarSiege getWarSiege() { - return _warInvasion; + return _warSiege; } // Bukkit event stuff private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionStartEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeStartEvent.java similarity index 51% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionStartEvent.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeStartEvent.java index 9f3d10f0b..30e7d2d79 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionStartEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeStartEvent.java @@ -1,29 +1,29 @@ package mineplex.game.clans.clans.war.event; +import mineplex.game.clans.clans.war.WarSiege; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.game.clans.clans.war.WarInvasion; - /** - * Called when a war invasion is started + * Called when a war siege is started */ -public class WarInvasionStartEvent extends Event +public class WarSiegeStartEvent extends Event { - private WarInvasion _warInvasion; + private WarSiege _warSiege; - public WarInvasionStartEvent(WarInvasion warInvasion) + public WarSiegeStartEvent(WarSiege warSiege) { - _warInvasion = warInvasion; + _warSiege = warSiege; } - public WarInvasion getWarInvasion() + public WarSiege getWarSiege() { - return _warInvasion; + return _warSiege; } // Bukkit event stuff private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file 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 4cc189f34..378b50478 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 @@ -1,74 +1,74 @@ package mineplex.game.clans.clans.worldevent; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Random; import java.util.Set; -import org.bukkit.Chunk; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.ClansManager; + import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import mineplex.core.common.util.EnclosedObject; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilWorld; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.regions.ClansRegions; +import com.google.common.collect.Lists; public class EventTerrainFinder { - private WorldEventManager _eventManager; + private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(3, TimeUnit.HOURS, TimeUnit.MILLISECONDS); private ClansManager _clansManager; - private ClansRegions _clansRegions; - public EventTerrainFinder(WorldEventManager eventManager, ClansManager clansManager, ClansRegions clansRegions) + public EventTerrainFinder(ClansManager clansManager) { - _eventManager = eventManager; _clansManager = clansManager; - _clansRegions = clansRegions; } - public double posNeg() + public Location findAreaInBorderlands(boolean force) { - if (Math.random() > 0.5) return -1; - return 1; - } - - public Location findAreaInBorderlands(World world, int size, int vert) - { - for (int i = 0; i < 150; i++) + List locs = Lists.newArrayList(); + locs.addAll(Arrays.asList(EventLocation.values())); + locs.sort(new Comparator() { - EnclosedObject loc = new EnclosedObject<>(); - - if (_clansManager.getClanUtility().getClanByClanName("Borderlands") == null) + public int compare(EventLocation loc1, EventLocation loc2) { - System.out.println("[WORLD EVENT] FATAL ERROR: CLAN BORDERLANDS NOT FOUND."); - break; + if (!UtilTime.elapsed(loc1.getLastUsed(), EVENT_AREA_COOLDOWN)) + { + return 1; + } + if (!UtilTime.elapsed(loc2.getLastUsed(), EVENT_AREA_COOLDOWN)) + { + return -1; + } + int[] rand = new int[] {1, -1}; + return rand[new Random().nextInt(rand.length)]; } - - _clansManager.getClanUtility().getClanByClanName("Borderlands").getClaimSet().stream().filter(claim -> Math.random() > .5).filter(claim -> Math.random() > .5).filter(claim -> Math.random() > .3).filter(claim -> Math.random() > .7).limit(1).forEach(claim -> { - Chunk chunk = UtilWorld.strToChunk(claim); - - loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); - }); - - if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2))) + }); + + for (EventLocation loc : locs) + { + if (!UtilTime.elapsed(loc.getLastUsed(), EVENT_AREA_COOLDOWN)) { continue; } - - if (loc.Get() == null) + if (_clansManager.getClanUtility().getClaim(loc.getLocation()) == null || _clansManager.getClanUtility().getClaim(loc.getLocation()).Owner.contains("Borderlands")) { - continue; + loc.use(); + return loc.getLocation(); } - - System.out.println("Done finding area... [success]"); - - // Success - return loc.Get(); } - System.out.println("Failed to find area..."); + if (force && !locs.isEmpty()) + { + EventLocation loc = locs.get(UtilMath.r(locs.size())); + loc.use(); + return loc.getLocation(); + } return null; } @@ -129,4 +129,61 @@ public class EventTerrainFinder return null; } -} + + /** + * Enum with locations around the map for world events to spawn + */ + 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); + + private String _world; + private double _x, _y, _z; + private long _last = 0; + + private EventLocation(String worldName, double x, double y, double z) + { + _world = worldName; + _x = x; + _y = y; + _z = z; + } + + /** + * Returns the Bukkit center location for this event space + * @return The Bukkit center location for this event space + */ + public Location getLocation() + { + return new Location(UtilWorld.getWorld(_world), _x, _y, _z); + } + + /** + * Gets the last time this event space has been used + * @return The last time this event space has been used + */ + public Long getLastUsed() + { + return _last; + } + + /** + * Updates this event space's last used time to now + */ + public void use() + { + _last = System.currentTimeMillis(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index a419b2d1c..3dd3cd94e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -1,24 +1,18 @@ package mineplex.game.clans.clans.worldevent; -import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Random; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; @@ -26,12 +20,26 @@ import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; + public class WorldEventManager extends MiniPlugin implements ScoreboardElement { + private static final double ARENA_RADIUS = 40; private final List _runningEvents; private Random _random; @@ -50,7 +58,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement super("World Event", plugin); _random = new Random(); - _terrainFinder = new EventTerrainFinder(this, clansManager, clansRegions); + _terrainFinder = new EventTerrainFinder(clansManager); _clansManager = clansManager; _damageManager = damageManager; _lootManager = lootManager; @@ -81,7 +89,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { for (WorldEvent event : _runningEvents) { - if (event.isInBounds(location)) + if (UtilMath.offset2d(location, event.getCenterLocation()) <= ARENA_RADIUS) { return true; } @@ -90,6 +98,37 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return false; } + @EventHandler + public void onIcePrison(SkillTriggerEvent event) + { + if (event.GetSkillName().equalsIgnoreCase("Ice Prison")) + { + for (WorldEvent e : _runningEvents) + { + if (isInEvent(event.GetPlayer().getLocation())) + { + event.SetCancelled(true); + } + } + } + } + + @EventHandler + public void onBossDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) + { + Location drop = event.getCreature().getLastKnownLocation(); + if (drop != null) + { + runSyncLater(() -> + { + ClansManager.getInstance().getLootManager().dropRare(drop); + }, 20 * 2); + } + } + } + @EventHandler public void update(UpdateEvent event) { @@ -137,31 +176,34 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement } } - public void randomEvent() + public WorldEventType randomEvent() { if (_runningEvents.size() == 0) { if (UtilServer.getPlayers().length > 0) { - tryStartEvent(); + return tryStartEvent(); } } + return null; } - private void tryStartEvent() + private WorldEventType tryStartEvent() { WorldEventType[] types = WorldEventType.values(); WorldEventType type = types[_random.nextInt(types.length)]; - Location location = _terrainFinder.findAreaInBorderlands(Bukkit.getWorlds().get(0), type.getAreaNeeded(), type.getAreaNeeded()); + Location location = _terrainFinder.findAreaInBorderlands(false); if (location != null) { initializeEvent(type.createInstance(this, location, _skillFactory)); + return type; } else { // Try again in 5 minutes _nextEventStart = System.currentTimeMillis() + (5 * 60 * 1000); } + return null; } private void initializeEvent(WorldEvent event) @@ -189,12 +231,16 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return null; } - public WorldEvent startEventFromType(Location location, WorldEventType eventType) + public WorldEvent startEventFromType(WorldEventType eventType) { if (eventType != null) { + Location location = _terrainFinder.findAreaInBorderlands(true); WorldEvent event = eventType.createInstance(this, location, _skillFactory); - initializeEvent(event); + if (event != null) + { + initializeEvent(event); + } return event; } @@ -245,7 +291,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement @Override public List getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); + List output = Lists.newArrayList(); Iterator iterator = _runningEvents.iterator(); while (iterator.hasNext()) @@ -254,7 +300,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement if (event.getState() == EventState.LIVE) { - output.add(" "); + output.add(" "); output.add(C.cAqua + C.Bold + "Event"); Location eventLocation = event.getCenterLocation(); @@ -290,4 +336,9 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { _skillFactory = skillManager; } + + public DisguiseManager getDisguiseManager() + { + return getClans().getDisguiseManager(); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 3852f4451..0110ae6c9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -4,17 +4,19 @@ import java.lang.reflect.Constructor; import org.bukkit.Location; -import mineplex.game.clans.clans.worldevent.kinghill.KingHill; -import mineplex.game.clans.clans.worldevent.undead.UndeadCamp; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; public enum WorldEventType { - // SLIME_KING("Slime King", SlimeBoss.class, 30), -// KING_HILL("King of The Hill", KingHill.class, 30), - UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30);// , - // Golem("Iron Wizard", GolemBoss.class, 30); + //SLIME_KING("Slime King", SlimeBoss.class, 30), + //KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), + //UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), + IRON_WIZARD("Iron Wizard",GolemBoss.class, 30), + //BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), + SKELETON_KING("Skeleton King", SkeletonBoss.class, 30); private String _name; private Class _clazz; @@ -59,7 +61,7 @@ public enum WorldEventType } else { - worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation); + worldEvent = (WorldEvent) con.newInstance(eventManager.getDisguiseManager(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation); } } } @@ -70,4 +72,9 @@ public enum WorldEventType return worldEvent; } + + public String getName() + { + return this._name; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java index 18d845188..4439d2502 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java @@ -18,13 +18,13 @@ public class ClearCommand extends CommandBase { public ClearCommand(WorldEventManager plugin) { - super(plugin, Rank.EVENT, "clear"); + super(plugin, Rank.ADMIN, "clear"); } @Override public void Execute(Player caller, String[] args) { Plugin.clearEvents(); - UtilPlayer.message(caller, F.main("Clans", "All world events cleared!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "All world events cleared!")); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java index 9fd1762b8..ef9c08af2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java @@ -17,12 +17,20 @@ public class RandomCommand extends CommandBase { public RandomCommand(WorldEventManager plugin) { - super(plugin, Rank.JNR_DEV, "random", "rand"); + super(plugin, Rank.ADMIN, "random", "rand"); } @Override public void Execute(Player caller, String[] args) { - Plugin.randomEvent(); + WorldEventType typeStarted = Plugin.randomEvent(); + if (typeStarted != null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Started " + F.name(typeStarted.getName()))); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not start World Event")); + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index e808e9981..e95f7fa48 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -14,7 +15,7 @@ public class StartCommand extends CommandBase { public StartCommand(WorldEventManager plugin) { - super(plugin, Rank.EVENT, "start", "create"); + super(plugin, Rank.ADMIN, "start", "create"); } @Override @@ -26,20 +27,32 @@ public class StartCommand extends CommandBase try { WorldEventType eventType = WorldEventType.valueOf(args[0]); - WorldEvent event = Plugin.startEventFromType(caller.getLocation(), eventType); + WorldEvent event = Plugin.startEventFromType(eventType); if (event == null) { - UtilPlayer.message(caller, F.main("WorldEvent", "Error whilst starting the world event you chose.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Error whilst starting the world event you chose.")); } else { - UtilPlayer.message(caller, F.main("worldEvent", "Started WorldEvent " + F.elem(args[0]) + " at your current location")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Started WorldEvent " + F.elem(args[0]) + "!")); } } catch (IllegalArgumentException e) { - UtilPlayer.message(caller, F.main("WorldEvent", "Could not find a WorldEvent with the name " + F.elem(args[0]))); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find a WorldEvent with the name " + F.elem(args[0]) + "! Available types:")); + for (WorldEventType type : WorldEventType.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + type.toString()); + } + } + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "No World Event type specified. Available types:")); + for (WorldEventType type : WorldEventType.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + type.toString()); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index 73d55f096..e52b389b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.worldevent.command; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; @@ -20,7 +22,9 @@ public class WorldEventCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " start ", "Start a World Event where you're standing", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear", "Clears all World Events", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " random", "Starts a random World Event", Rank.ADMIN)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index 6b14c395f..5b6a64da3 100755 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -7,11 +7,12 @@ import java.util.List; import java.util.Map; import mineplex.core.common.util.*; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -53,7 +54,7 @@ public class KingHill extends WorldEvent private long _lastOnHillMessage; private long _goldDrops; - public KingHill(WorldEventManager eventManager, Location centerLocation) + public KingHill(WorldEventManager eventManager, Location centerLocation, SkillFactory skillFactory) { super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "King of the Hill", centerLocation); _clansManager = eventManager.getClans(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java new file mode 100644 index 000000000..ee0947382 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java @@ -0,0 +1,9 @@ +package mineplex.game.clans.economy; + +import mineplex.core.common.currency.Currency; +import mineplex.core.common.util.C; +import org.bukkit.Material; + +public class ClansCurrency { + public static final Currency GOLD = new Currency("Gold", "Gold", C.cGold, Material.GOLD_NUGGET); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java similarity index 73% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java index 953b2c840..fe7aa8421 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation.command; +package mineplex.game.clans.economy; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; @@ -6,13 +6,11 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; - import org.bukkit.entity.Player; -public class GoldCommand extends CommandBase +public class GoldCommand extends CommandBase { - public GoldCommand(DonationManager plugin) + public GoldCommand(GoldManager plugin) { super(plugin, Rank.ADMIN, "givegold"); } @@ -22,7 +20,7 @@ public class GoldCommand extends CommandBase { if (args == null || args.length == 0) { - UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getGold()))); + UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getBalance()))); return; } else if (args.length < 2) @@ -37,18 +35,13 @@ public class GoldCommand extends CommandBase if (target == null) { - Plugin.getClientManager().loadClientByName(targetName, new Runnable() + Plugin.getClientManager().loadClientByName(targetName, client -> { - public void run() + if (client != null) + rewardGold(caller, null, targetName, client.getAccountId(), goldString); + else { - CoreClient client = Plugin.getClientManager().Get(targetName); - - if (client != null) - rewardGold(caller, null, targetName, client.getAccountId(), goldString); - else - { - UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); - } + UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); } }); } @@ -84,6 +77,6 @@ public class GoldCommand extends CommandBase UtilPlayer.message(target, F.main("Gold", F.name(caller.getName()) + " gave you " + F.elem(gold + " Gold") + ".")); } } - }, caller.getName(), targetName, accountId, gold); + }, accountId, targetName, gold, true); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java new file mode 100644 index 000000000..9de4d3d9d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.economy; + +public class GoldData +{ + private int balance; + + public void addBalance(int amount) { + balance += amount; + } + + public void setBalance(int amount) { + balance = amount; + } + + public int getBalance() { + return balance; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index a86f41fd2..43f125e28 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -1,14 +1,17 @@ package mineplex.game.clans.economy; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; +import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansDataAccessLayer; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.items.economy.GoldToken; +import mineplex.game.clans.shop.bank.BankShop; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -24,22 +27,11 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import org.bukkit.util.Vector; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; -import mineplex.core.donation.Donor; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.items.economy.GoldToken; -import mineplex.game.clans.shop.bank.BankShop; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; -public class GoldManager extends MiniPlugin +public class GoldManager extends MiniDbClientPlugin { public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem @@ -50,21 +42,33 @@ public class GoldManager extends MiniPlugin public static GoldManager getInstance() { return _instance; } private DonationManager _donationManager; + private final int _serverId; private TransferTracker _transferTracker; private Set _itemSet; private Map _playerPickupMap; private BankShop _bankShop; - - public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager) + + private final GoldRepository _repository; + + public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager, ClansDataAccessLayer dataAccessLayer) { - super("Clans Gold", plugin.getPlugin()); - + super("Clans Gold", plugin.getPlugin(), clientManager); + _instance = this; _donationManager = donationManager; + _serverId = dataAccessLayer.getRepository().getServerId(); _transferTracker = new TransferTracker(); _itemSet = new HashSet(); _playerPickupMap = new HashMap(); _bankShop = new BankShop(plugin, clientManager, donationManager); + _repository = new GoldRepository(_serverId); + } + + @Override + public void addCommands() + { + addCommand(new GoldCommand(this)); + addCommand(new SetGoldCommand(this)); } @EventHandler @@ -177,12 +181,12 @@ public class GoldManager extends MiniPlugin public int getGold(Player player) { - return getDonor(player).getGold(); + return Get(player).getBalance(); } public int getGems(Player player) { - return getDonor(player).GetGems(); + return getDonor(player).getBalance(GlobalCurrency.GEM); } public void transferGemsToCoins(Player player, int gemAmount) @@ -192,7 +196,7 @@ public class GoldManager extends MiniPlugin if (gemCount >= gemAmount) { - deductGems(player, gemAmount); + _donationManager.RewardGemsLater("GoldManager", player, -gemAmount); addGold(player, goldCount); notify(player, String.format("You have transferred %d gems into %d gold coins!", gemAmount, goldCount)); _transferTracker.insertTransfer(player); @@ -208,20 +212,6 @@ public class GoldManager extends MiniPlugin { return !_transferTracker.hasTransferredToday(player); } - - public void addGold(Player player, int amount) - { - if (amount >= 0) - _donationManager.rewardGold(null, "GoldManager", player, amount); - } - - public void deductGold(Callback resultCallback, Player player, int amount) - { - if (amount == 0) - resultCallback.run(true); - if (amount > 0) - _donationManager.rewardGold(resultCallback, "GoldManager", player, -amount); - } public void cashIn(Player player, GoldToken token) { @@ -302,19 +292,10 @@ public class GoldManager extends MiniPlugin }, player, tokenValue); } - public void addGems(Player player, int amount) - { - _donationManager.RewardGemsLater("GoldManager", player, amount); - } - - public void deductGems(Player player, int amount) - { - addGems(player, -amount); - } - + private Donor getDonor(Player player) { - return _donationManager.Get(player.getName()); + return _donationManager.Get(player); } public static void notify(Player player, String message) @@ -330,4 +311,127 @@ public class GoldManager extends MiniPlugin item.remove(); } } + + public void setGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) + { + _repository.setGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + if (updateTotal) + { + GoldData data = Get(name); + + if (data != null) + { + data.setBalance(amount); + } + } + } + else + { + System.out.println("SET GOLD FAILED..."); + } + + if (callback != null) + callback.run(success); + } + }, accountId, amount); + } + + public void addGold(Player player, int amount) + { + if (amount >= 0) + rewardGold(null, player, amount, true); + } + + public void deductGold(Callback resultCallback, Player player, int amount) + { + if (amount > 0) + rewardGold(resultCallback, player, -amount, true); + } + + public void rewardGold(final Callback callback, final Player player, final int amount, final boolean updateTotal) + { + rewardGold(callback, getClientManager().Get(player).getAccountId(), player.getName(), amount, updateTotal); + } + + public void rewardGold(final Callback callback, int accountId, String name, final int amount, final boolean updateTotal) + { + if (amount == 0) + { + if (callback != null) + { + callback.run(true); + } + return; + } + + _repository.rewardGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + if (updateTotal) + { + GoldData data = Get(name); + + if (data != null) + { + data.addBalance(amount); + } + } + } + else + { + System.out.println("REWARD GOLD FAILED..."); + } + + if (callback != null) + callback.run(success); + } + }, accountId, amount); + } + + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT gold FROM clansGold WHERE id = '" + accountId + "' AND serverId=" + _serverId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, UUID playerUUID, int accountId, ResultSet resultSet) throws SQLException + { + if (resultSet.next()) + { + Get(playerUUID).setBalance(resultSet.getInt(1)); + + if (resultSet.getInt(1) < 0) + { + setGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + System.out.println("Fixed negative gold balance for " + playerName + "!"); + } + else + { + System.out.println("Failed to fix negative gold balance for " + playerName + "!"); + } + } + }, "", playerName, accountId, 0, true); + } + } + } + + @Override + protected GoldData addPlayer(UUID uuid) { + return new GoldData(); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java new file mode 100644 index 000000000..43df9ade0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java @@ -0,0 +1,74 @@ +package mineplex.game.clans.economy; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationProcessor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +public class GoldPurchaseProcessor implements ConfirmationProcessor { + private final Player _player; + private final int _price; + private final GoldManager _goldManager; + private final Runnable _runAfterPurchase; + + public GoldPurchaseProcessor(Player player, int price, GoldManager goldManager, Runnable runAfterPurchase) + { + _player = player; + _price = price; + _goldManager = goldManager; + _runAfterPurchase = runAfterPurchase; + } + + @Override + public void init(Inventory inventory) { + inventory.setItem(4, new ItemBuilder(ClansCurrency.GOLD.getDisplayMaterial()).setTitle(ClansCurrency.GOLD.getPrefix()).addLore(C.cGray + _price + " " + ClansCurrency.GOLD.getPrefix() + " will be", C.cGray + "deducted from your account balance").build()); + } + + @Override + public void process(ConfirmationCallback callback) { + int goldCount = _goldManager.Get(_player).getBalance(); + + if (_price > goldCount) + showResults(callback, TransactionResponse.InsufficientFunds); + else + { + _goldManager.rewardGold(data -> + { + if (data) + { + showResults(callback, TransactionResponse.Success); + _player.playSound(_player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + else + { + showResults(callback, TransactionResponse.Failed); + } + }, _player, -_price, true); + + } + } + + private void showResults(ConfirmationCallback callback, TransactionResponse response) + { + switch (response) + { + case Failed: + callback.reject("There was an error processing your request."); + break; + case AlreadyOwns: + callback.reject("You already own this package."); + break; + case InsufficientFunds: + callback.reject("Your account has insufficient funds."); + break; + case Success: + callback.resolve("Your purchase was successful."); + _runAfterPurchase.run(); + break; + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java new file mode 100644 index 000000000..d6f8958f8 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java @@ -0,0 +1,87 @@ +package mineplex.game.clans.economy; + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.database.DBPool; +import org.bukkit.Bukkit; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class GoldRepository { + private static final String CREATE_TABLE = "CREATE TABLE clansGold (serverId int(11) not null, id int(11) not null, gold int not null, primary key (serverId, id), foreign key (serverId) references clanServer(id), foreign key (id) references accounts(id))"; + private static final String UPDATE_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=gold+?"; + private static final String SET_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=?"; + + private final int _serverId; + + public GoldRepository(int serverId) { + _serverId = serverId; + } + + public void rewardGold(final Callback callback, final int accountId, final int gold) + { + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true)); + } + + } catch (SQLException e) + { + e.printStackTrace(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false)); + } + } + }); + } + + public void setGold(final Callback callback, final int accountId, final int gold) + { + if (gold < 0) + { + throw new IllegalArgumentException("gold cannot be negative"); + } + + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true)); + } + + } catch (SQLException e) + { + e.printStackTrace(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false)); + } + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java similarity index 71% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java index d477f5b8f..526805366 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation.command; +package mineplex.game.clans.economy; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; @@ -10,9 +10,9 @@ import mineplex.core.donation.DonationManager; import org.bukkit.entity.Player; -public class SetGoldCommand extends CommandBase +public class SetGoldCommand extends CommandBase { - public SetGoldCommand(DonationManager plugin) + public SetGoldCommand(GoldManager plugin) { super(plugin, Rank.ADMIN, "setgold"); } @@ -34,20 +34,15 @@ public class SetGoldCommand extends CommandBase { if (target == null) { - Plugin.getClientManager().loadClientByName(targetName, new Runnable() + Plugin.getClientManager().loadClientByName(targetName, client -> { - public void run() + if (client != null) { - CoreClient client = Plugin.getClientManager().Get(targetName); - - if (client != null) - { - setGold(caller, null, targetName, client.getAccountId(), Integer.parseInt(goldString)); - } - else - { - UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); - } + setGold(caller, null, targetName, client.getAccountId(), Integer.parseInt(goldString)); + } + else + { + UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); } }); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 05e00963b..df5d6e2cb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -4,6 +4,38 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.weight.Weight; +import mineplex.core.common.weight.WeightSet; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; +import mineplex.game.clans.clans.event.IronDoorOpenEvent; +import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.items.GearManager; +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.damage.DamageManager; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -14,7 +46,6 @@ import org.bukkit.Sound; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -47,38 +78,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.Dye; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.common.weight.Weight; -import mineplex.core.common.weight.WeightSet; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; -import mineplex.game.clans.clans.event.IronDoorOpenEvent; -import mineplex.game.clans.core.repository.ClanTerritory; -import mineplex.minecraft.game.classcombat.Class.ClientClass; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; -import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.minecraft.game.core.damage.DamageManager; - public class Gameplay extends MiniPlugin { private ClansManager _clansManager; @@ -357,9 +356,19 @@ public class Gameplay extends MiniPlugin @EventHandler public void WebBreak(BlockDamageEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) + { + return; + } + if (_clansManager.getWorldEvent().isInEvent(event.getBlock().getLocation())) + { + return; + } - if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true); + if (event.getBlock().getType() == Material.WEB) + { + event.setInstaBreak(true); + } } @EventHandler @@ -818,6 +827,12 @@ public class Gameplay extends MiniPlugin return; } + if (GearManager.isCustomItem(item)) + { + UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + ".")); + return; + } + int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0); boolean canRepair = canRepair(item); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index f83a7b0cb..1d0dd2814 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -203,13 +203,13 @@ public class CombatLogNPC skel.getEquipment().setLeggings(player.getInventory().getLeggings()); skel.getEquipment().setBoots(player.getInventory().getBoots()); skel.getEquipment().setItemInHand(player.getItemInHand()); - + // Get in range List inRange = UtilPlayer.getNearby(spawnLoc, 75d); // Disguise DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile()); - _disguiseManager.disguise(disguise, inRange.toArray(new Player[inRange.size()])); + _disguiseManager.disguise(disguise, attempted -> inRange.contains(attempted)); if (!UtilEnt.isGrounded(player)) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index a16b7529b..667bbdee1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -186,6 +186,11 @@ public class CustomItem implements Listener meta.setLore(lore); item.setItemMeta(meta); + + if (_dullEnchantment) + { + UtilInv.addDullEnchantment(item); + } GearManager.writeNBT(this, item); } @@ -201,7 +206,7 @@ public class CustomItem implements Listener name += word.substring(0, 1).toUpperCase() + word.substring(1) + " "; } - return name; + return name.trim(); } public Material getMaterial() @@ -213,4 +218,13 @@ public class CustomItem implements Listener { return _attributes; } + + public void setMaterial(Material material) + { + if (_material == null) + { + _displayName = prettifyName(material); + } + _material = material; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 43849130c..b25959a72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -1,8 +1,6 @@ package mineplex.game.clans.items; -import java.lang.reflect.Field; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -12,30 +10,11 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import com.google.gson.JsonSyntaxException; -import mineplex.core.account.CoreClient; -import mineplex.core.common.Rank; -import mineplex.game.clans.clans.ClansManager; -import net.minecraft.server.v1_8_R3.NBTBase; -import net.minecraft.server.v1_8_R3.NBTTagByte; -import net.minecraft.server.v1_8_R3.NBTTagString; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.weight.Weight; import mineplex.core.common.weight.WeightSet; @@ -65,6 +44,7 @@ import mineplex.game.clans.items.attributes.weapon.HasteAttribute; import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; import mineplex.game.clans.items.attributes.weapon.SharpAttribute; import mineplex.game.clans.items.commands.GearCommand; +import mineplex.game.clans.items.commands.RuneCommand; import mineplex.game.clans.items.economy.GoldToken; import mineplex.game.clans.items.legendaries.AlligatorsTooth; import mineplex.game.clans.items.legendaries.GiantsBroadsword; @@ -75,14 +55,35 @@ import mineplex.game.clans.items.legendaries.MeridianScepter; import mineplex.game.clans.items.legendaries.WindBlade; import mineplex.game.clans.items.rares.RareItem; import mineplex.game.clans.items.rares.RunedPickaxe; +import mineplex.game.clans.items.runes.RuneManager; import mineplex.game.clans.items.smelting.SmeltingListener; import mineplex.game.clans.items.ui.GearShop; import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; +import net.minecraft.server.v1_8_R3.NBTBase; +import net.minecraft.server.v1_8_R3.NBTTagByte; import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagString; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; + /** * Handles converting legendary itemstacks to their respective CustomItem objects */ @@ -92,14 +93,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable private static final Gson GSON; // Weightings for randomly selecting number of attributes (1, 2, 3) - private static final WeightSet ATTRIBUTE_WEIGHTS = new WeightSet<>( + private static final WeightSet ATTRIBUTE_WEIGHTS = new WeightSet( new Weight<>(3, 3), new Weight<>(20, 2), new Weight<>(77, 1) ); // Weightings for randomly selecting item type (legendary/weapon/armor/bow) - private static final WeightSet TYPE_WEIGHTS = new WeightSet<>( + private static final WeightSet TYPE_WEIGHTS = new WeightSet( new Weight<>(6, ItemType.LEGENDARY), new Weight<>(9, ItemType.RARE), new Weight<>(46 - 9, ItemType.ARMOR), @@ -215,6 +216,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable private Map _playerGears = new HashMap<>(); private GearShop _shop; + private RuneManager _rune; public GearManager(JavaPlugin plugin, PacketHandler packetHandler, CoreClientManager clientManager, DonationManager donationManager) { @@ -228,6 +230,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable _instance = this; _shop = new GearShop(this, clientManager, donationManager); + _rune = new RuneManager("Rune", plugin); // Register listeners UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(getPlugin()), getPlugin()); @@ -242,6 +245,12 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable public void addCommands() { addCommand(new GearCommand(this)); + addCommand(new RuneCommand(this)); + } + + public RuneManager getRuneManager() + { + return _rune; } /** @@ -303,8 +312,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable factory.setType(Material.BOW); } - if (itemType != ItemType.LEGENDARY) // Only non-legendaries have - // attributes + if (itemType != ItemType.LEGENDARY || (UtilMath.random.nextDouble() <= .35 && factory.getMaterial() != Material.RECORD_6)) // Melee Legendaries have a chance to spawn with attributes { AttributeContainer attributes = new AttributeContainer(); generateAttributes(attributes, itemType, attributeCount); @@ -352,6 +360,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable case WEAPON: sampleAttribute = instantiate(WEAPON_ATTRIBUTES.generateRandom()); break; + case LEGENDARY: + sampleAttribute = instantiate(WEAPON_ATTRIBUTES.generateRandom()); + break; case BOW: sampleAttribute = instantiate(BOW_ATTRIBUTES.generateRandom()); break; @@ -366,14 +377,25 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable attempts++; } - - container.addAttribute(attribute); + + if (attribute != null) + { + container.addAttribute(attribute); + } } } public void spawnItem(Location location) { CustomItem item = generateItem(); + if (item.getMaterial() == Material.RECORD_4 || item.getMaterial() == Material.GOLD_RECORD || item.getMaterial() == Material.RECORD_3 || item.getMaterial() == Material.RECORD_5 || item.getMaterial() == Material.RECORD_6 || item.getMaterial() == Material.GREEN_RECORD) + { + UtilFirework.playFirework(location, Type.BALL, Color.RED, true, false); + } + else + { + UtilFirework.playFirework(location, Type.BALL, Color.AQUA, true, false); + } location.getWorld().dropItem(location, item.toItemStack()); } @@ -667,7 +689,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable List cleansed = new ArrayList<>(); for (String s : input) { - if (s.startsWith(ITEM_SERIALIZATION_TAG)) + if (!s.startsWith(ITEM_SERIALIZATION_TAG)) { cleansed.add(s); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java index 8e1c17139..5b90f4fa4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java @@ -68,7 +68,7 @@ public class AttributeContainer if (_suffix != null) { - itemName += "of " + _suffix.getDisplayName(); + itemName += " of " + _suffix.getDisplayName(); } return itemName; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java new file mode 100644 index 000000000..b3cc4272a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.items.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.runes.RuneManager; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; + +import org.bukkit.entity.Player; + +/** + * Command to give yourself a rune + */ +public class RuneCommand extends CommandBase +{ + private RuneManager _rune; + + public RuneCommand(GearManager plugin) + { + super(plugin, Rank.ADMIN, "rune", "giverune", "getrune"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (_rune == null) + { + _rune = Plugin.getRuneManager(); + } + + if (args.length < 1) + { + UtilPlayer.message(caller, F.main("Rune", "Usage: /" + _aliasUsed + " ")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Available types:")); + for (RuneAttribute rune : RuneAttribute.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + rune.toString()); + } + return; + } + RuneAttribute rune = RuneAttribute.getFromString(args[0]); + if (rune == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Invalid rune type! Available types:")); + for (RuneAttribute type : RuneAttribute.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + type.toString()); + } + return; + } + UtilInv.insert(caller, _rune.getRune(rune)); + UtilPlayer.message(caller, F.main("Rune", "You have been given a(n) " + F.elem(rune.getDisplay()) + " rune!")); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java index c0bef5df0..7259f89e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java @@ -55,7 +55,7 @@ public class HyperAxe extends LegendaryItem { event.SetIgnoreRate(true); - event.AddMod("Hyper Axe", 9); + event.AddMod("Hyper Axe", 5); _lastAttack = System.currentTimeMillis(); } else diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 0ef767d7a..26003be99 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -17,7 +17,6 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; @@ -67,7 +66,7 @@ public class MeridianScepter extends LegendaryItem return; } - if (Recharge.Instance.use(wielder, "Meridian Scepter", 4000, true, true)) + if (Recharge.Instance.use(wielder, "Meridian Scepter", 2000, true, true)) { fire(wielder); @@ -93,22 +92,22 @@ public class MeridianScepter extends LegendaryItem { for (Entity cur : projectile.getWorld().getEntities()) { - if (cur == shooter || !(cur instanceof Player) || (cur instanceof Player && UtilPlayer.isSpectator(cur))) + if (cur == shooter || !(cur instanceof LivingEntity) || (cur instanceof Player && UtilPlayer.isSpectator(cur))) continue; - Player player = (Player) cur; + LivingEntity ent = (LivingEntity) cur; // If they are less than 0.5 blocks away - if (player.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2) + if (ent.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2) { - AttackAnimation aa = new AttackAnimation(player, shooter); + AttackAnimation aa = new AttackAnimation(ent, shooter); int i = UtilServer.getServer().getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), () -> { aa.update(); }, 0, 1); _animations.put(aa, i); - UtilPlayer.message(player, F.main("Clans", F.elem(shooter.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); - UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); + UtilPlayer.message(ent, F.main("Clans", F.elem(shooter.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); + UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(ent.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); } } @@ -199,7 +198,7 @@ public class MeridianScepter extends LegendaryItem Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector() .subtract(projectile.toVector()); - direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.15); + direction.add(newDirection.normalize().multiply(0.02)).normalize().multiply(0.25); } projectile.add(direction); @@ -254,12 +253,13 @@ public class MeridianScepter extends LegendaryItem private class AttackAnimation { - private Player _hit, _shooter; + private LivingEntity _hit; + private Player _shooter; private double _step; private double _radius; private long _start, _lastStepIncrease; - public AttackAnimation(Player hit, Player shooter) + public AttackAnimation(LivingEntity hit, Player shooter) { _step = 0; _start = System.currentTimeMillis(); @@ -271,25 +271,25 @@ public class MeridianScepter extends LegendaryItem public void update() { - if (_hit == null) + if (_hit == null || !_hit.isValid() || _hit.isDead() || ((_hit instanceof Player) && !((Player)_hit).isOnline())) { end(); return; } - if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + if (UtilTime.elapsed(_lastStepIncrease, 500)) { _step++; _lastStepIncrease = System.currentTimeMillis(); } drawHelix(); - if (UtilTime.elapsed(_start, 4000)) + if (UtilTime.elapsed(_start, 2000)) { _hit.getWorld().strikeLightningEffect(_hit.getLocation()); ClansManager.getInstance().getDamageManager().NewDamageEvent(_hit, _shooter, null, - DamageCause.CUSTOM, 6, false, true, true, + DamageCause.CUSTOM, 8, false, true, true, _shooter.getName(), "Meridian Scepter"); - ClansManager.getInstance().getCondition().Factory().Blind("Meridian Scepter", _hit, _shooter, 1, 0, true, true, true); + ClansManager.getInstance().getCondition().Factory().Blind("Meridian Scepter", _hit, _shooter, 3, 0, true, true, false); end(); return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java index 2bd901525..8905742d1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java @@ -77,7 +77,7 @@ public class RunedPickaxe extends RareItem { return; } - + RunedPickaxe pick = (RunedPickaxe) gear.getWeapon(); String playerClan = ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()) == null ? null : ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()).getName(); @@ -90,6 +90,9 @@ public class RunedPickaxe extends RareItem if (event.getBlock().getType() == Material.BEDROCK) return; + if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) + return; + if (!UtilTime.elapsed(pick._instamineEnabled, 12000)) { event.getBlock().breakNaturally(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java new file mode 100644 index 000000000..eb3ba28fd --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -0,0 +1,409 @@ +package mineplex.game.clans.items.runes; + +import java.util.Arrays; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.items.CustomItem; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.attributes.armor.ConqueringArmorAttribute; +import mineplex.game.clans.items.attributes.armor.LavaAttribute; +import mineplex.game.clans.items.attributes.armor.PaddedAttribute; +import mineplex.game.clans.items.attributes.armor.ReinforcedAttribute; +import mineplex.game.clans.items.attributes.armor.SlantedAttribute; +import mineplex.game.clans.items.attributes.bow.HeavyArrowsAttribute; +import mineplex.game.clans.items.attributes.bow.HuntingAttribute; +import mineplex.game.clans.items.attributes.bow.InverseAttribute; +import mineplex.game.clans.items.attributes.bow.LeechingAttribute; +import mineplex.game.clans.items.attributes.bow.RecursiveAttribute; +import mineplex.game.clans.items.attributes.bow.ScorchingAttribute; +import mineplex.game.clans.items.attributes.bow.SlayingAttribute; +import mineplex.game.clans.items.attributes.weapon.ConqueringAttribute; +import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; +import mineplex.game.clans.items.attributes.weapon.FrostedAttribute; +import mineplex.game.clans.items.attributes.weapon.HasteAttribute; +import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; +import mineplex.game.clans.items.attributes.weapon.SharpAttribute; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Manager class for runes + */ +public class RuneManager implements Listener +{ + private static final String RUNE_NAME = C.cGold + "Ancient Rune"; + private String _managerName; + + public RuneManager(String name, JavaPlugin plugin) + { + _managerName = name; + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + /** + * Checks if an item is a rune + * @param item The item to check + * @return Whether the item is a rune + */ + public boolean isRune(ItemStack item) + { + if (item == null || item.getType() == Material.AIR) + { + return false; + } + ItemMeta im = item.getItemMeta(); + return im.hasDisplayName() && im.getDisplayName().equals(RUNE_NAME) && im.hasLore() && im.getLore().size() > 0; + } + + /** + * Converts a rune item to a rune attribute + * @param rune The rune to convert + * @return The attribute of the rune + */ + public RuneAttribute decodeRune(ItemStack rune) + { + if (!isRune(rune)) + { + return null; + } + RuneAttribute attribute = RuneAttribute.getFromDisplay(rune.getItemMeta().getLore().get(0)); + + return attribute; + } + + /** + * Gets the item representation of a rune attribute + * @param attribute The rune attribute to generate the rune from + * @return The item representation of the rune attribute + */ + public ItemStack getRune(RuneAttribute attribute) + { + ItemStack rune = new ItemStack(Material.NETHER_STAR); + ItemMeta im = rune.getItemMeta(); + + im.setDisplayName(RUNE_NAME); + im.setLore(Arrays.asList(attribute.getDisplay())); + rune.setItemMeta(im); + + return rune; + } + + /** + * Applies a rune to an item + * @param rune The rune to apply to the item + * @param to The item to apply the rune to + * @return The item after having the rune applied + */ + public ItemStack applyToItem(RuneAttribute rune, ItemStack to) + { + if (!rune.canApplyTo(to.getType())) + { + return null; + } + if (GearManager.isCustomItem(to)) + { + try + { + ItemAttribute attribute = rune.getAttributeClass().newInstance(); + CustomItem item = GearManager.parseItem(to); + if (!item.getAttributes().getRemainingTypes().contains(attribute.getType())) + { + return null; + } + item.getAttributes().addAttribute(attribute); + ItemStack stack = to.clone(); + item.setMaterial(stack.getType()); + item.update(stack); + return stack; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + } + else + { + try + { + CustomItem item = new CustomItem(to.getType()); + item.addDullEnchantment(); + ItemAttribute attribute = rune.getAttributeClass().newInstance(); + item.getAttributes().addAttribute(attribute); + ItemStack stack = to.clone(); + item.update(stack); + return stack; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onMakeBeaconWithRune(PrepareItemCraftEvent event) + { + if (event.getInventory().getResult() == null || !event.getInventory().getResult().getType().equals(Material.BEACON)) + { + return; + } + if (!isRune(event.getInventory().getItem(5))) + { + return; + } + event.getInventory().setResult(null); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onCraftBeaconWithRune(CraftItemEvent event) + { + if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BEACON) + { + return; + } + if (!isRune(event.getInventory().getItem(5))) + { + return; + } + event.setCancelled(true); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onPlaceRuneInAnvil(InventoryClickEvent event) + { + if (!(event.getWhoClicked() instanceof Player)) + { + return; + } + if (!event.getInventory().getType().equals(InventoryType.ANVIL)) + { + return; + } + if (!isRune(event.getCursor()) && !isRune(event.getCurrentItem())) + { + return; + } + event.setCancelled(true); + if (event.getInventory().getItem(0) == null && event.getInventory().getItem(1) == null) + { + event.getWhoClicked().closeInventory(); + } + UtilPlayer.message(event.getWhoClicked(), F.main(_managerName, "To use a rune, place it on an item!")); + } + + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onUseRune(InventoryClickEvent event) + { + if(!(event.getWhoClicked() instanceof Player)) + { + return; + } + + Player player = (Player) event.getWhoClicked(); + + if (!isRune(event.getCursor())) + { + return; + } + if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) + { + return; + } + + RuneAttribute rune = decodeRune(event.getCursor()); + if (rune == null) + { + return; + } + if (event.getCurrentItem().getAmount() > 1) + { + UtilPlayer.message(player, F.main(_managerName, "The rune cannot apply to all of those items!")); + return; + } + if (!rune.canApplyTo(event.getCurrentItem().getType())) + { + UtilPlayer.message(player, F.main(_managerName, "The rune seems to reject that type of item!")); + return; + } + ItemStack after = applyToItem(rune, event.getCurrentItem()); + if (after == null) + { + UtilPlayer.message(player, F.main(_managerName, "The rune seems to reject that item!")); + return; + } + + event.setCancelled(true); + ItemStack cursorAfter = null; + if (event.getCursor().getAmount() > 1) + { + cursorAfter = event.getCursor().clone(); + cursorAfter.setAmount(cursorAfter.getAmount() - 1); + } + event.setCursor(new ItemStack(Material.AIR)); + event.getClickedInventory().setItem(event.getSlot(), after); + if (cursorAfter != null) + { + UtilInv.insert(player, cursorAfter); + } + player.playSound(player.getLocation(), Sound.ANVIL_USE, 1.5f, 5f); + + player.updateInventory(); + } + + /** + * Enum of all rune attributes + */ + public static enum RuneAttribute + { + FROSTED(FrostedAttribute.class, "Frosted", true, false, false), + SHARP(SharpAttribute.class, "Sharp", true, false, false), + JAGGED(JaggedAttribute.class, "Jagged", true, false, false), + HASTE(HasteAttribute.class, "Haste", true, false, false), + FLAMING(FlamingAttribute.class, "Flaming", true, false, false), + CONQUERING(ConqueringAttribute.class, "Conquering", true, false, false), + SLANTED(SlantedAttribute.class, "Slanted", false, true, false), + REINFORCED(ReinforcedAttribute.class, "Reinforced", false, true, false), + CONQUERING_ARMOR(ConqueringArmorAttribute.class, "Conquering", false, true, false), + PADDED(PaddedAttribute.class, "Padded", false, true, false), + LAVA(LavaAttribute.class, "Lava Forged", false, true, false), + HEAVY(HeavyArrowsAttribute.class, "Heavy", false, false, true), + HUNTING(HuntingAttribute.class, "Hunting", false, false, true), + INVERSE(InverseAttribute.class, "Inverse", false, false, true), + LEECHING(LeechingAttribute.class, "Leeching", false, false, true), + RECURSIVE(RecursiveAttribute.class, "Recursive", false, false, true), + SCORCHING(ScorchingAttribute.class, "Scorching", false, false, true), + SLAYING(SlayingAttribute.class, "Slaying", false, false, true) + ; + + private Class _class; + private String _display; + private boolean _weapon, _armor, _bow; + + private RuneAttribute(Class attributeClass, String display, boolean weapon, boolean armor, boolean bow) + { + _class = attributeClass; + _display = display; + _weapon = weapon; + _armor = armor; + _bow = bow; + + if (weapon) + { + _display = C.cRed + C.Italics + _display; + } + if (armor) + { + _display = C.cGreen + C.Italics + _display; + } + if (bow) + { + _display = C.cDAqua + C.Italics + _display; + } + } + + /** + * Gets the lore display of this rune type + * @return The lore display of this rune type + */ + public String getDisplay() + { + return _display; + } + + /** + * Gets the class for this rune type + * @return The class for this rune type + */ + public Class getAttributeClass() + { + return _class; + } + + /** + * Checks whether this rune type can be applied to an item type + * @param type The item type to check + * @return Whether this rune type can be applied to that item type + */ + public boolean canApplyTo(Material type) + { + if (_weapon) + { + if (UtilItem.isSword(type) || UtilItem.isAxe(type)) + { + return true; + } + if (type == Material.RECORD_4 || type == Material.GOLD_RECORD || type == Material.RECORD_3 || type == Material.RECORD_5 || type == Material.GREEN_RECORD) + { + return true; + } + } + if (_armor && UtilItem.isArmor(type)) + { + return true; + } + if (_bow && type == Material.BOW) + { + return true; + } + + return false; + } + + /** + * Gets the rune attribute from a given lore display + * @param display The lore display to check + * @return The rune attribute associated with that lore display + */ + public static RuneAttribute getFromDisplay(String display) + { + for (RuneAttribute rune : RuneAttribute.values()) + { + if (rune.getDisplay().equals(display)) + { + return rune; + } + } + + return null; + } + + /** + * Gets the rune attribute that resolves to the given string + * @param string The string to get the rune attribute based on + * @return The rune attribute that resolves to that string + */ + public static RuneAttribute getFromString(String string) + { + for (RuneAttribute rune : RuneAttribute.values()) + { + if (rune.toString().equalsIgnoreCase(string)) + { + return rune; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java index b3221c89f..6dc7d8966 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java @@ -35,8 +35,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; import mineplex.core.packethandler.PacketHandler; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java new file mode 100644 index 000000000..4a33d2f5f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.restart; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class RestartCommand extends CommandBase +{ + public RestartCommand(RestartManager plugin) + { + super(plugin, Rank.ADMIN, "forceRestart"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main("Clans", "Initiating server restart!")); + Plugin.restart(); + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..2800434cb --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -0,0 +1,121 @@ +package mineplex.game.clans.restart; + +import java.util.Calendar; +import java.util.LinkedList; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; + +public class RestartManager extends MiniPlugin +{ + private static final int MAX_RESTART_TIME = 2; //Server won't auto restart after 2am + private final LinkedList _warnings = new LinkedList<>(); + private Long _restartUnlock; + private Long _restartTime = -1L; + private boolean _restarting; + + public RestartManager(JavaPlugin plugin) + { + super("Restart Manager", plugin); + + if (inRestartZone(Calendar.HOUR_OF_DAY)) + { + _restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS); + } + else + { + _restartUnlock = System.currentTimeMillis(); + } + + _warnings.add(60000L); + _warnings.add(30000L); + _warnings.add(10000L); + _warnings.add(5000L); + addCommand(new RestartCommand(this)); + } + + private boolean inRestartZone(int hour) + { + return hour >= 0 && hour < MAX_RESTART_TIME; //12 am = 0 + } + + private boolean tryRestart() + { + if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock) + { + return false; + } + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + return false; + } + if (ClansManager.getInstance().getNetherManager().InNether.size() > 0) + { + return false; + } + if (ClansManager.getInstance().getWorldEvent().getEvents().size() > 0) + { + return false; + } + + return true; + } + + public void restart() + { + Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!")); + UtilTextMiddle.display(C.cRed + "Server Restart", C.cGray + "This server will restart in " + F.elem(UtilTime.MakeStr(120000)) + "!"); + _restartTime = System.currentTimeMillis() + 120000; + } + + @EventHandler + public void checkRestart(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (_restarting) + { + return; + } + + if (_restartTime != -1) + { + if (!_warnings.isEmpty()) + { + if (_restartTime - System.currentTimeMillis() <= _warnings.getFirst()) + { + Long time = _warnings.removeFirst(); + Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(time)) + "!")); + } + } + if (System.currentTimeMillis() >= _restartTime) + { + _restarting = true; + Portal.getInstance().sendAllPlayers("ClansHub"); + runSyncLater(() -> {Bukkit.shutdown();}, 120L); + } + } + else + { + if (tryRestart()) + { + restart(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java index 3ba9eaff8..636854481 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java @@ -37,7 +37,7 @@ public enum ClansShopItem BOW(175, 35, Material.BOW, 1), ARROW(10, 2, Material.ARROW, 1), ENCHANTMENT_TABLE(30000, 0, Material.ENCHANTMENT_TABLE, 1), - TNT(30000, 0, Material.TNT, 1), + TNT(20000, 0, Material.TNT, 1), TNT_GENERATOR(300000, 0, Material.BREWING_STAND_ITEM, 1), // Mining Shop IRON_INGOT(500, 100, Material.IRON_INGOT, 1), @@ -78,8 +78,8 @@ public enum ClansShopItem QUARTZ_BLOCK(75, 15, Material.QUARTZ_BLOCK, 1), CLAY(30, 6, Material.CLAY, 1), GOLD_TOKEN(50000, 50000, Material.GOLD_RECORD, 1, (byte) 0, "Gold Token"), - OUTPOST(100000, 0, Material.BEACON, 1, (byte) 0, C.cBlue + "Outpost"), - CANNON(50000, 0, Material.SPONGE, 1, (byte) 1, C.cBlue + "Cannon"); + OUTPOST(30000, 0, Material.BEACON, 1, (byte) 0, C.cBlue + "Outpost"), + CANNON(25000, 0, Material.SPONGE, 1, (byte) 1, C.cBlue + "Cannon"); private int _buyPrice; private int _sellPrice; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java index a62f2ad89..c87a00d32 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java @@ -31,8 +31,8 @@ public class PvpItem extends ShopItem LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + (buyPrice == 0 ? "Free (Tutorial)" : buyPrice + "g"), C.cWhite + " ", - UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, - UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", + UtilItem.isArmor(type) || UtilItem.isTool(type) || type == Material.BOW ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, + UtilItem.isArmor(type) || UtilItem.isTool(type) || type == Material.BOW ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + (sellPrice == 0 ? "Free" : sellPrice + ""), C.cWhite + " ", diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index 9ea38cf70..8a292032d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -15,6 +15,7 @@ import mineplex.core.common.util.InventoryUtil; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; @@ -57,6 +58,10 @@ public class ShopItemButton> implements IButton @Override public void onClick(final Player player, ClickType clickType) { + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } boolean shiftClick = (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.SHIFT_RIGHT); if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT) @@ -95,7 +100,7 @@ public class ShopItemButton> implements IButton } else if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT) { - final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType())) && shiftClick ? 64 : 1; + final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType()) || _item.getType() == Material.BOW) && shiftClick ? 64 : 1; final int cost = amount * _buyPrice; int goldCount = GoldManager.getInstance().getGold(player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java index 1589acf09..e2259fd51 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java @@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.Callback; import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -29,6 +30,11 @@ public class CashInButton implements IButton { if (clickType != ClickType.LEFT && clickType != ClickType.RIGHT) return; + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + ItemStack item = player.getItemOnCursor(); CustomItem cursorItem = GearManager.parseItem(item); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java index cd5a969b2..226fcfdec 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/GemTransferButton.java @@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.Callback; import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -31,6 +32,11 @@ public class GemTransferButton implements IButton { if (clickType != ClickType.LEFT) return; + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + if (GoldManager.getInstance().canTransferGems(player)) { GoldManager.getInstance().transferGemsToCoins(player, _gemAmount); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java index d6dcd4ccb..66efc500b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/StoreGoldButton.java @@ -4,6 +4,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.game.clans.economy.GoldManager; @@ -21,6 +22,11 @@ public class StoreGoldButton implements IButton { if (clickType != ClickType.LEFT) return; + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + if (_page.hasEnoughGold()) { int cost = BankPage.TOKEN_VALUE; @@ -29,4 +35,4 @@ public class StoreGoldButton implements IButton } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java deleted file mode 100644 index 5cbea79d1..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java +++ /dev/null @@ -1,25 +0,0 @@ -package mineplex.game.clans.shop.energy; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.shop.item.SalesPackageBase; - -public class EnergyPackage extends SalesPackageBase -{ - public EnergyPackage(String name, int cost) - { - super(name, Material.REDSTONE, " ", ChatColor.RESET + "Clan Energy"); - CurrencyCostMap.put(CurrencyType.GOLD, cost); - KnownPackage = false; - OneTimePurchaseOnly = false; - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index d84a9877a..162be0a87 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -1,19 +1,25 @@ package mineplex.game.clans.shop.energy; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent; +import mineplex.game.clans.economy.GoldPurchaseProcessor; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; public class EnergyShopButton implements IButton { + private static final ItemStack ICON = new ItemBuilder(Material.REDSTONE).setTitle(ChatColor.RESET + "Clan Energy").build(); + private ClanEnergyManager _energyManager; private EnergyPage _page; private int _energyToPurchase; @@ -32,34 +38,26 @@ public class EnergyShopButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { - if (UtilServer.CallEvent(new PreEnergyShopBuyEvent(player, _energyToPurchase, _cost)).isCancelled()) + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) { return; } - _page.getShop().openPageForPlayer(player, new ConfirmationPage( - _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + if (UtilServer.CallEvent(new PreEnergyShopBuyEvent(player, _energyToPurchase, _cost)).isCancelled()) { - public void run() - { - _clanInfo.adjustEnergy(_energyToPurchase); - _page.refresh(); + return; + } - _energyManager.runAsync(new Runnable() - { - @Override - public void run() - { - _energyManager.getClansManager().getClanDataAccess().updateEnergy(_clanInfo); - } - }); - - // Notify - _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); - } - }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), CurrencyType.GOLD, player)); + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new GoldPurchaseProcessor(player, _cost, _energyManager.getClansManager().getGoldManager(), () -> + { + _clanInfo.adjustEnergy(_energyToPurchase); + _page.refresh(); + _energyManager.runAsync(() -> _energyManager.getClansManager().getClanDataAccess().updateEnergy(_clanInfo)); + // Notify + _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); + }), ICON)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java index eaed63bc0..367cc8464 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java @@ -1,31 +1,19 @@ package mineplex.game.clans.shop.pvp.tnt; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilUI; +import mineplex.core.common.util.*; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.shop.ClansShopItem; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.inventory.ItemStack; public class TNTGenPage extends ShopPageBase { @@ -64,7 +52,7 @@ public class TNTGenPage extends ShopPageBase return; } - if (_donationManager.Get(player).getGold() >= ClansShopItem.TNT_GENERATOR.getBuyPrice()) + if (getPlugin().getGoldManager().Get(player).getBalance() >= ClansShopItem.TNT_GENERATOR.getBuyPrice()) { GoldManager.getInstance().deductGold(success -> { UtilPlayer.message(player, F.main("Clans", "You purchased a " + F.elem("TNT Generator") + " for your Clan. You can now access it from the " + F.elem("PvP Shop") + ".")); 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 92f29b3bf..5c57ef602 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 @@ -2,6 +2,23 @@ package mineplex.game.clans.spawn; import java.util.Set; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.weight.WeightSet; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -26,28 +43,10 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.common.weight.WeightSet; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - public class Spawn extends MiniPlugin { public static final int SPAWN_RADIUS = 32; @@ -457,7 +456,7 @@ public class Spawn extends MiniPlugin public static Location getWestTown() { - return new Location(getSpawnWorld(), -440.91, 63, 23.08); + return new Location(getSpawnWorld(), -440.91, 65, 23.08); } public static Location getWestTownCenter() @@ -467,7 +466,7 @@ public class Spawn extends MiniPlugin public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 63, -23.08); + return new Location(getSpawnWorld(), 440.91, 65, -23.08); } public static Location getEastTownCenter() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 826fbccc1..135689cdc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -16,8 +16,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.hologram.HologramManager; import mineplex.core.npc.NpcManager; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.message.ClansMessageManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index f9d21b850..804966bb3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -469,7 +469,7 @@ public class ClansMainTutorial extends Tutorial // } // }); - if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) + /*if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) { ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); if (clan == null) @@ -481,7 +481,7 @@ public class ClansMainTutorial extends Tutorial UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial")); } } - else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) + else */if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) { Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2); } diff --git a/Plugins/Mineplex.Hub.Clans/plugin.yml b/Plugins/Mineplex.Hub.Clans/plugin.yml new file mode 100644 index 000000000..5bc1ff2f7 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/plugin.yml @@ -0,0 +1,3 @@ +name: ClansHub +main: mineplex.clanshub.ClansHub +version: 0.1 \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/pom.xml b/Plugins/Mineplex.Hub.Clans/pom.xml new file mode 100644 index 000000000..b5bc14c36 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + ClansHub + mineplex-clanshub + + + + ${project.groupId} + mineplex-game-clans-core + ${project.version} + + + ${project.groupId} + mineplex-minecraft-game-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java new file mode 100644 index 000000000..6272f6477 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -0,0 +1,175 @@ +package mineplex.clanshub; + +import mineplex.core.CustomTagFix; +import mineplex.core.PacketsInteractionFix; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.AntiHackGuardian; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.chat.Chat; +import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; +import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.elo.EloManager; +import mineplex.core.friend.FriendManager; +import mineplex.core.give.Give; +import mineplex.core.globalpacket.GlobalPacketManager; +import mineplex.core.hologram.HologramManager; +import mineplex.core.ignore.IgnoreManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.memory.MemoryFix; +import mineplex.core.message.MessageManager; +import mineplex.core.monitor.LagMeter; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.PartyManager; +import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.profileCache.ProfileCacheManager; +import mineplex.core.punish.Punish; +import mineplex.core.recharge.Recharge; +import mineplex.core.resourcepack.ResourcePackManager; +import mineplex.core.serverConfig.ServerConfiguration; +import mineplex.core.stats.StatsManager; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.task.TaskManager; +import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; +import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.updater.FileUpdater; +import mineplex.core.updater.Updater; +import mineplex.core.velocity.VelocityFix; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.combat.CombatManager; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; + +import static mineplex.core.Managers.require; + +/** + * Main class for clans hub + */ +public class ClansHub extends JavaPlugin +{ + private String WEB_CONFIG = "webServer"; + + @Override + public void onEnable() + { + Bukkit.setSpawnRadius(0); + getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); + getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); + saveConfig(); + + String webServerAddress = getConfig().getString(WEB_CONFIG); + + //Logger.initialize(this); + + //Velocity Fix + new VelocityFix(this); + + //Static Modules + require(ProfileCacheManager.class); + CommandCenter.Initialize(this); + CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); + CommandCenter.Instance.setClientManager(clientManager); + +// new ProfileCacheManager(this); + ItemStackFactory.Initialize(this, false); + Recharge.Initialize(this); + VisibilityManager.Initialize(this); Give.Initialize(this); + Punish punish = new Punish(this, webServerAddress, clientManager); + BlockRestore blockRestore = new BlockRestore(this); + DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); + + ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager); + + //Other Modules + PacketHandler packetHandler = require(PacketHandler.class); + DisguiseManager disguiseManager = require(DisguiseManager.class); + IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager); + + incognito.setPreferencesManager(preferenceManager); + + preferenceManager.GiveItem = true; + Creature creature = new Creature(this); + NpcManager npcManager = new NpcManager(this, creature); + InventoryManager inventoryManager = new InventoryManager(this, clientManager); + PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); + PollManager pollManager = new PollManager(this, clientManager, donationManager); + + //Main Modules + ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); + new TitanGiveawayManager(this, clientManager, serverStatusManager); + + Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); + + AntiHack antiHack = require(AntiHack.class); + + for (int i = 0; i < 8; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 195, 0), 25, -8, 195, 185, 17, -16)); + } + + IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); + + FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + + StatsManager statsManager = new StatsManager(this, clientManager); + EloManager eloManager = new EloManager(this, clientManager); + AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager, incognito, eloManager); + + PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); + + CustomDataManager customDataManager = new CustomDataManager(this, clientManager); + + ConditionManager condition = new ConditionManager(this); + ThankManager thankManager = new ThankManager(this, clientManager, donationManager); + BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); + + HologramManager hologramManager = new HologramManager(this, packetHandler); + + ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); + + Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); + new MemoryFix(this); + new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); + new CustomTagFix(this, packetHandler); + new PacketsInteractionFix(this, packetHandler); + new ResourcePackManager(this, portal); + new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, hubManager.getBonusManager().getRewardManager()); + + AprilFoolsManager.Initialize(this, clientManager, disguiseManager); + + CombatManager combatManager = new CombatManager(this); + + DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, condition); + + Teleport teleport = new Teleport(this, clientManager); + + //Updates + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); + } + + @Override + public void onDisable() + { + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java new file mode 100644 index 000000000..a561d15fc --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -0,0 +1,150 @@ +package mineplex.clanshub; + +import java.util.Collection; +import java.util.Comparator; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.core.repository.tokens.SimpleClanToken; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +/** + * GUI page for clans servers + */ +public class ClansServerPage extends ShopPageBase +{ + public ClansServerPage(ClansTransferManager plugin, ClansServerShop shop, CoreClientManager clientManager, + DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Clans", player, 54); + + buildPage(); + } + + @Override + protected void buildPage() + { + if (!getPlugin().Get(_player).getClanName().isEmpty()) + { + buildClanPage(getPlugin().Get(_player)); + } + else + { + buildNoClanPage(); + } + } + + private void buildClanPage(SimpleClanToken clan) + { + if (getClientManager().hasRank(_player, Rank.HELPER)) + { + buildStaffJoinServers(clan); + } + else + { + buildJoinHomeServer(clan); + } + } + + private void buildNoClanPage() + { + Collection servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator() + { + @Override + public int compare(ServerInfo o1, ServerInfo o2) + { + return o1.Name.compareTo(o2.Name); + } + }); + + int currentSlot = 9; + for (ServerInfo server : servers) + { + buildJoinServer(currentSlot, server); + currentSlot++; + } + } + + private void buildJoinHomeServer(SimpleClanToken clan) + { + ServerInfo serverInfo = getServerInfo(clan.getHomeServer()); + boolean serverOnline = (serverInfo != null); + String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline"; + + String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!"; + String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer(); + String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus; + String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" ); + String change = C.cRed + "Note: " + C.cWhite + "You must leave your Clan to "; + String change2 = C.cWhite + "play on a different Clans Server!"; + ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " ", change, change2, " "}, 0, true, true); + addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()))); + } + + private void buildJoinServer(int slot, ServerInfo server) + { + String title = C.cGreen + C.Bold + "Join Clans Server!"; + String desc1 = C.cYellow + "Server Name " + C.cWhite + server.Name; + String desc2 = C.cYellow + "Players " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers; + String desc3 = C.cRed + "Note: " + C.cWhite + "Creating or Joining a clan on this"; + String desc4 = C.cWhite + "server will set your Home Server!"; + + ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK, title, new String[] {" ", desc1, desc2, " ", desc3, desc4}, 0, true, true); + addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), server)); + } + + private void buildStaffJoinServers(SimpleClanToken clan) + { + ServerInfo serverInfo = getServerInfo(clan.getHomeServer()); + boolean serverOnline = (serverInfo != null); + String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline"; + + String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!"; + String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer(); + String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus; + String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" ); + ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " "}, 0, true, true); + addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()))); + + Collection servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator() + { + @Override + public int compare(ServerInfo o1, ServerInfo o2) + { + return o1.Name.compareTo(o2.Name); + } + }); + + int currentSlot = 27; + for (ServerInfo server : servers) + { + if (server.Name.equalsIgnoreCase(clan.getHomeServer())) + { + continue; + } + buildJoinServer(currentSlot, server); + currentSlot++; + } + } + + private ServerInfo getServerInfo(String serverName) + { + return getPlugin().getServer(serverName); + } + + /** + * Refresh all GUI pages and buttons + */ + public void update() + { + getButtonMap().clear(); + buildPage(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java new file mode 100644 index 000000000..23065a997 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java @@ -0,0 +1,43 @@ +package mineplex.clanshub; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.donation.DonationManager; +import mineplex.core.party.Party; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +/** + * GUI Shop manager for clans servers + */ +public class ClansServerShop extends ShopBase +{ + public ClansServerShop(ClansTransferManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Clans"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new ClansServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player); + } + + @Override + protected boolean canOpenShop(Player player) + { + Party party = getPlugin().getPartyManager().getParty(player); + + if (party != null) + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); + player.sendMessage(F.main("Party", "You cannot join Clans while in a party.")); + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java new file mode 100644 index 000000000..f91e02691 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -0,0 +1,292 @@ +package mineplex.clanshub; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; +import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.portal.Portal; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.core.repository.tokens.SimpleClanToken; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.MinecraftServer; +import mineplex.serverdata.servers.ServerManager; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; + +/** + * Server selection controller for clans + */ +public class ClansTransferManager extends MiniDbClientPlugin +{ + private static final long SERVER_RELOAD_INTERVAL = 5000; + private PartyManager _party; + private Portal _portal; + private HubManager _hub; + private Region _region; + private final HashMap _servers = new HashMap(); + private boolean _loading = false; + private long _lastLoaded; + private ClansServerShop _serverShop; + + public ClansTransferManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation, PartyManager party, Portal portal, HubManager hub) + { + super("Server Transfer", plugin, client); + + _party = party; + _portal = portal; + _hub = hub; + _region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; + _serverShop = new ClansServerShop(this, client, donation); + } + + /** + * Gets the stored party manager + * @return The stored party manager + */ + public PartyManager getPartyManager() + { + return _party; + } + + /** + * Gets a list of all loaded servers + * @return A list of all loaded servers + */ + public List getServers() + { + List servers = Lists.newArrayList(); + servers.addAll(_servers.values()); + return servers; + } + + /** + * Gets the loaded ServerInfo with the given name + * @param name The name to check + * @return The loaded ServerInfo, or null if it is not stored + */ + public ServerInfo getServer(String name) + { + for (ServerInfo server : _servers.values()) + { + if (server.Name.equalsIgnoreCase(name)) + { + return server; + } + } + + return null; + } + + /** + * Pulls all the clans servers from redis and loads them. SHOULD BE RUN ASYNC + */ + public void reload() + { + _servers.clear(); + for (MinecraftServer server : ServerManager.getServerRepository(_region).getServerStatusesByPrefix("Clans-")) + { + ServerInfo info = new ServerInfo(); + info.Name = server.getName(); + info.CurrentPlayers = server.getPlayerCount(); + info.MaxPlayers = server.getMaxPlayerCount(); + _servers.put(server, info); + } + } + + /** + * Selects a server to send a player to + * @param player The player to send + * @param serverInfo The server to send the player to + */ + public void selectServer(Player player, ServerInfo serverInfo) + { + Party party = _party.getParty(player); + if (party != null) + { + if(!party.getOwner().equalsIgnoreCase(player.getName())) + { + Lang.NOT_OWNER_SERVER.send(player); + return; + } + _party.getJoinManager().requestServerJoin(serverInfo.Name, party); + return; + } + player.leaveVehicle(); + player.eject(); + + _portal.sendPlayerToServer(player, serverInfo.Name); + } + + @EventHandler + public void reloadServers(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _loading || !UtilTime.elapsed(_lastLoaded, SERVER_RELOAD_INTERVAL)) + { + return; + } + _loading = true; + final Runnable after = new Runnable() + { + public void run() + { + _lastLoaded = System.currentTimeMillis(); + _loading = false; + } + }; + runAsync(() -> + { + reload(); + runSync(after); + }); + } + + @SuppressWarnings("rawtypes") + @EventHandler + public void refreshPages(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (ShopPageBase page : _serverShop.getPageMap().values()) + { + if (page instanceof ClansServerPage) + { + ((ClansServerPage)page).update(); + } + } + } + + @EventHandler + public void onEnterPortal(EntityPortalEnterEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + UtilAction.velocity(event.getEntity(), UtilAlg.getTrajectory(event.getEntity().getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + return; + } + + Player player = (Player) event.getEntity(); + if (!_hub.CanPortal(player)) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + return; + } + if (_party.getParty(player) != null) + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); + player.sendMessage(F.main("Party", "You cannot join Clans while in a party.")); + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + return; + } + + if (!Recharge.Instance.use(player, "Transfer Portal", 5000, false, false)) + { + return; + } + + if (Get(player) == null || Get(player).getHomeServer() == null || Get(player).getHomeServer().isEmpty()) + { + player.teleport(_hub.GetSpawn()); + runSyncLater(() -> + { + _serverShop.attemptShopOpen(player); + }, 20L); + return; + } + + if (getServer(Get(player).getHomeServer()) != null) + { + UtilPlayer.message(player, F.main(getName(), "You are being transferred to your Clan's home server!")); + selectServer(player, getServer(Get(player).getHomeServer())); + } + else + { + UtilPlayer.message(player, F.main(getName(), "Your Clan's home server is not online!")); + } + } + + @EventHandler + public void onUseNPC(NpcInteractEntityEvent event) + { + if (event.getNpc().getName().contains("Clans")) + { + _serverShop.attemptShopOpen(event.getPlayer()); + } + if (event.getNpc().getName().contains("Return")) + { + _portal.sendToHub(event.getPlayer(), "Returning to Mineplex!"); + } + } + + @EventHandler + public void onUseNPC(NpcDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Player)) + { + return; + } + Player player = (Player) event.getDamager(); + + if (event.getNpc().getName().contains("Clans") && Recharge.Instance.use(player, "Go to Clans", 1000, false, false)) + { + _serverShop.attemptShopOpen(player); + } + if (event.getNpc().getName().contains("Return") && Recharge.Instance.use(player, "Return to Mineplex", 1000, false, false)) + { + _portal.sendToHub(player, "Returning to Mineplex!"); + } + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = " + accountId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + SimpleClanToken clanToken = new SimpleClanToken(); + + while (resultSet.next()) + { + String clanName = resultSet.getString(1); + String clanRole = resultSet.getString(2); + String homeServer = resultSet.getString(3); + int clanId = resultSet.getInt(4); + clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId); + } + + Set(uuid, clanToken); + } + + @Override + protected SimpleClanToken addPlayer(UUID uuid) + { + return new SimpleClanToken(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java new file mode 100644 index 000000000..29d8c755a --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java @@ -0,0 +1,104 @@ +package mineplex.clanshub; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.preferences.Preference; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; + +/** + * Manager for player forcefields + */ +public class ForcefieldManager extends MiniPlugin +{ + public HubManager Manager; + + private HashMap _radius = new HashMap(); + + public ForcefieldManager(HubManager manager) + { + super("Forcefield", manager.getPlugin()); + + Manager = manager; + } + + @EventHandler + public void ForcefieldUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.equals(other)) + continue; + + int range = 5; + if (_radius.containsKey(player)) + range = _radius.get(player); + + if (UtilMath.offset(other, player) > range) + continue; + + if (Manager.GetClients().Get(other).GetRank().has(Rank.JNR_DEV)) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + Entity bottom = other; + while (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + } + } + + /** + * Handles the radius from a command and sets a player's forcefield to it + * @param caller The caller of the command + * @param args The args of the command + */ + public void ForcefieldRadius(Player caller, String[] args) + { + try + { + int range = Integer.parseInt(args[0]); + + _radius.put(caller, range); + + UtilPlayer.message(caller, F.main(getName(), "Radius set to " + F.elem(range + "") + ".")); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(getName(), "Invalid Input. Correct input is " + F.elem("/radius #") + ".")); + } + } + + @EventHandler + public void ForcefieldReset(PlayerQuitEvent event) + { + _radius.remove(event.getPlayer()); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java new file mode 100644 index 000000000..38740b49e --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -0,0 +1,1024 @@ +package mineplex.clanshub; + +import mineplex.clanshub.commands.ForcefieldRadius; +import mineplex.clanshub.commands.GadgetToggle; +import mineplex.clanshub.commands.GameModeCommand; +import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.Managers; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.benefit.BenefitManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextTop; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.donation.DonationManager; +import mineplex.core.facebook.FacebookManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.gadgets.morph.MorphWither; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.hologram.HologramManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.menu.MenuManager; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.mount.Mount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.types.MountDragon; +import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.pet.PetManager; +import mineplex.core.playerCount.PlayerCountManager; +import mineplex.core.poll.PollManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; +import mineplex.core.stats.StatsManager; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.task.TaskManager; +import mineplex.core.thank.ThankManager; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.valentines.ValentinesGiftManager; +import mineplex.core.youtube.YoutubeManager; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.UUID; + +/** + * Main manager for clans hub + */ +public class HubManager extends MiniPlugin +{ + private BlockRestore _blockRestore; + private CoreClientManager _clientManager; + private ConditionManager _conditionManager; + private DonationManager _donationManager; + private DisguiseManager _disguiseManager; + private PartyManager _partyManager; + private ForcefieldManager _forcefieldManager; + private PollManager _pollManager; + private Portal _portal; + private StatsManager _statsManager; + private GadgetManager _gadgetManager; + private MountManager _mountManager; + private HubVisibilityManager _visibilityManager; + private PreferencesManager _preferences; + private InventoryManager _inventoryManager; + private AchievementManager _achievementManager; + private TreasureManager _treasureManager; + private PetManager _petManager; + private PacketHandler _packetHandler; + private PlayerCountManager _playerCountManager; + private CustomDataManager _customDataManager; + private Punish _punishManager; + private IncognitoManager _incognito; + private BonusManager _bonusManager; + + private Location _spawn; + private int _scoreboardTick = 0; + + private HashMap _scoreboards = new HashMap(); + + private String _serverName = ""; + private int _lastPlayerCount = 0; + private boolean _shuttingDown; + + private HashMap _portalTime = new HashMap(); + + private HashMap> _creativeAdmin = new HashMap>(); + + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) + { + super("Hub Manager", plugin); + + _incognito = incognito; + + _blockRestore = blockRestore; + _clientManager = clientManager; + _conditionManager = conditionManager; + _donationManager = donationManager; + _disguiseManager = disguiseManager; + _pollManager = pollManager; + + _portal = portal; + + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5, -90f, 0f); + runSyncLater(() -> + { + for (Entity e : _spawn.getWorld().getEntities()) + { + if (npcManager.getNpcByEntity(e) != null) + { + e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), 90f, 0f)); + } + } + }, 120L); + ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; + + new WorldManager(this); + _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); + _inventoryManager = inventoryManager; + new BenefitManager(plugin, clientManager, _inventoryManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager); + + FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); + YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); + + World world = _spawn.getWorld(); + _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); + _treasureManager.disable(); + { + Block chestBlock = world.getBlockAt(-1, 178, -9); + Block chestLoc1 = world.getBlockAt(-4, 178, -8); + Block chestLoc2 = world.getBlockAt(-4, 178, -10); + Block chestLoc3 = world.getBlockAt(-2, 178, -12); + Block chestLoc4 = world.getBlockAt(0, 178, -12); + Block chestLoc5 = world.getBlockAt(2, 178, -10); + Block chestLoc6 = world.getBlockAt(2, 178, -8); + Block chestLoc7 = world.getBlockAt(0, 178, -6); + Block chestLoc8 = world.getBlockAt(-2, 178, -6); + TreasureLocation loc = new TreasureLocation(_treasureManager, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, _spawn, hologramManager, _gadgetManager, serverStatusManager); + _treasureManager.addTreasureLocation(loc); + } + { + Block chestBlock = world.getBlockAt(-1, 178, 9); + Block chestLoc1 = world.getBlockAt(-4, 178, 10); + Block chestLoc2 = world.getBlockAt(-4, 178, 8); + Block chestLoc3 = world.getBlockAt(-2, 178, 6); + Block chestLoc4 = world.getBlockAt(0, 178, 6); + Block chestLoc5 = world.getBlockAt(2, 178, 8); + Block chestLoc6 = world.getBlockAt(2, 178, 10); + Block chestLoc7 = world.getBlockAt(0, 178, 12); + Block chestLoc8 = world.getBlockAt(-2, 178, 12); + TreasureLocation loc = new TreasureLocation(_treasureManager, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, _spawn, hologramManager, _gadgetManager, serverStatusManager); + _treasureManager.addTreasureLocation(loc); + } + + new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + + new MenuManager(_plugin); + + _petManager = petManager; + _partyManager = partyManager; + _preferences = preferences; + _visibilityManager = new HubVisibilityManager(this); + + _forcefieldManager = new ForcefieldManager(this); + addCommand(new ForcefieldRadius(_forcefieldManager)); + + _statsManager = statsManager; + _achievementManager = achievementManager; + _achievementManager.setGiveInterfaceItem(true); + _packetHandler = packetHandler; + + new NotificationManager(getPlugin(), clientManager, _preferences); + new BotSpamManager(plugin, clientManager, punish); + + ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + + new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); + + _playerCountManager = new PlayerCountManager(plugin); + + _customDataManager = Managers.get(CustomDataManager.class); + + _punishManager = punish; + + _serverName = getPlugin().getConfig().getString("serverstatus.name"); + _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); + } + + @Override + public void addCommands() + { + addCommand(new GadgetToggle(this)); + addCommand(new GameModeCommand(this)); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void reflectMotd(ServerListPingEvent event) + { + if (_shuttingDown) + { + event.setMotd("Restarting soon"); + } + } + + /** + * Checks if an entity can be bumped + * @param ent The entity to check + * @return Whether the entity can be bumped + */ + public boolean BumpDisabled(Entity ent) + { + if (ent == null) + return false; + + if (ent instanceof Player) + { + return !_preferences.get((Player)ent).isActive(Preference.HUB_GAMES); + } + + return true; + } + + @EventHandler + public void redirectStopCommand(PlayerCommandPreprocessEvent event) + { + if (event.getPlayer().isOp() && event.getMessage().equalsIgnoreCase("/stop")) + { + _shuttingDown = true; + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + _portal.sendAllPlayers("Lobby"); + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + Bukkit.shutdown(); + } + }, 40L); + } + }, 60L); + + event.setCancelled(true); + } + } + + @EventHandler + public void preventEggSpawn(ItemSpawnEvent event) + { + if (event.getEntity() instanceof Egg) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void login(final PlayerLoginEvent event) + { + CoreClient client = _clientManager.Get(event.getPlayer()); + + // Reserved Slot Check + if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) + { + if (!client.GetRank().has(Rank.ULTRA)) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + { + public void run() + { + _portal.sendPlayerToServer(event.getPlayer(), "ClansHub"); + } + }); + + event.allow(); + } + } + else + event.allow(); + } + + @EventHandler(priority = EventPriority.LOW) + public void handleOP(PlayerJoinEvent event) + { + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) + event.getPlayer().setOp(true); + else + event.getPlayer().setOp(false); + } + + @EventHandler + public void PlayerRespawn(PlayerRespawnEvent event) + { + event.setRespawnLocation(GetSpawn()); + } + + @EventHandler(priority = EventPriority.LOW) + public void PlayerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + //Public Message + event.setJoinMessage(null); + + //Teleport + player.teleport(GetSpawn()); + + //Survival + player.setGameMode(GameMode.SURVIVAL); + + //Clear Inv + UtilInv.Clear(player); + + //Health + player.setHealth(20); + + //Scoreboard + Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); + player.setScoreboard(board); + _scoreboards.put(player, board); + + //Objective + Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy"); + obj.setDisplaySlot(DisplaySlot.SIDEBAR); + + for (Rank rank : Rank.values()) + { + if (rank != Rank.ALL) + board.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + else + board.registerNewTeam(rank.Name).setPrefix(""); + } + + for (Player otherPlayer : Bukkit.getOnlinePlayers()) + { + if (_clientManager.Get(otherPlayer) == null) + continue; + + String rankName = _clientManager.Get(player).GetRank().Name; + String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name; + + //Add Other to Self + board.getTeam(otherRankName).addPlayer(otherPlayer); + + //Add Self to Other + otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player); + } + } + + @EventHandler + public void PlayerQuit(PlayerQuitEvent event) + { + event.setQuitMessage(null); + + event.getPlayer().leaveVehicle(); + event.getPlayer().eject(); + event.getPlayer().setOp(false); + + for (Player player : UtilServer.getPlayers()) + player.getScoreboard().resetScores(event.getPlayer().getName()); + + _scoreboards.remove(event.getPlayer()); + + _portalTime.remove(event.getPlayer().getName()); + } + + @EventHandler + public void playerPrivateMessage(PrivateMessageEvent event) + { + //Dont Let PM Near Spawn! + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER)) + { + UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); + event.setCancelled(true); + } + } + + @EventHandler + public void Incog(IncognitoHidePlayerEvent event) + { + if (!_clientManager.hasRank(event.getPlayer(), Rank.CMOD)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void PlayerChat(AsyncPlayerChatEvent event) + { + if (event.isCancelled()) + return; + + //Dont Let Chat Near Spawn! + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) + { + UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); + event.setCancelled(true); + return; + } + + Player player = event.getPlayer(); + String playerName = player.getName(); + + Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); + + //Level Prefix + String levelStr = _achievementManager.getMineplexLevel(player, rank); + + //Rank Prefix + String rankStr = ""; + if (rank != Rank.ALL) + rankStr = rank.getTag(true, true) + " "; + //Party Chat + if (event.getMessage().charAt(0) == '#') + { + Party party = _partyManager.getParty(player); + if (party != null) + { + event.getRecipients().clear(); + + event.setMessage(event.getMessage().substring(1, event.getMessage().length())); + event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); + + for (UUID name : party.getMembersByUUID()) + { + Player other = Bukkit.getPlayer(name); + + if (other != null) + event.getRecipients().add(other); + } + } + else + { + UtilPlayer.message(player, F.main("Party", "You are not in a Party.")); + event.setCancelled(true); + } + + return; + } + else + { + TextComponent rankComponent = new TextComponent(rankStr); + TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); + TextComponent component = new TextComponent(); + + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + + component.setText(levelStr); + component.addExtra(rankComponent); + component.addExtra(playerNameText); + component.addExtra(" " + ChatColor.WHITE + event.getMessage()); + + for (Player other : UtilServer.getPlayers()) + { + if (!event.isCancelled()) + other.spigot().sendMessage(component); + } + event.setCancelled(true); + } + } + + @EventHandler + public void Damage(EntityDamageEvent event) + { + if (event.getCause() == DamageCause.VOID) + { + if (event.getEntity() instanceof Player) + { + event.getEntity().eject(); + event.getEntity().leaveVehicle(); + event.getEntity().teleport(GetSpawn()); + } + else + { + event.getEntity().remove(); + } + } + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void handleDeath(PlayerDeathEvent event) + { + event.setKeepInventory(true); + event.getDrops().clear(); + event.getEntity().setHealth(20); + event.getEntity().teleport(GetSpawn()); + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.None); + } + + @EventHandler + public void FoodHealthUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + player.setFoodLevel(20); + player.setExhaustion(0f); + player.setSaturation(3f); + } + } + + @EventHandler + public void InventoryCancel(InventoryClickEvent event) + { + if (event.getWhoClicked() instanceof Player && ((Player)event.getWhoClicked()).getGameMode() != GameMode.CREATIVE) + event.setCancelled(true); + } + + @EventHandler + public void UpdateScoreboard(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + _scoreboardTick = (_scoreboardTick + 1)%3; + + if (_scoreboardTick != 0) + return; + + int playerCount = _playerCountManager.getPlayerCount(); + + for (Player player : UtilServer.getPlayers()) + { + //Return to Main Scoreboard + if (!player.getScoreboard().equals(_scoreboards.get(player))) + player.setScoreboard(_scoreboards.get(player)); + + //Objective + Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); + + //Title + obj.setDisplayName(C.cRed + C.Bold + C.Line + "Mineplex Clans"); + + int line = 15; + + //Space + obj.getScore(" ").setScore(line--); + + //Server + obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); + obj.getScore(_serverName).setScore(line--); + + //Space + obj.getScore(" ").setScore(line--); + + //Players + obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--); + player.getScoreboard().resetScores(_lastPlayerCount + ""); + obj.getScore(playerCount + "").setScore(line--); + + //Space + obj.getScore(" ").setScore(line--); + + //Display Rank + obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); + //Remove Old + player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(false).Name); + player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(true).Name); + player.getScoreboard().resetScores("No Rank"); + //Add New + if (GetClients().Get(player).GetRank() != Rank.ALL) + obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--); + else + obj.getScore("No Rank").setScore(line--); + + //Space + obj.getScore(" ").setScore(line--); + + //Website + obj.getScore(C.cRed + C.Bold + "Website").setScore(line--); + obj.getScore("www.mineplex.com").setScore(line--); + } + + _lastPlayerCount = playerCount; + Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).GetRank() == Rank.ALL).forEach(player -> + { + UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); + }); + } + + /** + * Gets the loaded BlockRestore manager + * @return The loaded BlockRestore manager + */ + public BlockRestore GetBlockRestore() + { + return _blockRestore; + } + + /** + * Gets the loaded CoreClient manager + * @return The loaded CoreClient manager + */ + public CoreClientManager GetClients() + { + return _clientManager; + } + + /** + * Gets the loaded Condition manager + * @return The loaded Condition manager + */ + public ConditionManager GetCondition() + { + return _conditionManager; + } + + /** + * Gets the loaded Donation manager + * @return The loaded Donation manager + */ + public DonationManager GetDonation() + { + return _donationManager; + } + + /** + * Gets the loaded Disguise manager + * @return The loaded Disguise manager + */ + public DisguiseManager GetDisguise() + { + return _disguiseManager; + } + + /** + * Gets the loaded Gadget manager + * @return The loaded Gadget manager + */ + public GadgetManager GetGadget() + { + return _gadgetManager; + } + + /** + * Gets the loaded Treasure manager + * @return The loaded Treasure manager + */ + public TreasureManager GetTreasure() + { + return _treasureManager; + } + + /** + * Gets the loaded Mount manager + * @return The loaded Mount manager + */ + public MountManager GetMount() + { + return _mountManager; + } + + /** + * Gets the loaded Preferences manager + * @return The loaded Preferences manager + */ + public PreferencesManager getPreferences() + { + return _preferences; + } + + /** + * Gets the lobby's spawn + * @return The lobby's spawn + */ + public Location GetSpawn() + { + return _spawn.clone(); + } + + /** + * Gets the loaded Pet manager + * @return The loaded Pet manager + */ + public PetManager getPetManager() + { + return _petManager; + } + + /** + * Gets the loaded Bonus manager + * @return The loaded Bonus manager + */ + public BonusManager getBonusManager() + { + return _bonusManager; + } + + /** + * Gets the loaded Stats manager + * @return The loaded Stats manager + */ + public StatsManager GetStats() + { + return _statsManager; + } + + /** + * Gets the loaded HubVisibility manager + * @return The loaded HubVisibility manager + */ + public HubVisibilityManager GetVisibility() + { + return _visibilityManager; + } + + /** + * Gets the loaded CustomData manager + * @return The loaded CustomData manager + */ + public CustomDataManager getCustomDataManager() + { + return _customDataManager; + } + + /** + * Gets the loaded Punishment manager + * @return The loaded Punishment manager + */ + public Punish getPunishments() + { + return _punishManager; + } + + /** + * Gets the loaded Incognito manager + * @return The loaded Incognito manager + */ + public IncognitoManager getIncognitoManager() + { + return _incognito; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void gadgetCollide(GadgetCollideEntityEvent event) + { + if (!event.isCancelled()) + { + SetPortalDelay(event.getOther()); + } + } + + /** + * Updates a player's portal delay start to be now + * @param ent The player to set delay for + */ + public void SetPortalDelay(Entity ent) + { + if (ent instanceof Player) + { + _portalTime.put(((Player)ent).getName(), System.currentTimeMillis()); + } + } + + /** + * Checks if a player can portal yet + * @param player The player to check + * @return Whether a player can portal yet + */ + public boolean CanPortal(Player player) + { + //Riding + if (player.getVehicle() != null || player.getPassenger() != null) + return false; + + //Portal Delay + if (!_portalTime.containsKey(player.getName())) + return true; + + return UtilTime.elapsed(_portalTime.get(player.getName()), 5000); + } + + @EventHandler + public void ignoreVelocity(PlayerVelocityEvent event) + { + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) + { + event.setCancelled(true); + } + } + + /** + * Toggles all gadgets on or off via command + * @param caller The player who issued the command + */ + public void ToggleGadget(Player caller) + { + toggleGadget(); + } + + /** + * Toggles gadget access on or off in this lobby + */ + public void toggleGadget() + { + GetGadget().toggleGadgetEnabled(); + + for (Player player : UtilServer.getPlayers()) + player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); + } + + /** + * Sets a player's gamemode via command + * @param caller The issuer of the command + * @param target The player whose gamemode should be set + */ + public void addGameMode(Player caller, Player target) + { + if (!_creativeAdmin.containsKey(caller.getName())) + _creativeAdmin.put(caller.getName(), new ArrayList()); + + if (target.getGameMode() == GameMode.CREATIVE) + { + _creativeAdmin.get(caller.getName()).add(target.getName()); + } + else + { + _creativeAdmin.get(caller.getName()).remove(target.getName()); + } + } + + @EventHandler + public void clearEntityTargets(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Entity entity : Bukkit.getWorlds().get(0).getEntities()) + { + if (entity instanceof EntityInsentient) + { + EntityInsentient entityMonster = (EntityInsentient)entity; + + if (entityMonster.getGoalTarget() != null && entityMonster.getGoalTarget() instanceof EntityPlayer) + { + if (((EntityPlayer)entityMonster.getGoalTarget()).playerConnection.isDisconnected()) + entityMonster.setGoalTarget(null, TargetReason.FORGOT_TARGET, false); + } + } + } + } + + @EventHandler + public void clearGameMode(PlayerQuitEvent event) + { + ArrayList creative = _creativeAdmin.remove(event.getPlayer().getName()); + + if (creative == null) + return; + + for (String name : creative) + { + Player player = UtilPlayer.searchExact(name); + if (player == null) + continue; + + player.setGameMode(GameMode.SURVIVAL); + + UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); + } + } + + /** + * Gets the loaded PacketHandler + * @return The loaded PacketHandler + */ + public PacketHandler getPacketHandler() + { + return _packetHandler; + } + + @EventHandler + public void openProfile(PlayerInteractEvent event) + { + if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) + return; + + new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager).openInventory();; + } + + @EventHandler + public void trackPortalDelayPlayers(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Iterator playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext();) + { + String playerName = playerNameIterator.next(); + + if (UtilTime.elapsed(_portalTime.get(playerName), 5000)) + { + playerNameIterator.remove(); + } + } + } + + @EventHandler + public void showHeader(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + String text = C.cRed + "Welcome to Mineplex Clans"; + UtilTextTop.display(text, UtilServer.getPlayers()); + + //Fix Entity Names + for (Creature pet : _petManager.getPets()) + { + DisguiseBase disguise = _disguiseManager.getDisguise(pet); + + if (disguise instanceof DisguiseWither) + { + ((DisguiseWither) disguise).setName(text); + disguise.resendMetadata(); + } + } + + for (Mount mount : _mountManager.getMounts()) + { + if (mount instanceof MountDragon) + { + ((MountDragon)mount).SetName(text); + } + } + + for (Gadget gadget : _gadgetManager.getGadgets(GadgetType.MORPH)) + { + if (gadget instanceof MorphWither) + { + ((MorphWither)gadget).setWitherData(text, 100); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java new file mode 100644 index 000000000..51ad84a0f --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -0,0 +1,91 @@ +package mineplex.clanshub; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.preferences.Preference; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; + +/** + * Manager for Hub Visibility of players + */ +public class HubVisibilityManager extends MiniPlugin +{ + public HubManager Manager; + + private HashSet _hiddenPlayers = new HashSet(); + + public HubVisibilityManager(HubManager manager) + { + super("Visibility Manager", manager.getPlugin()); + + Manager = manager; + } + + /** + * Force sets a player as hidden + * @param player The player to set + */ + public void addHiddenPlayer(Player player) + { + _hiddenPlayers.add(player); + + } + + /** + * Force unsets a player as hidden + * @param player The player to unset + */ + public void removeHiddenPlayer(Player player) + { + _hiddenPlayers.remove(player); + } + + @EventHandler + public void removeHiddenPlayerOnQuit(PlayerQuitEvent event) + { + _hiddenPlayers.remove(event.getPlayer()); + } + + @EventHandler + public void updateVisibility(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + Rank rank = Manager.GetClients().Get(player).GetRank(); + boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || + (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || + _hiddenPlayers.contains(player); + + for (Player other : UtilServer.getPlayers()) + { + boolean localHideMe = hideMe; + if (player.equals(other)) + continue; + + if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) + localHideMe = false; + + if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) + { + VisibilityManager.Instance.setVisibility(player, false, other); + } + else + { + VisibilityManager.Instance.setVisibility(player, true, other); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java new file mode 100644 index 000000000..658accdf4 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java @@ -0,0 +1,58 @@ +package mineplex.clanshub; + +import mineplex.core.common.Rank; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * GUI button to select a server from a display + */ +public class JoinServerButton implements IButton +{ + private ShopPageBase _page; + private ClansTransferManager _transferManager; + private ServerInfo _serverInfo; + + public JoinServerButton(ShopPageBase page, ClansTransferManager transferManager, ServerInfo serverInfo) + { + _page = page; + _transferManager = transferManager; + _serverInfo = serverInfo; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + selectServer(player, _serverInfo); + } + + /** + * Selects a server to send a player to + * @param player The player to send + * @param serverInfo The server to send the player to + */ + public void selectServer(Player player, ServerInfo serverInfo) + { + if (serverInfo != null) + { + System.out.println("Selecting server :" + serverInfo.Name); + int slots = 1; + + if (serverInfo.getAvailableSlots() < slots && !_page.getClient().GetRank().has(Rank.ULTRA)) + { + _page.playDenySound(player); + } + else + { + _transferManager.selectServer(player, serverInfo); + } + } + else + { + _page.playDenySound(player); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java new file mode 100644 index 000000000..1bb5643db --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java @@ -0,0 +1,20 @@ +package mineplex.clanshub; + +/** + * Data class for loaded servers + */ +public class ServerInfo +{ + public String Name; + public int CurrentPlayers = 0; + public int MaxPlayers = 0; + + /** + * Checks how many slots are left on this server + * @return The amount of slots that are left on this server + */ + public int getAvailableSlots() + { + return MaxPlayers - CurrentPlayers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java new file mode 100644 index 000000000..577bbb7e1 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java @@ -0,0 +1,211 @@ +package mineplex.clanshub; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Boat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.weather.WeatherChangeEvent; + +/** + * Manager for the hub world + */ +public class WorldManager extends MiniPlugin +{ + public HubManager Manager; + + public WorldManager(HubManager manager) + { + super("World Manager", manager.getPlugin()); + + Manager = manager; + + World world = UtilWorld.getWorld("world"); + + world.setGameRuleValue("doDaylightCycle", "false"); + + world.setTime(6000); + world.setStorm(false); + world.setThundering(false); + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onBlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBlockIgnite(BlockIgniteEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) + { + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onExplosion(EntityExplodeEvent event) + { + event.blockList().clear(); + } + + @EventHandler + public void onVineGrow(BlockSpreadEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onLeafDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onBorderUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 50) + { + player.eject(); + player.leaveVehicle(); + player.teleport(Manager.GetSpawn()); + } + } + } + + @EventHandler(priority = EventPriority.LOW) + public void onItemPickup(PlayerPickupItemEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOW) + public void onItemDrop(PlayerDropItemEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOW) + public void onItemDespawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Entity ent : UtilWorld.getWorld("world").getEntities()) + { + if (!(ent instanceof Item)) + continue; + + if (((Item)ent).getItemStack().getType() == Material.MONSTER_EGG) + continue; + + if (UtilEnt.GetMetadata(ent, "UtilItemSpawning") != null) + continue; + + if (ent.getTicksLived() > 1200) + ent.remove(); + } + } + + @EventHandler + public void onWeather(WeatherChangeEvent event) + { + if (!event.getWorld().getName().equals("world")) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onBlockForm(BlockFormEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBoatBreak(CustomDamageEvent event) + { + if (event.GetDamageeEntity() instanceof Boat) + { + event.SetCancelled("Boat Cancel"); + } + } + + @EventHandler + public void prevenCombustiont(EntityCombustEvent event) + { + if (event.getEntity() instanceof Player) + { + event.setCancelled(true); + } + } + + @EventHandler + public void preventMobs(CreatureSpawnEvent event) + { + if (event.getSpawnReason() == SpawnReason.NATURAL || event.getSpawnReason() == SpawnReason.NETHER_PORTAL) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java new file mode 100644 index 000000000..113cfacf3 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java @@ -0,0 +1,24 @@ +package mineplex.clanshub.commands; + +import mineplex.clanshub.ForcefieldManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +import org.bukkit.entity.Player; + +/** + * Command for controlling forcefield radius + */ +public class ForcefieldRadius extends CommandBase +{ + public ForcefieldRadius(ForcefieldManager plugin) + { + super(plugin, Rank.ADMIN, "radius", "forcefield"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.ForcefieldRadius(caller, args); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java new file mode 100644 index 000000000..c30b61fae --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java @@ -0,0 +1,24 @@ +package mineplex.clanshub.commands; + +import mineplex.clanshub.HubManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +import org.bukkit.entity.Player; + +/** + * Command for toggling gadgets + */ +public class GadgetToggle extends CommandBase +{ + public GadgetToggle(HubManager plugin) + { + super(plugin, Rank.ADMIN, "gadget"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.ToggleGadget(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java new file mode 100644 index 000000000..f79e55f38 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java @@ -0,0 +1,52 @@ +package mineplex.clanshub.commands; + +import mineplex.clanshub.HubManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; + +/** + * Command for setting gamemode + */ +public class GameModeCommand extends CommandBase +{ + public GameModeCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "gamemode", "gm"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Player target = caller; + + if (args != null && args.length >= 1) + { + target = UtilPlayer.searchOnline(caller, args[0], true); + + if (target == null) + return; + } + + if (target.getGameMode() == GameMode.SURVIVAL) + { + target.setGameMode(GameMode.CREATIVE); + } + else + { + target.setGameMode(GameMode.SURVIVAL); + } + + if (!target.equals(caller)) + { + Plugin.addGameMode(caller, target); + UtilPlayer.message(target, F.main("Game Mode", caller.getName() + " toggled your Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); + } + + UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java new file mode 100644 index 000000000..54b195ef2 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java @@ -0,0 +1,58 @@ +package mineplex.clanshub.profile.buttons; + +import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemBuilder; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * Button to open preferences menu + */ +public class ButtonPrefs implements GuiItem +{ + private GUIProfile _profile; + private Player _player; + + public ButtonPrefs(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getPrefManager().openMenu(_player); + } + + @Override + public ItemStack getObject() + { + return new ItemBuilder(Material.REDSTONE_COMPARATOR).setTitle(C.Reset + C.cYellow + "Preferences").addLore(new String[] + { + "", + C.cWhite + "Set your preferences to your liking", + C.cWhite + "so you can enjoy the game more!", + + "", + C.cWhite + "Type " + C.cGreen + "/prefs" + C.cWhite + " to access this anywhere!" + }).build(); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java new file mode 100644 index 000000000..4b3833618 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java @@ -0,0 +1,66 @@ +package mineplex.clanshub.profile.buttons; + +import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +/** + * Button to open stats menu + */ +public class ButtonStats implements GuiItem +{ + private GUIProfile _profile; + private Player _player; + + public ButtonStats(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getAchievementManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, + ChatColor.RESET + C.cYellow + "Stats and Achievements", + new String[] + { + "", + C.cWhite + "View your Statistics and Achievements", + C.cWhite + "for all of the games on Mineplex!", + + "", + C.cWhite + "Type " + C.cGreen + "/stats" + C.cWhite + " to access this anywhere!" + }); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(_player.getName()); + item.setItemMeta(meta); + return item; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java new file mode 100644 index 000000000..e14ab7fc4 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java @@ -0,0 +1,39 @@ +package mineplex.clanshub.profile.gui; + +import mineplex.clanshub.profile.buttons.ButtonPrefs; +import mineplex.clanshub.profile.buttons.ButtonStats; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.gui.SimpleGui; +import mineplex.core.preferences.PreferencesManager; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +/** + * Profile GUI + */ +public class GUIProfile extends SimpleGui +{ + private PreferencesManager _preferencesManager; + private AchievementManager _achievementManager; + + public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager) + { + super(plugin, player, "My Profile", 9*3); + _preferencesManager = preferencesManager; + _achievementManager = achievementManager; + + setItem(12, new ButtonStats(this, player)); + setItem(14, new ButtonPrefs(this, player)); + } + + public PreferencesManager getPrefManager() + { + return _preferencesManager; + } + + public AchievementManager getAchievementManager() + { + return _achievementManager; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/plugin.yml b/Plugins/Mineplex.Hub/plugin.yml index 9f010adb1..dbe6db4f4 100644 --- a/Plugins/Mineplex.Hub/plugin.yml +++ b/Plugins/Mineplex.Hub/plugin.yml @@ -1,3 +1,4 @@ name: Hub main: mineplex.hub.Hub -version: 0.1 \ No newline at end of file +version: 0.1 +loadbefore: [MineplexAnticheat] \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 73b853af5..3f9bcf022 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,14 +1,11 @@ package mineplex.hub; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.CustomTagFix; import mineplex.core.PacketsInteractionFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; @@ -53,6 +50,7 @@ import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.titangiveaway.TitanGiveawayManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; @@ -72,11 +70,19 @@ import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import static mineplex.core.Managers.require; public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; + private NpcManager _npcManager; + @Override public void onEnable() { @@ -93,7 +99,7 @@ public class Hub extends JavaPlugin implements IRelation new VelocityFix(this); //Static Modules - new ProfileCacheManager(this); + require(ProfileCacheManager.class); CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); @@ -109,20 +115,23 @@ public class Hub extends JavaPlugin implements IRelation ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager); //Other Modules - PacketHandler packetHandler = new PacketHandler(this); - DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + PacketHandler packetHandler = require(PacketHandler.class); + DisguiseManager disguiseManager = require(DisguiseManager.class); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager); incognito.setPreferencesManager(preferenceManager); preferenceManager.GiveItem = true; Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); + _npcManager = npcManager; InventoryManager inventoryManager = new InventoryManager(this, clientManager); PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); PollManager pollManager = new PollManager(this, clientManager, donationManager); //new TournamentManager(this, clientManager, donationManager); + + ProjectileManager throwManager = new ProjectileManager(this); //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); @@ -130,7 +139,12 @@ public class Hub extends JavaPlugin implements IRelation Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); - AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + AntiHack antiHack = require(AntiHack.class); + + for (int i = 0; i < 8; i++) + { + antiHack.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 100, 0), 50, -50, 105, 95, 50, -50)); + } IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); @@ -148,11 +162,12 @@ public class Hub extends JavaPlugin implements IRelation PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); String boosterGroup = serverConfiguration.getServerGroup().getBoosterGroup(); - BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager); + ThankManager thankManager = new ThankManager(this, clientManager, donationManager); + BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager, thankManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); HologramManager hologramManager = new HologramManager(this, packetHandler); - QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); + QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager); ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager, boosterManager); new FountainManager(this, clientManager, donationManager, hologramManager, statsManager, serverManager); @@ -170,7 +185,6 @@ public class Hub extends JavaPlugin implements IRelation CombatManager combatManager = new CombatManager(this); - ProjectileManager throwManager = new ProjectileManager(this); DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); @@ -223,4 +237,9 @@ public class Hub extends JavaPlugin implements IRelation { return true; } + + public NpcManager getNpcManager() + { + return _npcManager; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java index 4b56eff02..247ba32a9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java @@ -1,134 +1,128 @@ package mineplex.hub; public class HubClient -{ +{ public String ScoreboardString = " Hello, I am a big friendly cat!"; public int ScoreboardIndex = 0; - + public String NewsString = " Bridges v2.0 is coming soon! New gameplay, new kits, new maps!"; public int NewsIndex = 0; - + public String PurchaseString = " Purchase Ultra Rank at mineplex.com to unlock all game benefits!"; public int PurchaseIndex = 0; - + public String UltraString = " Thank you for your support!"; public int UltraIndex = 0; - + public String StaffString = "None"; public int StaffIndex = 0; - + public String BestPig = "0-Nobody"; - + public int DisplayLength = 16; - - private int _lastGemCount = 0; - + public HubClient(String name) { - ScoreboardString = " Welcome " + name + ", to the Mineplex Network!"; + setName(name); } - public void SetLastGemCount(int gems) + public void setName(String name) { - _lastGemCount = gems; + ScoreboardString = " Welcome " + name + ", to the Mineplex Network!"; + ScoreboardIndex = 0; } - - public int GetLastGemCount() - { - return _lastGemCount; - } - - public String GetScoreboardText() + + public String GetScoreboardText() { if (ScoreboardString.length() <= DisplayLength) return ScoreboardString; - - String display = ScoreboardString.substring(ScoreboardIndex, Math.min(ScoreboardIndex+DisplayLength, ScoreboardString.length())); - + + String display = ScoreboardString.substring(ScoreboardIndex, Math.min(ScoreboardIndex + DisplayLength, ScoreboardString.length())); + if (display.length() < DisplayLength && ScoreboardString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += ScoreboardString.substring(0, add); } - + ScoreboardIndex = (ScoreboardIndex + 1) % ScoreboardString.length(); - + return display; } - - public String GetPurchaseText(boolean increment) + + public String GetPurchaseText(boolean increment) { if (PurchaseString.length() <= DisplayLength) return PurchaseString; - + if (increment) PurchaseIndex = (PurchaseIndex + 1) % PurchaseString.length(); - - String display = PurchaseString.substring(PurchaseIndex, Math.min(PurchaseIndex+DisplayLength, PurchaseString.length())); - + + String display = PurchaseString.substring(PurchaseIndex, Math.min(PurchaseIndex + DisplayLength, PurchaseString.length())); + if (display.length() < DisplayLength && PurchaseString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += PurchaseString.substring(0, add); } - + return display; } - public String GetUltraText(boolean increment) + public String GetUltraText(boolean increment) { if (UltraString.length() <= DisplayLength) return UltraString; - + if (increment) UltraIndex = (UltraIndex + 1) % UltraString.length(); - - String display = UltraString.substring(UltraIndex, Math.min(UltraIndex+DisplayLength, UltraString.length())); - + + String display = UltraString.substring(UltraIndex, Math.min(UltraIndex + DisplayLength, UltraString.length())); + if (display.length() < DisplayLength) { int add = DisplayLength - display.length(); display += UltraString.substring(0, add); } - + return display; } - - public String GetStaffText(boolean increment) + + public String GetStaffText(boolean increment) { if (StaffString.length() <= DisplayLength) return StaffString; - + if (increment) StaffIndex = (StaffIndex + 1) % StaffString.length(); - - String display = StaffString.substring(StaffIndex, Math.min(StaffIndex+DisplayLength, StaffString.length())); - + + String display = StaffString.substring(StaffIndex, Math.min(StaffIndex + DisplayLength, StaffString.length())); + if (display.length() < DisplayLength && StaffString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += StaffString.substring(0, add); } - + return display; } - - public String GetNewsText(boolean increment) + + public String GetNewsText(boolean increment) { if (NewsString.length() <= DisplayLength) return NewsString; - + if (increment) NewsIndex = (NewsIndex + 1) % NewsString.length(); - - String display = NewsString.substring(NewsIndex, Math.min(NewsIndex+DisplayLength, NewsString.length())); - + + String display = NewsString.substring(NewsIndex, Math.min(NewsIndex + DisplayLength, NewsString.length())); + if (display.length() < DisplayLength && NewsString.length() > DisplayLength) { int add = DisplayLength - display.length(); display += NewsString.substring(0, add); } - + return display; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 4b435a657..3771a4e1c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -8,100 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Random; - -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementManager; -import mineplex.core.aprilfools.AprilFoolsManager; -import mineplex.core.benefit.BenefitManager; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.boosters.BoosterManager; -import mineplex.core.botspam.BotSpamManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.customdata.CustomDataManager; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.PlayerDisguiseManager; -import mineplex.core.disguise.disguises.DisguiseSlime; -import mineplex.core.donation.DonationManager; -import mineplex.core.facebook.FacebookManager; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetCollideEntityEvent; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.hologram.HologramManager; -import mineplex.core.incognito.IncognitoManager; -import mineplex.core.incognito.events.IncognitoHidePlayerEvent; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.message.PrivateMessageEvent; -import mineplex.core.mount.MountManager; -import mineplex.core.noteblock.INoteVerifier; -import mineplex.core.noteblock.NBSReader; -import mineplex.core.noteblock.NotePlayer; -import mineplex.core.noteblock.NoteSong; -import mineplex.core.noteblock.event.SongFinishEvent; -import mineplex.core.notifier.NotificationManager; -import mineplex.core.npc.NpcManager; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.party.Party; -import mineplex.core.party.PartyManager; -import mineplex.core.personalServer.PersonalServerManager; -import mineplex.core.pet.PetManager; -import mineplex.core.playerCount.PlayerCountManager; -import mineplex.core.poll.PollManager; -import mineplex.core.portal.Portal; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.projectile.ProjectileManager; -import mineplex.core.punish.Punish; -import mineplex.core.stats.StatsManager; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.task.TaskManager; -import mineplex.core.treasure.TreasureManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.valentines.ValentinesGiftManager; -import mineplex.core.youtube.YoutubeManager; -import mineplex.hub.commands.DisguiseCommand; -import mineplex.hub.commands.ForcefieldRadius; -import mineplex.hub.commands.GadgetToggle; -import mineplex.hub.commands.GameModeCommand; -import mineplex.hub.commands.NewsCommand; -import mineplex.hub.modules.ForcefieldManager; -import mineplex.hub.modules.HubVisibilityManager; -import mineplex.hub.modules.JumpManager; -import mineplex.hub.modules.KothManager; -import mineplex.hub.modules.MavericksManager; -import mineplex.hub.modules.NewsManager; -import mineplex.hub.modules.ParkourManager; -import mineplex.hub.modules.SoccerManager; -import mineplex.hub.modules.TextManager; -import mineplex.hub.modules.ValentinesManager; -import mineplex.hub.modules.WorldManager; -import mineplex.hub.modules.nonpremium.NonPremiumManager; -import mineplex.hub.profile.gui.GUIProfile; -import mineplex.hub.tutorial.TutorialManager; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; -import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.condition.ConditionManager; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.HoverEvent.Action; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityInsentient; -import net.minecraft.server.v1_8_R3.EntityPlayer; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -132,9 +39,105 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; + +import mineplex.core.Managers; +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.antispam.AntiSpamManager; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.benefit.BenefitManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; +import mineplex.core.facebook.FacebookManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.hologram.HologramManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; +import mineplex.core.interactions.NewInteractionsManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.menu.MenuManager; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.mount.MountManager; +import mineplex.core.noteblock.INoteVerifier; +import mineplex.core.noteblock.NBSReader; +import mineplex.core.noteblock.NotePlayer; +import mineplex.core.noteblock.NoteSong; +import mineplex.core.noteblock.event.SongFinishEvent; +import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.personalServer.PersonalServerManager; +import mineplex.core.pet.PetManager; +import mineplex.core.playerCount.PlayerCountManager; +import mineplex.core.poll.PollManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; +import mineplex.core.scoreboard.MineplexScoreboard; +import mineplex.core.scoreboard.ScoreboardManager; +import mineplex.core.stats.StatsManager; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.task.TaskManager; +import mineplex.core.thank.ThankManager; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.valentines.ValentinesGiftManager; +import mineplex.core.youtube.YoutubeManager; +import mineplex.hub.commands.ForcefieldRadius; +import mineplex.hub.commands.GadgetToggle; +import mineplex.hub.commands.GameModeCommand; +import mineplex.hub.commands.NewsCommand; +import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HubVisibilityManager; +import mineplex.hub.modules.JumpManager; +import mineplex.hub.modules.KothManager; +import mineplex.hub.modules.MavericksManager; +import mineplex.hub.modules.NewsManager; +import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.SoccerManager; +import mineplex.hub.modules.ValentinesManager; +import mineplex.hub.modules.WorldManager; +import mineplex.hub.modules.nonpremium.NonPremiumManager; +import mineplex.hub.profile.gui.GUIProfile; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; public class HubManager extends MiniClientPlugin { @@ -154,8 +157,6 @@ public class HubManager extends MiniClientPlugin private GadgetManager _gadgetManager; private MountManager _mountManager; private HubVisibilityManager _visibilityManager; - private TutorialManager _tutorialManager; - private TextManager _textCreator; private ParkourManager _parkour; private PreferencesManager _preferences; private InventoryManager _inventoryManager; @@ -177,12 +178,8 @@ public class HubManager extends MiniClientPlugin private MavericksManager _mavericksManager; private Location _spawn; - private int _scoreboardTick = 0; - private HashMap _scoreboards = new HashMap(); - - private String _serverName = ""; - private int _lastPlayerCount = 0; + private final String _serverName; private boolean _shuttingDown; private HashMap _portalTime = new HashMap(); @@ -192,15 +189,18 @@ public class HubManager extends MiniClientPlugin // Christmas Songs private Random _random = new Random(); private int _lastSong = 0; -// private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; + // private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; private final ArrayList _songs; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, BoosterManager boosterManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) { super("Hub Manager", plugin); + String serverName = getPlugin().getConfig().getString("serverstatus.name"); + _serverName = serverName.substring(0, Math.min(16, serverName.length())); + _incognito = incognito; - + _blockRestore = blockRestore; _clientManager = clientManager; _conditionManager = conditionManager; @@ -211,43 +211,45 @@ public class HubManager extends MiniClientPlugin _portal = portal; - _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 79, -23.5); // Disable item merging ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; - _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); new WorldManager(this); _jumpManager = new JumpManager(this); //new TournamentInviter(this); - _news = new NewsManager(this); _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); - _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, Managers.get(ProjectileManager.class), achievementManager, packetHandler, hologramManager); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, boosterManager); - - _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - CosmeticManager cosmetics = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); - - _mavericksManager = new MavericksManager(plugin, cosmetics, hologramManager, this); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); + + _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); + CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + + _mavericksManager = new MavericksManager(plugin, cosmeticManager, hologramManager, this); + new SoccerManager(this, _gadgetManager); new KothManager(this, _gadgetManager); + new AntiSpamManager(); + new MenuManager(_plugin); + new NewInteractionsManager(); + //new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager); _petManager = petManager; _partyManager = partyManager; _preferences = preferences; - _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _visibilityManager = new HubVisibilityManager(this); _forcefieldManager = new ForcefieldManager(this); @@ -261,24 +263,24 @@ public class HubManager extends MiniClientPlugin new NotificationManager(getPlugin(), clientManager, _preferences); new BotSpamManager(plugin, clientManager, punish); - ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; // _halloweenManager = new HalloweenSpookinessManager(this); // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); - new PlayerDisguiseManager(plugin, _clientManager); + require(PlayerDisguiseManager.class); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); _playerCountManager = new PlayerCountManager(plugin); - _customDataManager = new CustomDataManager(plugin, clientManager); - + _customDataManager = Managers.get(CustomDataManager.class); + _songs = new ArrayList(); - + _punishManager = punish; - + _valentinesManager = new ValentinesManager(plugin, clientManager, donationManager); new NonPremiumManager(plugin, clientManager); @@ -313,8 +315,121 @@ public class HubManager extends MiniClientPlugin playNextSong(); - _serverName = getPlugin().getConfig().getString("serverstatus.name"); - _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); + ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) + { + @Override + public void setup(MineplexScoreboard scoreboard) + { + for (Rank rank : Rank.values()) + { + if (rank == Rank.ALL) + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(""); + else + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + } + + scoreboard.register(HubScoreboardLine.SERVER_TITLE) + .register(HubScoreboardLine.SERVER_NAME) + .register(HubScoreboardLine.SERVER_EMPTY_SPACER) + .register(HubScoreboardLine.GEM_TITLE) + .register(HubScoreboardLine.GEM_COUNT) + .register(HubScoreboardLine.GEM_EMPTY_SPACER) + .register(HubScoreboardLine.SHARDS_TITLE) + .register(HubScoreboardLine.SHARDS_COUNT) + .register(HubScoreboardLine.PLAYER_EMPTY_SPACER) + .register(HubScoreboardLine.RANK_TITLE) + .register(HubScoreboardLine.RANK_NAME) + .register(HubScoreboardLine.RANK_EMPTY_SPACER) + .register(HubScoreboardLine.WEBSITE_TITLE) + .register(HubScoreboardLine.WEBSITE_VALUE) + .register(HubScoreboardLine.END_BREAKER) + .recalculate(); + + scoreboard.get(HubScoreboardLine.SERVER_TITLE).write(C.cAqua + C.Bold + "Server"); + scoreboard.get(HubScoreboardLine.SERVER_NAME).write(_serverName); + scoreboard.get(HubScoreboardLine.GEM_TITLE).write(C.cGreen + C.Bold + "Gems"); + scoreboard.get(HubScoreboardLine.SHARDS_TITLE).write(C.cYellow + C.Bold + "Shards"); + scoreboard.get(HubScoreboardLine.RANK_TITLE).write(C.cGold + C.Bold + "Rank"); + scoreboard.get(HubScoreboardLine.WEBSITE_TITLE).write(C.cRed + C.Bold + "Website"); + scoreboard.get(HubScoreboardLine.WEBSITE_VALUE).write("www.mineplex.com"); + scoreboard.get(HubScoreboardLine.END_BREAKER).write("----------------"); + } + + @Override + public void draw(MineplexScoreboard scoreboard) + { + scoreboard.setSidebarName(C.cWhite + C.Bold + Get(scoreboard.getOwner()).GetScoreboardText()); + scoreboard.get(HubScoreboardLine.GEM_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + scoreboard.get(HubScoreboardLine.SHARDS_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.TREASURE_SHARD)); + + String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).GetRank(), GetDonation().Get(scoreboard.getOwner())); + + Rank disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedRank(); + String disguisedAs = GetClients().Get(scoreboard.getOwner()).getDisguisedAs(); + if (disguisedRank != null && disguisedAs != null) + { + rankName = getRankName(disguisedRank, GetDonation().Get(GetClients().Get(scoreboard.getOwner()).getDisguisedAsUUID())) + " (" + rankName + ")"; + } + + scoreboard.get(HubScoreboardLine.RANK_NAME).write(rankName); + } + + @Override + public void handlePlayerJoin(String playerName) + { + Player player = Bukkit.getPlayerExact(playerName); + + HubClient hubclient = HubManager.this.Get(player); + hubclient.setName(playerName); + + CoreClient client = GetClients().Get(player.getUniqueId()); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(playerName); + } + + if (get(player) != null) + { + for (Player player1 : Bukkit.getOnlinePlayers()) + { + client = GetClients().Get(player1); + get(player).getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(player1.getName()); + } + } + } + + @Override + public void handlePlayerQuit(String playerName) + { + Player player = Bukkit.getPlayerExact(playerName); + + CoreClient client = GetClients().Get(player); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).removeEntry(playerName); + } + } + + private String getRankName(Rank rank, Donor donor) + { + String rankName; + if (rank.has(Rank.ULTRA)) + rankName = rank.Name; + else if (donor.OwnsUnknownPackage("SuperSmashMobs ULTRA") || + donor.OwnsUnknownPackage("Survival Games ULTRA") || + donor.OwnsUnknownPackage("Minigames ULTRA") || + donor.OwnsUnknownPackage("CastleSiege ULTRA") || + donor.OwnsUnknownPackage("Champions ULTRA")) + rankName = "Single Ultra"; + else + rankName = "No Rank"; + return rankName; + } + }; + + Managers.put(scoreboardManager, ScoreboardManager.class); } private void playNextSong() @@ -331,7 +446,7 @@ public class HubManager extends MiniClientPlugin { for (Player player : UtilServer.getPlayers()) { - if (_preferences.Get(player).HubMusic) + if (_preferences.get(player).isActive(Preference.HUB_MUSIC)) { UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player); } @@ -342,7 +457,7 @@ public class HubManager extends MiniClientPlugin @Override public boolean shouldPlay(Player player) { - return _preferences.Get(player).HubMusic; + return _preferences.get(player).isActive(Preference.HUB_MUSIC); } }, 0.5F, false); } @@ -354,7 +469,6 @@ public class HubManager extends MiniClientPlugin addCommand(new GadgetToggle(this)); addCommand(new NewsCommand(this)); addCommand(new GameModeCommand(this)); - addCommand(new DisguiseCommand(this)); } @EventHandler(priority = EventPriority.HIGHEST) @@ -373,7 +487,7 @@ public class HubManager extends MiniClientPlugin if (ent instanceof Player) { - return !_preferences.Get((Player)ent).HubGames; + return !_preferences.get((Player) ent).isActive(Preference.HUB_GAMES); } return true; @@ -422,13 +536,13 @@ public class HubManager extends MiniClientPlugin { if (entity instanceof LivingEntity) { - if (((LivingEntity)entity).isCustomNameVisible() && ((LivingEntity)entity).getCustomName() != null) + if (((LivingEntity) entity).isCustomNameVisible() && ((LivingEntity) entity).getCustomName() != null) { - if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Block Hunt")) + if (ChatColor.stripColor(((LivingEntity) entity).getCustomName()).equalsIgnoreCase("Block Hunt")) { DisguiseSlime disguise = new DisguiseSlime(entity); disguise.setCustomNameVisible(true); - disguise.setName(((LivingEntity)entity).getCustomName(), null); + disguise.setName(((LivingEntity) entity).getCustomName(), null); disguise.SetSize(2); _disguiseManager.disguise(disguise); } @@ -440,9 +554,9 @@ public class HubManager extends MiniClientPlugin @EventHandler(priority = EventPriority.LOW) public void login(final PlayerLoginEvent event) { - CoreClient client = _clientManager.Get(event.getPlayer().getName()); + CoreClient client = _clientManager.Get(event.getPlayer().getUniqueId()); - // Reserved Slot Check + // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { if (!client.GetRank().has(Rank.ULTRA)) @@ -467,13 +581,13 @@ public class HubManager extends MiniClientPlugin { // Give developers operator on their servers boolean testServer = _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); - + Rank minimum = Rank.OWNER; if (testServer) { minimum = Rank.JNR_DEV; } - + if (_clientManager.Get(event.getPlayer()).GetRank().has(minimum)) event.getPlayer().setOp(true); else @@ -521,37 +635,8 @@ public class HubManager extends MiniClientPlugin //Health player.setHealth(20); - //Scoreboard - Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); - player.setScoreboard(board); - _scoreboards.put(player, board); - - //Objective - Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy"); - obj.setDisplaySlot(DisplaySlot.SIDEBAR); - - for (Rank rank : Rank.values()) - { - if (rank != Rank.ALL) - board.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); - else - board.registerNewTeam(rank.Name).setPrefix(""); - } - - for (Player otherPlayer : Bukkit.getOnlinePlayers()) - { - if (_clientManager.Get(otherPlayer) == null) - continue; - - String rankName = _clientManager.Get(player).GetRank().Name; - String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name; - - //Add Other to Self - board.getTeam(otherRankName).addPlayer(otherPlayer); - - //Add Self to Other - otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player); - } + //only give it in the hub + player.getInventory().setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM); } @EventHandler @@ -562,11 +647,6 @@ public class HubManager extends MiniClientPlugin event.getPlayer().leaveVehicle(); event.getPlayer().eject(); - for (Player player : UtilServer.getPlayers()) - player.getScoreboard().resetScores(event.getPlayer().getName()); - - _scoreboards.remove(event.getPlayer()); - _portalTime.remove(event.getPlayer().getName()); } @@ -580,7 +660,7 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } } - + @EventHandler public void Incog(IncognitoHidePlayerEvent event) { @@ -611,20 +691,17 @@ public class HubManager extends MiniClientPlugin if (AprilFoolsManager.Instance.isActive()) playerName = AprilFoolsManager.Instance.getName(player); - Rank rank = GetClients().Get(player).GetRank(); - - if(GetClients().Get(player).isDisguised()) - rank = GetClients().Get(player).getDisguisedRank(); + Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); //Level Prefix String levelStr = _achievementManager.getMineplexLevel(player, rank); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) + if (rank != Rank.ALL) rankStr = rank.getTag(true, true) + " "; //Party Chat - if (event.getMessage().charAt(0) == '#') + if (event.getMessage().charAt(0) == '@') { Party party = _partyManager.getParty(player); if (party != null) @@ -634,9 +711,9 @@ public class HubManager extends MiniClientPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - for (String name : party.getMembers()) + for (UUID uuid: party.getMembersByUUID()) { - Player other = UtilPlayer.searchExact(name); + Player other = Bukkit.getPlayer(uuid); if (other != null) event.getRecipients().add(other); @@ -648,7 +725,6 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } - return; } else { @@ -665,14 +741,10 @@ public class HubManager extends MiniClientPlugin for (Player other : UtilServer.getPlayers()) { - if (_tutorialManager.InTutorial(other)) - { - event.getRecipients().remove(other); - continue; - } - if (!event.isCancelled()) + { other.spigot().sendMessage(component); + } } event.setCancelled(true); } @@ -727,100 +799,14 @@ public class HubManager extends MiniClientPlugin @EventHandler public void InventoryCancel(InventoryClickEvent event) { - if (event.getWhoClicked() instanceof Player && ((Player)event.getWhoClicked()).getGameMode() != GameMode.CREATIVE) + if (event.getWhoClicked() instanceof Player && ((Player) event.getWhoClicked()).getGameMode() != GameMode.CREATIVE) event.setCancelled(true); } - @EventHandler - public void UpdateScoreboard(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - _scoreboardTick = (_scoreboardTick + 1)%3; - - if (_scoreboardTick != 0) - return; - - int playerCount = _playerCountManager.getPlayerCount(); - - for (Player player : UtilServer.getPlayers()) - { - - //Return to Main Scoreboard - if (!player.getScoreboard().equals(_scoreboards.get(player))) - player.setScoreboard(_scoreboards.get(player)); - - //Objective - Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); - - //Title - obj.setDisplayName(C.cWhite + C.Bold + Get(player).GetScoreboardText()); - - int line = 15; - - //Stacker - obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); - obj.getScore(_serverName).setScore(line--); - - //Space - obj.getScore(" ").setScore(line--); - - //Gems - obj.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); - // Remove Old/Add New - player.getScoreboard().resetScores(Get(player.getName()).GetLastGemCount() + ""); - obj.getScore(GetDonation().Get(player.getName()).GetGems() + "").setScore(line--); - Get(player.getName()).SetLastGemCount(GetDonation().Get(player.getName()).GetGems()); - - //Space - obj.getScore(" ").setScore(line--); - - //Players - obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--); - player.getScoreboard().resetScores(_lastPlayerCount + ""); - obj.getScore(playerCount + "").setScore(line--); - - - //Space - obj.getScore(" ").setScore(line--); - - - //Display Rank - obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); - //Remove Old - player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(false).Name); - player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(true).Name); - player.getScoreboard().resetScores("No Rank"); - //Add New - if (GetClients().Get(player).GetRank().has(Rank.ULTRA)) - obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--); - else if (GetDonation().Get(player.getName()).OwnsUnknownPackage("SuperSmashMobs ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("Survival Games ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("Minigames ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("CastleSiege ULTRA") || - GetDonation().Get(player.getName()).OwnsUnknownPackage("Champions ULTRA")) - obj.getScore("Single Ultra").setScore(line--); - else - obj.getScore("No Rank").setScore(line--); - - - //Space - obj.getScore(" ").setScore(line--); - - //Website - obj.getScore(C.cRed + C.Bold + "Website").setScore(line--); - obj.getScore("www.mineplex.com").setScore(line--); - obj.getScore("----------------").setScore(line--); - } - - _lastPlayerCount = playerCount; - } - @Override - protected HubClient addPlayer(String player) + protected HubClient addPlayer(UUID uuid) { - return new HubClient(player); + return new HubClient(Bukkit.getPlayer(uuid).getName()); } public BlockRestore GetBlockRestore() @@ -880,19 +866,14 @@ public class HubManager extends MiniClientPlugin public PetManager getPetManager() { - return _petManager; + return _petManager; } - + public BonusManager getBonusManager() { return _bonusManager; } - public TutorialManager GetTutorial() - { - return _tutorialManager; - } - public StatsManager GetStats() { return _statsManager; @@ -907,7 +888,7 @@ public class HubManager extends MiniClientPlugin { return _customDataManager; } - + public Punish getPunishments() { return _punishManager; @@ -922,7 +903,7 @@ public class HubManager extends MiniClientPlugin // { // return _halloweenManager; // } - + @EventHandler(priority = EventPriority.MONITOR) public void gadgetCollide(GadgetCollideEntityEvent event) { @@ -933,7 +914,7 @@ public class HubManager extends MiniClientPlugin public void SetPortalDelay(Entity ent) { if (ent instanceof Player) - _portalTime.put(((Player)ent).getName(), System.currentTimeMillis()); + _portalTime.put(((Player) ent).getName(), System.currentTimeMillis()); } public boolean CanPortal(Player player) @@ -957,7 +938,7 @@ public class HubManager extends MiniClientPlugin if (BumpDisabled(ent)) return false; - if (!getPreferences().Get((Player)ent).ShowPlayers) + if (!getPreferences().get((Player) ent).isActive(Preference.SHOW_PLAYERS)) return false; return true; @@ -983,7 +964,7 @@ public class HubManager extends MiniClientPlugin @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) { event.setCancelled(true); } @@ -1027,17 +1008,17 @@ public class HubManager extends MiniClientPlugin { if (entity instanceof EntityInsentient) { - EntityInsentient entityMonster = (EntityInsentient)entity; - + EntityInsentient entityMonster = (EntityInsentient) entity; + if (entityMonster.getGoalTarget() != null && entityMonster.getGoalTarget() instanceof EntityPlayer) { - if (((EntityPlayer)entityMonster.getGoalTarget()).playerConnection.isDisconnected()) + if (((EntityPlayer) entityMonster.getGoalTarget()).playerConnection.isDisconnected()) entityMonster.setGoalTarget(null, TargetReason.FORGOT_TARGET, false); } } } } - + @EventHandler public void clearGameMode(PlayerQuitEvent event) { @@ -1060,26 +1041,17 @@ public class HubManager extends MiniClientPlugin public PacketHandler getPacketHandler() { - return _packetHandler; + return _packetHandler; } @EventHandler public void openProfile(PlayerInteractEvent event) { - if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) + if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) return; - new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();; - } - - @EventHandler - public void disableMusicChristmas(GadgetEnableEvent event) - { - if (event.getGadget() != null && event.getGadget().getGadgetType() == GadgetType.MUSIC_DISC) - { - UtilPlayer.message(event.getPlayer(), F.main("Hub", "Music Discs are disabled right now!")); - event.setCancelled(true); - } + new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory(); + ; } @EventHandler @@ -1087,17 +1059,17 @@ public class HubManager extends MiniClientPlugin { playNextSong(); } - + @EventHandler public void trackPortalDelayPlayers(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - - for (Iterator playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext();) + + for (Iterator playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext(); ) { String playerName = playerNameIterator.next(); - + if (UtilTime.elapsed(_portalTime.get(playerName), 5000)) { playerNameIterator.remove(); @@ -1109,7 +1081,7 @@ public class HubManager extends MiniClientPlugin { return _incognito; } - + public JumpManager getJumpManager() { return _jumpManager; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java new file mode 100644 index 000000000..539d13f0e --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java @@ -0,0 +1,22 @@ +package mineplex.hub; + +import mineplex.core.scoreboard.ScoreboardLine; + +public enum HubScoreboardLine implements ScoreboardLine +{ + SERVER_TITLE, + SERVER_NAME, + SERVER_EMPTY_SPACER, + GEM_TITLE, + GEM_COUNT, + GEM_EMPTY_SPACER, + SHARDS_TITLE, + SHARDS_COUNT, + PLAYER_EMPTY_SPACER, + RANK_TITLE, + RANK_NAME, + RANK_EMPTY_SPACER, + WEBSITE_TITLE, + WEBSITE_VALUE, + END_BREAKER; +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java deleted file mode 100644 index bc34a9e79..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ /dev/null @@ -1,481 +0,0 @@ -package mineplex.hub.commands; - -import java.lang.reflect.Field; -import java.util.UUID; - -import mineplex.core.account.CoreClient; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.ProfileLoader; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.PlayerUndisguiseEvent; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.punish.PunishClient; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import net.minecraft.server.v1_8_R3.ChatComponentText; -import net.minecraft.server.v1_8_R3.EntityHuman; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; -import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; -import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.scoreboard.Team; - -import com.mojang.authlib.GameProfile; - -public class DisguiseCommand extends CommandBase implements Listener -{ - - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - - public DisguiseCommand(HubManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); - - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null || args.length == 0) - { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - try - { - GameProfile profile = _disguisedPlayers.get(caller); - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName, true); - - for(Player other : UtilServer.getPlayers()) - updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - team.removePlayer(caller); - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); - return; - } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUID.randomUUID(); - GameProfile profile = null; - try - { - uuid = UUIDFetcher.getUUIDOf(args[0]); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch (Exception e) - { - uuid = UUID.randomUUID(); - profile = new ProfileLoader(null, args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - CoreClient other = null; - try - { - other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - { - other = null; - } - if(otherRank.has(Rank.TWITCH)) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); - return; - } - if(other != null) - { - PunishClient pclient = Plugin.getPunishments().GetClient(args[0]); - if(pclient.IsBanned() || pclient.IsMuted()) - { - UtilPlayer.message(caller, F.main("Disguise", "Unable to disguise as this Player!")); - return; - } - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0], true); - - Plugin.GetGadget().removeGadgetType(caller, GadgetType.ITEM); - - // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - tablistRefresh(caller); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - } - }); - } - - @EventHandler - public void refreshTabNames(UpdateEvent event) - { - if(event.getType() != UpdateType.FAST) - return; - - for(Player player : _disguisedPlayers.keySet()) - { - if(!player.isOnline()) - return; - - tablistRefresh(player); - } - } - - public void tablistRefresh(Player player) - { - for (Player other : UtilServer.getPlayers()) - { - if (player.canSee(other)) - { - updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); - } - } - } - - public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) - { - ChatColor team = ChatColor.WHITE; - Player player = Bukkit.getPlayer(profileToAdd.getName()); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; - if(Plugin.GetClients().Get(player).isDisguised()) - { - tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; - } - - IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); - - if(!refreshOnly) - { - PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); - PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - removePacket.b.add(removeData); - UtilPlayer.sendPacket(target, removePacket); - - PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); - PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - addPacket.b.add(addData); - UtilPlayer.sendPacket(target, addPacket); - } - - PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); - PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - updatePacket.b.add(updateData); - UtilPlayer.sendPacket(target, updatePacket); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) - { - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); - } - } - - public void changeName(final Player player, String changedName, boolean skin) - { - try - { - GameProfile gameProfile = ((CraftPlayer) player).getProfile(); - - Field name = GameProfile.class.getDeclaredField("name"); - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName, true); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetEnableEvent event) - { - if(!event.getGadget().getName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.MORPH) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler - public void onPlayerLeftClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(player)) - { - EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - human.world.broadcastEntityEffect(human, (byte) 0); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - - Player player = event.getPlayer(); - - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) - { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } - } - } - } - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java index a31b07381..fc29c38e8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailManager.java @@ -1,6 +1,7 @@ package mineplex.hub.mail; import java.util.List; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -27,7 +28,7 @@ public class MailManager extends MiniClientPlugin implements Not } @Override - protected PlayerMailData addPlayer(String player) + protected PlayerMailData addPlayer(UUID uuid) { return new PlayerMailData(); } @@ -40,7 +41,7 @@ public class MailManager extends MiniClientPlugin implements Not @Override public void run() { - Set(event.getPlayer().getName(), _repository.loadMailData(event.getPlayer().getUniqueId())); + Set(event.getPlayer(), _repository.loadMailData(event.getPlayer().getUniqueId())); } }); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index 107fd8aa6..8002a87b4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -1,13 +1,5 @@ package mineplex.hub.modules; -import java.util.HashMap; - -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; - import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -16,10 +8,18 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; public class ForcefieldManager extends MiniPlugin { @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) + if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) { for (Player other : UtilServer.getPlayers()) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java index f0754c10f..3f033bcd6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java @@ -1,24 +1,19 @@ package mineplex.hub.modules; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseArmorStand; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.Preference; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; import mineplex.hub.HubType; - import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -27,6 +22,10 @@ import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + public class HalloweenSpookinessManager extends MiniPlugin { /** @@ -155,7 +154,7 @@ public class HalloweenSpookinessManager extends MiniPlugin return; //Follow for 2 seconds - if (!_target.isOnline() || _manager.getPreferences().Get(_target).Invisibility || UtilTime.elapsed(_targetTime, 2000)) + if (!_target.isOnline() || _manager.getPreferences().get(_target).isActive(Preference.INVISIBILITY) || UtilTime.elapsed(_targetTime, 2000)) { resetFollowing(); return; @@ -215,7 +214,7 @@ public class HalloweenSpookinessManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (_manager.getPreferences().Get(player).Invisibility) + if (_manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) ) continue; if (UtilMath.offset(player.getLocation(), average) <= 7) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java deleted file mode 100644 index 9e5a6be02..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubScoreboardManager.java +++ /dev/null @@ -1,74 +0,0 @@ -package mineplex.hub.modules; - -import org.bukkit.event.EventHandler; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.scoreboard.ScoreboardData; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; - -public class HubScoreboardManager extends MiniPlugin -{ - private ScoreboardManager _scoreboardManager; - private String _serverName; - - public HubScoreboardManager(HubManager manager, CoreClientManager clientManager, DonationManager donationManager) - { - super("Hub Scoreboard Manager", manager.getPlugin()); - - _scoreboardManager = new ScoreboardManager(manager.getPlugin(), clientManager, donationManager, manager.getIncognitoManager()); - - init(); - } - - private String getServerName() - { - if (_serverName == null) - _serverName = getPlugin().getConfig().getString("serverstatus.name"); - - return _serverName; - } - - private void init() - { - ScoreboardData data = _scoreboardManager.getData("default", true); - - data.writeEmpty(); - - //Server - data.write(C.cAqua + C.Bold + "Server"); - data.write(getServerName()); - data.writeEmpty(); - - //Gems - data.write(C.cGreen + C.Bold + "Gems"); - data.writePlayerGems(); - data.writeEmpty(); - - //Coins - data.write(C.cYellow + C.Bold + "Coins"); - data.writePlayerCoins(); - data.writeEmpty(); - - //Rank - data.write(C.cGold + C.Bold + "Rank"); - data.writePlayerRank(); - data.writeEmpty(); - - //Website - data.write(C.cRed + C.Bold + "Website"); - data.write("www.mineplex.com"); - } - - @EventHandler - public void drawUpdate(UpdateEvent event) - { - if (event.getType() == UpdateType.FAST) - _scoreboardManager.draw(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index 75abcbfbd..b2c29d783 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -1,28 +1,28 @@ package mineplex.hub.modules; -import java.util.HashMap; -import java.util.HashSet; - +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.preferences.Preference; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import mineplex.hub.HubManager; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; -import mineplex.hub.HubManager; +import java.util.HashMap; +import java.util.HashSet; public class HubVisibilityManager extends MiniPlugin { @@ -64,9 +64,8 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { Rank rank = Manager.GetClients().Get(player).GetRank(); - boolean hideMe = Manager.GetTutorial().InTutorial(player) || - UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || + boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || + (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || _hiddenPlayers.contains(player); for (Player other : UtilServer.getPlayers()) @@ -78,9 +77,7 @@ public class HubVisibilityManager extends MiniPlugin if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) localHideMe = false; - if (localHideMe || - !Manager.getPreferences().Get(other).ShowPlayers || - Manager.GetTutorial().InTutorial(other)) + if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) { VisibilityManager.Instance.setVisibility(player, false, other); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index afa61a5a1..106e9a9c8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -1,16 +1,5 @@ package mineplex.hub.modules; -import java.util.HashSet; - -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.util.Vector; - import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.util.UtilAction; @@ -22,10 +11,21 @@ import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; +import org.bukkit.util.Vector; + +import java.util.HashSet; public class JumpManager extends MiniPlugin { @@ -48,7 +48,7 @@ public class JumpManager extends MiniPlugin return; Rank rank = Manager.GetClients().Get(player).GetRank(); - if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { return; } @@ -90,7 +90,7 @@ public class JumpManager extends MiniPlugin continue; Rank rank = Manager.GetClients().Get(player).GetRank(); - if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { player.setAllowFlight(true); continue; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java index 827690a1f..c9e42cf55 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java @@ -1,19 +1,6 @@ package mineplex.hub.modules; -import java.util.ArrayList; -import java.util.HashSet; - -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import mineplex.core.MiniPlugin; +import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -32,6 +19,18 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; import mineplex.hub.modules.koth.CapturePoint; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.HashSet; public class KothManager extends MiniPlugin { @@ -59,13 +58,13 @@ public class KothManager extends MiniPlugin Manager = manager; - _cornerPlayerA = new Location(Manager.GetSpawn().getWorld(), -52.5,0,-23.5); - _cornerPlayerB = new Location(Manager.GetSpawn().getWorld(), -133.5,200,80.5); + _cornerPlayerA = new Location(Manager.GetSpawn().getWorld(), -52.5, 0, -21.5); + _cornerPlayerB = new Location(Manager.GetSpawn().getWorld(), -133.5, 197, 82.5); - _cornerHillA = new Location(Manager.GetSpawn().getWorld(), -88.5,60,47.5); - _cornerHillB = new Location(Manager.GetSpawn().getWorld(), -102.5,80,61.5); - - _cp = new CapturePoint(this, "Desert Pyramid", new Location(Manager.GetSpawn().getWorld(), -95.5,72,54.5)); + _cornerHillA = new Location(Manager.GetSpawn().getWorld(), -88.5, 57, 49.5); + _cornerHillB = new Location(Manager.GetSpawn().getWorld(), -102.5, 77, 63.5); + + _cp = new CapturePoint(this, "Desert Pyramid", new Location(Manager.GetSpawn().getWorld(), -95.5, 69, 56.5)); //Store Gadgets for (Gadget gadget : gadgets.getGadgets(GadgetType.COSTUME)) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index b357aee34..c887fc433 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -1,9 +1,32 @@ package mineplex.hub.modules; -import java.util.HashSet; -import java.util.Iterator; -import java.util.WeakHashMap; - +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.gadget.types.MusicGadget; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.recharge.Recharge; +import mineplex.core.task.TaskManager; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.modules.parkour.ParkourData; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -16,55 +39,71 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.gadget.types.MusicGadget; -import mineplex.core.mount.event.MountActivateEvent; -import mineplex.core.recharge.Recharge; -import mineplex.core.task.TaskManager; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import mineplex.hub.modules.parkour.ParkourData; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.WeakHashMap; +import java.util.stream.Collectors; public class ParkourManager extends MiniPlugin { + private final String[] RUINS_DESCRIPTION = { + "This is an extremely difficult parkour.", + "You will need to find the correct way through", + "the ruins, overcoming many challenging jumps.", + }; + + private final String[] GWEN_DESCRIPTION = { + "Can you escape from our Guardians?", + "I hear they have infested the water", + "sending anyone who falls in back to the start!", + }; + + private final String[] LAVA_DESCRIPTION = { + "This parkour is HOT! It's so hot that you", + "must keep sprinting for the entire course,", + "or you will die in flames!" + }; + + private final String[] DESERT_DESCRIPTION = { + "Ever heard of Prince of Persia", + "well, this isn't as exciting.", + "yet...." + }; + + private final int RUINS_GEMS = 10000; + private final int GWEN_GEMS = 4000; + private final int LAVA_GEMS = 5000; + private final int DESERT_GEMS = 3000; + public HubManager Manager; - private HashSet _active = new HashSet(); + private Map _active = Maps.newHashMap(); private HashSet _parkour = new HashSet(); //private Location _snakeParkourReturn; private Location _lavaParkourReturn; + private Location _waterReturn; private WeakHashMap _lavaLocation = new WeakHashMap(); private WeakHashMap _lavaTimer = new WeakHashMap(); //Modules protected DonationManager _donationManager; protected TaskManager _taskManager; - + public ParkourManager(HubManager manager, DonationManager donation, TaskManager task) { super("Parkour", manager.getPlugin()); @@ -74,136 +113,139 @@ public class ParkourManager extends MiniPlugin _taskManager = task; _donationManager = donation; - _parkour.add(new ParkourData("Ruins Parkour", new String[] - { - "This is an extremely difficult parkour.", - "You will need to find the correct way through", - "the ruins, overcoming many challenging jumps.", - }, - 6000, new Location(Manager.GetSpawn().getWorld(), 110,66,-44), - new Location(Manager.GetSpawn().getWorld(), 103,100,-60), new Location(Manager.GetSpawn().getWorld(), 150,50,26))); + _parkour.add(new ParkourData("Ruins Parkour", RUINS_DESCRIPTION, RUINS_GEMS, + new Location(Manager.GetSpawn().getWorld(), 113.5, 66, -46.5), + new Location(Manager.GetSpawn().getWorld(), 124, 86, 18), + new Location(Manager.GetSpawn().getWorld(), 105, 57, -53))); + _parkour.add(new ParkourData("G.W.E.N Parkour", GWEN_DESCRIPTION, GWEN_GEMS, + new Location(Manager.GetSpawn().getWorld(), 55.5, 68, -94.5), + new Location(Manager.GetSpawn().getWorld(), 106, 96, -142), + new Location(Manager.GetSpawn().getWorld(), 52, 61, -81))); - _parkour.add(new ParkourData("Lava Parkour", new String[] - { - "This parkour is HOT! It's so hot that you", - "must keep sprinting for the entire course,", - "or you will die in flames!" - }, 4000, new Location(Manager.GetSpawn().getWorld(), -93,67,38), - new Location(Manager.GetSpawn().getWorld(), -86,100,42), new Location(Manager.GetSpawn().getWorld(), -120,50,-17))); - -// _parkour.add(new ParkourSnake("Snake Parkour", new String[] -// { -// "This parkour requires incredible timing", -// "and great agility! Some say it was created", -// "by the devil as a cruel joke!" -// }, 8000, new Location(Manager.GetSpawn().getWorld(), 22,70,-54), -// new Location(Manager.GetSpawn().getWorld(), 35,-200,-90), new Location(Manager.GetSpawn().getWorld(), -30,250,-46))); + _parkour.add(new ParkourData("Lava Parkour", LAVA_DESCRIPTION, LAVA_GEMS, + new Location(Manager.GetSpawn().getWorld(), -93.5, 67, 37.5), + new Location(Manager.GetSpawn().getWorld(), -144, 97, -21), + new Location(Manager.GetSpawn().getWorld(), -88, 62, 41))); - _lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5,68,36.5); + _parkour.add(new ParkourData("Desert Village Parkour", DESERT_DESCRIPTION, DESERT_GEMS, + new Location(Manager.GetSpawn().getWorld(), -63.5, 69, -32.5), + new Location(Manager.GetSpawn().getWorld(), -57, 82, -35), + new Location(Manager.GetSpawn().getWorld(), -122, 45, 57))); + + _lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5, 68, 36.5); _lavaParkourReturn.setYaw(90); - - //_snakeParkourReturn = new Location(Manager.GetSpawn().getWorld(), 16.5,72,-52.5); - //_snakeParkourReturn.setYaw(180); + _waterReturn = new Location(Manager.GetSpawn().getWorld(), 56.5, 68, -88.5); + _waterReturn.setYaw(-141); } public boolean isParkourMode(Player player) { - return _active.contains(player); + return _active.containsKey(player.getUniqueId()); } - - public void setParkourMode(Player player, boolean enabled) + + public void setParkourMode(Player player, boolean enabled, ParkourData data) { if (enabled) { - _active.add(player); + player.setAllowFlight(false); + player.setFlying(false); + _active.put(player.getUniqueId(), data); UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Parkour Mode") + ".")); - + Manager.GetGadget().disableAll(player); - - player.setVelocity(new Vector(0,-1,0)); - } - else + + player.setVelocity(new Vector(0, -1, 0)); + } else { - _active.remove(player); + player.setAllowFlight(true); + _active.remove(player.getUniqueId()); UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Parkour Mode") + ".")); } } - + @EventHandler public void playerVelocity(PlayerVelocityEvent event) { if (isParkourMode(event.getPlayer())) + { event.setCancelled(true); + } } - + @EventHandler public void disableGadgets(GadgetEnableEvent event) { if (isParkourMode(event.getPlayer())) + { event.setCancelled(true); + } } - + @EventHandler public void disableMounts(MountActivateEvent event) { if (isParkourMode(event.getPlayer())) + { event.setCancelled(true); + } } - + @EventHandler public void playerEnterParkour(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; - + } + for (Player player : UtilServer.getPlayers()) { if (isParkourMode(player)) + { continue; - - for (ParkourData data : _parkour) - if (UtilMath.offset(player.getLocation(), data.NPC) < 6) - if (Recharge.Instance.use(player, data.Name+" Info", 300000, false, false)) - data.Inform(player); + } + + + _parkour.stream() + .filter(data -> UtilMath.offset(player.getLocation(), data.NPC) < 6) + .filter(data -> Recharge.Instance.use(player, data.Name + " Info", 300000, false, false)) + .forEach(data -> data.Inform(player)); } } - + @EventHandler public void parkourUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - Iterator playerIterator = _active.iterator(); - - while (playerIterator.hasNext()) { - Player player = playerIterator.next(); - + return; + } + + List players = Lists.newArrayList(_active.keySet().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); + for(Player player : players) + { player.leaveVehicle(); player.eject(); - - if (!InsideParkour(player.getLocation())) + if(!InsideParkour(player.getLocation())) { - playerIterator.remove(); - UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Parkour Mode") + ".")); - } - else + setParkourMode(player, false, null); + } else { - - for (Iterator iterator = player.getActivePotionEffects().iterator(); iterator.hasNext();) + for (PotionEffect potionEffect : player.getActivePotionEffects()) { - player.removePotionEffect(iterator.next().getType()); + player.removePotionEffect(potionEffect.getType()); } } } + players.clear(); + } @EventHandler public void playerQuit(PlayerQuitEvent event) { - _active.remove(event.getPlayer()); + _active.remove(event.getPlayer().getUniqueId()); } @EventHandler @@ -215,19 +257,25 @@ public class ParkourManager extends MiniPlugin UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You cannot break blocks in Parkour Mode!")); } } - + @EventHandler(priority = EventPriority.LOWEST) public void disallowBlockPlace(PlayerInteractEvent event) { if (event.getPlayer().getItemInHand() == null) + { return; - + } + if (!event.getPlayer().getItemInHand().getType().isBlock()) + { return; - + } + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { return; - + } + if (isParkourMode(event.getPlayer())) { event.getPlayer().teleport(Manager.GetSpawn()); @@ -239,7 +287,9 @@ public class ParkourManager extends MiniPlugin public void lavaReturn(EntityDamageEvent event) { if (event.getCause() != DamageCause.LAVA) + { return; + } if (!(event.getEntity() instanceof Player)) { @@ -247,53 +297,77 @@ public class ParkourManager extends MiniPlugin return; } - Player player = (Player)event.getEntity(); + Player player = (Player) event.getEntity(); if (!isParkourMode(player)) + { return; + } event.getEntity().eject(); event.getEntity().leaveVehicle(); event.getEntity().teleport(_lavaParkourReturn); } - -// @EventHandler(priority = EventPriority.HIGHEST) -// public void snakeReturn(EntityDamageEvent event) -// { -// if (event.getCause() != DamageCause.VOID) -// return; -// -// if (!(event.getEntity() instanceof Player)) -// return; -// -// Player player = (Player)event.getEntity(); -// -// if (!isParkourMode(player)) -// return; -// -// event.getEntity().eject(); -// event.getEntity().leaveVehicle(); -// event.getEntity().teleport(_snakeParkourReturn); -// } + + @EventHandler + public void waterReturn(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + + if (!isParkourMode(player)) + { + return; + } + + if (!Arrays.equals(_active.get(player.getUniqueId()).Desc, GWEN_DESCRIPTION)) + { + return; + } + + if (event.getTo().getBlock().getType() == Material.WATER || event.getTo().getBlock().getType() == Material.STATIONARY_WATER) + { + player.eject(); + player.leaveVehicle(); + player.teleport(_waterReturn); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onTeam(PlayerCommandPreprocessEvent event) + { + if(event.getMessage().startsWith("/team ") && isParkourMode(event.getPlayer())) + { + event.setCancelled(true); + event.getPlayer().sendMessage(F.main("Team", "You cannot join a team while in parkour mode!")); + } + } @EventHandler public void lavaBlockReturn(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player player : UtilServer.getPlayers()) { if (!UtilEnt.isGrounded(player)) + { continue; - + } + if (!isParkourMode(player)) + { continue; + } int id = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getTypeId(); int data = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getData(); - if (id != 0 && id != 112 && id != 114 && !(id == 43 && data == 6) && !(id == 44 && data == 6)) + if (id != 0 && id != 112 && id != 114 && !(id == 43 && data == 6) && !(id == 44 && data == 6)) + { continue; + } if (!_lavaLocation.containsKey(player) || UtilMath.offset(player.getLocation(), _lavaLocation.get(player)) > 1.5) { @@ -315,7 +389,9 @@ public class ParkourManager extends MiniPlugin } if (!inCourse) + { continue; + } _lavaLocation.remove(player); _lavaTimer.remove(player); @@ -334,16 +410,22 @@ public class ParkourManager extends MiniPlugin public void finishParkour(PlayerInteractEntityEvent event) { if (event.getRightClicked() == null) + { return; + } if (!(event.getRightClicked() instanceof LivingEntity)) + { return; + } - LivingEntity ent = (LivingEntity)event.getRightClicked(); + LivingEntity ent = (LivingEntity) event.getRightClicked(); if (ent.getCustomName() == null) + { return; - + } + //Start Message if (ent.getCustomName().contains("Start")) { @@ -352,12 +434,17 @@ public class ParkourManager extends MiniPlugin for (ParkourData data : _parkour) { if (!ent.getCustomName().contains(data.Name)) + { continue; - + } + if (isParkourMode(player)) - setParkourMode(player, false); - else - setParkourMode(player, true); + { + setParkourMode(player, false, data); + } else + { + setParkourMode(player, true, data); + } } } @@ -365,7 +452,7 @@ public class ParkourManager extends MiniPlugin if (ent.getCustomName().contains("Finish")) { final Player player = event.getPlayer(); - + if (!isParkourMode(player)) { //Inform @@ -375,60 +462,67 @@ public class ParkourManager extends MiniPlugin } if (!Recharge.Instance.use(player, "Finish Parkour", 30000, false, false)) - return; - - for (ParkourData data : _parkour) { - if (!ent.getCustomName().contains(data.Name)) - continue; - - //Inform - UtilPlayer.message(player, F.main("Parkour", "You completed " + F.elem(data.Name) + ".")); - - //Gems - if (!_taskManager.hasCompletedTask(player, data.Name)) - { - final ParkourData fData = data; - - _taskManager.completedTask(new Callback() - { - public void run(Boolean completed) - { - _donationManager.RewardGems(new Callback() - { - public void run(Boolean completed) - { - if (completed) - { - UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + ".")); - - //Sound - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - else - { - _taskManager.Get(player).TasksCompleted.remove(_taskManager.getTaskId(fData.Name)); - UtilPlayer.message(player, F.main("Parkour", "There was an error giving " + F.elem(C.cGreen + fData.Gems + " Gems to you. Please click the NPC again.") + ".")); - } - } - }, "Parkour " + fData.Name, player.getName(), player.getUniqueId(), fData.Gems); - - //Sound - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - }, player, fData.Name); - } + return; } + + ParkourData data = _active.get(player.getUniqueId()); + + if(!ent.getCustomName().contains(data.Name)) + { + UtilPlayer.message(player, F.main("Parkour", "This is not the entity you are looking for...")); + player.teleport(data.NPC); + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0f, 1.0F); + return; + } + //Inform + UtilPlayer.message(player, F.main("Parkour", "You completed " + F.elem(data.Name) + ".")); + + setParkourMode(player, false, null); + + //Gems + if (!_taskManager.hasCompletedTask(player, data.Name)) + { + final ParkourData fData = data; + + _taskManager.completedTask(new Callback() + { + public void run(Boolean completed) + { + _donationManager.RewardGems(new Callback() + { + public void run(Boolean completed) + { + if (completed) + { + UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + ".")); + + //Sound + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } else + { + _taskManager.Get(player).TasksCompleted.remove(_taskManager.getTaskId(fData.Name)); + UtilPlayer.message(player, F.main("Parkour", "There was an error giving " + F.elem(C.cGreen + fData.Gems + " Gems to you. Please click the NPC again.") + ".")); + } + } + }, "Parkour " + fData.Name, player.getName(), player.getUniqueId(), fData.Gems); + + //Sound + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + }, player, fData.Name); + } + } } - + @EventHandler public void gadgetBlockChange(GadgetBlockEvent event) { - for (Iterator iterator = event.getBlocks().iterator(); iterator.hasNext();) + for (Iterator iterator = event.getBlocks().iterator(); iterator.hasNext(); ) { Block block = iterator.next(); - + for (ParkourData data : _parkour) { if (data.InBoundary(block.getLocation())) @@ -436,7 +530,7 @@ public class ParkourManager extends MiniPlugin iterator.remove(); break; } - } + } } } @@ -444,8 +538,10 @@ public class ParkourManager extends MiniPlugin { for (ParkourData data : _parkour) if (data.InBoundary(loc)) + { return true; - + } + return false; } @@ -458,7 +554,7 @@ public class ParkourManager extends MiniPlugin UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You can't open chests near Parkour.")); } } - + @EventHandler public void musicDisable(GadgetEnableEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index c6ddf2553..ec4812c11 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -1,28 +1,5 @@ package mineplex.hub.modules; -import java.util.ArrayList; -import java.util.HashSet; - -import org.bukkit.Color; -import org.bukkit.EntityEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Firework; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.WitherSkull; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerVelocityEvent; -import org.bukkit.util.Vector; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -50,6 +27,28 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Color; +import org.bukkit.EntityEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashSet; public class SoccerManager extends MiniPlugin { @@ -97,21 +96,21 @@ public class SoccerManager extends MiniPlugin super("Football Manager", hubManager.getPlugin()); _hubManager = hubManager; - - _cornerFieldPlayerA = new Location(hubManager.GetSpawn().getWorld(), 28.5,70,-27.5); - _cornerFieldPlayerB = new Location(hubManager.GetSpawn().getWorld(), 50.5,100,-65.5); - _cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), 35.5,70,-24.5); - _cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 43.5,100,-68.5); + _cornerFieldPlayerA = new Location(hubManager.GetSpawn().getWorld(), -13.5, 67, -65.5); + _cornerFieldPlayerB = new Location(hubManager.GetSpawn().getWorld(), 25.5, 100, -87.5); - _cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), 29.75,70,-28.75); - _cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 49.25,100,-64.25); + _cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), -17.5, 67, -71.5); + _cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 29.5, 100, -80.5); - _cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-64.25); - _cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-67.25); + _cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), -12.75, 67, -66.75); + _cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 24.25, 100, -86.25); - _cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-25.75); - _cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-28.75); + _cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 27.75, 67.5, -73.25); + _cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 25.25, 72.5, -79.25); + + _cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), -15.75, 67.5, -79.75); + _cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), -13.25, 72.5, -73.75); //Store Gadgets for (Gadget gadget : gadgetManager.getGadgets(GadgetType.COSTUME)) @@ -135,7 +134,7 @@ public class SoccerManager extends MiniPlugin _redGoals = 0; if (_ball != null) - _ball.remove();; + _ball.remove(); return; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index a3cab8a0b..760bb8eba 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -1,27 +1,6 @@ package mineplex.hub.modules; -import java.util.HashSet; - -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCrafting; -import org.bukkit.entity.Bat; -import org.bukkit.entity.EnderDragon; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Horse; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Wither; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -41,6 +20,29 @@ import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.hub.HubManager; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCrafting; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Bat; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Minecart; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; public class StackerManager extends MiniPlugin implements IThrown { @@ -56,7 +58,7 @@ public class StackerManager extends MiniPlugin implements IThrown Manager = manager; - _projectileManager = new ProjectileManager(manager.getPlugin()); + _projectileManager = Managers.get(ProjectileManager.class); } @EventHandler @@ -86,7 +88,17 @@ public class StackerManager extends MiniPlugin implements IThrown if (stackee instanceof Player && ((Player)stackee).getGameMode() != GameMode.SURVIVAL) return; - + + if(stackee instanceof ArmorStand) + { + return; + } + + if(stackee instanceof Minecart) + { + return; + } + Player stacker = event.getPlayer(); if (stacker.getGameMode() != GameMode.SURVIVAL) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java index cce5c3625..d0ce99b44 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java @@ -1,19 +1,9 @@ package mineplex.hub.modules; -import org.bukkit.entity.Player; -import org.bukkit.entity.Sheep; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.gadgets.item.ItemLovePotion; @@ -21,6 +11,10 @@ import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.modules.valentines.Courtship; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; public class ValentinesManager extends MiniPlugin { @@ -128,6 +122,6 @@ public class ValentinesManager extends MiniPlugin UtilPlayer.message(player, F.main("Reward", "You recieved " + F.elem(_reward + " Mount") + " from " + F.elem(_prefix) + "!")); } } - }, player.getName(), _client.getAccountId(player), _reward, CurrencyType.TREASURE_SHARD, 0, true); + }, player.getName(), _client.getAccountId(player), _reward, GlobalCurrency.TREASURE_SHARD, 0, true); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index c035382b9..6f771072b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -1,14 +1,29 @@ package mineplex.hub.modules; -import java.util.HashSet; -import java.util.Iterator; - +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.npc.NpcManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.Hub; +import mineplex.hub.HubManager; +import mineplex.hub.HubType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Boat; import org.bukkit.entity.Chicken; import org.bukkit.entity.Cow; @@ -38,26 +53,15 @@ import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.weather.WeatherChangeEvent; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import mineplex.hub.HubType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import java.util.HashSet; +import java.util.Iterator; public class WorldManager extends MiniPlugin { public HubManager Manager; private HashSet _mobs = new HashSet(); - + private boolean _christmasSnow = false; private long _christSnowTime = 0; @@ -66,25 +70,31 @@ public class WorldManager extends MiniPlugin super("World Manager", manager.getPlugin()); Manager = manager; - + //Added by TheMineBench, to stop day cycles instead of setting the time on update event. World world = UtilWorld.getWorld("world"); - + world.setGameRuleValue("doDaylightCycle", "false"); - - if (Manager.Type == HubType.Halloween) + + if (Manager.Type == HubType.Halloween) + { world.setTime(16000); - else + } else + { world.setTime(6000); + } world.setStorm(false); world.setThundering(false); + fixEntities(); } @EventHandler public void SpawnAnimals(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) + { return; + } Iterator entIterator = _mobs.iterator(); @@ -100,46 +110,72 @@ public class WorldManager extends MiniPlugin } if (_mobs.size() > 16) + { return; + } //Loc double r = Math.random(); Location loc = Manager.GetSpawn(); - if (r > 0.66) loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42); - else if (r > 0.33) loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28); - else loc = new Location(Manager.GetSpawn().getWorld(), 43, 72, 5); + if (r > 0.66) + { + loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42); + } else if (r > 0.33) + { + loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28); + } else + { + loc = new Location(Manager.GetSpawn().getWorld(), 43, 72, 5); + } //Spawn if (Manager.Type == HubType.Halloween) { Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class); - if (Math.random() > 0.5) + if (Math.random() > 0.5) + { ent.setSkeletonType(SkeletonType.WITHER); - + } + ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); - + ent.setCustomName(C.cYellow + "Pumpkin Minion"); ent.setCustomNameVisible(false); - + _mobs.add(ent); Manager.GetCondition().Factory().Invisible("Perm", ent, ent, 999999999, 0, false, false, true); Manager.GetCondition().Factory().Slow("Perm", ent, ent, 999999999, 1, false, false, false, true); - } - else if (Manager.Type == HubType.Christmas) + } else if (Manager.Type == HubType.Christmas) { _mobs.add(loc.getWorld().spawn(loc, Snowman.class)); - } - else + } else { r = Math.random(); - if (r > 0.66) _mobs.add(loc.getWorld().spawn(loc, Cow.class)); - else if (r > 0.33) _mobs.add(loc.getWorld().spawn(loc, Pig.class)); - else _mobs.add(loc.getWorld().spawn(loc, Chicken.class)); + if (r > 0.66) + { + _mobs.add(loc.getWorld().spawn(loc, Cow.class)); + } else if (r > 0.33) + { + _mobs.add(loc.getWorld().spawn(loc, Pig.class)); + } else + { + _mobs.add(loc.getWorld().spawn(loc, Chicken.class)); + } + } + } + + + @EventHandler + public void onGadgetCollide(GadgetCollideEntityEvent event) + { + if(_mobs.contains(event.getOther()) || event.getOther() instanceof ArmorStand) + { + event.setCancelled(false); } } @@ -147,23 +183,25 @@ public class WorldManager extends MiniPlugin public void BlockBreak(BlockBreakEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) - return; + { + return; + } event.setCancelled(true); } - + @EventHandler public void BlockBurn(BlockBurnEvent event) { event.setCancelled(true); } - + @EventHandler public void BlockIgnite(BlockIgniteEvent event) { event.setCancelled(true); } - + @EventHandler public void BlockEntityChange(EntityChangeBlockEvent event) { @@ -192,7 +230,9 @@ public class WorldManager extends MiniPlugin public void BlockPlace(BlockPlaceEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); } @@ -201,11 +241,13 @@ public class WorldManager extends MiniPlugin public void BorderUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FASTEST) + { return; + } for (Player player : Manager.GetSpawn().getWorld().getPlayers()) { - if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 200) + if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 210) { player.eject(); player.leaveVehicle(); @@ -218,7 +260,9 @@ public class WorldManager extends MiniPlugin public void ItemPickup(PlayerPickupItemEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); } @@ -227,33 +271,46 @@ public class WorldManager extends MiniPlugin public void ItemDrop(PlayerDropItemEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); } - + @EventHandler(priority = EventPriority.LOW) public void ItemDespawn(UpdateEvent event) { if (event.getType() != UpdateType.SEC) + { return; - + } + for (Entity ent : UtilWorld.getWorld("world").getEntities()) { if (!(ent instanceof Item)) + { continue; - - if (((Item)ent).getItemStack().getType() == Material.MONSTER_EGG) + } + + if (((Item) ent).getItemStack().getType() == Material.MONSTER_EGG) + { continue; - + } + if (UtilEnt.GetMetadata(ent, "UtilItemSpawning") != null) + { continue; - + } + if (ent.getTicksLived() > 1200) + { ent.remove(); + } } } -//Removed by TheMineBench, time is now stopped when the WorldManager is created + + //Removed by TheMineBench, time is now stopped when the WorldManager is created /* @EventHandler public void UpdateWeather(UpdateEvent event) @@ -273,22 +330,29 @@ public class WorldManager extends MiniPlugin */ //Added by TheMineBench. Stops weather from changing. @EventHandler - public void OnWeather(WeatherChangeEvent event) { - + public void OnWeather(WeatherChangeEvent event) + { + if (!event.getWorld().getName().equals("world")) + { return; - + } + event.setCancelled(true); } - + @EventHandler public void HalloweenUpdates(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; + } if (Manager.Type != HubType.Halloween) + { return; + } //Block Lightup for (Player player : UtilServer.getPlayers()) @@ -296,7 +360,9 @@ public class WorldManager extends MiniPlugin for (Block block : UtilBlock.getInRadius(player.getLocation(), 3d).keySet()) { if (block.getType() == Material.PUMPKIN) + { Manager.GetBlockRestore().add(block, 91, block.getData(), 2000); + } } } @@ -304,43 +370,50 @@ public class WorldManager extends MiniPlugin for (LivingEntity ent : _mobs) { if (!(ent instanceof Creature)) + { continue; + } - Creature skel = (Creature)ent; + Creature skel = (Creature) ent; if (skel.getTarget() != null && skel.getTarget() instanceof Player && UtilMath.offset(skel, skel.getTarget()) < 6) { skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); - } - else + } else { skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); } } } - + @EventHandler public void SoundUpdate(UpdateEvent event) { if (Manager.Type != HubType.Halloween) + { return; + } if (event.getType() != UpdateType.SLOW) + { return; + } if (Math.random() > 0.1) + { return; + } for (Player player : UtilServer.getPlayers()) player.playSound(player.getLocation(), Sound.AMBIENCE_CAVE, 3f, 1f); } - + @EventHandler public void BlockForm(BlockFormEvent event) { event.setCancelled(true); } - + @EventHandler public void CreatureTarget(EntityTargetEvent event) { @@ -349,14 +422,16 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } } - + @EventHandler public void BoatBreak(CustomDamageEvent event) { if (event.GetDamageeEntity() instanceof Boat) + { event.SetCancelled("Boat Cancel"); + } } - + @EventHandler public void combustPrevent(EntityCombustEvent event) { @@ -365,4 +440,15 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } } + + public void fixEntities() + { + NpcManager npcManager = ((Hub) Manager.getPlugin()).getNpcManager(); + + runSyncLater(() -> Manager.GetSpawn().getWorld().getEntities().stream().filter(e -> npcManager.getNpcByEntity(e) != null).forEach(e -> + { + float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory(e.getLocation(), Manager.GetSpawn())); + e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), yaw, 0f)); + }), 120L); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java index 948a334aa..f76644b16 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java @@ -38,15 +38,15 @@ public class Courtship * Created by: Mysticate * Timestamp: February 6, 2016 */ - + private ValentinesManager _manager; private Player _player; private Sheep _sheep; private String _prefix; private final boolean _success; - + private int _tick = 0; - + public Courtship(ValentinesManager manager, Player player, Sheep sheep, String prefix, boolean success) { _manager = manager; @@ -55,14 +55,14 @@ public class Courtship _prefix = prefix; _success = success; } - + public boolean tick() { if (!_player.isOnline()) return true; - + _tick++; - + { Vector vec = UtilAlg.getTrajectory(_sheep, _player); UtilEnt.CreatureForceLook(_sheep, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); @@ -77,21 +77,21 @@ public class Courtship Entity bottom = player; while (bottom.getVehicle() != null) bottom = bottom.getVehicle(); - + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(_sheep, bottom), .5, true, 0.8, 0, 10, true); player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); - + UtilPlayer.message(player, F.main(_prefix, "I'm talking to someone else right now!")); } } } - + if (_tick == 20) { message("What do we have here?"); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, 1F, 1F); } - + if (_tick == 40) { if (_success) @@ -105,16 +105,16 @@ public class Courtship _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, .5F, 1F); } } - + if (_tick > 40 && _tick < 80) { if (_tick % 2 == 0) { _sheep.getWorld().playSound(_sheep.getLocation(), Sound.DIG_GRASS, 1F, 1F); - + UtilParticle.PlayParticle(ParticleType.HEART, _sheep.getLocation().clone().add(0, 1, 0), new Vector(), 0F, 1, ViewDist.NORMAL, _player); UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _sheep.getLocation(), 1F, 1F, 1F, 0F, 1, ViewDist.NORMAL, _player); - + _sheep.setColor(DyeColor.PINK); } else @@ -122,7 +122,7 @@ public class Courtship _sheep.setColor(DyeColor.WHITE); } } - + if (_tick == 80) { if (_success) @@ -134,10 +134,10 @@ public class Courtship { message(UtilMath.randomElement(FAIL_MESSAGES)); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.ANVIL_BREAK, 1F, 1F); - _sheep.setColor(DyeColor.BLACK); + _sheep.setColor(DyeColor.BLACK); } } - + if (_tick > 80 && _tick < 120 && _success) { if (_tick % 2 == 0) @@ -149,31 +149,31 @@ public class Courtship _sheep.setColor(DyeColor.RED); } } - + if (_tick == 90 && _success) { message("I think..."); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.FIZZ, 1F, 1F); } - + if (_tick == 100 && _success) { message("I think I'm in love!"); _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); } - + if (_tick == 120 && _success) { message("Here, take this present as a token of my admiration."); - _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); - + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); + _manager.giveReward(_player); - + _sheep.setColor(DyeColor.RED); - + UtilServer.broadcast(C.cYellowB + _player.getName() + C.cWhiteB + " tricked " + C.cGoldB + "Polly the Pink Sheep" + C.cWhiteB + " with a love potion!"); } - + if (_tick == 130) { _sheep.setColor(DyeColor.PINK); @@ -183,7 +183,7 @@ public class Courtship return false; } - + private void message(String message) { UtilPlayer.message(_player, " "); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java index 1b9c38395..34471294d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java @@ -3,15 +3,11 @@ package mineplex.hub.profile.buttons; import mineplex.core.common.util.C; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.hub.profile.gui.GUIProfile; - -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; public class ButtonPrefs implements GuiItem { @@ -28,7 +24,7 @@ public class ButtonPrefs implements GuiItem @Override public void click(ClickType clickType) { - _profile.getPrefManager().openShop(_player); + _profile.getPrefManager().openMenu(_player); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java index 7a44aee11..48efd5a9d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/ui/QueuePage.java @@ -138,7 +138,7 @@ public class QueuePage extends ShopPageBase } if(party.getOwner().equalsIgnoreCase(player.getName())) { - List players = party.getMembers().stream().map(Bukkit::getPlayerExact).collect(Collectors.toList()); + List players = party.getMembers().stream().map(Bukkit::getPlayer).collect(Collectors.toList()); getPlugin().queuePlayer(gameType, players.toArray(new Player[players.size()])); } buildPage(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 32ba26c92..30c56aa5a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -1,24 +1,44 @@ package mineplex.hub.server; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.Set; - +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.brawl.fountain.BrawlShopProvider; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; import mineplex.core.party.event.PartySelectServerEvent; +import mineplex.core.portal.Portal; +import mineplex.core.shop.ShopBase; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.modules.StackerManager; +import mineplex.hub.queue.QueueManager; +import mineplex.hub.server.ui.LobbyShop; +import mineplex.hub.server.ui.QuickShop; +import mineplex.hub.server.ui.ServerCountSorter; +import mineplex.hub.server.ui.ServerNpcShop; +import mineplex.hub.server.ui.clans.ClansServerShop; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.MinecraftServer; +import mineplex.serverdata.data.ServerGroup; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -32,42 +52,16 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.party.Party; -import mineplex.core.party.PartyManager; -import mineplex.core.portal.Portal; -import mineplex.core.recharge.Recharge; -import mineplex.core.shop.ShopBase; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.core.repository.tokens.SimpleClanToken; -import mineplex.hub.HubManager; -import mineplex.hub.modules.StackerManager; -import mineplex.hub.queue.QueueManager; -import mineplex.hub.server.ui.LobbyShop; -import mineplex.hub.server.ui.QuickShop; -import mineplex.hub.server.ui.ServerCountSorter; -import mineplex.hub.server.ui.ServerNpcShop; -import mineplex.hub.server.ui.clans.ClansServerShop; -import mineplex.serverdata.Region; -import mineplex.serverdata.data.MinecraftServer; -import mineplex.serverdata.data.ServerGroup; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; -public class ServerManager extends MiniDbClientPlugin implements BrawlShopProvider +public class ServerManager extends MiniPlugin implements BrawlShopProvider { private static final Long FREE_PORTAL_TIMER = -1L; private static final Long BETA_PORTAL_TIMER = 120000L; @@ -107,7 +101,7 @@ public class ServerManager extends MiniDbClientPlugin implement public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager, BoosterManager boosterManager) { - super("Server Manager", plugin, clientManager); + super("Server Manager", plugin); _clientManager = clientManager; _donationManager = donationManager; @@ -151,79 +145,10 @@ public class ServerManager extends MiniDbClientPlugin implement return; } - final Player player = (Player)event.getEntity(); + Player player = (Player)event.getEntity(); + player.teleport(_hubManager.GetSpawn()); + runSyncLater(() -> {_quickShop.attemptShopOpen(player);}, 3L); - if (!Recharge.Instance.use(player, "Portal Server", 1000, false, false)) - return; - - long timeUntilPortal = getMillisecondsUntilPortal(player, false); - if (!_hubManager.CanPortal(player) || timeUntilPortal > 0) - { - player.closeInventory(); - - if (timeUntilPortal > 0) - { - player.playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 2, 2); - UtilPlayer.message(player, F.main("Server Portal", "You cannot join a server for " + C.cGreen + UtilTime.convertString(timeUntilPortal, 0, TimeUnit.SECONDS))); - } - - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1.5, true, 0.8, 0, 1.0, true); - - // Need to set their velocity again a tick later - // Setting Y-Velocity while in a portal doesn't seem to do anything... Science! - _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() - { - - @Override - public void run() - { - if (player != null && player.isOnline()) - { - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1, true, 0.5, 0, 1.0, true); - } - } - }); - - return; - } - - String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector()); - - if (serverKey != null) - { - List serverList = new ArrayList(); - - Collection servers = getServerList(serverKey); - if (servers != null && servers.size() > 0) - serverList.addAll(servers); - - int slots = 1; - - if (serverList.size() > 0) - { - slots = getRequiredSlots(player, serverList.get(0).ServerType); - } - - try - { - Collections.sort(serverList, new ServerSorter(slots)); - - for (ServerInfo serverInfo : serverList) - { - if ((serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup")) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slots) - { - selectServer(player, serverInfo); - return; - } - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - - UtilPlayer.message(player, F.main("Server Portal", "There are currently no joinable servers!")); - } } @EventHandler @@ -750,7 +675,7 @@ public class ServerManager extends MiniDbClientPlugin implement { int slots = 0; - if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player.getName()).OwnsUnknownPackage(serverType + " ULTRA")) + if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player).OwnsUnknownPackage(serverType + " ULTRA")) slots++; return slots; @@ -919,38 +844,9 @@ public class ServerManager extends MiniDbClientPlugin implement { return _serverNpcShopMap.get("Bawk Bawk Battles"); } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = " + accountId + ";"; - } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - SimpleClanToken clanToken = new SimpleClanToken(); - - while (resultSet.next()) - { - String clanName = resultSet.getString(1); - String clanRole = resultSet.getString(2); - String homeServer = resultSet.getString(3); - int clanId = resultSet.getInt(4); - clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId); - } - - Set(playerName, clanToken); - } - - @Override - protected SimpleClanToken addPlayer(String player) - { - return new SimpleClanToken(); - } public BoosterManager getBoosterManager() { return _boosterManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index a176467a8..711602e2d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -190,7 +190,7 @@ public class ServerGameMenu extends ShopPageBase add(40, Material.IRON_DOOR, C.cYellowB + "Mineplex Clans " + C.cGray + "Factions PvP", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA RELEASE", + (_extraValue ? C.cAquaB : C.cWhiteB) + "FULL RELEASE", C.Reset + "", C.Reset + "Equip custom skills and builds", C.Reset + "and join your clan to destroy", diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index 18df137c9..8a3feb293 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -119,7 +119,7 @@ public class ServerNpcPage extends ShopPageInventory lore = new ArrayList(); @@ -206,7 +206,7 @@ public class ServerNpcPage extends ShopPageInventory 0 && serverList.get(0).Name.contains("BETA"); boolean tournament = serverList.size() > 0 && serverList.get(0).Name.contains("T_"); boolean privateServer = serverList.size() > 0 && serverList.get(0).ServerType.equals("Player"); - boolean ownsUltraPackage = getClient().GetRank().has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA")); + boolean ownsUltraPackage = getClient().GetRank().has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA")); long portalTime = getPlugin().getMillisecondsUntilPortal(getPlayer(), beta); if (portalTime > 0) @@ -471,7 +471,7 @@ public class ServerNpcPage extends ShopPageInventory { public ClansServerPage(ServerManager plugin, ClansServerShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { - super(plugin, shop, clientManager, donationManager, "Clans Beta", player, 54); + super(plugin, shop, clientManager, donationManager, "Clans", player, 54); buildPage(); } @@ -38,29 +29,12 @@ public class ClansServerPage extends ShopPageBase servers = UtilAlg.sortSet(getPlugin().getServerList("Clans"), new Comparator() + Collection servers = UtilAlg.sortSet(getPlugin().getServerList("ClansHub"), new Comparator() { @Override public int compare(ServerInfo o1, ServerInfo o2) @@ -77,72 +51,12 @@ public class ClansServerPage extends ShopPageBase -{ - private ClanRepository _repository; - +{ public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Clans Beta"); - - _repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName()); + super(plugin, clientManager, donationManager, "Clans"); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java index 4bc36c039..4afa557f3 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java @@ -2,6 +2,7 @@ package mineplex.minecraft.game.classcombat.Class; import java.util.Collection; import java.util.HashMap; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.MiniClientPlugin; @@ -41,7 +42,7 @@ public class ClassManager extends MiniClientPlugin implements IClas private HashMap _classes; private HashMap _classSalesPackageIdMap; - private Object _clientLock = new Object(); + private final Object _clientLock = new Object(); private boolean _enabled = true; @@ -88,24 +89,16 @@ public class ClassManager extends MiniClientPlugin implements IClas public void OnClientWebResponse(ClientWebResponseEvent event) { ClientClassTokenWrapper token = new Gson().fromJson(event.GetResponse(), ClientClassTokenWrapper.class); - LoadClassBuilds(token); + LoadClassBuilds(token, event.getUniqueId()); } - private void LoadClassBuilds(ClientClassTokenWrapper token) + private void LoadClassBuilds(ClientClassTokenWrapper token, UUID uuid) { synchronized (_clientLock) { - Set(token.Name, - new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(token.Name), _donationManager - .Get(token.Name), token.DonorToken)); - } - } - - public ClientClass Get(String name) - { - synchronized (_clientLock) - { - return super.Get(name); + Set(uuid, + new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(uuid), _donationManager + .Get(uuid), token.DonorToken)); } } @@ -322,9 +315,9 @@ public class ClassManager extends MiniClientPlugin implements IClas } @Override - protected ClientClass addPlayer(String player) + protected ClientClass addPlayer(UUID uuid) { - return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(player), _donationManager.Get(player), null); + return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(uuid), _donationManager.Get(uuid), null); } public ClassRepository GetRepository() @@ -363,7 +356,7 @@ public class ClassManager extends MiniClientPlugin implements IClas } } - ClientClass client = Get(target.getName()); + ClientClass client = Get(target.getUniqueId()); if (client == null) event.getPlayer().sendMessage(target.getName() + " does not have a ClientClass."); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index bddac25dd..123874341 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -232,7 +232,7 @@ public class ClientClass public void SaveActiveCustomBuild() { - _savingCustomBuild.PlayerName = _client.GetPlayerName(); + _savingCustomBuild.PlayerName = _client.getName(); _classFactory.GetRepository().SaveCustomBuild(_savingCustomBuild); _savingCustomBuild = null; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index 7aecaade1..2da9df000 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -33,7 +33,7 @@ public class Blink extends SkillActive { private HashMap _loc = new HashMap(); private HashMap _blinkTime = new HashMap(); - + public Blink(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, int energy, int energyMod, @@ -170,6 +170,12 @@ public class Blink extends SkillActive public void Deblink(Player player, int level) { + Location target = _loc.remove(player); + if (!player.getWorld().equals(target.getWorld())) + { + UtilPlayer.message(player, F.main(GetClassType().name(), "You cannot use " + F.skill("De-Blink") + " between worlds!")); + return; + } UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill("De-Blink") + ".")); //Smoke Trail @@ -177,8 +183,6 @@ public class Blink extends SkillActive double curRange = 0; - Location target = _loc.remove(player); - boolean done = false; while (!done) { @@ -206,6 +210,9 @@ public class Blink extends SkillActive done = true; } + target.setYaw(player.getLocation().getYaw()); + target.setPitch(player.getLocation().getPitch()); + player.teleport(target); player.setFallDistance(0); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java index c00d10c69..128ee2a11 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java @@ -29,6 +29,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -213,10 +214,11 @@ public class Evade extends SkillActive { Player player = activeIter.next(); - if (!player.isOnline() || !player.isBlocking() || UtilTime.elapsed(_active.get(player), 750)) + if (!player.isOnline() || !player.isBlocking() || UtilTime.elapsed(_active.get(player), 1000)) { activeIter.remove(); UtilPlayer.message(player, F.main(GetClassType().name(), "You failed to " + F.skill(GetName()) + ".")); + Recharge.Instance.useForce(player, GetName(), 10000l, true); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java index a87c6fc53..8c7fe10d2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Sound; @@ -110,14 +111,14 @@ public class Illusion extends SkillActive skel.getEquipment().setItemInHand(Math.random() > 0.5 ? player.getItemInHand() : new ItemStack(Material.IRON_AXE)); //Get in range - ArrayList inRange = new ArrayList(); + ArrayList inRange = new ArrayList<>(); for (Player other : UtilServer.getPlayers()) if (UtilMath.offset2d(skel, other) < 70) - inRange.add(other); + inRange.add(other.getUniqueId()); //Disguise DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer)player).getHandle().getProfile()); - Factory.Disguise().disguise(disguise, inRange.toArray(new Player[inRange.size()])); + Factory.Disguise().disguise(disguise, attempted -> inRange.contains(attempted.getUniqueId())); //Invis Factory.Condition().Factory().Cloak(GetName(), player, player, 2 + 1*level, false, true); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 1918c5cf4..f293f5c7f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerDropItemEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -28,7 +29,6 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import net.minecraft.server.v1_8_R3.Material; public class Recall extends Skill { @@ -69,6 +69,12 @@ public class Recall extends Skill event.setCancelled(true); + if (UtilBlock.water(player.getLocation().getBlock())) + { + UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water.")); + return; + } + //Check Allowed SkillTriggerEvent trigger = new SkillTriggerEvent(player, GetName(), GetClassType()); Bukkit.getServer().getPluginManager().callEvent(trigger); @@ -92,6 +98,10 @@ public class Recall extends Skill { return; } + if (!player.getWorld().equals(locs.getLast().getWorld())) + { + return; + } //Heal double newHealth = Math.min(health.getLast(), player.getHealth() + 3 + level); player.setHealth(newHealth); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java index 7cac7e593..6aaaba4a2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java @@ -6,12 +6,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.UtilGear; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ViperStrikes extends Skill { @@ -21,8 +23,8 @@ public class ViperStrikes extends Skill SetDesc(new String[] { - "Your attacks give enemies", - "Shock, Slow 1 and Poison 1", + "Your attacks give", + "enemies Poison 1", "for #0#1 seconds." }); } @@ -47,10 +49,9 @@ public class ViperStrikes extends Skill LivingEntity damagee = event.GetDamageeEntity(); if (damagee == null) return; - - //Confuse - Factory.Condition().Factory().PoisonShock(GetName(), damagee, damager, level, false); - Factory.Condition().Factory().Slow(GetName(), damagee, damager, level, 0, false, false, true, false); + + Factory.Damage().NewDamageEvent(damagee, damager, null, DamageCause.POISON, 0, false, true, true, damager.getName(), GetName()); + damagee.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * (2 + level), 0)); //Sound damager.getWorld().playSound(damager.getLocation(), Sound.SPIDER_IDLE, 1f, 2f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 800547f8b..3422b690b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -9,32 +9,34 @@ import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEvent; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillCharge; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossExpireEvent; @@ -90,7 +92,7 @@ public class BlockToss extends SkillCharge implements IThrown @Override public String GetRechargeString() { - return "Recharge: " + "#4#-0.5 Seconds"; + return "Recharge: " + "#5.5#-0.5 Seconds"; } @EventHandler @@ -193,7 +195,22 @@ public class BlockToss extends SkillCharge implements IThrown //Effect player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, block.getMaterial().getId()); } - + + @EventHandler + public void Damage(EntityDamageByEntityEvent event) + { + Entity vehicle = event.getEntity().getVehicle(); + + if (_holding.containsKey(vehicle)) + { + Player attacker = (Player) event.getDamager(); + + //Forward Damage + Factory.Damage().NewDamageEvent((Player) vehicle, attacker, Factory.Damage().GetProjectile(event), + event.getCause(), event.getDamage(), true, false, false, null, null, event.isCancelled()); + } + } + @EventHandler public void Throw(UpdateEvent event) { @@ -224,7 +241,7 @@ public class BlockToss extends SkillCharge implements IThrown } //Throw - if (!cur.isBlocking()) + if (!cur.isBlocking() || (_charge.containsKey(cur) && _charge.get(cur) >= 1)) throwSet.add(cur); //Charged Tick @@ -241,7 +258,7 @@ public class BlockToss extends SkillCharge implements IThrown for (Player cur : throwSet) { Recharge.Instance.recharge(cur, GetName()); - Recharge.Instance.use(cur, GetName(), 4000 - (500 * getLevel(cur)), false, true); + Recharge.Instance.use(cur, GetName(), 5500 - (500 * getLevel(cur)), false, true); FallingBlock block = _holding.remove(cur); float charge = _charge.remove(cur); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java index 3e384a64c..1ae7b8f6e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java @@ -24,7 +24,7 @@ public class CripplingBlow extends Skill { "Your powerful axe attacks give", "targets Slow 2 for 1.5 second,", - "as well as 50% less knockback." + "as well as 25% less knockback." }); } @@ -57,7 +57,7 @@ public class CripplingBlow extends Skill //Damage event.AddMod(damager.getName(), GetName(), 0, true); - event.AddKnockback(GetName(), 0.5); + event.AddKnockback(GetName(), 0.75); //Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(damager, GetName(), ClassType.Brute, damagee)); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java index 915c78b7a..1ce818b5f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java @@ -73,7 +73,7 @@ public class DwarfToss extends SkillActive { if (_used.contains(player)) return false; - + return true; } @@ -96,7 +96,13 @@ public class DwarfToss extends SkillActive { int level = getLevel(player); if (level == 0) return false; - + + if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9) + { + UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water.")); + return false; + } + //Check Material if (player.getItemInHand() != null) if (!_itemSet.contains(player.getItemInHand().getType())) @@ -337,6 +343,9 @@ public class DwarfToss extends SkillActive target.leaveVehicle(); final double mult = (1.8) * timeScale; + //Protection + Factory.Condition().Factory().Invulnerable(GetName(), target, target, 1.25, false, false); + //Delay Bukkit.getScheduler().scheduleSyncDelayedTask(Factory.getPlugin(), new Runnable() { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java index 373caea1f..588571fdc 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java @@ -101,16 +101,16 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Release Charge else if (_charge.containsKey(cur)) { - float charge = _charge.remove(cur); + double charge = _charge.remove(cur); //Action Item item = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(131)); UtilAction.velocity(item, cur.getLocation().getDirection(), - 1 + charge , false, 0, 0.2, 20, false); + 1 + charge, false, 0, 0.2, 20, false); Factory.Projectile().AddThrow(item, cur, this, -1, true, true, true, true, - Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f); - + Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f, charge); + //Inform UtilPlayer.message(cur, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + ".")); @@ -148,14 +148,14 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Pull UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), - 1.2 + (0.3 * level), false, 0, 0.7, 1.2, true); + velocity, false, 0, 0.7, 1.2, true); //Condition Factory.Condition().Factory().Falling(GetName(), target, player, 10, false, true); //Damage Event Factory.Damage().NewDamageEvent(target, player, null, - DamageCause.CUSTOM, 5 + level, false, true, false, + DamageCause.CUSTOM, (5 + level) * data.getCharge(), false, true, false, player.getName(), GetName()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java index cab4d77fa..1f5d560b9 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java @@ -21,7 +21,7 @@ public class Intimidation extends Skill SetDesc(new String[] { "You intimidate nearby enemies;", - "Enemies within #3#3 blocks receive Slow 1.", + "Enemies within #4#2 blocks receive Slow 1.", }); } @@ -36,7 +36,7 @@ public class Intimidation extends Skill int level = getLevel(cur); if (level == 0) continue; - HashMap targets = UtilPlayer.getInRadius(cur.getLocation(), 3 + (level * 3)); + HashMap targets = UtilPlayer.getInRadius(cur.getLocation(), 3 + (level * 2)); for (Player other : targets.keySet()) if (!other.equals(cur)) if (Factory.Relation().canHurt(cur, other)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java index bf2d6aa75..14ae0fcf1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java @@ -52,7 +52,7 @@ public class AxeThrow extends SkillActive implements IThrown SetDesc(new String[] { "Throw your axe with #0.7#0.1 velocity, ", - "dealing #5.5#0.5 damage.", + "dealing #4.5#0.5 damage.", "", "You pull your axe back to you when it", "collides with anything.", @@ -107,7 +107,7 @@ public class AxeThrow extends SkillActive implements IThrown if (level <= 0) return; - double damage = 5.5 + 0.5 * level; + double damage = 4.5 + 0.5 * level; //Damage Event Factory.Damage().NewDamageEvent(target, data.getThrower(), null, diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java index 9e743cea2..cf9845e03 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java @@ -46,7 +46,7 @@ public class HiltSmash extends SkillActive SetDesc(new String[] { "Smash the hilt of your sword into", - "your opponent, dealing #2#1 damage", + "your opponent, dealing #1#1 damage", "and Slow 3 for #0.5#0.5 seconds." }); } @@ -153,7 +153,7 @@ public class HiltSmash extends SkillActive //Damage Event Factory.Damage().NewDamageEvent((LivingEntity)ent, player, null, - DamageCause.CUSTOM, 2 + level, false, true, false, + DamageCause.CUSTOM, 1 + level, false, true, false, player.getName(), GetName()); //Sound diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java index 1e29be118..5d62eac5f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java @@ -30,7 +30,7 @@ public class Swordsmanship extends Skill { "Prepare a powerful sword attack;", "You gain 1 Charge every #5#-1 seconds.", - "You can store a maximum of #0#1 Charges.", + "You can store a maximum of #1#1 Charges.", "", "When you next attack, your damage is", "increased by the number of your Charges,", @@ -79,7 +79,7 @@ public class Swordsmanship extends Skill if (!Recharge.Instance.use(cur, GetName(), 5000 - (1000 * level), false, false)) continue; - int max = level; + int max = 1 + level; int charge = 1; if (_charges.containsKey(cur)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java index 57bf77854..e27680712 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java @@ -67,7 +67,7 @@ public class Blizzard extends SkillActive @Override public String GetEnergyString() { - return "Energy: #34#-2 per Second"; + return "Energy: #42#-2 per Second"; } @Override @@ -114,7 +114,7 @@ public class Blizzard extends SkillActive } //Energy - if (!Factory.Energy().Use(cur, GetName(), 1.7 - (0.1 * level), true, true)) + if (!Factory.Energy().Use(cur, GetName(), 2.1 - (0.1 * level), true, true)) { _active.remove(cur); continue; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java index 8fd59a6d1..e61fd8892 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java @@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -133,6 +134,10 @@ public class FissureData return false; if (block.getRelative(BlockFace.UP).getType().toString().contains("BANNER")) return false; + if (block.getType() == Material.ANVIL) + return false; + if (block.getRelative(BlockFace.UP).getType() == Material.ANVIL) + return false; Block up = block.getRelative(0, _height + 1, 0); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java index 2c2c0f118..a04b31ebc 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java @@ -48,7 +48,7 @@ public class IcePrison extends SkillActive implements IThrown { "Launch an icy orb. When it collides,", "it creates a hollow sphere of ice", - "thats lasts for #3#1.5 seconds.", + "thats lasts for #3#1 seconds.", }); } @@ -171,7 +171,7 @@ public class IcePrison extends SkillActive implements IThrown if (!UtilBlock.airFoliage(freeze)) return; - long time = 3500 + (1500 * level); + long time = 3500 + (1000 * level); int yDiff = freeze.getY() - mid.getY(); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java index 043333409..d0f884988 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java @@ -152,6 +152,12 @@ public class Immolate extends Skill Remove(cur); continue; } + + if (cur.getLocation().getBlock().getType() == Material.WATER || cur.getLocation().getBlock().getType() == Material.STATIONARY_WATER) + { + Remove(cur); + continue; + } //Energy if (!Factory.Energy().Use(cur, GetName(), 0.65 - (level * 0.05), true, true)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java index 9ef227c18..2c07078cb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java @@ -53,7 +53,7 @@ public class Inferno extends SkillActive @Override public String GetEnergyString() { - return "Energy: #34#-2 per Second"; + return "Energy: #42#-2 per Second"; } @Override @@ -100,7 +100,7 @@ public class Inferno extends SkillActive } //Energy - if (!Factory.Energy().Use(cur, GetName(), 1.7 - (0.1 * level), true, false)) + if (!Factory.Energy().Use(cur, GetName(), 2.1 - (0.1 * level), true, false)) { _active.remove(cur); continue; @@ -113,7 +113,7 @@ public class Inferno extends SkillActive itemStack.setItemMeta(meta); Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), itemStack); - Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), 1, GetName(), false); + Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), .25, GetName(), false); fire.teleport(cur.getEyeLocation()); double x = 0.07 - (UtilMath.r(14)/100d); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java index 837fb8ada..4ad73365d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java @@ -42,8 +42,8 @@ public class LifeBonds extends Skill { "Drop Axe/Sword to Toggle.", "", - "Transfers life from healthy allies", - "to nearby allies with less health.", + "Transfers life from yourself to", + "nearby allies with less health.", "", "Transfers #0.5#0.5 health every second.", "Maximum range of #3#3 Blocks from user." @@ -188,9 +188,6 @@ public class LifeBonds extends Skill int level = getLevel(cur); //Bonds - Player highest = null; - double highestHp = 0; - Player lowest = null; double lowestHp = 20; @@ -199,12 +196,6 @@ public class LifeBonds extends Skill if (Factory.Relation().canHurt(cur, other) && !other.equals(cur)) continue; - if (highest == null || other.getHealth() > highestHp) - { - highest = other; - highestHp = other.getHealth(); - } - if (lowest == null || other.getHealth() < lowestHp) { lowest = other; @@ -213,18 +204,18 @@ public class LifeBonds extends Skill } //Nothing to Transfer - if (highest == null || lowest == null || highest.equals(lowest) || highestHp - lowestHp < 2) + if (cur.equals(lowest) || cur.getHealth() - lowestHp < 2) continue; double amount = 0.5 + (0.5 * level); - amount = Math.min((double)(highestHp - lowestHp) / 2d, amount); + amount = Math.min((double)(cur.getHealth() - lowestHp) / 2d, amount); //Steal - UtilPlayer.health(highest, -amount); + UtilPlayer.health(cur, -amount); //Hearts - _hearts.add(new LifeBondsData(highest.getLocation().add(0, 0.8, 0), lowest, amount)); + _hearts.add(new LifeBondsData(cur.getLocation().add(0, 0.8, 0), lowest, amount)); //Effect //highest.getWorld().playEffect(highest.getLocation(), Effect.STEP_SOUND, 18); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java index 027fee62a..79cbdc825 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java @@ -1,31 +1,36 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; -import org.bukkit.*; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.SkillActive; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.common.util.F; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.minecraft.game.classcombat.Skill.SkillActive; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; - -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerEvent; public class LightningOrb extends SkillActive implements IThrown { @@ -99,7 +104,7 @@ public class LightningOrb extends SkillActive implements IThrown public void Skill(Player player, int level) { //Action - Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(57)); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),new ItemBuilder(Material.DIAMOND_BLOCK).setTitle(UtilMath.random.nextDouble() + "").build()); item.setVelocity(player.getLocation().getDirection()); Factory.Projectile().AddThrow(item, player, this, 5000 - (400 * level), true, true, false, false, Sound.FIZZ, 0.6f, 1.6f, ParticleType.FIREWORKS_SPARK, UpdateType.TICK, 0.4f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java index 4ad21a66b..e107aca50 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java @@ -22,7 +22,7 @@ public class MagmaBlade extends Skill SetDesc(new String[] { "Your sword deals an additional,", - "#0.5#0.5 damage to burning opponents,", + "#0.25#0.25 damage to burning opponents,", "but also extinguishes them.", }); } @@ -54,7 +54,7 @@ public class MagmaBlade extends Skill if (level == 0) return; //Damage - event.AddMod(damager.getName(), GetName(), 0.5 + 0.5 * level, true); + event.AddMod(damager.getName(), GetName(), 0.25 + 0.25 * level, true); //Effect damager.getWorld().playSound(damager.getLocation(), Sound.FIZZ, 0.8f, 0f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java index 77218628b..4a0f2ede7 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java @@ -18,18 +18,24 @@ import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.BlockIterator; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class Sharpshooter extends Skill { + private WeakHashMap _missedCount = new WeakHashMap(); private WeakHashMap _hitCount = new WeakHashMap(); - private HashMap _arrows = new HashMap(); + private HashMap _arrows = new HashMap(); public Sharpshooter(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -53,9 +59,15 @@ public class Sharpshooter extends Skill int level = getLevel((Player)event.getEntity()); if (level == 0) return; - + + if (!(event.getProjectile() instanceof Arrow)) + { + System.out.println(GetName() + " : " + event.getEntity().getName() + " shot bow but resulting projectile was now Arrow?!?!?!?"); + return; + } + //Store - _arrows.put(event.getProjectile(), (Player)event.getEntity()); + _arrows.put((Arrow) event.getProjectile(), (Player)event.getEntity()); } @EventHandler(priority = EventPriority.HIGH) @@ -98,9 +110,46 @@ public class Sharpshooter extends Skill projectile.remove(); + _missedCount.remove(player); + Recharge.Instance.useForce(player, GetName() + " Timer", 5000); } + @EventHandler + public void missReset(ProjectileHitEvent event) + { + final Projectile projectile = event.getEntity(); + Factory.runSyncLater(() -> { + if (!projectile.isDead() && _arrows.containsKey(projectile)) + { + Player shooter = (Player) projectile.getShooter(); + + if (!_hitCount.containsKey(shooter)) + { + return; + } + + if (!_missedCount.containsKey(shooter)) + { + _missedCount.put(shooter, Integer.valueOf(1)); + } + else + { + _missedCount.put(shooter, Integer.valueOf(_missedCount.get(shooter).intValue() + 1)); + + // Reset + if (_missedCount.get(shooter).intValue() >= 2) + { + _hitCount.remove(shooter); + _missedCount.remove(shooter); + UtilPlayer.message(shooter, F.main(GetClassType().name(), GetName() + " : " + F.elem("Damage Bonus Reset"))); + shooter.playSound(shooter.getLocation(), Sound.NOTE_PLING, 1f, 0.75f); + } + } + } + }, 3l); + } + @EventHandler public void resetViaTime(UpdateEvent event) { @@ -148,5 +197,6 @@ public class Sharpshooter extends Skill public void Reset(Player player) { _hitCount.remove(player); + _missedCount.remove(player); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java index db7e4e34c..310146f5a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java @@ -1,28 +1,26 @@ package mineplex.minecraft.game.classcombat.Skill.Ranger; import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class VitalitySpores extends Skill { - private HashMap _lastMove = new HashMap(); + private HashMap _lastDamage = new HashMap<>(); public VitalitySpores(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -30,47 +28,52 @@ public class VitalitySpores extends Skill SetDesc(new String[] { - "While standing still, forest spores", - "heal you for #0#0.5 health per 2 seconds." + "After getting hit, if no damage is taken", + "for 10 Seconds then you will receive", + "Regeneration #2#0 for #5#1 Seconds", }); } @EventHandler - public void playerMove(PlayerMoveEvent event) + public void damage(CustomDamageEvent event) { - if (doesUserHaveSkill(event.getPlayer()) && UtilMath.offset(event.getFrom(), event.getTo()) > 0) - _lastMove.put(event.getPlayer(), System.currentTimeMillis()); + if (doesUserHaveSkill(event.GetDamageePlayer())) + { + if (event.GetDamageePlayer().hasPotionEffect(PotionEffectType.REGENERATION)) + { + event.GetDamageePlayer().removePotionEffect(PotionEffectType.REGENERATION); + } + else + { + _lastDamage.put(event.GetDamageePlayer(), Long.valueOf(System.currentTimeMillis())); + } + } } @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - - for (Player cur : GetUsers()) - { - int level = getLevel(cur); - if (level == 0) continue; - - if (!_lastMove.containsKey(cur)) - continue; - - if (UtilTime.elapsed(_lastMove.get(cur), 2000)) + } + + Iterator> iterator = _lastDamage.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + + if (UtilTime.elapsed(entry.getValue().longValue(), 10000)) { - UtilPlayer.health(cur, 0.5 * level); - - UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation().add(UtilAlg.getBehind(cur.getLocation().getDirection().multiply(0.5))), 0, 0.2f, 0, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - - _lastMove.put(cur, System.currentTimeMillis()); - } + iterator.remove(); + entry.getKey().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, (20 * (5 + getLevel(entry.getKey()))), 1)); + } } } @Override public void Reset(Player player) { - _lastMove.remove(player); + _lastDamage.remove(player); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java index 51e412beb..195ff7a27 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java @@ -45,7 +45,7 @@ public class WolfsPounce extends SkillChargeSword "Taking damage cancels charge.", "", "Colliding with another player", - "mid-air deals up to #4#1 damage", + "mid-air deals up to #2#1 damage", "and Slow 2 for 3 seconds." }); @@ -128,7 +128,7 @@ public class WolfsPounce extends SkillChargeSword if (_chargeStore.containsKey(damager)) charge = _chargeStore.remove(damager); - int damage = (int)((4 + getLevel(damager)) * charge); + int damage = (int)((2 + getLevel(damager)) * charge); //Damage Event Factory.Damage().NewDamageEvent(damagee, damager, null, diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java index 7fd52db63..8bc9f565b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java @@ -221,10 +221,6 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Fitness(this, "Mana Pool", ClassType.Mage, SkillType.GlobalPassive, 1, 3)); AddSkill(new Recharge(this, "Mana Regeneration", ClassType.Mage, SkillType.GlobalPassive, 1, 3)); - AddSkill(new Fitness(this, "Fitness", ClassType.Assassin, SkillType.GlobalPassive, 1, 3)); - AddSkill(new Recharge(this, "Rest", ClassType.Assassin, SkillType.GlobalPassive, 1, 3)); - - //AddSkill(new Stamina(this, "Stamina", ClassType.Global, SkillType.GlobalPassive, 1, 1)); //AddSkill(new Swim(this, "Swim", ClassType.Global, SkillType.GlobalPassive, 1, 1)); } @@ -235,9 +231,9 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory //Sword AddSkill(new Evade(this, "Evade", ClassType.Assassin, SkillType.Sword, - 1, 4, + 2, 1, 0, 0, - 6500, -500, true, + 2500, -500, true, new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -337,7 +333,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Takedown(this, "Takedown", ClassType.Brute, SkillType.Axe, 1, 5, 0, 0, - 21000, -1000, true, + 17000, -1000, true, new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -374,7 +370,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Riposte(this, "Riposte", ClassType.Knight, SkillType.Sword, 1, 5, 0, 0, - 11000, -1000, false, + 15000, -1000, false, new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -411,7 +407,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new AxeThrow(this, "Roped Axe Throw", ClassType.Knight, SkillType.Axe, 1, 5, 0, 0, - 3300, -300, true, + 4300, -300, true, new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java index 4ebc47b56..00d5ef316 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java @@ -6,7 +6,8 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; @@ -155,7 +156,7 @@ public abstract class ItemUsable extends Item implements IThrown if (_throwExpire >= 0) expire = _throwExpire; - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(GetType())); + org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), new ItemBuilder(GetType()).setTitle(UtilMath.random.nextDouble() + "").build()); UtilAction.velocity(ent, player.getLocation().getDirection(), _throwPower, false, 0, 0.2, 10, false); Factory.Throw().AddThrow(ent, player, this, expire, _throwPlayer, _throwPlayer, _throwBlock, _throwIdle, _throwPickup, 0.5f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java index 023afeb5c..55e9929bb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java @@ -88,6 +88,6 @@ public class Web extends ItemUsable WebTossEvent webEvent = new WebTossEvent(thrower, location); Bukkit.getPluginManager().callEvent(webEvent); - return !webEvent.isCancelled() && UtilBlock.airFoliage(location.getBlock()); + return !webEvent.isCancelled() && UtilBlock.airFoliage(location.getBlock()) && !location.getBlock().getType().toString().contains("BANNER"); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java index 211e1d6de..d29892b44 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java @@ -1,5 +1,17 @@ package mineplex.minecraft.game.classcombat.shop; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.IPvpClass; +import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; +import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent; +import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Sound; @@ -9,20 +21,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.account.CoreClientManager; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; -import mineplex.minecraft.game.classcombat.Class.ClientClass; -import mineplex.minecraft.game.classcombat.Class.IPvpClass; -import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; -import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent; -import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage; - public class ClassCombatShop extends ShopBase { private NautHashMap _playerInventoryMap = new NautHashMap(); @@ -34,14 +32,14 @@ public class ClassCombatShop extends ShopBase public ClassCombatShop(ClassShopManager plugin, CoreClientManager clientManager, DonationManager donationManager, boolean skillsOnly, String name) { - super(plugin, clientManager, donationManager, name, CurrencyType.GEM); + super(plugin, clientManager, donationManager, name); _skillsOnly = skillsOnly; } public ClassCombatShop(ClassShopManager plugin, CoreClientManager clientManager, DonationManager donationManager, boolean skillsOnly, String name, IPvpClass iPvpClass, boolean hub) { - super(plugin, clientManager, donationManager, name, CurrencyType.GEM); + super(plugin, clientManager, donationManager, name); _gameClass = iPvpClass; _takeAwayStuff = true; _skillsOnly = skillsOnly; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index 60025020b..bfa289da2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -1,16 +1,14 @@ package mineplex.minecraft.game.classcombat.shop.page; -import java.util.ArrayList; -import java.util.List; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; @@ -20,20 +18,18 @@ import mineplex.minecraft.game.classcombat.Skill.ISkill; import mineplex.minecraft.game.classcombat.item.Item; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; -import mineplex.minecraft.game.classcombat.shop.button.DeselectItemButton; -import mineplex.minecraft.game.classcombat.shop.button.PurchaseItemButton; -import mineplex.minecraft.game.classcombat.shop.button.PurchaseSkillButton; -import mineplex.minecraft.game.classcombat.shop.button.SelectItemButton; -import mineplex.minecraft.game.classcombat.shop.button.SelectSkillButton; +import mineplex.minecraft.game.classcombat.shop.button.*; import mineplex.minecraft.game.classcombat.shop.salespackage.ItemSalesPackage; import mineplex.minecraft.game.classcombat.shop.salespackage.SkillSalesPackage; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.List; + public class SkillPage extends ShopPageBase { private IPvpClass _pvpClass; @@ -392,18 +388,13 @@ public class SkillPage extends ShopPageBase public void PurchaseSkill(Player player, ISkill skill) { - getShop().openPageForPlayer(player, new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() - { - public void run() - { - buildPage(); - } - }, this, new SkillSalesPackage(skill), CurrencyType.GEM, player)); + SalesPackageBase salesPackage = new SkillSalesPackage(skill); + getShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, getDonationManager(), this::buildPage), salesPackage.buildIcon())); } private boolean isSkillLocked(ISkill skill) { - if (skill.IsFree() || getClientManager().Get(getPlayer().getName()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + skill.GetName())) + if (skill.IsFree() || getClientManager().Get(getPlayer()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions " + skill.GetName())) return false; return true; @@ -411,7 +402,7 @@ public class SkillPage extends ShopPageBase private boolean isItemLocked(Item item) { - if (item.isFree() || getClientManager().Get(getPlayer().getName()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage("Champions " + item.GetName())) + if (item.isFree() || getClientManager().Get(getPlayer()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).OwnsUnknownPackage("Champions " + item.GetName())) return false; return true; @@ -419,13 +410,8 @@ public class SkillPage extends ShopPageBase public void PurchaseItem(Player player, Item item) { - getShop().openPageForPlayer(player, new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() - { - public void run() - { - buildPage(); - } - }, this, new ItemSalesPackage(item), CurrencyType.GEM, player)); + SalesPackageBase salesPackage = new ItemSalesPackage(item); + getShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, getDonationManager(), this::buildPage), salesPackage.buildIcon())); } public void SelectItem(Player player, Item item) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java index d30d81984..3ce30af02 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java @@ -1,11 +1,9 @@ package mineplex.minecraft.game.classcombat.shop.salespackage; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; import mineplex.minecraft.game.classcombat.item.Item; +import org.bukkit.Material; public class ItemSalesPackage extends SalesPackageBase { @@ -14,12 +12,6 @@ public class ItemSalesPackage extends SalesPackageBase super("Champions " + item.GetName(), Material.BOOK, (byte)0, item.GetDesc(), item.GetGemCost()); Free = item.isFree(); KnownPackage = false; - CurrencyCostMap.put(CurrencyType.GEM, item.GetGemCost()); - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - + CurrencyCostMap.put(GlobalCurrency.GEM, item.GetGemCost()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java index fe3873a3d..420427e31 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java @@ -1,11 +1,9 @@ package mineplex.minecraft.game.classcombat.shop.salespackage; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; import mineplex.minecraft.game.classcombat.Skill.ISkill; +import org.bukkit.Material; public class SkillSalesPackage extends SalesPackageBase { @@ -14,12 +12,6 @@ public class SkillSalesPackage extends SalesPackageBase super("Champions " + skill.GetName(), Material.BOOK, (byte)0, skill.GetDesc(0), skill.GetGemCost()); Free = skill.IsFree(); KnownPackage = false; - CurrencyCostMap.put(CurrencyType.GEM, skill.GetGemCost()); - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - + CurrencyCostMap.put(GlobalCurrency.GEM, skill.GetGemCost()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java new file mode 100644 index 000000000..0f06c5d90 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java @@ -0,0 +1,41 @@ +package mineplex.minecraft.game.core.boss; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.event.Listener; + +public abstract class BossPassive implements Listener +{ + private T _creature; + + public BossPassive(T creature) + { + _creature = creature; + Bukkit.getPluginManager().registerEvents(this, creature.getEvent().getPlugin()); + } + + public int getCooldown() + { + return 3; + } + + public Y getEntity() + { + return (Y) getBoss().getEntity(); + } + + public T getBoss() + { + return _creature; + } + + public Location getLocation() + { + return getEntity().getLocation(); + } + + public abstract boolean isProgressing(); + + public abstract void tick(); +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index a41376eae..6746f9187 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.boss; import java.util.UUID; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseInsentient; @@ -27,7 +28,7 @@ public abstract class EventCreature implements Listener // Spawn Data private T _entity; private Class _entityClass; - private Location _spawnLocation; + private Location _spawnLocation, _lastLocation; // Creature Data private String _name; @@ -36,6 +37,7 @@ public abstract class EventCreature implements Listener private double _health; private double _maxHealth; private boolean _showHealthName; + private long _teleportHome; // Fight Data private long _lastDamaged; @@ -54,6 +56,7 @@ public abstract class EventCreature implements Listener _health = health; _maxHealth = health; _showHealthName = true; + _teleportHome = -1L; } public double getDifficulty() @@ -182,6 +185,11 @@ public abstract class EventCreature implements Listener { return _spawnLocation; } + + public Location getLastKnownLocation() + { + return _lastLocation; + } public void setSpawnLocation(Location spawnLocation) { @@ -273,6 +281,32 @@ public abstract class EventCreature implements Listener System.out.println("Respawning " + getName() + " because it is null or dead"); spawnEntity(); } + + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 30) + { + if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome) + { + _entity.teleport(_spawnLocation); + _teleportHome = -1; + } + else + { + _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); + if (_teleportHome == -1) + { + _teleportHome = System.currentTimeMillis() + 5000; + } + } + } + else + { + if (_teleportHome != -1) + { + _teleportHome = -1; + } + } + + _lastLocation = _entity.getLocation(); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java new file mode 100644 index 000000000..892827cc8 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java @@ -0,0 +1,31 @@ +package mineplex.minecraft.game.core.boss; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class EventCreatureDeathEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private EventCreature _creature; + + public EventCreatureDeathEvent(EventCreature creature) + { + _creature = creature; + } + + public EventCreature getCreature() + { + return _creature; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index 6f10d660c..70c8f7a17 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -7,16 +7,6 @@ import java.util.List; import java.util.Random; import java.util.Set; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; - import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestoreMap; import mineplex.core.common.block.BlockData; @@ -33,13 +23,24 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilWorld; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; -import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.scoreboard.elements.ScoreboardElement; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + public abstract class WorldEvent implements Listener, ScoreboardElement { // 20 Minutes @@ -173,7 +174,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement { customStart(); } - + @Override public List getLines(ScoreboardManager manager, Player player, List out) { @@ -269,6 +270,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement public void removeCreature(EventCreature creature) { + Bukkit.getPluginManager().callEvent(new EventCreatureDeathEvent(creature)); HandlerList.unregisterAll(creature); _creatures.remove(creature); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java new file mode 100644 index 000000000..d653ca539 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java @@ -0,0 +1,96 @@ +package mineplex.minecraft.game.core.boss.broodmother; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.UtilMath; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.ItemSpawnEvent; + +public class SpiderBoss extends WorldEvent +{ + public SpiderBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + { + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation); + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + Block block = event.getBlock(); + + if (UtilMath.offset2d(event.getBlock().getLocation(), getCenterLocation()) > 40) + { + return; + } + + if (block.getType() != Material.WEB) + { + return; + } + + event.setCancelled(true); + event.getBlock().setType(Material.AIR); + } + + @Override + protected void customStart() + { + Bukkit.broadcastMessage("Custom Start"); + spawnSpider(getCenterLocation()); + setState(EventState.LIVE); + announceStart(); + } + + /** + * Check if this spider boss has been defeated + */ + private void checkDeath() + { + if (getCreatures().size() == 0) + { + setState(EventState.COMPLETE); + Bukkit.broadcastMessage("FINISHED!"); + } + } + + @Override + public void removeCreature(EventCreature creature) + { + super.removeCreature(creature); + + if (creature instanceof SpiderCreature) + { + checkDeath(); + } + } + + public SpiderMinionCreature spawnMinion(Location location) + { + if (getState() != EventState.LIVE) + { + return null; + } + SpiderMinionCreature minionCreature = new SpiderMinionCreature(this, location, 15); + registerCreature(minionCreature); + return minionCreature; + } + + private SpiderCreature spawnSpider(Location location) + { + SpiderCreature spiderCreature = new SpiderCreature(this, location, 2500); + registerCreature(spiderCreature); + return spiderCreature; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java similarity index 88% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java index 8c813ed28..a4b657260 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java @@ -1,10 +1,11 @@ -package mineplex.minecraft.game.core.boss.spider; +package mineplex.minecraft.game.core.boss.broodmother; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; import org.bukkit.Bukkit; @@ -12,37 +13,34 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Pig; import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.util.Vector; +import com.google.common.collect.Lists; + import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.disguise.disguises.DisguiseSpider; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderCeilingCling; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggScatter; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderPoisonBarrage; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebBarrage; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebStomp; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderCeilingCling; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggScatter; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggplosm; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderPoisonBarrage; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebBarrage; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebStomp; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class SpiderCreature extends EventCreature +public class SpiderCreature extends EventCreature { private ArrayList _currentAbilities = new ArrayList(); private int _lastAbility; @@ -55,24 +53,11 @@ public class SpiderCreature extends EventCreature public SpiderCreature(SpiderBoss boss, Location location, double maxHealth) { - super(boss, location, "Brood Mother", true, maxHealth, Pig.class); + super(boss, location, "Brood Mother", true, maxHealth, Spider.class); spawnEntity(); } - @Override - public void setEntity(Pig entity) - { - super.setEntity(entity); - - if (entity != null) - { - DisguiseSpider disguise = new DisguiseSpider(getEntity()); - - ((SpiderBoss) getEvent()).getDisguiseManager().disguise(disguise); - } - } - @Override protected void spawnCustom() { @@ -82,6 +67,10 @@ public class SpiderCreature extends EventCreature @Override public void dieCustom() { + /*for (Block block : Webs) + { + block.setType(Material.AIR); + }*/ } @EventHandler @@ -252,7 +241,14 @@ public class SpiderCreature extends EventCreature for (BossAbility ability : _currentAbilities) { - ability.tick(); + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); + } if (!ability.canMove()) { @@ -318,7 +314,7 @@ public class SpiderCreature extends EventCreature getEvent().getCondition().Factory() .Blind("Brood Mother Bite", target, getEntity(), 1.5, 0, false, true, true); getEvent().getCondition().Factory() - .Slow("Brood Mother Bite", target, getEntity(), 4, 0, false, true, true, true); + .Slow("Brood Mother Bite", target, getEntity(), 4, 1, false, true, true, true); getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK, 2 * getDifficulty(), true, false, false, "Brood Mother Attack", "Brood Mother Attack"); @@ -449,5 +445,4 @@ public class SpiderCreature extends EventCreature if (cause == DamageCause.FALL) event.SetCancelled("Cancel"); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderMinionCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderMinionCreature.java similarity index 86% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderMinionCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderMinionCreature.java index 255f2406e..15eb9a843 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderMinionCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderMinionCreature.java @@ -1,37 +1,34 @@ -package mineplex.minecraft.game.core.boss.spider; +package mineplex.minecraft.game.core.boss.broodmother; import java.util.HashMap; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.entity.Silverfish; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.util.Vector; - import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.disguise.disguises.DisguiseCaveSpider; -import mineplex.core.disguise.disguises.DisguiseSpider; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class SpiderMinionCreature extends EventCreature +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.CaveSpider; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class SpiderMinionCreature extends EventCreature { private long _lastAttack; private Location _moveTo; public SpiderMinionCreature(SpiderBoss boss, Location location, double maxHealth) { - super(boss, location, "Spider Minion", true, maxHealth, Pig.class); + super(boss, location, "Spider Minion", true, maxHealth, CaveSpider.class); spawnEntity(); } @@ -55,10 +52,6 @@ public class SpiderMinionCreature extends EventCreature UtilEnt.Vegetate(getEntity(), true); getEntity().setVelocity(new Vector(UtilMath.rr(0.5, true), 0.4, UtilMath.rr(0.4, true))); - - DisguiseCaveSpider disguise = new DisguiseCaveSpider(getEntity()); - - getEvent().getDisguiseManager().disguise(disguise); } @Override @@ -141,5 +134,4 @@ public class SpiderMinionCreature extends EventCreature if (cause == DamageCause.FALL) event.SetCancelled("Cancel"); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderCeilingCling.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java similarity index 96% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderCeilingCling.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java index 01f28b569..ec6d85ad3 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderCeilingCling.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import java.util.Collections; import java.util.List; @@ -20,7 +20,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilShapes; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class SpiderCeilingCling extends SpiderEggAbility @@ -215,4 +215,4 @@ public class SpiderCeilingCling extends SpiderEggAbility event.SetCancelled("Cancelled"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java new file mode 100644 index 000000000..cb1a5651a --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java @@ -0,0 +1,71 @@ +package mineplex.minecraft.game.core.boss.broodmother.attacks; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.entity.Spider; +import org.bukkit.event.EventHandler; + +public class SpiderCocoon extends BossAbility +{ + private static final long ABILITY_DURATION = 7000; + private long _start; + + public SpiderCocoon(SpiderCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ABILITY_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ABILITY_DURATION; + } + + @Override + public void tick() + { + for (Location loc : UtilShapes.getSphereBlocks(getEntity().getLocation(), 3, 3, false)) + { + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, loc, null, 0, 1, ViewDist.NORMAL); + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (hasFinished()) + { + return; + } + if (event.GetDamageeEntity() != null && event.GetDamageeEntity().equals(getEntity())) + { + event.SetCancelled("Cocoon Defense"); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggAbility.java similarity index 95% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggAbility.java index 9636a1da6..fcf6b9127 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggAbility.java @@ -1,10 +1,26 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Vec3D; + import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; @@ -13,29 +29,13 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Pig; +import org.bukkit.entity.Spider; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.util.Vector; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.MovingObjectPosition; -import net.minecraft.server.v1_8_R3.Vec3D; - -public abstract class SpiderEggAbility extends BossAbility +public abstract class SpiderEggAbility extends BossAbility { private HashMap _eggs = new HashMap(); private ArrayList _fallingBlocks = new ArrayList(); @@ -206,7 +206,7 @@ public abstract class SpiderEggAbility extends BossAbility && block.getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG) { block.setType(Material.DRAGON_EGG); - _eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000)); + _eggs.put(block, System.currentTimeMillis() + 5000 + UtilMath.r(5000)); } fallingIterator.remove(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggScatter.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggScatter.java similarity index 90% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggScatter.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggScatter.java index b6ea531a6..a01753e0a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggScatter.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggScatter.java @@ -1,10 +1,10 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; public class SpiderEggScatter extends SpiderEggAbility { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggplosm.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggplosm.java similarity index 89% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggplosm.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggplosm.java index c1dd81bfc..de527b47c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggplosm.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggplosm.java @@ -1,10 +1,10 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; public class SpiderEggplosm extends SpiderEggAbility { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoison.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java similarity index 96% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoison.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java index 3135945b0..b1bc6cc24 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoison.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import org.bukkit.Material; import org.bukkit.block.Block; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoisonBarrage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoisonBarrage.java similarity index 94% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoisonBarrage.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoisonBarrage.java index 1e44b90f9..1361921e6 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoisonBarrage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoisonBarrage.java @@ -1,25 +1,25 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Item; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; -public class SpiderPoisonBarrage extends BossAbility +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class SpiderPoisonBarrage extends BossAbility { private int _poisonAmount = UtilMath.r(20) + 30; private int _tick; @@ -56,7 +56,7 @@ public class SpiderPoisonBarrage extends BossAbility @Override public int getCooldown() { - return 100; + return 10; } /*@Override @@ -129,7 +129,7 @@ public class SpiderPoisonBarrage extends BossAbility vec.setY(0.35 + UtilMath.rr(0.3, false)); Item item = getLocation().getWorld() - .dropItem(getLocation().add(0, 0.5, 0), new ItemStack(Material.EMERALD_BLOCK)); + .dropItem(getLocation().add(0, 0.5, 0), new ItemStack(Material.SLIME_BALL)); item.setVelocity(vec); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebBarrage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java similarity index 88% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebBarrage.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java index 1e0eab120..103f8258e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebBarrage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java @@ -1,17 +1,7 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map.Entry; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -19,10 +9,19 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; -public class SpiderWebBarrage extends BossAbility +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +public class SpiderWebBarrage extends BossAbility { private int _canShoot; private ArrayList _fallingBlocks = new ArrayList(); @@ -129,7 +128,8 @@ public class SpiderWebBarrage extends BossAbility if (UtilBlock.airFoliage(block) || block.getType() == Material.WEB) { - block.setType(Material.WEB); + Bukkit.broadcastMessage("Setting Web"); + getBoss().getEvent().setBlock(block, Material.WEB); } // Expire diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebStomp.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java similarity index 78% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebStomp.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java index 9ea40cfc9..45a8359d7 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebStomp.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java @@ -1,20 +1,21 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; - -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; /** * A attack where webs appear all around the spider in a kinda maze formation, making it hard to approach it. */ -public class SpiderWebStomp extends BossAbility +public class SpiderWebStomp extends BossAbility { private int _tick; @@ -78,8 +79,9 @@ public class SpiderWebStomp extends BossAbility { continue; } - - block.setType(Material.WEB); + + Bukkit.broadcastMessage("Setting Web"); + getBoss().getEvent().setBlock(block, Material.WEB); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB); } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index 2bb55096e..75891e616 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -1,6 +1,7 @@ package mineplex.minecraft.game.core.boss.ironwizard; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; import mineplex.minecraft.game.core.boss.EventCreature; @@ -14,31 +15,29 @@ import org.bukkit.Location; public class GolemBoss extends WorldEvent { - - public GolemBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, - BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) + public GolemBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic"); + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation); } @Override protected void customStart() { - Bukkit.broadcastMessage("Custom Start"); + Bukkit.broadcastMessage(F.main(getName(), "The mighty " + getName() + " challenges you to face him!")); spawnGolem(getCenterLocation()); setState(EventState.LIVE); announceStart(); } /** - * Check if this slime boss has been defeated + * Check if this golem boss has been defeated */ private void checkDeath() { if (getCreatures().size() == 0) { setState(EventState.COMPLETE); - Bukkit.broadcastMessage("FINISHED!"); + Bukkit.broadcastMessage(F.main(getName(), "The mighty " + getName() + " has fallen!")); } } @@ -55,9 +54,8 @@ public class GolemBoss extends WorldEvent private GolemCreature spawnGolem(Location location) { - GolemCreature slimeCreature = new GolemCreature(this, location, 2500); - registerCreature(slimeCreature); - return slimeCreature; + GolemCreature golemCreature = new GolemCreature(this, location, 3000); + registerCreature(golemCreature); + return golemCreature; } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java index 06f1dc23d..be4e87f8c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -6,6 +6,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import java.util.Random; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -19,18 +20,22 @@ import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockHail; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockShot; -import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemCaveIn; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemDeadlyTremor; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemIronHook; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSlam; -import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSpike; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Arrow; import org.bukkit.entity.IronGolem; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -40,6 +45,11 @@ import org.bukkit.util.Vector; public class GolemCreature extends EventCreature { + //private static final double HEALTH_PER_REGEN = 5; + //private static final long HEALTH_REGEN_DELAY = 1000; + //private static final long REGEN_SAFE_TIME_NEED = 10000; + //private static final double CROWD_CONTROL_DAMAGE_REDUCTION = .70; + //private final double MAX_HEALTH; private GolemBoss _boss; // private GolemAbility _currentAbility; private int _lastAbility; @@ -51,13 +61,17 @@ public class GolemCreature extends EventCreature private Class _lastAttack; private boolean _usedFinalAttack; private ArrayList _currentAbilities = new ArrayList(); - private double _canCaveIn = 450; + private double _canDeadlyTremor = 225; private Vector _afkWalk = new Vector(); private long _lastSlam; + //private long _lastHit; + //private long _lastRegenerate; public GolemCreature(GolemBoss boss, Location location, double maxHealth) { super(boss, location, "Iron Wizard", true, maxHealth, IronGolem.class); + //MAX_HEALTH = maxHealth; + //_lastRegenerate = System.currentTimeMillis() + 20000; _boss = boss; spawnEntity(); @@ -70,7 +84,7 @@ public class GolemCreature extends EventCreature { GolemEarthquake.class, GolemRupture.class }); - _preferedCombos.put(GolemCaveIn.class, new Class[] + _preferedCombos.put(GolemDeadlyTremor.class, new Class[] { GolemMeleeAttack.class }); @@ -82,6 +96,29 @@ public class GolemCreature extends EventCreature { GolemBlockShot.class }); + _preferedCombos.put(GolemBlockHail.class, new Class[] + { + GolemDeadlyTremor.class + }); + } + + private boolean hasFurther(HashMap distances, double range) + { + for (Player player : distances.keySet()) + { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + Double dist = distances.get(player); + if (dist >= range) + { + return true; + } + } + + return false; } @Override @@ -106,6 +143,13 @@ public class GolemCreature extends EventCreature _standing = getEntity().getLocation(); return; } + + /*if (UtilTime.elapsed(_lastHit, REGEN_SAFE_TIME_NEED) && UtilTime.elapsed(_lastRegenerate, HEALTH_REGEN_DELAY)) + { + _lastRegenerate = System.currentTimeMillis(); + super.setHealth(Math.min(MAX_HEALTH, getHealth() + HEALTH_PER_REGEN)); + setHealth(getHealth() + HEALTH_PER_REGEN); + }*/ // if (_currentAbility == null || _currentAbility.hasFinished()) // { @@ -153,9 +197,21 @@ public class GolemCreature extends EventCreature if (!players.isEmpty()) { - weight.put(GolemMeleeAttack.class, 999); + if (players.size() >= 4) + { + weight.put(GolemEarthquake.class, 999); + } + else + { + weight.put(GolemMeleeAttack.class, 999); + } } } + + if (hasFurther(dist, 15)) + { // Iron Hook + weight.put(GolemIronHook.class, 6); //6 + } if (hp < 0.7) { // Earthquake @@ -180,9 +236,9 @@ public class GolemCreature extends EventCreature } { // Wall explode - if (!getPlayers(dist, 13).isEmpty() && getPlayers(dist, 4).isEmpty()) + if (!getPlayers(dist, 20).isEmpty() && getPlayers(dist, 4).isEmpty()) { - weight.put(GolemWallExplode.class, 8); + weight.put(GolemSpike.class, 8); } } @@ -217,9 +273,9 @@ public class GolemCreature extends EventCreature } } - if (_canCaveIn <= 0) // Cave in + if (_canDeadlyTremor <= 0) // Deadly Tremor { - ArrayList players = getPlayers(dist, 30); + ArrayList players = getPlayers(dist, 80); for (BossAbility ability : _currentAbilities) { @@ -232,7 +288,7 @@ public class GolemCreature extends EventCreature if (!players.isEmpty()) { // weight.put(GolemCaveIn.class, (int) Math.min(players.size() * 2, 7)); - weight.put(GolemCaveIn.class, (int) 30); + weight.put(GolemDeadlyTremor.class, (int) 30); } } @@ -241,7 +297,7 @@ public class GolemCreature extends EventCreature if (!players.isEmpty()) { - int we = _lastAttack == GolemEarthquake.class ? 5 : UtilMath.r(4) - 2; + int we = _lastAttack == GolemEarthquake.class ? 20 : UtilMath.r(15) - 2; if (we > 0) { @@ -325,9 +381,9 @@ public class GolemCreature extends EventCreature { _lastAttack = ability.getClass(); - if (ability instanceof GolemCaveIn) + if (ability instanceof GolemDeadlyTremor) { - _canCaveIn = 450; + _canDeadlyTremor = 225; } else if (ability instanceof GolemSlam) { @@ -353,7 +409,14 @@ public class GolemCreature extends EventCreature for (BossAbility ability : _currentAbilities) { - ability.tick(); + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); //Keeps the boss from getting stuck if one of the moves throws an error in progression + } if (!ability.canMove()) { @@ -492,6 +555,11 @@ public class GolemCreature extends EventCreature if (event.GetDamageeEntity().equals(getEntity())) { event.AddKnockback("Heavy Golem", 0.3); + //_lastHit = System.currentTimeMillis(); + /*if (UtilPlayer.getInRadius(getEntity().getLocation(), 10).size() >= 3) + { + event.AddMult(getEntity().getName(), "Level Field", CROWD_CONTROL_DAMAGE_REDUCTION, false); + }*/ } } @@ -502,6 +570,16 @@ public class GolemCreature extends EventCreature { if (event.GetDamageePlayer() != null) { + if (event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) + { + if (new Random().nextDouble() <= .5) + { + event.SetCancelled("Iron Skin Reflection"); + getEntity().getWorld().playSound(getEntity().getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f); + return; + } + } + double dist = event.GetDamageePlayer().getLocation().distance(getEntity().getLocation()); double maxRange = _usedFinalAttack ? 20 : 45; @@ -540,34 +618,11 @@ public class GolemCreature extends EventCreature @Override public void setHealth(double health) { - _canCaveIn -= getHealth() - health; - + _canDeadlyTremor -= getHealth() - health; super.setHealth(health); - if (getHealth() <= 100 && !_usedFinalAttack) { endAbility(); } } - - @EventHandler - public void onPlayerDamage(CustomDamageEvent event) - { - if (!(event.GetDamageeEntity() instanceof Player)) - { - return; - } - - if (event.GetCause() != DamageCause.FALL) - { - return; - } - - if (!getEvent().getEventMap().isInMap(event.GetDamageeEntity().getLocation())) - { - return; - } - - event.AddMod("Fall negation", 0.5); - } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java index 4a32cb525..f31a05798 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java @@ -407,7 +407,7 @@ public class GolemBlockHail extends BossAbility for (int i = 1; i <= _currentLevel; i++) { - if (_floatingBlocks.containsKey(i)) + if (_floatingBlocks.containsKey(i) && !_floatingBlocks.get(i).isEmpty()) { floatingBlock = _floatingBlocks.get(i).remove(0); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java index 5f57bd4c9..6b6e0a11a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java @@ -283,7 +283,7 @@ public class GolemCaveIn extends BossAbility List players = UtilPlayer.getNearby(getLocation(), 50, true); - for (int i = 0; i < players.size() * 4; i++) + for (int i = 0; i < players.size() * 2; i++) { int dist = UtilMath.r(10); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java new file mode 100644 index 000000000..36c72f340 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java @@ -0,0 +1,89 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemDeadlyTremor extends BossAbility +{ + private static final long ATTACK_DURATION = 10000; + private long _start; + + public GolemDeadlyTremor(GolemCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + } + + @Override + public void tick() + { + for (Player player : UtilPlayer.getInRadius(getLocation(), 30).keySet()) + { + player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); + + if (UtilEnt.isGrounded(player)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getBoss().getEntity(), null, DamageCause.CUSTOM, (1 + 2 * Math.random()) * getBoss().getDifficulty(), false, false, false, getBoss().getEntity().getName(), "Deadly Tremor"); + + if (Recharge.Instance.use(player, "Deadly Tremor Hit", 400, false, false)) + { + UtilAction.velocity(player, new Vector(Math.random() - 0.5, Math.random() * 0.2, Math.random() - 0.5), + Math.random() * 1 + 1, false, 0, 0.1 + Math.random() * 0.2, 2, true); + } + } + + for (Block block : UtilBlock.getInRadius(player.getLocation(), 5).keySet()) + { + if (Math.random() < 0.98) + continue; + + if (!UtilBlock.solid(block)) + continue; + + if (!UtilBlock.airFoliage(block.getRelative(BlockFace.UP))) + continue; + + player.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java index 1d06110c2..7633b145c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java @@ -105,7 +105,7 @@ public class GolemEarthquake extends BossAbility } } - _center.getWorld().playSound(_center, Sound.DIG_GRASS, 2, 0.8F); + _center.getWorld().playSound(_center, Sound.DIG_STONE, 2, 0.8F); HashSet toDamage = new HashSet(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java new file mode 100644 index 000000000..fb8ffd2cc --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java @@ -0,0 +1,170 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + +//2-3 people +//5 impact damage +//High pull velocity +//40 block range +public class GolemIronHook extends BossAbility +{ + private static final Integer MAX_TARGETS = 3; + private boolean _shot, _complete; + + private List _hooks = Lists.newArrayList(); + + public GolemIronHook(GolemCreature creature) + { + super(creature); + _shot = false; + _complete = false; + } + + private int getPosition(Player toAdd, LinkedList ordered, HashMap distances) + { + int position = ordered.size(); + int index = 0; + for (Player player : ordered) + { + if (distances.get(player) < distances.get(toAdd)) + { + position = index; + } + index++; + } + + return position; + } + + private void shoot() + { + IronGolem wizard = getBoss().getEntity(); + LinkedList selections = new LinkedList<>(); + List targeted = Lists.newArrayList(); + + HashMap near = UtilPlayer.getInRadius(wizard.getLocation(), 40D); + + for (Player nearby : near.keySet()) + { + if (nearby.getGameMode() == GameMode.CREATIVE || nearby.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + if (selections.isEmpty()) + { + selections.addFirst(nearby); + } + else + { + selections.add(getPosition(nearby, selections, near), nearby); + } + } + + for (int i = 0; i < MAX_TARGETS; i++) + { + if (i < selections.size()) + { + targeted.add(selections.get(i)); + } + } + + if (targeted.isEmpty()) + { + _complete = true; + setFinished(); + return; + } + + for (Player target : targeted) + { + Item item = wizard.getWorld().dropItem(wizard.getEyeLocation().add(UtilAlg.getTrajectory(wizard, target)), ItemStackFactory.Instance.CreateStack(131)); + UtilAction.velocity(item, UtilAlg.getTrajectory(wizard, target).normalize(), + 2, false, 0, 0.2, 20, false); + + getBoss().getEvent().getProjectileManager().AddThrow(item, getBoss().getEntity(), new IronHook(getBoss().getEvent()), -1, true, true, true, true, + Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 1f); + + item.getWorld().playSound(item.getLocation(), Sound.IRONGOLEM_THROW, 2f, 0.8f); + _hooks.add(item); + } + } + + @Override + public int getCooldown() + { + return 10; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _complete; + } + + @Override + public void setFinished() + { + for (Item hook : _hooks) + { + if (!hook.isDead() && hook.isValid()) + { + getBoss().getEvent().getProjectileManager().deleteThrown(hook); + hook.remove(); + } + } + + _hooks.clear(); + } + + @Override + public void tick() + { + if (_shot) + { + return; + } + shoot(); + _shot = true; + Bukkit.getScheduler().runTaskLater(getBoss().getEvent().getPlugin(), new Runnable() + { + public void run() + { + _complete = true; + setFinished(); + } + }, 2 * 20); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java index ba93748e5..670ffc8e0 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java @@ -348,7 +348,7 @@ public class GolemRupture extends BossAbility _items.add(item); // Effect - loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId()); + loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.STONE.getId()); done++; } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java new file mode 100644 index 000000000..4059bb4e9 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java @@ -0,0 +1,105 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.List; +import java.util.Random; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Sound; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import com.google.common.collect.Lists; + +public class GolemSpike extends BossAbility +{ + private static final int SPIKE_HEIGHT = 2; + private static final long ATTACK_DURATION = 1000 + (500 * SPIKE_HEIGHT * 2); + private static final long SPIKE_REMAIN = 1000; + private long _start; + private List _spikes; + + public GolemSpike(GolemCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _spikes = Lists.newArrayList(); + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION) && _spikes.isEmpty(); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + for (GroundSpike spike : _spikes) + { + spike.finish(); + } + _spikes.clear(); + } + + @Override + public void tick() + { + if (_spikes.isEmpty()) + { + for (Player player : UtilPlayer.getInRadius(getLocation(), 20).keySet()) + { + if (UtilEnt.isGrounded(player)) + { + player.playSound(player.getLocation(), Sound.STEP_STONE, 0.2f, 0.2f); + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getBoss().getEntity(), null, DamageCause.CUSTOM, 5 * getBoss().getDifficulty(), false, false, false, getBoss().getEntity().getName(), "Stone Spike"); + player.teleport(player.getLocation().add(0, SPIKE_HEIGHT, 0)); + UtilAction.velocity(player, player.getLocation().toVector().normalize().add(new Vector(0, 0.02, 0)).normalize()); + _spikes.add(new GroundSpike(player.getLocation().getBlock(), player.getLocation().getBlock().getRelative(0, -1, 0).getType(), new Random().nextInt(SPIKE_HEIGHT) + 2, SPIKE_REMAIN)); + } + } + } + else + { + List toRemove = Lists.newArrayList(); + for (GroundSpike spike : _spikes) + { + spike.tick(); + if (spike.isFinished()) + { + toRemove.add(spike); + } + } + for (GroundSpike remove : toRemove) + { + _spikes.remove(remove); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java new file mode 100644 index 000000000..3cac28e69 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java @@ -0,0 +1,116 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.LinkedList; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; + +public class GroundSpike +{ + private Block _initial; + private Material _type; + private int _max, _height; + private long _lastTick, _remain; + private LinkedList _blocks; + private boolean _shrinking, _finished; + + public GroundSpike(Block first, Material type, int maxHeight, long remainDuration) + { + _initial = first; + _type = type; + _height = 0; + _max = maxHeight; + _remain = remainDuration; + _lastTick = System.currentTimeMillis(); + _blocks = new LinkedList<>(); + _shrinking = false; + _finished = false; + } + + @SuppressWarnings("deprecation") + private void raise() + { + if ((_height + 1) < _max) + { + _lastTick = System.currentTimeMillis(); + Block b = _initial.getRelative(0, _height, 0); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(b.getLocation(), _type, (byte)0); + } + _blocks.add(b); + _height++; + } + else + { + if (UtilTime.elapsed(_lastTick, _remain)) + { + _shrinking = true; + lower(); + } + } + } + + @SuppressWarnings("deprecation") + private void lower() + { + _height = Math.min(_blocks.size() - 1, _height); + if ((_height - 1) >= 0) + { + _lastTick = System.currentTimeMillis(); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(_blocks.get(_height).getLocation(), Material.AIR, (byte)0); + } + _blocks.remove(_height); + _height--; + } + else + { + finish(); + } + } + + public boolean isFinished() + { + if (!_blocks.isEmpty()) + return false; + + return _finished; + } + + @SuppressWarnings("deprecation") + public void finish() + { + _finished = true; + for (Block block : _blocks) + { + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(block.getLocation(), Material.AIR, (byte)0); + } + } + _blocks.clear(); + } + + public void tick() + { + if (isFinished()) + return; + if (!UtilTime.elapsed(_lastTick, 500)) + return; + + if (_shrinking) + { + lower(); + } + else + { + raise(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java new file mode 100644 index 000000000..9c402dab6 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java @@ -0,0 +1,54 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.minecraft.game.core.boss.WorldEvent; + +import org.bukkit.block.Block; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class IronHook implements IThrown +{ + private WorldEvent _host; + + public IronHook(WorldEvent event) + { + _host = event; + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + data.getThrown().remove(); + + if (!(data.getThrower() instanceof IronGolem)) + return; + + IronGolem wizard = (IronGolem)data.getThrower(); + + if (target == null) + return; + + UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), wizard.getLocation()), 5, false, 0, 0.7, 1.2, true); + + _host.getCondition().Factory().Falling("Iron Hook", target, wizard, 10, false, true); + + _host.getDamageManager().NewDamageEvent(target, wizard, null, DamageCause.CUSTOM, 5, false, true, false, wizard.getName(), "Iron Hook"); + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java new file mode 100644 index 000000000..f2509954c --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java @@ -0,0 +1,102 @@ +package mineplex.minecraft.game.core.boss.skeletonking; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.skeletonking.minion.MinionType; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; + +public class SkeletonBoss extends WorldEvent +{ + protected boolean canMove = false; + + public SkeletonBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + { + super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation); + } + + @Override + protected void customStart() + { + Bukkit.broadcastMessage(F.main(getName(), "The evils of the world have manifested in the form of the " + getName() + "! Become the champion of Light and destroy him!")); + spawnNecromancer(getCenterLocation()); + setState(EventState.LIVE); + announceStart(); + } + + /** + * Check if this skeleton boss has been defeated + */ + private void checkDeath() + { + if (getBossesAlive() == 0) + { + setState(EventState.COMPLETE); + Bukkit.broadcastMessage(F.main(getName(), "The demonic " + getName() + " has been slain!")); + } + } + + @Override + public void removeCreature(EventCreature creature) + { + super.removeCreature(creature); + + if (creature instanceof SkeletonCreature) + { + checkDeath(); + } + } + + @Override + protected void setState(EventState state) + { + super.setState(state); + if (state == EventState.LIVE) + { + Bukkit.getScheduler().runTaskLater(getPlugin(), () -> + { + canMove = true; + }, 20 * 3); + } + } + + public EventCreature spawnMinion(MinionType type, Location location) + { + EventCreature minionCreature = type.getNewInstance(this, location); + if (minionCreature != null) + { + registerCreature(minionCreature); + } + return minionCreature; + } + + private SkeletonCreature spawnNecromancer(Location location) + { + SkeletonCreature necromancerCreature = new SkeletonCreature(this, location, 2500); + registerCreature(necromancerCreature); + return necromancerCreature; + } + + private int getBossesAlive() + { + int alive = 0; + + for (EventCreature creature : getCreatures()) + { + if (creature instanceof SkeletonCreature) + { + alive++; + } + } + + return alive; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java new file mode 100644 index 000000000..45cae347e --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java @@ -0,0 +1,478 @@ +package mineplex.minecraft.game.core.boss.skeletonking; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map.Entry; +import java.util.Random; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonArcherShield; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonPassive; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonPulse; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonSmite; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonStrike; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonWraithSummon; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadWarriorCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import com.google.common.collect.Lists; + +public class SkeletonCreature extends EventCreature +{ + private ArrayList _currentAbilities = Lists.newArrayList(); + private SkeletonPassive _passive; + private int _lastAbility; + private HashMap _cooldowns = new HashMap<>(); + private LinkedList _wraithTriggers = new LinkedList<>(); + private List _movePoints = Lists.newArrayList(); + private Location _movingTo; + private boolean _moving; + private long _lastMoved; + private long _lastUsedPassive; + public List Archers = Lists.newArrayList(); + public List Warriors = Lists.newArrayList(); + + public SkeletonCreature(SkeletonBoss boss, Location location, double maxHealth) + { + super(boss, location, "Skeleton King", true, maxHealth, Skeleton.class); + + spawnEntity(); + _passive = new SkeletonPassive(this); + _wraithTriggers.add(1500D); + _wraithTriggers.add(1000D); + _wraithTriggers.add(500D); + _wraithTriggers.add(100D); + getEntity().getWorld().setThunderDuration(10000000); + getEntity().getWorld().setThundering(true); + } + + @Override + protected void spawnCustom() + { + UtilEnt.Vegetate(getEntity()); + getEntity().setSkeletonType(SkeletonType.WITHER); + getEntity().getEquipment().setItemInHand(new ItemStack(Material.RECORD_6)); //Meridian Scepter + getEntity().getEquipment().setItemInHandDropChance(0.f); + } + + @Override + public void dieCustom() + { + HandlerList.unregisterAll(_passive); + _passive = null; + endAbility(); + getEntity().getWorld().setThunderDuration(0); + getEntity().getWorld().setThundering(false); + } + + private void endAbility() + { + for (BossAbility ability : _currentAbilities) + { + ability.setFinished(); + HandlerList.unregisterAll(ability); + } + + _currentAbilities.clear(); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_passive != null && ((SkeletonBoss)getEvent()).canMove) + { + if (UtilTime.elapsed(_lastUsedPassive, _passive.getCooldown() * 20) || _passive.isProgressing()) + { + _lastUsedPassive = System.currentTimeMillis(); + _passive.tick(); + } + } + + Iterator itel = _currentAbilities.iterator(); + boolean canDoNew = _currentAbilities.size() < 3; + + while (itel.hasNext()) + { + BossAbility ability = itel.next(); + + if (ability.hasFinished()) + { + itel.remove(); + ability.setFinished(); + _lastAbility = 20;// _currentAbility.getCooldown(); + + HandlerList.unregisterAll(ability); + System.out.print("Unregistered necromancer ability " + ability.getClass().getSimpleName()); + + _cooldowns.put(ability.getClass(), System.currentTimeMillis() + (ability.getCooldown() * 1000)); + } + else if (ability.inProgress()) + { + canDoNew = false; + _lastAbility = 20;// _currentAbility.getCooldown(); + } + } + + if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))) + { + HashMap, Integer> weight = new HashMap<>(); + HashMap dist = new HashMap<>(); + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (player.hasLineOfSight(getEntity())) + { + dist.put(player, player.getLocation().distance(getEntity().getLocation())); + } + } + + if (!dist.isEmpty()) + { + {// Pulse & Strike + ArrayList players = getPlayers(dist, UtilMath.r(10) == 0 ? 25 : 20); + ArrayList near = getPlayers(dist, 5); + + if (!players.isEmpty()) + { + if (!near.isEmpty() && near.size() >= 4 && new Random().nextDouble() <= .45) + { + weight.put(SkeletonPulse.class, 999); + } + else + { + weight.put(SkeletonStrike.class, 6); + } + } + } + {// Smite + ArrayList players = getPlayers(dist, 15); + + if (!players.isEmpty()) + { + weight.put(SkeletonSmite.class, 6); + } + } + {//Archer Shield + ArrayList players = getPlayers(dist, 20); + double score = 0; + for (Player player : players) + { + score += (18 - dist.get(player)) / 2; + } + if (players.size() >= 4) + { + score += 17; + } + if (score > 0) + { + weight.put(SkeletonArcherShield.class, (int) Math.ceil(score)); + } + } + Double wraithUse = null; + for (Double test : _wraithTriggers) + { + if (wraithUse == null) + { + if (getHealth() <= test) + { + wraithUse = test; + break; + } + } + } + if (wraithUse != null) + {// Wraith Summon + _wraithTriggers.remove(wraithUse); + weight.clear(); + weight.put(SkeletonWraithSummon.class, 999); + } + } + + for (BossAbility ability : _currentAbilities) + { + weight.remove(ability.getClass()); + } + + for (Class c : _cooldowns.keySet()) + { + if (_cooldowns.get(c) > System.currentTimeMillis()) + { + weight.remove(c); + } + } + + if (_moving) + { + Iterator> trying = weight.keySet().iterator(); + while (trying.hasNext()) + { + Class abilityClass = trying.next(); + + try + { + BossAbility ability = abilityClass.newInstance(); + if (!ability.canMove()) + { + trying.remove(); + } + } + catch (Exception e) {} + } + } + + BossAbility ability = null; + + if (!weight.isEmpty()) + { + int i = 0; + + for (Integer entry : weight.values()) + { + i += entry; + } + + loop: for (int a = 0; a < 10; a++) + { + int luckyNumber = UtilMath.r(i); + + for (Entry, Integer> entry : weight.entrySet()) + { + luckyNumber -= entry.getValue(); + + if (luckyNumber <= 0) + { + try + { + ability = entry.getKey().getConstructor(SkeletonCreature.class).newInstance(this); + + if (ability.getTarget() == null || ability.hasFinished()) + { + ability = null; + } + else + { + break loop; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + break; + } + } + } + } + + if (ability != null && ability.getTarget() != null) + { + + Bukkit.getPluginManager().registerEvents(ability, getEvent().getPlugin()); + + System.out.print("Necromancer is using " + ability.getClass().getSimpleName()); + + _currentAbilities.add(ability); + } + + _lastAbility = 10; + } + + for (BossAbility ability : _currentAbilities) + { + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + boolean canMove = true; + for (BossAbility ability : _currentAbilities) + { + if (!ability.canMove()) + { + canMove = false; + } + } + if (!((SkeletonBoss)getEvent()).canMove) + { + return; + } + + if (_moving) + { + if (_movingTo == null) + { + _movingTo = selectWalkTarget(); + } + if (UtilMath.offset(getEntity().getLocation(), _movingTo) <= 1.3) + { + _lastMoved = System.currentTimeMillis(); + _movingTo = null; + _moving = false; + return; + } + UtilEnt.LookAt(getEntity(), _movingTo); + Vector walk = UtilAlg.getTrajectory(getEntity().getLocation(), _movingTo); + walk.multiply(walk.length()); + walk.multiply(.2); + getEntity().setVelocity(walk); + } + else + { + if (!UtilTime.elapsed(_lastMoved, 7000) || !canMove) + { + return; + } + _movingTo = selectWalkTarget(); + _moving = true; + } + } + + private Location selectWalkTarget() + { + if (_movePoints.isEmpty()) + { + Location base = getSpawnLocation().clone(); + base.setY(getEntity().getLocation().getY()); + generateWalkPoints(base); + } + Location selected = _movePoints.get(new Random().nextInt(_movePoints.size())); + _movePoints.remove(selected); + + return selected; + } + + private void generateWalkPoints(Location base) + { + _movePoints.add(base.clone().add(5 + UtilMath.random(1, 3), 0, 5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(-5 + UtilMath.random(1, 3), 0, 5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(5 + UtilMath.random(1, 3), 0, -5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(-5 + UtilMath.random(1, 3), 0, -5 + UtilMath.random(1, 3))); + } + + private ArrayList getPlayers(HashMap map, double maxDist) + { + return getPlayers(map, 0, maxDist); + } + + private ArrayList getPlayers(final HashMap map, double minDist, double maxDist) + { + ArrayList list = new ArrayList(); + + for (Player p : map.keySet()) + { + if (map.get(p) >= minDist && map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, new Comparator() + { + + @Override + public int compare(Player o1, Player o2) + { + return Double.compare(map.get(o2), map.get(o1)); + } + }); + + return list; + } + + @EventHandler + public void onSkeletonDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetKnockback(false); + } + } + + @EventHandler + public void noFallDamage(CustomDamageEvent event) + { + if (getEntity() == null) + return; + + if (event.GetDamageeEntity().getEntityId() != getEntity().getEntityId()) + return; + + DamageCause cause = event.GetCause(); + + if (cause == DamageCause.FALL) + { + event.SetCancelled("Boss Invulnerability"); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java new file mode 100644 index 000000000..c393c73e3 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java @@ -0,0 +1,186 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +public class SkeletonArcherShield extends BossAbility +{ + private static long ATTACK_DURATION = 10000; + private static long ARROW_DELAY = 100; + private static long ARROW_WARMUP = 2000; + private static double PULL_RANGE = 12; + private long _start; + private long _lastShoot; + private boolean _teleported; + + public SkeletonArcherShield(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + for (UndeadArcherCreature creature : getBoss().Archers) + { + creature.getEntity().remove(); + } + } + + private void run(boolean initial) + { + for (int i = 0; i < getBoss().Archers.size(); i++) + { + Skeleton archer = getBoss().Archers.get(i).getEntity(); + UtilEnt.Vegetate(archer); + ((CraftSkeleton)archer).setVegetated(false); + + double lead = i * ((2d * Math.PI)/getBoss().Archers.size()); + + double sizeMod = 2; + + //Orbit + double speed = 10d; + double oX = -Math.sin(getEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + double oY = 0; + double oZ = Math.cos(getEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + + if (initial) + { + archer.teleport(getEntity().getLocation().add(oX, oY, oZ)); + UtilEnt.Vegetate(archer); + } + else + { + Location to = getEntity().getLocation().add(oX, oY, oZ); + UtilEnt.LookAt(archer, to); + UtilAction.velocity(archer, UtilAlg.getTrajectory(archer.getLocation(), to), 0.4, false, 0, 0.1, 1, true); + } + } + } + + private void shoot() + { + if (UtilTime.elapsed(_start, ARROW_WARMUP) && UtilTime.elapsed(_lastShoot, ARROW_DELAY)) + { + _lastShoot = System.currentTimeMillis(); + for (UndeadArcherCreature archer : getBoss().Archers) + { + Location spawn = archer.getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity().getEyeLocation(), archer.getEntity().getEyeLocation()).normalize()); + Vector vector = UtilAlg.getTrajectory(getEntity().getEyeLocation(), spawn); + Arrow arrow = archer.getEntity().getWorld().spawnArrow(spawn, vector, 0.6f, 12f); + arrow.setMetadata("SHIELD_SHOT", new FixedMetadataValue(getBoss().getEvent().getPlugin(), true)); + arrow.setMetadata("BARBED_ARROW", new FixedMetadataValue(getBoss().getEvent().getPlugin(), 10)); + arrow.setShooter(archer.getEntity()); + } + } + } + + @Override + public void tick() + { + if (!_teleported) + { + run(true); + _teleported = true; + for (Player near : UtilPlayer.getInRadius(getEntity().getLocation(), PULL_RANGE).keySet()) + { + Vector velocity = UtilAlg.getTrajectory(near, getEntity()); + UtilAction.velocity(near, velocity, 2, false, 0, 0, 1, true); + near.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, -2)); + for (int i = 0; i < 6; i++) + { + Vector random = new Vector(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2); + + Location origin = getEntity().getLocation().add(0, 1.3, 0); + origin.add(velocity.clone().multiply(10)); + origin.add(random); + + Vector vel = UtilAlg.getTrajectory(origin, getEntity().getLocation().add(0, 1.3, 0)); + vel.multiply(7); + + UtilParticle.PlayParticleToAll(ParticleType.MAGIC_CRIT, origin, (float)vel.getX(), (float)vel.getY(), (float)vel.getZ(), 1, 0, ViewDist.LONG); + } + } + } + else + { + run(false); + shoot(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getBoss().getEntity())) + { + if (!hasFinished()) + { + event.SetCancelled("Wraiths Alive"); + } + } + } + + @EventHandler + public void onArrowHit(ProjectileHitEvent event) + { + if (event.getEntity().hasMetadata("SHIELD_SHOT")) + { + Bukkit.getScheduler().runTaskLater(getBoss().getEvent().getPlugin(), () -> + { + event.getEntity().remove(); + }, 20L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonHellishFlood.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonHellishFlood.java new file mode 100644 index 000000000..089db01b8 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonHellishFlood.java @@ -0,0 +1,118 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.MinionType; + +import org.bukkit.Location; +import org.bukkit.entity.Skeleton; + +public class SkeletonHellishFlood extends BossAbility +{ + private static final int WAVE_COUNT = 3; + private static final int WAVE_SIZE = 5; + private static final MinionType[] POSSIBLE_MINIONS = new MinionType[] {MinionType.WARRIOR, MinionType.ARCHER}; + private static final long WAVE_DELAY = 1000; + + private ConcurrentHashMap _waves = new ConcurrentHashMap<>(); + private long _lastSpawned; + private int _current; + private int _ticks; + + public SkeletonHellishFlood(SkeletonCreature creature) + { + super(creature); + + if (WAVE_COUNT > 0) + { + for (int i = 1; i <= WAVE_COUNT; i++) + { + createWave(i); + } + } + _lastSpawned = System.currentTimeMillis(); + _current = 1; + } + + private void createWave(int number) + { + int length = POSSIBLE_MINIONS.length; + if (length <= 0 || WAVE_SIZE <= 0) + { + return; + } + MinionType[] wave = new MinionType[WAVE_SIZE]; + for (int i = 0; i < WAVE_SIZE; i++) + { + wave[i] = POSSIBLE_MINIONS[new Random().nextInt(length)]; + } + _waves.put("Wave " + number, wave); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return _waves.isEmpty() && _ticks > ((WAVE_DELAY / 1000) * 20 * (WAVE_COUNT - 1)); + } + + @Override + public void setFinished() + { + _waves.clear(); + _ticks = 60; + } + + @Override + public void tick() + { + _ticks++; + if (UtilTime.elapsed(_lastSpawned, WAVE_DELAY)) + { + if (_current <= WAVE_COUNT) + { + for (MinionType type : _waves.get("Wave " + _current)) + { + Location toSpawn = getLocation().clone(); + toSpawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + + ((SkeletonBoss)getBoss().getEvent()).spawnMinion(type, toSpawn); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, toSpawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, toSpawn, null, 0, 2, ViewDist.MAX); + } + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + _waves.remove("Wave " + _current); + _current++; + _lastSpawned = System.currentTimeMillis(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java new file mode 100644 index 000000000..b8ce6b1c2 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java @@ -0,0 +1,121 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import java.util.List; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossPassive; +import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.MinionType; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadWarriorCreature; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; + +import com.google.common.collect.Lists; + +public class SkeletonPassive extends BossPassive +{ + private static final int MAX_ARCHERS = 10; + private static final int MAX_WARRIORS = 8; + private static final long SPAWN_RATE = 5000; + private List _queuedArchers = Lists.newArrayList(); + private List _queuedWarriors = Lists.newArrayList(); + private long _lastASpawned; + private long _lastWSpawned; + + public SkeletonPassive(SkeletonCreature creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public boolean isProgressing() + { + return !_queuedArchers.isEmpty() || !_queuedWarriors.isEmpty(); + } + + @Override + public void tick() + { + if (getBoss().Archers.size() < MAX_ARCHERS && _queuedArchers.isEmpty()) + { + for (int i = 0; i < (MAX_ARCHERS - getBoss().Archers.size()); i++) + { + Location spawn = getLocation().clone(); + spawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + _queuedArchers.add(spawn); + } + } + if (getBoss().Warriors.size() < MAX_WARRIORS && _queuedWarriors.isEmpty()) + { + for (int i = 0; i < (MAX_WARRIORS - getBoss().Warriors.size()); i++) + { + Location spawn = getLocation().clone(); + spawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + _queuedWarriors.add(spawn); + } + } + + for (Location animate : _queuedArchers) + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + animate.clone().add(0, 0.2, 0), null, 0, 4, ViewDist.NORMAL); + } + for (Location animate : _queuedWarriors) + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + animate.clone().add(0, 0.2, 0), null, 0, 4, ViewDist.NORMAL); + } + + if (!_queuedArchers.isEmpty() && UtilTime.elapsed(_lastASpawned, SPAWN_RATE)) + { + _lastASpawned = System.currentTimeMillis(); + Location spawn = _queuedArchers.remove(0); + getBoss().Archers.add((UndeadArcherCreature) ((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.ARCHER, spawn)); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + } + if (!_queuedWarriors.isEmpty() && UtilTime.elapsed(_lastWSpawned, SPAWN_RATE)) + { + _lastWSpawned = System.currentTimeMillis(); + Location spawn = _queuedWarriors.remove(0); + getBoss().Warriors.add((UndeadWarriorCreature) ((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.WARRIOR, spawn)); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + } + } + + @EventHandler + public void onArcherDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof UndeadArcherCreature) + { + getBoss().Archers.remove(event.getCreature()); + } + if (event.getCreature() instanceof UndeadWarriorCreature) + { + getBoss().Warriors.remove(event.getCreature()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPulse.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPulse.java new file mode 100644 index 000000000..2e457e60d --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPulse.java @@ -0,0 +1,108 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; + +public class SkeletonPulse extends BossAbility +{ + private static final long TOTAL_ATTACK_DURATION = 8000; + private static final long TOTAL_ATTACK_PROGRESS = 3000; + private long _start, _lastIncrement; + private int _radius; + private Location _center; + + public SkeletonPulse(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _radius = 2; + _lastIncrement = System.currentTimeMillis(); + _center = creature.getEntity().getLocation(); + } + + private int getRadius() + { + return Math.min(8, _radius); + } + + @Override + public int getCooldown() + { + return 7; + } + + @Override + public boolean canMove() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_PROGRESS); + } + + @Override + public boolean inProgress() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_PROGRESS); + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - TOTAL_ATTACK_DURATION; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastIncrement, 500)) + { + _lastIncrement = System.currentTimeMillis(); + _radius++; + } + + for (double token = 0; token <= (2 * Math.PI); token += .2) + { + double x = getRadius() * Math.cos(token); + double z = getRadius() * Math.sin(token); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, _center.clone().add(x, 1.5, z), null, 0, 1, ViewDist.MAX); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), getRadius()).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + if (!Recharge.Instance.use(player, "Pulse Knockback", 400, false, false, false)) + { + continue; + } + + player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 1f, 1f); + UtilAction.velocity(player, UtilAlg.getTrajectory2d(getEntity(), player), 2, false, 0.6, 0, 1.4, true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonSmite.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonSmite.java new file mode 100644 index 000000000..6d3bfa4fc --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonSmite.java @@ -0,0 +1,104 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import java.math.BigDecimal; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class SkeletonSmite extends BossAbility +{ + private static final long TOTAL_ATTACK_DURATION = 8000; + private long _start; + private int _ticks; + private boolean _shot; + + public SkeletonSmite(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _ticks = 0; + _shot = false; + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_DURATION) && _shot; + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - TOTAL_ATTACK_DURATION; + _shot = true; + } + + @Override + public void tick() + { + if (_shot) + return; + + if (_ticks < (6 * 20)) + { + _ticks++; + double maxHeight = Math.min(_ticks / 20, 6); + int radius = Math.max(6 - (new BigDecimal(_ticks).divide(new BigDecimal(20)).intValue()), 0); + + for (double y = 0; y < maxHeight; y += 0.5) + { + double cos = radius * Math.cos(y); + double sin = radius * Math.sin(y); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(cos, y, sin), null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(sin, y, cos), null, 0, 1, ViewDist.MAX); + } + } + else + { + _shot = true; + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 15).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.getWorld().strikeLightningEffect(player.getLocation()); + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.LIGHTNING, 15 * getBoss().getDifficulty(), false, true, false, getEntity().getName(), "Lightning Strike"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonStrike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonStrike.java new file mode 100644 index 000000000..e61791a45 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonStrike.java @@ -0,0 +1,168 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import com.google.common.collect.Lists; + +public class SkeletonStrike extends BossAbility +{ + private static final double MAX_RANGE = 25; + private static final Integer MAX_TARGETS = 1; + private boolean _shot; + + public SkeletonStrike(SkeletonCreature creature) + { + super(creature); + _shot = false; + } + + private int getPosition(Player toAdd, LinkedList ordered) + { + int position = ordered.size(); + int index = 0; + for (Player player : ordered) + { + if (player.getHealth() < toAdd.getHealth()) + { + position = index; + return position; + } + index++; + } + + return position; + } + + private List getTargets() + { + Skeleton necromancer = getBoss().getEntity(); + LinkedList selections = new LinkedList<>(); + List targeted = Lists.newArrayList(); + + HashMap near = UtilPlayer.getInRadius(necromancer.getLocation(), MAX_RANGE); + + for (Player nearby : near.keySet()) + { + if (nearby.getGameMode() == GameMode.CREATIVE || nearby.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + if (selections.isEmpty()) + { + selections.addFirst(nearby); + } + else + { + selections.add(getPosition(nearby, selections), nearby); + } + } + + for (int i = 0; i < MAX_TARGETS; i++) + { + if (i < selections.size()) + { + targeted.add(selections.get(i)); + } + } + + return targeted; + } + + private void shootAt(Player target) + { + double curRange = 0; + boolean canHit = false; + + while (curRange <= MAX_RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.9) + { + canHit = true; + break; + } + + curRange += 0.2; + + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + + canHit = true; + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 12 * getBoss().getDifficulty(), true, true, false, getEntity().getName(), "Mystical Energy"); + } + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _shot; + } + + @Override + public void setFinished() + { + _shot = true; + } + + @Override + public void tick() + { + if (_shot) + return; + + _shot = true; + + for (Player target : getTargets()) + { + shootAt(target); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonWraithSummon.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonWraithSummon.java new file mode 100644 index 000000000..8f2be01e9 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonWraithSummon.java @@ -0,0 +1,230 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import java.math.BigDecimal; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.MinionType; +import mineplex.minecraft.game.core.boss.skeletonking.minion.WraithCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.util.Vector; + +public class SkeletonWraithSummon extends BossAbility +{ + private static final int WRAITH_AMOUNT = 4; + private static final double DISTANCE_FROM_KING = 4; + private static final double FINAL_SKELETON_HEALTH = 100; + private static final double FINAL_WRAITH_MULTIPLIER = 2; + private final int WRAITH_AMOUNT_THIS_USE; + + private ConcurrentHashMap _wraiths = new ConcurrentHashMap<>(); + private Location[] _spawns; + private int _ticks; + + public SkeletonWraithSummon(SkeletonCreature creature) + { + super(creature); + + _spawns = new Location[] + { + getEntity().getLocation().add(DISTANCE_FROM_KING, 0, DISTANCE_FROM_KING), + getEntity().getLocation().add(DISTANCE_FROM_KING * -1, 0, DISTANCE_FROM_KING), + getEntity().getLocation().add(DISTANCE_FROM_KING, 0, DISTANCE_FROM_KING * -1), + getEntity().getLocation().add(DISTANCE_FROM_KING * -1, 0, DISTANCE_FROM_KING * -1), + getEntity().getLocation().add(DISTANCE_FROM_KING / 2, 0, DISTANCE_FROM_KING / 2), + getEntity().getLocation().add((DISTANCE_FROM_KING / 2) * -1, 0, DISTANCE_FROM_KING / 2), + getEntity().getLocation().add(DISTANCE_FROM_KING / 2, 0, (DISTANCE_FROM_KING / 2) * -1), + getEntity().getLocation().add((DISTANCE_FROM_KING / 2) * -1, 0, (DISTANCE_FROM_KING / 2) * -1) + }; + + if (creature.getHealth() <= FINAL_SKELETON_HEALTH) + { + WRAITH_AMOUNT_THIS_USE = (int)(WRAITH_AMOUNT * FINAL_WRAITH_MULTIPLIER); + } + else + { + WRAITH_AMOUNT_THIS_USE = WRAITH_AMOUNT; + } + } + + private String getNumberString(Integer number) + { + String num = number.toString(); + char last = num.toCharArray()[num.length() - 1]; + + String formatted = number.toString(); + String ending = ""; + + if (last == '1' && !num.equals("1" + last)) + { + ending = "st"; + } + if (last == '2' && !num.equals("1" + last)) + { + ending = "nd"; + } + if (last == '3' && !num.equals("1" + last)) + { + ending = "rd"; + } + if (ending.equals("")) + { + ending = "th"; + } + + return formatted + ending; + } + + private void spawnWraith(Location loc, int number) + { + WraithCreature wraith = (WraithCreature)((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.WRAITH, loc); + _wraiths.put(wraith, getNumberString(number)); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return _wraiths.isEmpty() && _ticks > 40; + } + + @Override + public void setFinished() + { + for (WraithCreature wraith : _wraiths.keySet()) + { + wraith.remove(); + } + _wraiths.clear(); + _ticks = 41; + } + + @Override + public void tick() + { + if (_ticks == 0) + { + if (WRAITH_AMOUNT > 0) + { + for (int i = 0; i < WRAITH_AMOUNT_THIS_USE; i++) + { + int spawnIndex = i; + if (spawnIndex >= _spawns.length) + { + spawnIndex = spawnIndex % _spawns.length; + } + spawnWraith(_spawns[spawnIndex], i + 1); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 80).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.sendMessage(F.main(getBoss().getEvent().getName(), "You must slay all " + WRAITH_AMOUNT_THIS_USE + " wraiths before continuing to fight the " + getBoss().getEvent().getName() + "!")); + } + } + } + _ticks++; + if (!hasFinished()) + { + int ticks = 10; + int hticks = 40; + boolean up = getEntity().getTicksLived() % (hticks * 2) < hticks; + int tick = getEntity().getTicksLived() % ticks; + double htick = getEntity().getTicksLived() % hticks; + int splits = 4; + + Location loc = getEntity().getLocation().add(0, 2, 0); + + for (double d = tick * (Math.PI * 2 / splits) / ticks; d < Math.PI * 2; d += Math.PI * 2 / splits) + { + Vector v = new Vector(Math.sin(d), 0, Math.cos(d)); + v.normalize().multiply(Math.max(0.2, Math.sin((htick / hticks) * Math.PI) * 1.0)); + v.setY((htick / hticks) * -2); + if (up) v.setY(-2 + 2 * (htick / hticks)); + + Location lloc = loc.clone().add(v); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, lloc, null, 0f, 2, ViewDist.MAX); + } + } + } + + @EventHandler + public void onWraithDie(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof WraithCreature) + { + String number = _wraiths.remove(event.getCreature()); + if (number != null) + { + double remainPercent = new BigDecimal(_wraiths.size()).divide(new BigDecimal(WRAITH_AMOUNT_THIS_USE)).doubleValue(); + ChatColor remainColor = ChatColor.GREEN; + if (remainPercent < .66) + { + remainColor = ChatColor.YELLOW; + } + if (remainPercent < .33) + { + remainColor = ChatColor.RED; + } + Bukkit.broadcastMessage(F.main(getBoss().getEvent().getName(), "A wraith has been slain!" + " (" + remainColor + _wraiths.size() + "/" + WRAITH_AMOUNT_THIS_USE + C.cGray + ") wraiths remaining!")); + System.out.println(F.main(getBoss().getEvent().getName(), "The " + number + " wraith has been slain!")); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getBoss().getEntity())) + { + if (!hasFinished()) + { + event.SetCancelled("Wraiths Alive"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/MinionType.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/MinionType.java new file mode 100644 index 000000000..9bd6a7fb9 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/MinionType.java @@ -0,0 +1,36 @@ +package mineplex.minecraft.game.core.boss.skeletonking.minion; + +import java.lang.reflect.InvocationTargetException; + +import org.bukkit.Location; + +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; + +public enum MinionType +{ + WARRIOR(UndeadWarriorCreature.class), + ARCHER(UndeadArcherCreature.class), + WRAITH(WraithCreature.class); + + private Class _code; + + private MinionType(Class code) + { + _code = code; + } + + public EventCreature getNewInstance(WorldEvent event, Location spawn) + { + try + { + return _code.getConstructor(WorldEvent.class, Location.class).newInstance(event, spawn); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java new file mode 100644 index 000000000..395eb8fa5 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java @@ -0,0 +1,233 @@ +package mineplex.minecraft.game.core.boss.skeletonking.minion; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class UndeadArcherCreature extends EventCreature +{ + private static final int BARBED_LEVEL = 1; + private static final int LIFETIME = -1; + + public UndeadArcherCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Undead Archer", true, 25, Skeleton.class); + + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Skeleton entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setItemInHand(new ItemStack(Material.BOW)); + eq.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + eq.setItemInHandDropChance(0.f); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_HELMET)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_CHESTPLATE)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_LEGGINGS)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_BOOTS)); + } + + if (Math.random() > 0.90) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.BOW)); + } + + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.ARROW, UtilMath.r(12) + 1)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bowShoot(EntityShootBowEvent event) + { + if (BARBED_LEVEL == 0) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + if (event.getEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + event.getProjectile().setMetadata("BARBED_ARROW", new FixedMetadataValue(getEvent().getPlugin(), 2)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile projectile = event.GetProjectile(); + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + + if (projectile == null) + { + return; + } + + if (!projectile.hasMetadata("BARBED_ARROW")) + { + return; + } + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (!getEntity().equals(damager)) + { + return; + } + + // Level + if (BARBED_LEVEL == 0) + { + return; + } + + Player damageePlayer = event.GetDamageePlayer(); + + if (damageePlayer != null) + { + damageePlayer.setSprinting(false); + } + + // Damage + event.AddMod(damager.getName(), "Barbed Arrows", projectile.getMetadata("BARBED_ARROW").get(0).asDouble(), false); + + // Condition + getEvent().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); + } + + @EventHandler + public void clean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java new file mode 100644 index 000000000..c0b254717 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java @@ -0,0 +1,186 @@ +package mineplex.minecraft.game.core.boss.skeletonking.minion; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class UndeadWarriorCreature extends EventCreature +{ + private static final int LIFETIME = -1; + + public UndeadWarriorCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Undead Warrior", true, 30, Zombie.class); + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.IRON_HELMET)); + eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + eq.setBoots(new ItemStack(Material.IRON_BOOTS)); + eq.setItemInHand(new ItemStack(Material.STONE_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_HELMET)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_CHESTPLATE)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_LEGGINGS)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_BOOTS)); + } + + @EventHandler + public void leap(UpdateEvent event) + { + if (getEntity() == null) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + if (Math.random() < 0.9) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 3 || dist > 16) + return; + + + double power = 0.8 + (1.2 * ((dist-3)/13d)); + + //Leap + UtilAction.velocity(zombie, UtilAlg.getTrajectory(zombie, zombie.getTarget()), + power, false, 0, 0.2, 1, true); + + //Effect + zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void attack(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damager)) + { + if (damagee instanceof Player) + { + ((Player)damagee).setFoodLevel(((Player)damagee).getFoodLevel() - 1); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java new file mode 100644 index 000000000..6a71d40f6 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java @@ -0,0 +1,190 @@ +package mineplex.minecraft.game.core.boss.skeletonking.minion; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class WraithCreature extends EventCreature +{ + private static final int LIFETIME = -1; + + public WraithCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Wraith", true, 200, Zombie.class); + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)1)); + eq.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLACK).build()); + eq.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLACK).build()); + eq.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLACK).build()); + eq.setItemInHand(new ItemStack(Material.IRON_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 1)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_HELMET)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_CHESTPLATE)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_LEGGINGS)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_BOOTS)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damager)) + { + event.AddMult(damager.getName(), "Mystical Darkness", 2, false); + } + } + + @EventHandler + public void blink(UpdateEvent event) + { + if (getEntity() == null) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + if (Math.random() < 0.6) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 10 || dist > 25) + return; + + Location teleport = zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1); + if (UtilMath.offset(getSpawnLocation(), teleport) > 30) + { + return; + } + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); + zombie.teleport(teleport); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java index 570fb0039..d7cf66624 100755 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java @@ -25,8 +25,7 @@ public class SlimeBoss extends WorldEvent private static final int MAX_SIZE = 16; private static final int MIN_SIZE = 2; - public SlimeBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, - BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) + public SlimeBoss(DisguiseManager disguiseManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Slime King", cornerLocation, "schematic/ClansSlime.schematic"); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java deleted file mode 100644 index cf2a16e35..000000000 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java +++ /dev/null @@ -1,185 +0,0 @@ -package mineplex.minecraft.game.core.boss.spider; - -import java.util.HashMap; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.entity.ItemSpawnEvent; - -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.projectile.ProjectileManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.EventState; -import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; -import mineplex.minecraft.game.core.condition.ConditionManager; -import mineplex.minecraft.game.core.damage.DamageManager; - -public class SpiderBoss extends WorldEvent -{ - private HashMap _webDurability = new HashMap(); - - public SpiderBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, - BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) - { - super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, - "schematic/Golem.schematic"); - } - - @EventHandler - public void onWebDura(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - for (Player player : getCenterLocation().getWorld().getPlayers()) - { - if (!getEventMap().isInMap(player.getLocation())) - { - continue; - } - - loop: for (double x = -0.3; x <= 0.3; x += 0.6) - { - for (double z = -0.3; z <= 0.3; z += 0.6) - { - for (double y = -0.9; y <= 0.9; y += 1.8) - { - Block block = player.getLocation().add(x, 0.9 + y, z).getBlock(); - - if (block.getType() != Material.WEB) - { - continue; - } - - if (!_webDurability.containsKey(block)) - { - _webDurability.put(block, 0D); - } - - _webDurability.put(block, _webDurability.get(block) + 0.1); - - if (_webDurability.get(block) > 1) - { - _webDurability.remove(block); - - block.setType(Material.AIR); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB); - } - - break loop; - } - } - } - } - - Iterator itel = _webDurability.keySet().iterator(); - - while (itel.hasNext()) - { - Block block = itel.next(); - - _webDurability.put(block, _webDurability.get(block) - 0.01); - - if (_webDurability.get(block) < 0) - { - itel.remove(); - } - } - } - - @EventHandler - public void onBreak(BlockBreakEvent event) - { - Block block = event.getBlock(); - - if (!getEventMap().isInMap(block.getLocation())) - { - return; - } - - if (block.getType() != Material.WEB) - { - return; - } - - _webDurability.remove(block); - - event.setCancelled(false); - } - - @EventHandler - public void onString(ItemSpawnEvent event) - { - if (!getEventMap().isInMap(event.getLocation())) - { - return; - } - - if (event.getEntity().getItemStack().getType() != Material.STRING) - { - return; - } - - event.setCancelled(true); - } - - @Override - protected void customStart() - { - Bukkit.broadcastMessage("Custom Start"); - spawnGolem(getCenterLocation()); - setState(EventState.LIVE); - announceStart(); - } - - /** - * Check if this slime boss has been defeated - */ - private void checkDeath() - { - if (getCreatures().size() == 0) - { - setState(EventState.COMPLETE); - Bukkit.broadcastMessage("FINISHED!"); - } - } - - @Override - public void removeCreature(EventCreature creature) - { - super.removeCreature(creature); - - if (creature instanceof GolemCreature) - { - checkDeath(); - } - } - - public SpiderMinionCreature spawnMinion(Location location) - { - SpiderMinionCreature slimeCreature = new SpiderMinionCreature(this, location, 5); - registerCreature(slimeCreature); - return slimeCreature; - } - - private SpiderCreature spawnGolem(Location location) - { - SpiderCreature slimeCreature = new SpiderCreature(this, location, 2500); - registerCreature(slimeCreature); - return slimeCreature; - } - -} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java index 6dda3daa5..45a9d5c51 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java @@ -1,8 +1,10 @@ package mineplex.minecraft.game.core.combat; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.UUID; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; @@ -13,20 +15,23 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; public class CombatComponent -{ +{ private boolean _player = false; private LinkedList _damage; protected String EntityName; protected long LastDamage = 0; - + + private UUID _entityUUID; + public CombatComponent(String name, LivingEntity ent) { EntityName = name; if (ent != null) { + _entityUUID = ent.getUniqueId(); if (ent instanceof Player) { _player = true; @@ -51,6 +56,15 @@ public class CombatComponent return EntityName; } + public UUID getUniqueIdOfEntity() + { + if (_entityUUID == null) + { + return UUID.nameUUIDFromBytes(GetName().getBytes(StandardCharsets.UTF_8)); + } + return _entityUUID; + } + public LinkedList GetDamage() { if (_damage == null) @@ -58,12 +72,12 @@ public class CombatComponent return _damage; } - + public String GetReason() { if (_damage.isEmpty()) return null; - + return _damage.get(0).GetName(); } @@ -116,7 +130,7 @@ public class CombatComponent + F.elem(GetTotalDamage() + "dmg") + "" + "] [" + F.elem(GetBestWeapon()) + "] [" + F.time(time) + "]"; } - + public String Display(long _deathTime, CombatDamage damage) { // Time diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index c00c1b3d4..24a848c3e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -1,7 +1,10 @@ package mineplex.minecraft.game.core.combat; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; @@ -44,7 +47,7 @@ public class CombatManager extends MiniPlugin } private NautHashMap _active = new NautHashMap(); - private NautHashMap _combatClients = new NautHashMap(); + private Map _combatClients = new HashMap<>(); private HashSet _removeList = new HashSet(); @@ -63,12 +66,12 @@ public class CombatManager extends MiniPlugin _combatClients.remove(event.GetName()); } - public ClientCombat Get(String name) + public ClientCombat Get(UUID uuid) { - if (!_combatClients.containsKey(name)) - _combatClients.put(name, new ClientCombat()); + if (!_combatClients.containsKey(uuid)) + _combatClients.put(uuid, new ClientCombat()); - return _combatClients.get(name); + return _combatClients.get(uuid); } //This is a backup, for when CustomDamageEvent is disabled (manually) @@ -423,7 +426,7 @@ public class CombatManager extends MiniPlugin log.SetDeathTime(System.currentTimeMillis()); // Save Death - Get(event.getEntity().getName()).GetDeaths().addFirst(log); + Get(event.getEntity().getUniqueId()).GetDeaths().addFirst(log); // Add Kill/Assist int assists = 0; @@ -440,7 +443,7 @@ public class CombatManager extends MiniPlugin { log.SetKiller(log.GetAttackers().get(i)); - ClientCombat killerClient = Get(log.GetAttackers().get(i).GetName()); + ClientCombat killerClient = Get(log.GetAttackers().get(i).getUniqueIdOfEntity()); if (killerClient != null) killerClient.GetKills().addFirst(log); @@ -450,7 +453,7 @@ public class CombatManager extends MiniPlugin { assists++; - ClientCombat assistClient = Get(log.GetAttackers().get(i).GetName()); + ClientCombat assistClient = Get(log.GetAttackers().get(i).getUniqueIdOfEntity()); if (assistClient != null) assistClient.GetAssists().addFirst(log); @@ -460,7 +463,7 @@ public class CombatManager extends MiniPlugin log.SetAssists(assists); // Event - CombatDeathEvent deathEvent = new CombatDeathEvent(event, Get(event.getEntity().getName()), log, "killed"); + CombatDeathEvent deathEvent = new CombatDeathEvent(event, Get(event.getEntity().getUniqueId()), log, "killed"); UtilServer.getServer().getPluginManager().callEvent(deathEvent); //XXX Death MSG diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java index b84ac5cd0..8109e3ef2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java @@ -72,7 +72,9 @@ public class Condition protected boolean _add = false; protected boolean _live = false; - + + protected boolean _cancelPotion; + protected boolean _showIndicator = true; public Condition(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, @@ -101,6 +103,35 @@ public class Condition //Live if NOT Additive _live = !add; } + + public Condition(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, + ConditionType type, int mult, int ticks, boolean add, Material visualType, byte visualData, boolean showIndicator, boolean ambient, boolean cancelPotion) + { + Manager = manager; + _time = System.currentTimeMillis(); + + _reason = reason; + + _ent = ent; + _source = source; + + _type = type; + _mult = mult; + _ticks = ticks; + _ticksTotal = ticks; + _ambient = ambient; + + _indicatorType = visualType; + _indicatorData = visualData; + _showIndicator = showIndicator; + + _cancelPotion = cancelPotion; + + _add = add; + + //Live if NOT Additive + _live = !add; + } public boolean Tick() { @@ -124,6 +155,11 @@ public class Condition public void Add() { + if (_cancelPotion) + { + return; + } + try { PotionEffectType type = PotionEffectType.getByName(_type.toString()); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java index c976c0a54..427680a56 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java @@ -1,13 +1,15 @@ package mineplex.minecraft.game.core.condition; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.visibility.VisibilityManager; +import java.util.Iterator; + import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -371,8 +373,10 @@ public class ConditionEffect implements Listener if (event.getType() != UpdateType.TICK) return; - for (LivingEntity ent : Manager.GetActiveConditions().keySet()) + Iterator ents = Manager.GetActiveConditions().keySet().iterator(); + while (ents.hasNext()) { + LivingEntity ent = ents.next(); Condition condition = Manager.GetActiveCondition(ent, ConditionType.POISON_SHOCK); if (condition == null || condition.GetSource() == null) continue; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java index e6fac9836..fcfa571e1 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java @@ -239,10 +239,16 @@ public class ConditionFactory public Condition Poison(String reason, LivingEntity ent, LivingEntity source, double duration, int mult, boolean extend, boolean showIndicator, boolean ambient) + { + return Poison(reason, ent, source, duration, mult, extend, showIndicator, ambient, false); + } + + public Condition Poison(String reason, LivingEntity ent, LivingEntity source, + double duration, int mult, boolean extend, boolean showIndicator, boolean ambient, boolean cancelPotion) { return Manager.AddCondition(new Condition(Manager, reason, ent, source, ConditionType.POISON, mult, (int)(20 * duration), extend, - Material.SLIME_BALL, (byte)14, showIndicator, ambient)); + Material.SLIME_BALL, (byte)14, showIndicator, ambient, cancelPotion)); } public Condition PoisonShock(String reason, LivingEntity ent, LivingEntity source, diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index c679ba060..ebb331257 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -360,7 +360,7 @@ public class DamageManager extends MiniPlugin //Limit Mob/World Damage Rate if (!event.IgnoreRate()) { - if (!_combatManager.Get(damagee.getName()).CanBeHurtBy(event.GetDamagerEntity(true))) + if (!_combatManager.Get(damagee.getUniqueId()).CanBeHurtBy(event.GetDamagerEntity(true))) { event.SetCancelled("World/Monster Damage Rate"); return; @@ -381,7 +381,7 @@ public class DamageManager extends MiniPlugin //Damage Rate if (!event.IgnoreRate()) - if (!_combatManager.Get(damager.getName()).CanHurt(event.GetDamageeEntity())) + if (!_combatManager.Get(damager.getUniqueId()).CanHurt(event.GetDamageeEntity())) { event.SetCancelled("PvP Damage Rate"); return; @@ -545,13 +545,19 @@ public class DamageManager extends MiniPlugin origin = event.GetDamagerEntity(true).getLocation(); if (event.getKnockbackOrigin() != null) origin = event.getKnockbackOrigin(); - else if (event.GetProjectile() != null) - origin = event.GetProjectile().getLocation(); //Vec Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation()); trajectory.multiply(0.6 * knockback); trajectory.setY(Math.abs(trajectory.getY())); + + if (event.GetProjectile() != null && event.getKnockbackOrigin() == null) + { + trajectory = event.GetProjectile().getVelocity(); + trajectory.setY(0); + trajectory.multiply(0.37 * knockback / trajectory.length()); + trajectory.setY(0.06); + } //Apply double vel = 0.2 + trajectory.length() * 0.8; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java index cd172b8e5..2153d4758 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java @@ -1,8 +1,8 @@ package mineplex.serverdata.commands; -public interface CommandCallback +public interface CommandCallback { - public void run(ServerCommand command); + void run(T command); } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java index 0b0779035..089f29e97 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java @@ -117,7 +117,7 @@ public class ServerCommandManager * Register a new type of {@link ServerCommand}. * @param commandType - the {@link ServerCommand} type to register. */ - public void registerCommandType(String commandName, Class commandType, CommandCallback callback) + public void registerCommandType(String commandName, Class commandType, CommandCallback callback) { if (_commandTypes.containsKey(commandName)) { @@ -128,12 +128,12 @@ public class ServerCommandManager _commandTypes.put(commandName, cmdType); System.out.println("Registered : " + commandName); } - - public void registerCommandType(Class commandType, CommandCallback callback) + + public void registerCommandType(Class commandType, CommandCallback callback) { registerCommandType(commandType.getSimpleName(), commandType, callback); } - + public void registerCommandType(String commandName, Class commandType) { registerCommandType(commandName, commandType, null); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 282933d23..124d6dc2a 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -1,7 +1,6 @@ package mineplex.staffServer; -import java.util.UUID; - +import com.mojang.authlib.GameProfile; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -9,12 +8,14 @@ import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.Rank; import mineplex.core.creature.Creature; +import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.memory.MemoryFix; import mineplex.core.monitor.LagMeter; import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.profileCache.ProfileCacheManager; @@ -27,12 +28,13 @@ import mineplex.core.updater.Updater; import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.salespackage.SalesPackageManager; import net.minecraft.server.v1_8_R3.MinecraftServer; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.plugin.java.JavaPlugin; -import com.mojang.authlib.GameProfile; +import java.util.UUID; + +import static mineplex.core.Managers.require; public class StaffServer extends JavaPlugin { @@ -58,7 +60,7 @@ public class StaffServer extends JavaPlugin Punish punish = new Punish(this, webServerAddress, clientManager); new NpcManager(this, new Creature(this)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); - PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager, donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager); preferenceManager.GiveItem = false; Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); @@ -66,7 +68,10 @@ public class StaffServer extends JavaPlugin new Chat(this, null, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager, null, eloManager), serverStatusManager.getCurrentServerName()); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + + require(PacketHandler.class); + require(DisguiseManager.class); + require(AntiHack.class); new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), new StatsManager(this, clientManager))); //new Password(this, serverStatusManager.getCurrentServerName()); @@ -82,18 +87,19 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou")); - ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EvilEsther")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EstherCS")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Timmy48081_")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("231fb752-9556-489b-8428-f47c7598e061"), "Nuclear_Poptart")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("a47a4d04-9f51-44ba-9d35-8de6053e9289"), "AlexTheCoder")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD")); - new ProfileCacheManager(this); + require(ProfileCacheManager.class); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index c91f53c0e..ae823b7fa 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -5,11 +5,13 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.UUID; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -17,11 +19,8 @@ import mineplex.core.donation.DonationManager; import mineplex.core.donation.Donor; import mineplex.core.donation.repository.token.CoinTransactionToken; import mineplex.core.donation.repository.token.TransactionToken; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.mount.Mount; import mineplex.serverdata.database.ResultSetCallable; import mineplex.staffServer.salespackage.SalesPackageManager; - import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -92,18 +91,18 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(F.main(getName(), "Usage : /check defek7")); } - public void addAgentMapping(Player caller, String playerName) + public void addAgentMapping(Player caller, CoreClient client) { if (!_agentCacheMap.containsKey(caller)) _agentCacheMap.put(caller, new HashSet()); - _agentCacheMap.get(caller).add(playerName); + _agentCacheMap.get(caller).add(client.getName()); } - public void showPlayerInfo(Player caller, String playerName) + public void showPlayerInfo(Player caller, CoreClient client) { - CoreClient client = _clientManager.Get(playerName); - Donor donor = _donationManager.Get(playerName); + String playerName = client.getName(); + Donor donor = _donationManager.Get(client.getUniqueId()); CustomerSupport instance = this; runAsync(new Runnable() @@ -119,8 +118,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cDGreen + C.Strike + "============================================="); caller.sendMessage(C.cBlue + "Name: " + C.cYellow + playerName); caller.sendMessage(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name))); - caller.sendMessage(C.cBlue + "Shards: " + C.cYellow + donor.getCoins()); - caller.sendMessage(C.cBlue + "Gems: " + C.cYellow + donor.GetGems()); + caller.sendMessage(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); + caller.sendMessage(C.cBlue + "Gems: " + C.cYellow + donor.getBalance(GlobalCurrency.GEM)); int enjinCoinsReceived = 0; int oldChestsReceived = 0; @@ -131,6 +130,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int valentinesGiftsReceived = 0; int boostersReceived = 0; int freedomChestsReceived = 0; + int runeAmplifier20 = 0; + int runeAmplifier60 = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -229,7 +230,26 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable else if (transaction.SalesPackageName.split(" ").length == 2) boostersReceived += 1; } - + } + if (transaction.SalesPackageName.startsWith("Rune Amplifier 20")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + runeAmplifier20 += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + runeAmplifier20 += 1; + } + } + if (transaction.SalesPackageName.startsWith("Rune Amplifier 60")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + runeAmplifier60 += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + runeAmplifier60 += 1; + } } } @@ -240,6 +260,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived); caller.sendMessage(C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); + caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min) Received: " + C.cYellow + runeAmplifier20); + caller.sendMessage(C.cBlue + "Rune Amplifiers (60 min) Received: " + C.cYellow + runeAmplifier60); caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); @@ -254,13 +276,16 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _salesPackageManager.displaySalesPackages(caller, playerName); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); - caller.sendMessage(C.cBlue + "Freedom Mount: " + getLockedFreedomStr(playerName, "Freedom Mount")); - caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(playerName, "Uncle Sam Morph")); - caller.sendMessage(C.cBlue + "Freedom Aura: " + getLockedFreedomStr(playerName, "Freedom Aura")); - caller.sendMessage(C.cBlue + "Shock and Awe: " + getLockedFreedomStr(playerName, "Shock and Awe")); - caller.sendMessage(C.cBlue + "Leap of Freedom: " + getLockedFreedomStr(playerName, "Leap of Freedom")); - caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(playerName, "Price of Freedom")); - caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(playerName, "Uncle Sam Hat")); + caller.sendMessage(C.cBlue + "Freedom Mount: " + getLockedFreedomStr(client.getUniqueId(), "Freedom Mount")); + caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(client.getUniqueId(), "Uncle Sam Morph")); + caller.sendMessage(C.cBlue + "Freedom Aura: " + getLockedFreedomStr(client.getUniqueId(), "Freedom Aura")); + caller.sendMessage(C.cBlue + "Shock and Awe: " + getLockedFreedomStr(client.getUniqueId(), "Shock and Awe")); + caller.sendMessage(C.cBlue + "Leap of Freedom: " + getLockedFreedomStr(client.getUniqueId(), "Leap of Freedom")); + caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(client.getUniqueId(), "Price of Freedom")); + caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(client.getUniqueId(), "Uncle Sam Hat")); + caller.sendMessage(C.cDGreen + C.Strike + "============================================="); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage")); + caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _accountBonusLog.remove(client.getAccountId()); @@ -314,9 +339,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _accountBonusLog.put(accountId, log); } - private String getLockedFreedomStr(String player, String name) + private String getLockedFreedomStr(UUID uuid, String name) { - if (_donationManager.Get(player).OwnsUnknownPackage(name)) + if (_donationManager.Get(uuid).OwnsUnknownPackage(name)) { return C.cGreen + C.Bold + "Unlocked"; } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index 63f11315b..62017cba3 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -1,5 +1,7 @@ package mineplex.staffServer.customerSupport; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -24,21 +26,22 @@ public class checkCommand extends CommandBase { String playerName = args[0]; - _commandCenter.GetClientManager().checkPlayerName(caller, playerName, new Callback() + _commandCenter.GetClientManager().checkPlayerName(caller, playerName, name -> { - public void run(final String name) + if (name != null) { - if (name != null) + _commandCenter.GetClientManager().loadClientByName(name, client -> { - _commandCenter.GetClientManager().loadClientByName(name, new Runnable() + if (client != null) { - public void run() - { - Plugin.showPlayerInfo(caller, name); - Plugin.addAgentMapping(caller, name); - } - }); - } + Plugin.showPlayerInfo(caller, client); + Plugin.addAgentMapping(caller, client); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not load data for " + name)); + } + }); } }); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 67dea4d96..e93d43c34 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -54,6 +54,10 @@ public class SalesPackageManager extends MiniPlugin //AddSalesPackage(new ValentinesGift(this)); AddSalesPackage(new FrostLord(this)); AddSalesPackage(new EasterBunny(this)); + AddSalesPackage(new ClanBannerUsage(this)); + AddSalesPackage(new ClanBannerEditor(this)); + AddSalesPackage(new RuneAmplifier(this, 20)); + AddSalesPackage(new RuneAmplifier(this, 60)); } private void AddSalesPackage(SalesPackageBase salesPackage) @@ -97,6 +101,7 @@ public class SalesPackageManager extends MiniPlugin JsonMessage coinBuilder = new JsonMessage("Shards : ").color("blue"); JsonMessage packageBuilder = new JsonMessage("Rank Packages : ").color("blue"); JsonMessage chestBuilder = new JsonMessage("Chest Packages : ").color("blue"); + JsonMessage clanBuilder = new JsonMessage("Clan Packages : ").color("blue"); for (SalesPackageBase salesPackage : _salesPackages.values()) { @@ -108,6 +113,10 @@ public class SalesPackageManager extends MiniPlugin { chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } + else if (salesPackage instanceof ClanBannerEditor || salesPackage instanceof ClanBannerUsage || salesPackage instanceof RuneAmplifier) + { + clanBuilder = clanBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); + } else { packageBuilder = packageBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); @@ -117,6 +126,7 @@ public class SalesPackageManager extends MiniPlugin coinBuilder.sendToPlayer(caller); chestBuilder.sendToPlayer(caller); packageBuilder.sendToPlayer(caller); + clanBuilder.sendToPlayer(caller); } public StatsManager getStatsManager() diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java index 3ced1fbc3..f4d3cca6f 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java @@ -29,33 +29,24 @@ public class CoinCommand extends CommandBase final String playerName = args[0]; final int amount = Integer.parseInt(args[1]); - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + Plugin.getClientManager().loadClientByName(playerName, client -> { - public void run() + if (client != null) { - CoreClient client = Plugin.getClientManager().Get(playerName); - - if (client != null) + Plugin.getDonationManager().RewardCoins(completed -> { - Plugin.getDonationManager().RewardCoins(new Callback() + if (completed) { - public void run(Boolean completed) - { - if (completed) - { - caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " shards to " + playerName + "'s account!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Shards") + " to " + F.name(playerName) + ".")); - } - } - }, caller.getName(), playerName, client.getAccountId(), amount); - - } - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " shards to " + playerName + "'s account!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Shards") + " to " + F.name(playerName) + ".")); + } + }, caller.getName(), playerName, client.getAccountId(), amount); } + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); }); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java index 62258e3af..f77065d03 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -1,13 +1,12 @@ package mineplex.staffServer.salespackage.command; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; public class GemHunterCommand extends CommandBase { @@ -33,21 +32,16 @@ public class GemHunterCommand extends CommandBase final long experience = tempExp; - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + Plugin.getClientManager().loadClientByName(playerName, client -> { - public void run() + if (client != null) { - CoreClient client = Plugin.getClientManager().Get(playerName); - - if (client != null) - { - Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, client.getAccountId(), "Gem Hunter Level " + amount, CurrencyType.GEM, 0, false); - Plugin.getStatsManager().incrementStat(client.getAccountId(), "Global.GemsEarned", experience); - caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); - } - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, client.getAccountId(), "Gem Hunter Level " + amount, GlobalCurrency.GEM, 0, false); + Plugin.getStatsManager().incrementStat(client.getAccountId(), "Global.GemsEarned", experience); + caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); } - }); + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + }); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java index 0e30045b5..c983848f0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java @@ -1,18 +1,17 @@ package mineplex.staffServer.salespackage.command; -import java.util.UUID; - -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.server.util.TransactionResponse; import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +import java.util.UUID; public class ItemCommand extends CommandBase { @@ -26,57 +25,53 @@ public class ItemCommand extends CommandBase { if (args == null) return; - + final String playerName = args[0]; int amountSpecified = Integer.parseInt(args[1]); final String category = args[2]; String tempName = args[3]; - + for (int i = 4; i < args.length; i++) { tempName += " " + args[i]; } - + final String itemName = tempName; final int amount = amountSpecified; - + if (!Plugin.getInventoryManager().validItem(itemName)) { caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Item.")); return; } - - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + + Plugin.getClientManager().loadClientByName(playerName, client -> { - public void run() + final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); + + if (uuid != null) { - final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); - final CoreClient client = Plugin.getClientManager().Get(playerName); - - if (uuid != null) + Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback() { - Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback() + public void run(TransactionResponse data) { - public void run(TransactionResponse data) + Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback() { - Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback() + public void run(Boolean success) { - public void run(Boolean success) + if (success) + UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + ".")); + else { - if (success) - UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + ".")); - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + ".")); - } + UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + ".")); } - }, uuid, itemName, amount); - } - }, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), CurrencyType.GEM, 0, false); - } - else - caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + } + }, uuid, itemName, amount); + } + }, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false); } + else + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); }); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java new file mode 100644 index 000000000..7c998baeb --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class ClanBannerEditor extends SalesPackageBase +{ + public ClanBannerEditor(SalesPackageManager manager) + { + super(manager, "Clan Banner Editor Access"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Unlock Clan Banner Editor", "Give Clan Banner Editor access."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java new file mode 100644 index 000000000..4edce3544 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class ClanBannerUsage extends SalesPackageBase +{ + public ClanBannerUsage(SalesPackageManager manager) + { + super(manager, "Clan Banner Usage Access"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Unlock Clan Banner Usage", "Give Clan Banner Usage access."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java new file mode 100644 index 000000000..18c1054fb --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java @@ -0,0 +1,22 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +public class RuneAmplifier extends SalesPackageBase +{ + private int _minutes; + + public RuneAmplifier(SalesPackageManager manager, int minutes) + { + super(manager, "1 " + minutes + " minutes Rune Amplifier"); + _minutes = minutes; + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Rune Amplifier " + _minutes, "Give 1 " + _minutes + " minute Rune Amplifier."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/plugin.yml b/Plugins/Nautilus.Game.Arcade/plugin.yml index 808eefbe4..e03cfc73b 100644 --- a/Plugins/Nautilus.Game.Arcade/plugin.yml +++ b/Plugins/Nautilus.Game.Arcade/plugin.yml @@ -1,3 +1,4 @@ name: Arcade main: nautilus.game.arcade.Arcade -version: 0.1 \ No newline at end of file +version: 0.1 +loadbefore: [MineplexAnticheat] \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 08de28ad9..0f052bbfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,25 +1,14 @@ package nautilus.game.arcade; -import java.io.File; -import java.util.HashMap; - -import mineplex.core.boosters.BoosterManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; -import mineplex.core.customdata.CustomDataManager; -import mineplex.core.globalpacket.GlobalPacketManager; -import net.minecraft.server.v1_8_R3.BiomeBase; -import net.minecraft.server.v1_8_R3.MinecraftServer; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; +import mineplex.core.boosters.BoosterManager; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.events.ServerShutdownEvent; @@ -27,12 +16,14 @@ import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.give.Give; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; @@ -57,6 +48,7 @@ import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; @@ -64,6 +56,16 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import net.minecraft.server.v1_8_R3.BiomeBase; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; +import java.util.HashMap; + +import static mineplex.core.Managers.require; public class Arcade extends JavaPlugin { @@ -98,7 +100,7 @@ public class Arcade extends JavaPlugin CommandCenter.Initialize(this); _clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(_clientManager); - new ProfileCacheManager(this); + require(ProfileCacheManager.class); ItemStackFactory.Initialize(this, false); @@ -113,14 +115,13 @@ public class Arcade extends JavaPlugin _serverConfiguration = new ServerConfiguration(this, _clientManager); - PacketHandler packetHandler = new PacketHandler(this); + PacketHandler packetHandler = require(PacketHandler.class); IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager); incognito.setPreferencesManager(preferenceManager); - Creature creature = new Creature(this); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager); @@ -128,14 +129,15 @@ public class Arcade extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + DisguiseManager disguiseManager = require(DisguiseManager.class); NpcManager npcmanager = new NpcManager(this, creature); _damageManager = new DamageManager(this, new CombatManager(this), npcmanager, disguiseManager, null); Punish punish = new Punish(this, webServerAddress, _clientManager); - AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); - AntiHack.Instance.setKick(false); + + AntiHack antiHack = require(AntiHack.class); + antiHack.setKick(false); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, _clientManager); @@ -159,7 +161,8 @@ public class Arcade extends JavaPlugin PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager); - BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager); + ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); + BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); cosmeticManager.setInterfaceSlot(6); cosmeticManager.disableTeamArmor(); @@ -168,7 +171,7 @@ public class Arcade extends JavaPlugin //Arcade Manager PollManager pollManager = new PollManager(this, _clientManager, _donationManager); - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager, boosterManager); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager, thankManager, boosterManager); new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager, _gameManager.getBonusManager().getRewardManager()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 6b41a4d91..7ec4136af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,6 +1,8 @@ package nautilus.game.arcade; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; @@ -9,15 +11,25 @@ import mineplex.core.bonuses.BonusManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.PlayerDisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; +import mineplex.core.event.JoinMessageBroadcastEvent; import mineplex.core.explosion.Explosion; import mineplex.core.explosion.ExplosionEvent; import mineplex.core.facebook.FacebookManager; @@ -28,6 +40,7 @@ import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.menu.MenuManager; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -42,11 +55,14 @@ import mineplex.core.punish.Punish; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; +import mineplex.core.scoreboard.MineplexScoreboard; +import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.timing.TimingManager; import mineplex.core.titangiveaway.TitanGiveawayManager; import mineplex.core.valentines.ValentinesGiftManager; @@ -67,7 +83,6 @@ import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.addons.TeamArmorAddon; import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.booster.GameBoosterManager; -import nautilus.game.arcade.command.DisguiseCommand; import nautilus.game.arcade.command.GameCmdModeCommand; import nautilus.game.arcade.command.GameCommand; import nautilus.game.arcade.command.KitUnlockCommand; @@ -80,13 +95,32 @@ import nautilus.game.arcade.game.GameServerConfig; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.event.EventModule; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.uhc.UHC; -import nautilus.game.arcade.managers.*; +import nautilus.game.arcade.managers.GameAchievementManager; +import nautilus.game.arcade.managers.GameCreationManager; +import nautilus.game.arcade.managers.GameFlagManager; +import nautilus.game.arcade.managers.GameHostManager; +import nautilus.game.arcade.managers.GameLobbyManager; +import nautilus.game.arcade.managers.GameLootManager; +import nautilus.game.arcade.managers.GameManager; +import nautilus.game.arcade.managers.GamePlayerManager; +import nautilus.game.arcade.managers.GameRewardManager; +import nautilus.game.arcade.managers.GameSpectatorManager; +import nautilus.game.arcade.managers.GameStatManager; +import nautilus.game.arcade.managers.GameTestingManager; +import nautilus.game.arcade.managers.GameTournamentManager; +import nautilus.game.arcade.managers.GameWorldManager; +import nautilus.game.arcade.managers.IdleManager; +import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.managers.ProgressingKitManager; +import nautilus.game.arcade.managers.ServerUptimeManager; import nautilus.game.arcade.managers.chat.GameChatManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import net.minecraft.server.v1_8_R3.EntityLiving; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -98,13 +132,20 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; -import org.bukkit.event.block.*; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.potion.PotionEffect; +import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; import java.io.File; @@ -172,7 +213,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation private BoosterManager _boosterManager; private GameSpectatorManager _spectatorManager; private ServerUptimeManager _serverUptimeManager; - + private ScoreboardManager _scoreboardManager; + private IncognitoManager _incognitoManager; private TaskManager _taskManager; @@ -203,14 +245,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, - NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, BoosterManager boosterManager) + NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, ThankManager thankManager, BoosterManager boosterManager) { super("Game Manager", plugin); _serverConfig = serverConfig; // Modules - _blockRestore = new BlockRestore(plugin); + _blockRestore = Managers.get(BlockRestore.class); _incognitoManager = incognitoManager; @@ -288,7 +330,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation new GameStatManager(this); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), boosterManager); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager); new GameLootManager(this, petManager, _bonusManager.getRewardManager()); _spectatorManager = new GameSpectatorManager(this); _gameWorldManager = new GameWorldManager(this); @@ -299,7 +341,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation // new HolidayManager(this, titanGiveaway); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); new GameTestingManager(this); - new PlayerDisguiseManager(plugin, _clientManager); + require(PlayerDisguiseManager.class); new GameBoosterManager(plugin, boosterManager, disguiseManager, hologramManager, npcManager, serverConfig.BoosterGroup); // Game Addons @@ -331,7 +373,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); - + if (GetHost() != null && !GetHost().isEmpty()) { Bukkit.getScheduler().runTaskLater(plugin, () -> Portal.transferPlayer(GetHost(), _serverStatusManager.getCurrentServerName()), 80L); @@ -340,6 +382,187 @@ public class ArcadeManager extends MiniPlugin implements IRelation loadRequiredRank(); _gameCommandMode = checkGameCommandMode(); + + this._scoreboardManager = new ScoreboardManager(_plugin) + { + @Override + public void handlePlayerJoin(String playerName) + { + CoreClient client = GetClients().Get(playerName); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(playerName); + } + + Player player = Bukkit.getPlayerExact(playerName); + + if (player != null && get(player) != null) + { + for (Player player1 : Bukkit.getOnlinePlayers()) + { + client = GetClients().Get(player1); + + get(player).getHandle().getTeam(client.getRealOrDisguisedRank().Name).addEntry(player1.getName()); + } + } + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) + { + GameTeam gameTeam = null; + if (GetGame() != null && GetGame().GetTeam(onlinePlayer) != null) + gameTeam = GetGame().GetTeam(onlinePlayer); + + _gameLobbyManager.AddPlayerToScoreboards(onlinePlayer, gameTeam); + } + + System.out.println("Handling player join " + playerName + " " + player.getName() + " " + GetGame()); + + if (GetGame() != null) + { + System.out.println(GetGame().IsAlive(player)); + if (GetGame().IsAlive(player)) + { + GetGame().GetScoreboard().setPlayerTeam(player, GetGame().GetTeam(player)); + } + else + { + GetGame().GetScoreboard().setSpectating(player); + } + } + } + + @Override + public void handlePlayerQuit(String playerName) + { + CoreClient client = GetClients().Get(playerName); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().Name).removeEntry(playerName); + } + } + + @Override + public void setup(MineplexScoreboard scoreboard) + { + for (Rank rank : Rank.values()) + { + if (rank == Rank.ALL) + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(""); + else + scoreboard.getHandle().registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + } + + scoreboard.register(ArcadeScoreboardLine.PLAYERS_SPACER) + .register(ArcadeScoreboardLine.PLAYERS_NAME) + .register(ArcadeScoreboardLine.PLAYERS_VALUE) + .register(ArcadeScoreboardLine.KIT_SPACER) + .register(ArcadeScoreboardLine.KIT_NAME) + .register(ArcadeScoreboardLine.KIT_VALUE) + .register(ArcadeScoreboardLine.GEM_SPACER) + .register(ArcadeScoreboardLine.GEM_NAME) + .register(ArcadeScoreboardLine.GEM_VALUE) + .register(ArcadeScoreboardLine.SERVER_SPACER) + .register(ArcadeScoreboardLine.SERVER_NAME) + .register(ArcadeScoreboardLine.SERVER_VALUE) + .recalculate(); + + scoreboard.get(ArcadeScoreboardLine.PLAYERS_NAME).write(C.cYellow + C.Bold + "Players"); + scoreboard.get(ArcadeScoreboardLine.KIT_NAME).write(C.cGray + C.Bold + "Kit"); + scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGreen + C.Bold + "Gems"); + scoreboard.get(ArcadeScoreboardLine.SERVER_NAME).write(C.cAqua + C.Bold + "Server"); + scoreboard.get(ArcadeScoreboardLine.SERVER_VALUE).write(_plugin.getConfig().getString("serverstatus.name")); + } + + @Override + public void draw(MineplexScoreboard scoreboard) + { + if (GetGame() != null && GetGame().GetCountdown() >= 0) + { + if (GetGame().GetCountdown() > 0) + scoreboard.setSidebarName(C.Bold + "§lStarting in " + C.cGreen + "§l" + GetGame().GetCountdown() + (GetGame().GetCountdown() == 1 ? " Second" : " Seconds")); + else if (GetGame().GetCountdown() == 0) + scoreboard.setSidebarName(ChatColor.WHITE + "§lIn Progress..."); + } + else + { + if (GetGame() instanceof UHC && !((UHC) GetGame()).isMapLoaded()) + { + scoreboard.setSidebarName(((UHC) GetGame()).getObjectiveName(_gameLobbyManager._colorTick)); + } + else + { + scoreboard.setSidebarName(ChatColor.GREEN + "§l" + "Waiting for Players"); + } + } + + int spectatorCount = 0; + + for (Player players : UtilServer.getPlayersCollection()) + { + if (isVanished(players)) + { + spectatorCount++; + } + } + + scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(UtilServer.getPlayers().length - spectatorCount + "/" + GetPlayerFull()); + scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + + if (GetGame() != null) + { + ChatColor teamColor = null; + String kitName = "None"; + + if (GetGame().GetTeam(scoreboard.getOwner()) != null) + { + teamColor = GetGame().GetTeam(scoreboard.getOwner()).GetColor(); + } + + if (GetGame().GetKit(scoreboard.getOwner()) != null) + { + kitName = GetGame().GetKit(scoreboard.getOwner()).GetName() + ""; + } + + if (teamColor == null) + { + teamColor = ChatColor.GRAY; + } + + scoreboard.get(ArcadeScoreboardLine.KIT_NAME).write(teamColor + C.Bold + "Kit"); + scoreboard.get(ArcadeScoreboardLine.KIT_VALUE).write(kitName); + } + + if (GetGame() instanceof MinecraftLeague) + { + if (!scoreboard.isRegistered(ArcadeScoreboardLine.DIVISION_SPACER)) + { + scoreboard.register(ArcadeScoreboardLine.DIVISION_SPACER) + .register(ArcadeScoreboardLine.DIVISION_NAME) + .register(ArcadeScoreboardLine.DIVISION_VALUE) + .recalculate(); + } + scoreboard.get(ArcadeScoreboardLine.DIVISION_NAME).write(C.cPurpleB + "Division"); + + + EloManager.EloDivision ed = EloManager.EloDivision.getDivision(getEloManager().getElo(scoreboard.getOwner(), GetGame().GetType().getGameId())); + scoreboard.get(ArcadeScoreboardLine.DIVISION_VALUE).write(ed.getDisplayName()); + } + else + { + if (scoreboard.isRegistered(ArcadeScoreboardLine.DIVISION_SPACER)) + { + scoreboard.unregister(ArcadeScoreboardLine.DIVISION_SPACER) + .unregister(ArcadeScoreboardLine.DIVISION_NAME) + .unregister(ArcadeScoreboardLine.DIVISION_VALUE) + .recalculate(); + } + } + } + }; + new MenuManager(_plugin); + Managers.put(this._scoreboardManager, ScoreboardManager.class); } @Override @@ -348,7 +571,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new GameCommand(this)); addCommand(new WriteCommand(this)); addCommand(new KitUnlockCommand(this)); - addCommand(new DisguiseCommand(this)); addCommand(new RequiredRankCommand(this)); addCommand(new GameCmdModeCommand(this)); } @@ -548,7 +770,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _serverStatusManager; } - public CustomDataManager getCustomDataManager() { return _customDataManager; } + public CustomDataManager getCustomDataManager() + { + return _customDataManager; + } public ChatColor GetColor(Player player) { @@ -615,12 +840,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void StaffIncognito(IncognitoStatusChangeEvent event) - { - if(event.getNewState()) //Is going into incognito + { + if (event.getNewState()) //Is going into incognito { UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); - - if(_game.GetCountdown() > 0) //Lobby is counting down + + if (_game.GetCountdown() > 0) //Lobby is counting down { // Clean if (_game != null) @@ -639,11 +864,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } } - else if(_game.GetState() != GameState.Recruit) //Game is NOT in lobby + else if (_game.GetState() != GameState.Recruit) //Game is NOT in lobby { addSpectator(event.getPlayer(), true); _specList.add(event.getPlayer()); - if(_game.GetTeam(event.getPlayer()) != null) + if (_game.GetTeam(event.getPlayer()) != null) _game.GetTeam(event.getPlayer()).SetPlayerState(event.getPlayer(), PlayerState.OUT); } else //Game is in lobby @@ -654,11 +879,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation else //Is coming out of incognito { UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); - - if(!(_game.GetState() == GameState.Live || _game.GetState() == GameState.Prepare)) + + if (!(_game.GetState() == GameState.Live || _game.GetState() == GameState.Prepare)) { _specList.remove(event.getPlayer()); - if(_game.GetTeam(event.getPlayer()) != null) + if (_game.GetTeam(event.getPlayer()) != null) _game.GetTeam(event.getPlayer()).SetPlayerState(event.getPlayer(), PlayerState.IN); } @@ -731,8 +956,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageJoin(PlayerJoinEvent event) { - String name = event.getPlayer().getName(); - if (_incognitoManager.Get(event.getPlayer()).Status) { event.setJoinMessage(null); @@ -743,10 +966,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation return; if (_game != null && _game.AnnounceJoinQuit) - event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name)); - + { + JoinMessageBroadcastEvent joinMessageBroadcastEvent = new JoinMessageBroadcastEvent(event.getPlayer()); + UtilServer.CallEvent(joinMessageBroadcastEvent); + if (joinMessageBroadcastEvent.getUsername() != null) + { + event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + joinMessageBroadcastEvent.getUsername())); + } + } else + { event.setJoinMessage(null); + } } @EventHandler @@ -807,7 +1038,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation 8, ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, (short) 0, C.cGreen + "Return to Hub", new String[]{"", ChatColor.RESET + "Click while holding this", - ChatColor.RESET + "to return to the Hub."})); + ChatColor.RESET + "to return to the Hub."})); UtilInv.Update(player); } @@ -818,14 +1049,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (Bukkit.getServer().hasWhitelist()) { - if(_requiredRank != null) + if (_requiredRank != null) { - if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), _requiredRank, false)) + if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), _requiredRank, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); - if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) + if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) { event.getPlayer().setOp(true); } @@ -846,9 +1077,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation return; } } - if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false) || - _clientManager.Get(event.getPlayer().getName()).GetRank() == Rank.MAPDEV || - _clientManager.Get(event.getPlayer().getName()).GetRank() == Rank.MAPLEAD) + if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false) || + _clientManager.Get(event.getPlayer().getUniqueId()).GetRank() == Rank.MAPDEV || + _clientManager.Get(event.getPlayer().getUniqueId()).GetRank() == Rank.MAPLEAD) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -879,14 +1110,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { - if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - else if (_clientManager.Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.ULTRA, false) - || _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA")) + else if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.ULTRA, false) + || _donationManager.Get(event.getPlayer().getUniqueId()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA")) { if (GetGame() != null && GetGame().DontAllowOverfill) @@ -942,6 +1173,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation /** * Checks if a player is participating in/has been participating in the current game + * * @param player The player to check * @return Whether they are/have been playing */ @@ -1013,8 +1245,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation HubClock(player); - GetDisguise().undisguise(player); - Gadget morph = getCosmeticManager().getGadgetManager().getActive(player, GadgetType.MORPH); if (morph != null && morph.isActive(player)) morph.disable(player); @@ -1026,7 +1256,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation File folder = new File(".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar + "maps" + File.separatorChar + gameName); - System.out.println(folder.getAbsolutePath()+" -=-=-=-=-=" ); + System.out.println(folder.getAbsolutePath() + " -=-=-=-=-="); if (!folder.exists()) folder.mkdirs(); @@ -1199,7 +1429,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation } return _specList.contains(player); } - + public boolean isVanished(Player player) { return _incognitoManager.Get(player).Status; @@ -1474,11 +1704,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0, 0); if (reward.canGiveReward(player)) - reward.giveReward(null, player, data -> { + reward.giveReward(null, player, data -> + { }); } - + public void enableChampionsModules() { _classManager.setEnabled(true); @@ -1487,11 +1718,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation _itemFactory.registerSelf(); _energy.registerSelf(); _eloManager.registerSelf(); - + //Class Shop _plugin.getServer().getPluginManager().registerEvents(_classShop, _plugin); } - + public void disableChampionsModules() { _classManager.setEnabled(false); @@ -1500,11 +1731,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation _itemFactory.deregisterSelf(); _energy.deregisterSelf(); _eloManager.deregisterSelf(); - + //Class Shop HandlerList.unregisterAll(_classShop); } - + public void toggleChampionsModules(GameType gameType) { boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM || gameType == GameType.ChampionsCTF || gameType == GameType.BossBattles; @@ -1544,7 +1775,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation player.teleport(GetGame().GetSpectatorLocation()); //Set Spec State - UtilAction.velocity(player, new Vector(0,1,0)); + UtilAction.velocity(player, new Vector(0, 1, 0)); player.setAllowFlight(true); player.setFlying(true); player.setFlySpeed(0.1f); @@ -1555,7 +1786,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true); //Game Team - GetGame().GetScoreboard().SetPlayerTeam(player, "SPEC"); + GetGame().GetScoreboard().setSpectating(player); } public boolean isSpectator(Entity player) @@ -1569,9 +1800,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { _requiredRank = null; - for(File file : new File(".").listFiles()) + for (File file : new File(".").listFiles()) { - if(!file.getName().startsWith("RequiredRank")) + if (!file.getName().startsWith("RequiredRank")) continue; try @@ -1599,7 +1830,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _requiredRank = rank; } - @EventHandler(priority=EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST) public void explosionCancel(EntityExplodeEvent event) { if (GetGame() == null || !GetGame().InProgress()) @@ -1697,6 +1928,55 @@ public class ArcadeManager extends MiniPlugin implements IRelation return true; } + @EventHandler + public void clearDisguises(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Dead) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + while (true) + { + DisguiseBase activeDisguise = _disguiseManager.getActiveDisguise(player); + if (activeDisguise == null) + { + break; + } + if (!(activeDisguise instanceof DisguisePlayer)) + { + _disguiseManager.undisguise(player); + } + else + { + break; + } + } + } + } + } + + @EventHandler + public void clearGameTeams(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Dead) + { + for (MineplexScoreboard scoreboard : _scoreboardManager.getScoreboards().values()) + { + for (Team team : scoreboard.getHandle().getTeams()) + { + if (team.getName().startsWith("GT")) + { + team.unregister(); + } + } + } + for (Player player : Bukkit.getOnlinePlayers()) + { + _gameLobbyManager.AddPlayerToScoreboards(player, null); + } + } + } + public ProgressingKitManager getProgressionKitManager() { return _progressionKitManager; @@ -1711,4 +1991,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _spectatorManager; } + + public ScoreboardManager getScoreboardManager() + { + return this._scoreboardManager; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java new file mode 100644 index 000000000..d2c1d202c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeScoreboardLine.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade; + +import mineplex.core.scoreboard.ScoreboardLine; + +public enum ArcadeScoreboardLine implements ScoreboardLine +{ + PLAYERS_SPACER, + PLAYERS_NAME, + PLAYERS_VALUE, + KIT_SPACER, + KIT_NAME, + KIT_VALUE, + GEM_SPACER, + GEM_NAME, + GEM_VALUE, + SERVER_SPACER, + SERVER_NAME, + SERVER_VALUE, + DIVISION_SPACER, + DIVISION_NAME, + DIVISION_VALUE +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java index 8c6139b9f..9865c3c98 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/BoosterPodium.java @@ -4,9 +4,10 @@ import mineplex.core.MiniPlugin; import mineplex.core.boosters.Booster; import mineplex.core.boosters.event.BoosterActivateEvent; import mineplex.core.boosters.event.BoosterExpireEvent; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.common.util.*; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.itemstack.ItemBuilder; @@ -15,6 +16,8 @@ import mineplex.core.npc.NpcManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.database.tables.records.NpcsRecord; + +import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -177,7 +180,7 @@ public class BoosterPodium extends MiniPlugin return new String[] { C.cGreen + "Amplified by " + C.cWhite + booster.getPlayerName(), C.cWhite + booster.getTimeRemainingString() + " Remaining", - C.cAqua + "Click to Thank. You get " + BoosterTipManager.TIP_FOR_TIPPER + " Treasure Shards" + C.cAqua + "Click to Thank. You get " + BoosterThankManager.TIP_FOR_TIPPER + " Treasure Shards" }; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 764fc09ef..90d0aad03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -4,13 +4,13 @@ import mineplex.core.MiniPlugin; import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.event.BoosterActivateEvent; -import mineplex.core.boosters.event.BoosterExpireEvent; -import mineplex.core.boosters.tips.BoosterTipManager; +import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.boosters.tips.TipAddResult; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.HoverEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.*; import mineplex.core.disguise.DisguiseManager; import mineplex.core.hologram.HologramManager; import mineplex.core.npc.NpcManager; @@ -59,11 +59,11 @@ public class GameBoosterManager extends MiniPlugin return; } - _boosterManager.getTipManager().addTip(player, active, result -> { + _boosterManager.getBoosterThankManager().addTip(player, active, result -> { if (result == TipAddResult.SUCCESS) { - UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " - + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); + UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_SPONSOR) + " and you got " + + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER)) + " in return!"); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } else { @@ -79,12 +79,24 @@ public class GameBoosterManager extends MiniPlugin public void onActivate(BoosterActivateEvent event) { Booster booster = event.getBooster(); + + boolean isTesting = event.getBoosterGroup().equalsIgnoreCase("Testing"); + if (event.getBoosterGroup().equals(_boosterGroup)) { Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier for " + booster.getMultiplier() + "x Shards!")); - } else + } + else if (!isTesting) { Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier on " + F.elem(event.getBoosterGroup().replaceAll("_", " ")) + "!")); } + + if (event.getBoosterGroup().equals(_boosterGroup) || !isTesting) + { + JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and get " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!")); + message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup()); + message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); + message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java deleted file mode 100644 index 118be3200..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ /dev/null @@ -1,507 +0,0 @@ -package nautilus.game.arcade.command; - -import java.lang.reflect.Field; -import java.util.UUID; - -import mineplex.core.account.CoreClient; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.ProfileLoader; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.PlayerUndisguiseEvent; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.punish.PunishClient; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; -import net.minecraft.server.v1_8_R3.ChatComponentText; -import net.minecraft.server.v1_8_R3.EntityHuman; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; -import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; -import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.scoreboard.Team; - -import com.mojang.authlib.GameProfile; - -public class DisguiseCommand extends CommandBase implements Listener -{ - - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - - public DisguiseCommand(ArcadeManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); - - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null || args.length == 0) - { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - try - { - GameProfile profile = _disguisedPlayers.get(caller); - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName, true); - - for(Player other : UtilServer.getPlayers()) - updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - team.removePlayer(caller); - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); - return; - } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUID.randomUUID(); - GameProfile profile = null; - try - { - uuid = UUIDFetcher.getUUIDOf(args[0]); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch (Exception e) - { - uuid = UUID.randomUUID(); - profile = new ProfileLoader(null, args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - CoreClient other = null; - try - { - other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - { - other = null; - } - if(otherRank.has(Rank.TWITCH)) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); - return; - } - if(other != null) - { - PunishClient pclient = Plugin.getPunishments().GetClient(args[0]); - if(pclient.IsBanned() || pclient.IsMuted()) - { - UtilPlayer.message(caller, F.main("Disguise", "Unable to disguise as this Player!")); - return; - } - } - - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0], true); - - Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.ITEM); - - // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); - - Field field; - try - { - field = GameProfile.class.getDeclaredField("id"); - field.setAccessible(true); - UUID old = ((CraftPlayer) caller).getProfile().getId(); - UUID newUUID = profile.getId(); - field.set(profile, old); - field.set(((CraftPlayer) caller).getProfile(), newUUID); - } - catch(Exception e) - { - e.printStackTrace(); - } - - // removed "due to Kicked for Flying" - //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - //UtilPlayer.sendPacket(caller, packet); - - tablistRefresh(caller); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); - return; - } - } - }); - } - - @EventHandler - public void refreshTabNames(UpdateEvent event) - { - if(event.getType() != UpdateType.FAST) - return; - - for(Player player : _disguisedPlayers.keySet()) - { - if(!player.isOnline()) - return; - - tablistRefresh(player); - } - } - - public void tablistRefresh(Player player) - { - for (Player other : UtilServer.getPlayers()) - { - if (player.canSee(other)) - { - updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); - } - } - } - - public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) - { - ChatColor team = ChatColor.WHITE; - Player player = Bukkit.getPlayer(profileToAdd.getName()); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - if(Plugin.GetGame().GetTeam(player) != null) - { - team = Plugin.GetGame().GetTeam(player).GetColor(); - } - String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; - if(Plugin.GetClients().Get(player).isDisguised()) - { - tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; - } - if(Plugin.GetGame().GetState() != GameState.Recruit) - tag = ""; - - IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); - - if(!refreshOnly) - { - PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); - PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - removePacket.b.add(removeData); - UtilPlayer.sendPacket(target, removePacket); - - PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); - PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - addPacket.b.add(addData); - UtilPlayer.sendPacket(target, addPacket); - } - - PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); - PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); - updatePacket.b.add(updateData); - UtilPlayer.sendPacket(target, updatePacket); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) - { - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } - if(other.getScoreboard().getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) - { - if(other.getScoreboard() - .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .getPlayers().contains(player)) - { - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .removePlayer(player); - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).getDisguisedRank().Name - + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); - } - } - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); - } - } - - public void changeName(final Player player, String changedName, boolean skin) - { - try - { - GameProfile gameProfile = ((CraftPlayer) player).getProfile(); - - Field name = GameProfile.class.getDeclaredField("name"); - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName, true); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetEnableEvent event) - { - if(!event.getGadget().getName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.MORPH) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler - public void onPlayerLeftClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(player)) - { - EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - human.world.broadcastEntityEffect(human, (byte) 0); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - - Player player = event.getPlayer(); - - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) - { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } - } - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index bcd04629c..9e6ae9671 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -2,17 +2,28 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; -import mineplex.core.common.util.*; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; import mineplex.core.elo.EloTeam; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; -import mineplex.core.party.Party; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; @@ -23,28 +34,47 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.hideseek.HideSeek; +import nautilus.game.arcade.game.games.minestrike.Minestrike; +import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins; +import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; +import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.modules.Module; -import nautilus.game.arcade.kit.*; +import nautilus.game.arcade.kit.ChampionsKit; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.managers.GameLobbyManager; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.scoreboard.GameScoreboard; -import nautilus.game.arcade.stats.*; +import nautilus.game.arcade.stats.AssistsStatTracker; +import nautilus.game.arcade.stats.DamageDealtStatTracker; +import nautilus.game.arcade.stats.DamageTakenStatTracker; +import nautilus.game.arcade.stats.DeathsStatTracker; +import nautilus.game.arcade.stats.ExperienceStatTracker; +import nautilus.game.arcade.stats.GamesPlayedStatTracker; +import nautilus.game.arcade.stats.KillsStatTracker; +import nautilus.game.arcade.stats.LoseStatTracker; +import nautilus.game.arcade.stats.StatTracker; +import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.wineffect.WinEffectManager; import nautilus.game.arcade.world.WorldData; import net.minecraft.server.v1_8_R3.EntityItem; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import net.minecraft.server.v1_8_R3.WorldServer; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItem; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -55,18 +85,24 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.NameTagVisibility; -import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; public abstract class Game implements Listener { @@ -140,7 +176,7 @@ public abstract class Game implements Listener // Gameplay Flags public long GameTimeout = 1200000; - + public boolean SpectatorAllowed = true; public boolean Damage = true; @@ -183,7 +219,7 @@ public abstract class Game implements Listener public double DeathSpectateSecs = 0; public boolean DeathTeleport = true; - + public boolean QuitOut = true; public boolean QuitDropItems = false; @@ -216,8 +252,6 @@ public abstract class Game implements Listener public boolean AnnounceJoinQuit = true; public boolean AnnounceSilence = true; - public boolean DisplayLobbySide = true; - public GameState KitRegisterState = GameState.Live; public boolean JoinInProgress = false; @@ -254,7 +288,7 @@ public abstract class Game implements Listener public long PrepareTime = 9000; public boolean PlaySoundGameStart = true; - + public double XpMult = 1; // Chat Stats @@ -294,11 +328,11 @@ public abstract class Game implements Listener public String Winner = "Nobody"; public GameTeam WinnerTeam = null; - + //ELO public boolean EloRanking = false; public int EloStart = 1000; - + public boolean CanAddStats = true; public boolean CanGiveLoot = true; @@ -313,13 +347,13 @@ public abstract class Game implements Listener public boolean EnableTutorials = false; public boolean FixSpawnFacing = true; - + public boolean AllowEntitySpectate = true; - + public boolean TeamMode = false; - + public boolean TeamPerSpawn = false; - + public boolean ForceTeamSize = true; public int PlayersPerTeam = 2; public int TeamCount = 0; @@ -330,7 +364,7 @@ public abstract class Game implements Listener private NautHashMap _deadBodiesExpire = new NautHashMap(); private final Set> _statTrackers = new HashSet<>(); - + private NautHashMap _teamReqs = new NautHashMap(); public WinEffectManager WinEffectManager = new WinEffectManager(); @@ -461,14 +495,14 @@ public abstract class Game implements Listener { return _gameType.GetName(); } - + public GameType[] GetWorldHostNames() { GameType[] mapSource = new GameType[] - { - GetType() - }; - + { + GetType() + }; + if (GetType().getMapSource() != null) { if (GetType().ownMaps()) @@ -487,11 +521,11 @@ public abstract class Game implements Listener mapSource = GetType().getMapSource(); } } - + if (GetType().isUsingGameModesMaps()) { GameType mode = GetType().getModeGameType(getClass()); - + if (mode.getMapSource() != null) return mode.getMapSource(); else @@ -549,7 +583,7 @@ public abstract class Game implements Listener { _customWinLine = line; } - + public void SetCustomWinMessage(Player player, String message) { _customWinMessages.put(player, message); @@ -560,11 +594,6 @@ public abstract class Game implements Listener return Scoreboard; } - private Objective GetObjectiveSide() - { - return Scoreboard.GetObjectiveSide(); - } - public ArrayList GetTeamList() { return _teamList; @@ -620,6 +649,35 @@ public abstract class Game implements Listener _gameState = state; _gameStateTime = System.currentTimeMillis(); + if (this._gameState == Game.GameState.Prepare) + { + Managers.get(AntiHack.class).enableNewAnticheat(); + if (this instanceof HideSeek) + { + Managers.get(AntiHack.class).registerFilter(player -> + { + if (GetTeam(player) == ((HideSeek) this).getHiders()) + { + return false; + } + return true; + }); + } + else if (this instanceof SurvivalGames || this instanceof Minestrike || this instanceof SneakyAssassins || this instanceof UHC || this instanceof WitherGame) + { + Managers.get(AntiHack.class).registerFilter(player -> + { + return false; + }); + } + } + else if (this._gameState == Game.GameState.End) + { + Managers.get(AntiHack.class).disableNewAnticheat(); + Managers.get(AntiHack.class).registerFilter(null); + } + + if (_gameState == GameState.Live) setGameLiveTime(_gameStateTime); @@ -629,7 +687,7 @@ public abstract class Game implements Listener // Event GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state); UtilServer.getServer().getPluginManager().callEvent(stateEvent); - + System.out.println(GetName() + " state set to " + state.toString()); } @@ -685,16 +743,50 @@ public abstract class Game implements Listener { for (Kit kit : _kits) { - if(kit == null) + if (kit == null) { continue; } UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin()); - for (Perk perk : kit.GetPerks()) + System.out.println("Kit instance of " + String.valueOf(kit instanceof ProgressingKit)); + + if (kit instanceof ProgressingKit) { - UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin()); - perk.registeredEvents(); + ProgressingKit progressingKit = (ProgressingKit) kit; + + if(!progressingKit.hasUpgrades()) + { + for(Perk perk : progressingKit.getNonUpgradePerks()) + { + UtilServer.RegisterEvents(perk); + perk.registeredEvents(); + } + } else + { + for (Perk[] upgradePerks : progressingKit.getPerks()) + { + for (Perk perk : upgradePerks) + { + + if (perk == null) + { + break; + } + + UtilServer.RegisterEvents(perk); + perk.registeredEvents(); + } + } + } + } + else + { + for (Perk perk : kit.GetPerks()) + { + UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin()); + perk.registeredEvents(); + } } } } @@ -703,7 +795,7 @@ public abstract class Game implements Listener { for (Kit kit : _kits) { - if(kit == null) + if (kit == null) { continue; } @@ -736,10 +828,10 @@ public abstract class Game implements Listener team.AddPlayer(player, in); // Game Scoreboard - Scoreboard.SetPlayerTeam(player, team.GetName().toUpperCase()); + Scoreboard.setPlayerTeam(player, team); // Lobby Scoreboard - Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase()); + Manager.GetLobby().AddPlayerToScoreboards(player, team); // Save Tournament Team Manager.GetGameTournamentManager().setTournamentTeam(player, team); @@ -836,7 +928,7 @@ public abstract class Game implements Listener } player.sendMessage(F.main("Kit", "Your current kit is not applicable with your team. Please select a different kit")); Optional newKit = Lists.newArrayList(GetKits()) - .stream().filter(team::KitAllowed).findFirst(); + .stream().filter(team::KitAllowed).findFirst(); if (newKit.isPresent()) { SetKit(player, newKit.get(), false); @@ -882,7 +974,7 @@ public abstract class Game implements Listener { SetKit(player, kit, announce, true); } - + public void SetKit(Player player, Kit kit, boolean announce, boolean apply) { GameTeam team = GetTeam(player); @@ -892,9 +984,9 @@ public abstract class Game implements Listener { player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); UtilPlayer.message( - player, - F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") - + ".")); + player, + F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") + + ".")); return; } } @@ -956,8 +1048,6 @@ public abstract class Game implements Listener public boolean SetPlayerState(Player player, PlayerState state) { - GetScoreboard().ResetScore(player.getName()); - GameTeam team = GetTeam(player); if (team == null) @@ -994,7 +1084,7 @@ public abstract class Game implements Listener } }, 0); } - + public void RespawnPlayerTeleport(Player player) { player.teleport(GetTeam(player).GetSpawn()); @@ -1142,7 +1232,7 @@ public abstract class Game implements Listener public boolean CanJoinTeam(GameTeam team) { - if(TeamMode) + if (TeamMode) { return team.GetSize() < PlayersPerTeam; } @@ -1153,7 +1243,7 @@ public abstract class Game implements Listener public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event) { ((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original - // food level changes + // food level changes } public GameTeam GetTeamPreference(Player player) @@ -1239,8 +1329,8 @@ public abstract class Game implements Listener { if (!IsLive()) return; - - if(team != null && !team.GetPlacements(true).isEmpty()) + + if (team != null && !team.GetPlacements(true).isEmpty()) { List teamList = new ArrayList<>(); List otherList = new ArrayList<>(); @@ -1249,7 +1339,7 @@ public abstract class Game implements Listener otherList.removeAll(teamList); Player player = teamList.remove(0); WinEffectManager.prePlay(this, player, teamList, otherList); - + Location loc = GetSpectatorLocation().clone().add(1000, 0, 1000); loc.setY(200); WinEffectManager.playWinEffect(loc); @@ -1290,14 +1380,14 @@ public abstract class Game implements Listener { UtilPlayer.message(player, _customWinLine); } - + UtilPlayer.message(player, _customWinMessages.get(player)); } else { UtilPlayer.message(player, _customWinLine); } - + UtilPlayer.message(player, ""); UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" + WorldData.MapAuthor); @@ -1306,10 +1396,10 @@ public abstract class Game implements Listener } UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20); - + if (AnnounceSilence) Manager.GetChat().Silence(5000, false); - + endElo(); } @@ -1317,17 +1407,17 @@ public abstract class Game implements Listener { String winnerText = ChatColor.WHITE + "§lNobody won the game..."; ChatColor subColor = ChatColor.WHITE; - - if(places != null && !places.isEmpty()) + + if (places != null && !places.isEmpty()) { List teamList = new ArrayList<>(); List nonTeamList = new ArrayList<>(); nonTeamList.addAll(places); Player player = places.get(0); nonTeamList.remove(player); - + WinEffectManager.prePlay(this, player, teamList, nonTeamList); - + Location loc = GetSpectatorLocation().clone().add(1000, 0, 1000); loc.setY(200); WinEffectManager.playWinEffect(loc); @@ -1380,10 +1470,10 @@ public abstract class Game implements Listener } UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20); - + if (AnnounceSilence) Manager.GetChat().Silence(5000, false); - + endElo(); } @@ -1407,7 +1497,7 @@ public abstract class Game implements Listener System.out.println("[Announcement] " + message); } - + public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage) { return false; @@ -1643,13 +1733,25 @@ public abstract class Game implements Listener if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - + endElo(); - + // End SetState(GameState.End); } + @EventHandler + public void disableParticles(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare && Manager.getCosmeticManager().getGadgetManager().hideParticles()) + { + for (Player player : GetPlayers(false)) + { + getArcadeManager().getCosmeticManager().getGadgetManager().removeGadgetType(player, GadgetType.PARTICLE); + } + } + } + @EventHandler public void onGameStart(GameStateChangeEvent event) { @@ -1664,15 +1766,15 @@ public abstract class Game implements Listener for (Player player : team.GetPlayers(false)) { - eloTeam.addPlayer(new EloPlayer(player, Manager.GetClients().getAccountId(player), Manager.getEloManager().getElo(player, GetType().getGameId()))); + eloTeam.addPlayer(new EloPlayer(player, Manager.GetClients().getAccountId(player), Manager.getEloManager().getElo(player, GetType().getGameId()))); } - + Manager.getEloManager().addTeam(team.getDisplayName(), eloTeam); } } } } - + // Handle Elo at end of game -- method can be overridden in different game modes to meet their individual needs protected void endElo() { @@ -1680,12 +1782,12 @@ public abstract class Game implements Listener { if (WinnerTeam != null) Manager.getEloManager().setWinningTeam(WinnerTeam.getDisplayName()); - + Manager.getEloManager().endMatch(GetType().getGameId()); } } - - + + @EventHandler public void handleInteractEntityPacket(GameStateChangeEvent event) { @@ -1746,51 +1848,48 @@ public abstract class Game implements Listener return; } + Location loc = player.getLocation(); + String name = "Body #" + _deadBodyCount++; - Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + Team team = Scoreboard.getScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); if (team == null) { - team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + team = Scoreboard.getScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); team.setNameTagVisibility(NameTagVisibility.NEVER); } - team.addEntry(name); - GameProfile newProfile = new GameProfile(UUID.randomUUID(), name); + EntityItem entityItem = new EntityItem( + ((CraftWorld) loc.getWorld()).getHandle(), + loc.getX(), + loc.getY() + 0.5, + loc.getZ(), + CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build()) + ); + entityItem.pickupDelay = Integer.MAX_VALUE; + entityItem.yaw = player.getLocation().getYaw(); + entityItem.pitch = player.getLocation().getPitch(); - newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); + UtilEnt.CreatureLook(entityItem.getBukkitEntity(), player.getLocation().getPitch(), player.getLocation().getYaw()); - DisguisePlayer disguise = new DisguisePlayer(null, newProfile); + GameProfile profile = UtilGameProfile.getGameProfile(player); + GameProfile cloned = new GameProfile(UUID.randomUUID(), name); + cloned.getProperties().putAll(profile.getProperties()); + + DisguisePlayer disguise = new DisguisePlayer(entityItem.getBukkitEntity(), cloned); disguise.setSleeping(getSleepingFace(player.getLocation())); - getArcadeManager().GetDisguise().addFutureDisguise(disguise); - - Location loc = player.getLocation(); - WorldServer world = ((CraftWorld) loc.getWorld()).getHandle(); - - EntityItem nmsItem = new EntityItem(world, loc.getX(), loc.getY() + 0.5, loc.getZ(), - CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build())); - - nmsItem.motX = 0; - nmsItem.motY = 0; - nmsItem.motZ = 0; - nmsItem.yaw = 0; - - world.addEntity(nmsItem); - - Item entity = new CraftItem(world.getServer(), nmsItem); - - entity.setPickupDelay(Integer.MAX_VALUE); - - _deadBodies.put(player.getName(), entity); + _deadBodies.put(player.getName(), entityItem.getBukkitEntity()); if (DeadBodiesExpire > 0) { _deadBodiesExpire.put(player.getName(), System.currentTimeMillis() + (DeadBodiesExpire * 1000)); } + + getArcadeManager().GetDisguise().disguise(disguise); } @EventHandler(priority = EventPriority.HIGHEST) @@ -1835,10 +1934,10 @@ public abstract class Game implements Listener // A complicated way to get the face the dead body should be towards. for (HashSet validBlocks : new HashSet[] - { - UtilBlock.blockAirFoliageSet, - UtilBlock.blockPassSet - }) + { + UtilBlock.blockAirFoliageSet, + UtilBlock.blockPassSet + }) { if (validBlocks.contains((byte) block.getRelative(proper).getTypeId())) @@ -1847,12 +1946,12 @@ public abstract class Game implements Listener } for (BlockFace face : new BlockFace[] - { - BlockFace.EAST, - BlockFace.SOUTH, - BlockFace.NORTH, - BlockFace.WEST - }) + { + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.NORTH, + BlockFace.WEST + }) { if (validBlocks.contains((byte) block.getRelative(face).getTypeId())) { @@ -2034,7 +2133,7 @@ public abstract class Game implements Listener if (UtilBlock.airFoliage(newSpawn.getBlock()) && UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) && !UtilBlock - .airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN))) + .airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN))) { spawns.add(newSpawn); } @@ -2042,10 +2141,10 @@ public abstract class Game implements Listener } } } - + private enum TeamColors { - + YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}), GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}), AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}), @@ -2059,26 +2158,26 @@ public abstract class Game implements Listener DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}), DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}), DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"}); - + private ChatColor color; private String[] names; - + private TeamColors(ChatColor color, String[] names) { this.color = color; this.names = names; } - + public ChatColor getColor() { return color; } - + public String[] getNames() { return names; } - + } private String[] getColorName(ChatColor color) @@ -2120,6 +2219,7 @@ public abstract class Game implements Listener module.cleanup(); HandlerList.unregisterAll(module); } + this._modules.clear(); } public T getModule(Class clazz) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index d6302e4b1..fd2620b91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.concurrent.atomic.AtomicLong; import mineplex.core.account.CoreClient; import mineplex.core.common.util.C; @@ -26,8 +27,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.scoreboard.Team; -public class GameTeam +public class GameTeam { + private static final AtomicLong TEAM_ID = new AtomicLong(); + private Game Host; private double _respawnTime = 0; @@ -40,7 +43,7 @@ public class GameTeam private String name; private ChatColor color; - private PlayerState(String name, ChatColor color) + private PlayerState(String name, ChatColor color) { this.name = name; this.color = color; @@ -57,16 +60,18 @@ public class GameTeam } } + private final long _teamId = TEAM_ID.getAndIncrement(); + private String _name; private String _displayName; private ChatColor _color; - + private GameTutorial _tutorial; private HashMap _players = new HashMap(); private ArrayList _spawns; - + private Creature _teamEntity = null; private HashSet _kitRestrict = new HashSet(); @@ -74,7 +79,7 @@ public class GameTeam private boolean _visible = true; private boolean _displayTag; - + //Records order players go out in protected ArrayList _places = new ArrayList(); private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered @@ -89,7 +94,7 @@ public class GameTeam _spawns = spawns; _displayTag = tags; } - + public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) { this(host, name, color, spawns, false); @@ -120,9 +125,9 @@ public class GameTeam if (Host.FixSpawnFacing) { float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(loc, Host.GetSpectatorLocation())); - + yaw = (int) (yaw / 90) * 90; - + loc = loc.clone(); loc.setYaw(yaw); } @@ -130,8 +135,8 @@ public class GameTeam return loc; } - public Location GetSpawn() - { + public Location GetSpawn() + { //Keep allies together if (!Host.IsLive() && Host.SpawnNearAllies) { @@ -139,9 +144,9 @@ public class GameTeam Location loc = UtilAlg.getLocationNearPlayers(_spawns, GetPlayers(true), Host.GetPlayers(true)); if (loc != null) return fixFacing(loc); - + //No allies existed spawned yet - + //Spawn near enemies (used for SG) if (Host.SpawnNearEnemies) { @@ -155,7 +160,7 @@ public class GameTeam loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); if (loc != null) return fixFacing(loc); - } + } } else { @@ -182,44 +187,27 @@ public class GameTeam { _players.put(player, in ? PlayerState.IN : PlayerState.OUT); - UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + getDisplayName() + " Team.")); + UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + getDisplayName() + " Team.")); VisibilityManager.Instance.refreshPlayerToAll(player); } - public void DisbandTeam() + public void DisbandTeam() { for (Player player : _players.keySet()) { - for(Player other : UtilServer.getPlayers()) - { - Team team = other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name + _name.toUpperCase()); - if (team != null) - { - team.removePlayer(player); - } - other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player); - } - UtilPlayer.message(player, F.main("Team", _color + C.Bold + getDisplayName() + " Team was disbanded.")); + Host.getArcadeManager().GetLobby().RemovePlayerFromTeam(player, this); + UtilPlayer.message(player, F.main("Team", _color + C.Bold + getDisplayName() + " Team was disbanded.")); } - + _players.clear(); } - + public void RemovePlayer(Player player) { _players.remove(player); } - public Player GetPlayer(String name) - { - for (Player player : _players.keySet()) - if (player.getName().equals(name)) - return player; - - return null; - } - public boolean HasPlayer(Player player) { return _players.containsKey(player); @@ -240,7 +228,7 @@ public class GameTeam return _players.size(); } - public void SetPlayerState(Player player, PlayerState state) + public void SetPlayerState(Player player, PlayerState state) { if (player == null) return; @@ -268,7 +256,7 @@ public class GameTeam return alive; } - public String GetFormattedName() + public String GetFormattedName() { return GetColor() + "§l" + GetName(); } @@ -287,12 +275,12 @@ public class GameTeam player.teleport(location); } - public void SpawnTeleport() + public void SpawnTeleport() { SpawnTeleport(true); } - public void SpawnTeleport(boolean aliveOnly) + public void SpawnTeleport(boolean aliveOnly) { for (Player player : GetPlayers(aliveOnly)) { @@ -321,7 +309,7 @@ public class GameTeam return player.isOnline() && _players.get(player) == PlayerState.IN; } - public void SetColor(ChatColor color) + public void SetColor(ChatColor color) { _color = color; } @@ -330,7 +318,7 @@ public class GameTeam { _name = name; } - + public void setDisplayName(String name) { _displayName = name; @@ -340,52 +328,52 @@ public class GameTeam { if (_displayName == null) return _name; - + return _displayName; } public byte GetColorData() { - if (GetColor() == ChatColor.WHITE) return (byte)0; - if (GetColor() == ChatColor.GOLD) return (byte)1; - if (GetColor() == ChatColor.LIGHT_PURPLE) return (byte)2; - if (GetColor() == ChatColor.AQUA) return (byte)3; - if (GetColor() == ChatColor.YELLOW) return (byte)4; - if (GetColor() == ChatColor.GREEN) return (byte)5; + if (GetColor() == ChatColor.WHITE) return (byte) 0; + if (GetColor() == ChatColor.GOLD) return (byte) 1; + if (GetColor() == ChatColor.LIGHT_PURPLE) return (byte) 2; + if (GetColor() == ChatColor.AQUA) return (byte) 3; + if (GetColor() == ChatColor.YELLOW) return (byte) 4; + if (GetColor() == ChatColor.GREEN) return (byte) 5; //if (GetColor() == ChatColor.PINK) return (byte)6; - if (GetColor() == ChatColor.DARK_GRAY) return (byte)7; - if (GetColor() == ChatColor.GRAY) return (byte)8; - if (GetColor() == ChatColor.DARK_AQUA) return (byte)9; - if (GetColor() == ChatColor.DARK_PURPLE) return (byte)10; - if (GetColor() == ChatColor.BLUE) return (byte)11; - if (GetColor() == ChatColor.DARK_BLUE) return (byte)11; + if (GetColor() == ChatColor.DARK_GRAY) return (byte) 7; + if (GetColor() == ChatColor.GRAY) return (byte) 8; + if (GetColor() == ChatColor.DARK_AQUA) return (byte) 9; + if (GetColor() == ChatColor.DARK_PURPLE) return (byte) 10; + if (GetColor() == ChatColor.BLUE) return (byte) 11; + if (GetColor() == ChatColor.DARK_BLUE) return (byte) 11; //if (GetColor() == ChatColor.BROWN) return (byte)12; - if (GetColor() == ChatColor.DARK_GREEN) return (byte)13; - if (GetColor() == ChatColor.RED) return (byte)14; - if (GetColor() == ChatColor.DARK_RED) return (byte)14; - else return (byte)15; + if (GetColor() == ChatColor.DARK_GREEN) return (byte) 13; + if (GetColor() == ChatColor.RED) return (byte) 14; + if (GetColor() == ChatColor.DARK_RED) return (byte) 14; + else return (byte) 15; } public Color GetColorBase() { - if (GetColor() == ChatColor.WHITE) return Color.WHITE; - if (GetColor() == ChatColor.GOLD) return Color.ORANGE; - if (GetColor() == ChatColor.LIGHT_PURPLE) return Color.PURPLE; - if (GetColor() == ChatColor.AQUA) return Color.AQUA; - if (GetColor() == ChatColor.YELLOW) return Color.YELLOW; - if (GetColor() == ChatColor.GREEN) return Color.GREEN; - if (GetColor() == ChatColor.DARK_GRAY) return Color.GRAY; - if (GetColor() == ChatColor.GRAY) return Color.GRAY; - if (GetColor() == ChatColor.DARK_AQUA) return Color.AQUA; - if (GetColor() == ChatColor.DARK_PURPLE) return Color.PURPLE; - if (GetColor() == ChatColor.BLUE) return Color.BLUE; - if (GetColor() == ChatColor.DARK_BLUE) return Color.BLUE; - if (GetColor() == ChatColor.DARK_GREEN) return Color.GREEN; - if (GetColor() == ChatColor.RED) return Color.RED; - else return Color.WHITE; + if (GetColor() == ChatColor.WHITE) return Color.WHITE; + if (GetColor() == ChatColor.GOLD) return Color.ORANGE; + if (GetColor() == ChatColor.LIGHT_PURPLE) return Color.PURPLE; + if (GetColor() == ChatColor.AQUA) return Color.AQUA; + if (GetColor() == ChatColor.YELLOW) return Color.YELLOW; + if (GetColor() == ChatColor.GREEN) return Color.GREEN; + if (GetColor() == ChatColor.DARK_GRAY) return Color.GRAY; + if (GetColor() == ChatColor.GRAY) return Color.GRAY; + if (GetColor() == ChatColor.DARK_AQUA) return Color.AQUA; + if (GetColor() == ChatColor.DARK_PURPLE) return Color.PURPLE; + if (GetColor() == ChatColor.BLUE) return Color.BLUE; + if (GetColor() == ChatColor.DARK_BLUE) return Color.BLUE; + if (GetColor() == ChatColor.DARK_GREEN) return Color.GREEN; + if (GetColor() == ChatColor.RED) return Color.RED; + else return Color.WHITE; } - public void SetTeamEntity(Creature ent) + public void SetTeamEntity(Creature ent) { _teamEntity = ent; } @@ -395,7 +383,7 @@ public class GameTeam return _teamEntity; } - public void SetSpawns(ArrayList spawns) + public void SetSpawns(ArrayList spawns) { _spawns = spawns; } @@ -409,12 +397,10 @@ public class GameTeam { return _visible; } - - public void setDisplayTag(boolean b) - { - _displayTag = b; - } - + + /* + * Whether this GameTeam should show a prefix + */ public boolean GetDisplaytag() { return _displayTag; @@ -430,12 +416,12 @@ public class GameTeam return _respawnTime; } - public void SetPlacement(Player player, PlayerState state) + public void SetPlacement(Player player, PlayerState state) { if (state == PlayerState.OUT) { if (!_places.contains(player)) - _places.add(0, player); + _places.add(0, player); } else _places.remove(player); @@ -452,7 +438,7 @@ public class GameTeam placesClone.add(player); } - for (Player player : GetPlayers(true)) + for (Player player : GetPlayers(true)) { placesClone.add(0, player); } @@ -462,15 +448,19 @@ public class GameTeam return _places; } - + public GameTutorial getTutorial() { return _tutorial; } - + public void setTutorial(GameTutorial tutorial) { _tutorial = tutorial; } - + + public long getTeamId() + { + return this._teamId; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java index 7abcab96e..702e5ddb8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java @@ -100,7 +100,7 @@ public abstract class RankedTeamGame extends TeamGame if (Bukkit.getOnlinePlayers().size() < MaxPlayers) return; String message = ChatColor.RED + "This game has reached maximum capacity!"; - if (Manager.GetClients().Get(event.getPlayer().getName()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (Manager.GetClients().Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) { if (InProgress()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java index 6e029034f..6a8873016 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java @@ -83,9 +83,9 @@ public abstract class SoloGame extends Game if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); GameTeam team = GetTeamList().get(0); @@ -95,11 +95,11 @@ public abstract class SoloGame extends Game { if (team.IsAlive(player)) { - Scoreboard.Write(C.cGreen + player.getName()); + Scoreboard.write(C.cGreen + player.getName()); } else { - Scoreboard.Write(C.cGray + player.getName()); + Scoreboard.write(C.cGray + player.getName()); } } } @@ -107,20 +107,20 @@ public abstract class SoloGame extends Game { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(C.cGreen + player.getName()); + Scoreboard.write(C.cGreen + player.getName()); } } else { - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write("" + team.GetPlayers(true).size()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); } - Scoreboard.Draw(); + Scoreboard.draw(); } public int GetScoreboardScore(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index 1f55a9039..c59d26e5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -92,7 +92,10 @@ public abstract class TeamGame extends Game RejoinHealth.put(player.getName(), player.getHealth()); - GetLocationStore().put(player.getName(), player.getLocation()); + if (!GetLocationStore().containsKey(player.getName())) + { + GetLocationStore().put(player.getName(), player.getLocation()); + } //Announcement Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! " + UtilTime.convert(RejoinTime, 0, TimeUnit.MINUTES) + " minutes to rejoin.", false); @@ -135,7 +138,7 @@ public abstract class TeamGame extends Game } //Do this on Join, not Login, otherwise player no get heal. - @EventHandler + @EventHandler (priority = EventPriority.MONITOR) public void playerRejoinGame(PlayerJoinEvent event) { if (!InProgress() || QuitOut) @@ -154,14 +157,6 @@ public abstract class TeamGame extends Game }, 1L); } } - - if (GetLocationStore().containsKey(player.getName())) - { - getArcadeManager().runSyncLater(() -> - { - player.teleport(GetLocationStore().remove(player.getName())); - }, 1L); - } } @EventHandler @@ -261,7 +256,7 @@ public abstract class TeamGame extends Game if (event != null && event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { @@ -271,25 +266,25 @@ public abstract class TeamGame extends Game if (!team.IsTeamAlive()) continue; - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } //Display Players Alive else { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(team.GetPlayers(true).size() + "" + team.GetColor() + " Alive"); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(team.GetPlayers(true).size() + "" + team.GetColor() + " Alive"); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/data/ScoringManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/data/ScoringManager.java index 7d29c85c2..da257e2a4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/data/ScoringManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/data/ScoringManager.java @@ -38,26 +38,26 @@ public class ScoringManager */ public void displayScores(GameScoreboard sb, boolean end, String winTeam) { - sb.Reset(); - sb.Write(C.cRedB + "Red Score"); - sb.Write(C.cWhite + getScores()[0]); + sb.reset(); + sb.write(C.cRedB + "Red Score"); + sb.write(C.cWhite + getScores()[0]); - sb.WriteBlank(); + sb.writeNewLine(); - sb.Write(C.cAquaB + "Blue Score"); - sb.Write(C.cWhite + getScores()[1]); + sb.write(C.cAquaB + "Blue Score"); + sb.write(C.cWhite + getScores()[1]); - sb.WriteBlank(); + sb.writeNewLine(); if (end) { - sb.Write(C.cWhiteB + "FINAL SCORE"); - sb.WriteBlank(); - sb.Write(winTeam + " Wins!"); + sb.write(C.cWhiteB + "FINAL SCORE"); + sb.writeNewLine(); + sb.write(winTeam + " Wins!"); } else { - sb.Write(C.cYellowB + "Time Remaining"); + sb.write(C.cYellowB + "Time Remaining"); long timeLeft = (_host.GetStateTime() + UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)) - System.currentTimeMillis(); if (!_host.IsLive() && !_host.InProgress()) { @@ -70,15 +70,15 @@ public class ScoringManager if (timeLeft < 0) { - sb.Write(C.cYellow + "Overtime"); + sb.write(C.cYellow + "Overtime"); } else { - sb.Write(UtilTime.MakeStr(timeLeft)); + sb.write(UtilTime.MakeStr(timeLeft)); } } - sb.Draw(); + sb.draw(); } /** diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java index ac364d49c..6567784a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java @@ -1,9 +1,9 @@ package nautilus.game.arcade.game.games.bossbattles; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; import mineplex.minecraft.game.core.boss.snake.SnakeBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; import nautilus.game.arcade.game.games.bossbattles.displays.*; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java index 0ecfe91f4..5511d0842 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java @@ -22,8 +22,8 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index e09833334..812ad20c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -1449,7 +1449,7 @@ public class Bridge extends TeamGame implements OreObsfucation return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Display Players Alive if (!_tournament) @@ -1462,20 +1462,20 @@ public class Bridge extends TeamGame implements OreObsfucation if (!team.IsTeamAlive()) continue; - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } //Display Players Alive else { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); } } } @@ -1488,14 +1488,14 @@ public class Bridge extends TeamGame implements OreObsfucation if (_tournamentKills.containsKey(team)) kills = _tournamentKills.get(team); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players"); - Scoreboard.Write(team.GetColor() + " " + kills + " Kills"); + Scoreboard.write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players"); + Scoreboard.write(team.GetColor() + " " + kills + " Kills"); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); long time = _bridgeTime @@ -1503,16 +1503,16 @@ public class Bridge extends TeamGame implements OreObsfucation if (time > 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Bridges In"); - Scoreboard.Write(UtilTime.MakeStr(time, 0)); + Scoreboard.write(C.cYellow + C.Bold + "Bridges In"); + Scoreboard.write(UtilTime.MakeStr(time, 0)); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java index 7fcf95f0e..17b6b5ce5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java @@ -233,16 +233,13 @@ public class OverpoweredBridge extends Bridge { for (Player player : _starterChests.keySet()) { - System.out.println("test4"); if (player == clicker) continue; - System.out.println("test2"); Location chest = _starterChests.get(player); if (chest.getBlock().getLocation().equals(block.getLocation())) { - System.out.println("test1"); return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index 505eac137..b7f46b730 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -1341,27 +1341,23 @@ public class Build extends Game public void writeScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Build Theme"); - for(String word : _word.split(" ")) - { - Scoreboard.Write(word); - } + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Build Theme"); + Scoreboard.write(_word); - - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_buildGameState == 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _buildTime - (System.currentTimeMillis() - this.GetStateTime())), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _buildTime - (System.currentTimeMillis() - this.GetStateTime())), 0)); } else if (_buildGameState == 2) { - Scoreboard.Write(C.cYellow + C.Bold + "Vote Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Vote Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 0)); // if (_viewData != null) // { @@ -1381,12 +1377,12 @@ public class Build extends Game { for (Entry score : _scoreboardPlaces) { - Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getName()); + Scoreboard.write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getName()); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java index 0fb700e65..3b2d98bb5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java @@ -115,35 +115,35 @@ public class TeamBuild extends Build public void writeScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Build Theme"); - Scoreboard.Write(getWord()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Build Theme"); + Scoreboard.write(getWord()); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (getBuildGameState() == 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, getBuildTime() - (System.currentTimeMillis() - this.GetStateTime())), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, getBuildTime() - (System.currentTimeMillis() - this.GetStateTime())), 0)); } else if (getBuildGameState() == 2) { - Scoreboard.Write(C.cYellow + C.Bold + "Vote Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, getVoteTime() - (System.currentTimeMillis() - getBuildStateTime())), 0)); + Scoreboard.write(C.cYellow + C.Bold + "Vote Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, getVoteTime() - (System.currentTimeMillis() - getBuildStateTime())), 0)); } else if (getBuildGameState() == 4) { for (Entry score : _scoreboardPlaces) { - Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getDisplayName()); + Scoreboard.write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getDisplayName()); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java index ac0f3834d..8f3ef9115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java @@ -10,57 +10,57 @@ import mineplex.core.map.MapText; public class CardFactory { private MapText _mapText; - + public CardFactory() { _mapText = new MapText(); } - + private String[] _questions = new String[] { - "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thanks to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", + "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thanks to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", }; - + private String[] _answers = new String[] { - "A Stinky Pig Butt", "Mouldy Raw Fish", "A sawed off 10-foot pole", "billions of diamonds", "A whiny forum post", "Sparkling Diamonds", "Sheep that don’t know when to stop", "Villager Legs", "Curdled cow milk", "That one popcorn piece stuck in your teeth.", "THE DIAMOND DANCE!", "an unstoppable addiction to fly hacks", "the biggest pile of poop you've ever seen!", "Bed time", "A bag of Doritos and a Mountain Dew.", "zombies chewing on my butt", "Jazz hands", "Brain surgery", "A disappointing birthday party.", "Overly friendly Iron Golems", "An Endermans favourite block", "Puppies!", "your friend who deleted you from Skype", "being on fire", "two cows stealing your wallet", "a lifetime of sadness", "a golden notch apple", "dragon eggs", "holding hands", "kissing", "wearing parents on your head", "soup that is too hot", "edible underpants", "people who are terrible at PvP", "obesity", "sheep eating potatoes", "my collection of spider eyes", "oversized fishing rods", "working as a team", "horse meat", "zombies screaming while on fire", "a ghast calling her dad to say happy birthday", "Microsoft releasing a good game", "bad childhood memories", "a bad haircut", "a steamy locker room", "armed robbery", "bankruptcy", "stacks of TNT", "a block of dirt", "cold pizza", "a pack of angry wolves", "eternal sadness", "the Nether", "a blaze having a barbeque", "Endermen robbing your house", "dental surgery", "religious villagers", "poor villagers", "flesh-eating bacteria", "the drive to win", "friends who take all your loot", "Morgan Freeman", "Darth Vader", "Villager #17", "Barrack Obama", "Lady Gaga", "That one hobo that lives down the street", "A Sad Creeper", "Parker Games", "A shaved sheep", "CaptainSparklez", "DanTDM", "SkyDoesMinecraft", "Mineplex", "A Mineplex Administrator", "Miley Cyrus", "Notch", "Mojang", "Pikachu", "BATMAN!!!", "The Hulk", "Justin Beiber", "Herobrine", "Pirates", "Vikings", "Ninjas", "Uncontrollably pooping", "Dancing until a helper warned me", "Making passive aggressive tweets", "complaining about balance on the forums", "Chopping down the mineplex lobby tree", "crashing servers", "falling off a cliff", "Realizing that you arent actually a ninja.", "Eating a hot pepper", "Digging straight down", "using xray hacks", "picking your nose", "Playing against a team in SSM", "Mining diamond with a stone pickaxe", "stepping on Legos", "Shaking it off", "Watching Parker games", "Accidentally hiding an egg as Easter bunny morph", "doing a poop and realizing there is no toilet paper", "Eating rotten flesh", "Understanding how magnets work", "watching videos on YouTube", "finding Legendary loot in a Treasure Chest", "Doing homework", "dividing by 0", "Finding out the meaning of life", "banning players for no reason", "dying", "so angry that he pooped himself.", "spending hours planting carrots", "doing the right thing", "sleeping in a cave", "getting drunk on potions", "trolling on the internet", "punching a tree", "leaving a stinky surprise", "doing math", "being devoured by zombie pigmen", "farting and walking away", "sneakily doing a poop", "blowing everything up with TNT", "peeing a little bit", "Tweeting about cats", "reading the instructions carefully", - "leaving some poop in the corner of the room", "eating a balanced breakfast", "puking", "shooting arrows at bats", "typing /kill", "watching Frozen repeatedly", "building a house out of dirt", "winking at chickens", "yelling at a toaster", "putting in 110% effort", "paying a lot of money", "bribing with candy", "throwing rocks at people", "crying until everything is better" + "A Stinky Pig Butt", "Mouldy Raw Fish", "A sawed off 10-foot pole", "billions of diamonds", "A whiny forum post", "Sparkling Diamonds", "Sheep that don’t know when to stop", "Villager Legs", "Curdled cow milk", "That one popcorn piece stuck in your teeth.", "THE DIAMOND DANCE!", "an unstoppable addiction to fly hacks", "the biggest pile of poop you've ever seen!", "Bed time", "A bag of Doritos and a Mountain Dew.", "zombies chewing on my butt", "Jazz hands", "Brain surgery", "A disappointing birthday party.", "Overly friendly Iron Golems", "An Endermans favourite block", "Puppies!", "your friend who deleted you from Skype", "being on fire", "two cows stealing your wallet", "a lifetime of sadness", "a golden notch apple", "dragon eggs", "holding hands", "kissing", "wearing parents on your head", "soup that is too hot", "edible underpants", "people who are terrible at PvP", "obesity", "sheep eating potatoes", "my collection of spider eyes", "oversized fishing rods", "working as a team", "horse meat", "zombies screaming while on fire", "a ghast calling her dad to say happy birthday", "Microsoft releasing a good game", "bad childhood memories", "a bad haircut", "a steamy locker room", "armed robbery", "bankruptcy", "stacks of TNT", "a block of dirt", "cold pizza", "a pack of angry wolves", "eternal sadness", "the Nether", "a blaze having a barbeque", "Endermen robbing your house", "dental surgery", "religious villagers", "poor villagers", "flesh-eating bacteria", "the drive to win", "friends who take all your loot", "Morgan Freeman", "Darth Vader", "Villager #17", "Barrack Obama", "Lady Gaga", "That one hobo that lives down the street", "A Sad Creeper", "Parker Games", "A shaved sheep", "CaptainSparklez", "DanTDM", "SkyDoesMinecraft", "Mineplex", "A Mineplex Administrator", "Miley Cyrus", "Notch", "Mojang", "Pikachu", "BATMAN!!!", "The Hulk", "Justin Beiber", "Herobrine", "Pirates", "Vikings", "Ninjas", "Uncontrollably pooping", "Dancing until a helper warned me", "Making passive aggressive tweets", "complaining about balance on the forums", "Chopping down the mineplex lobby tree", "crashing servers", "falling off a cliff", "Realizing that you arent actually a ninja.", "Eating a hot pepper", "Digging straight down", "using xray hacks", "picking your nose", "Playing against a team in SSM", "Mining diamond with a stone pickaxe", "stepping on Legos", "Shaking it off", "Watching Parker games", "Accidentally hiding an egg as Easter bunny morph", "doing a poop and realizing there is no toilet paper", "Eating rotten flesh", "Understanding how magnets work", "watching videos on YouTube", "finding Legendary loot in a Treasure Chest", "Doing homework", "dividing by 0", "Finding out the meaning of life", "banning players for no reason", "dying", "so angry that he pooped himself.", "spending hours planting carrots", "doing the right thing", "sleeping in a cave", "getting drunk on potions", "trolling on the internet", "punching a tree", "leaving a stinky surprise", "doing math", "being devoured by zombie pigmen", "farting and walking away", "sneakily doing a poop", "blowing everything up with TNT", "peeing a little bit", "Tweeting about cats", "reading the instructions carefully", + "leaving some poop in the corner of the room", "eating a balanced breakfast", "puking", "shooting arrows at bats", "typing /kill", "watching Frozen repeatedly", "building a house out of dirt", "winking at chickens", "yelling at a toaster", "putting in 110% effort", "paying a lot of money", "bribing with candy", "throwing rocks at people", "crying until everything is better" }; - + public String getQuestionCard() { return _questions[UtilMath.r(_questions.length)]; } - + public String getAnswerCard() { return _answers[UtilMath.r(_answers.length)]; } - public ItemStack getAnswerStack() + public ItemStack getAnswerStack() { String text = getAnswerCard(); - + ItemStack stack = _mapText.getMap(true, text); - + ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(C.cGreen + text); stack.setItemMeta(meta); - + return stack; } - + public ItemStack getQuestionStack() { String text = getQuestionCard(); - + ItemStack stack = _mapText.getMap(true, text); - + ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(C.cYellow + text); stack.setItemMeta(meta); - + return stack; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java index e890a34a2..f038c1fb2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -229,44 +229,44 @@ public class Cards extends SoloGame public void writeScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_roundState == RoundState.PlaceCards) { - Scoreboard.Write(C.cYellow + C.Bold + "Select Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _playTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + Scoreboard.write(C.cYellow + C.Bold + "Select Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _playTime - (System.currentTimeMillis() - _roundStateTime)), 1)); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Judge"); - Scoreboard.Write(C.cWhite + _roundDealer.getName()); + Scoreboard.write(C.cYellow + C.Bold + "Judge"); + Scoreboard.write(C.cWhite + _roundDealer.getName()); } else if (_roundState == RoundState.Judge) { - Scoreboard.Write(C.cYellow + C.Bold + "Judge Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _judgeTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + Scoreboard.write(C.cYellow + C.Bold + "Judge Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _judgeTime - (System.currentTimeMillis() - _roundStateTime)), 1)); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Judge"); - Scoreboard.Write(C.cWhite + _roundDealer.getName()); + Scoreboard.write(C.cYellow + C.Bold + "Judge"); + Scoreboard.write(C.cWhite + _roundDealer.getName()); } else if (_roundState == RoundState.View) { - Scoreboard.Write(C.cYellow + C.Bold + "View Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _viewTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + Scoreboard.write(C.cYellow + C.Bold + "View Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, _viewTime - (System.currentTimeMillis() - _roundStateTime)), 1)); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Round Wins"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Round Wins"); for (GameScore score : _ranks) { - Scoreboard.Write((int)score.Score + " " + C.Bold + score.Player.getName()); + Scoreboard.write((int)score.Score + " " + C.Bold + score.Player.getName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index 2aced88d1..602b8d680 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -49,6 +49,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -71,7 +72,6 @@ import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadGhoul; import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadZombie; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BloodThirstyStatTracker; import nautilus.game.arcade.stats.KingDamageStatTracker; import nautilus.game.arcade.stats.KingSlayerStatTracker; @@ -444,6 +444,11 @@ public class CastleSiege extends TeamGame { if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) return; + + if (!IsAlive(damager)) + { + return; + } _king.playEffect(EntityEffect.HURT); @@ -537,22 +542,22 @@ public class CastleSiege extends TeamGame } //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Teams for (String group : _scoreGroup.keySet()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(group); - Scoreboard.Write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(group); + Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); } //King if (_king != null && _king.isValid()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "King"); - Scoreboard.Write(_kingHealth + " Health"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "King"); + Scoreboard.write(_kingHealth + " Health"); } long timeLeft = 24000 - WorldTimeSet; @@ -561,21 +566,21 @@ public class CastleSiege extends TeamGame if (timeLeft > 0) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.Write(UtilTime.MakeStr(timeLeft, 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); } else { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.Write("Undead Burning!"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write("Undead Burning!"); for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override @@ -584,7 +589,7 @@ public class CastleSiege extends TeamGame if (!IsLive()) return; - if (this.WorldTimeSet > 24100) + if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) { SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); @@ -608,7 +613,7 @@ public class CastleSiege extends TeamGame SetState(GameState.End); } - if (!_king.isValid()) + if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) { if (_kingDamager != null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java index fbe9a5428..32855df7d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java @@ -1,9 +1,7 @@ package nautilus.game.arcade.game.games.champions; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; @@ -28,7 +26,6 @@ import nautilus.game.arcade.stats.SpecialWinStatTracker; import nautilus.game.arcade.stats.TheLongestShotStatTracker; import org.bukkit.Location; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index f8583deec..52763c8a3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -16,7 +16,6 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index 3f6441659..8baa4a01c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -16,7 +16,6 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.TeamDeathmatch; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillAllOpposingStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index 5e68140ee..5733e3108 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -615,61 +615,61 @@ public class Christmas extends SoloGame if (!IsLive()) { - Scoreboard.Reset(); + Scoreboard.reset(); String line = ""; for (int i = 0 ; i < 20 ; i++) line += ((i % 2 == 0 ? C.cRed : C.cDGreen) + "█"); - Scoreboard.WriteBlank(); - Scoreboard.Write(line); + Scoreboard.writeNewLine(); + Scoreboard.write(line); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cWhiteB + "May your winter"); - Scoreboard.Write(C.cWhiteB + "be filled with"); - Scoreboard.Write(C.cYellowB + "joy" + C.cWhiteB + " and " + C.cYellowB + "cheer."); + Scoreboard.write(C.cWhiteB + "May your winter"); + Scoreboard.write(C.cWhiteB + "be filled with"); + Scoreboard.write(C.cYellowB + "joy" + C.cWhiteB + " and " + C.cYellowB + "cheer."); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cAquaB + "Happy Holidays!"); + Scoreboard.write(C.cAquaB + "Happy Holidays!"); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cWhiteB + "- Your friends at"); - Scoreboard.Write(C.cGoldB + "MINEPLEX"); + Scoreboard.write(C.cWhiteB + "- Your friends at"); + Scoreboard.write(C.cGoldB + "MINEPLEX"); - Scoreboard.WriteBlank(); - Scoreboard.Write(line); + Scoreboard.writeNewLine(); + Scoreboard.write(line); - Scoreboard.Draw(); + Scoreboard.draw(); return; } //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Rounds - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGoldB + "Challenge"); - Scoreboard.Write(C.cWhite + (5 - _parts.size()) + " of " + 5); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGoldB + "Challenge"); + Scoreboard.write(C.cWhite + (5 - _parts.size()) + " of " + 5); //Presents - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreenB + "Presents"); - Scoreboard.Write(C.cWhite + GetSleigh().GetPresents().size() + " of " + 10); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "Presents"); + Scoreboard.write(C.cWhite + GetSleigh().GetPresents().size() + " of " + 10); //Players - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Players"); - Scoreboard.Write(C.cWhite + GetPlayers(true).size()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Players"); + Scoreboard.write(C.cWhite + GetPlayers(true).size()); //Time - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Time Left"); - Scoreboard.Write(C.cWhite + UtilTime.MakeStr(_gameTime - (System.currentTimeMillis() - GetStateTime()))); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Time Left"); + Scoreboard.write(C.cWhite + UtilTime.MakeStr(_gameTime - (System.currentTimeMillis() - GetStateTime()))); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index 6ecb96ed2..cd88da9c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -16,9 +16,6 @@ import mineplex.core.common.util.UtilRadar; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.elo.EloPlayer; -import mineplex.core.elo.EloTeam; -import mineplex.core.elo.GameResult; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -443,12 +440,12 @@ public class CaptureTheFlag extends TeamGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Scores - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRedB + "Red Team"); - Scoreboard.Write(_redScore + " Captures"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRedB + "Red Team"); + Scoreboard.write(_redScore + " Captures"); String redMessage = "Flag Dropped"; if (getFlag(true).isAtHome()) @@ -460,19 +457,19 @@ public class CaptureTheFlag extends TeamGame if (_flickerStage) { if (!getFlag(true).isAtHome()) - Scoreboard.Write(C.cRed + redMessage); + Scoreboard.write(C.cRed + redMessage); else - Scoreboard.Write(redMessage); + Scoreboard.write(redMessage); } else { - Scoreboard.Write(redMessage); + Scoreboard.write(redMessage); } //Flag in play stuff - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAquaB + "Blue Team"); - Scoreboard.Write(_blueScore + " Captures"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAquaB + "Blue Team"); + Scoreboard.write(_blueScore + " Captures"); String blueMessage = "Flag Dropped"; if (getFlag(false).isAtHome()) @@ -486,37 +483,37 @@ public class CaptureTheFlag extends TeamGame if (_flickerStage) { if (!getFlag(false).isAtHome()) - Scoreboard.Write(C.cAqua + blueMessage); + Scoreboard.write(C.cAqua + blueMessage); else - Scoreboard.Write(blueMessage); + Scoreboard.write(blueMessage); } else { - Scoreboard.Write(blueMessage); + Scoreboard.write(blueMessage); } _flickerStage = !_flickerStage; //Flag in play stuff - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Score to Win"); - Scoreboard.Write(_victoryCaps + " Captures"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Score to Win"); + Scoreboard.write(_victoryCaps + " Captures"); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_suddenDeath) { - Scoreboard.Write(C.cYellowB + "Sudden Death"); - Scoreboard.Write("Next Cap Wins"); - Scoreboard.Write("No Respawns"); + Scoreboard.write(C.cYellowB + "Sudden Death"); + Scoreboard.write("Next Cap Wins"); + Scoreboard.write("No Respawns"); } else { - Scoreboard.Write(C.cYellowB + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(_gameTime - (System.currentTimeMillis() - GetStateTime()), 0)) + C.cWhite); + Scoreboard.write(C.cYellowB + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(Math.max(_gameTime - (System.currentTimeMillis() - GetStateTime()), 0)) + C.cWhite); } - Scoreboard.Draw(); + Scoreboard.draw(); } public void endCheckScore(int needed) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java index 80fa91b70..ea8a79135 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.game.games.common; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -15,8 +14,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ItemDespawnEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -26,10 +23,6 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilRadar; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextTop; -import mineplex.core.elo.EloPlayer; -import mineplex.core.elo.EloTeam; -import mineplex.core.elo.GameResult; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -265,29 +258,29 @@ public class Domination extends TeamGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Scores - Scoreboard.WriteBlank(); - Scoreboard.Write("First to " + _victoryScore); + Scoreboard.writeNewLine(); + Scoreboard.write("First to " + _victoryScore); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Red Team"); - Scoreboard.Write(_redScore + C.cRed); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Red Team"); + Scoreboard.write(_redScore + C.cRed); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + "Blue Team"); - Scoreboard.Write(_blueScore + C.cAqua); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + "Blue Team"); + Scoreboard.write(_blueScore + C.cAqua); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); //Write CPs for (int i=0 ; i<_points.size() ; i++) { - Scoreboard.Write(_points.get(i).GetScoreboardName()); + Scoreboard.write(_points.get(i).GetScoreboardName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } public void EndCheckScore() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java index 5b016f0a3..f6d2bc073 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/TeamDeathmatch.java @@ -274,14 +274,14 @@ public class TeamDeathmatch extends TeamGame public void ScoreboardWrite() { - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { //Display Individual Players if (this.GetPlayers(false).size() <= 10) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for (Player player : team.GetPlayers(false)) { @@ -290,38 +290,38 @@ public class TeamDeathmatch extends TeamGame kills = _kills.get(player); if (IsAlive(player)) - Scoreboard.Write(kills + " " + team.GetColor() + player.getName()); + Scoreboard.write(kills + " " + team.GetColor() + player.getName()); else - Scoreboard.Write(kills + " " + C.cGray + player.getName()); + Scoreboard.write(kills + " " + C.cGray + player.getName()); } } //Display Players Alive else { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(team.GetColor() + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); + Scoreboard.write(team.GetColor() + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); } } if (_beacon != null) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + _beacon.GetName()); - Scoreboard.Write(_beacon.GetOwnership()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + _beacon.GetName()); + Scoreboard.write(_beacon.GetOwnership()); } else { long timeLeft = _beaconTime - (System.currentTimeMillis() - GetStateTime()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Beacon"); - Scoreboard.Write(UtilTime.MakeStr(timeLeft, 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Beacon"); + Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } public void EndCheckScore() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index d4c96743c..a115c82c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -350,17 +350,17 @@ public class DeathTag extends SoloGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(_runners.GetPlayers(true).size() + " " +_runners.GetColor() + " Runners"); + Scoreboard.write(_runners.GetPlayers(true).size() + " " +_runners.GetColor() + " Runners"); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(_chasers.GetPlayers(true).size() + " " +_chasers.GetColor() + " Chasers"); + Scoreboard.write(_chasers.GetPlayers(true).size() + " " +_chasers.GetColor() + " Chasers"); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index c6cead608..23d67fb7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -4,15 +4,17 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EnderDragon; @@ -30,18 +32,21 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.block.BlockData; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -50,7 +55,10 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.dragonescape.kits.*; +import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger; +import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor; +import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper; +import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.DistanceTraveledStatTracker; @@ -94,6 +102,9 @@ public class DragonEscape extends SoloGame private double _speedMult = 1; private HashMap _tunneled = new HashMap(); + + private long _started; + private long _ended; public DragonEscape(ArcadeManager manager) { @@ -188,7 +199,7 @@ public class DragonEscape extends SoloGame if (event.GetState() != GameState.Prepare) return; - for (Team team : GetScoreboard().GetScoreboard().getTeams()) + for (Team team : GetScoreboard().getScoreboard().getTeams()) team.setCanSeeFriendlyInvisibles(true); this.CreatureAllowOverride = true; @@ -386,23 +397,21 @@ public class DragonEscape extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - - //Write New - for (int i=0 ; i<_ranks.size() && i<14 ; i++) - { - DragonScore score = _ranks.get(i); + Scoreboard.writeNewLine(); + AtomicInteger index = new AtomicInteger(0); + + Scoreboard.writeGroup(_ranks.subList(0, Math.min(_ranks.size(), 14)), score -> + { ChatColor col = ChatColor.GREEN; if (!IsAlive(score.Player)) col = ChatColor.RED; + return Pair.create(col + score.Player.getName(), index.incrementAndGet()); + }, true); - Scoreboard.WriteOrdered("Rank", col + score.Player.getName(), i+1, true); - } - - Scoreboard.Draw(); + Scoreboard.draw(); } @Override @@ -644,4 +653,46 @@ public class DragonEscape extends SoloGame // Stops players using trap doors in game. event.setCancelled(true); } + + @EventHandler + public void setTimes(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + _started = System.currentTimeMillis(); + } + else if (event.GetState() == GameState.End) + { + _ended = System.currentTimeMillis(); + } + } + + @EventHandler + public void updateTimer(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (GetState() == GameState.Prepare) + { + UtilTextTop.display(F.game("Game time: ") + F.time("0.0 Seconds"), UtilServer.getPlayers()); + } + else if (GetState() == GameState.Live) + { + if (_started == 0) + return; + + UtilTextTop.display(F.game("Game time: ") + F.time(UtilTime.convertString(System.currentTimeMillis() - _started, 6, TimeUnit.SECONDS)), UtilServer.getPlayers()); + } + else if (GetState() == GameState.End) + { + if (_started == 0) + return; + + if (_ended == 0) + return; + + UtilTextBottom.display(F.game("Game time: ") + F.time(UtilTime.convertString(_ended - _started, 6, TimeUnit.SECONDS)), UtilServer.getPlayers()); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java index 0b6764bb5..5e43f436e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java @@ -5,10 +5,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; -import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -40,9 +38,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.dragonescape.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -399,7 +395,7 @@ public class DragonEscapeTeams extends TeamGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); HashMap scores = GetTeamScores(); for (GameTeam team : scores.keySet()) @@ -407,12 +403,12 @@ public class DragonEscapeTeams extends TeamGame //Time int score = scores.get(team).intValue(); - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(score + "" + team.GetColor() + " Score"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(score + "" + team.GetColor() + " Score"); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java index 9743a5aaf..b088fe019 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import org.bukkit.Bukkit; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Sound; @@ -15,7 +14,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; @@ -28,7 +26,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.dragons.kits.*; @@ -258,19 +255,19 @@ public class DragonsTeams extends TeamGame private void WriteScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : _teamScore.keySet()) { //Time int seconds = _teamScore.get(team); - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(team.GetColor() + "" + seconds + " Seconds"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(team.GetColor() + "" + seconds + " Seconds"); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 8b6c61a77..b6bad607f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -30,16 +31,15 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; - +import mineplex.core.common.util.UtilBlockText; +import mineplex.core.common.util.UtilBlockText.TextAlign; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilBlockText; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilBlockText.TextAlign; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -50,8 +50,11 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.GameScore; -import nautilus.game.arcade.game.games.draw.kits.*; -import nautilus.game.arcade.game.games.draw.tools.*; +import nautilus.game.arcade.game.games.draw.kits.KitArtist; +import nautilus.game.arcade.game.games.draw.tools.Tool; +import nautilus.game.arcade.game.games.draw.tools.ToolCircle; +import nautilus.game.arcade.game.games.draw.tools.ToolLine; +import nautilus.game.arcade.game.games.draw.tools.ToolSquare; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.DrawGuessStatTracker; @@ -108,7 +111,7 @@ public class Draw extends SoloGame { "Take turns to draw something", "Right-Click with items to draw", - "Hints are given at top of screen", + "Hints are given at the bottom of screen", }); StrictAntiHack = true; @@ -211,7 +214,6 @@ public class Draw extends SoloGame new ChatStatData("PureLuck", "Lucky Guess'", true) ); - Manager.GetChat().setThreeSecondDelay(false); } @Override @@ -991,31 +993,29 @@ public class Draw extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Rounds - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cWhite + "Round:"); - Scoreboard.Write(C.cYellow + Math.min(_roundCount+1, _roundMax) + " of " + _roundMax); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cWhite + "Round:"); + Scoreboard.write(C.cYellow + Math.min(_roundCount+1, _roundMax) + " of " + _roundMax); //Drawer - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cWhite + "Drawer:"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cWhite + "Drawer:"); if (_round == null) - Scoreboard.Write(C.cYellow + "None"); + Scoreboard.write(C.cYellow + "None"); else - Scoreboard.Write(C.cYellow + _round.Drawer.getName()); + Scoreboard.write(C.cYellow + _round.Drawer.getName()); //Scores - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cWhite + "Scores:"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cWhite + "Scores:"); + + + Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cYellow + score.Player.getName(), (int) score.Score), true); - for (int i=0 ; i<_ranks.size() ; i++) - { - Scoreboard.WriteOrdered("Score", C.cYellow + _ranks.get(i).Player.getName(), (int)_ranks.get(i).Score, true); - } - - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 9543fa0b7..c2d56aebb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -1,29 +1,8 @@ package nautilus.game.arcade.game.games.event; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseBat; -import mineplex.core.disguise.disguises.DisguiseChicken; -import mineplex.core.disguise.disguises.DisguiseEnderman; -import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; +import mineplex.core.disguise.disguises.*; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -42,14 +21,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.event.kits.KitPlayer; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; import org.bukkit.entity.Entity; @@ -72,13 +44,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.*; + public class EventGame extends Game { private GameHostManager _mps; - private String[] _sideText = new String[] { - " "," "," "," "," "," "," "," "," "," "," "," " - ," "," "," "}; + private String[] _sideText = new String[] {"","","","","","","","","","","","","","",""}; private boolean _doubleJump = false; private boolean _gadgetsEnabled = true; @@ -410,16 +382,14 @@ public class EventGame extends Game if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); - - Scoreboard.WriteBlank(); + Scoreboard.reset(); for (int i=_sideText.length-1 ; i>=0 ; i--) { - Scoreboard.Write(_sideText[i]); + Scoreboard.write(_sideText[i]); } - Scoreboard.Draw(); + Scoreboard.draw(); } //This re-enables cosmetic hotbar, because MPS disables it - temp fix until i find out whats disabling it repeatedly @@ -1242,7 +1212,7 @@ public class EventGame extends Game return; } - if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price) + if(Manager.GetDonation().Get(event.getPlayer()).getBalance(GlobalCurrency.GEM) < price) { UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems.")); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 9f19b1475..0ceb25143 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -1147,7 +1147,7 @@ public class EventModule extends MiniPlugin int line = 0; try { - line = Integer.parseInt(args[1]); + line = Integer.parseInt(args[1]) - 1; } catch (Exception e) { @@ -1155,7 +1155,7 @@ public class EventModule extends MiniPlugin return; } - if (line < 1 || line > 14) + if (line < 0 || line > 14) { UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number.")); return; @@ -1180,7 +1180,7 @@ public class EventModule extends MiniPlugin ((EventGame) Manager.GetGame()).getSideText()[line] = ChatColor.translateAlternateColorCodes('&', lineText); - UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + ".")); + UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem((line + 1)+"") + " to " + F.elem(lineText) + ".")); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 65eaad951..73d5fc452 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.evolution; import com.google.common.collect.Maps; +import mineplex.core.common.Pair; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -810,19 +811,16 @@ public class Evolution extends SoloGame if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "First to " + _mobKits.size()); + Scoreboard.write(C.cYellow + C.Bold + "First to " + _mobKits.size()); - Scoreboard.WriteBlank(); - - for (Player player : GetPlayers(true)) - { - Scoreboard.WriteOrdered("Score", C.cGreen + player.getName(), getScore(player), true); - } + Scoreboard.writeNewLine(); + + Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(C.cGreen + player.getName(), getScore(player)), true); - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java index 2e52e42a9..85c2e7c9d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitGolem.java @@ -41,8 +41,7 @@ public class KitGolem extends EvoKit DisguiseIronGolem disguise = new DisguiseIronGolem(player); disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); disguise.setCustomNameVisible(true); - - Manager.GetDisguise().undisguise(player); + Manager.GetDisguise().disguise(disguise); player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_DEATH, 4f, 1f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 020f3fddb..59dd19d6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -239,7 +239,7 @@ public class Gladiators extends SoloGame // Zombie hit one PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).getEntityId(); packet.b = 0; for (Player p : UtilServer.getPlayers()) @@ -259,7 +259,7 @@ public class Gladiators extends SoloGame // Zombie hit two PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).getEntityId(); packet.b = 0; for (Player p : UtilServer.getPlayers()) @@ -958,10 +958,10 @@ public class Gladiators extends SoloGame if (GetState() != GameState.Live) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + C.Bold + "Status"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + C.Bold + "Status"); if (_roundState == RoundState.FIGHTING) { double start = -1D; @@ -976,34 +976,34 @@ public class Gladiators extends SoloGame double number = ((start + 60000) - System.currentTimeMillis()); int time = (int)(number / 1000.0 + 0.5); if (time < 0) - Scoreboard.Write("Poison Active"); + Scoreboard.write("Poison Active"); else - Scoreboard.Write("Poison in " + time + "s"); + Scoreboard.write("Poison in " + time + "s"); } else { - Scoreboard.Write(_roundState.getScoreboardText()); + Scoreboard.write(_roundState.getScoreboardText()); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + C.Bold + "Matches Left"); - Scoreboard.Write(C.cWhite + getMatchesFighting()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + C.Bold + "Matches Left"); + Scoreboard.write(C.cWhite + getMatchesFighting()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (GetPlayers(true).size() > 7) { - Scoreboard.Write(C.cWhite + GetPlayers(true).size() + " Players"); + Scoreboard.write(C.cWhite + GetPlayers(true).size() + " Players"); } else { for (Player p : GetPlayers(true)) { - Scoreboard.Write(C.cWhite + p.getName()); + Scoreboard.write(C.cWhite + p.getName()); } } - Scoreboard.Draw(); + Scoreboard.draw(); } private int getMatchesFighting() @@ -1096,20 +1096,20 @@ public class Gladiators extends SoloGame if (e.GetState() != GameState.End) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + C.Bold + "Status"); - Scoreboard.Write(C.cWhite + "Ended"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + C.Bold + "Matches Left"); - Scoreboard.Write(C.cWhite + "0"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + C.Bold + "Status"); + Scoreboard.write(C.cWhite + "Ended"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + C.Bold + "Matches Left"); + Scoreboard.write(C.cWhite + "0"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (getWinners() != null && !getWinners().isEmpty()) - Scoreboard.Write(C.cWhite + getWinners().get(0).getName()); + Scoreboard.write(C.cWhite + getWinners().get(0).getName()); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 19d8cfa40..3f4c10226 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -1,19 +1,7 @@ package nautilus.game.arcade.game.games.halloween; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -29,37 +17,22 @@ import nautilus.game.arcade.game.games.halloween.creatures.InterfaceMove; import nautilus.game.arcade.game.games.halloween.kits.KitFinn; import nautilus.game.arcade.game.games.halloween.kits.KitRobinHood; import nautilus.game.arcade.game.games.halloween.kits.KitThor; -import nautilus.game.arcade.game.games.halloween.waves.Wave1; -import nautilus.game.arcade.game.games.halloween.waves.Wave2; -import nautilus.game.arcade.game.games.halloween.waves.Wave3; -import nautilus.game.arcade.game.games.halloween.waves.Wave4; -import nautilus.game.arcade.game.games.halloween.waves.Wave5; -import nautilus.game.arcade.game.games.halloween.waves.WaveBase; -import nautilus.game.arcade.game.games.halloween.waves.WaveBoss; -import nautilus.game.arcade.game.games.halloween.waves.WaveVictory; +import nautilus.game.arcade.game.games.halloween.waves.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; - import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect; - -import org.bukkit.ChatColor; -import org.bukkit.Difficulty; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.Fireball; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import java.util.*; + public class Halloween extends SoloGame { //Wave Data @@ -436,7 +409,7 @@ public class Halloween extends SoloGame if (!player.isOnline()) continue; - Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Decrepit Warhorse", CurrencyType.TREASURE_SHARD, 0, true); + Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Decrepit Warhorse", GlobalCurrency.TREASURE_SHARD, 0, true); } } @@ -564,34 +537,34 @@ public class Halloween extends SoloGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); //Rounds - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Wave"); - Scoreboard.Write(Math.min(6, _wave+1) + " of 6"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Wave"); + Scoreboard.write(Math.min(6, _wave+1) + " of 6"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Monsters"); - Scoreboard.Write("" + _mobs.size()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Monsters"); + Scoreboard.write("" + _mobs.size()); //Drawer - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (GetPlayers(true).size() < 8) { for (Player player : GetPlayers(true)) { - Scoreboard.Write(C.cWhite + player.getName()); + Scoreboard.write(C.cWhite + player.getName()); } } else { - Scoreboard.Write(GetPlayers(true).size() + " Alive"); + Scoreboard.write(GetPlayers(true).size() + " Alive"); } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index 55535e846..05527b4cd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -1,9 +1,20 @@ package nautilus.game.arcade.game.games.hideseek; +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -311,13 +322,14 @@ public class HideSeek extends TeamGame { if (event.GetState() == GameState.Prepare) { + System.out.println("prep"); this.getArcadeManager().getPacketHandler().addPacketHandler(_blockDisguise, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class); this.getArcadeManager().getPacketHandler().addPacketHandler(_useEntity, true, PacketPlayInUseEntity.class); } else if (event.GetState() == GameState.Dead) { - this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); - this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); + this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); + this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); } } @@ -1088,8 +1100,6 @@ public class HideSeek extends TeamGame SetPlayerTeam(player, _seekers, true); - Manager.GetDisguise().undisguise(player); - // Remove Form Form form = _forms.remove(player); if (form != null) @@ -1257,32 +1267,32 @@ public class HideSeek extends TeamGame private void WriteScoreboard() { // Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } if (!_started) { long timeLeft = _hideTime - (System.currentTimeMillis() - GetStateTime()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Hide Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Hide Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); } else { long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Seek Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Seek Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override @@ -1329,6 +1339,11 @@ public class HideSeek extends TeamGame if (UtilBlock.usable(event.getClickedBlock())) event.setCancelled(true); + + if (event.getClickedBlock().getType() == Material.WOODEN_DOOR) + { + event.setCancelled(false); + } } public GameTeam getHiders() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index d4c95961f..aba4c1463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilGear; @@ -29,7 +30,6 @@ import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.Navigation; import net.minecraft.server.v1_8_R3.NavigationAbstract; import org.bukkit.Bukkit; @@ -95,7 +95,7 @@ public class MilkCow extends SoloGame this.CompassEnabled = true; this.DeathOut = false; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Milk", "dummy"); + _scoreObj = Scoreboard.getScoreboard().registerNewObjective("Milk", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); registerChatStats( @@ -487,21 +487,21 @@ public class MilkCow extends SoloGame return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - for (Player player : GetPlayers(true)) + Scoreboard.writeGroup(GetPlayers(true), player -> { int score = (int)GetScore(player); GameTeam team = GetTeam(player); - if (team == null) continue; - - Scoreboard.WriteOrdered("Milk", team.GetColor() + player.getName(), score, true); - } - - Scoreboard.Draw(); + if (team == null) return null; + + return Pair.create(team.GetColor() + player.getName(), score); + }, true); + + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 4ec6f2edd..981dd22c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -482,14 +482,14 @@ public class MinecraftLeague extends RankedTeamGame public void writeEndSb(String winner) { - Scoreboard.Reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cDRedB + GetName()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGoldB + "Winner:"); - Scoreboard.Write(winner); + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGoldB + "Winner:"); + Scoreboard.write(winner); - Scoreboard.Draw(); + Scoreboard.draw(); } private void scoreboardWrite(boolean sec) @@ -501,23 +501,23 @@ public class MinecraftLeague extends RankedTeamGame { if (!sec) return; - Scoreboard.Reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cDRedB + GetName()); - Scoreboard.WriteBlank(); + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); if (_yellow) { - Scoreboard.Write(C.cYellow + "Loading..."); + Scoreboard.write(C.cYellow + "Loading..."); _yellow = false; } else { - Scoreboard.Write("Loading..."); + Scoreboard.write("Loading..."); _yellow = true; } - Scoreboard.Draw(); + Scoreboard.draw(); return; } @@ -553,41 +553,41 @@ public class MinecraftLeague extends RankedTeamGame _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRedB + "Red Team"); - Scoreboard.Write("Towers: " + reds); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRedB + "Red Team"); + Scoreboard.write("Towers: " + reds); for (String s : _vman.getSelected().getTeamScoreboardAdditions(red)) { - Scoreboard.Write(s); + Scoreboard.write(s); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAquaB + "Blue Team"); - Scoreboard.Write("Towers: " + blues); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAquaB + "Blue Team"); + Scoreboard.write("Towers: " + blues); for (String s : _vman.getSelected().getTeamScoreboardAdditions(blue)) { - Scoreboard.Write(s); + Scoreboard.write(s); } int i = 1; for (ExtraScoreboardData sbD : ExtraSb.keySet()) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); sbD.write(); if (i < ExtraSb.size()) - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); i++; } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Time Elapsed"); - Scoreboard.Write(UtilTime.MakeStr(_liveTime)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Time Elapsed"); + Scoreboard.write(UtilTime.MakeStr(_liveTime)); if (OverTime) - Scoreboard.Write(C.cDRedB + "Overtime"); + Scoreboard.write(C.cDRedB + "Overtime"); - Scoreboard.Draw(); + Scoreboard.draw(); } /*@Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java index 0b655ae09..d4a1c8f85 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java @@ -30,13 +30,13 @@ public class WitherSkeletonTimer extends ExtraScoreboardData public void write() { - Scoreboard.Write(C.cYellowB + "Wither Skeleton Spawn"); + Scoreboard.write(C.cYellowB + "Wither Skeleton Spawn"); if (_frozen != -1) { if (_frozen == -2) - Scoreboard.Write("WITHER ALIVE"); + Scoreboard.write("WITHER ALIVE"); else - Scoreboard.Write(_frozen + " Seconds"); + Scoreboard.write(_frozen + " Seconds"); } else { @@ -44,7 +44,7 @@ public class WitherSkeletonTimer extends ExtraScoreboardData if (_end - System.currentTimeMillis() > 0) seconds = UtilTime.convert(_end - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); - Scoreboard.Write(UtilTime.MakeStr(UtilTime.convert(seconds, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); + Scoreboard.write(UtilTime.MakeStr(UtilTime.convert(seconds, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java index 862ead445..e6d8f5e0a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java @@ -13,7 +13,6 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -157,7 +156,7 @@ public class Minestrike extends TeamGame this.DontAllowOverfill = true; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); + _scoreObj = Scoreboard.getScoreboard().registerNewObjective("HP", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); this._help = new String[] @@ -225,7 +224,7 @@ public class Minestrike extends TeamGame return; System.out.println("Hiding Scoreboard Nametags for Other Teams"); - for (Team curTeam : Scoreboard.GetScoreboard().getTeams()) + for (Team curTeam : Scoreboard.getScoreboard().getTeams()) { curTeam.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); //UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), @@ -939,7 +938,7 @@ public class Minestrike extends TeamGame //Update Scoreboard Teams for (GameTeam team : GetTeamList()) for (Player teamMember : team.GetPlayers(true)) - GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase()); + GetScoreboard().setPlayerTeam(teamMember, team); //Alternate Bullets if (_gunModule.BulletAlternate) @@ -1043,6 +1042,11 @@ public class Minestrike extends TeamGame { if (GetState() == GameState.Recruit || GetState() == GameState.Loading) return; + + if (Manager.isVanished(event.getPlayer())) + { + return; + } //Target Team GameTeam targetTeam = null; @@ -1114,45 +1118,45 @@ public class Minestrike extends TeamGame public void drawScoreboard() { - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); + Scoreboard.write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); //Scoreboard.Write(team.GetColor() + "" + getScore(team) + "" + " Wins" + team.GetColor()); - Scoreboard.Write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); + Scoreboard.write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGold + C.Bold + "Playing To"); - Scoreboard.Write(_roundsToWin + " Wins"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGold + C.Bold + "Playing To"); + Scoreboard.write(_roundsToWin + " Wins"); if (InProgress()) { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (_gunModule.getBomb() == null) { - Scoreboard.Write(C.cGold + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); + Scoreboard.write(C.cGold + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); } else { if (_bombScoreboardFlash) - Scoreboard.Write(C.cRed + C.Bold + "Bomb Active"); + Scoreboard.write(C.cRed + C.Bold + "Bomb Active"); else - Scoreboard.Write(C.cWhite + C.Bold + "Bomb Active"); + Scoreboard.write(C.cWhite + C.Bold + "Bomb Active"); _bombScoreboardFlash = !_bombScoreboardFlash; } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java index 87f40aa8d..3fed98d5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import mineplex.core.common.Pair; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -462,7 +463,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (_lives.get(player) > 0) { Manager.Clear(player); - Scoreboard.SetPlayerTeam(player, _playerTeam.GetName().toUpperCase()); + Scoreboard.setPlayerTeam(player, _playerTeam); } } } @@ -1352,7 +1353,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); if (getPlayersWithRemainingLives() >= GENERIC_SCOREBOARD_PLAYER_COUNT) { @@ -1363,7 +1364,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown displayDetailedScoreboard(); } - Scoreboard.Draw(); + Scoreboard.draw(); } private void displayGenericScoreboard() @@ -1376,76 +1377,70 @@ public class BawkBawkBattles extends TeamGame implements IThrown private void displayPlayerTotal() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); - Scoreboard.Write(getPlayersWithRemainingLives() + " "); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); + Scoreboard.write(getPlayersWithRemainingLives() + " "); } private void displayAlivePlayers() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + C.Bold + "Alive"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + C.Bold + "Alive"); if (_settings.isChallengeStarted()) { int data = _challenge.getPlayersIn(false).size(); - Scoreboard.Write("" + data); + Scoreboard.write("" + data); } else { - Scoreboard.Write("-"); + Scoreboard.write("-"); } } private void displayCompletedPlayers() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGold + C.Bold + "Completed"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGold + C.Bold + "Completed"); if (_settings.isChallengeStarted()) { int data = _challenge.getData().getCompletedPlayers().size(); - Scoreboard.Write("" + data); + Scoreboard.write("" + data); } else { - Scoreboard.Write("-"); + Scoreboard.write("-"); } } private void displayDeadPlayers() { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGray + C.Bold + "Dead"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGray + C.Bold + "Dead"); if (_settings.isChallengeStarted()) { int data = _challenge.getData().getLostPlayers().size(); - Scoreboard.Write("" + data); + Scoreboard.write("" + data); } else { - Scoreboard.Write("-"); + Scoreboard.write("-"); } } private void displayDetailedScoreboard() { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - for (Player player : super.GetPlayers(true)) // Use super.GetPlayers(true) to show players during chicken attack. + Scoreboard.writeGroup(super.GetPlayers(true), player -> { - displayPersonalScore(player); - } - } - - private void displayPersonalScore(Player player) - { - int lives = lives(player); - String state = definePlayerState(player); - String display = definePlayerDisplay(player.getName(), lives, state); - - Scoreboard.WriteOrdered("Lives Left", display, lives, true); + int lives = lives(player); + String state = definePlayerState(player); + String display = definePlayerDisplay(player.getName(), lives, state); + return Pair.create(display, lives); + }, true); } private String definePlayerDisplay(String name, int lives, String state) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java index 384ab9280..c6fdc6a31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java @@ -329,7 +329,6 @@ public abstract class Challenge implements Listener if (lives <= 0 && alive > CHICKEN_ATTACK_CRITERIA) { - Host.GetScoreboard().ResetScore(player.getName()); Host.getChickenAttack().start(player); } else @@ -496,7 +495,6 @@ public abstract class Challenge implements Listener } Data.addCompletedPlayer(player); - Host.Manager.GetDisguise().undisguise(player); UtilPlayer.clearPotionEffects(player); UtilInv.Clear(player); } @@ -542,7 +540,6 @@ public abstract class Challenge implements Listener Host.showLivesLeft(player); player.playSound(player.getLocation(), Sound.NOTE_BASS, LOST_SOUND_VOLUME, LOST_SOUND_PITCH); - Host.Manager.GetDisguise().undisguise(player); UtilPlayer.clearPotionEffects(player); UtilInv.Clear(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java index 86abbfedf..cea7b74e6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.mineware.challenge.type; import java.util.ArrayList; +import mineplex.core.disguise.disguises.DisguiseVillager; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -156,6 +157,15 @@ public class ChallengeDogsVersusCats extends TeamChallenge { _catScore = 0; _dogScore = 0; + + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseCat || + Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseWolf) + { + Host.Manager.GetDisguise().undisguise(player); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java index 311983f81..49037ba6f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java @@ -6,6 +6,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; +import mineplex.core.disguise.disguises.DisguiseVillager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -114,6 +115,14 @@ public class ChallengeLavaRun extends Challenge _modifiedDelay = 0; _modifiedDelayMin = 0; _disappearingBlocks = 0; + + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseMagmaCube) + { + Host.Manager.GetDisguise().undisguise(player); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java index d4fed513e..b1f43a0ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeMilkACow.java @@ -174,6 +174,14 @@ public class ChallengeMilkACow extends Challenge implements NumberTracker cow.remove(); } + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseVillager) + { + Host.Manager.GetDisguise().undisguise(player); + } + } + _farmer.remove(); _farmer = null; _milkedCows.clear(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java index 2d7dd04fe..765bfda6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import mineplex.core.disguise.disguises.DisguiseVillager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -268,6 +269,14 @@ public class ChallengeZombieInfection extends Challenge _zombie.spawn(); Host.CreatureAllow = false; + for (Player player : Host.GetPlayers(false)) + { + if (Host.getArcadeManager().GetDisguise().getActiveDisguise(player) instanceof DisguiseZombie) + { + Host.Manager.GetDisguise().undisguise(player); + } + } + _zombie.setSpeed(_defaultSpeed); _zombie.extinguish(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java index 02f34c55d..7599ab638 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java @@ -127,7 +127,7 @@ public class ChickenAttack DisguiseChicken disguise = new DisguiseChicken(player); disguise.setBaby(); - _host.Manager.GetDisguise().disguise(disguise, UtilServer.getPlayers()); + _host.Manager.GetDisguise().disguise(disguise); player.teleport(_host.GetSpectatorLocation()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java index 3d1d29c40..1eef92624 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/Maze.java @@ -327,7 +327,7 @@ public class Maze implements Listener animation.b = 0; if (_host.Manager.GetDisguise().isDisguised(ent)) - animation.a = _host.Manager.GetDisguise().getDisguise(ent).GetEntityId(); + animation.a = _host.Manager.GetDisguise().getDisguise(ent).getEntityId(); for (Player cur : UtilServer.getPlayers()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java index dc3538511..fadbfffa1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java @@ -130,7 +130,7 @@ public class MonsterMaze extends SoloGame UtilTextMiddle.display("", C.cYellow + C.Bold + "Get to the Safe Pad!", 5, 40, 5); - for (Team team : GetScoreboard().GetScoreboard().getTeams()) + for (Team team : GetScoreboard().getScoreboard().getTeams()) team.setCanSeeFriendlyInvisibles(true); } else if(event.GetState() == GameState.Recruit) @@ -411,43 +411,43 @@ public class MonsterMaze extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (GetPlayers(true).size() > 5) { - Scoreboard.Write(C.cWhite + GetPlayers(true).size() + " Alive"); + Scoreboard.write(C.cWhite + GetPlayers(true).size() + " Alive"); } else { for (Player p : GetPlayers(true)) { - Scoreboard.Write(C.cWhite + p.getName()); + Scoreboard.write(C.cWhite + p.getName()); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cGreen + C.Bold + "Safe Pad"); + Scoreboard.write(C.cGreen + C.Bold + "Safe Pad"); if (_maze.getSafePad() != null) { - Scoreboard.Write(C.cWhite + _maze.getPhaseTimer() + " Seconds"); + Scoreboard.write(C.cWhite + _maze.getPhaseTimer() + " Seconds"); } else { - Scoreboard.Write("None"); + Scoreboard.write("None"); } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cGold + C.Bold + "Stage"); + Scoreboard.write(C.cGold + C.Bold + "Stage"); - Scoreboard.Write(C.cWhite + getMaze().getCurrentSafePadCount()); + Scoreboard.write(C.cWhite + getMaze().getCurrentSafePadCount()); - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java index e127ed2aa..f550a929b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java @@ -267,8 +267,6 @@ public class OldMineWare extends SoloGame player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); player.damage(5000); - - Scoreboard.ResetScore(player.getName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 20641932c..8fffdb878 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -144,7 +144,7 @@ public class Paintball extends TeamGame public void onNameTag(GameStateChangeEvent event) { if (event.GetState() == GameState.Prepare) - for (Team team : Scoreboard.GetScoreboard().getTeams()) + for (Team team : Scoreboard.getScoreboard().getTeams()) team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index eb581769f..7ecd12499 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; + +import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -102,7 +104,7 @@ public class Quiver extends SoloGame this.DeathSpectateSecs = 1; - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Kills", "dummy"); + _scoreObj = Scoreboard.getScoreboard().registerNewObjective("Kills", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); } @@ -306,17 +308,13 @@ public class Quiver extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - //Write New - for (QuiverScore score : _ranks) - { - Scoreboard.WriteOrdered("Score", C.cGreen + score.Player.getName(), score.Kills, true); - } + Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cGreen + score.Player.getName(), score.Kills), true); - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java index 4626d4f24..7da21409b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java @@ -192,22 +192,22 @@ public class QuiverTeams extends TeamGame private void WriteScoreboard() { //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : _teamKills.keySet()) { int kills = _teamKills.get(team); - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + team.GetName()); - Scoreboard.Write(kills + "" + team.GetColor() + " Kills"); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetColor() + team.GetName()); + Scoreboard.write(kills + "" + team.GetColor() + " Kills"); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.Bold + "First To"); - Scoreboard.Write(C.cGold + C.Bold + _reqKills + " Kills"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.Bold + "First To"); + Scoreboard.write(C.cGold + C.Bold + _reqKills + " Kills"); - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java index 40ccaf0d7..b6d739c57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java @@ -1,16 +1,14 @@ package nautilus.game.arcade.game.games.searchanddestroy; -import java.util.ArrayList; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.game.games.searchanddestroy.KitManager.UpgradeKit; - import org.bukkit.entity.Player; +import java.util.ArrayList; + public class KitEvolveShop extends ShopBase { @@ -18,9 +16,9 @@ public class KitEvolveShop extends ShopBase private ArrayList _kits; public KitEvolveShop(KitEvolve plugin, SearchAndDestroy arcadeManager, CoreClientManager clientManager, - DonationManager donationManager, ArrayList kits, CurrencyType... currencyTypes) + DonationManager donationManager, ArrayList kits) { - super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); + super(plugin, clientManager, donationManager, "Kit Evolve Menu"); _arcadeManager = arcadeManager; _kits = kits; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java index 5fc2ba8df..052b288b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java @@ -390,9 +390,9 @@ public class SearchAndDestroy extends TeamGame private void drawScoreboard() { - GetScoreboard().Reset(); + GetScoreboard().reset(); - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); ArrayList aliveTeams = new ArrayList(); for (GameTeam team : GetTeamList()) { @@ -411,8 +411,8 @@ public class SearchAndDestroy extends TeamGame GameTeam team = itel.next(); if (!team.IsTeamAlive()) continue; - GetScoreboard().Write(team.GetColor() + C.Bold + team.GetName() + " Team"); - GetScoreboard().Write(team.GetPlayers(true).size() + " alive"); + GetScoreboard().write(team.GetColor() + C.Bold + team.GetName() + " Team"); + GetScoreboard().write(team.GetPlayers(true).size() + " alive"); int bombsArmed = 0; for (TeamBomb bomb : bombs) @@ -424,20 +424,20 @@ public class SearchAndDestroy extends TeamGame } if (bombsArmed > 0) { - GetScoreboard().Write(team.GetColor() + "" + bombsArmed + " Bomb" + (bombsArmed > 1 ? "s" : "") + " Armed"); + GetScoreboard().write(team.GetColor() + "" + bombsArmed + " Bomb" + (bombsArmed > 1 ? "s" : "") + " Armed"); } else { - GetScoreboard().Write("Bombs Safe"); + GetScoreboard().write("Bombs Safe"); } if (itel.hasNext()) { - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); } } - GetScoreboard().Draw(); + GetScoreboard().draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java index 2f56ba572..5274a0fc1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -596,34 +597,30 @@ public class SheepGame extends TeamGame return; //Wipe Last - Scoreboard.Reset(); - Scoreboard.WriteBlank(); + Scoreboard.reset(); + Scoreboard.writeNewLine(); - //Write New - for (GameTeam team : _sheepPens.keySet()) + Scoreboard.writeGroup(_sheepPens.keySet(), team -> { - int score = getSheepCount(team); - - Scoreboard.WriteOrdered("Sheep", team.GetColor() + team.GetName(), score, true); - - _teamScore.put(team, score); - } + _teamScore.put(team, getSheepCount(team)); + return Pair.create(team.GetColor() + team.GetName(), getSheepCount(team)); + }, true); if (!IsLive()) return; - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Next Sheep"); - Scoreboard.Write(UtilTime.MakeStr(_sheepDelay - (System.currentTimeMillis() - _sheepTimer), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Next Sheep"); + Scoreboard.write(UtilTime.MakeStr(_sheepDelay - (System.currentTimeMillis() - _sheepTimer), 0)); long time = _gameTime - (System.currentTimeMillis() - this.GetStateTime()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, time), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, time), 0)); - Scoreboard.Draw(); + Scoreboard.draw(); } public void GetTeamPen(SheepData data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index 22bdc6d79..001e802bb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -5,6 +5,46 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.block.Chest; +import org.bukkit.block.DoubleChest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Egg; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -15,6 +55,7 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -23,11 +64,10 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.explosion.ExplosionEvent; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.ChestLoot; import mineplex.core.loot.RandomItem; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -38,85 +78,37 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.skywars.data.TNTGenerator; import nautilus.game.arcade.game.games.skywars.events.PlayerKillZombieEvent; -import nautilus.game.arcade.game.games.skywars.kits.KitChicken; -import nautilus.game.arcade.game.games.skywars.kits.KitDestructor; -import nautilus.game.arcade.game.games.skywars.kits.KitMiner; -import nautilus.game.arcade.game.games.skywars.kits.KitMadScientist; +import nautilus.game.arcade.game.games.skywars.kits.KitAir; +import nautilus.game.arcade.game.games.skywars.kits.KitEarth; +import nautilus.game.arcade.game.games.skywars.kits.KitFire; +import nautilus.game.arcade.game.games.skywars.kits.KitIce; +import nautilus.game.arcade.game.games.skywars.kits.KitMetal; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.ore.OreHider; -import nautilus.game.arcade.stats.DeathBomberStatTracker; -import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; -import nautilus.game.arcade.stats.SkywarsTNTStatTracker; -import nautilus.game.arcade.stats.WinWithoutOpeningChestStatTracker; -import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.block.DoubleChest; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Egg; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemDespawnEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.ProjectileLaunchEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; @SuppressWarnings("deprecation") public abstract class Skywars extends Game { - //./parse 19 30 56 - - private long _crumbleTime = 210000; + // ./parse 19 30 56 + + private long _crumbleTime = 150000; private ArrayList _worldBlocks = new ArrayList(); private HashSet _lootedBlocks = new HashSet(); private TNTGenerator _tntGen; private boolean _alreadyAnnounced; - + private NautHashMap _zombies = new NautHashMap(); private ArrayList _spawnChests = new ArrayList(); + private ArrayList _connectorChests = new ArrayList(); private ArrayList _middleChests = new ArrayList(); - + private HashMap _tntMap = new HashMap(); - private HashSet _pearls = new HashSet(); - + private HashMap _pearlMap = new HashMap(); + private long _lastChicken = 0; private OreHider _oreHider; @@ -126,34 +118,50 @@ public abstract class Skywars extends Game private ChestLoot _playerTool = new ChestLoot(); private ChestLoot _playerProjectile = new ChestLoot(); private ChestLoot _playerBlock = new ChestLoot(); + private ChestLoot _playerMisc = new ChestLoot(); + + private ChestLoot _connectorArmor = new ChestLoot(); + private ChestLoot _connectorFood = new ChestLoot(); + private ChestLoot _connectorTool = new ChestLoot(); + private ChestLoot _connectorProjectile = new ChestLoot(); + private ChestLoot _connectorBlock = new ChestLoot(); + private ChestLoot _connectorMisc = new ChestLoot(); private ChestLoot _middleArmor = new ChestLoot(); private ChestLoot _middleFood = new ChestLoot(); private ChestLoot _middleTool = new ChestLoot(); private ChestLoot _middleProjectile = new ChestLoot(); private ChestLoot _middleBlock = new ChestLoot(); - + private ChestLoot _middleBooks = new ChestLoot(); + private ChestLoot _middleMisc = new ChestLoot(); + + private Enchantment[] _armorEnchantments = new Enchantment[] { Enchantment.PROTECTION_ENVIRONMENTAL, Enchantment.PROTECTION_PROJECTILE, Enchantment.PROTECTION_FIRE, Enchantment.THORNS }; + private Enchantment[] _toolEnchantments = new Enchantment[] { Enchantment.DIG_SPEED, Enchantment.DURABILITY, Enchantment.LOOT_BONUS_BLOCKS }; + private Enchantment[] _swordEnchantments = new Enchantment[] { Enchantment.DAMAGE_ALL, Enchantment.FIRE_ASPECT, Enchantment.KNOCKBACK }; + private Enchantment[] _bowEnchantments = new Enchantment[] { Enchantment.ARROW_DAMAGE, Enchantment.ARROW_FIRE, Enchantment.ARROW_KNOCKBACK }; + + private HashMap _commonBookEnchantments = new HashMap(); + private HashMap _rareBookEnchantments = new HashMap(); + public Skywars(ArcadeManager manager, GameType type, String[] description) { - this(manager, new Kit[] - { - new KitChicken(manager), - new KitMiner(manager), - new KitMadScientist(manager), - new KitDestructor(manager), - - }, type, description); + this(manager, new Kit[] { + new KitIce(manager), + new KitFire(manager), + new KitAir(manager), + new KitMetal(manager), + new KitEarth(manager), + }, type, description); } - - @SuppressWarnings("unchecked") + public Skywars(ArcadeManager manager, Kit[] kits, GameType type, String[] description) { super(manager, type, kits, description); PrepareFreeze = true; - + AnnounceStay = false; - + HideTeamSheep = true; CompassEnabled = true; @@ -163,11 +171,11 @@ public abstract class Skywars extends Game GameTimeout = 1500000L; DeathDropItems = true; - + QuitDropItems = true; - WorldTimeSet = 0; - WorldBoundaryKill = false; + WorldTimeSet = 0; + WorldBoundaryKill = true; DamageSelf = true; DamageTeamSelf = true; @@ -188,26 +196,28 @@ public abstract class Skywars extends Game PlaySoundGameStart = true; PrepareTime = 10000L; - + DontAllowOverfill = true; _oreHider = new OreHider(); - _help = new String[] - { + _help = new String[] { - }; + }; setAlreadyAnnounced(false); - + setupBookEnchantments(); + setupPlayerLoot(); + setupConnectorLoot(); + setupMiddleLoot(); } + @Override public void ParseData() { - setupPlayerLoot(); - setupMiddleLoot(); parseCreateZombieSpawns(); parseCreateMiddleChests(); + parseCreateConnectorChests(); parseCreatePlayerChests(); parseCreatePlayerWebs(); @@ -215,7 +225,7 @@ public abstract class Skywars extends Game { oreLoc.getBlock().setType(Material.STONE); } - + // Remove Sponge (Holds up Sand) for (Location loc : WorldData.GetCustomLocs("19")) { @@ -236,8 +246,7 @@ public abstract class Skywars extends Game for (int z = WorldData.MinZ; z < WorldData.MaxZ; z++) { Block block = WorldData.World.getBlockAt(x, y, z); - if ((block.getType() != Material.AIR) - && (!block.isLiquid())) + if ((block.getType() != Material.AIR) && (!block.isLiquid())) { _worldBlocks.add(block); } @@ -251,7 +260,7 @@ public abstract class Skywars extends Game // Zombies for (Location loc : WorldData.GetDataLocs("RED")) { - //Spawn + // Spawn CreatureAllowOverride = true; Zombie zombie = (Zombie) loc.getWorld().spawn(loc, Zombie.class); zombie.setRemoveWhenFarAway(false); @@ -260,41 +269,51 @@ public abstract class Skywars extends Game zombie.setMaxHealth(15); zombie.setHealth(15); CreatureAllowOverride = false; - - // Armor - Make sure the player can't get it! - zombie.getEquipment().setHelmet( - new ItemStack(Material.GOLD_HELMET)); - zombie.getEquipment().setHelmetDropChance(0F); - zombie.getEquipment().setChestplate( - new ItemStack(Material.GOLD_CHESTPLATE)); - zombie.getEquipment().setChestplateDropChance(0F); - zombie.getEquipment().setLeggings( - new ItemStack(Material.GOLD_LEGGINGS)); - zombie.getEquipment().setLeggingsDropChance(0F); - zombie.getEquipment().setBoots( - new ItemStack(Material.GOLD_BOOTS)); - zombie.getEquipment().setBootsDropChance(0F); + // Armor - Make sure the player can't get it! + zombie.getEquipment().setHelmet(new ItemStack(Material.GOLD_HELMET)); + zombie.getEquipment().setHelmetDropChance(0F); + zombie.getEquipment().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE)); + zombie.getEquipment().setChestplateDropChance(0F); + zombie.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS)); + zombie.getEquipment().setLeggingsDropChance(0F); + zombie.getEquipment().setBoots(new ItemStack(Material.GOLD_BOOTS)); + zombie.getEquipment().setBootsDropChance(0F); _zombies.put(zombie, loc); } } - + private void parseCreateMiddleChests() { - for (int i=0 ; i<4 && !WorldData.GetDataLocs("YELLOW").isEmpty() ; i++) + for (int i = 0; i < 4 && !WorldData.GetDataLocs("BLACK").isEmpty(); i++) { - Location loc = UtilAlg.Random(WorldData.GetDataLocs("YELLOW")); - - WorldData.GetDataLocs("YELLOW").remove(loc); - + Location loc = UtilAlg.Random(WorldData.GetDataLocs("BLACK")); + + WorldData.GetDataLocs("BLACK").remove(loc); + loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true); - + _middleChests.add(loc.getBlock()); _worldBlocks.add(loc.getBlock()); } } + private void parseCreateConnectorChests() + { + for (int i = 0; i < 4 && !WorldData.GetDataLocs("GRAY").isEmpty(); i++) + { + Location loc = UtilAlg.Random(WorldData.GetDataLocs("GRAY")); + + WorldData.GetDataLocs("GRAY").remove(loc); + + loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true); + + _connectorChests.add(loc.getBlock()); + _worldBlocks.add(loc.getBlock()); + } + } + private void parseCreatePlayerChests() { NautHashMap> islandChests = new NautHashMap>(); @@ -302,8 +321,7 @@ public abstract class Skywars extends Game for (Location chestLoc : WorldData.GetDataLocs("BROWN")) { - Location closestSpawn = UtilAlg.findClosest(chestLoc, - GetTeamList().get(0).GetSpawns()); + Location closestSpawn = UtilAlg.findClosest(chestLoc, GetTeamList().get(0).GetSpawns()); if (UtilMath.offset2d(chestLoc, closestSpawn) > 8) continue; @@ -341,8 +359,7 @@ public abstract class Skywars extends Game for (Location webLoc : WorldData.GetCustomLocs("30")) { // Gets the spawn point closest to the current chest - Location closestSpawn = UtilAlg.findClosest(webLoc, - GetTeamList().get(0).GetSpawns()); + Location closestSpawn = UtilAlg.findClosest(webLoc, GetTeamList().get(0).GetSpawns()); if (UtilMath.offset2d(webLoc, closestSpawn) > 8) continue; @@ -373,9 +390,24 @@ public abstract class Skywars extends Game } } + private void setupBookEnchantments() + { + _commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 3); + _commonBookEnchantments.put(Enchantment.FIRE_ASPECT, 1); + _commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 3); + _commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + + _rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 4); + _rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 3); + _rareBookEnchantments.put(Enchantment.ARROW_FIRE, 1); + //_rareBookEnchantments.put(Enchantment.FIRE_ASPECT, 2); + _rareBookEnchantments.put(Enchantment.ARROW_KNOCKBACK, 1); + _rareBookEnchantments.put(Enchantment.KNOCKBACK, 2); + _rareBookEnchantments.put(Enchantment.THORNS, 1); + } @EventHandler - public void blockUpdate(UpdateEvent event) + public void onUpdateCrumble(UpdateEvent event) { if (event.getType() != UpdateType.TICK) { @@ -399,16 +431,14 @@ public abstract class Skywars extends Game if (!alreadyAnnounced()) { - Announce(C.cGreen + C.Bold - + "As time passes, the world begins to crumble..."); + Announce(C.cGreenB + "As time passes, the world begins to crumble..."); Player[] arrayOfPlayer; int j = (arrayOfPlayer = UtilServer.getPlayers()).length; for (int i = 0; i < j; i++) { Player player = arrayOfPlayer[i]; - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, - 3.0F, 1.0F); + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 3.0F, 1.0F); } setAlreadyAnnounced(true); } @@ -419,8 +449,7 @@ public abstract class Skywars extends Game double bestDist = 0.0D; for (Block block : _worldBlocks) { - double dist = UtilMath.offset2d(GetSpectatorLocation(), block - .getLocation().add(0.5D, 0.5D, 0.5D)); + double dist = UtilMath.offset2d(GetSpectatorLocation(), block.getLocation().add(0.5D, 0.5D, 0.5D)); if ((bestBlock == null) || (dist > bestDist)) { bestBlock = block; @@ -436,63 +465,82 @@ public abstract class Skywars extends Game { if (Math.random() > 0.95D) { - bestBlock.getWorld().spawnFallingBlock( - bestBlock.getLocation().add(0.5D, 0.5D, 0.5D), - bestBlock.getType(), bestBlock.getData()); + bestBlock.getWorld().spawnFallingBlock(bestBlock.getLocation().add(0.5D, 0.5D, 0.5D), bestBlock.getType(), bestBlock.getData()); } - MapUtil.QuickChangeBlockAt(bestBlock.getLocation(), - Material.AIR); + if (bestBlock.getType() == Material.WOODEN_DOOR || bestBlock.getType() == Material.IRON_DOOR_BLOCK) + { + MapUtil.QuickChangeBlockAt(bestBlock.getRelative(BlockFace.UP).getLocation(), Material.AIR); + } + MapUtil.QuickChangeBlockAt(bestBlock.getLocation(), Material.AIR); } } } @EventHandler - public void createIslandChickens(UpdateEvent event) + public void onUpdateChickens(UpdateEvent event) { if (!IsLive()) return; - + if (event.getType() != UpdateType.SEC) return; - + if (!UtilTime.elapsed(_lastChicken, 45000)) return; - + if (!UtilTime.elapsed(this.GetStateTime(), 5000)) return; - + CreatureAllowOverride = true; for (Location loc : GetTeamList().get(0).GetSpawns()) { Chicken chicken = loc.getWorld().spawn(loc.clone().add(0, 1, 0), Chicken.class); - + if (Math.random() > 0.75) chicken.setBaby(); - + chicken.setMaxHealth(4); chicken.setHealth(4); } CreatureAllowOverride = false; - + _lastChicken = System.currentTimeMillis(); } - + @EventHandler - public void sandMapWarning(GameStateChangeEvent event) + public void onGameStateChangeLeap(GameStateChangeEvent event) { - if (event.GetState() != Game.GameState.Live) + if (event.GetState() != GameState.Live) + { return; - + } + + for (Player player : GetPlayers(true)) + { + if (GetKit(player) instanceof KitAir) + { + player.sendMessage(F.main("Game", "Your " + F.skill("Leap") + " is on a 30 second cooldown.")); + Recharge.Instance.use(player, "Leap", 30000, true, false); + } + } + } + + @EventHandler + public void onGameStateChangeMapWarning(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + if (WorldData.MapName.equals("Sahara")) { UtilTextMiddle.display(C.cRed + "Warning", "Red Sand is Unstable", 10, 60, 20); } } - + @EventHandler - public void createIslandOres(GameStateChangeEvent event) + public void onGameStateChangeCreateOres(GameStateChangeEvent event) { - if (event.GetState() != Game.GameState.Prepare) + if (event.GetState() != GameState.Prepare) { return; } @@ -503,25 +551,27 @@ public abstract class Skywars extends Game // Allocate chests to their nearest spawn point for (Location oreLoc : WorldData.GetCustomLocs("56")) { - // Gets the spawn point closest to the current - Location closestOre = UtilAlg.findClosest(oreLoc, - GetTeamList().get(0).GetSpawns()); + for (GameTeam team : GetTeamList()) // This handles Team Skywars + { + // Gets the spawn point closest to the current + Location closestOre = UtilAlg.findClosest(oreLoc, team.GetSpawns()); - if (UtilMath.offset2d(oreLoc, closestOre) > 8) - continue; + if (UtilMath.offset2d(oreLoc, closestOre) > 8) + continue; - // Ensure the list exists - if (!islandOres.containsKey(closestOre)) - islandOres.put(closestOre, new ArrayList()); + // Ensure the list exists + if (!islandOres.containsKey(closestOre)) + islandOres.put(closestOre, new ArrayList()); - // Add this chest location to the spawn - islandOres.get(closestOre).add(oreLoc); + // Add this chest location to the spawn + islandOres.get(closestOre).add(oreLoc); + } } // Vein Counts - int diamondVeins = 2 + UtilMath.r(2); - int ironVeins = 4 + UtilMath.r(4); - int gravelVeins = 4 + UtilMath.r(3); + int diamondVeins = 3; + int ironVeins = 7; + int gravelVeins = 4; // Create Ores for (ArrayList ores : islandOres.values()) @@ -537,8 +587,7 @@ public abstract class Skywars extends Game } } - private void createVein(ArrayList ores, Material type, - int veinSize, boolean allowAboveAir) + private void createVein(ArrayList ores, Material type, int veinSize, boolean allowAboveAir) { if (ores.isEmpty()) return; @@ -559,7 +608,7 @@ public abstract class Skywars extends Game } @EventHandler - public void createRandomChests(GameStateChangeEvent event) + public void onGameStateChangeCreateChests(GameStateChangeEvent event) { if (event.GetState() != Game.GameState.Live) { @@ -578,9 +627,7 @@ public abstract class Skywars extends Game { attempts++; - Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX - + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), - ignore); + Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), ignore); // Dont spawn near player islands boolean nearPlayer = false; @@ -598,13 +645,12 @@ public abstract class Skywars extends Game continue; } - //Find LOWEST valid point - prevents spawning on rooftops/etc + // Find LOWEST valid point - prevents spawning on rooftops/etc Block validChest = null; while (block.getY() > WorldData.MinY) { // Valid Spot for Chest - if ((UtilBlock.airFoliage(block)) - && (UtilBlock.solid(block.getRelative(BlockFace.DOWN)))) + if ((UtilBlock.airFoliage(block)) && (UtilBlock.solid(block.getRelative(BlockFace.DOWN)))) { validChest = block; } @@ -614,8 +660,7 @@ public abstract class Skywars extends Game if (validChest != null) { - validChest.setTypeIdAndData(Material.CHEST.getId(), - (byte) UtilMath.r(4), false); + validChest.setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), false); _worldBlocks.add(validChest); @@ -635,7 +680,7 @@ public abstract class Skywars extends Game } @EventHandler - public void openChest(PlayerInteractEvent event) + public void onPlayerInteract(PlayerInteractEvent event) { if (event.isCancelled()) { @@ -671,20 +716,21 @@ public abstract class Skywars extends Game fillChest(event.getPlayer(), block); } } - + @EventHandler - public void pickupTNT(PlayerPickupItemEvent e) + public void onPlayerPickupItem(PlayerPickupItemEvent e) { ItemStack is = e.getItem().getItemStack(); Player player = e.getPlayer(); if (is.getType() == Material.TNT) { - e.setCancelled(_tntGen.pickup(player, e.getItem())); + e.setCancelled(true); + _tntGen.pickup(player, e.getItem()); } } @EventHandler - public void onTNTThrow(PlayerInteractEvent e) + public void onPlayerInteractTNT(PlayerInteractEvent e) { if (!IsLive()) { @@ -707,59 +753,56 @@ public abstract class Skywars extends Game UtilInv.remove(player, Material.TNT, (byte) 0, 1); UtilInv.Update(player); - TNTPrimed tnt = (TNTPrimed) player.getWorld().spawn( - player.getEyeLocation() - .add(player.getLocation().getDirection()), - TNTPrimed.class); + TNTPrimed tnt = (TNTPrimed) player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); tnt.setFuseTicks(60); if (UtilEvent.isAction(e, UtilEvent.ActionType.L)) { - UtilAction.velocity(tnt, player.getLocation().getDirection(), - 1.75D, false, 0.0D, 0.1D, 10.0D, false); - player.playSound(player.getLocation(), Sound.GHAST_FIREBALL, 3.0F, - 1.0F); + UtilAction.velocity(tnt, player.getLocation().getDirection(), 1.75D, false, 0.0D, 0.1D, 10.0D, false); + player.playSound(player.getLocation(), Sound.GHAST_FIREBALL, 3.0F, 1.0F); } - + _tntMap.put(tnt, player); } @EventHandler - public void ItemDespawn(ItemDespawnEvent event) + public void onItemDespawn(ItemDespawnEvent event) { event.setCancelled(true); } @EventHandler - public void handleTNTCannon(UpdateEvent e) + public void onUpdateTNTCannon(UpdateEvent e) { if (!IsLive()) return; if (e.getType() == UpdateType.FAST) + { _tntGen.update(); + } } @EventHandler - public void zombieUpdate(UpdateEvent event) + public void onUpdateZombie(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + Iterator zombieIter = _zombies.keySet().iterator(); - + while (zombieIter.hasNext()) { Zombie zombie = zombieIter.next(); - + if (!zombie.isValid()) { zombieIter.remove(); continue; } - + Location loc = _zombies.get(zombie); - + if (zombie.getTarget() == null || UtilMath.offset(zombie.getLocation(), loc) > 8) { zombie.setTarget(null); @@ -767,15 +810,15 @@ public abstract class Skywars extends Game } } } - + @EventHandler - public void zombieTarget(EntityTargetLivingEntityEvent event) + public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) { - if (event.getTarget() != null && event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie)event.getEntity())) + if (event.getTarget() != null && event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie) event.getEntity())) { - Zombie zombie = (Zombie)event.getEntity(); + Zombie zombie = (Zombie) event.getEntity(); Location loc = _zombies.get(zombie); - + if (UtilMath.offset(event.getTarget().getLocation(), loc) > 8) { event.setCancelled(true); @@ -783,313 +826,361 @@ public abstract class Skywars extends Game } } } - + @EventHandler - public void noZombieBurn(EntityCombustEvent e) + public void onEntityCombust(EntityCombustEvent event) { - if ((e.getEntity() instanceof Zombie)) + if ((event.getEntity() instanceof Zombie)) { - e.setDuration(0); - e.setCancelled(true); + event.setDuration(0); + event.setCancelled(true); } } @EventHandler - public void blockBurn(BlockBurnEvent event) + public void onBlockBurn(BlockBurnEvent event) { event.setCancelled(true); } @EventHandler - public void blockDecay(LeavesDecayEvent event) + public void onBlockDecay(LeavesDecayEvent event) { event.setCancelled(true); } @EventHandler - public void blockFade(BlockFadeEvent event) + public void onBlockFade(BlockFadeEvent event) { event.setCancelled(true); } @EventHandler - public void blockSpread(BlockSpreadEvent event) + public void onBlockSpread(BlockSpreadEvent event) { event.setCancelled(true); } @EventHandler - public void onBlockPlaceAdd(BlockPlaceEvent e) + public void onBlockPlaceAdd(BlockPlaceEvent event) { - _worldBlocks.add(e.getBlock()); - - if (e.getBlock().getType() == Material.CHEST || - e.getBlock().getType() == Material.PISTON_BASE || - e.getBlock().getType() == Material.PISTON_STICKY_BASE || - e.getBlock().getType() == Material.HOPPER) + Material material = event.getBlock().getType(); + _worldBlocks.add(event.getBlock()); + + if (material == Material.CHEST || material == Material.PISTON_BASE || material == Material.PISTON_STICKY_BASE || material == Material.HOPPER) { - e.setCancelled(true); + event.setCancelled(true); } } @EventHandler - public void blockBonusDrops(BlockBreakEvent e) + public void onBlockPhysics(BlockPhysicsEvent event) { - e.setExpToDrop(0); - - final Block block = e.getBlock(); - - if (e.getBlock().getType() == Material.WEB) + if (IsLive()) { - Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - block.getWorld().dropItem(block.getLocation().add(0.5, 0.2, 0.5), new ItemStack(Material.STRING)); - - }}, 1); - + _worldBlocks.add(event.getBlock()); } + } - if (e.getBlock().getType() == Material.GRAVEL) + @EventHandler(priority = EventPriority.MONITOR) + public void onBlockBreakBonusDrops(BlockBreakEvent event) + { + event.setExpToDrop(0); + + Block block = event.getBlock(); + + if (block.getType() == Material.WEB) { - e.setCancelled(true); - e.getBlock().setType(Material.AIR); - - Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - for (int i=0 ; i<1 + UtilMath.r(3) ; i++) - block.getWorld().dropItem(block.getLocation().add(0.5, 0.2, 0.5), new ItemStack(Material.FLINT)); - - }}, 1); + event.setCancelled(true); + block.setType(Material.AIR); + + for (int i = 0; i < 1 + UtilMath.r(2); i++) + block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.STRING)); } - - if (e.getBlock().getType() == Material.IRON_ORE) + else if (block.getType() == Material.GRAVEL) { - e.setCancelled(true); - e.getBlock().setType(Material.AIR); - - Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - block.getWorld().dropItem(block.getLocation().add(0.5, 0.2, 0.5), new ItemStack(Material.IRON_INGOT)); - - }}, 1); + event.setCancelled(true); + block.setType(Material.AIR); + + for (int i = 0; i < 1 + UtilMath.r(3); i++) + block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.FLINT)); + } + else if (block.getType() == Material.IRON_ORE) + { + event.setCancelled(true); + block.setType(Material.AIR); + block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.IRON_INGOT)); } } @EventHandler - public void onKillZombie(EntityDeathEvent e) + public void onEntityDeathZombie(EntityDeathEvent event) { - if (e.getEntity() instanceof Zombie) + if (event.getEntity() instanceof Zombie) { - Zombie ent = (Zombie) e.getEntity(); + Zombie ent = (Zombie) event.getEntity(); if (_zombies.containsKey(ent)) { if (ent.getKiller() instanceof Player) { - Player p = ent.getKiller(); + Player player = ent.getKiller(); - Bukkit.getPluginManager().callEvent( - new PlayerKillZombieEvent(p, ent)); + Bukkit.getPluginManager().callEvent(new PlayerKillZombieEvent(player, ent)); } } } - else - { - return; - } } @EventHandler - public void blockBreak(BlockBreakEvent e) + public void onBlockBreakTNTSpawner(BlockBreakEvent event) { - if (e.getBlock().getType() == Material.IRON_BLOCK) + Material material = event.getBlock().getType(); + if (material == Material.IRON_BLOCK || material == Material.REDSTONE_BLOCK) { - e.setCancelled(true); - } - if (e.getBlock().getType() == Material.REDSTONE_BLOCK) - { - e.setCancelled(true); + event.setCancelled(true); } } @EventHandler - public void disableDamageToLevel(CustomDamageEvent event) + public void onCustomDamageToLevel(CustomDamageEvent event) { event.SetDamageToLevel(false); } - + @EventHandler - public void mobLoot(EntityDeathEvent event) + public void onEntityDeathMobLoot(EntityDeathEvent event) { - //Zombie Loot - if (event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie)event.getEntity())) + // Zombie Loot + if (event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie) event.getEntity())) { event.getDrops().clear(); - + double r = Math.random(); - - if (r > 0.80) event.getDrops().add(_middleArmor.getLoot()); - else if (r > 0.60) event.getDrops().add(_middleTool.getLoot()); - else if (r > 0.40) event.getDrops().add(_middleProjectile.getLoot()); - else event.getDrops().add(_middleFood.getLoot()); + + if (r > 0.80) + event.getDrops().add(_middleArmor.getLoot()); + else if (r > 0.60) + event.getDrops().add(_middleTool.getLoot()); + else if (r > 0.40) + event.getDrops().add(_middleProjectile.getLoot()); + else + event.getDrops().add(_middleFood.getLoot()); } - //Chicken Loot + // Chicken Loot else if (event.getEntity() instanceof Chicken) { event.getDrops().clear(); - + event.getDrops().add(new ItemStack(Material.FEATHER, 1 + UtilMath.r(4))); } } @EventHandler - public void eggHit(CustomDamageEvent event) + public void onCustomDamageProjectile(CustomDamageEvent event) { if (event.GetProjectile() == null) - return; - - if (event.GetDamage() >= 1) - return; - - if(this instanceof TeamSkywars) { - if(GetTeam(event.GetDamagerPlayer(true)) == GetTeam(event.GetDamageePlayer())) - { - return; - } + return; } - + if (event.GetProjectile() instanceof Egg || event.GetProjectile() instanceof Snowball) { - event.SetCancelled("Egg/Snowball"); - - // Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), - (LivingEntity) event.GetProjectile().getShooter(), event.GetProjectile(), - DamageCause.PROJECTILE, 1, false, true, false, - UtilEnt.getName((LivingEntity) event.GetProjectile().getShooter()), - (event.GetProjectile() instanceof Egg ? "Egg" : "Snowball")); - - - Vector vel = event.GetProjectile().getVelocity().multiply(0.2); - - if (vel.getY() < 0.1) - vel.setY(0.1); - - UtilAction.velocity(event.GetDamageeEntity(), vel); + event.AddMod(event.GetDamagerPlayer(true).getName(), (event.GetProjectile() instanceof Egg ? "Egg" : "Snowball"), 2, true); } } - @EventHandler - public void projectile(EntityDamageByEntityEvent event) - { - if(event.getDamager() instanceof Snowball || event.getDamager() instanceof Egg || event.getDamager() instanceof EnderPearl) - { - Projectile prj = (Projectile) event.getDamager(); - if(prj.getShooter() instanceof Player) - { - if(event.getEntity() instanceof Player) - { - - if(this instanceof SoloSkywars) - return; - - if(GetTeam((Player) prj.getShooter()) == GetTeam((Player) event.getEntity())) - { - event.setCancelled(true); - } - } - } - } - } - public void fillChest(Player looter, Block block) { _lootedBlocks.add(block.getLocation()); Chest chest = (Chest) block.getState(); chest.getBlockInventory().clear(); - - //Prevents same inventory spot being used twice + + // Prevents same inventory spot being used twice HashSet used = new HashSet(); - - //Player Island + + // Player Island if (_spawnChests.contains(block)) { - //Armor - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _playerArmor.getLoot()); - - //Food - for (int i=0 ; i<1 + UtilMath.r(3) ; i++) + // Armor + for (int i = 0; i < 1 + UtilMath.r(2); i++) + { + ItemStack itemStack = _playerArmor.getLoot(); + + for (Enchantment enchantment : Enchantment.values()) + { + itemStack.removeEnchantment(enchantment); + } + + if (UtilMath.r(2) == 0) + { + itemStack.addEnchantment(_armorEnchantments[UtilMath.r(_armorEnchantments.length - 1)], UtilMath.r(2) + 1); + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } + + // Food + for (int i = 0; i < 1 + UtilMath.r(3); i++) chest.getBlockInventory().setItem(getIndex(used), _playerFood.getLoot()); - - //Tool - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _playerTool.getLoot()); - - //Projectile - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + + // Tool + for (int i = 0; i < 1 + UtilMath.r(2); i++) + { + ItemStack itemStack = _playerTool.getLoot(); + + for (Enchantment enchantment : Enchantment.values()) + { + itemStack.removeEnchantment(enchantment); + } + + if (UtilMath.r(2) == 0) + { + if (UtilItem.isSword(itemStack)) + { + itemStack.addEnchantment(_swordEnchantments[UtilMath.r(_swordEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (itemStack.getType() == Material.BOW) + { + itemStack.addEnchantment(_bowEnchantments[UtilMath.r(_bowEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (UtilItem.isAxe(itemStack)) + { + + } + else if (UtilItem.isTool(itemStack)) + { + itemStack.addEnchantment(_toolEnchantments[UtilMath.r(_toolEnchantments.length - 1)], UtilMath.r(2) + 1); + } + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } + + // Projectile + for (int i = 0; i < 1 + UtilMath.r(2); i++) chest.getBlockInventory().setItem(getIndex(used), _playerProjectile.getLoot()); - - //Block - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + + // Block + for (int i = 0; i < 1 + UtilMath.r(2); i++) chest.getBlockInventory().setItem(getIndex(used), _playerBlock.getLoot()); + + // Misc + for (int i = 0; i < 1 + UtilMath.r(2); i++) + chest.getBlockInventory().setItem(getIndex(used), _playerMisc.getLoot()); } - //Other - else if (_middleChests.contains(block)) + // Connector + else if (_connectorChests.contains(block)) { - //Armor - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _middleArmor.getLoot()); - - //Food - for (int i=0 ; i<1 + UtilMath.r(3) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _middleFood.getLoot()); - - //Tool - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _middleTool.getLoot()); - - //Projectile - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _middleProjectile.getLoot()); - - //Block - for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot()); + // Armor + for (int i = 0; i < 1 + UtilMath.r(2); i++) + { + ItemStack itemStack = _connectorArmor.getLoot(); + + for (Enchantment enchantment : Enchantment.values()) + { + itemStack.removeEnchantment(enchantment); + } + + if (UtilMath.r(2) == 0) + { + itemStack.addEnchantment(_armorEnchantments[UtilMath.r(_armorEnchantments.length - 1)], UtilMath.r(2) + 1); + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } + + // Food + for (int i = 0; i < 1 + UtilMath.r(3); i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorFood.getLoot()); + + // Tool + for (int i = 0; i < 1 + UtilMath.r(2); i++) + { + ItemStack itemStack = _connectorTool.getLoot(); + + for (Enchantment enchantment : Enchantment.values()) + { + itemStack.removeEnchantment(enchantment); + } + + if (UtilMath.r(2) == 0) + { + if (UtilItem.isSword(itemStack)) + { + itemStack.addEnchantment(_swordEnchantments[UtilMath.r(_swordEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (UtilItem.isTool(itemStack)) + { + itemStack.addEnchantment(_toolEnchantments[UtilMath.r(_toolEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (itemStack.getType() == Material.BOW) + { + itemStack.addEnchantment(_bowEnchantments[UtilMath.r(_bowEnchantments.length - 1)], UtilMath.r(2) + 1); + } + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } + + // Projectile + for (int i = 0; i < 1 + UtilMath.r(2); i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorProjectile.getLoot()); + + // Block + for (int i = 0; i < 1 + UtilMath.r(2); i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorBlock.getLoot()); + + // Misc + for (int i = 0; i < 1 + UtilMath.r(2); i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorMisc.getLoot()); } - else + // Middle + else { - //Armor - for (int i=0 ; i blocks = event.GetBlocks().iterator(); + + while (blocks.hasNext()) + { + Block block = blocks.next(); + if (block.getType() == Material.CHEST || block.getType() == Material.ANVIL) + { + blocks.remove(); + } + } } - @EventHandler(priority = EventPriority.MONITOR) - public void OreReveal(BlockBreakEvent event) + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) { - if (event.isCancelled()) - return; + if (event.getBlock().getType() == Material.ANVIL) + { + event.setCancelled(true); + } + } + @EventHandler + public void onBlockBreakOreReveal(BlockBreakEvent event) + { _oreHider.BlockBreak(event); } - + @EventHandler - public void tntDamageAttribute(ExplosionPrimeEvent event) + public void onExplosionPrime(ExplosionPrimeEvent event) { Player player = _tntMap.get(event.getEntity()); if (player != null) @@ -1235,72 +1391,70 @@ public abstract class Skywars extends Game } } } - + @EventHandler - public void pearlRide(ProjectileLaunchEvent event) + public void onProjectileLaunch(ProjectileLaunchEvent event) { if (!IsLive()) return; - + if (!(event.getEntity() instanceof EnderPearl)) return; - + if (event.getEntity().getShooter() == null) return; - + if (!(event.getEntity().getShooter() instanceof Player)) return; - - Player shooter = (Player)event.getEntity().getShooter(); - - if (event.getEntity().hasMetadata("Destructor")) - return; - - event.getEntity().setPassenger(shooter); - - _pearls.add(event.getEntity()); - - ((CraftPlayer)shooter).getHandle().spectating = true; + + Player shooter = (Player) event.getEntity().getShooter(); + + _pearlMap.put(event.getEntity(), shooter); } - + @EventHandler - public void pearlUpdate(UpdateEvent event) + public void onProjectileHit(ProjectileHitEvent event) + { + if (_pearlMap.get(event.getEntity()) == null) + { + return; + } + + Player player = _pearlMap.get(event.getEntity()); + Location playerLocation = player.getLocation(); + Location entityLocation = event.getEntity().getLocation(); + float yaw = playerLocation.getYaw(); + float pitch = playerLocation.getPitch(); + + player.setFallDistance(0); + player.teleport(new Location(player.getWorld(), entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), yaw, pitch)); + + _pearlMap.remove(event.getEntity()); + } + + @EventHandler + public void onUpdatePeral(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - - //Disable Spec - for (Player player : GetPlayers(true)) - if (((CraftPlayer)player).getHandle().spectating && player.getVehicle() == null) - ((CraftPlayer)player).getHandle().spectating = false; - - Iterator pearlIter = _pearls.iterator(); - - while (pearlIter.hasNext()) + + for (Entity entity : _pearlMap.keySet()) { - Projectile proj = pearlIter.next(); - - if (!proj.isValid()) - { - proj.remove(); - pearlIter.remove(); - continue; - } - - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, proj.getLocation(), 0f, 0f, 0f, 0f, 1, ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, entity.getLocation(), 0f, 0f, 0f, 0f, 1, ViewDist.MAX, UtilServer.getPlayers()); } } - + @EventHandler - public void killLevelReward(CombatDeathEvent event) + public void onCombatDeathEventLevels(CombatDeathEvent event) { Game game = Manager.GetGame(); - if (game == null) return; + if (game == null) + return; if (!(event.GetEvent().getEntity() instanceof Player)) return; - Player killed = (Player)event.GetEvent().getEntity(); + Player killed = (Player) event.GetEvent().getEntity(); if (event.GetLog().GetKiller() != null) { @@ -1308,9 +1462,9 @@ public abstract class Skywars extends Game if (killer != null && !killer.equals(killed)) { - //Kill + // Kill killer.giveExpLevels(2); - + killer.playSound(killer.getLocation(), Sound.LEVEL_UP, 1f, 1f); } } @@ -1322,48 +1476,50 @@ public abstract class Skywars extends Game Player assist = UtilPlayer.searchExact(log.GetName()); - //Assist + // Assist if (assist != null) { assist.giveExpLevels(1); assist.playSound(assist.getLocation(), Sound.ORB_PICKUP, 1f, 1f); } - + } } - + @Override public double GetKillsGems(Player killer, Player killed, boolean assist) { - if (assist) - return 3; - else - return 12; + return assist ? 3 : 12; } - - public TNTGenerator getTnTGen() + + public TNTGenerator getTnTGen() { return this._tntGen; } - + public long getCrumbleTime() { return this._crumbleTime; } - + public ArrayList getSpawnChests() { return _spawnChests; } - + + public ArrayList getConnectorChests() + { + return _connectorChests; + } + public ArrayList getMiddleChests() { return _middleChests; } - + public HashSet getLooted() { return _lootedBlocks; } - + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java index 207ee85e8..be448adde 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java @@ -29,6 +29,7 @@ public class SoloSkywars extends Skywars private GameTeam _players; + @SuppressWarnings("unchecked") public SoloSkywars(ArcadeManager manager) { this(manager, GameType.Skywars); @@ -99,51 +100,51 @@ public class SoloSkywars extends Skywars if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); GameTeam team = GetTeamList().get(0); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Players"); if (team.GetPlayers(true).size() > 4) { - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write("" + team.GetPlayers(true).size()); } else { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(C.cWhite + player.getName()); + Scoreboard.write(C.cWhite + player.getName()); } } if (IsLive()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); - Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); - Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + Scoreboard.writeNewLine(); + Scoreboard.write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.write(this.getTnTGen().getScoreboardInfo()); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) { - Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); - Scoreboard.Write("Active"); + Scoreboard.write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.write("Active"); } else { - Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); - Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 2b470ce33..74ed0a76a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -1,24 +1,19 @@ package nautilus.game.arcade.game.games.skywars; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.stats.DeathBomberStatTracker; import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; @@ -26,20 +21,10 @@ import nautilus.game.arcade.stats.SkywarsTNTStatTracker; import nautilus.game.arcade.stats.WinWithoutOpeningChestStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; - public class TeamSkywars extends Skywars { + @SuppressWarnings("unchecked") public TeamSkywars(ArcadeManager manager) { this(manager, GameType.SkywarsTeams); @@ -96,10 +81,10 @@ public class TeamSkywars extends Skywars if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Teams"); ArrayList alive = new ArrayList(); for (GameTeam team : GetTeamList()) @@ -114,7 +99,7 @@ public class TeamSkywars extends Skywars { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } } @@ -122,39 +107,39 @@ public class TeamSkywars extends Skywars { for (GameTeam team : alive) { - Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } } else { - Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + Scoreboard.write(C.cWhite + alive.size() + " Alive"); } if (IsLive()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); - Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); - Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + Scoreboard.writeNewLine(); + Scoreboard.write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.write(this.getTnTGen().getScoreboardInfo()); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) { - Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); - Scoreboard.Write("Active"); + Scoreboard.write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.write("Active"); } else { - Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); - Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitAir.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitAir.java new file mode 100644 index 000000000..2722c0a8f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitAir.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.skywars.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkVoidSaver; + +public class KitAir extends ProgressingKit +{ + + private static final String DOUBLE_JUMP = "Leap"; + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Eye of Ender", + "", + "Right Click " + C.cGreen + "Eye of Ender" + C.cWhite + " to teleport back to your", + "last safe location", + C.cRedB + "ONE" + C.cWhite + " use only.", + "", + C.cYellow + "Tap Jump Twice" + C.cWhite + " to " + C.cGreen + DOUBLE_JUMP, + }; + + private static final Perk[][] PERKS = + { + { + new PerkVoidSaver(), + new PerkDoubleJump(DOUBLE_JUMP, 1, 1, true, 30000, true) + }, + { + new PerkVoidSaver(), + new PerkDoubleJump(DOUBLE_JUMP, 1, 1, true, 29000, true) + }, + { + new PerkVoidSaver(), + new PerkDoubleJump(DOUBLE_JUMP, 1.1, 1, true, 29000, true) + }, + { + new PerkVoidSaver(), + new PerkDoubleJump(DOUBLE_JUMP, 1.1, 1, true, 28000, true) + }, + { + new PerkVoidSaver(), + new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 28000, true) + }, + { + new PerkVoidSaver(), + new PerkDoubleJump(DOUBLE_JUMP, 1.2, 1, true, 27000, true) + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + reduceCooldown(DOUBLE_JUMP, 1) + }, + { + increase(DOUBLE_JUMP, "Range", 10) + }, + { + reduceCooldown(DOUBLE_JUMP, 1) + }, + { + increase(DOUBLE_JUMP, "Range", 10) + }, + { + reduceCooldown(DOUBLE_JUMP, 1) + }, + }; + + private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemBuilder(Material.EYE_OF_ENDER).setTitle(C.cGreen + "Eye of Ender").build() }; + + private static final ItemStack IN_HAND = new ItemStack(Material.EYE_OF_ENDER); + + public KitAir(ArcadeManager manager) + { + super(manager, "Air", "skywarsmadscientist", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @Override + public boolean showUpgrades() + { + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitChicken.java deleted file mode 100644 index 058875fc6..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitChicken.java +++ /dev/null @@ -1,47 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkChicken; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitChicken extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "BAWK BAWK. Eggs!", - "", - "Get a chicken that follows you around", - "And lays eggs every " + C.cGreen + 8 + C.cWhite + " seconds!" - }; - - private static final Perk[] PERKS = { - new PerkChicken() - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.EGG); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE), - ItemStackFactory.Instance.CreateStack(Material.WOOD_PICKAXE) - }; - - - public KitChicken(ArcadeManager manager) - { - super(manager, "Chicken Farmer", "skywarschickenfarmer", KitAvailability.Free, 0, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - ((PerkChicken) PERKS[0]).spawnChicken(player, player.getLocation()); - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDestructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDestructor.java deleted file mode 100644 index a735ffbcd..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDestructor.java +++ /dev/null @@ -1,58 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.achievement.Achievement; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkDestructor; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitDestructor extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "Your Ender Pearls make the world crumble!", - "", - receiveItem("Seismic Charge", 1, 40, 2), - C.cYellow + "Right-Click" + C.cWhite + " with Seismic Charge to " + C.cGreen + "Throw Seismic Charge", - }; - - private static final Perk[] PERKS = { - new PerkDestructor(40, 2, 2500, true) - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.ENDER_PEARL); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE), - ItemStackFactory.Instance.CreateStack(Material.WOOD_PICKAXE) - }; - - private static final Achievement[] ACHIEVEMENTS = { - Achievement.SKYWARS_BOMBER, - Achievement.SKYWARS_NOARMOR, - Achievement.SKYWARS_NOCHEST, - Achievement.SKYWARS_PLAYER_KILLS, - Achievement.SKYWARS_TNT, - Achievement.SKYWARS_WINS, - Achievement.SKYWARS_ZOMBIE_KILLS - }; - - public KitDestructor(ArcadeManager manager) - { - super(manager, "Destructor", "skywarsdestructor", KitAvailability.Achievement, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - - this.setAchievementRequirements(ACHIEVEMENTS); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitEarth.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitEarth.java new file mode 100644 index 000000000..f104da903 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitEarth.java @@ -0,0 +1,115 @@ +package nautilus.game.arcade.game.games.skywars.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDirtCannon; +import nautilus.game.arcade.kit.perks.PerkKnockback; + +public class KitEarth extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Wood Shovel", + "", + C.cYellow + "Right-Click" + C.cWhite + " to fire " + C.cGreen + "Throwable Dirt", + "You recieve " + C.cGreen + "1 Throwable Dirt " + C.cWhite + "every", + C.cGreen + UtilTime.convertString(20000, 0, TimeUnit.SECONDS) + C.cWhite + ".", + "You take " + C.cGreen + "25" + C.cWhite + "% knockback while on the ground." + }; + + private static final String DIRT_CANNON = "Throwable Dirt"; + private static final String KNOCKBACK = "Knockback"; + + private static final Perk[][] PERKS = + { + { + new PerkDirtCannon(1), + new PerkKnockback(0.75, true) + }, + { + new PerkDirtCannon(1.1), + new PerkKnockback(0.75, true) + }, + { + new PerkDirtCannon(1.2), + new PerkKnockback(0.75, true) + }, + { + new PerkDirtCannon(1.3), + new PerkKnockback(0.75, true) + }, + { + new PerkDirtCannon(1.4), + new PerkKnockback(0.75, true) + }, + { + new PerkDirtCannon(1.5), + new PerkKnockback(0.75, true) + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + increase(DIRT_CANNON, KNOCKBACK, 10) + }, + { + increase(DIRT_CANNON, KNOCKBACK, 10) + }, + { + increase(DIRT_CANNON, KNOCKBACK, 10) + }, + { + increase(DIRT_CANNON, KNOCKBACK, 10) + }, + { + increase(DIRT_CANNON, KNOCKBACK, 10) + }, + }; + + private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemStack(Material.WOOD_SPADE) }; + + private static final ItemStack IN_HAND = new ItemStack(Material.DIRT); + + private static final Achievement[] ACHIEVEMENTS = + { + Achievement.SKYWARS_BOMBER, + Achievement.SKYWARS_NOARMOR, + Achievement.SKYWARS_NOCHEST, + Achievement.SKYWARS_PLAYER_KILLS, + Achievement.SKYWARS_TNT, + Achievement.SKYWARS_WINS, + Achievement.SKYWARS_ZOMBIE_KILLS + }; + + public KitEarth(ArcadeManager manager) + { + super(manager, "Earth", "skywarsearth", KitAvailability.Achievement, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + + setAchievementRequirements(ACHIEVEMENTS); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @Override + public boolean showUpgrades() + { + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java new file mode 100644 index 000000000..b078a8252 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java @@ -0,0 +1,97 @@ +package nautilus.game.arcade.game.games.skywars.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkFireBurst; + +public class KitFire extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Blaze Rod", + "", + C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst", + "Sends out a pulse of fire that deals " + C.cGreen + 3 + C.cWhite + " damage to", + "all players within " + C.cGreen + 4 + C.cWhite + " blocks.", + "Cooldown " + C.cGreen + UtilTime.convertString(45000, 0, TimeUnit.SECONDS) + C.cWhite + "." + }; + + private static final String FIRE_BURST = "Fire Burst"; + + private static final Perk[][] PERKS = + { + { + new PerkFireBurst(45000, 4, 3) + }, + { + new PerkFireBurst(44000, 4, 3) + }, + { + new PerkFireBurst(43000, 4, 3) + }, + { + new PerkFireBurst(42000, 4, 4) + }, + { + new PerkFireBurst(41000, 4, 4) + }, + { + new PerkFireBurst(40000, 4, 4) + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + reduceCooldown(FIRE_BURST, 1) + }, + { + reduceCooldown(FIRE_BURST, 1) + }, + { + reduceCooldown(FIRE_BURST, 1), + increase(FIRE_BURST, "Range", 20) + }, + { + reduceCooldown(FIRE_BURST, 1) + }, + { + reduceCooldown(FIRE_BURST, 1) + }, + }; + + + private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemBuilder(Material.BLAZE_ROD).setTitle(C.cGreen + "Fire Burst").build() }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); + + public KitFire(ArcadeManager manager) + { + super(manager, "Fire", "skywarsminer", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @Override + public boolean showUpgrades() + { + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitIce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitIce.java new file mode 100644 index 000000000..c565ed750 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitIce.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.skywars.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkIceBridge; + +public class KitIce extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Ice", + "", + C.cYellow + "Right Click" + C.cWhite + " with Ice to create an " + C.cGreen + "Ice Bridge", + "Lasts for " + C.cGreen + UtilTime.convertString(4000, 0, TimeUnit.SECONDS) + C.cWhite + ".", + "Cooldown " + C.cGreen + UtilTime.convertString(30000, 0, TimeUnit.SECONDS) + C.cWhite + "." + }; + + private static final String ICE_BRIDGE = "Ice Bridge"; + + private static final Perk[][] PERKS = + { + { + new PerkIceBridge(30000, 4000) + }, + { + new PerkIceBridge(29000, 4000) + }, + { + new PerkIceBridge(28000, 5000) + }, + { + new PerkIceBridge(27000, 5000) + }, + { + new PerkIceBridge(26000, 6000) + }, + { + new PerkIceBridge(25000, 6000) + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + reduceCooldown(ICE_BRIDGE, 1) + }, + { + reduceCooldown(ICE_BRIDGE, 1), + increase(ICE_BRIDGE, "Uptime", 20) + }, + { + reduceCooldown(ICE_BRIDGE, 1) + }, + { + reduceCooldown(ICE_BRIDGE, 1), + increase(ICE_BRIDGE, "Uptime", 20) + }, + { + reduceCooldown(ICE_BRIDGE, 1) + }, + }; + + private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemBuilder(Material.ICE).setTitle(C.cGreen + "Ice Bridge").build() }; + + private static final ItemStack IN_HAND = new ItemStack(Material.ICE); + + public KitIce(ArcadeManager manager) + { + super(manager, "Ice", "skywarschickenfarmer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @Override + public boolean showUpgrades() + { + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMadScientist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMadScientist.java deleted file mode 100644 index 7ebca6b01..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMadScientist.java +++ /dev/null @@ -1,45 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkMadScientist; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitMadScientist extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "Spawn crazy animals to fight for you!", - "", - receiveItem("Egg", 1, 90, 3), - "Eggs spawn a loyal minion to fight for you", - }; - - private static final Perk[] PERKS = { - new PerkMadScientist() - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.MONSTER_EGG); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE), - ItemStackFactory.Instance.CreateStack(Material.WOOD_PICKAXE) - }; - - public KitMadScientist(ArcadeManager manager) - { - super(manager, "Mad Scientist", "skywarsmadscientist", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java new file mode 100644 index 000000000..1c6e43125 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java @@ -0,0 +1,102 @@ +package nautilus.game.arcade.game.games.skywars.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkMagnetism; + +public class KitMetal extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Sword" + C.cGray + ", " + C.cGreen + "Stone Pickaxe" + C.cGray + " and " + C.cGreen + "Redstone Comparator", + "", + C.cYellow + "Right Click" + C.cWhite + " with Redstone Comparator to activate " + C.cGreen + "Magnet", + "", + C.cGreen + C.Italics + "Metal" + C.cGray + C.Italics + " means Gold/Chainmail/Iron armor.", + "", + "Any player in your line of sight is drawn to you.", + "The velocity that they are drawn towards you is", + "based on how much metal armor they are wearing", + "Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".", + "", + "For each piece of metal armor you wear you gain", + "a level of " + C.cGreen + "Damage Resistance" + C.cWhite + ".", + }; + + private static final String MAGNET = "Magnet"; + private static final String POWER = "Power"; + + private static final Perk[][] PERKS = + { + { + new PerkMagnetism(15000, 10, 1) + }, + { + new PerkMagnetism(15000, 10, 1.1) + }, + { + new PerkMagnetism(15000, 10, 1.2) + }, + { + new PerkMagnetism(15000, 10, 1.3) + }, + { + new PerkMagnetism(15000, 10, 1.4) + }, + { + new PerkMagnetism(15000, 10, 1.5) + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + increase(MAGNET, POWER, 10) + }, + { + increase(MAGNET, POWER, 10) + }, + { + increase(MAGNET, POWER, 10) + }, + { + increase(MAGNET, POWER, 10) + }, + { + increase(MAGNET, POWER, 10) + }, + }; + + private static final ItemStack[] PLAYER_ITEMS = { new ItemStack(Material.WOOD_SWORD), new ItemStack(Material.STONE_PICKAXE), new ItemBuilder(Material.REDSTONE_COMPARATOR).setTitle(C.cGreen + "Magnet").build() }; + + private static final ItemStack IN_HAND = new ItemStack(Material.REDSTONE_COMPARATOR); + + public KitMetal(ArcadeManager manager) + { + super(manager, "Metal", "skywarsdestructor", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @Override + public boolean showUpgrades() + { + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMiner.java deleted file mode 100644 index 8d1e5946f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMiner.java +++ /dev/null @@ -1,45 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkDigger; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitMiner extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "Start with better tools!", - "", - "Receive " + C.cGreen + "Haste II" + C.cWhite + " the entire game" - }; - - private static final Perk[] PERKS = { - new PerkDigger(), - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.IRON_PICKAXE); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_AXE), - ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE) - }; - - - public KitMiner(ArcadeManager manager) - { - super(manager, "Miner", "skywarsminer", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java index b6e016af5..1cbc14f81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java @@ -13,7 +13,6 @@ import org.bukkit.scoreboard.Objective; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.skywars.SoloSkywars; @@ -39,7 +38,7 @@ public class UHCSkywars extends SoloSkywars { if(event.GetState() == GameState.Prepare) { - Objective objective = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + Objective objective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java index 22af827c9..478341edb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import mineplex.core.common.Pair; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -16,7 +17,6 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.FreeKitWinStatTracker; import nautilus.game.arcade.stats.KillFastStatTracker; @@ -93,24 +93,23 @@ public class SoloSuperSmash extends SuperSmash return; //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); if (GetPlayers(true).size() > 14) { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write(GetPlayers(true).size() + " "); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write(GetPlayers(true).size() + " "); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); } else { - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - //Write New - for (Player player : GetPlayers(true)) + Scoreboard.writeGroup(GetPlayers(true), player -> { int lives = GetLives(player); @@ -121,13 +120,13 @@ public class SoloSuperSmash extends SuperSmash else if (lives == 1) out = C.cRed + player.getName(); else if (lives == 0) out = C.cRed + player.getName(); else - continue; + return null; - Scoreboard.WriteOrdered("Lives", out, lives, true); - } + return Pair.create(out, lives); + }, true); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 3fb05c19c..7d560c10a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -1,19 +1,13 @@ package nautilus.game.arcade.game.games.smash; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -23,14 +17,8 @@ import nautilus.game.arcade.stats.OneVThreeStatTracker; import nautilus.game.arcade.stats.RecoveryMasterStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; public class TeamSuperSmash extends SuperSmash { @@ -95,8 +83,8 @@ public class TeamSuperSmash extends SuperSmash } //Wipe Last - Scoreboard.Reset(); - Scoreboard.WriteBlank(); + Scoreboard.reset(); + Scoreboard.writeNewLine(); if (GetPlayers(true).size() < 16) { @@ -107,7 +95,7 @@ public class TeamSuperSmash extends SuperSmash { int lives = GetLives(player); - Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + player.getName()); + Scoreboard.write(C.cWhite + lives + " " + team.GetColor() + player.getName()); } } } @@ -122,16 +110,16 @@ public class TeamSuperSmash extends SuperSmash lives += GetLives(player); } - Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); + Scoreboard.write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); } } else { - Scoreboard.Write(C.cYellow + C.Bold + "Teams Alive"); - Scoreboard.Write(C.cWhite + alive.size()); + Scoreboard.write(C.cYellow + C.Bold + "Teams Alive"); + Scoreboard.write(C.cWhite + alive.size()); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java index 23efec302..228622660 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java @@ -76,8 +76,8 @@ public class KitPig extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), null, }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java index b59a1bd66..75739762e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java @@ -67,10 +67,10 @@ public class KitWitherSkeleton extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS) + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java index 0c19539cf..362c4b4c4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.sneakyassassins; +import mineplex.core.common.Pair; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -209,47 +210,47 @@ public class SneakyAssassins extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + if (GetState() == GameState.End || GetState() == GameState.Dead) + return; - Scoreboard.WriteBlank(); + Scoreboard.reset(); + + Scoreboard.writeNewLine(); GameTeam team = GetTeamList().get(0); if (team.GetPlayers(false).size() < 13) { - for (Player player : team.GetPlayers(false)) + Scoreboard.writeGroup(team.GetPlayers(false), player -> { if (team.IsAlive(player)) { - Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player), true); + return Pair.create(C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player)); } else { - Scoreboard.WriteOrdered("Powerups", C.cGray + player.getName(), getPowerUpManager().getPowerUpCount(player), true); + return Pair.create(C.cGray + player.getName(), getPowerUpManager().getPowerUpCount(player)); } - } + }, true); } else if (team.GetPlayers(true).size() < 13) { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player), true); - } + Scoreboard.writeGroup(team.GetPlayers(true), player -> Pair.create(C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player)), true); } else { - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write("" + team.GetPlayers(true).size()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); } - GetScoreboard().WriteBlank(); - GetScoreboard().Write(C.cYellow + "Player Reveal"); - GetScoreboard().Write(String.valueOf(Math.max(0, _revealCountdown)) + (_revealCountdown == 1 ? " Second" : " Seconds")); - GetScoreboard().Draw(); + GetScoreboard().writeNewLine(); + GetScoreboard().write(C.cYellow + "Player Reveal"); + GetScoreboard().write(String.valueOf(Math.max(0, _revealCountdown)) + (_revealCountdown == 1 ? " Second" : " Seconds")); + GetScoreboard().draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index 9aaf3396d..c31ddd3b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -1,34 +1,27 @@ package nautilus.game.arcade.game.games.snowfight; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Map.Entry; -import java.util.Set; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.minecraft.game.core.explosion.CustomExplosion; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -40,13 +33,10 @@ import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman; import nautilus.game.arcade.kit.Kit; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; @@ -57,8 +47,6 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -67,8 +55,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; public class SnowFight extends TeamGame @@ -486,9 +472,9 @@ public class SnowFight extends TeamGame if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if(GetPlayers(true).size() <= 8) { for (GameTeam team : this.GetTeamList()) @@ -498,19 +484,19 @@ public class SnowFight extends TeamGame for(Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); } } else { for (GameTeam team : this.GetTeamList()) { - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); - Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); - Scoreboard.WriteBlank(); + Scoreboard.write(team.GetColor() + C.Bold + team.GetName()); + Scoreboard.write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); + Scoreboard.writeNewLine(); } } @@ -520,17 +506,17 @@ public class SnowFight extends TeamGame { if (time > 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Meteors in"); - Scoreboard.Write(UtilTime.MakeStr(time, 0)); + Scoreboard.write(C.cYellow + C.Bold + "Meteors in"); + Scoreboard.write(UtilTime.MakeStr(time, 0)); } else { - Scoreboard.Write(C.cGold + C.Bold + "Meteors!"); + Scoreboard.write(C.cGold + C.Bold + "Meteors!"); } } - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index 0c02a2c71..c03f7f326 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -1807,23 +1807,23 @@ public class SpeedBuilders extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellowB + "Build"); + Scoreboard.write(C.cYellowB + "Build"); if (_currentBuild == null) - Scoreboard.Write("(None)"); + Scoreboard.write("(None)"); else - Scoreboard.Write(C.cWhite + _currentBuild.BuildText); + Scoreboard.write(C.cWhite + _currentBuild.BuildText); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellowB + "Round"); - Scoreboard.Write("" + _roundsPlayed); + Scoreboard.write(C.cYellowB + "Round"); + Scoreboard.write("" + _roundsPlayed); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); List playersAlive = GetTeamList().get(0).GetPlayers(true); @@ -1832,19 +1832,19 @@ public class SpeedBuilders extends SoloGame if (GetTeamList().size() > 1) playersDead.addAll(GetTeamList().get(1).GetPlayers(false)); - Scoreboard.Write(C.cYellowB + "Players"); + Scoreboard.write(C.cYellowB + "Players"); for (Player player : playersAlive) { - Scoreboard.Write(player.getName()); + Scoreboard.write(player.getName()); } for (Player player : playersDead) { - Scoreboard.Write(C.cDGray + player.getName()); + Scoreboard.write(C.cDGray + player.getName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } public Location getJudgeSpawn() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java index a77b8817b..dfb29abb3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -2,10 +2,9 @@ package nautilus.game.arcade.game.games.squidshooter; import java.util.ArrayList; -import org.bukkit.Bukkit; +import mineplex.core.common.Pair; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; @@ -15,7 +14,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.quiver.QuiverScore; import nautilus.game.arcade.game.games.squidshooter.kits.*; @@ -112,13 +110,11 @@ public class SquidShooter extends SoloGame SortScores(); //Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - //Write New - for (QuiverScore score : _ranks) - Scoreboard.WriteOrdered("Kills", C.cGreen + score.Player.getName(), score.Kills, true); + Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cGreen + score.Player.getName(), score.Kills), true); - Scoreboard.Draw(); + Scoreboard.draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java index b97097648..d6e8b49a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java @@ -105,50 +105,50 @@ public class SoloSurvivalGames extends SurvivalGames if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); GameTeam team = GetTeamList().get(0); - Scoreboard.Write(C.cGreen + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cYellow + C.Bold + "Tributes"); + Scoreboard.write(C.cYellow + C.Bold + "Tributes"); if (team.GetPlayers(true).size() > 7) { - Scoreboard.Write("" + team.GetPlayers(true).size()); + Scoreboard.write("" + team.GetPlayers(true).size()); } else { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(C.cWhite + player.getName()); + Scoreboard.write(C.cWhite + player.getName()); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) { - Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); } else if (this.getDeathMatchTime() > 0) { - Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.Write(UtilTime.convertString( + Scoreboard.write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.write(UtilTime.convertString( Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); } else { - Scoreboard.Write(C.cRed + C.Bold + "Game End"); - Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cRed + C.Bold + "Game End"); + Scoreboard.write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index d357ced98..5b6f4d4b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.survivalgames; import java.lang.reflect.Field; import java.util.*; +import org.apache.commons.lang.StringUtils; import org.bukkit.*; import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; @@ -13,6 +14,7 @@ import org.bukkit.block.DoubleChest; import org.bukkit.block.Furnace; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLargeFireball; +import org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard; import org.bukkit.entity.Boat; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; @@ -34,6 +36,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.hanging.HangingBreakEvent; @@ -91,11 +94,6 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.survivalgames.kit.*; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; -import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; -import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; -import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; import net.minecraft.server.v1_8_R3.EntityLargeFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardTeam; import net.minecraft.server.v1_8_R3.ScoreboardTeam; @@ -141,11 +139,9 @@ public abstract class SurvivalGames extends Game private boolean _informedDeathmatchCommand; private int _gameEndTime = 3 * 60; - private Field _packetTeam; - private int _chestRefillTime = 60 * 7; - public SurvivalGames(ArcadeManager manager, GameType type, String[] description) + public SurvivalGames(ArcadeManager manager, GameType type, String[] description) { this(manager, new Kit[] { @@ -172,20 +168,20 @@ public abstract class SurvivalGames extends Game new KitHorseman(manager), }, type, description); } - + public SurvivalGames(ArcadeManager manager, Kit[] kits, GameType type, - String[] description) + String[] description) { super(manager, type, kits, description); _help = new String[] - { - C.cGreen + "Use a Compass to find and kill enemies!", + { + C.cGreen + "Use a Compass to find and kill enemies!", - C.cGreen + "You lose Speed 2 at start of game if you attack.", + C.cGreen + "You lose Speed 2 at start of game if you attack.", - C.cAqua + "Avoid enemies who have better gear than you!" - }; + C.cAqua + "Avoid enemies who have better gear than you!" + }; // Manager.GetAntiStack().SetEnabled(false); @@ -248,19 +244,6 @@ public abstract class SurvivalGames extends Game // "chestsOpened"); setupLoot(); - - try - { - - _packetTeam = Class.forName( - "org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftTeam") - .getDeclaredField("team"); - _packetTeam.setAccessible(true); - } - catch (Exception ex) - { - ex.printStackTrace(); - } } @EventHandler @@ -345,52 +328,52 @@ public abstract class SurvivalGames extends Game switch (_chestRefillTime) { - case 0: + case 0: - Announce(C.cGold + C.Bold + "The chests have been refilled!", false); + Announce(C.cGold + C.Bold + "The chests have been refilled!", false); - for (Player player : Bukkit.getOnlinePlayers()) - { - player.playSound(player.getEyeLocation(), - Sound.IRONGOLEM_DEATH, 1000, 0); - } + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getEyeLocation(), + Sound.IRONGOLEM_DEATH, 1000, 0); + } - refillChests(); + refillChests(); - _chestRefillTime--; - break; - case 300: - case 180: - case 120: - case 60: - case 30: - case 15: - case 10: - case 5: - case 4: - case 3: - case 2: - case 1: + _chestRefillTime--; + break; + case 300: + case 180: + case 120: + case 60: + case 30: + case 15: + case 10: + case 5: + case 4: + case 3: + case 2: + case 1: - String time; + String time; - if (_chestRefillTime >= 60) - { - time = (_chestRefillTime / 60) + " minute" - + (_chestRefillTime > 60 ? "s" : ""); - } - else - { - time = _chestRefillTime + " second" - + (_chestRefillTime != 1 ? "s" : ""); - } + if (_chestRefillTime >= 60) + { + time = (_chestRefillTime / 60) + " minute" + + (_chestRefillTime > 60 ? "s" : ""); + } + else + { + time = _chestRefillTime + " second" + + (_chestRefillTime != 1 ? "s" : ""); + } - Announce(C.cGold + C.Bold + "The chests will be refilled in " - + time, false); + Announce(C.cGold + C.Bold + "The chests will be refilled in " + + time, false); - break; - default: - break; + break; + default: + break; } } @@ -413,7 +396,7 @@ public abstract class SurvivalGames extends Game { Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX - + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), + + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), ignore); if (!UtilBlock.airFoliage(block) @@ -587,7 +570,7 @@ public abstract class SurvivalGames extends Game || _deathMatchTime == 15 || _deathMatchTime == 10 || (_deathMatchTeleported ? _deathMatchTime <= 10 - : _deathMatchTime <= 5)) + : _deathMatchTime <= 5)) { if (_deathMatchTeleported && _deathMatchTime <= 10) { @@ -644,7 +627,7 @@ public abstract class SurvivalGames extends Game } _borderStartedMoving = System.currentTimeMillis(); - + WorldBorder border = WorldData.World.getWorldBorder(); border.setSize(_currentBorder * 2, 1); @@ -764,7 +747,7 @@ public abstract class SurvivalGames extends Game { item = buildCompass(5); } - + handlePickup(item); chest.getBlockInventory().setItem(UtilMath.r(27), item); @@ -802,46 +785,46 @@ public abstract class SurvivalGames extends Game { if (event.getEntity().getItemStack().hasItemMeta()) return; - + Material mat = event.getEntity().getItemStack().getType(); switch (mat) { - case SEEDS: - case SAPLING: - case VINE: - case LEAVES: - case LONG_GRASS: - case RED_ROSE: - case YELLOW_FLOWER: - case DEAD_BUSH: - case WATER_LILY: - event.setCancelled(true); - return; - case CARROT_ITEM: - if (UtilMath.r(10) != 0) - { + case SEEDS: + case SAPLING: + case VINE: + case LEAVES: + case LONG_GRASS: + case RED_ROSE: + case YELLOW_FLOWER: + case DEAD_BUSH: + case WATER_LILY: event.setCancelled(true); - } - return; - case POTATO_ITEM: - if (UtilMath.r(10) != 0) - { + return; + case CARROT_ITEM: + if (UtilMath.r(10) != 0) + { + event.setCancelled(true); + } + return; + case POTATO_ITEM: + if (UtilMath.r(10) != 0) + { + event.setCancelled(true); + } + return; + case WHEAT: + if (UtilMath.r(6) != 0) + { + event.setCancelled(true); + } + return; + case WOOD: event.setCancelled(true); - } - return; - case WHEAT: - if (UtilMath.r(6) != 0) - { - event.setCancelled(true); - } - return; - case WOOD: - event.setCancelled(true); - return; + return; - default: - break; + default: + break; } for (Player player : GetPlayers(true)) @@ -1008,27 +991,27 @@ public abstract class SurvivalGames extends Game { handlePickup(event.getItem().getItemStack()); } - - private void handlePickup(ItemStack stack) + + public void handlePickup(ItemStack stack) { if (stack.getType() == Material.CARROT - || stack.getType() == Material.POTATO - || stack.getType() == Material.WHEAT - || stack.getType() == Material.CARROT_ITEM - || stack.getType() == Material.POTATO_ITEM) + || stack.getType() == Material.POTATO + || stack.getType() == Material.WHEAT + || stack.getType() == Material.CARROT_ITEM + || stack.getType() == Material.POTATO_ITEM) { String name = "Carrot"; if (stack.getType() == Material.POTATO || stack.getType() == Material.POTATO_ITEM) name = "Potato"; if (stack.getType() == Material.WHEAT) name = "Wheat"; - + ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(name); stack.setItemMeta(meta); } } - + @EventHandler public void OpenChest(PlayerInteractEvent event) { @@ -1262,7 +1245,7 @@ public abstract class SurvivalGames extends Game if (!(event.getEntity() instanceof Fireball)) return; - + Collection blocks = UtilBlock.getInRadius( event.getEntity().getLocation(), 2.4).keySet(); @@ -1284,6 +1267,15 @@ public abstract class SurvivalGames extends Game return sides >= 3; } + + @EventHandler + public void borderSpecInteraction(EntityDamageByEntityEvent event) + { + if (event.getEntity() instanceof Fireball && UtilPlayer.isSpectator(event.getDamager())) + { + event.setCancelled(true); + } + } @EventHandler public void borderDamage(CustomDamageEvent event) @@ -1300,7 +1292,7 @@ public abstract class SurvivalGames extends Game } private ArrayList buildBorders(int seconds, double border, - double leaveRemaining) + double leaveRemaining) { double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50); @@ -1676,7 +1668,7 @@ public abstract class SurvivalGames extends Game if (event.GetState() != GameState.Live) return; - Scoreboard board = GetScoreboard().GetScoreboard(); + Scoreboard board = GetScoreboard().getScoreboard(); for (Player player : GetPlayers(true)) { @@ -1693,12 +1685,6 @@ public abstract class SurvivalGames extends Game player.setHealth(player.getMaxHealth()); - Team team = board.registerNewTeam(player.getName()); - - team.setPrefix(board.getPlayerTeam(player).getPrefix()); - - team.addPlayer(player); - _hiddenNames.put(player, new HashSet()); } } @@ -1811,7 +1797,7 @@ public abstract class SurvivalGames extends Game } UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation() - .add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG, + .add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); } } @@ -1870,8 +1856,8 @@ public abstract class SurvivalGames extends Game if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) return; - - if(!IsAlive(player)) + + if (!IsAlive(player)) return; event.setCancelled(true); @@ -1940,7 +1926,7 @@ public abstract class SurvivalGames extends Game } } } - + @EventHandler public void craftedItems(CraftItemEvent event) { @@ -1961,24 +1947,41 @@ public abstract class SurvivalGames extends Game ArrayList alivePlayers = new ArrayList( _hiddenNames.keySet()); - HashMap> checkedPlayers = new HashMap>(); + HashMap> checkedPlayers = new HashMap<>(); for (Player target : alivePlayers) { + Team originalTeam = GetScoreboard().getScoreboard().getTeam(getArcadeManager().GetLobby().getTeamId(GetTeam(target), target)); - PacketPlayOutScoreboardTeam packet = null; - - try + // If it's null this tick, it'll be set next tick. We can wait a tick + if (originalTeam == null) { - ScoreboardTeam nmsTeam = (ScoreboardTeam) _packetTeam - .get(target.getScoreboard().getTeam(target.getName())); + System.out.println("Skipping " + target.getName() + " because of a null originalTeam"); + continue; + } - packet = new PacketPlayOutScoreboardTeam(nmsTeam, 2); - } - catch (Exception ex) + Team requestedTeam = GetScoreboard().getScoreboard().getTeam(target.getName()); + + if (requestedTeam == null) { - ex.printStackTrace(); + requestedTeam = GetScoreboard().getScoreboard().registerNewTeam(target.getName()); + requestedTeam.addEntry(target.getName()); + requestedTeam.setPrefix(originalTeam.getPrefix()); + requestedTeam.setSuffix(originalTeam.getSuffix()); } + else + { + if (!StringUtils.equals(requestedTeam.getPrefix(), originalTeam.getPrefix())) + { + requestedTeam.setPrefix(originalTeam.getPrefix()); + } + if (!StringUtils.equals(requestedTeam.getSuffix(), originalTeam.getSuffix())) + { + requestedTeam.setSuffix(originalTeam.getSuffix()); + } + } + + PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(((CraftScoreboard) GetScoreboard().getScoreboard()).getHandle().getTeam(requestedTeam.getName()), 2); for (Player player : alivePlayers) { @@ -1986,11 +1989,9 @@ public abstract class SurvivalGames extends Game { boolean hideName = false; - if (!checkedPlayers.containsKey(target) - || !checkedPlayers.get(target).containsKey(player)) + if (!checkedPlayers.containsKey(target) || !checkedPlayers.get(target).containsKey(player)) { - if (player.getLocation().distance(target.getLocation()) > (GetKit(target) instanceof KitAssassin ? 8 - : 24)) + if (player.getLocation().distance(target.getLocation()) > (GetKit(target) instanceof KitAssassin ? 8 : 24)) { hideName = true; } @@ -2001,9 +2002,9 @@ public abstract class SurvivalGames extends Game } Player[] players = new Player[] - { - target, player - }; + { + target, player + }; if (!(GetKit(player) instanceof KitAssassin || GetKit(target) instanceof KitAssassin)) { @@ -2048,11 +2049,11 @@ public abstract class SurvivalGames extends Game } } } - + @EventHandler public void onInventoryOpen(InventoryOpenEvent event) { - if(event.getInventory() instanceof BeaconInventory) + if (event.getInventory() instanceof BeaconInventory) { event.setCancelled(true); } @@ -2082,50 +2083,50 @@ public abstract class SurvivalGames extends Game { return _gameEndTime; } - + public ArrayList getSupplyBlocks() { return _supplyCrates; } - + public HashSet getLootedBlocks() { return _lootedBlocks; } - + public ChestLoot getBaseLoot() { return _baseLoot; } - + public ChestLoot getCrateLoot() { return _crateLoot; } - + public ChestLoot getSpawnLoot() { return _spawnLoot; } - + public ChestLoot getDeathMatch() { return _deathMatchLoot; } - + public ChestLoot getRawFurnace() { return _rawFurnace; } - + public ChestLoot getFurnace() { return _cookedFurnace; } - + public Location getSpawn() { return _spawn; } - + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index 99d49393b..f6c6b1820 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -1,21 +1,15 @@ package nautilus.game.arcade.game.games.survivalgames; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -24,14 +18,8 @@ import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; public class TeamSurvivalGames extends SurvivalGames { @@ -89,15 +77,15 @@ public class TeamSurvivalGames extends SurvivalGames if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); - Scoreboard.Write(C.cGreen + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGreen + C.Bold + "Time"); + Scoreboard.write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Teams"); ArrayList alive = new ArrayList(); for (GameTeam team : GetTeamList()) @@ -112,7 +100,7 @@ public class TeamSurvivalGames extends SurvivalGames { for (Player player : team.GetPlayers(true)) { - Scoreboard.Write(team.GetColor() + player.getName()); + Scoreboard.write(team.GetColor() + player.getName()); } } } @@ -120,34 +108,34 @@ public class TeamSurvivalGames extends SurvivalGames { for (GameTeam team : alive) { - Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } } else { - Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + Scoreboard.write(C.cWhite + alive.size() + " Alive"); } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); if (getChestRefillTime() > 0 && getDeathMatchTime() > 60) { - Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.Write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT)); } else if (getDeathMatchTime() > 0) { - Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.Write(UtilTime.convertString( + Scoreboard.write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.write(UtilTime.convertString( Math.min(getDeathMatchTime(), isDeathMatchTeleported() ? 10 : getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); } else { - Scoreboard.Write(C.cRed + C.Bold + "Game End"); - Scoreboard.Write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + Scoreboard.write(C.cRed + C.Bold + "Game End"); + Scoreboard.write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT)); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java index e7d1a30f2..fa44f00ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java @@ -1,21 +1,38 @@ package nautilus.game.arcade.game.games.survivalgames.modes; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.RandomItem; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; +import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; +import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; +import nautilus.game.arcade.game.games.survivalgames.modes.kit.KitSurvivalist; +import nautilus.game.arcade.kit.Kit; /** * UHCSurvivalgames gamemode for Survivalgames @@ -25,14 +42,73 @@ import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; public class UHCSurvivalgames extends SoloSurvivalGames { + private long _peacePhase; + private boolean _peace; + public UHCSurvivalgames(ArcadeManager manager) { - super(manager, GameType.Brawl); + super(manager, new Kit[] + { + new KitSurvivalist(manager) + }, + GameType.Brawl); + _peacePhase = 45000; // 45 Seconds SoupEnabled = false; + DamagePvP = false; + + BlockBreak = true; + BlockPlace = true; + + BlockBreakDeny.add(Material.DIAMOND_BLOCK.getId()); + BlockBreakDeny.add(Material.IRON_BLOCK.getId()); + BlockBreakDeny.add(Material.GOLD_BLOCK.getId()); + BlockBreakDeny.add(Material.REDSTONE_ORE.getId()); + BlockBreakDeny.add(Material.REDSTONE_WIRE.getId()); + BlockBreakDeny.add(Material.REDSTONE.getId()); + BlockBreakDeny.add(Material.TNT.getId()); + BlockBreakDeny.add(Material.CHEST.getId()); + + BlockPlaceDeny.add(Material.REDSTONE.getId()); + BlockPlaceDeny.add(Material.REDSTONE_ORE.getId()); + BlockPlaceDeny.add(Material.REDSTONE_WIRE.getId()); + BlockPlaceDeny.add(Material.CHEST.getId()); + new AbsorptionFix(this); } + + @EventHandler + public void enableDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + if (!IsLive()) + return; + + if (!UtilTime.elapsed(GetStateTime(), _peacePhase)) + return; + + if (!_peace) + return; + + _peace = false; + + Announce(F.main("Game", "The Peace Phase has ended! You can now fight each other!")); + DamagePvP = true; + } + + @EventHandler + public void informPeace(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + _peace = true; + + Announce(F.main("Game", "A Peace Phase of " + F.time((_peacePhase/1000) + "") + " seconds has started!")); + } @EventHandler public void registerObj(GameStateChangeEvent event) @@ -42,7 +118,7 @@ public class UHCSurvivalgames extends SoloSurvivalGames else if (event.GetState() != GameState.Live) getCrateLoot().addLoot(new RandomItem(new ItemStack(Material.GOLDEN_APPLE), 100)); - Objective objective = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + Objective objective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); } @@ -58,14 +134,243 @@ public class UHCSurvivalgames extends SoloSurvivalGames { if (event.getEntity() instanceof Player) { - event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE)); + event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE, 2)); } } + + @EventHandler(priority=EventPriority.LOWEST) + public void spawnBreak(BlockBreakEvent event) + { + if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40) + event.setCancelled(true); + } + + @EventHandler(priority=EventPriority.LOWEST) + public void spawnPlace(BlockPlaceEvent event) + { + if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40) + event.setCancelled(true); + } + public void setupLoot() + { + // Build material + getBaseLoot().addLoot(new RandomItem(Material.WOOD, 40, 7, 15)); + + // Food + getBaseLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 40, 1, 3)); + getBaseLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 40, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 40, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 10, 1, 1)); + getBaseLoot().addLoot(new RandomItem(Material.PORK, 35, 1, 4)); + + // Weapons + getBaseLoot().addLoot(new RandomItem(Material.IRON_AXE, 80)); + getBaseLoot().addLoot(new RandomItem(Material.IRON_SWORD, 70)); + getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 60)); + getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 30)); + + // Gold armor + getBaseLoot().addLoot(new RandomItem(Material.GOLD_BOOTS, 25)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_HELMET, 25)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); + + // Chain armor + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); + getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); + + // Throwable + getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30)); + getBaseLoot().addLoot(new RandomItem(Material.BOW, 20)); + getBaseLoot().addLoot(new RandomItem(Material.ARROW, 40, 2, 4)); + + // Misc + getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 40, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20)); + getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2)); + getBaseLoot().addLoot(new RandomItem(Material.BOAT, 15)); + getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20)); + getBaseLoot().addLoot(new RandomItem(Material.GOLDEN_APPLE, 2)); + getBaseLoot().addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack( + Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15)); + getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); + + getSpawnLoot().cloneLoot(getBaseLoot()); + + // Food + getSpawnLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); + getSpawnLoot().addLoot(new RandomItem(Material.CAKE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); + getSpawnLoot().addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.COOKIE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); + getSpawnLoot().addLoot(new RandomItem(Material.APPLE, 30, 2, 6)); + + // Loot for chests in spawn + // Weaponry and ores + getSpawnLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_AXE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_INGOT, 40, 1, 2)); + getSpawnLoot().addLoot(new RandomItem(Material.DIAMOND, 30)); + + // Iron gear + getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); + getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); + + // Supply crate loot + // Diamond gear + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); + + // Iron gear + getCrateLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); + getCrateLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); + getCrateLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); + getCrateLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); + + // Weapons + getCrateLoot().addLoot(new RandomItem(Material.IRON_SWORD, 24)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); + getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 16)); + + // Cooked furnace + getFurnace().addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); + getFurnace().addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); + getFurnace().addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); + getFurnace().addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); + + // Raw furnace + getRawFurnace().addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.PORK, 1, 1, 3)); + getRawFurnace().addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); + + // Deathmatch Loot + getDeathMatch().addLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); + getDeathMatch().addLoot(new RandomItem(Material.BAKED_POTATO, 4)); + getDeathMatch().addLoot(new RandomItem(Material.CAKE, 4)); + getDeathMatch().addLoot(new RandomItem(Material.APPLE, 4)); + getDeathMatch().addLoot(new RandomItem(Material.WOOD_SWORD, 3)); + getDeathMatch().addLoot(new RandomItem(Material.WOOD_AXE, 3)); + getDeathMatch().addLoot(new RandomItem(Material.STONE_AXE, 3)); + getDeathMatch().addLoot(new RandomItem(Material.STONE_SWORD, 1)); + } + + public void fillChest(Player looter, Block block) + { + getLootedBlocks().add(block.getLocation()); + + Chest chest = (Chest) block.getState(); + + chest.getBlockInventory().clear(); + + int items = 2; + if (Math.random() > 0.50) + items++; + if (Math.random() > 0.65) + items++; + if (Math.random() > 0.80) + items++; + if (Math.random() > 0.95) + items++; + + boolean spawnChest = getChestRefillTime() > 0 + && UtilMath.offset(chest.getLocation(), getSpawn()) < 8; + + if (spawnChest) + items += 3; + + if (GetKit(looter) instanceof KitLooter) + { + items += UtilMath.r(3); + } + + if (getSupplyBlocks().contains(block)) + { + items = 2; + if (Math.random() > 0.75) + items++; + if (Math.random() > 0.95) + items++; + } + + for (int i = 0; i < items; i++) + { + ItemStack item; + + if (spawnChest) + { + item = getSpawnLoot().getLoot(); + } + else if (isDeathMatchTeleported()) + { + item = getDeathMatch().getLoot(); + } + else + { + boolean drop = getSupplyBlocks().contains(block); + item = GetChestItem(drop); + + // Golden apple spawn + if (drop && i == items) + item = new ItemStack(Material.GOLDEN_APPLE); + } + + if (item.getType() == Material.COMPASS) + { + item = buildCompass(5); + } + + handlePickup(item); + + chest.getBlockInventory().setItem(UtilMath.r(27), item); + } + + if (getSupplyBlocks().contains(block)) + { + Bukkit.getPluginManager().callEvent( + new SupplyChestOpenEvent(looter, block)); + } + + getSupplyBlocks().remove(block); + } + + @Override + @EventHandler + public void preventCrafting(PrepareItemCraftEvent event) + { + ItemStack result = event.getInventory().getResult(); + + if (result != null) + { + Material type = result.getType(); + + if (type == Material.BUCKET + || type == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + } + } + } + @Override public String GetMode() { - return "UHC Survivalagmes"; + return "UHC Survivalgames"; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java new file mode 100644 index 000000000..d2165eeea --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.survivalgames.modes.kit; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +/** + * KitSurvivalist + * + * @author xXVevzZXx + */ +public class KitSurvivalist extends Kit +{ + public KitSurvivalist(ArcadeManager manager) + { + super(manager, "Survivalist", KitAvailability.Free, + new String[] + { + "You are a survival expert!", + }, + new Perk[] + { + + }, + EntityType.PLAYER, + new ItemStack(Material.AIR)); + + } + + @Override + public void GiveItems(Player player) + { + + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java index 30a7e7a17..a232d4115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java @@ -15,7 +15,6 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Creature; import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -30,13 +29,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.tug.kits.*; import nautilus.game.arcade.kit.Kit; @@ -327,17 +323,17 @@ public class Tug extends TeamGame public void ScoreboardWrite() { - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Pig Team"); - Scoreboard.Write(_redLives.size() + " Wheat"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cRed + "Pig Team"); + Scoreboard.write(_redLives.size() + " Wheat"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cAqua + "Sheep Team"); - Scoreboard.Write(_blueLives.size() + " Carrots"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cAqua + "Sheep Team"); + Scoreboard.write(_blueLives.size() + " Carrots"); - Scoreboard.Draw(); + Scoreboard.draw(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 3f11f4fad..15ffadb9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -44,9 +44,6 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.elo.EloPlayer; -import mineplex.core.elo.EloTeam; -import mineplex.core.elo.GameResult; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -618,7 +615,7 @@ public class TurfForts extends TeamGame if (event.getType() != UpdateType.FAST) return; - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { @@ -626,17 +623,17 @@ public class TurfForts extends TeamGame if (team.GetColor() == ChatColor.RED) lines = GetRedLines(); else lines = GetBlueLines(); - Scoreboard.WriteBlank(); - Scoreboard.Write(lines + " " + team.GetColor() + team.GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(lines + " " + team.GetColor() + team.GetName()); } if (!_fight) { long time = _buildTime - (System.currentTimeMillis() - _phaseTime); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, time), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, time), 0)); } @@ -644,12 +641,12 @@ public class TurfForts extends TeamGame { long time = _fightTime - (System.currentTimeMillis() - _phaseTime); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Combat Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, time), 0)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Combat Time"); + Scoreboard.write(UtilTime.MakeStr(Math.max(0, time), 0)); } - Scoreboard.Draw(); + Scoreboard.draw(); } public int GetRedLines() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index fd5ad26b4..2a71c63a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -1,31 +1,5 @@ package nautilus.game.arcade.game.games.typewars; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.util.Vector; - import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -67,8 +41,32 @@ import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.TimeInGameStatTracker; import nautilus.game.arcade.world.WorldData; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; public class TypeWars extends TeamGame { @@ -175,7 +173,6 @@ public class TypeWars extends TeamGame ); manager.GetCreature().SetDisableCustomDrops(true); - manager.GetChat().setThreeSecondDelay(false); } @EventHandler @@ -972,28 +969,27 @@ public class TypeWars extends TeamGame } } - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for(GameTeam team : GetTeamList()) { - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); - Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + Scoreboard.write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); if(wpm.length() > 4) wpm = wpm.substring(0, 4); - Scoreboard.Write(team.GetColor() + "WPM: " + wpm); - Scoreboard.WriteBlank(); + Scoreboard.write(team.GetColor() + "WPM: " + wpm); + Scoreboard.writeNewLine(); } - Scoreboard.Draw(); + Scoreboard.draw(); //End Manager.GetCreature().SetDisableCustomDrops(false); - Manager.GetChat().setThreeSecondDelay(true); SetState(GameState.End); } @@ -1173,24 +1169,24 @@ public class TypeWars extends TeamGame if(!IsLive()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); for(GameTeam team : GetTeamList()) { - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); - Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); - Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + Scoreboard.write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); if(wpm.length() > 4) wpm = wpm.substring(0, 4); - Scoreboard.Write(team.GetColor() + "WPM: " + wpm); - Scoreboard.WriteBlank(); + Scoreboard.write(team.GetColor() + "WPM: " + wpm); + Scoreboard.writeNewLine(); } - Scoreboard.Draw(); + Scoreboard.draw(); } public ArrayList getMinions(GameTeam team) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 6ae58980a..18d67e8ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -5,8 +5,10 @@ import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.access.IViolationInfo; import fr.neatmonster.nocheatplus.hooks.NCPHook; import fr.neatmonster.nocheatplus.hooks.NCPHookManager; +import mineplex.core.Managers; import mineplex.core.account.CoreClient; import mineplex.core.boosters.event.BoosterItemGiveEvent; +import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -23,6 +25,7 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.monitor.LagMeter; import mineplex.core.recharge.Recharge; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; @@ -39,6 +42,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.uhc.helpers.ChunkLoadingThread; import nautilus.game.arcade.game.games.uhc.helpers.WorldGenThread; +import nautilus.game.arcade.game.modules.AntiExpOrbModule; import nautilus.game.arcade.game.modules.OreVeinEditorModule; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.game.modules.combatlog.CombatLogModule; @@ -59,10 +63,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Ghast; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; @@ -80,7 +84,6 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; @@ -92,6 +95,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.event.world.ChunkLoadEvent; +import org.bukkit.event.world.ChunkPopulateEvent; import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.inventory.CraftingInventory; @@ -102,7 +107,6 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; @@ -130,12 +134,24 @@ public class UHC extends TeamGame implements NCPHook // The number of chunks to unload per tick public static final int CHUNKS_UNLOAD_PER_TICK = 1; + // The number of ticks to delay chunk unloading by + public static final long CHUNKS_UNLOAD_DELAY = 5 * 20L; + + // The number of ticks to wait between each chunk unload period + public static final long CHUNKS_UNLOAD_PERIOD = 2 * 20L; + // This is the region in which nothing can be done (block placing, flowing, etc) public static final int SAFE_REGION = 36; // The amount of damage to give from hitting the world border public static final int WORLD_BORDER_DAMAGE = 5; + // The number of ticks to delay before teleporting each player + public static final long DELAY_BETWEEN_PLAYER_TELEPORT = 5L; + + // The centers of the spawn for each team + private Map _teamCenter = new HashMap<>(); + // The thread responsible for generating the world private final WorldGenThread _worldGenThread = new WorldGenThread(this); @@ -146,7 +162,7 @@ public class UHC extends TeamGame implements NCPHook private final Set _loadedChunks = new HashSet<>(); // The task which will unload chunks periodically - private BukkitRunnable _chunkUnloadTask; + private int _chunkUnloadTaskId = -1; // The number of minutes passed in this game private int _minutesSinceStart = 0; @@ -184,6 +200,7 @@ public class UHC extends TeamGame implements NCPHook new OreVeinEditorModule() .removeNonAirVeins() ); + registerModule(new AntiExpOrbModule()); } public UHC(ArcadeManager manager, GameType type) @@ -230,8 +247,6 @@ public class UHC extends TeamGame implements NCPHook this.AnnounceStay = false; - this.DisplayLobbySide = true; - this.DeathMessages = false; this.SoupEnabled = false; @@ -270,7 +285,7 @@ public class UHC extends TeamGame implements NCPHook // Damage Settings Manager.GetDamage().SetEnabled(false); - _healthObjective = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + _healthObjective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); _healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST); NCPHookManager.addHook(CheckType.ALL, this); @@ -278,6 +293,24 @@ public class UHC extends TeamGame implements NCPHook registerModule(new TeamModule()); } + @EventHandler + public void onLoad(ChunkLoadEvent event) + { + if (event.getChunk().getWorld().equals(WorldData.World) && _isTeleporting) + { + new Exception(event.getChunk().getX() + " " + event.getChunk().getZ()).printStackTrace(); + } + } + + @EventHandler + public void onPopulate(ChunkPopulateEvent event) + { + if (event.getChunk().getWorld().equals(WorldData.World) && _isTeleporting) + { + new Exception(event.getChunk().getX() + " " + event.getChunk().getZ()).printStackTrace(); + } + } + @Override public void ParseData() { @@ -448,7 +481,7 @@ public class UHC extends TeamGame implements NCPHook { while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size()) { - Location loc = GetRandomSpawn(null); + Location loc = GetRandomSpawn(null, false); // Dynamically scale distance requirement based on how many teams need to fit double dist = (2 * _currentBorder) / (Math.sqrt(this.GetPlayers(true).size()) + 3); @@ -470,7 +503,7 @@ public class UHC extends TeamGame implements NCPHook if (!clash) break; - loc = GetRandomSpawn(null); + loc = GetRandomSpawn(null, false); } GetTeamList().get(0).GetSpawns().add(loc); @@ -481,7 +514,7 @@ public class UHC extends TeamGame implements NCPHook { for (GameTeam team : GetTeamList()) { - Location loc = GetRandomSpawn(null); + Location loc = GetRandomSpawn(null, false); // Dynamically scale distance requirement based on how many teams need to fit double dist = (2 * _currentBorder) / (Math.sqrt(GetTeamList().size()) + 3); @@ -506,23 +539,17 @@ public class UHC extends TeamGame implements NCPHook if (!clash) break; - loc = GetRandomSpawn(null); + loc = GetRandomSpawn(null, false); } + _teamCenter.put(team, loc); team.GetSpawns().add(loc); - - while (team.GetSpawns().size() < 20) - { - Location other = GetRandomSpawn(loc); - - team.GetSpawns().add(other); - } } } TimingManager.stop("UHC Spawn Generation"); - Location spawn = GetRandomSpawn(WorldData.World.getSpawnLocation()); + Location spawn = GetRandomSpawn(WorldData.World.getSpawnLocation(), true); WorldData.World.setSpawnLocation(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()); WorldServer worldServer = ((CraftWorld) WorldData.World).getHandle(); @@ -577,69 +604,67 @@ public class UHC extends TeamGame implements NCPHook this.DamagePvP = true; this.CompassGiveItem = true; this.RejoinTime = 300000; // 5 minutes - registerModule( - new CombatLogModule() - .setSpawnForCreative(false) - .setCombatLogTime(300000) - .setOnDeathAction(npc -> + registerModule(new CombatLogModule()) + .setSpawnForCreative(false) + .setCombatLogTime(300000) + .setOnDeathAction(npc -> + { + if (npc.getLastDamager() instanceof Player) + { + Player killer = (Player) npc.getLastDamager(); + Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() + + C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer) + + C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out."); + } + else + { + String cause = UtilParser.parseDamageCause(npc.getLastDamageCause()); + if (npc.getLastDamager() != null) { - if (npc.getLastDamager() instanceof Player) - { - Player killer = (Player) npc.getLastDamager(); - Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() - + C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer) - + C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out."); - } - else - { - String cause = UtilParser.parseDamageCause(npc.getLastDamageCause()); - if (npc.getLastDamager() != null) - { - cause = npc.getLastDamager().getName(); - } - Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() - + C.cGray + C.Bold + " was killed by " + cause + " while logged out."); - } + cause = npc.getLastDamager().getName(); + } + Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() + + C.cGray + C.Bold + " was killed by " + cause + " while logged out."); + } - ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) - .setData((byte) 3) - .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") - .build(); + ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) + .setData((byte) 3) + .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") + .build(); - SkullMeta meta = (SkullMeta) stack.getItemMeta(); - meta.setOwner(npc.getPlayerInfo().getName()); - stack.setItemMeta(meta); + SkullMeta meta = (SkullMeta) stack.getItemMeta(); + meta.setOwner(npc.getPlayerInfo().getName()); + stack.setItemMeta(meta); - npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); + npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); - Location location = npc.getNPC().getLocation(); + Location location = npc.getNPC().getLocation(); - for (ItemStack item : npc.getPlayerInfo().getItems()) - { - location.getWorld().dropItemNaturally(location, item); - } - }) - .setOnExpireAction(npc -> - { - ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) - .setData((byte) 3) - .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") - .build(); + for (ItemStack item : npc.getPlayerInfo().getItems()) + { + location.getWorld().dropItemNaturally(location, item); + } + }) + .setOnExpireAction(npc -> + { + ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) + .setData((byte) 3) + .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") + .build(); - SkullMeta meta = (SkullMeta) stack.getItemMeta(); - meta.setOwner(npc.getPlayerInfo().getName()); - stack.setItemMeta(meta); + SkullMeta meta = (SkullMeta) stack.getItemMeta(); + meta.setOwner(npc.getPlayerInfo().getName()); + stack.setItemMeta(meta); - npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); + npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); - Location location = npc.getNPC().getLocation(); + Location location = npc.getNPC().getLocation(); - for (ItemStack item : npc.getPlayerInfo().getItems()) - { - location.getWorld().dropItemNaturally(location, item); - } - }) - ); + for (ItemStack item : npc.getPlayerInfo().getItems()) + { + location.getWorld().dropItemNaturally(location, item); + } + }); } } @@ -704,35 +729,26 @@ public class UHC extends TeamGame implements NCPHook HandlerList.unregisterAll(_chunkLoadingThread); NCPHookManager.removeHook(this); - if (_chunkUnloadTask != null) - { - try - { - _chunkUnloadTask.cancel(); - } - catch (IllegalStateException ex) - { - // bukkit - } - } - - Iterator iterator = _loadedChunks.iterator(); - while (iterator.hasNext()) - { - Chunk chunk = iterator.next(); - WorldData.World.unloadChunk(chunk.getX(), chunk.getZ()); - iterator.remove(); - } +// if (_chunkUnloadTaskId != -1) +// { +// Bukkit.getScheduler().cancelTask(_chunkUnloadTaskId); +// } +// +// Iterator iterator = _loadedChunks.iterator(); +// while (iterator.hasNext()) +// { +// Chunk chunk = iterator.next(); +// WorldData.World.unloadChunk(chunk.getX(), chunk.getZ()); +// iterator.remove(); +// } return; } - if (event.GetState() != GameState.Recruit) + if (event.GetState() == GameState.Recruit) { - return; + _worldGenThread.start(); } - - _worldGenThread.start(); } @EventHandler(priority = EventPriority.MONITOR) @@ -741,7 +757,7 @@ public class UHC extends TeamGame implements NCPHook if (!IsLive()) { event.setCancelled(true); - _loadedChunks.add(event.getChunk()); +// _loadedChunks.add(event.getChunk()); } } @@ -750,7 +766,7 @@ public class UHC extends TeamGame implements NCPHook { if (_isTeleporting) { - System.out.println("WARNING: TRIED TO LOAD CHUNK WHILE TELEPORTING: " + event.getX() + " " + event.getZ()); + new Exception("WARNING: TRIED TO LOAD CHUNK WHILE TELEPORTING: " + event.getX() + " " + event.getZ()).printStackTrace(); } } @@ -764,6 +780,15 @@ public class UHC extends TeamGame implements NCPHook } } + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerQuitEvent event) + { + if (_isTeleporting) + { + GetLocationStore().put(event.getPlayer().getName(), GetTeam(event.getPlayer()).GetSpawn()); + } + } + @EventHandler(priority = EventPriority.LOW) public void PlayerPrepare(GameStateChangeEvent event) { @@ -772,6 +797,13 @@ public class UHC extends TeamGame implements NCPHook if (event.GetState() != GameState.Prepare) return; + for (Map.Entry entries : _teamCenter.entrySet()) + { + while (entries.getKey().GetSpawns().size() < 20) + { + entries.getKey().GetSpawns().add(GetRandomSpawn(entries.getValue(), true)); + } + } Manager.GetChat().Silence(1000 * 120, false); @@ -781,16 +813,30 @@ public class UHC extends TeamGame implements NCPHook Location zero = WorldData.World.getSpawnLocation(); - // fixme if you leave while teleporting you'll rejoin at 0,0 - for (Player player : players) { player.teleport(zero); + + // Update scoreboard + _healthObjective.getScore(player.getName()).setScore((int) player.getMaxHealth()); + + game.addPlayerInTime(player); + + Manager.Clear(player); + UtilInv.Clear(player); + // Heal player.setHealth(player.getMaxHealth()); // Resistance and regen player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true); player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true); + + + game.ValidateKit(player, game.GetTeam(player)); + + if (game.GetKit(player) != null) + game.GetKit(player).ApplyKit(player); + } Announce(C.cGreen + C.Bold + "Please wait, you will be teleported soon", false); @@ -824,8 +870,8 @@ public class UHC extends TeamGame implements NCPHook // Heal player.setHealth(player.getMaxHealth()); // Resistance and regen - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true); - player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * 20, 128), true); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 10 * 20, 128), true); } teleportedLocations.clear(); @@ -843,39 +889,32 @@ public class UHC extends TeamGame implements NCPHook Manager.runSyncLater(() -> { - for (Player player : players) - { - player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - player.removePotionEffect(PotionEffectType.REGENERATION); - } - WorldData.World.setAutoSave(true); - _chunkUnloadTask = new BukkitRunnable() - { - @Override - public void run() - { - Iterator iterator = _loadedChunks.iterator(); - int amount = 0; - - while (amount < CHUNKS_UNLOAD_PER_TICK && iterator.hasNext()) - { - Chunk next = iterator.next(); - if (WorldData.World.unloadChunkRequest(next.getX(), next.getZ())) - { - System.out.println("Requesting unload of chunk " + next.getX() + " " + next.getZ()); - } - iterator.remove(); - amount++; - } - - if (_loadedChunks.size() == 0) - { - cancel(); - } - } - }; +// _chunkUnloadTaskId = Bukkit.getScheduler().runTaskTimer(getArcadeManager().getPlugin(), () -> +// { +// Iterator iterator = _loadedChunks.iterator(); +// int amount = 0; +// +// while (amount < CHUNKS_UNLOAD_PER_TICK && iterator.hasNext()) +// { +// if (WorldData == null || WorldData.World == null) +// { +// Bukkit.getScheduler().cancelTask(_chunkUnloadTaskId); +// return; +// } +// +// Chunk next = iterator.next(); +// WorldData.World.unloadChunkRequest(next.getX(), next.getZ()); +// iterator.remove(); +// amount++; +// } +// +// if (_loadedChunks.size() == 0) +// { +// Bukkit.getScheduler().cancelTask(_chunkUnloadTaskId); +// } +// }, CHUNKS_UNLOAD_DELAY, CHUNKS_UNLOAD_PERIOD).getTaskId(); }, 10 * 20L); } }, 5 * 20L); @@ -893,31 +932,11 @@ public class UHC extends TeamGame implements NCPHook // Save where they teleported teleportedLocations.put(player.getUniqueId(), team.SpawnTeleport(player)); - // Update scoreboard - _healthObjective.getScore(player).setScore((int) player.getMaxHealth()); - - game.addPlayerInTime(player); - - Manager.Clear(player); - UtilInv.Clear(player); - - // Heal - player.setHealth(player.getMaxHealth()); - // Resistance and regen - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 30 * 20, 128), true); - player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 30 * 20, 128), true); - - - game.ValidateKit(player, game.GetTeam(player)); - - if (game.GetKit(player) != null) - game.GetKit(player).ApplyKit(player); - //Event PlayerPrepareTeleportEvent playerStateEvent = new PlayerPrepareTeleportEvent(game, player); UtilServer.getServer().getPluginManager().callEvent(playerStateEvent); } - }, 5 * 20L, 5L).getTaskId()); + }, 5 * 20L, DELAY_BETWEEN_PLAYER_TELEPORT).getTaskId()); //Spectators Move for (Player player : UtilServer.getPlayers()) @@ -939,36 +958,7 @@ public class UHC extends TeamGame implements NCPHook SpectatorSpawn = WorldData.World.getSpawnLocation(); - // Move Up - Out Of Blocks - while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) - || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.add(0, 1, 0); - } - - int Up = 0; - - // Move Up - Through Air - for (int i = 0; i < 15; i++) - { - if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.add(0, 1, 0); - Up++; - } - else - { - break; - } - } - - // Move Down - Out Of Blocks - while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) - || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.subtract(0, 1, 0); - Up--; - } + SpectatorSpawn.add(0, 10, 0); SpectatorSpawn = SpectatorSpawn.getBlock().getLocation().add(0.5, 0.1, 0.5); @@ -1024,11 +1014,6 @@ public class UHC extends TeamGame implements NCPHook isIllegal = event.getPlayer().getItemInHand().getType() == Material.INK_SACK && event.getPlayer().getItemInHand().getData().getData() == (byte) 15; } - if (!isIllegal) - { - isIllegal = event.getPlayer().getItemInHand().getType() == Material.WATER_BUCKET - || event.getPlayer().getItemInHand().getType() == Material.LAVA_BUCKET; - } if (isIllegal && isInSafeZone(event.getClickedBlock().getLocation())) { @@ -1058,55 +1043,80 @@ public class UHC extends TeamGame implements NCPHook private boolean isInSafeZone(Location location) { return location.getX() <= SAFE_REGION && location.getX() >= -SAFE_REGION - && location.getZ() < SAFE_REGION && location.getZ() >= -SAFE_REGION; + && location.getZ() <= SAFE_REGION && location.getZ() >= -SAFE_REGION; } - // fixme world decoration means random spawns which were clear before might not be after - public Location GetRandomSpawn(Location around) + private Location GetRandomSpawn(Location around, boolean sameChunk) { - // Sometimes getting a random spawn at 0,0 hangs forever int tries = 0; - Location loc = null; + Chunk chunk = around == null ? null : around.getChunk(); - while (loc == null) + while (true) { tries++; - Block block = null; - // Get Team Location + if (tries > 100) + { + System.out.println("Tries > 100, returning spawn"); + return WorldData.World.getSpawnLocation(); + } + + Block targetBlock; + if (around == null) { // Return a int from 0 - 1800, then remove 900 so its a int from -900 to 900 int x = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder)); int z = (int) (UtilMath.r((int) (1.8 * _currentBorder)) - (0.9 * _currentBorder)); - block = UtilBlock.getHighest(WorldData.World, x, z, null); + targetBlock = UtilBlock.getHighest(WorldData.World, x, z, null); } - // Get Radius Location else { - block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(tries < 10 ? 8 : 30), around.getBlockZ() - 4 - + UtilMath.r(tries < 10 ? 8 : 30), null); + if (sameChunk) + { + if (tries > 20) + { + System.out.println("----------- WARNING ---------------"); + System.out.println("DISABLED SAMECHUNK CHECK AFTER 20 ATTEMPTS"); + sameChunk = false; + continue; + } + + targetBlock = UtilBlock.getHighest(WorldData.World, chunk.getBlock(UtilMath.r(15), 0, UtilMath.r(15)).getLocation()); + } + else + { + targetBlock = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(tries < 10 ? 8 : 30), around.getBlockZ() - 4 + + UtilMath.r(tries < 10 ? 8 : 30), null); + } + } + + if (sameChunk && around != null && !around.getChunk().equals(targetBlock.getChunk())) + { + System.out.println("Failed same chunk check: " + around.getChunk() + " " + targetBlock.getChunk() + " " + tries); + continue; } // Check Validity // Liquid - if (block.getRelative(BlockFace.DOWN).isLiquid()) - continue; - - if (!block.getRelative(BlockFace.DOWN).getType().isSolid()) + if (targetBlock.getRelative(BlockFace.DOWN).isLiquid()) + { + System.out.println("Failed liquid check: " + targetBlock.getRelative(BlockFace.DOWN) + " " + tries); continue; + } // Suffocated - if (block.getType() != Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) + if (CraftMagicNumbers.getBlock(targetBlock.getRelative(BlockFace.UP)).w()) + { + System.out.println("Failed suffocation check: " + targetBlock.getRelative(BlockFace.UP) + " " + tries); continue; + } - loc = block.getLocation().add(0.5, 0.5, 0.5); + return targetBlock.getLocation().add(0.5, 0.5, 0.5); } - - return loc; } @EventHandler @@ -1215,25 +1225,6 @@ public class UHC extends TeamGame implements NCPHook } } - @EventHandler - public void on(EntityTargetLivingEntityEvent event) - { - if (event.getEntity() instanceof ExperienceOrb) - { - if (event.getTarget() instanceof Player) - { - Player player = (Player) event.getTarget(); - - Game game = Manager.GetGame(); - - if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live) - { - event.setCancelled(true); - } - } - } - } - @EventHandler(priority = EventPriority.LOWEST) public void PlayerKick(PlayerKickEvent event) { @@ -1536,7 +1527,10 @@ public class UHC extends TeamGame implements NCPHook } } - AnnounceEnd(teamsAlive.get(0)); + if (teamsAlive.size() > 0) + { + AnnounceEnd(teamsAlive.get(0)); + } SetState(GameState.End); } } @@ -1554,24 +1548,21 @@ public class UHC extends TeamGame implements NCPHook public void ScoreboardWrite() { - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); // Solo if (GetTeamList().size() == 1) { if (GetPlayers(true).size() < 8) { - for (Player player : GetPlayers(true)) - { - Scoreboard.WriteOrdered("Health", player.getName(), GetHealth(player), true); - } + Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(player.getName(), GetHealth(player)), true); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Players"); - Scoreboard.Write(GetPlayers(true).size() + " Alive"); + Scoreboard.write(C.cYellow + C.Bold + "Players"); + Scoreboard.write(GetPlayers(true).size() + " Alive"); } } // Team @@ -1585,37 +1576,42 @@ public class UHC extends TeamGame implements NCPHook if (GetPlayers(true).size() < 8) { - for (Player player : GetPlayers(true)) - { - Scoreboard.WriteOrdered("Health", GetTeam(player).GetColor() + player.getName(), GetHealth(player), true); - } + Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(GetTeam(player).GetColor() + player.getName(), GetHealth(player)), true); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Teams"); - Scoreboard.Write(aliveList.size() + " Alive"); + Scoreboard.write(C.cYellow + C.Bold + "Teams"); + Scoreboard.write(aliveList.size() + " Alive"); } } - Scoreboard.WriteBlank(); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Status"); if (GetState() == GameState.Prepare) { - Scoreboard.Write(C.cYellow + C.Bold + "Status"); int players = _teleportedPlayers + 1; if (players > _totalPlayers) players = _totalPlayers; - Scoreboard.Write("Teleporting Players (" + players + "/" + _totalPlayers + ")"); + Scoreboard.write("Teleporting Players (" + players + "/" + _totalPlayers + ")"); + } + else if (GetState() == GameState.Live) + { + Scoreboard.write("Live (" + UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime()) + ")"); } else { - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); + Scoreboard.write("Finished"); } - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Borders"); - Scoreboard.Write("-" + (int) _currentBorder + " to " + "+" + (int) _currentBorder); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Borders"); + Scoreboard.write("-" + (int) _currentBorder + " to " + "+" + (int) _currentBorder); - Scoreboard.Draw(); + Scoreboard.draw(); + + for (Player player : GetPlayers(true)) + { + _healthObjective.getScore(player.getName()).setScore((int) player.getHealth()); + } } public int GetHealth(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java index 39012869c..c019c337b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/helpers/WorldGenThread.java @@ -138,16 +138,10 @@ public class WorldGenThread extends Thread TimingManager.start("Map Generation"); long start = System.currentTimeMillis(); - long last = start; while (!_stopGen) { long now = System.currentTimeMillis(); - if ((now - last) >= 10 * 1000) - { - _game.Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false); - last = now; - } long hash = LongHash.toLong(_chunkX, _chunkZ); @@ -174,7 +168,6 @@ public class WorldGenThread extends Thread else { _mapLoaded = true; - System.out.println("Map Loading Finished! Took " + TimeUnit.MILLISECONDS.toSeconds(now - start) + " seconds"); break; } @@ -215,13 +208,6 @@ public class WorldGenThread extends Thread this._stopGen = true; } - public String getMapLoadETA() - { - int chunksToGo = _chunkTotal - _chunksLoaded; - - return UtilTime.MakeStr((long) ((double) chunksToGo / (double) (_chunksPerTick * 20) * 1000d), 1); - } - public boolean isMapLoaded() { return this._mapLoaded; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java index e902d5f44..b1f5f327e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -1,12 +1,38 @@ package nautilus.game.arcade.game.games.valentines; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.stream.Collectors; - +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.noteblock.INoteVerifier; +import mineplex.core.noteblock.NBSReader; +import mineplex.core.noteblock.NotePlayer; +import mineplex.core.noteblock.NoteSong; +import mineplex.core.preferences.Preference; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; +import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; +import nautilus.game.arcade.kit.Kit; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Material; @@ -21,50 +47,16 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.noteblock.INoteVerifier; -import mineplex.core.noteblock.NBSReader; -import mineplex.core.noteblock.NotePlayer; -import mineplex.core.noteblock.NoteSong; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.christmas.ChristmasAudio; -import nautilus.game.arcade.game.games.gladiators.tutorial.TutorialGladiators; -import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; -import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; -import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; -import nautilus.game.arcade.kit.Kit; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; public class Valentines extends SoloGame { @@ -711,7 +703,7 @@ public class Valentines extends SoloGame @Override public boolean shouldPlay(Player player) { - return Manager.getPreferences().Get(player).HubMusic; + return Manager.getPreferences().get(player).isActive(Preference.HUB_MUSIC); } }, 0.7F, true); } @@ -726,28 +718,28 @@ public class Valentines extends SoloGame if (GetTeamList().isEmpty()) return; - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write("" + GetPlayers(true).size()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write("" + GetPlayers(true).size()); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Items Left"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Items Left"); if (_roundState == 1) - Scoreboard.Write("" + _pigs.size()); + Scoreboard.write("" + _pigs.size()); else - Scoreboard.Write("-"); + Scoreboard.write("-"); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Time Left"); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreen + "Time Left"); if (_roundState == 1) - Scoreboard.Write("" + UtilTime.MakeStr(_roundTimeLimit - (System.currentTimeMillis() - _roundTime), 0)); + Scoreboard.write("" + UtilTime.MakeStr(_roundTimeLimit - (System.currentTimeMillis() - _roundTime), 0)); else - Scoreboard.Write("-"); + Scoreboard.write("-"); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 20e743fc8..17683ac99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -271,13 +271,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer return; } - if(event.getBlock().getLocation().getBlockY() < _maxY - 4) - { - event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); - event.setCancelled(true); - return; - } - _locationsOfBlocks.add(event.getBlock().getLocation()); } @@ -544,32 +537,32 @@ public class WitherGame extends TeamGame implements IBlockRestorer // lives += i; // Wipe Last - Scoreboard.Reset(); + Scoreboard.reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(_runners.GetColor() + C.Bold + _runners.GetName()); - Scoreboard.Write(_runners.GetColor() + "" + Scoreboard.writeNewLine(); + Scoreboard.write(_runners.GetColor() + C.Bold + _runners.GetName()); + Scoreboard.write(_runners.GetColor() + "" + _runners.GetPlayers(true).size() + " Players"); - Scoreboard.WriteBlank(); - Scoreboard.Write(_withers.GetColor() + C.Bold + _withers.GetName()); - Scoreboard.Write(_withers.GetColor() + "" + Scoreboard.writeNewLine(); + Scoreboard.write(_withers.GetColor() + C.Bold + _withers.GetName()); + Scoreboard.write(_withers.GetColor() + "" + _withers.GetPlayers(true).size() + " Players"); // Scoreboard.WriteBlank(); // Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive"); // Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer)); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr( + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.write(UtilTime.MakeStr( Math.max( 0, _gameTime - (System.currentTimeMillis() - this .GetStateTime())), 1)); - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java index 4c7cb0154..cda8ebd37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java @@ -1,11 +1,9 @@ package nautilus.game.arcade.game.games.wizards; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; - import org.bukkit.entity.Player; public class WizardSpellMenuShop extends ShopBase @@ -13,9 +11,9 @@ public class WizardSpellMenuShop extends ShopBase private Wizards _wizards; public WizardSpellMenuShop(WizardSpellMenu plugin, CoreClientManager clientManager, DonationManager donationManager, - Wizards wizard, CurrencyType... currencyTypes) + Wizards wizard) { - super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); + super(plugin, clientManager, donationManager, "Kit Evolve Menu"); _wizards = wizard; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 6ab2f5018..c4463ea18 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.wizards; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -51,11 +50,11 @@ import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import net.minecraft.server.v1_8_R3.EntityFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; -import nautilus.game.arcade.managers.chat.ChatStatData; import org.apache.commons.lang.IllegalClassException; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -736,7 +735,7 @@ public class Wizards extends SoloGame done++; } } - + private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players) { // Generate Bar @@ -863,7 +862,7 @@ public class Wizards extends SoloGame return items; } - + private void dropSpells(Player player) { HashSet spells = new HashSet(); @@ -1638,14 +1637,14 @@ public class Wizards extends SoloGame @EventHandler public void ScoreboardUpdate(UpdateEvent event) { - GetScoreboard().Reset(); + GetScoreboard().reset(); - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); - GetScoreboard().Write(C.cYellow + C.Bold + "Wizards"); - GetScoreboard().Write(C.cWhite + GetPlayers(true).size()); + GetScoreboard().write(C.cYellow + C.Bold + "Wizards"); + GetScoreboard().write(C.cWhite + GetPlayers(true).size()); - GetScoreboard().WriteBlank(); + GetScoreboard().writeNewLine(); double time = UtilTime.convert(( @@ -1653,10 +1652,10 @@ public class Wizards extends SoloGame + (10 * 60 * 1000)) - System.currentTimeMillis(), 1, TimeUnit.MINUTES); - GetScoreboard().Write((time >= 0 ? C.cYellow : C.cRed) + C.Bold + (time >= 0 ? "Time Left" : "Overtime")); - GetScoreboard().Write(C.cWhite + Math.abs(time) + " Minute" + (Math.abs(time) != 1 ? "s" : "")); + GetScoreboard().write((time >= 0 ? C.cYellow : C.cRed) + C.Bold + (time >= 0 ? "Time Left" : "Overtime")); + GetScoreboard().write(C.cWhite + Math.abs(time) + " Minute" + (Math.abs(time) != 1 ? "s" : "")); - GetScoreboard().Draw(); + GetScoreboard().draw(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java index 3f118fbb9..92c5ce0c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java @@ -35,7 +35,6 @@ import nautilus.game.arcade.game.games.zombiesurvival.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.Navigation; import net.minecraft.server.v1_8_R3.NavigationAbstract; public class ZombieSurvival extends SoloGame @@ -357,15 +356,15 @@ public class ZombieSurvival extends SoloGame if (_survivors == null || _undead == null) return; - Scoreboard.Reset(); + Scoreboard.reset(); for (GameTeam team : this.GetTeamList()) { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); } - Scoreboard.Draw(); + Scoreboard.draw(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java new file mode 100644 index 000000000..6928d08f7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AntiExpOrbModule.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/* + * This module will prevent spectators from picking up xp orbs + * + * fixme: there are still some graphical glitches + */ +public class AntiExpOrbModule extends Module +{ + private Set _playersLastUpdated = new HashSet<>(); + + @EventHandler + public void on(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Game game = getGame(); + + for (Player player : Bukkit.getOnlinePlayers()) + { + boolean disallow = game.GetState() != Game.GameState.Live || !game.IsAlive(player); + + if (disallow) + { + updateTimer(player, 86000); + _playersLastUpdated.add(player.getUniqueId()); + } + else + { + if (_playersLastUpdated.remove(player.getUniqueId())) + { + updateTimer(player, 2); + } + } + } + } + + @EventHandler + public void on(EntityTargetLivingEntityEvent event) + { + if (event.getEntity() instanceof ExperienceOrb) + { + if (event.getTarget() instanceof Player) + { + Player player = (Player) event.getTarget(); + + Game game = getGame(); + + if (game.GetState() != Game.GameState.Live || !game.IsAlive(player)) + { + // Setting the target to null sets the actual target in EntityExperienceOrb to null + event.setTarget(null); + // Cancelling the event is a sanity check + event.setCancelled(true); + } + } + } + } + + @EventHandler + public void on(PlayerQuitEvent event) + { + _playersLastUpdated.remove(event.getPlayer().getUniqueId()); + } + + @Override + public void cleanup() + { + for (UUID uuid : _playersLastUpdated) + { + Player player = Bukkit.getPlayer(uuid); + if (player != null) + { + updateTimer(player, 0); + } + } + _playersLastUpdated.clear(); + } + + private void updateTimer(Player player, int ticksToWait) + { + ((CraftPlayer) player).getHandle().bp = ticksToWait; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java index 38e54b55e..12c709f29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java @@ -137,7 +137,7 @@ public class TeamModule extends Module } } - @EventHandler + @EventHandler (priority = EventPriority.LOWEST) public void teamQuit(PlayerQuitEvent event) { if (getGame().GetState() != Game.GameState.Recruit) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java index 216cf8355..3c3caf09e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java @@ -43,6 +43,7 @@ public class AntiXrayModule extends Module public void cleanup() { _service.setEnabled(false); + _service.clearCache(); } public AntiXrayModule setEnabled(boolean enabled) @@ -87,6 +88,12 @@ public class AntiXrayModule extends Module return this; } + public AntiXrayModule setDarknessHideBlocks(boolean darknessHideBlocks) + { + _service.setDarknessHideBlocks(darknessHideBlocks); + return this; + } + public AntiXrayModule setObfuscateBlocks(Material... materials) { return setObfuscateBlocks(Arrays.asList(materials)); @@ -108,4 +115,31 @@ public class AntiXrayModule extends Module _service.setRandomBlocks(materials); return this; } + + public AntiXrayModule setProximityBlocks(Material... materials) + { + return setProximityBlocks(Arrays.asList(materials)); + } + + public AntiXrayModule setProximityBlocks(List materials) + { + _service.setProximityBlocks(materials); + return this; + } + public AntiXrayModule setDarknessBlocks(Material... materials) + { + return setDarknessBlocks(Arrays.asList(materials)); + } + + public AntiXrayModule setDarknessBlocks(List materials) + { + _service.setDarknessBlocks(materials); + return this; + } + + public AntiXrayModule setUseCache(boolean useCache) + { + _service.setUseCache(true); + return this; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java index 9c1619bbf..d84ff27cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java @@ -17,11 +17,41 @@ public interface AntiXrayService void setUpdateRadius(int updateRadius); + void setUseWorldsAsBlacklist(boolean useWorldsAsBlacklist); + + void setUseCache(boolean useCache); + + void setMaxLoadedCacheFiles(int maxLoadedCacheFiles); + + void clearCache(); + + void setProximityHiderRate(int proximityHiderRate); + + void setProximityHiderDistance(int proximityHiderDistance); + + void setProximityHiderId(int proximityHiderId); + + void setProximityHiderEnd(int proximityHiderEnd); + + void setUseSpecialBlockForProximityHider(boolean useSpecialBlockForProximityHider); + + void setUseYLocationProximity(boolean useYLocationProximity); + + void setAirGeneratorMaxChance(int airGeneratorMaxChance); + + void setWorlds(List worlds); + void setUseProximityHider(boolean useProximityHider); void setAntiTexturePacksAndFreecam(boolean antiTexturePacksAndFreecam); + void setDarknessHideBlocks(boolean darknessHideBlocks); + void setObfuscateBlocks(List materials); void setRandomBlocks(List materials); + + void setDarknessBlocks(List materials); + + void setProximityBlocks(List materials); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java index 25b2d3b73..6e23a2ad6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java @@ -181,6 +181,8 @@ public class CombatLogModule extends Module _logoutNpcs.clear(); _killedBy.clear(); + + Bukkit.getScheduler().cancelTask(_locationTaskId); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java index 26b0de8c3..f7dad01e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java @@ -1,15 +1,13 @@ package nautilus.game.arcade.gui.spectatorMenu; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.gui.spectatorMenu.page.SpectatorPage; +import org.bukkit.entity.Player; /** * Created by shaun on 14-09-24. @@ -19,9 +17,9 @@ public class SpectatorShop extends ShopBase private ArcadeManager _arcadeManager; - public SpectatorShop(CompassAddon plugin, ArcadeManager arcadeManager, CoreClientManager clientManager, DonationManager donationManager, CurrencyType... currencyTypes) + public SpectatorShop(CompassAddon plugin, ArcadeManager arcadeManager, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Spectate Menu", currencyTypes); + super(plugin, clientManager, donationManager, "Spectate Menu"); _arcadeManager = arcadeManager; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index 37e11c948..8f9f95b5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.*; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.PlayerKitGiveEvent; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.*; @@ -44,13 +45,20 @@ public abstract class Kit implements Listener _kitName = name; _kitDesc = kitDesc; _kitPerks = kitPerks; - + for (Perk perk : _kitPerks) + { + if (perk == null) + { + break; + } + perk.SetHost(this); + } _kitAvailability = kitAvailability; _cost = cost; - + _entityType = entityType; _itemInHand = itemInHand; @@ -93,6 +101,11 @@ public abstract class Kit implements Listener { return _kitPerks; } + + public EntityType getEntityType() + { + return _entityType; + } public boolean HasKit(Player player) { @@ -107,7 +120,14 @@ public abstract class Kit implements Listener UtilInv.Clear(player); for (Perk perk : _kitPerks) + { + if (perk == null) + { + break; + } + perk.Apply(player); + } GiveItemsCall(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java index 922b0daca..9d637c716 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java @@ -14,12 +14,11 @@ public abstract class Perk implements Listener private String[] _perkDesc; private boolean _display; + private int _upgradeLevel; public Perk(String name, String[] perkDesc) { - _perkName = name; - _perkDesc = perkDesc; - _display = true; + this(name, perkDesc, true); } public Perk(String name, String[] perkDesc, boolean display) @@ -29,6 +28,23 @@ public abstract class Perk implements Listener _display = display; } + public boolean hasPerk(Player player) + { + if (!(Kit instanceof ProgressingKit)) + { + return Kit.HasKit(player); + } + + ProgressingKit progressingKit = (ProgressingKit) Kit; + + return Kit.HasKit(player) && progressingKit.getUpgradeLevel(player.getUniqueId()) == _upgradeLevel; + } + + public void setUpgradeLevel(int upgradeLevel) + { + _upgradeLevel = upgradeLevel; + } + public void SetHost(Kit kit) { Manager = kit.Manager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 9d8679a34..f8463d4f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -1,20 +1,22 @@ package nautilus.game.arcade.kit; import com.google.common.collect.Lists; -import mineplex.core.common.CurrencyType; +import com.google.common.collect.Maps; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.Donor; +import mineplex.core.menu.Menu; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.data.KitAbilityDetail; import mineplex.core.progression.data.PlayerKit; import mineplex.core.progression.data.PlayerKitDataManager; -import mineplex.core.progression.gui.Menu; import mineplex.core.progression.math.Calculations; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.games.evolution.Evolution; @@ -22,8 +24,13 @@ import nautilus.game.arcade.shop.KitPackage; import net.minecraft.server.v1_8_R3.EntityFireworks; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; import net.minecraft.server.v1_8_R3.World; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; @@ -35,6 +42,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -50,17 +58,50 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit private String _internalName; private PlayerKitDataManager _dataManager; - private List _kitAbilityDetails; + private Map> _kitUpgradeDetails; + private Perk[][] _perks; + private Perk[] _nonUpgradePerks; public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) { super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand); _internalName = internalName; _dataManager = manager.getKitProgressionManager().getDataManager(); - _kitAbilityDetails = Lists.newArrayList(); - for (Perk perk : kitPerks) + _nonUpgradePerks = kitPerks; + } + + public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, String[] kitDesc, Perk[][] kitPerks, String[][] upgradeDetails, EntityType entityType, ItemStack itemInHand) + { + super(manager, name, kitAvailability, kitDesc, kitPerks[0], entityType, itemInHand); + _internalName = internalName; + _dataManager = manager.getKitProgressionManager().getDataManager(); + _kitUpgradeDetails = Maps.newHashMap(); + _perks = new Perk[kitPerks.length][kitPerks.length]; + + for (int level = 0; level < kitPerks.length; level++) { - _kitAbilityDetails.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); + if (level > 0) + { + List details = Lists.newArrayList(); + String[] kitDetails = upgradeDetails[level - 1]; + + for (String detail : kitDetails) + { + details.add(C.cGray + detail); + } + + _kitUpgradeDetails.put(level - 1, details); + } + + Perk[] perks = kitPerks[level]; + int index = 0; + + for (Perk perk : perks) + { + _perks[level][index++] = perk; + perk.setUpgradeLevel(level); + perk.SetHost(this); + } } } @@ -69,13 +110,43 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); _internalName = internalName; _dataManager = manager.getKitProgressionManager().getDataManager(); - _kitAbilityDetails = Lists.newArrayList(); - for (Perk perk : kitPerks) - { - _kitAbilityDetails.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); - } + _nonUpgradePerks = kitPerks; } + public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[][] kitPerks, String[][] upgradeDetails, EntityType entityType, ItemStack itemInHand) + { + super(manager, name, kitAvailability, cost, kitDesc, kitPerks[0], entityType, itemInHand); + _internalName = internalName; + _dataManager = manager.getKitProgressionManager().getDataManager(); + _kitUpgradeDetails = Maps.newHashMap(); + _perks = new Perk[kitPerks.length][kitPerks.length]; + + for (int level = 0; level < kitPerks.length; level++) + { + if (level > 0) + { + List details = Lists.newArrayList(); + String[] kitDetails = upgradeDetails[level - 1]; + + for (String detail : kitDetails) + { + details.add(C.cGray + detail); + } + + _kitUpgradeDetails.put(level - 1, details); + } + + Perk[] perks = kitPerks[level]; + int index = 0; + + for (Perk perk : perks) + { + _perks[level][index++] = perk; + perk.setUpgradeLevel(level); + perk.SetHost(this); + } + } + } @Override public String getDisplayName() @@ -102,9 +173,9 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit } @Override - public List getAbilityDetails() + public Map> getUpgradeDetails() { - return _kitAbilityDetails; + return _kitUpgradeDetails; } @Override @@ -242,7 +313,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { PlayerKit playerKit = _dataManager.get(player); Donor donor = Manager.GetDonation().Get(Bukkit.getPlayer(player)); - return Calculations.canUpgrade(playerKit.getLevel(getInternalName()), donor.GetGems()); + return Calculations.canUpgrade(Calculations.getNextUpgradeLevel(playerKit.getLevel(getInternalName())), donor.getBalance(GlobalCurrency.GEM)) && playerKit.getLevel(getInternalName()) >= Calculations.getLevelRequiredFor(upgradeLevel); } @Override @@ -298,15 +369,16 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { return true; } - else if (this.GetAvailability() == KitAvailability.Gem && donor.GetBalance(CurrencyType.GEM) >= this.GetCost()) + else if (this.GetAvailability() == KitAvailability.Gem && donor.getBalance(GlobalCurrency.GEM) >= this.GetCost()) { - Manager.GetShop().openPageForPlayer(player, new ConfirmationPage<>( - Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), () -> { + SalesPackageBase salesPackage = new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this); + Manager.GetShop().openPageForPlayer(player, new ConfirmationPage<>(player, Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, Manager.GetDonation(), () -> + { if (player.isOnline()) { Manager.GetGame().SetKit(player, this, true); } - }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), CurrencyType.GEM, player)); + }), salesPackage.buildIcon())); } else if (this.GetAvailability() == KitAvailability.Achievement) { @@ -321,6 +393,21 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit return false; } + public boolean hasUpgrades() + { + return _nonUpgradePerks == null && _perks != null; + } + + public Perk[] getNonUpgradePerks() + { + return _nonUpgradePerks; + } + + public Perk[][] getPerks() + { + return _perks; + } + public static String leap() { return C.cYellow + "Right-Click" + C.cWhite + " with Axe to " + C.cGreen + "Leap"; @@ -342,6 +429,16 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit return C.cWhite + "Receive " + C.cGreen + amount + C.cWhite + " arrow" + (amount == 1 ? "" : "s") + " every " + C.cGreen + per + C.cWhite + " seconds. Max " + C.cGreen + max; } + public static String reduceCooldown(String perk, double time) + { + return C.cWhite + "Reduce the cooldown of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + time + C.cWhite + " seconds" + (time == 1 ? "" : "s") + "."; + } + + public static String increase(String perk, String increasing, double percentage) + { + return C.cWhite + "Increase the " + C.cGreen + increasing + C.cWhite + " of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + percentage + C.cWhite + "%."; + } + public static class CustomFirework extends EntityFireworks { @@ -406,4 +503,4 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit } } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java new file mode 100644 index 000000000..a010dd5f4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java @@ -0,0 +1,213 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.Iterator; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.kit.Perk; + +public class PerkDirtCannon extends Perk implements IThrown +{ + + private static final int GIVE_DELAY = 20000; + + private static final ItemStack DIRT_ITEM = new ItemBuilder(Material.DIRT).setTitle(C.cGreen + "Throwable Dirt").setGlow(true).build(); + + private long _lastDirt; + private double _targetKnockback; + + public PerkDirtCannon(double targetKnockback) + { + super("Throwable Dirt", new String[] { + }); + _targetKnockback = targetKnockback; + _lastDirt = 0; + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null) + { + return; + } + + if (!DIRT_ITEM.isSimilar(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + int amount = player.getInventory().getItemInHand().getAmount() - 1; + + if (amount == 0) + { + player.getInventory().remove(DIRT_ITEM); + } + else + { + player.getItemInHand().setAmount(amount); + } + + @SuppressWarnings("deprecation") + FallingBlock fallingBlock = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.DIRT, (byte) 0); + fallingBlock.setDropItem(false); + fallingBlock.setVelocity(player.getLocation().getDirection().multiply(2)); + Manager.GetProjectile().AddThrow(fallingBlock, player, this, -1, true, true, true, true, false, 1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (UtilTime.elapsed(_lastDirt, GIVE_DELAY)) + { + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, 4)) + { + continue; + } + + player.getInventory().addItem(DIRT_ITEM); + } + + _lastDirt = System.currentTimeMillis(); + } + } + + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) + { + if (event.getBlock().getType() == Material.DIRT) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (!hasPerk(event.getPlayer())) + { + return; + } + + if (DIRT_ITEM.isSimilar(event.getItemInHand())) + { + event.getPlayer().sendMessage(F.main("Game", "You cannot place your skill item.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDropItem(PlayerDropItemEvent event) + { + if (DIRT_ITEM.isSimilar(event.getItemDrop().getItemStack())) + { + event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + if (!hasPerk(event.getEntity())) + { + return; + } + + Iterator iterator = event.getDrops().iterator(); + + while (iterator.hasNext()) + { + ItemStack itemStack = iterator.next(); + if (DIRT_ITEM.isSimilar(itemStack)) + { + iterator.remove(); + } + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target == null) + { + return; + } + + if (Manager.GetGame() instanceof TeamGame && target instanceof Player && data.getThrower() instanceof Player) + { + Game game = Manager.GetGame(); + + if (!game.IsAlive(target)) + { + return; + } + + if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower()))) + { + return; + } + } + + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, 2, false, true, true, data.getThrower().getName(), GetName()); + + UtilAction.velocity(target, data.getThrown().getVelocity().normalize().setY(0.5).multiply(_targetKnockback)); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java index 2dddbcc76..1af48f4f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java @@ -4,7 +4,6 @@ import java.util.HashSet; import org.bukkit.Effect; import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,8 +12,9 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -34,7 +34,7 @@ public class PerkDoubleJump extends Perk { super(name, new String[] { - C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name + C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name, }); _power = power; @@ -48,7 +48,8 @@ public class PerkDoubleJump extends Perk { super(name, new String[] { - C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name + C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name, + "Cooldown " + C.cGreen + UtilTime.convertString(recharge, 0, TimeUnit.SECONDS) + C.cGray + "." }); _power = power; @@ -74,7 +75,7 @@ public class PerkDoubleJump extends Perk { Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!hasPerk(player)) return; if (Manager.isSpectator(player)) @@ -127,7 +128,7 @@ public class PerkDoubleJump extends Perk if (Manager.isSpectator(player)) continue; - if (!Kit.HasKit(player)) + if (!hasPerk(player)) continue; if (_recharge > 0 && !Recharge.Instance.usable(player, GetName())) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFireBurst.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFireBurst.java new file mode 100644 index 000000000..1a235389e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFireBurst.java @@ -0,0 +1,146 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.Iterator; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.kit.Perk; + +public class PerkFireBurst extends Perk +{ + + private static final int FIRE_TICKS = 60; + private static final double LOCATION_Y_MODIFER = 1; + + private long _cooldown; + private double _range; + private double _damage; + + public PerkFireBurst(long cooldown, double range, double damage) + { + super("Fire Burst", new String[] { + C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst", + "Sends out a pulse of fire that deals " + C.cGreen + damage + C.cWhite + " damage to", + "all players within " + C.cGreen + range + C.cWhite + " blocks.", + "Cooldown " + C.cGreen + UtilTime.convertString(cooldown, 0, TimeUnit.SECONDS) + C.cWhite + "." }); + + _cooldown = cooldown; + _range = range; + _damage = damage; + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null) + { + return; + } + + if (player.getItemInHand().getType() != Material.BLAZE_ROD) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true)) + { + return; + } + + final Location location = player.getLocation().add(0, LOCATION_Y_MODIFER, 0); + + for (Player other : UtilPlayer.getNearby(location, _range, true)) + { + if (other.equals(player)) + { + continue; + } + + other.setFireTicks(FIRE_TICKS); + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, true, true, player.getName(), GetName()); + } + + for (double radius = 0; radius < _range; radius += 0.5) + { + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 20) + { + double x = radius * Math.cos(theta); + double z = radius * Math.sin(theta); + + location.add(x, 0, z); + + UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.01F, 1, ViewDist.NORMAL); + + location.subtract(x, 0, z); + } + } + + } + + @EventHandler + public void onPlayerDropItem(PlayerDropItemEvent event) + { + if (!hasPerk(event.getPlayer())) + { + return; + } + + if (event.getItemDrop().getItemStack().getType() == Material.BLAZE_ROD) + { + event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + if (!hasPerk(event.getEntity())) + { + return; + } + + Iterator iterator = event.getDrops().iterator(); + + while (iterator.hasNext()) + { + ItemStack itemStack = iterator.next(); + + if (itemStack.getType() == Material.BLAZE_ROD) + { + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java index df7e17b2e..f16ef797c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java @@ -17,15 +17,17 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.perks.data.FireflyData; @@ -170,6 +172,11 @@ public class PerkFirefly extends SmashPerk if (event.GetDamage() <= 4) return; + if (!(event.GetDamagerEntity(true) instanceof Player)) + { + return; + } + Iterator dataIterator = _data.iterator(); while (dataIterator.hasNext()) @@ -181,6 +188,17 @@ public class PerkFirefly extends SmashPerk if (!UtilTime.elapsed(data.Time, 1250) && !isSuperActive(data.Player))// && event.GetCause() == DamageCause.PROJECTILE) { + Game game = Manager.GetGame(); + + if (game instanceof TeamSuperSmash) + { + if (game.GetTeam(data.Player).equals(game.GetTeam(event.GetDamagerPlayer(true)))) + { + event.SetCancelled("Team Damage"); + return; + } + } + dataIterator.remove(); } else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java index f52eaf0c8..0d66a2957 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java @@ -3,12 +3,12 @@ package nautilus.game.arcade.kit.perks; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -37,23 +37,35 @@ public class PerkFletcher extends Perk private int _time = 0; private boolean _remove; private int _slot; + private boolean _instant = true; public PerkFletcher(int time, int max, boolean remove) { this(time, max, remove, -1); } + public PerkFletcher(int time, int max, boolean remove, boolean instant) + { + this(time, max, remove, -1, instant); + } + public PerkFletcher(int time, int max, boolean remove, int slot) + { + this(time, max, remove, slot, true); + } + + public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant) { super("Fletcher", new String[] { - C.cGray + "Receive 1 Arrow every " + time + " seconds. Maximum of " + max + ".", + "Receive 1 Arrow every " + time + " seconds. Maximum of " + max + ".", }); _time = time; _max = max; _remove = remove; _slot = slot; + _instant = instant; } public boolean isFletchedArrow(ItemStack stack) @@ -106,7 +118,12 @@ public class PerkFletcher extends Perk { if (event.getType() != UpdateType.FAST) return; - + + if (!UtilTime.elapsed(Manager.GetGame().getGameLiveTime(), _time * 1000) && !_instant) + { + return; + } + for (Player cur : UtilServer.getPlayers()) { if (Manager.isSpectator(cur)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIceBridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIceBridge.java new file mode 100644 index 000000000..f035af804 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIceBridge.java @@ -0,0 +1,184 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.data.IcePathData; + +public class PerkIceBridge extends Perk +{ + + private HashSet _data = new HashSet(); + public long _cooldown; + private long _bridgeUpTime; + + public PerkIceBridge(long cooldown, long bridgeUpTime) + { + super("Ice Bridge", new String[] { + C.cYellow + "Right Click" + C.cGray + " with Ice to create an " + C.cGreen + "Ice Bridge", + "Lasts for " + C.cGreen + UtilTime.convertString(bridgeUpTime, 0, TimeUnit.SECONDS) + C.cGray + ".", + "Cooldown " + C.cGreen + UtilTime.convertString(cooldown, 0, TimeUnit.SECONDS) + C.cGray + "." + }); + + _cooldown = cooldown; + _bridgeUpTime = bridgeUpTime; + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null) + { + return; + } + + if (player.getItemInHand().getType() != Material.ICE) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true)) + { + return; + } + + player.teleport(player.getLocation().add(0, 1, 0)); + UtilAction.velocity(player, new Vector(0, 0.5, 0)); + + _data.add(new IcePathData(player)); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } + + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator dataIterator = _data.iterator(); + + while (dataIterator.hasNext()) + { + IcePathData data = dataIterator.next(); + + Block block = data.GetNextBlock(); + + if (block == null) + { + dataIterator.remove(); + } + else + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79); + Manager.GetBlockRestore().add(block, 79, (byte) 0, _bridgeUpTime); + } + } + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (!hasPerk(player)) + { + return; + } + + if (itemStack == null) + { + return; + } + + if (itemStack.getItemMeta() == null) + { + return; + } + + if (itemStack.getItemMeta().getDisplayName() == null) + { + return; + } + + if (itemStack.getItemMeta().getDisplayName().contains(GetName())) + { + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot place this item.")); + } + } + + @EventHandler + public void onPlayerDropItem(PlayerDropItemEvent event) + { + if (!hasPerk(event.getPlayer())) + { + return; + } + + if (event.getItemDrop().getItemStack().getType() == Material.ICE) + { + event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + if (!hasPerk(event.getEntity())) + { + return; + } + + Iterator iterator = event.getDrops().iterator(); + + while (iterator.hasNext()) + { + ItemStack itemStack = iterator.next(); + + if (itemStack.getType() == Material.ICE) + { + iterator.remove(); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java index b1eafb953..ec662a740 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java @@ -5,7 +5,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import mineplex.core.common.util.C; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; @@ -17,7 +16,7 @@ public class PerkIronSkin extends Perk { super("Iron Skin", new String[] { - C.cGray + "You take " + d + " less damage from attacks", + "You take " + d + " less damage from attacks", }); _reduction = d; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockback.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockback.java index a3653f8ce..29ee1a737 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockback.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockback.java @@ -16,15 +16,23 @@ import nautilus.game.arcade.kit.Perk; public class PerkKnockback extends Perk { private double _power; + private boolean _onGround; public PerkKnockback(double power) + { + this(power, false); + } + + public PerkKnockback(double power, boolean onGround) { super("Knockback", new String[] { - C.cGray + "Attacks gives knockback with " + power + " power.", + C.cGray + "Attacks gives knockback with " + C.cGreen + power + C.cGray + " power.", + (onGround ? "Only works while you are on the ground." : "Works in the air and on the ground."), }); _power = power; + _onGround = onGround; } @EventHandler(priority = EventPriority.HIGH) @@ -33,11 +41,16 @@ public class PerkKnockback extends Perk Player damager = event.GetDamagerPlayer(false); if (damager == null) return; - if (!Kit.HasKit(damager)) + if (!hasPerk(damager)) return; if (!Manager.IsAlive(damager)) return; + + if (_onGround && !UtilEnt.isGrounded(event.GetDamageeEntity())) + { + return; + } event.SetKnockback(false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java new file mode 100644 index 000000000..915ab6004 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java @@ -0,0 +1,270 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.Iterator; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.skywars.TeamSkywars; +import nautilus.game.arcade.kit.Perk; + +public class PerkMagnetism extends Perk +{ + + private static final int RESISTANCE_DURATION = 40; + + private long _cooldown; + private int _range; + private double _magnituideFactor; + + public PerkMagnetism(long cooldown, int range, double magnitudeFactor) + { + super("Magnetism", new String[] { + }); + + _cooldown = cooldown; + _range = range; + _magnituideFactor = magnitudeFactor; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : UtilServer.getPlayers()) + { + if (!hasPerk(player) || UtilPlayer.isSpectator(player)) + { + continue; + } + + int magnituide = getAmountOfMetalArmor(player); + + if (magnituide == 0) + { + continue; + } + + player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, RESISTANCE_DURATION, magnituide - 1)); + } + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null) + { + return; + } + + if (player.getItemInHand().getType() != Material.REDSTONE_COMPARATOR) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + Player target = UtilPlayer.getPlayerInSight(player, _range, true); + + if (target == null) + { + return; + } + + Game game = Manager.GetGame(); + + if (game instanceof TeamSkywars) + { + if (game.GetTeam(player).equals(game.GetTeam(target))) + { + player.sendMessage(F.main("Game", "They are on your team!")); + return; + } + } + + int magnitude = getAmountOfMetalArmor(target); + + if (magnitude == 0) + { + player.sendMessage(F.main("Game", "They do not have any metal armor on.")); + return; + } + + if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true)) + { + return; + } + + Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName()); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 1, 1, 1, 0.01F, 20, ViewDist.NORMAL); + + Vector vector = UtilAlg.getTrajectory(target, player).multiply((.5 + magnitude / 4) * _magnituideFactor); + + UtilAction.velocity(target, vector.setY(Math.max(.6, vector.getY()))); + } + + @EventHandler + public void onPlayerPickupItem(PlayerPickupItemEvent event) + { + if (!hasPerk(event.getPlayer())) + { + return; + } + + ItemStack itemStack = event.getItem().getItemStack(); + + if (UtilItem.isDiamondProduct(itemStack) && UtilItem.isArmor(itemStack)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) + { + if (!hasPerk((Player) event.getWhoClicked())) + { + return; + } + + ItemStack itemStack = event.getCurrentItem(); + + if (UtilItem.isDiamondProduct(itemStack) && UtilItem.isArmor(itemStack)) + { + event.getWhoClicked().sendMessage(F.main("Game", "You cannot equip diamond armor.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + if (!hasPerk(event.getPlayer())) + { + return; + } + + Block block = event.getBlock(); + + if (block.getType() == Material.IRON_ORE) + { + block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.IRON_INGOT)); + } + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (!hasPerk(player)) + { + return; + } + + if (itemStack == null) + { + return; + } + + if (itemStack.getType() == Material.REDSTONE_COMPARATOR) + { + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot place this item.")); + } + } + + @EventHandler + public void onPlayerDropItem(PlayerDropItemEvent event) + { + if (!hasPerk(event.getPlayer())) + { + return; + } + + if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_COMPARATOR) + { + event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + Iterator iterator = event.getDrops().iterator(); + + while (iterator.hasNext()) + { + ItemStack itemStack = iterator.next(); + + if (itemStack.getType() == Material.REDSTONE_COMPARATOR) + { + iterator.remove(); + } + } + } + + private int getAmountOfMetalArmor(Player player) + { + int magnitude = 0; + + for (ItemStack itemStack : player.getInventory().getArmorContents()) + { + if (UtilItem.isIronProduct(itemStack) || UtilItem.isGoldProduct(itemStack) || UtilItem.isChainmailProduct(itemStack)) + { + if (UtilItem.isArmor(itemStack)) + { + magnitude++; + } + } + } + + return magnitude; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVoidSaver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVoidSaver.java new file mode 100644 index 000000000..e0624d332 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkVoidSaver.java @@ -0,0 +1,138 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.kit.Perk; + +public class PerkVoidSaver extends Perk +{ + + private Map _safeLocations = new HashMap<>(); + private List _used = new ArrayList<>(); + + public PerkVoidSaver() + { + super("Void Saver", new String[] { + }); + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null) + { + return; + } + + if (player.getItemInHand().getType() != Material.EYE_OF_ENDER) + { + return; + } + + event.setCancelled(true); + + if (!hasPerk(player) || _used.contains(player.getUniqueId())) + { + return; + } + + if (_safeLocations.get(player.getUniqueId()) == null) + { + return; + } + + player.teleport(_safeLocations.get(player.getUniqueId()).add(0, 2, 0)); + player.setFallDistance(0); + player.getInventory().remove(Material.EYE_OF_ENDER); + player.sendMessage(F.main("Game", "You used your safe teleport.")); + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 0); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 10, ViewDist.NORMAL); + _used.add(player.getUniqueId()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player) || _used.contains(player.getUniqueId()) || !UtilEnt.isGrounded(player)) + { + continue; + } + + _safeLocations.put(player.getUniqueId(), player.getLocation()); + } + } + + @EventHandler + public void onPlayerDropItem(PlayerDropItemEvent event) + { + if (event.getItemDrop().getItemStack().getType() == Material.EYE_OF_ENDER) + { + event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item.")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + Iterator iterator = event.getDrops().iterator(); + + while (iterator.hasNext()) + { + ItemStack itemStack = iterator.next(); + + if (itemStack.getType() == Material.EYE_OF_ENDER) + { + iterator.remove(); + } + } + } + + @EventHandler + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() == GameState.WinRoom) + { + _used.clear(); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index 9b47ccc27..896bfc317 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -1,24 +1,5 @@ package nautilus.game.arcade.managers; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; - import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -33,6 +14,23 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.stats.StatTracker; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; public class GameCreationManager implements Listener { @@ -175,7 +173,6 @@ public class GameCreationManager implements Listener // Manager.GetAntiStack().SetEnabled(true); Manager.getCosmeticManager().setHideParticles(false); Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.CustomWeaponName); - Manager.GetChat().setThreeSecondDelay(true); ItemStackFactory.Instance.SetUseCustomNames(false); HashMap pastTeams = null; @@ -511,27 +508,27 @@ public class GameCreationManager implements Listener { return value; } - else if (clazz == int.class) + else if (clazz == int.class || clazz == Integer.class) { return Integer.parseInt(value); } - else if (clazz == float.class) + else if (clazz == float.class || clazz == Float.class) { return Float.parseFloat(value); } - else if (clazz == double.class) + else if (clazz == double.class || clazz == Double.class) { return Double.parseDouble(value); } - else if (clazz == long.class) + else if (clazz == long.class || clazz == Long.class) { return Long.parseLong(value); } - else if (clazz == byte.class) + else if (clazz == byte.class || clazz == Byte.class) { return Byte.parseByte(value); } - else if (clazz == short.class) + else if (clazz == short.class || clazz == Short.class) { return Short.parseShort(value); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index c00b8f81d..2e1b90360 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.Managers; import mineplex.core.antihack.AntiHack; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Rank; @@ -720,7 +721,7 @@ public class GameFlagManager implements Listener player.removePotionEffect(potion.getType()); //Visual - Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false); +// Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false); player.setFireTicks(0); player.setFallDistance(0); @@ -1235,10 +1236,10 @@ public class GameFlagManager implements Listener public void AntiHackStrict(GameStateChangeEvent event) { if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Live) - AntiHack.Instance.setStrict(event.GetGame().StrictAntiHack); + Managers.get(AntiHack.class).setStrict(event.GetGame().StrictAntiHack); else - AntiHack.Instance.setStrict(true); + Managers.get(AntiHack.class).setStrict(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 7e877fba7..2d8ce0e93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -426,7 +426,14 @@ public class GameHostManager implements Listener msg += event.getMessage().split(" ")[i] + " "; } msg = msg.trim(); - + + msg = Manager.GetChat().getFilteredMessage(event.getPlayer(), msg); + + if (msg == null) + { + return; + } + Bukkit.broadcastMessage(C.cDGreen + C.Bold + event.getPlayer().getName() + " " + C.cGreen + msg); } @@ -677,11 +684,12 @@ public class GameHostManager implements Listener player.closeInventory(); } UtilPlayer.message(player, F.main("Server", "Your Co-Host privileges were removed.")); - - player.setGameMode(GameMode.SURVIVAL); - + if (isEventServer()) + { + player.setGameMode(GameMode.SURVIVAL); worldeditPermissionSet(player, false); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 87c345881..62e5a3711 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -2,12 +2,22 @@ package nautilus.game.arcade.managers; import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlockText; import mineplex.core.common.util.UtilBlockText.TextAlign; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.Donor; -import mineplex.core.elo.EloManager.EloDivision; import mineplex.core.event.CustomTagEvent; import mineplex.core.packethandler.PacketHandler; +import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -21,11 +31,22 @@ import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitSorter; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.DyeColor; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.*; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -33,15 +54,16 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.weather.WeatherChangeEvent; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Map.Entry; +import java.util.UUID; public class GameLobbyManager implements Listener { @@ -53,7 +75,7 @@ public class GameLobbyManager implements Listener private Location _teamText; private Location _kitDisplay; - private Location _teamDisplay; + private Location _teamDisplay; private Location spawn; @@ -67,32 +89,22 @@ public class GameLobbyManager implements Listener private Color _fireworkColor; private int _advertiseStage = 0; - - //Scoreboard - private NautHashMap _scoreboardMap = new NautHashMap(); - private NautHashMap _gemMap = new NautHashMap(); - private NautHashMap _eloMap = new NautHashMap(); - private NautHashMap _divisionMap = new NautHashMap(); - private NautHashMap _kitMap = new NautHashMap(); - - private int _oldPlayerCount = 0; - private int _oldMaxPlayerCount = 0; // Used for scoreboard when max player count changes private String _serverName; - - private boolean _colorTick = false; + + public boolean _colorTick = false; public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler) { Manager = manager; World world = UtilWorld.getWorld("world"); - + world.setTime(6000); world.setStorm(false); world.setThundering(false); world.setGameRuleValue("doDaylightCycle", "false"); - + spawn = new Location(world, 0, 104, 0); _gameText = new Location(world, 0, 130, 50); @@ -115,87 +127,9 @@ public class GameLobbyManager implements Listener _teamDisplay.setYaw(yaw); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - + _serverName = Manager.getPlugin().getConfig().getString("serverstatus.name"); - _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); - } - - private boolean HasScoreboard(Player player) - { - return _scoreboardMap.containsKey(player); - } - - public void CreateScoreboards() - { - for (Player player : UtilServer.getPlayers()) - { - CreateScoreboard(player, false); - } - - for (Player otherPlayer : UtilServer.getPlayers()) - { - AddPlayerToScoreboards(otherPlayer, null); - } - } - - private void CreateScoreboard(Player player, boolean resendToAll) - { - _scoreboardMap.put(player, Bukkit.getScoreboardManager().getNewScoreboard()); - - Scoreboard scoreboard = _scoreboardMap.get(player); - Objective objective = scoreboard.registerNewObjective("§l" + "Lobby", "dummy"); - objective.setDisplaySlot(DisplaySlot.SIDEBAR); - - for (Rank rank : Rank.values()) - { - if (rank == Rank.ALL) - { - scoreboard.registerNewTeam(rank.Name).setPrefix(""); - } - else - { - scoreboard.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + ChatColor.WHITE); - } - - if (Manager.GetGame() != null && !Manager.GetGame().GetTeamList().isEmpty()) - { - for (GameTeam team : Manager.GetGame().GetTeamList()) - { - if(team.GetDisplaytag()) - { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); - } - else - { - if (rank == Rank.ALL) - { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); - } - else - { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + team.GetColor()); - } - } - } - } - } - - if (resendToAll) - { - for (Player otherPlayer : UtilServer.getPlayers()) - { - String teamName = null; - if (Manager.GetGame() != null && Manager.GetGame().GetTeam(otherPlayer) != null) - teamName = Manager.GetGame().GetTeam(otherPlayer).GetName().toUpperCase(); - - AddPlayerToScoreboards(otherPlayer, teamName); - } - } - } - - public Collection GetScoreboards() - { - return _scoreboardMap.values(); + _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); } public void WriteLine(Player player, int x, int y, int z, BlockFace face, int line, String text) @@ -215,7 +149,7 @@ public class GameLobbyManager implements Listener } if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); UtilBlockText.MakeText(text, loc, face, id, data, TextAlign.CENTER); @@ -227,7 +161,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_gameText.getWorld(), _gameText.getX(), _gameText.getY(), _gameText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.WEST; @@ -239,7 +173,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_advText.getWorld(), _advText.getX(), _advText.getY(), _advText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.EAST; @@ -251,7 +185,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_kitText.getWorld(), _kitText.getX(), _kitText.getY(), _kitText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.NORTH; @@ -263,7 +197,7 @@ public class GameLobbyManager implements Listener Location loc = new Location(_teamText.getWorld(), _teamText.getX(), _teamText.getY(), _teamText.getZ()); if (line > 0) - loc.add(0, line*-6, 0); + loc.add(0, line * -6, 0); BlockFace face = BlockFace.SOUTH; @@ -286,24 +220,24 @@ public class GameLobbyManager implements Listener } @EventHandler(priority = EventPriority.MONITOR) - public void TeamGeneration(GameStateChangeEvent event) + public void TeamGeneration(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; if (event.GetGame().GetMode() == null) - WriteGameLine(event.GetGame().WorldData.MapName, 1, 159, (byte)4); + WriteGameLine(event.GetGame().WorldData.MapName, 1, 159, (byte) 4); else - WriteGameLine(event.GetGame().WorldData.MapName, 2, 159, (byte)4); - + WriteGameLine(event.GetGame().WorldData.MapName, 2, 159, (byte) 4); + CreateTeams(event.GetGame()); } public void CreateTeams(Game game) { //Text - WriteTeamLine("Select", 0, 159, (byte)15); - WriteTeamLine("Team", 1, 159, (byte)4); + WriteTeamLine("Select", 0, 159, (byte) 15); + WriteTeamLine("Team", 1, 159, (byte) 4); //Remove Old Ents for (Entity ent : _teams.keySet()) @@ -314,33 +248,32 @@ public class GameLobbyManager implements Listener for (Block block : _teamBlocks.keySet()) block.setType(_teamBlocks.get(block)); _teamBlocks.clear(); - + //Smash if (game.HideTeamSheep) { //Text - WriteTeamLine("Select", 0, 159, (byte)15); - WriteTeamLine("Kit", 1, 159, (byte)4); - - CreateScoreboards(); + WriteTeamLine("Select", 0, 159, (byte) 15); + WriteTeamLine("Kit", 1, 159, (byte) 4); + return; } - + //UHC if (game.GetType() == GameType.UHC || game.getClass().getSuperclass().equals(UHC.class)) { if (game.GetTeamList().size() > 1) { //Text - WriteTeamLine("", 0, 159, (byte)15); - WriteTeamLine("", 1, 159, (byte)4); - - for (int i=0 ; i 1 || game.GetTeamList().size() < 6) && game.GetType() != GameType.SurvivalGamesTeams) { //Display ArrayList teams = new ArrayList(); - + for (GameTeam team : game.GetTeamList()) if (team.GetVisible()) teams.add(team); - - //Positions - double space = 6; - double offset = (teams.size()-1)*space/2d; - for (int i=0 ; i teamsA = new ArrayList(); ArrayList teamsB = new ArrayList(); - - for (int i=0 ; i blockMap) + public void SetKitTeamBlocks(Location loc, int id, byte data, NautHashMap blockMap) { //Coloring - Block block = loc.clone().add( 0.5, 0, 0.5).getBlock(); + Block block = loc.clone().add(0.5, 0, 0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); - block = loc.clone().add(-0.5, 0, 0.5).getBlock(); + block = loc.clone().add(-0.5, 0, 0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); - block = loc.clone().add( 0.5, 0, -0.5).getBlock(); + block = loc.clone().add(0.5, 0, -0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); @@ -744,28 +675,28 @@ public class GameLobbyManager implements Listener MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); //Top - block = loc.clone().add( 0.5, 1, 0.5).getBlock(); + block = loc.clone().add(0.5, 1, 0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); - block = loc.clone().add(-0.5, 1, 0.5).getBlock(); + block = loc.clone().add(-0.5, 1, 0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); - block = loc.clone().add( 0.5, 1, -0.5).getBlock(); + block = loc.clone().add(0.5, 1, -0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); block = loc.clone().add(-0.5, 1, -0.5).getBlock(); blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte)5); + MapUtil.QuickChangeBlockAt(block.getLocation(), 44, (byte) 5); //Floor - for (int x=-2 ; x<2 ; x++) + for (int x = -2; x < 2; x++) { - for (int z=-2 ; z<2 ; z++) + for (int z = -2; z < 2; z++) { - block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); + block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); blockMap.put(block, block.getType()); MapUtil.QuickChangeBlockAt(block.getLocation(), id, data); @@ -773,34 +704,26 @@ public class GameLobbyManager implements Listener } //Outline - for (int x=-3 ; x<3 ; x++) + for (int x = -3; x < 3; x++) { - for (int z=-3 ; z<3 ; z++) + for (int z = -3; z < 3; z++) { - block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); + block = loc.clone().add(x + 0.5, -1, z + 0.5).getBlock(); if (blockMap.containsKey(block)) continue; blockMap.put(block, block.getType()); - MapUtil.QuickChangeBlockAt(block.getLocation(), 35, (byte)15); + MapUtil.QuickChangeBlockAt(block.getLocation(), 35, (byte) 15); } } } - + public void AddKitLocation(Entity ent, Kit kit, Location loc) { _kits.put(ent, new LobbyEnt(ent, loc, kit)); } - @EventHandler - public void PlayerQuit(PlayerQuitEvent event) - { - _scoreboardMap.remove(event.getPlayer()); - _gemMap.remove(event.getPlayer()); - _kitMap.remove(event.getPlayer()); - } - @EventHandler(priority = EventPriority.LOWEST) public void DamageCancel(CustomDamageEvent event) { @@ -809,7 +732,7 @@ public class GameLobbyManager implements Listener } @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() == UpdateType.FAST) { @@ -829,24 +752,24 @@ public class GameLobbyManager implements Listener UpdateAdvertise(); ScoreboardDisplay(event); - ScoreboardSet(event); } - + @EventHandler - public void onWeather(WeatherChangeEvent event) { - + public void onWeather(WeatherChangeEvent event) + { + if (!event.getWorld().equals(spawn.getWorld())) return; - + event.setCancelled(true); } - + @EventHandler - private void RemoveInvalidEnts(GameStateChangeEvent event) + private void RemoveInvalidEnts(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; - + for (Entity ent : UtilWorld.getWorld("world").getEntities()) { if (ent instanceof Creature || ent instanceof Slime) @@ -859,19 +782,19 @@ public class GameLobbyManager implements Listener if (ent.getPassenger() != null) continue; - + ent.remove(); } } } - private void UpdateAdvertise() + private void UpdateAdvertise() { if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit) return; - - _advertiseStage = (_advertiseStage+1)%2; - + + _advertiseStage = (_advertiseStage + 1) % 2; + if (Manager.GetGame().AdvertiseText(this, _advertiseStage)) { return; @@ -879,19 +802,19 @@ public class GameLobbyManager implements Listener if (_advertiseStage == 0) { - WriteAdvertiseLine("GET MINEPLEX ULTRA", 0, 159, (byte)4); - WriteAdvertiseLine("FOR AMAZING", 1, 159, (byte)15); - WriteAdvertiseLine("FUN TIMES", 2, 159, (byte)15); + WriteAdvertiseLine("GET MINEPLEX ULTRA", 0, 159, (byte) 4); + WriteAdvertiseLine("FOR AMAZING", 1, 159, (byte) 15); + WriteAdvertiseLine("FUN TIMES", 2, 159, (byte) 15); - WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)15); + WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte) 15); } else if (_advertiseStage == 1) { - WriteAdvertiseLine("KEEP CALM", 0, 159, (byte)4); - WriteAdvertiseLine("AND", 1, 159, (byte)15); - WriteAdvertiseLine("PLAY MINEPLEX", 2, 159, (byte)4); + WriteAdvertiseLine("KEEP CALM", 0, 159, (byte) 4); + WriteAdvertiseLine("AND", 1, 159, (byte) 15); + WriteAdvertiseLine("PLAY MINEPLEX", 2, 159, (byte) 4); - WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)15); + WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte) 15); } } @@ -927,9 +850,9 @@ public class GameLobbyManager implements Listener if (winnerTeam != null) { _fireworkColor = Color.GREEN; - if (winnerTeam.GetColor() == ChatColor.RED) _fireworkColor = Color.RED; - if (winnerTeam.GetColor() == ChatColor.AQUA) _fireworkColor = Color.BLUE; - if (winnerTeam.GetColor() == ChatColor.YELLOW) _fireworkColor = Color.YELLOW; + if (winnerTeam.GetColor() == ChatColor.RED) _fireworkColor = Color.RED; + if (winnerTeam.GetColor() == ChatColor.AQUA) _fireworkColor = Color.BLUE; + if (winnerTeam.GetColor() == ChatColor.YELLOW) _fireworkColor = Color.YELLOW; _fireworkStart = System.currentTimeMillis(); } @@ -940,12 +863,12 @@ public class GameLobbyManager implements Listener if (UtilTime.elapsed(_fireworkStart, 10000)) return; - UtilFirework.playFirework(spawn.clone().add(Math.random()*160-80, 30 + Math.random()*10, Math.random()*160-80), + UtilFirework.playFirework(spawn.clone().add(Math.random() * 160 - 80, 30 + Math.random() * 10, Math.random() * 160 - 80), Type.BALL_LARGE, _fireworkColor, false, false); } @EventHandler - public void Combust(EntityCombustEvent event) + public void Combust(EntityCombustEvent event) { for (LobbyEnt ent : _kits.values()) if (event.getEntity().getWorld().getUID().equals(ent.GetEnt().getWorld().getUID()) && @@ -956,21 +879,21 @@ public class GameLobbyManager implements Listener } } - public void DisplayLast(Game game) + public void DisplayLast(Game game) { //Start Fireworks RegisterFireworks(game.WinnerTeam); } - public void DisplayNext(Game game, HashMap pastTeams) + public void DisplayNext(Game game, HashMap pastTeams) { - WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte)14); - + WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte) 14); + if (Manager.GetGame().GetMode() == null) - WriteGameLine(" ", 1, 159, (byte)1); + WriteGameLine(" ", 1, 159, (byte) 1); else - WriteGameLine(Manager.GetGame().GetMode(), 1, 159, (byte)1); - + WriteGameLine(Manager.GetGame().GetMode(), 1, 159, (byte) 1); + DisplayWaiting(); CreateKits(game); CreateTeams(game); @@ -978,7 +901,7 @@ public class GameLobbyManager implements Listener public void DisplayWaiting() { - WriteGameLine("waiting for players", 3, 159, (byte)13); + WriteGameLine("waiting for players", 3, 159, (byte) 13); } @EventHandler @@ -987,199 +910,64 @@ public class GameLobbyManager implements Listener if (event.getType() != UpdateType.FAST) return; - if (Manager.GetGame() != null && - (Manager.GetGame().GetState() != GameState.Loading && - Manager.GetGame().GetState() != GameState.Recruit)) + if (Manager.GetGame() != null && + (Manager.GetGame().GetState() != GameState.Loading && + Manager.GetGame().GetState() != GameState.Recruit)) { for (Player player : UtilServer.getPlayers()) - player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard()); //XXX + player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); //XXX } else { - for (Player player : UtilServer.getPlayers()) + for (Entry ent : Manager.getScoreboardManager().getScoreboards().entrySet()) { - if (!HasScoreboard(player)) + if (Bukkit.getPlayer(ent.getKey()) != null) { - CreateScoreboard(player, true); - } - else - { - player.setScoreboard(_scoreboardMap.get(player)); + Bukkit.getPlayer(ent.getKey()).setScoreboard(ent.getValue().getHandle()); } } } } - - //this is called from above - public void ScoreboardSet(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (Manager.GetGame() != null && !Manager.GetGame().DisplayLobbySide) - { - return; - } - - _colorTick = !_colorTick; - - int spectatorCount = 0; - - for(Player players : UtilServer.GetPlayers()) - { - if (Manager.isVanished(players)) - { - spectatorCount++; - } - } - - for (Entry entry : _scoreboardMap.entrySet()) - { - Objective objective = entry.getValue().getObjective("§l" + "Lobby"); - - if (Manager.GetGame() != null && Manager.GetGame().GetCountdown() >= 0) - { - if (Manager.GetGame().GetCountdown() > 0) - objective.setDisplayName(C.Bold + "§lStarting in " + C.cGreen + "§l" + Manager.GetGame().GetCountdown() + (Manager.GetGame().GetCountdown() == 1 ? " Second" : " Seconds")); - else if (Manager.GetGame().GetCountdown() == 0) - objective.setDisplayName(ChatColor.WHITE + "§lIn Progress..."); - } - else - { - if (Manager.GetGame() instanceof UHC && !((UHC)Manager.GetGame()).isMapLoaded()) - { - objective.setDisplayName(((UHC) Manager.GetGame()).getObjectiveName(_colorTick)); - } - else - { - objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players"); - } - } - - int line = 15; - - objective.getScore(" ").setScore(line--); - - objective.getScore(C.cYellow + C.Bold + "Players").setScore(line--); - - // Remove Old - entry.getValue().resetScores(_oldPlayerCount + "/" + _oldMaxPlayerCount); - // Set new - - objective.getScore(UtilServer.getPlayers().length - spectatorCount + "/" + Manager.GetPlayerFull()).setScore(line--); - - if (Manager.GetGame() != null) - { - ChatColor teamColor = ChatColor.GRAY; - String kitName = "None"; - - if (Manager.GetGame().GetTeam(entry.getKey()) != null) - { - teamColor = Manager.GetGame().GetTeam(entry.getKey()).GetColor(); - } - - if (Manager.GetGame().GetKit(entry.getKey()) != null) - { - kitName = Manager.GetGame().GetKit(entry.getKey()).GetName() + ""; - } - - if (teamColor == null) - - //Shorten Kit Name - if (kitName.length() > 16) - kitName = kitName.substring(0, 16); - - // Remove old - //entry.getValue().resetScores(teamColor + C.Bold + "Kit"); - for(String string : entry.getValue().getEntries()) - { - if(string.endsWith("Kit")) - { - entry.getValue().resetScores(string); - } - } - entry.getValue().resetScores(_kitMap.get(entry.getKey()) + ""); - - // Set new - objective.getScore(" ").setScore(line--); - objective.getScore(teamColor + C.Bold + "Kit").setScore(line--); - objective.getScore(kitName + "").setScore(line--); - - _kitMap.put(entry.getKey(), kitName + ""); - } - - objective.getScore(" ").setScore(line--); - objective.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); - - // Remove old - entry.getValue().resetScores(_gemMap.get(entry.getKey()) + " "); - // Set new - objective.getScore(Manager.GetDonation().Get(entry.getKey().getName()).GetGems() + " ").setScore(line--); - - _gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).GetGems()); - - //Server - objective.getScore(" ").setScore(line--); - objective.getScore(C.cAqua + C.Bold + "Server").setScore(line--); - objective.getScore(_serverName).setScore(line--); - - // ELO DIVISION - if (Manager.GetGame() != null && Manager.GetGame().EloRanking) - { - objective.getScore(" ").setScore(line--); - objective.getScore(C.cPurpleB + C.Bold + "Division").setScore(line--); - - // Remove old - entry.getValue().resetScores(_divisionMap.get(entry.getKey()) + " "); - // Set new - EloDivision ed = EloDivision.getDivision(Manager.getEloManager().getElo(entry.getKey(), Manager.GetGame().GetType().getGameId())); - objective.getScore(ed.getDisplayName() + " ").setScore(line--); - } - } - - _oldPlayerCount = UtilServer.getPlayers().length - spectatorCount; - _oldMaxPlayerCount = Manager.GetPlayerFull(); - } private String GetKitCustomName(Player player, Game game, LobbyEnt ent) { CoreClient client = Manager.GetClients().Get(player); - Donor donor = Manager.GetDonation().Get(player.getName()); + Donor donor = Manager.GetDonation().Get(player); String entityName = ent.GetKit().GetName(); if (!player.isOnline() || client == null || donor == null) return entityName; - + if (client.GetRank() == null) { System.out.println("client rank is null"); } - + if (game == null) { System.out.println("game is null"); } - + if (Manager == null) { System.out.println("Manager is null"); } - + if (Manager.GetServerConfig() == null) { System.out.println("Manager.GetServerConfig() is null"); } - - if (ent.GetKit().GetAvailability() == KitAvailability.Free || //Free - Manager.hasKitsUnlocked(player) || //YouTube - (ent.GetKit().GetAvailability() == KitAvailability.Achievement && - Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement - donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green - Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF - donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) - Manager.GetServerConfig().Tournament) //Tournament + + if (ent.GetKit().GetAvailability() == KitAvailability.Free || //Free + Manager.hasKitsUnlocked(player) || //YouTube + (ent.GetKit().GetAvailability() == KitAvailability.Achievement && + Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green + Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF + donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) + Manager.GetServerConfig().Tournament) //Tournament { entityName = ent.GetKit().GetAvailability().GetColor() + entityName; } @@ -1222,120 +1010,149 @@ public class GameLobbyManager implements Listener } } - public void AddPlayerToScoreboards(Player player, String teamName) - { - if (teamName == null) - teamName = ""; + public void AddPlayerToScoreboards(Player player, GameTeam gameTeam) + { + Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + String teamId = getTeamId(gameTeam, player); + + for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values()) + { + Team team = scoreboard.getHandle().getTeam(teamId); + if (team == null) + { + team = scoreboard.getHandle().registerNewTeam(teamId); + if (gameTeam != null) + { + if (gameTeam.GetDisplaytag()) + { + team.setPrefix(gameTeam.GetColor() + C.Bold + gameTeam.GetName() + gameTeam.GetColor() + " "); + } + else + { + if (rank == Rank.ALL) + { + team.setPrefix(gameTeam.GetColor() + ""); + } + else + { + team.setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + gameTeam.GetColor()); + } + } + } + } + team.addEntry(player.getName()); + } + } + + public void RemovePlayerFromTeam(Player player, GameTeam gameTeam) + { + Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + + String teamId = getTeamId(gameTeam, player); + + for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values()) + { + Team team = scoreboard.getHandle().getTeam(teamId); + if (team != null) + { + team.removeEntry(player.getName()); + } + scoreboard.getHandle().getTeam(rank.Name).addEntry(player.getName()); + } + } + + public String getTeamId(GameTeam gameTeam, Player player) + { + Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + String rankName = rank.Name; + boolean rankIsUltra = !rank.has(Rank.ULTRA) && + Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - String rankName = Manager.GetClients().Get(player).GetRank().Name; - boolean rankIsUltra = !Manager.GetClients().Get(player).GetRank().has(Rank.ULTRA) && Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - if (rankIsUltra) { rankName = Rank.ULTRA.Name; } - - String rankTeamName = rankName + teamName; - for (Scoreboard scoreboard : GetScoreboards()) + String teamId; + if (gameTeam != null && gameTeam.GetDisplaytag()) { - try + teamId = "GT" + String.valueOf(gameTeam.getTeamId()); + } + else + { + teamId = rankName; + + if (gameTeam != null && gameTeam.GetColor() != null) { - scoreboard.getTeam(rankTeamName).addPlayer(player); - } - catch (Exception e) - { - //UHC adds people to teams earlier than usual, which can case this - if (Manager.GetGame() instanceof UHC) - { - try - { - Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName).addPlayer(player); - System.out.println("GameLobbyManager UHC Team Assignment Success"); - break; - } - catch(Exception f) - { - System.out.println("GameLobbyManager AddPlayerToScoreboard UHC Error"); - System.out.println("[" + teamName + "] adding [" + player.getName() + "]"); - System.out.println("Team is Null [" + (Manager.GetGame().GetScoreboard().GetScoreboard().getTeam(teamName) == null) + "]"); - } - } - else - { - System.out.println("GameLobbyManager AddPlayerToScoreboard Error"); - System.out.println("[" + rankTeamName + "] adding [" + player.getName() + "]"); - System.out.println("Team is Null [" + (scoreboard.getTeam(rankTeamName) == null) + "]"); - } + teamId += "." + gameTeam.GetColor().getChar(); } } - - + return teamId; } - + @EventHandler public void disallowInventoryClick(InventoryClickEvent event) { if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() != GameState.Recruit) return; - + if (event.getInventory().getType() == InventoryType.CRAFTING) { event.setCancelled(true); event.getWhoClicked().closeInventory(); } } - + @EventHandler public void InventoryUpdate(UpdateEvent event) { if (!Manager.IsHotbarInventory()) return; - + if (event.getType() != UpdateType.FAST) - return; - + return; + if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() != GameState.Recruit && Manager.GetGame().GadgetsDisabled) return; - + for (Player player : UtilServer.getPlayers()) { if (player.getOpenInventory().getType() != InventoryType.CRAFTING) continue; - + //Cosmetic Menu Manager.getCosmeticManager().giveInterfaceItem(player); Manager.getBoosterManager().giveInterfaceItem(player); } } - + @EventHandler(priority = EventPriority.LOWEST) public void explodeBlockBreakFix(EntityExplodeEvent event) { if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() == GameState.Live) return; event.blockList().clear(); } - + @EventHandler(priority = EventPriority.LOWEST) public void velocityEventCancel(PlayerVelocityEvent event) { if (Manager.GetGame() == null) return; - + if (Manager.GetGame().GetState() == GameState.Live) return; - + event.setCancelled(true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index cadc5f53c..d6403af05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -519,7 +519,7 @@ public class GameManager implements Listener Game game = Manager.GetGame(); if (game == null) return; - game.GetScoreboard().UpdateTitle(); + game.GetScoreboard().updateTitle(); } @EventHandler(priority = EventPriority.LOWEST) //BEFORE PARSE DATA @@ -577,15 +577,6 @@ public class GameManager implements Listener game.ParseData(); } - @EventHandler(priority = EventPriority.MONITOR) - public void TeamScoreboardCreation(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - event.GetGame().GetScoreboard().CreateTeams(); - } - public void TeamPreferenceJoin(Game game) { //Preferred Team No Longer Full @@ -832,17 +823,7 @@ public class GameManager implements Listener }, i); } } - - @EventHandler - public void disguiseClean(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Dead) - return; - Manager.GetDisguise().clearDisguises(); - } - - @EventHandler public void WorldFireworksUpdate(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index d102b87dd..1401e987f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.managers; -import java.util.ArrayList; - import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -9,6 +7,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; import mineplex.core.common.util.UtilTime; +import mineplex.core.party.PartyManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -23,7 +22,6 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.ProgressingKit; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -42,6 +40,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.scheduler.BukkitRunnable; +import java.util.ArrayList; + public class GamePlayerManager implements Listener { ArcadeManager Manager; @@ -119,9 +119,6 @@ public class GamePlayerManager implements Listener UtilTabTitle.setHeaderAndFooter(player, Manager.GetGame() != null ? C.cGold + C.Bold + Manager.GetGame().GetType().GetName() : " ", "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); - - //Lobby Name - Manager.GetLobby().AddPlayerToScoreboards(player, null); //Lobby Spawn if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) @@ -155,6 +152,7 @@ public class GamePlayerManager implements Listener player.sendMessage(F.main("Kit", "No default kit found for " + C.cGreenB + Manager.GetGame().GetName())); } }.runTaskLater(Manager.getPlugin(), 10L); + player.getInventory().setItem(PartyManager.INTERFACE_SLOT, PartyManager.INTERFACE_ITEM); return; } @@ -177,7 +175,7 @@ public class GamePlayerManager implements Listener UtilPlayer.message(player, F.main("Game", Manager.GetGame().GetName() + " is in progress, please wait for next game!")); } - player.setScoreboard(Manager.GetGame().GetScoreboard().GetScoreboard()); + player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index c39b46247..2b60a12da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -1,28 +1,11 @@ package nautilus.game.arcade.managers; -import java.lang.reflect.Field; -import java.util.HashMap; - -import org.bukkit.Bukkit; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - import com.mojang.authlib.GameProfile; - import mineplex.core.achievement.Achievement; import mineplex.core.boosters.Booster; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.serverdata.Utility; @@ -37,6 +20,17 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GemData; import net.minecraft.server.v1_8_R3.EntityHuman; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.lang.reflect.Field; +import java.util.HashMap; /** * This class is used to reward gems and shards at the end of a game, or when players leave the server. @@ -184,8 +178,8 @@ public class GameRewardManager implements Listener if(Manager.GetClients().Get(player).getDisguisedAs() != null) { - changeName(player, Manager.GetClients().Get(player).GetPlayerName()); - System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName()); + changeName(player, Manager.GetClients().Get(player).getName()); + System.out.println("Gems for " + Manager.GetClients().Get(player).getName()); } // Award players shards equal to base gems, plus booster bonuses. @@ -202,7 +196,7 @@ public class GameRewardManager implements Listener // Gem Finder if (game.GemHunterEnabled) { - int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); + int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { gemsToReward += (int)(baseGemsEarned * (gemFinder * 0.25)); @@ -327,7 +321,7 @@ public class GameRewardManager implements Listener //Gem Finder if (game.GemHunterEnabled) { - int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); + int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " + @@ -405,8 +399,8 @@ public class GameRewardManager implements Listener if (give) { UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + - C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + - F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getName()).getCoins() + shards) + " Treasure Shards")); + C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + + F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards")); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java index 8e6088764..21132157e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java @@ -46,9 +46,9 @@ import java.util.UUID; public class GameSpectatorManager implements Listener, IPacketHandler { // A map of a player UUID to the UUID of the entity they want to spectate - private Map _pendingSpectate = Collections.synchronizedMap(new HashMap<>()); + private final Map _pendingSpectate = Collections.synchronizedMap(new HashMap<>()); - private ArcadeManager _manager; + private final ArcadeManager _manager; public GameSpectatorManager(ArcadeManager manager) { @@ -70,11 +70,6 @@ public class GameSpectatorManager implements Listener, IPacketHandler if (!_manager.GetGame().IsAlive(player)) event.setCancelled(true); - processClick(player, event.getAction()); - } - - public void processClick(Player player, Action action) - { if (_manager.GetGame() == null) return; @@ -102,7 +97,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler break; } - if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) + if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) currentPlayer = currentPlayer - 2; else return; @@ -212,6 +207,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler } } + // todo what if we cancel this event? @EventHandler(priority = EventPriority.LOW) public void dismountEntity(PlayerToggleSneakEvent event) { @@ -284,6 +280,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler _pendingSpectate.put(player.getUniqueId(), target.getUniqueId()); EntityPlayer ep = ((CraftPlayer) player).getHandle(); + EntityTracker tracker = ep.u().getTracker(); EntityTrackerEntry entry = tracker.trackedEntities.get(target.getEntityId()); @@ -300,6 +297,7 @@ public class GameSpectatorManager implements Listener, IPacketHandler UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating.")); _pendingSpectate.remove(player.getUniqueId()); + return; } // We still set spectating here even though it's pointless because of updateSpecEntites() above diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java index 44dd582f0..698cc5a92 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTournamentManager.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -123,8 +124,9 @@ public class GameTournamentManager implements Listener if (!Manager.IsTournamentPoints()) return; - for (Scoreboard scoreboard : Manager.GetLobby().GetScoreboards()) + for (MineplexScoreboard mpscoreboard : Manager.getScoreboardManager().getScoreboards().values()) { + Scoreboard scoreboard = mpscoreboard.getHandle(); Objective objective = scoreboard.getObjective(DisplaySlot.BELOW_NAME); if (objective == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index 7895fb33c..da35b59cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -24,6 +24,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -117,7 +118,14 @@ public class ProgressingKitManager implements Listener { return; } - new KitDisplayMenu((ProgressingKit) kit).open(player); + new KitDisplayMenu((ProgressingKit) kit, _manager.getKitProgressionManager()).open(player); + } + + @EventHandler + public void onAsyncPreLogin(AsyncPlayerPreLoginEvent event) + { + UUID uuid = event.getUniqueId(); + _manager.getKitProgressionManager().getRepository().loadInfoSync(uuid); } @EventHandler @@ -125,7 +133,6 @@ public class ProgressingKitManager implements Listener { Player player = event.getPlayer(); PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); - if (playerKit == null) { new BukkitRunnable() @@ -135,7 +142,6 @@ public class ProgressingKitManager implements Listener { _manager.getKitProgressionManager().getRepository().getInfo(player.getUniqueId()); } - }.runTaskLater(_manager.getPlugin(), 5L); } } @@ -163,19 +169,26 @@ public class ProgressingKitManager implements Listener { //This needs to stay in for testing sakes if the issue arises connor String message = event.getMessage(); - if(!event.getPlayer().getName().equalsIgnoreCase("TadahTech")) + String user = event.getPlayer().getName(); + + if(user.equalsIgnoreCase("TadahTech") || user.equalsIgnoreCase("Moppletop")) { - return; + if(message.startsWith("/kpsetlevel")) + { + event.setCancelled(true); + int level = Integer.parseInt(message.split(" ")[1]); + ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); + kit.setLevel(level, event.getPlayer().getUniqueId()); + event.getPlayer().sendMessage("Set level for "+ kit.GetName() + " to " + level); + } + else if (message.startsWith("/kpclearupgrades")) + { + event.setCancelled(true); + ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); + kit.setUpgradeLevel(0, event.getPlayer().getUniqueId()); + event.getPlayer().sendMessage("Cleared the upgrades for " + kit.GetName()); + } } - if(!message.startsWith("/kpsetlevel")) - { - return; - } - event.setCancelled(true); - int level = Integer.parseInt(message.split(" ")[1]); - ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); - kit.setLevel(level, event.getPlayer().getUniqueId()); - event.getPlayer().sendMessage("Set level for "+ kit.GetName() + " to " + level); } @EventHandler @@ -205,116 +218,133 @@ public class ProgressingKitManager implements Listener private void resetDefaultKits() { - Lists.newArrayList(UtilServer.getPlayers()).stream() - .forEach(player -> { - for (Kit kit : _manager.GetGame().GetKits()) - { - //Set default kit - if (kit instanceof ProgressingKit) - { - ProgressingKit progressingKit = (ProgressingKit) kit; - if (progressingKit.isDefault(player.getUniqueId())) - { - progressingKit.onSelected(player.getUniqueId()); - break; - } - } - } - }); + Lists.newArrayList(UtilServer.getPlayers()).forEach(player -> + { + for (Kit kit : _manager.GetGame().GetKits()) + { + //Set default kit + if (kit instanceof ProgressingKit) + { + ProgressingKit progressingKit = (ProgressingKit) kit; + if (progressingKit.isDefault(player.getUniqueId())) + { + progressingKit.onSelected(player.getUniqueId()); + break; + } + } + } + }); } private void displayKitData() { - Lists.newArrayList(UtilServer.getPlayers()).stream() - .forEach(player -> { - KitProgressionData data = _data.remove(player.getUniqueId()); - if (data == null) - { - return; - } + Lists.newArrayList(UtilServer.getPlayers()).forEach(player -> + { + KitProgressionData data = _data.remove(player.getUniqueId()); - player.sendMessage(SPACE); + if (data == null) + { + return; + } - player.sendMessage(LINE); - player.sendMessage(INFO); - player.sendMessage(SPACE); + player.sendMessage(SPACE); - int xpGained = data.getXpGained(); - ProgressingKit kit = data.getKit(); + player.sendMessage(LINE); + player.sendMessage(INFO); + player.sendMessage(SPACE); - PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); + int xpGained = data.getXpGained(); + ProgressingKit kit = data.getKit(); - //We only want them leveling up once a game, and to make sure XP stays the same - //Limit their total gained to the max amount they can gain, if they've reached it or exceeded it - if (xpGained >= Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()))) - { - xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())); - } + PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); + + if(playerKit.getLevel(kit.getInternalName()) >= 100) + { + StringBuilder builder = new StringBuilder(); + String kitName = C.cGoldB + kit.getDisplayName(); + + //Name of the kit + builder.append(kitName).append(" ").append(C.Reset).append(C.cGoldB).append("MAX LEVEL"); + + player.sendMessage(builder.toString()); + player.sendMessage(C.cWhite + "You maxed out this kit! Great job, and thanks for playing on Mineplex!"); + + player.sendMessage(SPACE); + player.sendMessage(LINE); + return; + } + + //We only want them leveling up once a game, and to make sure XP stays the same + //Limit their total gained to the max amount they can gain, if they've reached it or exceeded it + if (xpGained >= Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()))) + { + xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())); + } - kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId()); - boolean leveledUp = false; + kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId()); + boolean leveledUp = false; - if (kit.isLevelUpReady(player.getUniqueId())) - { - leveledUp = true; - kit.levelUp(player.getUniqueId()); - } + if (kit.isLevelUpReady(player.getUniqueId())) + { + leveledUp = true; + kit.levelUp(player.getUniqueId()); + } - int currentLevel = kit.getLevel(player.getUniqueId()); - int difference = kit.getXpDifference(player.getUniqueId()); + int currentLevel = kit.getLevel(player.getUniqueId()); + int difference = kit.getXpDifference(player.getUniqueId()); - //We shouldn't need to update the database, but there are some cases where we'll need too (found through testing) - _manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, kit.getInternalName()); + //We shouldn't need to update the database, but there are some cases where we'll need too (found through testing) + _manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, kit.getInternalName()); - StringBuilder builder = new StringBuilder(); - String kitName = C.cGoldB + kit.getDisplayName(); + StringBuilder builder = new StringBuilder(); + String kitName = C.cGoldB + kit.getDisplayName(); - //Name of the kit - builder.append(kitName) - .append(" ") - .append(C.Reset); + //Name of the kit + builder.append(kitName) + .append(" ") + .append(C.Reset); - //Current level out of 100 - builder.append(C.cYellow) - .append(currentLevel) - .append(C.cGold) - .append("/") - .append(C.cYellow) - .append(100) - .append(" ") - .append(C.Reset); + //Current level out of 100 + builder.append(C.cYellow) + .append(currentLevel) + .append(C.cGold) + .append("/") + .append(C.cYellow) + .append(100) + .append(" ") + .append(C.Reset); - //The amount of XP the player gained - builder.append(C.cGreen) - .append("+") - .append(xpGained) - .append(" ") - .append(C.Reset); + //The amount of XP the player gained + builder.append(C.cGreen) + .append("+") + .append(xpGained) + .append(" ") + .append(C.Reset); - if (!leveledUp) - { - //The XP required to level up - builder.append(C.cYellow) - .append(difference) - .append(" to next level"); - } else - { - builder.append(C.cAquaB) - .append("LEVEL UP! ") - .append(C.cYellow) - .append(Calculations.getXpForNextLevel(currentLevel)) - .append(" to next level"); - player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); - } + if (!leveledUp) + { + //The XP required to level up + builder.append(C.cYellow) + .append(difference) + .append(" to next level"); + } else + { + builder.append(C.cAquaB) + .append("LEVEL UP! ") + .append(C.cYellow) + .append(Calculations.getXpForNextLevel(currentLevel)) + .append(" to next level"); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + } - //Send the message finally - player.sendMessage(builder.toString()); - player.sendMessage(C.cWhite + "Level up by using this kit in game!"); + //Send the message finally + player.sendMessage(builder.toString()); + player.sendMessage(C.cWhite + "Level up by using this kit in game!"); - player.sendMessage(SPACE); - player.sendMessage(LINE); - }); + player.sendMessage(SPACE); + player.sendMessage(LINE); + }); } public void addData(Player player, int xpGained, Game game, ProgressingKit kit) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 996fc364c..0e91e1cc8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.managers.chat; -import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -11,6 +10,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.UUID; public class GameChatManager implements Listener { @@ -81,18 +82,7 @@ public class GameChatManager implements Listener if (!_manager.GetGame().IsAlive(sender)) dead = C.cGray + "Dead " + C.Reset; - Rank rank = _manager.GetClients().Get(sender).GetRank(); - String disguiseTag = ""; - if(_manager.GetClients().Get(sender).isDisguised()) - { - CoreClient cc = _manager.GetClients().Get(sender); - rank = cc.getDisguisedRank(); - - if(!cc.GetRank().has(Rank.JNR_DEV)) - { - disguiseTag = ChatColor.BLACK + " "; - } - } + Rank rank = _manager.GetClients().Get(sender).getRealOrDisguisedRank(); //Level String levelStr = ""; @@ -122,7 +112,7 @@ public class GameChatManager implements Listener } //Party Chat - if (event.getMessage().charAt(0) == '#') + if (event.getMessage().charAt(0) == '@') { Party party = _manager.getPartyManager().getParty(sender); if (party != null) @@ -132,9 +122,9 @@ public class GameChatManager implements Listener event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + event.getPlayer().getName() + " " + C.cPurple + "%2$s"); - for (String member : party.getMembers()) + for (UUID member : party.getMembersByUUID()) { - Player other = UtilPlayer.searchExact(member); + Player other = Bukkit.getPlayer(member); if (other != null) event.getRecipients().add(other); @@ -142,9 +132,10 @@ public class GameChatManager implements Listener } else { - UtilPlayer.message(sender, F.main("Party", "You are not in a Party.")); + UtilPlayer.message(event.getPlayer(), F.main("Party", "You are not in a Party.")); event.setCancelled(true); } + return; } @@ -156,7 +147,7 @@ public class GameChatManager implements Listener format = event.getFormat().split(rankStr)[0]; name = _manager.GetColor(sender) + sender.getName() + C.Reset; - if (event.getMessage().charAt(0) == '@') + if (event.getMessage().charAt(0) == '#') message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage().substring(1, event.getMessage().length())); else message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); @@ -174,7 +165,7 @@ public class GameChatManager implements Listener } //Base Format - event.setFormat(disguiseTag + dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); //Public/Private (Not If Player Dead) if (_manager.GetGame() != null && _manager.GetGame().GetState() == GameState.Live) @@ -186,17 +177,17 @@ public class GameChatManager implements Listener if (team != null) { - boolean isPriv = event.getMessage().charAt(0) == '@'; + boolean isPriv = event.getMessage().charAt(0) == '#'; if(isPriv) event.setMessage(event.getMessage().substring(1, event.getMessage().length())); else globalMessage = true; - event.setFormat(isPriv ? disguiseTag + C.cWhiteB + "Team " + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s" : disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(isPriv ? C.cWhiteB + "Team " + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s" : dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); if(rankStr.equals("")) - format = isPriv ? disguiseTag + C.cWhiteB + "Team " + dead + levelStr : disguiseTag + dead + levelStr; + format = isPriv ? C.cWhiteB + "Team " + dead + levelStr : dead + levelStr; else format = event.getFormat().split(rankStr)[0]; @@ -205,10 +196,10 @@ public class GameChatManager implements Listener else { globalMessage = true; - event.setFormat(disguiseTag + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); + event.setFormat(dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); if(rankStr.equals("")) - format = disguiseTag + dead + levelStr; + format = dead + levelStr; else format = event.getFormat().split(rankStr)[0]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index f3447b63a..90c137692 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -1,64 +1,49 @@ package nautilus.game.arcade.scoreboard; -import java.util.ArrayList; +import mineplex.core.common.Pair; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilMath; +import mineplex.core.scoreboard.WritableMineplexScoreboard; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; -public class GameScoreboard +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +public class GameScoreboard extends WritableMineplexScoreboard { - private Game Game; - - private Scoreboard _scoreboard; - private Objective _sideObjective; - - private ArrayList _elements = new ArrayList(); - private char[] _chars = "ghijstuvwxyz,.-;:_@*+?=".toCharArray(); - private ArrayList _previousLines = new ArrayList(); + private Game _game; private String _title; private int _shineIndex; private boolean _shineDirection = true; - - private boolean _debug = false; - + public GameScoreboard(Game game) { - Game = game; + _game = game; _title = " MINEPLEX "; - //Scoreboard - _scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - - _sideObjective = _scoreboard.registerNewObjective("Obj"+UtilMath.r(999999999), "dummy"); - _sideObjective.setDisplaySlot(DisplaySlot.SIDEBAR); - _sideObjective.setDisplayName(C.Bold + _title); + setSidebarName(C.Bold + _title); } - public Scoreboard GetScoreboard() + public Scoreboard getScoreboard() { - return _scoreboard; + return getHandle(); } - public Objective GetObjectiveSide() - { - return _sideObjective; - } - - public void UpdateTitle() + public void updateTitle() { String out; - + if (_shineDirection) { out = C.cGold + C.Bold; @@ -67,16 +52,16 @@ public class GameScoreboard { out = C.cWhite + C.Bold; } - - for (int i=0 ; i < _title.length() ; i++) + + for (int i = 0; i < _title.length(); i++) { char c = _title.charAt(i); - + if (_shineDirection) { if (i == _shineIndex) out += C.cYellow + C.Bold; - + if (i == _shineIndex + 1) out += C.cWhite + C.Bold; } @@ -84,255 +69,102 @@ public class GameScoreboard { if (i == _shineIndex) out += C.cYellow + C.Bold; - + if (i == _shineIndex + 1) out += C.cGold + C.Bold; } - - + + out += c; } - - _sideObjective.setDisplayName(out); - + + setSidebarName(out); + _shineIndex++; - - if (_shineIndex == _title.length()*2) + + if (_shineIndex == _title.length() * 2) { _shineIndex = 0; _shineDirection = !_shineDirection; } } - public String ParseTeamName(String name) + public void setPlayerTeam(Player player, GameTeam gameTeam) { - return name.substring(0, Math.min(16, name.length())); - } + String teamId = _game.getArcadeManager().GetLobby().getTeamId(gameTeam, player); - public void CreateTeams() - { - System.out.println("Creating Scoreboard Teams."); - - - _scoreboard.registerNewTeam(ParseTeamName("SPEC")).setPrefix(ChatColor.GRAY + ""); - - //Team Groups - for (GameTeam team : Game.GetTeamList()) + if (getHandle().getTeam(teamId) == null) { - System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); - if (team.GetDisplaytag()) - { - Team group = _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())); + Team targetTeam = getHandle().registerNewTeam(teamId); - group.setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); - group.setSuffix(C.Reset); + if (gameTeam.GetDisplaytag()) + { + targetTeam.setPrefix(gameTeam.GetColor() + C.Bold + gameTeam.GetName() + gameTeam.GetColor() + " "); + targetTeam.setSuffix(C.Reset); } else { - Team group = _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())); - - group.setPrefix(team.GetColor() + ""); - group.setSuffix(C.Reset); - } - } - - /* - //Base Groups - for (Rank rank : Rank.values()) - { - //_scoreboard.registerNewTeam(ParseTeamName(rank.Name + "SPEC")).setPrefix(ChatColor.GRAY + ""); - } - - //Team Groups - for (GameTeam team : Game.GetTeamList()) - { - System.out.println("Scoreboard Team: " + team.getName().toUpperCase()); - - for (Rank rank : Rank.values()) - { - _scoreboard.registerNewTeam(ParseTeamName(rank.Name + team.getName().toUpperCase())).setPrefix(team.GetColor() + ""); - } - } - */ - } - - public void SetPlayerTeam(Player player, String teamName) - { - for (Team team : _scoreboard.getTeams()) - team.removePlayer(player); - - if (teamName == null) - teamName = ""; - - String team = ParseTeamName(teamName); - - try - { - _scoreboard.getTeam(team).addPlayer(player); - } - catch (Exception e) - { - e.printStackTrace(); - System.out.println("ERROR ADDING PLAYER TO TEAM: " + team); - } - } - - public void ResetScore(String line) - { - _scoreboard.resetScores(line); - } - - /* - public void Reset() - { - for (ScoreboardElement elem : _elements) - { - for (String line : elem.getLines()) - { - ResetScore(line); + targetTeam.setPrefix(gameTeam.GetColor() + ""); + targetTeam.setSuffix(C.Reset); } } - _elements.clear(); - - _space = " "; - } - */ - - public void Write(String line) - { - _elements.add(new ScoreboardElementText(line)); + setPlayerTeam(player, teamId); } - public void WriteOrdered(String key, String line, int value, boolean prependScore) + public void setSpectating(Player player) { - if (prependScore) - line = value + " " + line; - - for (ScoreboardElement elem : _elements) + if (getHandle().getTeam("SPEC") == null) { - if (elem instanceof ScoreboardElementScores) - { - ScoreboardElementScores scores = (ScoreboardElementScores)elem; + getHandle().registerNewTeam("SPEC").setPrefix(C.cGray); + } + setPlayerTeam(player, "SPEC"); + } - if (scores.IsKey(key)) - { - scores.AddScore(line, value); - return; - } - } + private void setPlayerTeam(Player player, String teamId) + { + for (Team team : getHandle().getTeams()) + team.removeEntry(player.getName()); + + getHandle().getTeam(teamId).addEntry(player.getName()); + } + + public void writeGroup(Collection players, Function> score, boolean prependScore) + { + Map scores = new HashMap<>(); + Map names = new HashMap<>(); + + for (T player : players) + { + Pair result = score.apply(player); + if (result == null) continue; + scores.put(player, result.getRight()); + names.put(player, result.getLeft()); } - _elements.add(new ScoreboardElementScores(key, line, value, true)); + scores = sortByValue(scores); + + for (Map.Entry entry : scores.entrySet()) + { + String line = names.get(entry.getKey()); + if (prependScore) + { + line = entry.getValue() + " " + line; + } + write(line); + } } - public void WriteBlank() + private > Map sortByValue(Map map) { - _elements.add(new ScoreboardElementText(" ")); - } + List> list = new LinkedList<>(map.entrySet()); + Collections.sort(list, (o1, o2) -> (o2.getValue()).compareTo(o1.getValue())); - public void Draw() - { - if (_debug) System.out.println(); - if (_debug) System.out.println("/////////////////////////"); - - // Generate Lines - ArrayList newLines = new ArrayList(); - - for (ScoreboardElement elem : _elements) + Map result = new LinkedHashMap<>(); + for (Map.Entry entry : list) { - newLines.addAll(elem.GetLines()); + result.put(entry.getKey(), entry.getValue()); } - - int i = 0; - while (true) - { - if (i >= _chars.length) - break; - - String str = ChatColor.COLOR_CHAR + "" + _chars[i] + C.Reset; - - Score score = GetObjectiveSide().getScore(str); - - if (newLines.size() <= i) - { - if (score.isScoreSet()) - { - ResetScore(str); - } - else - { - break; - } - } - else if (i >= _previousLines.size() || !_previousLines.get(i).equals(newLines.get(i))) - { - Team team = GetScoreboard().getTeam(str); - - if (team == null) - { - team = GetScoreboard().registerNewTeam(str); - team.addEntry(str); - } - - String[] line = split(newLines.get(i)); - - team.setPrefix(line[0]); - String lastColor = ChatColor.getLastColors(line[0]); - team.setSuffix((lastColor + line[1])); - - if (!score.isScoreSet()) - { - if (i == 15) - { - score.setScore(1); - } - - score.setScore(15 - i); - } - } - - i++; - } - - _previousLines = newLines; + return result; } - - private String[] split(String line) - { - String[] strings = new String[2]; - - if (line.length() > 16) - { - String line1 = line.substring(0, 16); - String line2 = line.substring(16); - - if (line1.endsWith(ChatColor.COLOR_CHAR + "")) - { - line2 = line1.substring(15, 16) + line2; - line1 = line1.substring(0, 15); - } - - line2 = ChatColor.getLastColors(line1) + line2; - - if (line2.length() > 16) - { - line2 = line2.substring(0, 16); - } - - strings[0] = line1; - strings[1] = line2; - } - else - { - strings[0] = line; - strings[1] = ""; - } - - return strings; - } - public void Reset() - { - _elements.clear(); - } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java deleted file mode 100644 index a7df64281..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElement.java +++ /dev/null @@ -1,8 +0,0 @@ -package nautilus.game.arcade.scoreboard; - -import java.util.ArrayList; - -public abstract class ScoreboardElement -{ - public abstract ArrayList GetLines(); -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java deleted file mode 100644 index 02302866d..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementScores.java +++ /dev/null @@ -1,65 +0,0 @@ -package nautilus.game.arcade.scoreboard; - -import java.util.ArrayList; -import java.util.HashMap; - -public class ScoreboardElementScores extends ScoreboardElement -{ - private String _key; - - private HashMap _scores; - - private boolean _higherIsBetter; - - public ScoreboardElementScores(String key, String line, int value, boolean higherIsBetter) - { - _scores = new HashMap(); - - _key = key; - - AddScore(line, value); - - _higherIsBetter = higherIsBetter; - } - - @Override - public ArrayList GetLines() - { - ArrayList orderedScores = new ArrayList(); - - //Order Scores - while (orderedScores.size() < _scores.size()) - { - String bestKey = null; - int bestScore = 0; - - for (String key : _scores.keySet()) - { - if (orderedScores.contains(key)) - continue; - - if (bestKey == null || - (_higherIsBetter && _scores.get(key) >= bestScore) || - (!_higherIsBetter && _scores.get(key) <= bestScore)) - { - bestKey = key; - bestScore = _scores.get(key); - } - } - - orderedScores.add(bestKey); - } - - return orderedScores; - } - - public boolean IsKey(String key) - { - return _key.equals(key); - } - - public void AddScore(String line, int value) - { - _scores.put(line, value); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java deleted file mode 100644 index cccb2b8fa..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/ScoreboardElementText.java +++ /dev/null @@ -1,24 +0,0 @@ -package nautilus.game.arcade.scoreboard; - -import java.util.ArrayList; - -public class ScoreboardElementText extends ScoreboardElement -{ - private String _line; - - public ScoreboardElementText(String line) - { - _line = line; - } - - @Override - public ArrayList GetLines() - { - ArrayList orderedScores = new ArrayList(); - - orderedScores.add(_line); - - return orderedScores; - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java index 82919530d..eea1cfa52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java @@ -1,19 +1,17 @@ package nautilus.game.arcade.shop; -import org.bukkit.entity.Player; - -import nautilus.game.arcade.ArcadeManager; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; -import mineplex.core.common.CurrencyType; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.entity.Player; public class ArcadeShop extends ShopBase { public ArcadeShop(ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Shop", CurrencyType.GEM); + super(plugin, clientManager, donationManager, "Shop"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java index 7ff7bdae3..6fbea37dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java @@ -1,10 +1,8 @@ package nautilus.game.arcade.shop; -import org.bukkit.entity.Player; - -import nautilus.game.arcade.kit.Kit; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; +import nautilus.game.arcade.kit.Kit; public class KitPackage extends SalesPackageBase { @@ -12,12 +10,6 @@ public class KitPackage extends SalesPackageBase { super(gameName + " " + kit.GetName(), kit.getDisplayMaterial(), kit.GetDesc()); KnownPackage = false; - CurrencyCostMap.put(CurrencyType.GEM, kit.GetCost()); - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - + CurrencyCostMap.put(GlobalCurrency.GEM, kit.GetCost()); } } diff --git a/Plugins/app.xml b/Plugins/app.xml index aa91bc8fc..77c896f20 100644 --- a/Plugins/app.xml +++ b/Plugins/app.xml @@ -37,6 +37,7 @@ com.mineplex:spigot + com.mineplex:anticheat diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index 84baf84a7..f5d9f4215 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -44,12 +44,16 @@ import mineplex.core.reward.RewardManager; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; +import mineplex.core.thank.ThankManager; import mineplex.core.treasure.TreasureManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import net.minecraft.server.v1_8_R3.MinecraftServer; + +import static mineplex.core.Managers.require; + /** * Main JavaPlugin class for this plugin. Initializes the rest of this plugin. */ @@ -90,10 +94,10 @@ public class Hub extends JavaPlugin _donationManager = new DonationManager(this, _clientManager, webServerAddress); - PacketHandler packetHandler = new PacketHandler(this); + PacketHandler packetHandler = require(PacketHandler.class); IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager); incognito.setPreferencesManager(preferenceManager); @@ -102,11 +106,10 @@ public class Hub extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + DisguiseManager disguiseManager = require(DisguiseManager.class); Punish punish = new Punish(this, webServerAddress, _clientManager); - AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); - AntiHack.Instance.setKick(false); + require(AntiHack.class); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, _clientManager); @@ -130,7 +133,8 @@ public class Hub extends JavaPlugin MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager); - BoosterManager boosterManager = new BoosterManager(this, serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager); + ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); + BoosterManager boosterManager = new BoosterManager(this, serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, statsManager, gadgetManager); TreasureManager treasureManager = new TreasureManager(this, _clientManager, serverStatusManager, _donationManager, inventoryManager, petManager, gadgetManager, blockRestore, hologramManager, statsManager, rewardManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, @@ -145,7 +149,7 @@ public class Hub extends JavaPlugin new MavericksReviewManager(this, new MavericksBuildRepository(), new MavericksApprovedRepository()); - new ProfileCacheManager(this); + require(ProfileCacheManager.class); new SimpleChatManager(this, _clientManager, achievementManager); diff --git a/Plugins/plugin.xml b/Plugins/plugin.xml index c6ed635aa..a7e80fd04 100644 --- a/Plugins/plugin.xml +++ b/Plugins/plugin.xml @@ -46,6 +46,7 @@ com.google.code.gson:gson com.mineplex:spigot + com.mineplex:anticheat diff --git a/Plugins/pom.xml b/Plugins/pom.xml index c6377752c..63be70949 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -27,6 +27,7 @@ Mineplex.Game.Clans Mineplex.Game.Clans.Core Mineplex.Hub + Mineplex.Hub.Clans Mineplex.MapParser Mineplex.Minecraft.Game.ClassCombat Mineplex.Minecraft.Game.Core