Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into update/basketball-game
This commit is contained in:
commit
8ca214a4d8
@ -28,10 +28,6 @@
|
|||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.kencochrane.raven</groupId>
|
|
||||||
<artifactId>raven</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-proxy</artifactId>
|
<artifactId>bungeecord-proxy</artifactId>
|
||||||
|
@ -1,39 +1,21 @@
|
|||||||
package mineplex.bungee;
|
package mineplex.bungee;
|
||||||
|
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||||
import mineplex.bungee.motd.MotdManager;
|
import mineplex.bungee.motd.MotdManager;
|
||||||
import mineplex.bungee.playerCount.PlayerCount;
|
import mineplex.bungee.playerCount.PlayerCount;
|
||||||
import mineplex.bungee.playerStats.PlayerStats;
|
import mineplex.bungee.playerStats.PlayerStats;
|
||||||
import mineplex.bungee.playerTracker.PlayerTracker;
|
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;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
public class Mineplexer extends Plugin
|
public class Mineplexer extends Plugin
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
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 MotdManager(this);
|
||||||
new LobbyBalancer(this);
|
new LobbyBalancer(this);
|
||||||
PlayerCount playerCount = new PlayerCount(this);
|
new PlayerCount(this);
|
||||||
new FileUpdater(this);
|
new FileUpdater(this);
|
||||||
new PlayerStats(this);
|
new PlayerStats(this);
|
||||||
//new InternetStatus(this);
|
|
||||||
new PlayerTracker(this);
|
new PlayerTracker(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package mineplex.bungee.lobbyBalancer;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,21 +11,24 @@ import mineplex.serverdata.Region;
|
|||||||
import mineplex.serverdata.data.MinecraftServer;
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
import mineplex.serverdata.servers.ServerManager;
|
||||||
import mineplex.serverdata.servers.ServerRepository;
|
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.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class LobbyBalancer implements Listener, Runnable
|
public class LobbyBalancer implements Listener, Runnable
|
||||||
{
|
{
|
||||||
private Plugin _plugin;
|
private Plugin _plugin;
|
||||||
private ServerRepository _repository;
|
private ServerRepository _repository;
|
||||||
|
|
||||||
private List<MinecraftServer> _sortedLobbies = new ArrayList<MinecraftServer>();
|
private List<MinecraftServer> _sortedLobbies = Lists.newArrayList();
|
||||||
|
private List<MinecraftServer> _sortedClans = Lists.newArrayList();
|
||||||
private static Object _serverLock = new Object();
|
private static Object _serverLock = new Object();
|
||||||
|
|
||||||
private int _lobbyIndex = 0;
|
private int _lobbyIndex = 0;
|
||||||
|
private int _clansIndex = 0;
|
||||||
|
|
||||||
public LobbyBalancer(Plugin plugin)
|
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;
|
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||||
_repository = ServerManager.getServerRepository(region);
|
_repository = ServerManager.getServerRepository(region);
|
||||||
|
|
||||||
loadLobbyServers();
|
run();
|
||||||
|
|
||||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS);
|
_plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS);
|
||||||
@ -44,27 +46,49 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerConnect(ServerConnectEvent event)
|
public void playerConnect(ServerConnectEvent event)
|
||||||
{
|
{
|
||||||
if (!event.getTarget().getName().equalsIgnoreCase("Lobby"))
|
if (event.getTarget().getName().equalsIgnoreCase("Lobby"))
|
||||||
return;
|
|
||||||
|
|
||||||
synchronized (_serverLock)
|
|
||||||
{
|
{
|
||||||
if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount())
|
synchronized (_serverLock)
|
||||||
_lobbyIndex = 0;
|
{
|
||||||
|
if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount())
|
||||||
event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_lobbyIndex).getName()));
|
_lobbyIndex = 0;
|
||||||
_sortedLobbies.get(_lobbyIndex).incrementPlayerCount(1);
|
|
||||||
System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedLobbies.get(_lobbyIndex).getName() + "(" + _sortedLobbies.get(_lobbyIndex).getPublicAddress() + ")");
|
event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_lobbyIndex).getName()));
|
||||||
_lobbyIndex++;
|
_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()
|
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<MinecraftServer> servers = _repository.getServerStatuses();
|
Collection<MinecraftServer> servers = _repository.getServerStatuses();
|
||||||
|
|
||||||
@ -72,6 +96,7 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
_sortedLobbies.clear();
|
_sortedLobbies.clear();
|
||||||
|
_sortedClans.clear();
|
||||||
|
|
||||||
for (MinecraftServer server : servers)
|
for (MinecraftServer server : servers)
|
||||||
{
|
{
|
||||||
@ -88,9 +113,17 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
_sortedLobbies.add(server);
|
_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(_sortedLobbies, new LobbySorter());
|
||||||
|
Collections.sort(_sortedClans, new LobbySorter());
|
||||||
|
|
||||||
long timeSpentInLock = System.currentTimeMillis() - startTime;
|
long timeSpentInLock = System.currentTimeMillis() - startTime;
|
||||||
|
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package mineplex.bungee.motd;
|
package mineplex.bungee.motd;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import mineplex.serverdata.Region;
|
import mineplex.serverdata.Region;
|
||||||
import mineplex.serverdata.data.BungeeServer;
|
|
||||||
import mineplex.serverdata.data.DataRepository;
|
import mineplex.serverdata.data.DataRepository;
|
||||||
import mineplex.serverdata.redis.RedisDataRepository;
|
import mineplex.serverdata.redis.RedisDataRepository;
|
||||||
import mineplex.serverdata.servers.ConnectionData;
|
import mineplex.serverdata.servers.ConnectionData;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
|
||||||
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
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.event.ProxyPingEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
@ -31,6 +29,8 @@ public class MotdManager implements Listener, Runnable
|
|||||||
private Random _random = new Random();
|
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 String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||||
private List<String> _motdLines;
|
private List<String> _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<String> _motdCLines;
|
||||||
|
|
||||||
public MotdManager(Plugin plugin)
|
public MotdManager(Plugin plugin)
|
||||||
{
|
{
|
||||||
@ -70,25 +70,50 @@ public class MotdManager implements Listener, Runnable
|
|||||||
public void serverPing(ProxyPingEvent event)
|
public void serverPing(ProxyPingEvent event)
|
||||||
{
|
{
|
||||||
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
||||||
|
if (event.getConnection().getListener() != null && event.getConnection().getListener().getDefaultServer().equalsIgnoreCase("ClansHub"))
|
||||||
String motd = _firstLine;
|
|
||||||
if (_motdLines != null && _motdLines.size() > 0)
|
|
||||||
{
|
{
|
||||||
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
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
GlobalMotd motd = _repository.getElement("MainMotd");
|
{
|
||||||
|
GlobalMotd motd = _repository.getElement("MainMotd");
|
||||||
if (motd != null)
|
|
||||||
{
|
if (motd != null)
|
||||||
_motdLines = motd.getMotd();
|
{
|
||||||
_firstLine = motd.getHeadline();
|
_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")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package mineplex.bungee.playerCount;
|
package mineplex.bungee.playerCount;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import mineplex.bungee.status.InternetStatus;
|
import mineplex.bungee.status.InternetStatus;
|
||||||
@ -12,7 +11,6 @@ import mineplex.serverdata.redis.RedisDataRepository;
|
|||||||
import mineplex.serverdata.servers.ConnectionData;
|
import mineplex.serverdata.servers.ConnectionData;
|
||||||
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
import mineplex.serverdata.servers.ServerManager;
|
||||||
import mineplex.serverdata.servers.ServerRepository;
|
|
||||||
import net.md_5.bungee.api.ServerPing.Players;
|
import net.md_5.bungee.api.ServerPing.Players;
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
import net.md_5.bungee.api.config.ListenerInfo;
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
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().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS);
|
||||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
_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<BungeeServer>(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL),
|
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL),
|
||||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||||
@ -55,7 +59,10 @@ public class PlayerCount implements Listener, Runnable
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
BungeeServer snapshot = generateSnapshot();
|
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();
|
_totalPlayers = fetchPlayerCount();
|
||||||
}
|
}
|
||||||
@ -84,6 +91,10 @@ public class PlayerCount implements Listener, Runnable
|
|||||||
*/
|
*/
|
||||||
private BungeeServer generateSnapshot()
|
private BungeeServer generateSnapshot()
|
||||||
{
|
{
|
||||||
|
if (_listenerInfo == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String name = _listenerInfo.getHost().getAddress().getHostAddress();
|
String name = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||||
String host = _listenerInfo.getHost().getAddress().getHostAddress();
|
String host = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||||
int port = _listenerInfo.getHost().getPort();
|
int port = _listenerInfo.getHost().getPort();
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,6 +42,7 @@ public class SortedSchematicLoader<T>
|
|||||||
if (entry != null && !entry.getKey().equals(_currentValue))
|
if (entry != null && !entry.getKey().equals(_currentValue))
|
||||||
{
|
{
|
||||||
_currentValue = entry.getKey();
|
_currentValue = entry.getKey();
|
||||||
|
Schematic schematic = entry.getValue();
|
||||||
entry.getValue().paste(_pasteLocation, false);
|
entry.getValue().paste(_pasteLocation, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,30 @@
|
|||||||
package mineplex.core.common.api;
|
package mineplex.core.common.api;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
*/
|
*/
|
||||||
public class ApiEndpoint
|
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 Gson _gson;
|
||||||
private ApiWebCall _webCall;
|
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);
|
_webCall = new ApiWebCall(url, gson);
|
||||||
_gson = gson;
|
_gson = gson;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -283,13 +283,29 @@ public class Schematic
|
|||||||
return index < _blocks.length && index >= 0;
|
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)];
|
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)];
|
return _blockData[getIndex(x, y, z)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +99,13 @@ public class SchematicRunnable implements Runnable
|
|||||||
|
|
||||||
private void setBlock(Block block, int x, int y, int z)
|
private void setBlock(Block block, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
Short materialId = _schematic.getBlock(x, y, z);
|
||||||
int materialId = _schematic.getBlock(x, y, z);
|
Byte data = _schematic.getData(x, y, z);
|
||||||
byte data = _schematic.getData(x, y, z);
|
|
||||||
|
if (materialId == null || data == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Material material = Material.getMaterial(materialId);
|
Material material = Material.getMaterial(materialId);
|
||||||
if (material == null)
|
if (material == null)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -108,7 +108,7 @@ public class JsonMessage
|
|||||||
|
|
||||||
public void sendToPlayer(Player player)
|
public void sendToPlayer(Player player)
|
||||||
{
|
{
|
||||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + player.getName() + " " + toString());
|
((CraftPlayer) player).getHandle().sendMessage(IChatBaseComponent.ChatSerializer.a(toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,22 @@
|
|||||||
package mineplex.core.common.skin;
|
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.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.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
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.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_8_R3.NBTTagList;
|
import net.minecraft.server.v1_8_R3.NBTTagList;
|
||||||
import net.minecraft.server.v1_8_R3.NBTTagString;
|
import net.minecraft.server.v1_8_R3.NBTTagString;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
public class SkinData
|
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;
|
private static long _nameCount = -99999999999999L;
|
||||||
|
|
||||||
public final static SkinData FREEDOM_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY1NzA5NDAzODcsInByb2ZpbGVJZCI6IjQwZWQ5NzU1OWIzNTQ1M2Q4NjU1ZmMwMDM5OGRiNmI5IiwicHJvZmlsZU5hbWUiOiJTcG9vYm5jb29iciIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4N2Q4OGNlYzNmOWI0M2RiNDg1YTU0Mjc2YTQ1MjQzNGFiZDI2ZDMzY2QzZmZhMTM2N2ZiMzVmOWUzODQifX19", "UgsQyW/HJ/jmDzfI1d7RWFbhKi8PeJAKBuAOk7ajS5dzH5od301KfcmiT2X3TU7cBbUswcKtDb2F/m7gNrg/t+pU7Bi9UKzyALEu9HRjd4s1uKbqGkBip1z5Qycp4fhkSyKvtvTnA2fhpP9oHtE5FxGXdMhZXyFkLrli4Hyxp1BI0N4h7pgbcMaISPS0ZYzDRNxkrSnl3y3KyKn5Rl5qH7utmQtAjoyx9aueMZxG3tg/igfYF7uAvvmuYKsSiTZWZOOuSh+U1dkP+ZE/cQANfryXkLJSJHa9YZPCMJHXe4mMoAyu0/qu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yCZLpo20vamBJ1uK1dmx2+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/K0VReI9eq2yD6zGQpv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YTI2OTVlN2NmYmYifSwiQ0FQRSI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIyYjljNWVhNzYzYzg2ZmM1Y2FlYTMzZDgyYjBmYTY1YTdjMjI4ZmQzMjFiYTU0NzY2ZWE5NWEzZDBiOTc5MyJ9fX0=", "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;
|
private Property _skinProperty;
|
||||||
|
|
||||||
public SkinData(String value, String signature)
|
public SkinData(String value, String signature)
|
||||||
{
|
{
|
||||||
_skinProperty = new Property("textures", value, signature);
|
_skinProperty = new Property("textures", value, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkinData(GameProfile profile)
|
private SkinData(GameProfile profile)
|
||||||
{
|
{
|
||||||
_skinProperty = profile.getProperties().get("textures").iterator().next();
|
_skinProperty = profile.getProperties().get("textures").iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkinData(Player player)
|
|
||||||
{
|
|
||||||
this(((CraftPlayer)player).getProfile());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getSkull()
|
public ItemStack getSkull()
|
||||||
{
|
{
|
||||||
NBTTagCompound arrayElement = new NBTTagCompound();
|
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
|
||||||
arrayElement.setString("Value", _skinProperty.getValue());
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
arrayElement.setString("Signature", _skinProperty.getSignature());
|
|
||||||
|
GameProfile data = new GameProfile(UUID.randomUUID(), getUnusedSkullName());
|
||||||
NBTTagList textures = new NBTTagList();
|
data.getProperties().put("textures", getProperty());
|
||||||
textures.add(arrayElement);
|
|
||||||
|
try
|
||||||
NBTTagCompound properties = new NBTTagCompound();
|
{
|
||||||
properties.set("textures", textures);
|
PROFILE_FIELD.set(meta, data);
|
||||||
|
}
|
||||||
NBTTagCompound skullOwner = new NBTTagCompound();
|
catch (ReflectiveOperationException t)
|
||||||
skullOwner.set("Properties", properties);
|
{
|
||||||
skullOwner.set("Name", new NBTTagString(getUnusedSkullName()));
|
t.printStackTrace();
|
||||||
|
}
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
tag.set("SkullOwner", skullOwner);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
return item;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getSkull(String name, List<String> lore)
|
public ItemStack getSkull(String name, List<String> lore)
|
||||||
@ -94,16 +121,51 @@ public class SkinData
|
|||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Property getProperty()
|
public Property getProperty()
|
||||||
{
|
{
|
||||||
return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature());
|
return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUnusedSkullName()
|
public static String getUnusedSkullName()
|
||||||
{
|
{
|
||||||
_nameCount++;
|
_nameCount++;
|
||||||
return "_" + _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<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.<MinecraftProfileTexture.Type, MinecraftProfileTexture>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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package mineplex.core.common.util;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.currency.Currency;
|
||||||
|
|
||||||
public class F
|
public class F
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ public class F
|
|||||||
return out;
|
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;
|
return type.getString(amount) + ChatColor.RESET + C.mBody;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package mineplex.core.common.util;
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
|
import mineplex.core.common.events.EntityVelocityChangeEvent;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -49,6 +52,15 @@ public class UtilAction
|
|||||||
if (groundBoost)
|
if (groundBoost)
|
||||||
if (UtilEnt.isGrounded(ent))
|
if (UtilEnt.isGrounded(ent))
|
||||||
vec.setY(vec.getY() + 0.2);
|
vec.setY(vec.getY() + 0.2);
|
||||||
|
|
||||||
|
EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vec = event.getVelocity();
|
||||||
|
|
||||||
//Velocity
|
//Velocity
|
||||||
ent.setFallDistance(0);
|
ent.setFallDistance(0);
|
||||||
@ -65,6 +77,16 @@ public class UtilAction
|
|||||||
public static void zeroVelocity(Entity ent)
|
public static void zeroVelocity(Entity ent)
|
||||||
{
|
{
|
||||||
Vector vec = new Vector(0,0,0);
|
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);
|
ent.setFallDistance(0);
|
||||||
|
|
||||||
//Store It!
|
//Store It!
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
package mineplex.core.common.util;
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||||
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 org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.TrigMath;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
import org.bukkit.util.Vector;
|
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
|
public class UtilAlg
|
||||||
{
|
{
|
||||||
@ -56,6 +54,17 @@ public class UtilAlg
|
|||||||
{
|
{
|
||||||
return to.clone().subtract(from).normalize();
|
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)
|
public static Vector getTrajectory2d(Entity from, Entity to)
|
||||||
{
|
{
|
||||||
@ -98,28 +107,42 @@ public class UtilAlg
|
|||||||
|
|
||||||
public static float GetPitch(Vector vec)
|
public static float GetPitch(Vector vec)
|
||||||
{
|
{
|
||||||
double x = vec.getX();
|
return GetPitch(vec.getX(), vec.getY(), vec.getZ());
|
||||||
double y = vec.getY();
|
}
|
||||||
double z = 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 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;
|
if (y <= 0) pitch += 90;
|
||||||
else 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)
|
if (pitch == 180)
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
|
|
||||||
return (float) pitch;
|
return (float) pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float GetYaw(Vector vec)
|
public static float GetYaw(Vector vec)
|
||||||
{
|
{
|
||||||
double x = vec.getX();
|
return GetYaw(vec.getX(), vec.getY(), vec.getZ());
|
||||||
double z = vec.getZ();
|
}
|
||||||
|
|
||||||
double yaw = Math.toDegrees(Math.atan((-x)/z));
|
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;
|
if (z < 0) yaw += 180;
|
||||||
|
|
||||||
return (float) yaw;
|
return (float) yaw;
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
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.CraftCreature;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
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();
|
Vector dir = entity.getEyeLocation().toVector().subtract(location.toVector()).normalize();
|
||||||
Location loc = entity.getEyeLocation().clone();
|
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())));
|
loc.setPitch(90 - (float) Math.toDegrees(Math.acos(dir.getY())));
|
||||||
|
|
||||||
Rotate(entity, loc.getYaw(), loc.getPitch());
|
Rotate(entity, loc.getYaw(), loc.getPitch());
|
||||||
@ -700,6 +701,13 @@ public class UtilEnt
|
|||||||
return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec));
|
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)
|
public static boolean CreatureLook(Entity ent, Vector target)
|
||||||
{
|
{
|
||||||
return CreatureLook(ent, UtilAlg.GetPitch(target), UtilAlg.GetYaw(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());
|
EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.getWorld()).tracker.trackedEntities.get(ec.getId());
|
||||||
|
|
||||||
byte ya = (byte) (yaw * 256.0F / 360.0F);
|
if (entry != null)
|
||||||
byte pi = (byte) (pitch * 256.0F / 360.0F);
|
{
|
||||||
|
byte ya = (byte) (yaw * 256.0F / 360.0F);
|
||||||
|
byte pi = (byte) (pitch * 256.0F / 360.0F);
|
||||||
|
|
||||||
entry.yRot = ya;
|
entry.yRot = ya;
|
||||||
entry.xRot = pi;
|
entry.xRot = pi;
|
||||||
entry.i = ya;
|
entry.i = ya;
|
||||||
|
|
||||||
// Looks like both packets need to be sent. EntityLook packet for body yaw and head pitch. Head rotation for head yaw.
|
// 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 PacketPlayOutEntity.PacketPlayOutEntityLook(ent.getEntityId(), ya, pi, ec.onGround));
|
||||||
entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya));
|
entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
package mineplex.core.common.util;
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
import java.util.*;
|
import mineplex.core.common.MinecraftVersion;
|
||||||
|
import mineplex.core.common.events.PlayerMessageEvent;
|
||||||
import net.minecraft.server.v1_8_R3.*;
|
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.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -20,8 +28,17 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.util.BlockIterator;
|
import org.bukkit.util.BlockIterator;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.MinecraftVersion;
|
import java.util.ArrayList;
|
||||||
import mineplex.core.common.events.PlayerMessageEvent;
|
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
|
public class UtilPlayer
|
||||||
{
|
{
|
||||||
@ -179,7 +196,7 @@ public class UtilPlayer
|
|||||||
for (Entity entity : p.getNearbyEntities(range, range, range))
|
for (Entity entity : p.getNearbyEntities(range, range, range))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (entity == p || UtilPlayer.isSpectator(entity))
|
if (entity == p || UtilPlayer.isSpectator(entity) || !(entity instanceof Player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double theirDist = p.getEyeLocation().distance(entity.getLocation());
|
double theirDist = p.getEyeLocation().distance(entity.getLocation());
|
||||||
@ -938,9 +955,79 @@ public class UtilPlayer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void removeAllowedCommands(Player player)
|
public static void removeAllowedCommands(Player player)
|
||||||
{
|
{
|
||||||
if (ALLOWED_COMMANDS.containsKey(player.getUniqueId()))
|
if (ALLOWED_COMMANDS.containsKey(player.getUniqueId()))
|
||||||
ALLOWED_COMMANDS.remove(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 <code>viewCommand</code> 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 <code>Optional</code> The command to be run when VIEW is clicked
|
||||||
|
* @param viewDisplayText <code>Optional</code> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public class UtilServer
|
|||||||
HandlerList.unregisterAll(listener);
|
HandlerList.unregisterAll(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Plugin getPlugin()
|
public static JavaPlugin getPlugin()
|
||||||
{
|
{
|
||||||
return JavaPlugin.getProvidingPlugin(UtilServer.class);
|
return JavaPlugin.getProvidingPlugin(UtilServer.class);
|
||||||
}
|
}
|
||||||
@ -193,6 +193,11 @@ public class UtilServer
|
|||||||
return _serverName;
|
return _serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getServerNameFromConfig()
|
||||||
|
{
|
||||||
|
return getPlugin().getConfig().getString("serverstatus.name");
|
||||||
|
}
|
||||||
|
|
||||||
public static Collection<Player> GetPlayers()
|
public static Collection<Player> GetPlayers()
|
||||||
{
|
{
|
||||||
return Lists.newArrayList(getPlayers());
|
return Lists.newArrayList(getPlayers());
|
||||||
|
@ -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 <T> Consumer<T> onMainThread(Consumer<T> original)
|
||||||
|
{
|
||||||
|
return t ->
|
||||||
|
{
|
||||||
|
onMainThread(() ->
|
||||||
|
{
|
||||||
|
original.accept(t);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,9 @@
|
|||||||
package mineplex.core.common.util;
|
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.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -7,13 +11,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
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
|
public class UtilText
|
||||||
{
|
{
|
||||||
private static HashMap<Character, Integer> _characters = new HashMap<>();
|
private static HashMap<Character, Integer> _characters = new HashMap<>();
|
||||||
@ -25,7 +22,7 @@ public class UtilText
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream inputStream = CurrencyType.class.getResourceAsStream("/ascii.png");
|
InputStream inputStream = UtilText.class.getResourceAsStream("/ascii.png");
|
||||||
BufferedImage image = ImageIO.read(inputStream);
|
BufferedImage image = ImageIO.read(inputStream);
|
||||||
|
|
||||||
char[] text = new char[]
|
char[] text = new char[]
|
||||||
|
@ -24,7 +24,12 @@ public class UtilWorld
|
|||||||
{
|
{
|
||||||
return UtilServer.getServer().getWorld(world);
|
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)
|
public static String chunkToStr(Chunk chunk)
|
||||||
{
|
{
|
||||||
if (chunk == null)
|
if (chunk == null)
|
||||||
|
@ -44,6 +44,11 @@
|
|||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mineplex</groupId>
|
||||||
|
<artifactId>anticheat</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package mineplex.core;
|
package mineplex.core;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.common.DummyEntity;
|
import mineplex.core.common.DummyEntity;
|
||||||
@ -53,15 +56,15 @@ import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
|
|||||||
|
|
||||||
public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||||
{
|
{
|
||||||
private NautHashMap<String, NautHashMap<Integer, Integer[]>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer[]>>();
|
private Map<UUID, Map<Integer, Integer[]>> _entityMap = new HashMap<>();
|
||||||
private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>();
|
private Map<UUID, Map<Integer, String>> _entityNameMap = new HashMap<>();
|
||||||
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityRiding = new NautHashMap<String, NautHashMap<Integer, Integer>>();
|
private Map<UUID, HashMap<Integer, Integer>> _entityRiding = new HashMap<>();
|
||||||
|
|
||||||
private HashSet<String> _loggedIn = new HashSet<String>();
|
private Set<UUID> _loggedIn = new HashSet<>();
|
||||||
private HashSet<Integer> _ignoreIds = new HashSet<Integer>();
|
private Set<Integer> _ignoreIds = new HashSet<>();
|
||||||
|
|
||||||
private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>();
|
private Map<UUID, Long> _exemptTimeMap = new HashMap<>();
|
||||||
private NautHashMap<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new NautHashMap<UUID, NautHashMap<CheckType, Long>>();
|
private Map<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new HashMap<>();
|
||||||
|
|
||||||
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
|
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
|
||||||
{
|
{
|
||||||
@ -79,10 +82,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerQuit(PlayerQuitEvent event)
|
public void playerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
_entityMap.remove(event.getPlayer().getName());
|
_entityMap.remove(event.getPlayer().getUniqueId());
|
||||||
_entityNameMap.remove(event.getPlayer().getName());
|
_entityNameMap.remove(event.getPlayer().getUniqueId());
|
||||||
_entityRiding.remove(event.getPlayer().getName());
|
_entityRiding.remove(event.getPlayer().getUniqueId());
|
||||||
_loggedIn.remove(event.getPlayer().getName());
|
_loggedIn.remove(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
@ -122,7 +125,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
public void ncpExemptVelocity(final PlayerVelocityEvent event)
|
public void ncpExemptVelocity(final PlayerVelocityEvent event)
|
||||||
{
|
{
|
||||||
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500);
|
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500);
|
||||||
|
|
||||||
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
|
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
|
||||||
{
|
{
|
||||||
_exemptTimeMap.put(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)
|
if (event.getType() != UpdateType.TICK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Iterator<Entry<UUID, Long>> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext();)
|
for (Iterator<Entry<UUID, Long>> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
final Entry<UUID, Long> entry = iterator.next();
|
final Entry<UUID, Long> entry = iterator.next();
|
||||||
|
|
||||||
@ -150,12 +153,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator
|
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator
|
||||||
.hasNext();)
|
.hasNext(); )
|
||||||
{
|
{
|
||||||
Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
|
Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
|
||||||
|
|
||||||
for (Iterator<Entry<CheckType, Long>> innerIterator = entry.getValue().entrySet().iterator(); innerIterator
|
for (Iterator<Entry<CheckType, Long>> innerIterator = entry.getValue().entrySet().iterator(); innerIterator
|
||||||
.hasNext();)
|
.hasNext(); )
|
||||||
{
|
{
|
||||||
final Entry<CheckType, Long> entry2 = innerIterator.next();
|
final Entry<CheckType, Long> entry2 = innerIterator.next();
|
||||||
|
|
||||||
@ -176,11 +179,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
if (event.getType() != UpdateType.SEC)
|
if (event.getType() != UpdateType.SEC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Iterator<String> iterator = _loggedIn.iterator(); iterator.hasNext();)
|
for (Iterator<UUID> 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();
|
iterator.remove();
|
||||||
_entityMap.remove(player);
|
_entityMap.remove(player);
|
||||||
@ -195,7 +198,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void handle(PacketInfo packetInfo)
|
public void handle(PacketInfo packetInfo)
|
||||||
{
|
{
|
||||||
if (packetInfo.isCancelled())
|
if (packetInfo.isCancelled())
|
||||||
@ -205,311 +208,84 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
Player owner = packetInfo.getPlayer();
|
Player owner = packetInfo.getPlayer();
|
||||||
PacketVerifier verifier = packetInfo.getVerifier();
|
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<Integer, Integer[]>());
|
if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId())
|
||||||
_entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>());
|
|
||||||
_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<WatchableObject>) 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<WatchableObject>) 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<WatchableObject>) 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
|
|
||||||
{
|
{
|
||||||
_ignoreIds.add(spawnPacket.a);
|
_ignoreIds.add(spawnPacket.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (packet instanceof PacketPlayInUseEntity)
|
|
||||||
|
for (WatchableObject watchable : (List<WatchableObject>) spawnPacket.l.c())
|
||||||
{
|
{
|
||||||
PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet;
|
if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1)
|
||||||
|
|
||||||
loop:
|
|
||||||
|
|
||||||
for (Entry<Integer, Integer[]> entry : _entityMap.get(owner.getName()).entrySet())
|
|
||||||
{
|
{
|
||||||
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();
|
newIds[a] = ids[a];
|
||||||
newPacket.a = entry.getKey();
|
|
||||||
newPacket.action = usePacket.action;
|
|
||||||
newPacket.c = usePacket.c;
|
|
||||||
|
|
||||||
{
|
|
||||||
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
break loop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<WatchableObject>) spawnPacket.i.c())
|
||||||
{
|
{
|
||||||
int vech = -1;
|
if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1)
|
||||||
int rider = -1;
|
|
||||||
|
|
||||||
if (packet instanceof PacketPlayOutAttachEntity)
|
|
||||||
{
|
{
|
||||||
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet;
|
if (_entityMap.get(owner.getUniqueId()).containsKey(spawnPacket.a))
|
||||||
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<Integer, Integer>());
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
_entityRiding.get(owner.getName()).put(vech, rider);
|
Integer[] ids = _entityMap.get(owner.getUniqueId()).get(spawnPacket.a);
|
||||||
|
|
||||||
int[] newIds = new int[ids.length];
|
int[] newIds = new int[ids.length];
|
||||||
|
|
||||||
@ -519,14 +295,242 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
}
|
}
|
||||||
|
|
||||||
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
|
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<WatchableObject>) 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<Integer, Integer[]> 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<Integer, Integer>());
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
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);
|
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
|
||||||
_plugin.getServer().getPluginManager().callEvent(event);
|
_plugin.getServer().getPluginManager().callEvent(event);
|
||||||
@ -565,9 +569,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
if (UtilPlayer.is1_9(owner))
|
if (UtilPlayer.is1_9(owner))
|
||||||
{
|
{
|
||||||
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
|
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
|
||||||
{
|
{
|
||||||
entityIds[1]
|
entityIds[1]
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -595,9 +599,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
|||||||
if (UtilPlayer.is1_9(owner))
|
if (UtilPlayer.is1_9(owner))
|
||||||
{
|
{
|
||||||
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
|
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
|
||||||
{
|
{
|
||||||
entityIds[0]
|
entityIds[0]
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
92
Plugins/Mineplex.Core/src/mineplex/core/Managers.java
Normal file
92
Plugins/Mineplex.Core/src/mineplex/core/Managers.java
Normal file
@ -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<Class<?>, 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 extends MiniPlugin> T get(Class<T> clazz)
|
||||||
|
{
|
||||||
|
Object result = MANAGER_MAP.get(clazz);
|
||||||
|
return clazz.cast(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the given module, and initializes if necessary
|
||||||
|
* @param clazz
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T extends MiniPlugin> T require(Class<T> clazz)
|
||||||
|
{
|
||||||
|
if (MANAGER_MAP.containsKey(clazz))
|
||||||
|
{
|
||||||
|
return get(clazz);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReflectivelyCreateMiniPlugin annotation = clazz.getAnnotation(ReflectivelyCreateMiniPlugin.class);
|
||||||
|
if (annotation != null)
|
||||||
|
{
|
||||||
|
Constructor<T> 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<? extends MiniPlugin> 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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,21 @@
|
|||||||
package mineplex.core;
|
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.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import java.util.Collection;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
|
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
|
||||||
{
|
{
|
||||||
private static Object _clientDataLock = new Object();
|
private static final Object _clientDataLock = new Object();
|
||||||
|
|
||||||
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
private Map<UUID, DataType> _clientData = new HashMap<>();
|
||||||
|
|
||||||
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
@ -26,18 +28,27 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
|||||||
synchronized (_clientDataLock)
|
synchronized (_clientDataLock)
|
||||||
{
|
{
|
||||||
saveData(event.GetName(), event.getAccountId());
|
saveData(event.GetName(), event.getAccountId());
|
||||||
_clientData.remove(event.GetName());
|
_clientData.remove(event.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public DataType Get(String name)
|
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)
|
synchronized (_clientDataLock)
|
||||||
{
|
{
|
||||||
if (!_clientData.containsKey(name))
|
if (!_clientData.containsKey(uuid))
|
||||||
_clientData.put(name, addPlayer(name));
|
_clientData.put(uuid, addPlayer(uuid));
|
||||||
|
|
||||||
return _clientData.get(name);
|
return _clientData.get(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +56,7 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
|||||||
|
|
||||||
public DataType Get(Player player)
|
public DataType Get(Player player)
|
||||||
{
|
{
|
||||||
return Get(player.getName());
|
return Get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<DataType> GetValues()
|
protected Collection<DataType> GetValues()
|
||||||
@ -55,16 +66,16 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
|||||||
|
|
||||||
protected void Set(Player player, DataType data)
|
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)
|
synchronized (_clientDataLock)
|
||||||
{
|
{
|
||||||
_clientData.put(name, data);
|
_clientData.put(uuid, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract DataType addPlayer(String player);
|
protected abstract DataType addPlayer(UUID uuid);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package mineplex.core;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniCl
|
|||||||
clientManager.addStoredProcedureLoginProcessor(this);
|
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()
|
public CoreClientManager getClientManager()
|
||||||
{
|
{
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
package mineplex.core;
|
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.Bukkit;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import mineplex.core.command.CommandCenter;
|
/**
|
||||||
import mineplex.core.command.ICommand;
|
* In the future, all implementations of MiniPlugin should only have one constructor:
|
||||||
import mineplex.core.common.util.F;
|
*
|
||||||
import mineplex.core.common.util.NautHashMap;
|
* private MiniPlugin()
|
||||||
import mineplex.core.common.util.UtilTime;
|
*
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
* MiniPlugins should also not depend on load order.
|
||||||
import mineplex.core.thread.ThreadPool;
|
*
|
||||||
|
* 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
|
public abstract class MiniPlugin implements Listener
|
||||||
{
|
{
|
||||||
protected String _moduleName = "Default";
|
protected String _moduleName = "Default";
|
||||||
@ -23,6 +33,11 @@ public abstract class MiniPlugin implements Listener
|
|||||||
|
|
||||||
protected long _initializedTime;
|
protected long _initializedTime;
|
||||||
|
|
||||||
|
public MiniPlugin(String moduleName)
|
||||||
|
{
|
||||||
|
this(moduleName, UtilServer.getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
public MiniPlugin(String moduleName, JavaPlugin plugin)
|
public MiniPlugin(String moduleName, JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
_moduleName = moduleName;
|
_moduleName = moduleName;
|
||||||
@ -30,11 +45,13 @@ public abstract class MiniPlugin implements Listener
|
|||||||
|
|
||||||
_initializedTime = System.currentTimeMillis();
|
_initializedTime = System.currentTimeMillis();
|
||||||
|
|
||||||
_commands = new NautHashMap<String, ICommand>();
|
_commands = new NautHashMap<>();
|
||||||
|
|
||||||
onEnable();
|
onEnable();
|
||||||
|
|
||||||
registerEvents(this);
|
registerEvents(this);
|
||||||
|
|
||||||
|
Managers.put(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginManager getPluginManager()
|
public PluginManager getPluginManager()
|
||||||
@ -111,22 +128,36 @@ public abstract class MiniPlugin implements Listener
|
|||||||
|
|
||||||
public void runAsync(Runnable runnable)
|
public void runAsync(Runnable runnable)
|
||||||
{
|
{
|
||||||
// Instead of using
|
|
||||||
ThreadPool.ASYNC.execute(runnable);
|
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 extends MiniPlugin> T require(Class<T> clazz)
|
||||||
|
{
|
||||||
|
return Managers.require(clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
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.EntityPlayer;
|
||||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
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
|
public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler
|
||||||
{
|
{
|
||||||
private HashMap<String, HashSet<Integer>> _armorStands = new HashMap<String, HashSet<Integer>>();
|
private Map<UUID, HashSet<Integer>> _armorStands = new HashMap<>();
|
||||||
|
|
||||||
public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler)
|
public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler)
|
||||||
{
|
{
|
||||||
@ -46,7 +48,7 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event)
|
public void onQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
_armorStands.remove(event.getPlayer().getName());
|
_armorStands.remove(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -57,13 +59,13 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<String> itel = _armorStands.keySet().iterator();
|
Iterator<UUID> itel = _armorStands.keySet().iterator();
|
||||||
|
|
||||||
while (itel.hasNext())
|
while (itel.hasNext())
|
||||||
{
|
{
|
||||||
String name = itel.next();
|
UUID id = itel.next();
|
||||||
|
|
||||||
Player player = Bukkit.getPlayerExact(name);
|
Player player = Bukkit.getPlayer(id);
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
@ -89,12 +91,12 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_armorStands.containsKey(player.getName()))
|
if (!_armorStands.containsKey(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
_armorStands.put(player.getName(), new HashSet<Integer>());
|
_armorStands.put(player.getUniqueId(), new HashSet<Integer>());
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<Integer> list = _armorStands.get(player.getName());
|
HashSet<Integer> list = _armorStands.get(player.getUniqueId());
|
||||||
|
|
||||||
if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving)
|
if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving)
|
||||||
{
|
{
|
||||||
|
159
Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java
Normal file
159
Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java
Normal file
@ -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<Player> selector)
|
||||||
|
{
|
||||||
|
List<Player> 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<Player> selectPlayers(Predicate<Player> selector)
|
||||||
|
{
|
||||||
|
return Bukkit.getOnlinePlayers().stream().filter(selector).collect(Collectors.<Player>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<Player> 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<Player> 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<Player> 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<Player> inWorld(World world)
|
||||||
|
{
|
||||||
|
return entity -> world == null || entity.getWorld().equals(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will return a {@link Predicate} which will return true <b>if and only if</b> all of the supplied Predicates
|
||||||
|
* return true
|
||||||
|
* @param predicates The Predicates to test against
|
||||||
|
* @return The resulting criterion
|
||||||
|
*/
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> Predicate<T> and(Predicate<T>... predicates)
|
||||||
|
{
|
||||||
|
return t ->
|
||||||
|
{
|
||||||
|
for (Predicate<T> predicate : predicates)
|
||||||
|
{
|
||||||
|
if (!predicate.test(t))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will return a {@link Predicate} which will return true <b>if and only if</b> one of the the supplied Predicates
|
||||||
|
* return true
|
||||||
|
* @param predicates The Predicates to test against
|
||||||
|
* @return The resulting criterion
|
||||||
|
*/
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> Predicate<T> or(Predicate<T>... predicates)
|
||||||
|
{
|
||||||
|
return t ->
|
||||||
|
{
|
||||||
|
for (Predicate<T> predicate : predicates)
|
||||||
|
{
|
||||||
|
if (predicate.test(t))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
@ -9,51 +9,66 @@ import mineplex.serverdata.Utility;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CoreClient
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CoreClient
|
||||||
{
|
{
|
||||||
private int _accountId = -1;
|
private int _accountId = -1;
|
||||||
private long _networkSessionLoginTime;
|
private long _networkSessionLoginTime;
|
||||||
private String _name;
|
private String _name;
|
||||||
private String _disguisedAs;
|
private UUID _uuid;
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Rank _rank, _lastRank;
|
private Rank _rank, _lastRank;
|
||||||
private Rank _disguisedRank;
|
|
||||||
private Rank _tempRank, _lastTemp;
|
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)
|
public CoreClient(Player player)
|
||||||
{
|
{
|
||||||
_player = player;
|
_player = player;
|
||||||
|
_uuid = player.getUniqueId();
|
||||||
_name = player.getName();
|
_name = player.getName();
|
||||||
_networkSessionLoginTime = Utility.currentTimeMillis();
|
_networkSessionLoginTime = Utility.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreClient(String name)
|
public CoreClient(String name, UUID uuid)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
|
_uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetPlayerName()
|
public UUID getUniqueId()
|
||||||
|
{
|
||||||
|
return this._uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player GetPlayer()
|
public Player GetPlayer()
|
||||||
{
|
{
|
||||||
return _player;
|
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;
|
_name = null;
|
||||||
_player = null;
|
_player = null;
|
||||||
@ -63,7 +78,7 @@ public class CoreClient
|
|||||||
{
|
{
|
||||||
_accountId = accountId;
|
_accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank GetRank()
|
public Rank GetRank()
|
||||||
{
|
{
|
||||||
return GetRank(false);
|
return GetRank(false);
|
||||||
@ -73,13 +88,13 @@ public class CoreClient
|
|||||||
{
|
{
|
||||||
if (_rank == null)
|
if (_rank == null)
|
||||||
_rank = Rank.ALL;
|
_rank = Rank.ALL;
|
||||||
|
|
||||||
if (bypass || _tempRank == null)
|
if (bypass || _tempRank == null)
|
||||||
return _rank;
|
return _rank;
|
||||||
else
|
else
|
||||||
return _tempRank;
|
return _tempRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank GetLastRank(boolean temp)
|
public Rank GetLastRank(boolean temp)
|
||||||
{
|
{
|
||||||
if (temp)
|
if (temp)
|
||||||
@ -100,7 +115,7 @@ public class CoreClient
|
|||||||
return _lastRank;
|
return _lastRank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRank(Rank rank, boolean temp)
|
public void SetRank(Rank rank, boolean temp)
|
||||||
{
|
{
|
||||||
if (temp)
|
if (temp)
|
||||||
@ -117,47 +132,70 @@ public class CoreClient
|
|||||||
_rank = rank;
|
_rank = rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getNetworkSessionLoginTime()
|
public long getNetworkSessionLoginTime()
|
||||||
{
|
{
|
||||||
return _networkSessionLoginTime;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getDisguisedSkin()
|
||||||
* Only use this method if the client is actually disguised!
|
{
|
||||||
* @return
|
return this._disguisedSkin;
|
||||||
*/
|
}
|
||||||
public Rank getDisguisedRank() {
|
|
||||||
|
public Rank getDisguisedRank()
|
||||||
|
{
|
||||||
return _disguisedRank;
|
return _disguisedRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisguisedRank(Rank disguisedRank) {
|
public UUID getDisguisedAsUUID()
|
||||||
this._disguisedRank = disguisedRank;
|
{
|
||||||
|
return this._disguisedUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisguised() {
|
public boolean isDisguised()
|
||||||
return _disguised;
|
{
|
||||||
|
if (this._disguisedName == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !this._name.equalsIgnoreCase(this._disguisedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisguised(boolean disguised) {
|
public void disguise(String name, UUID uuid, Rank rank)
|
||||||
this._disguised = disguised;
|
{
|
||||||
|
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;
|
_networkSessionLoginTime = loginTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetTemp()
|
public void resetTemp()
|
||||||
{
|
{
|
||||||
if (_tempRank != null)
|
if (_tempRank != null)
|
||||||
|
@ -2,12 +2,17 @@ package mineplex.core.account;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
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.account.repository.token.ClientToken;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTasks;
|
||||||
import mineplex.core.timing.TimingManager;
|
import mineplex.core.timing.TimingManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import mineplex.core.utils.UtilGameProfile;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -43,43 +49,41 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class CoreClientManager extends MiniPlugin
|
public class CoreClientManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
private static NautHashMap<String, Object> _clientLoginLock = new NautHashMap<String, Object>();
|
private static final Map<String, Object> CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private JavaPlugin _plugin;
|
private JavaPlugin _plugin;
|
||||||
private AccountRepository _repository;
|
private AccountRepository _repository;
|
||||||
private NautHashMap<String, CoreClient> _clientList;
|
private Map<UUID, CoreClient> _clientList = new HashMap<>();
|
||||||
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
private HashSet<UUID> _duplicateLoginGlitchPreventionList = new HashSet<>();
|
||||||
|
|
||||||
private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
|
private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
|
||||||
|
|
||||||
private Object _clientLock = new Object();
|
private final Object _clientLock = new Object();
|
||||||
|
|
||||||
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
||||||
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
||||||
|
|
||||||
private final Rank WHITELIST_BYPASS;
|
private final Rank WHITELIST_BYPASS;
|
||||||
|
|
||||||
public CoreClientManager(JavaPlugin plugin, String webServer)
|
public CoreClientManager(JavaPlugin plugin, String webServer)
|
||||||
{
|
{
|
||||||
this(plugin, webServer, Rank.MODERATOR);
|
this(plugin, webServer, Rank.MODERATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreClientManager(JavaPlugin plugin, String webServer, Rank whitelistBypass)
|
public CoreClientManager(JavaPlugin plugin, String webServer, Rank whitelistBypass)
|
||||||
{
|
{
|
||||||
super("Client Manager", plugin);
|
super("Client Manager", plugin);
|
||||||
|
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_repository = new AccountRepository(plugin, webServer);
|
_repository = new AccountRepository(plugin, webServer);
|
||||||
_clientList = new NautHashMap<String, CoreClient>();
|
WHITELIST_BYPASS = whitelistBypass;
|
||||||
_duplicateLoginGlitchPreventionList = new HashSet<String>();
|
|
||||||
WHITELIST_BYPASS = whitelistBypass;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountRepository getRepository()
|
public AccountRepository getRepository()
|
||||||
{
|
{
|
||||||
return _repository;
|
return _repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCommands()
|
public void addCommands()
|
||||||
{
|
{
|
||||||
@ -87,72 +91,71 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
addCommand(new TestRank(this));
|
addCommand(new TestRank(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreClient Add(String name)
|
public CoreClient Add(String name, UUID uuid)
|
||||||
{
|
{
|
||||||
CoreClient newClient = null;
|
CoreClient newClient = new CoreClient(name, uuid);
|
||||||
|
|
||||||
if (newClient == null)
|
CoreClient oldClient;
|
||||||
|
|
||||||
|
synchronized (_clientLock)
|
||||||
{
|
{
|
||||||
newClient = new CoreClient(name);
|
oldClient = _clientList.put(uuid, newClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreClient oldClient = null;
|
if (oldClient != null)
|
||||||
|
|
||||||
synchronized(_clientLock)
|
|
||||||
{
|
{
|
||||||
oldClient = _clientList.put(name, newClient);
|
oldClient.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldClient != null)
|
|
||||||
{
|
|
||||||
oldClient.Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
return newClient;
|
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
|
// 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)
|
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())
|
CoreClient client = _clientList.get(uuid);
|
||||||
{
|
|
||||||
if(client.getDisguisedAs() != null)
|
|
||||||
if(client.getDisguisedAs().equalsIgnoreCase(name))
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
CoreClient client = _clientList.get(name);
|
|
||||||
|
|
||||||
if (client == null)
|
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;
|
return client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Contains(String name)
|
|
||||||
{
|
|
||||||
return _clientList.containsKey(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreClient Get(Player player)
|
public CoreClient Get(Player player)
|
||||||
{
|
{
|
||||||
return Get(player.getName());
|
return Get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerCountIncludingConnecting()
|
public int getPlayerCountIncludingConnecting()
|
||||||
{
|
{
|
||||||
return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get());
|
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
|
* Get the databse account id for a player. Requires the player is online
|
||||||
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -185,12 +189,12 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_clientsProcessing.incrementAndGet();
|
_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.");
|
event.disallow(Result.KICK_OTHER, "There was a problem logging you in.");
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
@ -202,8 +206,8 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
_clientsProcessing.decrementAndGet();
|
_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())
|
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||||
{
|
{
|
||||||
@ -212,7 +216,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend.");
|
event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,93 +230,84 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
_repository.getAccountId(uuid, callback);
|
_repository.getAccountId(uuid, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadClientByName(final String playerName, final Runnable runnable)
|
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<CoreClient> loadedClient)
|
||||||
|
{
|
||||||
|
runAsync(() ->
|
||||||
{
|
{
|
||||||
public void run()
|
AtomicReference<CoreClient> 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;
|
uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> {}).get().getId();
|
||||||
Gson gson = new Gson();
|
}
|
||||||
|
|
||||||
// Fails if not in DB and if duplicate.
|
String response = "";
|
||||||
UUID uuid = loadUUIDFromDB(playerName);
|
|
||||||
|
if (uuid == null)
|
||||||
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
|
playerInfo.setAccountId(client.getAccountId());
|
||||||
{
|
PlayerCache.getInstance().addPlayer(playerInfo);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
|
||||||
{
|
loaded.set(client);
|
||||||
exception.printStackTrace();
|
}
|
||||||
}
|
catch (Exception exception)
|
||||||
finally
|
{
|
||||||
{
|
exception.printStackTrace();
|
||||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
}
|
||||||
{
|
finally
|
||||||
public void run()
|
{
|
||||||
{
|
UtilTasks.onMainThread(() -> loadedClient.accept(loaded.get())).run();
|
||||||
if (runnable != null)
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadClientByNameSync(final String playerName, final Runnable runnable)
|
public void loadClientByNameSync(final String playerName, final Runnable runnable)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ClientToken token = null;
|
ClientToken token = null;
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
// Fails if not in DB and if duplicate.
|
// Fails if not in DB and if duplicate.
|
||||||
UUID uuid = loadUUIDFromDB(playerName);
|
UUID uuid = loadUUIDFromDB(playerName);
|
||||||
|
|
||||||
if (uuid == null)
|
if (uuid == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -324,9 +319,9 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
System.out.println("Error fetching uuid from mojang : " + exception.getMessage());
|
System.out.println("Error fetching uuid from mojang : " + exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String response = "";
|
String response = "";
|
||||||
|
|
||||||
if (uuid == null)
|
if (uuid == null)
|
||||||
{
|
{
|
||||||
response = _repository.getClientByName(playerName);
|
response = _repository.getClientByName(playerName);
|
||||||
@ -335,20 +330,20 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
response = _repository.getClientByUUID(uuid);
|
response = _repository.getClientByUUID(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
token = gson.fromJson(response, ClientToken.class);
|
|
||||||
|
|
||||||
CoreClient client = Add(playerName);
|
token = gson.fromJson(response, ClientToken.class);
|
||||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
|
CoreClient client = Add(playerName, uuid);
|
||||||
|
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||||
|
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
|
||||||
if (client.getAccountId() > 0)
|
if (client.getAccountId() > 0)
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||||
|
|
||||||
if (playerInfo != null)
|
if (playerInfo != null)
|
||||||
{
|
{
|
||||||
playerInfo.setAccountId(client.getAccountId());
|
playerInfo.setAccountId(client.getAccountId());
|
||||||
@ -358,7 +353,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -372,13 +367,13 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress)
|
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();
|
long timeStart = System.currentTimeMillis();
|
||||||
|
|
||||||
_clientLoginLock.put(client.GetPlayerName(), new Object());
|
CLIENT_LOGIN_LOCKS.put(client.getName(), new Object());
|
||||||
ClientToken token = null;
|
ClientToken token = null;
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
@ -387,33 +382,36 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
|
{
|
||||||
} catch (SQLException e) {
|
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
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.");
|
TimingManager.start(client.getName() + " GetClient.");
|
||||||
token = gson.fromJson(response, ClientToken.class);
|
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);
|
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||||
|
|
||||||
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
TimingManager.stop(client.GetPlayerName() + " Event.");
|
TimingManager.stop(client.getName() + " Event.");
|
||||||
|
|
||||||
TimingManager.start(client.GetPlayerName() + " While Loop.");
|
TimingManager.start(client.getName() + " While Loop.");
|
||||||
while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000)
|
while (CLIENT_LOGIN_LOCKS.containsKey(client.getName()) && System.currentTimeMillis() - timeStart < 15000)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -424,19 +422,19 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TimingManager.stop(client.GetPlayerName() + " While Loop.");
|
TimingManager.stop(client.getName() + " While Loop.");
|
||||||
|
|
||||||
if (_clientLoginLock.containsKey(client.GetPlayerName()))
|
if (CLIENT_LOGIN_LOCKS.containsKey(client.getName()))
|
||||||
{
|
{
|
||||||
System.out.println("MYSQL TOO LONG TO LOGIN....");
|
System.out.println("MYSQL TOO LONG TO LOGIN....");
|
||||||
}
|
}
|
||||||
|
|
||||||
TimingManager.stop(client.GetPlayerName() + " LoadClient Total.");
|
TimingManager.stop(client.getName() + " LoadClient Total.");
|
||||||
|
|
||||||
if (client.getAccountId() > 0)
|
if (client.getAccountId() > 0)
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||||
|
|
||||||
if (playerInfo != null)
|
if (playerInfo != null)
|
||||||
{
|
{
|
||||||
client.setNetworkSessionLoginTime(playerInfo.getLoginTime());
|
client.setNetworkSessionLoginTime(playerInfo.getLoginTime());
|
||||||
@ -444,32 +442,32 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
PlayerCache.getInstance().addPlayer(playerInfo);
|
PlayerCache.getInstance().addPlayer(playerInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !_clientLoginLock.containsKey(client.GetPlayerName());
|
return !CLIENT_LOGIN_LOCKS.containsKey(client.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void Login(PlayerLoginEvent event)
|
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());
|
CoreClient client = Get(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
if (client == null || client.GetRank() == null)
|
if (client == null || client.GetRank() == null)
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect.");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.SetPlayer(event.getPlayer());
|
client.SetPlayer(event.getPlayer());
|
||||||
|
|
||||||
// Reserved Slot Check
|
// Reserved Slot Check
|
||||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
|
||||||
{
|
{
|
||||||
if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false))
|
if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false))
|
||||||
@ -478,27 +476,29 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server is full and no longer accepts players.");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server is full and no longer accepts players.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void Kick(PlayerKickEvent event)
|
public void Kick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
if (event.getReason().contains("You logged in from another location"))
|
if (event.getReason().contains("You logged in from another location"))
|
||||||
{
|
{
|
||||||
_duplicateLoginGlitchPreventionList.add(event.getPlayer().getName());
|
_duplicateLoginGlitchPreventionList.add(event.getPlayer().getUniqueId());
|
||||||
Bukkit.getScheduler().runTask(_plugin, new Runnable() {
|
Bukkit.getScheduler().runTask(_plugin, new Runnable()
|
||||||
public void run() {
|
{
|
||||||
if(!_clientList.containsKey(event.getPlayer().getName())) return;
|
public void run()
|
||||||
Player p = _clientList.get(event.getPlayer().getName()).GetPlayer();
|
{
|
||||||
p.kickPlayer("You're already logged in.");
|
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)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void Quit(PlayerQuitEvent event)
|
public void Quit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
@ -509,11 +509,11 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
// PlayerKick -> old
|
// PlayerKick -> old
|
||||||
// PlayerQuit -> old
|
// PlayerQuit -> old
|
||||||
// Then it glitches because it added new, but then removed old afterwards since its based on name as key.
|
// 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());
|
Del(event.getPlayer().getName(), event.getPlayer().getUniqueId(), _clientList.get(event.getPlayer().getUniqueId()).getAccountId());
|
||||||
_duplicateLoginGlitchPreventionList.remove(event.getPlayer().getName());
|
_duplicateLoginGlitchPreventionList.remove(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,14 +525,14 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (_plugin.getServer().getPlayer(name) != null)
|
if (_plugin.getServer().getPlayer(name) != null)
|
||||||
{
|
{
|
||||||
CoreClient client = Get(name);
|
CoreClient client = Get(name);
|
||||||
|
|
||||||
client.SetRank(newRank, false);
|
client.SetRank(newRank, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, name, uuid, rank, perm);
|
}, name, uuid, rank, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveRank(final Callback<Rank> callback, final String name, final UUID uuid, Rank rank, boolean perm)
|
public void SaveRank(final Callback<Rank> callback, final String name, final UUID uuid, Rank rank, boolean perm)
|
||||||
{
|
{
|
||||||
_repository.saveRank(new Callback<Rank>()
|
_repository.saveRank(new Callback<Rank>()
|
||||||
@ -541,17 +541,17 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (_plugin.getServer().getPlayer(name) != null)
|
if (_plugin.getServer().getPlayer(name) != null)
|
||||||
{
|
{
|
||||||
CoreClient client = Get(name);
|
CoreClient client = Get(name);
|
||||||
|
|
||||||
client.SetRank(newRank, false);
|
client.SetRank(newRank, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.run(newRank);
|
callback.run(newRank);
|
||||||
}
|
}
|
||||||
}, name, uuid, rank, perm);
|
}, name, uuid, rank, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
||||||
{
|
{
|
||||||
_repository.matchPlayerName(new Callback<List<String>>()
|
_repository.matchPlayerName(new Callback<List<String>>()
|
||||||
@ -570,7 +570,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}, playerName);
|
}, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPlayerName(final Player caller, final String playerName, final Callback<String> callback)
|
public void checkPlayerName(final Player caller, final String playerName, final Callback<String> callback)
|
||||||
{
|
{
|
||||||
_repository.matchPlayerName(new Callback<List<String>>()
|
_repository.matchPlayerName(new Callback<List<String>>()
|
||||||
@ -617,51 +617,51 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}, playerName);
|
}, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DONT USE THIS IN PRODUCTION...its for enjin listener -someone you despise but definitely not me (defek7)
|
// DONT USE THIS IN PRODUCTION...its for enjin listener -someone you despise but definitely not me (defek7)
|
||||||
public UUID loadUUIDFromDB(String name)
|
public UUID loadUUIDFromDB(String name)
|
||||||
{
|
{
|
||||||
return _repository.getClientUUID(name);
|
return _repository.getClientUUID(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void cleanGlitchedClients(UpdateEvent event)
|
public void cleanGlitchedClients(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.SLOW)
|
if (event.getType() != UpdateType.SLOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
synchronized(_clientLock)
|
synchronized (_clientLock)
|
||||||
{
|
{
|
||||||
for (Iterator<Entry<String, CoreClient>> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext();)
|
for (Iterator<Entry<UUID, CoreClient>> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
CoreClient client = clientIterator.next().getValue(); // rawr, needed this for custom data - william
|
CoreClient client = clientIterator.next().getValue(); // rawr, needed this for custom data - william
|
||||||
Player clientPlayer = client.GetPlayer();
|
Player clientPlayer = client.GetPlayer();
|
||||||
|
|
||||||
if (clientPlayer != null && !clientPlayer.isOnline())
|
if (clientPlayer != null && !clientPlayer.isOnline())
|
||||||
{
|
{
|
||||||
clientIterator.remove();
|
clientIterator.remove();
|
||||||
|
|
||||||
if (clientPlayer != null)
|
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
|
@EventHandler
|
||||||
public void debug(UpdateEvent event)
|
public void debug(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.SLOWER)
|
if (event.getType() != UpdateType.SLOWER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// System.out.println("=====");
|
// System.out.println("=====");
|
||||||
// System.out.println("Connecting : " + _clientsConnecting.get());
|
// System.out.println("Connecting : " + _clientsConnecting.get());
|
||||||
// System.out.println("Processing : " + _clientsProcessing.get());
|
// System.out.println("Processing : " + _clientsProcessing.get());
|
||||||
// System.out.println("=====");
|
// System.out.println("=====");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
|
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
|
||||||
{
|
{
|
||||||
_loginProcessors.add(processor);
|
_loginProcessors.add(processor);
|
||||||
@ -672,7 +672,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
CoreClient client = Get(player);
|
CoreClient client = Get(player);
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return client.GetRank().has(rank);
|
return client.GetRank().has(rank);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,12 +2,13 @@ package mineplex.core.account;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface ILoginProcessor
|
public interface ILoginProcessor
|
||||||
{
|
{
|
||||||
String getName();
|
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);
|
String getQuery(int accountId, String uuid, String name);
|
||||||
}
|
}
|
@ -3,36 +3,45 @@ package mineplex.core.account.event;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ClientUnloadEvent extends Event
|
public class ClientUnloadEvent extends Event
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private String _name;
|
|
||||||
private int _accountId;
|
|
||||||
|
|
||||||
public ClientUnloadEvent(String name, int accountId)
|
private String _name;
|
||||||
{
|
private UUID _uuid;
|
||||||
_name = name;
|
private int _accountId;
|
||||||
_accountId = accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String GetName()
|
|
||||||
{
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAccountId()
|
public ClientUnloadEvent(String name, UUID uuid, int accountId)
|
||||||
{
|
{
|
||||||
return _accountId;
|
_name = name;
|
||||||
}
|
_accountId = accountId;
|
||||||
|
this._uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public String GetName()
|
||||||
{
|
{
|
||||||
return handlers;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public UUID getUniqueId()
|
||||||
{
|
{
|
||||||
return handlers;
|
return this._uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAccountId()
|
||||||
|
{
|
||||||
|
return _accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
|
|
||||||
for (ILoginProcessor loginProcessor : loginProcessors)
|
for (ILoginProcessor loginProcessor : loginProcessors)
|
||||||
{
|
{
|
||||||
loginProcessor.processLoginResultSet(name, finalId, statement.getResultSet());
|
loginProcessor.processLoginResultSet(name, uuid, finalId, statement.getResultSet());
|
||||||
statement.getMoreResults();
|
statement.getMoreResults();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ import mineplex.core.incognito.IncognitoManager;
|
|||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.stats.event.StatChangeEvent;
|
import mineplex.core.stats.event.StatChangeEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AchievementManager extends MiniPlugin
|
public class AchievementManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
private IncognitoManager _incognitoManager;
|
private IncognitoManager _incognitoManager;
|
||||||
@ -44,16 +46,16 @@ public class AchievementManager extends MiniPlugin
|
|||||||
|
|
||||||
public AchievementData get(Player player, Achievement type)
|
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;
|
int exp = 0;
|
||||||
|
|
||||||
for (String stat : type.getStats())
|
for (String stat : type.getStats())
|
||||||
{
|
{
|
||||||
exp += _statsManager.Get(playerName).getStat(stat);
|
exp += _statsManager.Get(playerUUID).getStat(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return type.getLevelData(exp);
|
return type.getLevelData(exp);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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<Double, Double> 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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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<Class<?>, 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;
|
||||||
|
}
|
||||||
|
}
|
@ -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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<AntiHackAction> _actions = new ArrayList<>();
|
||||||
|
private Map<UUID, Set<AntiHackAction>> _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();
|
||||||
|
}
|
||||||
|
}
|
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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<BanWaveInfo> 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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -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<BanWaveInfo> getBanWaveInfo(int accountId)
|
||||||
|
{
|
||||||
|
List<BanWaveInfo> 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()));
|
||||||
|
}
|
||||||
|
}
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.MiniDbClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
@ -67,15 +68,15 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BenefitData addPlayer(String player)
|
protected BenefitData addPlayer(UUID uuid)
|
||||||
{
|
{
|
||||||
return new BenefitData();
|
return new BenefitData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
|
@ -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)
|
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));
|
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)
|
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
|
//Fill Above
|
||||||
if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && getData(block) != null)
|
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 > 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);
|
if (heightJumps == -1) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1);
|
||||||
@ -213,8 +220,11 @@ public class BlockRestore extends MiniPlugin
|
|||||||
//Snow
|
//Snow
|
||||||
if (!contains(block))
|
if (!contains(block))
|
||||||
getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay, false));
|
getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay, false));
|
||||||
else
|
else
|
||||||
getData(block).update(78, heightAdd, expireTime, meltDelay);
|
{
|
||||||
|
if (getData(block) != null)
|
||||||
|
getData(block).update(78, heightAdd, expireTime, meltDelay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Block block)
|
public boolean contains(Block block)
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
|
||||||
public class BlockRestoreData
|
public class BlockRestoreData
|
||||||
{
|
{
|
||||||
@ -23,6 +24,8 @@ public class BlockRestoreData
|
|||||||
protected long _meltDelay = 0;
|
protected long _meltDelay = 0;
|
||||||
protected long _meltLast = 0;
|
protected long _meltLast = 0;
|
||||||
|
|
||||||
|
protected BlockState _fromState;
|
||||||
|
|
||||||
protected HashMap<Location, Byte> _pad = new HashMap<Location, Byte>();
|
protected HashMap<Location, Byte> _pad = new HashMap<Location, Byte>();
|
||||||
|
|
||||||
protected boolean _restoreOnBreak;
|
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)
|
public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay, boolean restoreOnBreak)
|
||||||
{
|
{
|
||||||
_block = block;
|
_block = block;
|
||||||
|
_fromState = block.getState();
|
||||||
|
|
||||||
_fromID = fromID;
|
_fromID = fromID;
|
||||||
_fromData = fromData;
|
_fromData = fromData;
|
||||||
@ -163,6 +167,8 @@ public class BlockRestoreData
|
|||||||
public void restore()
|
public void restore()
|
||||||
{
|
{
|
||||||
_block.setTypeIdAndData(_fromID, _fromData, true);
|
_block.setTypeIdAndData(_fromID, _fromData, true);
|
||||||
|
_fromState.update();
|
||||||
|
|
||||||
handleLilypad(true);
|
handleLilypad(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +41,14 @@ public class BlockRestoreMap
|
|||||||
public void addBlockData(BlockData blockData)
|
public void addBlockData(BlockData blockData)
|
||||||
{
|
{
|
||||||
Block block = blockData.Block;
|
Block block = blockData.Block;
|
||||||
|
|
||||||
if (!_blocks[block.getY()].containsKey(block))
|
if (block.getY() > 0 && block.getY() < _blocks.length)
|
||||||
_blocks[block.getY()].put(block, blockData);
|
{
|
||||||
|
if (!_blocks[block.getY()].containsKey(block))
|
||||||
|
{
|
||||||
|
_blocks[block.getY()].put(block, blockData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_changedBlocks.add(blockData.Block);
|
_changedBlocks.add(blockData.Block);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import mineplex.core.bonuses.gui.BonusGui;
|
|||||||
import mineplex.core.bonuses.gui.SpinGui;
|
import mineplex.core.bonuses.gui.SpinGui;
|
||||||
import mineplex.core.bonuses.redis.VoteHandler;
|
import mineplex.core.bonuses.redis.VoteHandler;
|
||||||
import mineplex.core.bonuses.redis.VotifierCommand;
|
import mineplex.core.bonuses.redis.VotifierCommand;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.*;
|
import mineplex.core.common.util.*;
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
@ -35,6 +34,7 @@ import mineplex.core.recharge.Recharge;
|
|||||||
import mineplex.core.reward.RewardManager;
|
import mineplex.core.reward.RewardManager;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.status.ServerStatusManager;
|
import mineplex.core.status.ServerStatusManager;
|
||||||
|
import mineplex.core.thank.ThankManager;
|
||||||
import mineplex.core.treasure.TreasureType;
|
import mineplex.core.treasure.TreasureType;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -123,7 +123,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
private StatsManager _statsManager;
|
private StatsManager _statsManager;
|
||||||
private FacebookManager _facebookManager;
|
private FacebookManager _facebookManager;
|
||||||
private YoutubeManager _youtubeManager;
|
private YoutubeManager _youtubeManager;
|
||||||
private BoosterManager _boosterManager;
|
private ThankManager _thankManager;
|
||||||
public boolean _enabled;
|
public boolean _enabled;
|
||||||
private Npc _carlNpc;
|
private Npc _carlNpc;
|
||||||
private AnimationCarl _animation;
|
private AnimationCarl _animation;
|
||||||
@ -162,7 +162,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
updateOffSet();
|
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);
|
super("Bonus", plugin);
|
||||||
_repository = new BonusRepository(plugin, this, donationManager);
|
_repository = new BonusRepository(plugin, this, donationManager);
|
||||||
@ -171,7 +171,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
_npcManager = npcManager;
|
_npcManager = npcManager;
|
||||||
_hologramManager = hologramManager;
|
_hologramManager = hologramManager;
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
_boosterManager = boosterManager;
|
_thankManager = thankManager;
|
||||||
|
|
||||||
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager);
|
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager);
|
||||||
|
|
||||||
@ -825,7 +825,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
if (entity.equals(_carlNpc.getEntity()))
|
if (entity.equals(_carlNpc.getEntity()))
|
||||||
{
|
{
|
||||||
updateDailyStreak(event.getPlayer());
|
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<BonusClientData> implements I
|
|||||||
if (event.getEntity().equals(_carlNpc.getEntity()))
|
if (event.getEntity().equals(_carlNpc.getEntity()))
|
||||||
{
|
{
|
||||||
updateDailyStreak(player);
|
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<BonusClientData> implements I
|
|||||||
if (canDaily(player)) availableRewards++;
|
if (canDaily(player)) availableRewards++;
|
||||||
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
|
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
|
||||||
if (!_facebookManager.hasRedeemed(player)) availableRewards++;
|
if (!_facebookManager.hasRedeemed(player)) availableRewards++;
|
||||||
if (_boosterManager.getTipManager().Get(player).getTips() > 0) availableRewards++;
|
if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++;
|
||||||
|
|
||||||
Hologram hologram;
|
Hologram hologram;
|
||||||
|
|
||||||
@ -987,7 +987,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BonusClientData addPlayer(String player)
|
protected BonusClientData addPlayer(UUID uuid)
|
||||||
{
|
{
|
||||||
return new BonusClientData();
|
return new BonusClientData();
|
||||||
}
|
}
|
||||||
@ -1011,7 +1011,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void UnloadPlayer(final ClientUnloadEvent event)
|
public void UnloadPlayer(final ClientUnloadEvent event)
|
||||||
{
|
{
|
||||||
final BonusClientData clientData = Get(event.GetName());
|
final BonusClientData clientData = Get(event.getUniqueId());
|
||||||
|
|
||||||
if (clientData.getHologram() != null)
|
if (clientData.getHologram() != null)
|
||||||
clientData.getHologram().stop();
|
clientData.getHologram().stop();
|
||||||
@ -1183,9 +1183,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
@ -1194,8 +1194,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';";
|
return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';";
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoosterManager getBoosterManager()
|
public ThankManager getThankManager()
|
||||||
{
|
{
|
||||||
return _boosterManager;
|
return _thankManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package mineplex.core.bonuses.commands;
|
package mineplex.core.bonuses.commands;
|
||||||
|
|
||||||
import mineplex.core.boosters.BoosterManager;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
@ -18,7 +17,7 @@ public class GuiCommand extends CommandBase<BonusManager>
|
|||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ package mineplex.core.bonuses.gui;
|
|||||||
|
|
||||||
import mineplex.core.bonuses.BonusManager;
|
import mineplex.core.bonuses.BonusManager;
|
||||||
import mineplex.core.bonuses.gui.buttons.*;
|
import mineplex.core.bonuses.gui.buttons.*;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
|
||||||
import mineplex.core.facebook.FacebookManager;
|
import mineplex.core.facebook.FacebookManager;
|
||||||
import mineplex.core.gui.SimpleGui;
|
import mineplex.core.gui.SimpleGui;
|
||||||
import mineplex.core.reward.RewardManager;
|
import mineplex.core.reward.RewardManager;
|
||||||
|
import mineplex.core.thank.ThankManager;
|
||||||
import mineplex.core.youtube.YoutubeManager;
|
import mineplex.core.youtube.YoutubeManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -15,7 +15,7 @@ public class BonusGui extends SimpleGui
|
|||||||
|
|
||||||
private BonusManager manager;
|
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);
|
super(plugin, player, player.getName() + "'s Bonuses", 5 * 9);
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class BonusGui extends SimpleGui
|
|||||||
|
|
||||||
setItem(23, new TwitterButton(player));
|
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));
|
setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,28 @@
|
|||||||
package mineplex.core.bonuses.gui.buttons;
|
package mineplex.core.bonuses.gui.buttons;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import mineplex.core.bonuses.BonusManager;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
|
||||||
import mineplex.core.common.CurrencyType;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
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.GuiItem;
|
||||||
import mineplex.core.gui.ItemRefresher;
|
import mineplex.core.gui.ItemRefresher;
|
||||||
import mineplex.core.gui.pages.LoadingWindow;
|
import mineplex.core.gui.pages.LoadingWindow;
|
||||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.thank.ThankManager;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import org.bukkit.*;
|
||||||
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 org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ClaimTipsButton implements GuiItem, Listener
|
public class ClaimTipsButton implements GuiItem, Listener
|
||||||
{
|
{
|
||||||
private ItemStack _item;
|
private ItemStack _item;
|
||||||
@ -45,12 +32,12 @@ public class ClaimTipsButton implements GuiItem, Listener
|
|||||||
private ItemRefresher _gui;
|
private ItemRefresher _gui;
|
||||||
|
|
||||||
private BonusManager _bonusManager;
|
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;
|
_bonusManager = bonusManager;
|
||||||
_boosterManager = boosterManager;
|
_thankManager = thankManager;
|
||||||
_player = player;
|
_player = player;
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_gui = gui;
|
_gui = gui;
|
||||||
@ -72,12 +59,17 @@ public class ClaimTipsButton implements GuiItem, Listener
|
|||||||
@Override
|
@Override
|
||||||
public void click(ClickType clickType)
|
public void click(ClickType clickType)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(_player, "Claim Tips Button", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isAvailable()) {
|
if (isAvailable()) {
|
||||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||||
refreshItem();
|
refreshItem();
|
||||||
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||||
_boosterManager.getTipManager().claimTips(getPlayer(), claimed -> {
|
_thankManager.claimThanks(getPlayer(), claimThankResult -> {
|
||||||
if (claimed > 0)
|
if (claimThankResult != null && claimThankResult.getClaimed() > 0)
|
||||||
{
|
{
|
||||||
// Woo, success!
|
// Woo, success!
|
||||||
setItem();
|
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();
|
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
|
// Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect
|
||||||
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
|
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
|
||||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
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
|
// No tips to claim
|
||||||
if (getPlayer().getOpenInventory() != null)
|
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!"));
|
UtilPlayer.message(getPlayer(), F.main("Carl", "You have no rewards to claim!"));
|
||||||
@ -133,7 +125,7 @@ public class ClaimTipsButton implements GuiItem, Listener
|
|||||||
if (isAvailable())
|
if (isAvailable())
|
||||||
{
|
{
|
||||||
material = Material.EMERALD;
|
material = Material.EMERALD;
|
||||||
itemName = C.cGreen + C.Bold + "Game Amplifiers";
|
itemName = C.cGreen + C.Bold + "Thank Rewards";
|
||||||
lore.add(" ");
|
lore.add(" ");
|
||||||
lore.add(C.cYellow + "Your Rewards");
|
lore.add(C.cYellow + "Your Rewards");
|
||||||
lore.add(" " + C.cWhite + getTips() + " Treasure Shards");
|
lore.add(" " + C.cWhite + getTips() + " Treasure Shards");
|
||||||
@ -143,10 +135,11 @@ public class ClaimTipsButton implements GuiItem, Listener
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
material = Material.REDSTONE_BLOCK;
|
material = Material.REDSTONE_BLOCK;
|
||||||
itemName = C.cRed + C.Bold + "Game Amplifiers";
|
itemName = C.cRed + C.Bold + "Thank Rewards";
|
||||||
|
|
||||||
lore.add(" ");
|
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(" ");
|
||||||
lore.add(C.cWhite + "Get Amplifiers at " + C.cGreen + "mineplex.com/shop");
|
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()
|
private int getTips()
|
||||||
{
|
{
|
||||||
return _boosterManager.getTipManager().Get(getPlayer()).getTips();
|
return _thankManager.Get(_player).getThankToClaim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAvailable()
|
private boolean isAvailable()
|
||||||
|
@ -13,6 +13,7 @@ import mineplex.core.gui.ItemRefresher;
|
|||||||
import mineplex.core.gui.pages.LoadingWindow;
|
import mineplex.core.gui.pages.LoadingWindow;
|
||||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -69,6 +70,11 @@ public class DailyBonusButton implements GuiItem, Listener
|
|||||||
@Override
|
@Override
|
||||||
public void click(ClickType clickType)
|
public void click(ClickType clickType)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(_player, "Carl Daily Bonus", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isAvailable()) {
|
if (isAvailable()) {
|
||||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||||
refreshItem();
|
refreshItem();
|
||||||
|
@ -17,6 +17,7 @@ import mineplex.core.gui.pages.TimedMessageWindow;
|
|||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.poll.Poll;
|
import mineplex.core.poll.Poll;
|
||||||
import mineplex.core.poll.PollManager;
|
import mineplex.core.poll.PollManager;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -109,6 +110,11 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public void click(ClickType clickType)
|
public void click(ClickType clickType)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(getPlayer(), "Poll Main Button", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_poll == null)
|
if (_poll == null)
|
||||||
{
|
{
|
||||||
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f);
|
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 1.6f);
|
||||||
@ -195,6 +201,11 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public void click(ClickType clickType)
|
public void click(ClickType clickType)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(getPlayer(), "Poll Answer Button", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_create = true;
|
_create = true;
|
||||||
|
|
||||||
_pollManager.answerPoll(getPlayer(), _poll, num + 1);
|
_pollManager.answerPoll(getPlayer(), _poll, num + 1);
|
||||||
|
@ -13,6 +13,7 @@ import mineplex.core.gui.ItemRefresher;
|
|||||||
import mineplex.core.gui.pages.LoadingWindow;
|
import mineplex.core.gui.pages.LoadingWindow;
|
||||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -78,6 +79,11 @@ public class RankBonusButton implements GuiItem, Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void click(ClickType clickType)
|
public void click(ClickType clickType)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(_player, "Claim Rank Bonus", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isAvailable() && _bonusManager.isPastAugust()) {
|
if (isAvailable() && _bonusManager.isPastAugust()) {
|
||||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||||
refreshItem();
|
refreshItem();
|
||||||
|
@ -5,6 +5,7 @@ import mineplex.core.common.jsonchat.JsonMessage;
|
|||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.gui.GuiItem;
|
import mineplex.core.gui.GuiItem;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.youtube.YoutubeManager;
|
import mineplex.core.youtube.YoutubeManager;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -59,6 +60,11 @@ public class YoutubeButton implements GuiItem
|
|||||||
@Override
|
@Override
|
||||||
public void click(ClickType clickType)
|
public void click(ClickType clickType)
|
||||||
{
|
{
|
||||||
|
if (!Recharge.Instance.use(_player, "Use Youtube Button", 1000, false, false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_player.closeInventory();
|
_player.closeInventory();
|
||||||
|
|
||||||
final String message;
|
final String message;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package mineplex.core.boosters;
|
package mineplex.core.boosters;
|
||||||
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.boosters.command.BoosterCommand;
|
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.event.BoosterUpdateEvent;
|
||||||
import mineplex.core.boosters.gui.BoosterShop;
|
import mineplex.core.boosters.gui.BoosterShop;
|
||||||
import mineplex.core.boosters.redis.BoosterUpdateRepository;
|
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.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.UtilGear;
|
import mineplex.core.common.util.UtilGear;
|
||||||
@ -19,12 +18,12 @@ import mineplex.core.common.util.UtilServer;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.thank.ThankManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -64,8 +63,8 @@ public class BoosterManager extends MiniPlugin
|
|||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private DonationManager _donationManager;
|
private DonationManager _donationManager;
|
||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
|
private BoosterThankManager _boosterThankManager;
|
||||||
|
|
||||||
private BoosterTipManager _tipManager;
|
|
||||||
private BoosterShop _shop;
|
private BoosterShop _shop;
|
||||||
private String _boosterGroup;
|
private String _boosterGroup;
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ public class BoosterManager extends MiniPlugin
|
|||||||
private long _cacheLastUpdated;
|
private long _cacheLastUpdated;
|
||||||
private Map<String, List<Booster>> _boosterCache = new HashMap<>();
|
private Map<String, List<Booster>> _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);
|
super("Booster Manager", plugin);
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ public class BoosterManager extends MiniPlugin
|
|||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
|
|
||||||
_tipManager = new BoosterTipManager(plugin, clientManager, donationManager);
|
_boosterThankManager = new BoosterThankManager(plugin, clientManager, thankManager);
|
||||||
_shop = new BoosterShop(this, clientManager, donationManager);
|
_shop = new BoosterShop(this, clientManager, donationManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -335,9 +334,9 @@ public class BoosterManager extends MiniPlugin
|
|||||||
handleBoosterUpdate(event.getBoosterMap());
|
handleBoosterUpdate(event.getBoosterMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoosterTipManager getTipManager()
|
public BoosterThankManager getBoosterThankManager()
|
||||||
{
|
{
|
||||||
return _tipManager;
|
return _boosterThankManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
||||||
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -21,6 +22,9 @@ public class BoosterProcessor implements ConfirmationProcessor
|
|||||||
_player = player;
|
_player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Inventory inventory) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(ConfirmationCallback callback)
|
public void process(ConfirmationCallback callback)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
import mineplex.core.common.api.ApiEndpoint;
|
import mineplex.core.common.api.ApiEndpoint;
|
||||||
import mineplex.core.common.api.ApiFieldNamingStrategy;
|
import mineplex.core.common.api.ApiFieldNamingStrategy;
|
||||||
|
import mineplex.core.common.api.ApiHost;
|
||||||
import mineplex.core.common.api.ApiResponse;
|
import mineplex.core.common.api.ApiResponse;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -23,7 +24,7 @@ public class BoosterRepository extends ApiEndpoint
|
|||||||
{
|
{
|
||||||
public BoosterRepository()
|
public BoosterRepository()
|
||||||
{
|
{
|
||||||
super("/booster", new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy())
|
super(ApiHost.AMPLIFIERS, "/booster", new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy())
|
||||||
// .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
// .registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create());
|
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create());
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
public BoosterCommand(BoosterManager plugin)
|
public BoosterCommand(BoosterManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "amplifier", "booster");
|
super(plugin, Rank.ALL, "amplifier", "booster");
|
||||||
|
|
||||||
AddCommand(new AddCommand(plugin));
|
AddCommand(new AddCommand(plugin));
|
||||||
AddCommand(new GuiCommand(plugin));
|
AddCommand(new GuiCommand(plugin));
|
||||||
AddCommand(new ReloadCommand(plugin));
|
AddCommand(new ReloadCommand(plugin));
|
||||||
|
AddCommand(new ThankCommand(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,5 +28,6 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.help("amplifier add <group>", "Add an amplifier to that group", Rank.DEVELOPER));
|
UtilPlayer.message(caller, F.help("amplifier add <group>", "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 gui", "Open Amplifier GUI", Rank.DEVELOPER));
|
||||||
|
UtilPlayer.message(caller, F.help("amplifier thank <group>", "Thank an Amplifier for a specific Booster Group", Rank.ALL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<BoosterManager>
|
||||||
|
{
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import mineplex.core.account.CoreClientManager;
|
|||||||
import mineplex.core.boosters.Booster;
|
import mineplex.core.boosters.Booster;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.boosters.BoosterProcessor;
|
import mineplex.core.boosters.BoosterProcessor;
|
||||||
import mineplex.core.common.Pair;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
@ -115,8 +114,7 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
|
|||||||
ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false);
|
ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false);
|
||||||
|
|
||||||
BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer());
|
BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer());
|
||||||
ConfirmationPage<BoosterManager, BoosterShop> page = new ConfirmationPage<>(getPlugin(), getShop(),
|
ConfirmationPage<BoosterManager, BoosterShop> page = new ConfirmationPage<>(getPlayer(), this, processor, booster);
|
||||||
getClientManager(), getDonationManager(), getPlayer(), this, processor, booster);
|
|
||||||
getShop().openPageForPlayer(getPlayer(), page);
|
getShop().openPageForPlayer(getPlayer(), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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<TipAddResult> 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;
|
||||||
|
}
|
||||||
|
}
|
@ -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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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<PlayerTipData>
|
|
||||||
{
|
|
||||||
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<TipAddResult> 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<Integer> 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,6 +7,7 @@ public enum TipAddResult
|
|||||||
{
|
{
|
||||||
ALREADY_TIPPED_BOOSTER("You have already thanked this Amplifier!"),
|
ALREADY_TIPPED_BOOSTER("You have already thanked this Amplifier!"),
|
||||||
INVALID_ACCOUNT_ID("Uh oh, something went wrong. Try relogging"),
|
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!"),
|
CANNOT_TIP_SELF("You can't thank yourself, silly!"),
|
||||||
ON_COOLDOWN(null),
|
ON_COOLDOWN(null),
|
||||||
SUCCESS(null);
|
SUCCESS(null);
|
||||||
|
@ -12,19 +12,13 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.hologram.Hologram;
|
import mineplex.core.hologram.Hologram;
|
||||||
import mineplex.core.hologram.HologramManager;
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.stats.StatsManager;
|
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.Region;
|
||||||
import mineplex.serverdata.redis.counter.GoalCounter;
|
import mineplex.serverdata.redis.counter.GoalCounter;
|
||||||
import mineplex.serverdata.redis.counter.GoalCounterListener;
|
import mineplex.serverdata.redis.counter.GoalCounterListener;
|
||||||
import mineplex.serverdata.servers.ConnectionData;
|
import mineplex.serverdata.servers.ConnectionData;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -63,7 +57,7 @@ public class Fountain implements GoalCounterListener
|
|||||||
_name = name;
|
_name = name;
|
||||||
_dataKey = dataKey;
|
_dataKey = dataKey;
|
||||||
_location = location;
|
_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 = new GoalCounter(writeConnection, readConnection, region, dataKey, goal);
|
||||||
_counter.addListener(this);
|
_counter.addListener(this);
|
||||||
_brawlActive = false;
|
_brawlActive = false;
|
||||||
|
@ -3,17 +3,13 @@ package mineplex.core.brawl.fountain;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.brawl.fountain.command.FountainCommand;
|
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.C;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilWorld;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.hologram.HologramManager;
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.serverdata.Region;
|
import mineplex.serverdata.Region;
|
||||||
import mineplex.serverdata.redis.counter.Counter;
|
|
||||||
import mineplex.serverdata.servers.ConnectionData;
|
import mineplex.serverdata.servers.ConnectionData;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -22,12 +18,9 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
*/
|
*/
|
||||||
@ -55,7 +48,7 @@ public class FountainManager extends MiniPlugin
|
|||||||
int goal = 70000000;//!new File("eu.dat").exists() ? 200000000 : 20000000;
|
int goal = 70000000;//!new File("eu.dat").exists() ? 200000000 : 20000000;
|
||||||
_gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"),
|
_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 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);
|
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package mineplex.core.brawl.fountain;
|
package mineplex.core.brawl.fountain;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -14,14 +13,8 @@ public class GemFountainSalesPackage extends SalesPackageBase
|
|||||||
{
|
{
|
||||||
super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1);
|
super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1);
|
||||||
|
|
||||||
CurrencyCostMap.put(CurrencyType.GEM, gems);
|
CurrencyCostMap.put(GlobalCurrency.GEM, gems);
|
||||||
KnownPackage = false;
|
KnownPackage = false;
|
||||||
OneTimePurchaseOnly = false;
|
OneTimePurchaseOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sold(Player player, CurrencyType currencyType)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package mineplex.core.brawl.fountain.command;
|
|||||||
|
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
import mineplex.core.brawl.fountain.FountainManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.CurrencyType;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -53,7 +53,7 @@ public class AddCommand extends CommandBase<FountainManager>
|
|||||||
UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!"));
|
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)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,8 @@ import mineplex.core.account.CoreClientManager;
|
|||||||
import mineplex.core.brawl.fountain.Fountain;
|
import mineplex.core.brawl.fountain.Fountain;
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
import mineplex.core.brawl.fountain.FountainManager;
|
||||||
import mineplex.core.brawl.fountain.gui.button.FountainAddButton;
|
import mineplex.core.brawl.fountain.gui.button.FountainAddButton;
|
||||||
import mineplex.core.common.CurrencyType;
|
|
||||||
import mineplex.core.common.MaterialData;
|
import mineplex.core.common.MaterialData;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
@ -77,7 +77,7 @@ public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
|||||||
|
|
||||||
if (canAdd)
|
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 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 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);
|
ShopItem add3 = new ShopItem(Material.EMERALD_BLOCK, "Add 10,000 Gems", new String[]{}, 1, playerGems < 10000, false);
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package mineplex.core.brawl.fountain.gui.button;
|
package mineplex.core.brawl.fountain.gui.button;
|
||||||
|
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
|
||||||
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
|
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
|
||||||
import mineplex.core.brawl.fountain.gui.FountainPage;
|
import mineplex.core.brawl.fountain.gui.FountainPage;
|
||||||
import mineplex.core.brawl.fountain.gui.FountainShop;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
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.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
@ -30,13 +29,10 @@ public class FountainAddButton implements IButton
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<FountainManager, FountainShop>(_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.getPlugin().getGemFountain().increment(player, _gems, null);
|
}), _salesPackage.buildIcon()));
|
||||||
_page.refresh();
|
|
||||||
}
|
|
||||||
}, _page, _salesPackage, CurrencyType.GEM, player));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
package mineplex.core.chat;
|
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.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.achievement.AchievementManager;
|
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.UtilText;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.incognito.IncognitoManager;
|
import mineplex.core.incognito.IncognitoManager;
|
||||||
|
import mineplex.core.preferences.Preference;
|
||||||
import mineplex.core.preferences.PreferencesManager;
|
import mineplex.core.preferences.PreferencesManager;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
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
|
public class Chat extends MiniPlugin
|
||||||
{
|
{
|
||||||
@ -69,7 +68,6 @@ public class Chat extends MiniPlugin
|
|||||||
|
|
||||||
private int _chatSlow = 0;
|
private int _chatSlow = 0;
|
||||||
private long _silenced = 0;
|
private long _silenced = 0;
|
||||||
private boolean _threeSecondDelay = true;
|
|
||||||
|
|
||||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
|
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
|
||||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = new ArrayList<>();
|
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = new ArrayList<>();
|
||||||
@ -213,7 +211,7 @@ public class Chat extends MiniPlugin
|
|||||||
{
|
{
|
||||||
for (Iterator<Player> playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();)
|
for (Iterator<Player> playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();)
|
||||||
{
|
{
|
||||||
if (!_preferences.Get(playerIterator.next()).ShowChat)
|
if (!_preferences.get(playerIterator.next()).isActive(Preference.SHOW_CHAT))
|
||||||
playerIterator.remove();
|
playerIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,15 +347,6 @@ public class Chat extends MiniPlugin
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
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) &&
|
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
||||||
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
||||||
{
|
{
|
||||||
@ -645,11 +634,6 @@ public class Chat extends MiniPlugin
|
|||||||
_playerLastMessage.remove(event.getPlayer().getUniqueId());
|
_playerLastMessage.remove(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThreeSecondDelay(boolean b)
|
|
||||||
{
|
|
||||||
_threeSecondDelay = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the function returns Boolean.TRUE then the message will be CANCELLED.
|
* If the function returns Boolean.TRUE then the message will be CANCELLED.
|
||||||
*/
|
*/
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
package mineplex.core.cosmetic.ui;
|
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.account.CoreClientManager;
|
||||||
import mineplex.core.common.CurrencyType;
|
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
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.donation.DonationManager;
|
||||||
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
|
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
|
||||||
import mineplex.core.shop.ShopBase;
|
import mineplex.core.shop.ShopBase;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.core.updater.UpdateType;
|
import org.bukkit.entity.Player;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
||||||
{
|
{
|
||||||
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
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);
|
plugin.getPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.getPlugin(), "MC|ItemName", this);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
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.cosmetic.ui.page.MountPage;
|
import mineplex.core.cosmetic.ui.page.MountPage;
|
||||||
import mineplex.core.mount.Mount;
|
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
|
public class MountButton implements IButton
|
||||||
{
|
{
|
||||||
@ -25,13 +23,10 @@ public class MountButton implements IButton
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(final Player player, ClickType clickType)
|
public void onClick(final Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(_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.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1);
|
}), _mount.buildIcon()));
|
||||||
_page.refresh();
|
|
||||||
}
|
|
||||||
}, _page, _mount, CurrencyType.TREASURE_SHARD, player));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
package mineplex.core.cosmetic.ui.page;
|
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.account.CoreClientManager;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
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.gadget.types.OutfitGadget;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
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.
|
* Created by shaun on 14-09-15.
|
||||||
@ -38,7 +37,7 @@ public class CostumePage extends GadgetPage
|
|||||||
|
|
||||||
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.COSTUME))
|
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.COSTUME))
|
||||||
{
|
{
|
||||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
OutfitGadget outfitGadget = ((OutfitGadget) gadget);
|
OutfitGadget outfitGadget = ((OutfitGadget) gadget);
|
||||||
|
@ -1,12 +1,29 @@
|
|||||||
package mineplex.core.cosmetic.ui.page;
|
package mineplex.core.cosmetic.ui.page;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import java.util.Arrays;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import java.util.List;
|
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.UtilServer;
|
||||||
import mineplex.core.common.util.banner.CountryFlag;
|
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.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.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
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.BannerMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import java.util.ArrayList;
|
||||||
import mineplex.core.common.CurrencyType;
|
import java.util.Arrays;
|
||||||
import mineplex.core.common.util.C;
|
import java.util.List;
|
||||||
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;
|
|
||||||
|
|
||||||
public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
|
|
||||||
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM))
|
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM))
|
||||||
{
|
{
|
||||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3)
|
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
addGadget(gadget, slot);
|
addGadget(gadget, slot);
|
||||||
@ -105,64 +105,64 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
|
|
||||||
if (!gadget.ownsGadget(getPlayer()))
|
if (!gadget.ownsGadget(getPlayer()))
|
||||||
{
|
{
|
||||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||||
{
|
{
|
||||||
//Nothing
|
//Nothing
|
||||||
}
|
}
|
||||||
//Chest Unlocks
|
//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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Treasure Chests");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Valentines Gifts");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Purchased from shop.mineplex.com");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Freedom Chests");
|
itemLore.add(C.cBlue + "Found in Freedom Chests");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rank Unlocks
|
//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.cBlack);
|
||||||
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
||||||
@ -178,12 +178,12 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
itemLore.add(C.cWhite + "You own " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getName()));
|
itemLore.add(C.cWhite + "You own " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getName()));
|
||||||
|
|
||||||
// boolean canAffordAmmo = true;
|
// boolean canAffordAmmo = true;
|
||||||
// if (itemGadget.getAmmo().getCost(CurrencyType.Coins) > 0)
|
// if (itemGadget.getAmmo().getCost(GlobalCurrency.Coins) > 0)
|
||||||
// {
|
// {
|
||||||
// itemLore.add(C.cBlack);
|
// 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");
|
// itemLore.add(C.cGreen + "Right-Click To Purchase");
|
||||||
// }
|
// }
|
||||||
@ -239,26 +239,26 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||||
{
|
{
|
||||||
itemLore.add(C.cBlack);
|
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.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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Click to Purchase");
|
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));
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||||
@ -291,7 +291,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH
|
if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH
|
||||||
|| gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP)
|
|| 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();
|
gadgetItemStack = CountryFlag.USA.getBanner();
|
||||||
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
||||||
@ -314,7 +314,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH
|
if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH
|
||||||
|| gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP)
|
|| 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();
|
gadgetItemStack = CountryFlag.USA.getBanner();
|
||||||
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
||||||
@ -329,20 +329,20 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||||
{
|
{
|
||||||
itemLore.add(C.cBlack);
|
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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Click to Purchase");
|
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));
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||||
@ -363,7 +363,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
ItemGadget itemGadget = (ItemGadget)gadget;
|
ItemGadget itemGadget = (ItemGadget)gadget;
|
||||||
|
|
||||||
if (itemGadget.getAmmo().getCost(CurrencyType.TREASURE_SHARD) < 0)
|
if (itemGadget.getAmmo().getCost(GlobalCurrency.TREASURE_SHARD) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,14 +372,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(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();
|
||||||
getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity()));
|
}), gadget.buildIcon()));
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
}, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), CurrencyType.TREASURE_SHARD, getPlayer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activateGadget(Player player, Gadget gadget)
|
public void activateGadget(Player player, Gadget gadget)
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
package mineplex.core.cosmetic.ui.page;
|
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.account.CoreClientManager;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.LineFormat;
|
import mineplex.core.common.util.LineFormat;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilText;
|
import mineplex.core.common.util.UtilText;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
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.donation.DonationManager;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
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.IButton;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
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<CosmeticManager, CosmeticShop>
|
public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||||
{
|
{
|
||||||
@ -41,7 +53,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
// Treasure Shards
|
// Treasure Shards
|
||||||
int treasureShards = getDonationManager().Get(getPlayer()).getCoins();
|
int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD);
|
||||||
|
|
||||||
List<String> shardLore = new ArrayList<String>();
|
List<String> shardLore = new ArrayList<String>();
|
||||||
shardLore.add(" ");
|
shardLore.add(" ");
|
||||||
@ -100,7 +112,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer());
|
Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer());
|
||||||
for (Mount<?> mount : getPlugin().getMountManager().getMounts())
|
for (Mount<?> mount : getPlugin().getMountManager().getMounts())
|
||||||
{
|
{
|
||||||
if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName()))
|
if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName()))
|
||||||
{
|
{
|
||||||
mountOwned++;
|
mountOwned++;
|
||||||
}
|
}
|
||||||
@ -112,7 +124,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
int petMax = 0;
|
int petMax = 0;
|
||||||
for (Pet pet : getPlugin().getPetManager().getFactory().GetPets())
|
for (Pet pet : getPlugin().getPetManager().getFactory().GetPets())
|
||||||
{
|
{
|
||||||
NautHashMap<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
|
Map<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
|
||||||
if (pets != null && pets.containsKey(pet.getPetType()))
|
if (pets != null && pets.containsKey(pet.getPetType()))
|
||||||
{
|
{
|
||||||
petOwned++;
|
petOwned++;
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
package mineplex.core.cosmetic.ui.page;
|
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.account.CoreClientManager;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
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.activate.ActivateMountButton;
|
||||||
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateMountButton;
|
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateMountButton;
|
||||||
import mineplex.core.cosmetic.ui.button.MountButton;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
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<CosmeticManager, CosmeticShop>
|
public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||||
{
|
{
|
||||||
@ -60,67 +59,67 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
itemLore.add(C.cBlack);
|
itemLore.add(C.cBlack);
|
||||||
itemLore.addAll(Arrays.asList(mount.getDescription()));
|
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
|
//Nothing
|
||||||
}
|
}
|
||||||
//Chest Unlocks
|
//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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Treasure Chests");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Freedom Chests");
|
itemLore.add(C.cBlue + "Found in Freedom Chests");
|
||||||
}
|
}
|
||||||
//Rank Unlocks
|
//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.cBlack);
|
||||||
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
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()))
|
if (mount.getActive().containsKey(getPlayer()))
|
||||||
{
|
{
|
||||||
@ -139,20 +138,20 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||||
{
|
{
|
||||||
itemLore.add(C.cBlack);
|
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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Click to Purchase");
|
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));
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||||
|
@ -1,33 +1,16 @@
|
|||||||
package mineplex.core.cosmetic.ui.page;
|
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.account.CoreClientManager;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||||
import mineplex.core.cosmetic.ui.PetSorter;
|
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.PetButton;
|
||||||
import mineplex.core.cosmetic.ui.button.RenamePetButton;
|
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.donation.DonationManager;
|
||||||
import mineplex.core.pet.Pet;
|
import mineplex.core.pet.Pet;
|
||||||
import mineplex.core.pet.PetExtra;
|
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.item.ShopItem;
|
||||||
import mineplex.core.shop.page.AnvilContainer;
|
import mineplex.core.shop.page.AnvilContainer;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
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<CosmeticManager, CosmeticShop>
|
public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||||
{
|
{
|
||||||
@ -63,49 +56,49 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
//Chest Unlocks
|
//Chest Unlocks
|
||||||
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
|
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
|
||||||
{
|
{
|
||||||
if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||||
{
|
{
|
||||||
//Nothing
|
//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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Treasure Chests");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
|
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.cBlack);
|
||||||
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rank Unlocks
|
//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.cBlack);
|
||||||
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
||||||
@ -145,20 +138,20 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
//Not Owned
|
//Not Owned
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||||
{
|
{
|
||||||
itemLore.add(C.cBlack);
|
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.cBlack);
|
||||||
itemLore.add(C.cGreen + "Click to Purchase");
|
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));
|
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.cBlack);
|
||||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||||
@ -194,7 +187,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER
|
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER
|
||||||
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE)
|
|| 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++;
|
slot++;
|
||||||
|
@ -2,7 +2,7 @@ package mineplex.core.cosmetic.ui.page;
|
|||||||
|
|
||||||
import mineplex.cache.player.PlayerCache;
|
import mineplex.cache.player.PlayerCache;
|
||||||
import mineplex.core.account.CoreClientManager;
|
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.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -15,11 +15,12 @@ import mineplex.core.pet.Pet;
|
|||||||
import mineplex.core.pet.PetExtra;
|
import mineplex.core.pet.PetExtra;
|
||||||
import mineplex.core.pet.repository.token.PetChangeToken;
|
import mineplex.core.pet.repository.token.PetChangeToken;
|
||||||
import mineplex.core.pet.repository.token.PetToken;
|
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 mineplex.core.shop.page.ShopPageBase;
|
||||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_8_R3.Items;
|
import net.minecraft.server.v1_8_R3.Items;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -93,44 +94,42 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
|
|
||||||
PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100);
|
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);
|
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
|
||||||
|
|
||||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(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();
|
getPlugin().getPetManager().getRepository().AddPet(token);
|
||||||
|
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType());
|
||||||
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()));
|
|
||||||
}
|
}
|
||||||
}, 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)
|
public void SetTagName(String tagName)
|
||||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -55,6 +56,15 @@ public class Creature extends MiniPlugin
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends Entity> T SpawnEntity(Location location, Class<T> entityType)
|
||||||
|
{
|
||||||
|
_spawnForce = true;
|
||||||
|
T entity = location.getWorld().spawn(location, entityType);
|
||||||
|
_spawnForce = false;
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void eggThrow(PlayerEggThrowEvent event)
|
public void eggThrow(PlayerEggThrowEvent event)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package mineplex.core.customdata;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -26,14 +27,14 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
PlayerCustomData data = new PlayerCustomData(_repository);
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data"));
|
data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data"));
|
||||||
}
|
}
|
||||||
Set(playerName, data);
|
Set(uuid, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,7 +44,7 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PlayerCustomData addPlayer(String player)
|
protected PlayerCustomData addPlayer(UUID uuid)
|
||||||
{
|
{
|
||||||
return new PlayerCustomData(_repository);
|
return new PlayerCustomData(_repository);
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
|||||||
if (accountId == -1)
|
if (accountId == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
runAsync(() -> _repository.saveData(name, accountId));
|
runAsync(() -> _repository.saveData(name, player.getUniqueId(), accountId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CorePlayer getCorePlayer(Player player)
|
public CorePlayer getCorePlayer(Player player)
|
||||||
|
@ -4,6 +4,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.database.MinecraftRepository;
|
import mineplex.core.database.MinecraftRepository;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
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<CustomData, Integer> entry : data.getDataMap().entrySet())
|
for (Map.Entry<CustomData, Integer> entry : data.getDataMap().entrySet())
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,8 @@ import mineplex.core.common.util.Callback;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
||||||
{
|
{
|
||||||
public static DelayedTask Instance;
|
public static DelayedTask Instance;
|
||||||
@ -58,9 +60,9 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public boolean HasTask(Player player, String task)
|
||||||
|
@ -35,7 +35,7 @@ public class DisguiseFactory
|
|||||||
case PIG_ZOMBIE:
|
case PIG_ZOMBIE:
|
||||||
return new DisguisePigZombie(disguised);
|
return new DisguisePigZombie(disguised);
|
||||||
case PLAYER:
|
case PLAYER:
|
||||||
return new DisguisePlayer(disguised);
|
throw new UnsupportedOperationException("Player disguises must be initialized via constructor");
|
||||||
case SHEEP:
|
case SHEEP:
|
||||||
return new DisguiseSheep(disguised);
|
return new DisguiseSheep(disguised);
|
||||||
case SKELETON:
|
case SKELETON:
|
||||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user