Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex into SearchAndDestroy
This commit is contained in:
commit
f5533dbce2
@ -1,6 +1,7 @@
|
|||||||
package mineplex.core;
|
package mineplex.core;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ import net.minecraft.server.v1_7_R4.Packet;
|
|||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||||
import net.minecraft.server.v1_7_R4.WatchableObject;
|
import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
|||||||
private NautHashMap<Player, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<Player, NautHashMap<Integer, String>>();
|
private NautHashMap<Player, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<Player, NautHashMap<Integer, String>>();
|
||||||
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityVehicleMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
|
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityVehicleMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
|
||||||
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
|
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
|
||||||
|
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
|
||||||
|
|
||||||
private Field _destroyId;
|
private Field _destroyId;
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
|||||||
{
|
{
|
||||||
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
|
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
|
||||||
|
|
||||||
if (!_entityMap.get(owner).containsKey(metaPacket.a) && metaPacket.a != 777777)
|
if (!_entityMap.get(owner).containsKey(metaPacket.a) && metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
|
||||||
{
|
{
|
||||||
String entityName = "";
|
String entityName = "";
|
||||||
boolean nameShowing = false;
|
boolean nameShowing = false;
|
||||||
@ -199,6 +202,14 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
|||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (packet instanceof PacketPlayOutSpawnEntity)
|
||||||
|
{
|
||||||
|
PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet;
|
||||||
|
if (spawnPacket.j == 66 && spawnPacket.a != 777777)
|
||||||
|
{
|
||||||
|
_ignoreSkulls.add(spawnPacket.a);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
else if (packet instanceof PacketPlayOutAttachEntity)
|
else if (packet instanceof PacketPlayOutAttachEntity)
|
||||||
{
|
{
|
||||||
|
@ -7,25 +7,20 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
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 Object _clientDataLock = new Object();
|
||||||
|
|
||||||
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
||||||
|
|
||||||
|
|
||||||
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super(moduleName, plugin);
|
super(moduleName, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void loadPlayer(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
loadClientInformation(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void UnloadPlayer(ClientUnloadEvent event)
|
public void UnloadPlayer(ClientUnloadEvent event)
|
||||||
{
|
{
|
||||||
@ -70,6 +65,4 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract DataType AddPlayer(String player);
|
protected abstract DataType AddPlayer(String player);
|
||||||
|
|
||||||
protected abstract void loadClientInformation(RetrieveClientInformationEvent event);
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package mineplex.core;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.ILoginProcessor;
|
||||||
|
|
||||||
|
public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniClientPlugin<DataType> implements ILoginProcessor
|
||||||
|
{
|
||||||
|
protected CoreClientManager ClientManager = null;
|
||||||
|
|
||||||
|
public MiniDbClientPlugin(String moduleName, JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
|
{
|
||||||
|
super(moduleName, plugin);
|
||||||
|
|
||||||
|
ClientManager = clientManager;
|
||||||
|
|
||||||
|
clientManager.addStoredProcedureLoginProcessor(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
||||||
|
}
|
@ -10,10 +10,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.command.UpdateRank;
|
import mineplex.core.account.command.UpdateRank;
|
||||||
import mineplex.core.account.event.AsyncClientLoadEvent;
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.account.repository.AccountRepository;
|
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;
|
||||||
@ -41,11 +39,15 @@ 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 JavaPlugin _plugin;
|
private JavaPlugin _plugin;
|
||||||
private AccountRepository _repository;
|
private AccountRepository _repository;
|
||||||
private NautHashMap<String, CoreClient> _clientList;
|
private NautHashMap<String, CoreClient> _clientList;
|
||||||
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
||||||
|
|
||||||
|
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||||
|
|
||||||
private Object _clientLock = new Object();
|
private Object _clientLock = new Object();
|
||||||
|
|
||||||
private static int _connectingClients = 0;
|
private static int _connectingClients = 0;
|
||||||
@ -187,38 +189,11 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
client.SetAccountId(token.AccountId);
|
client.SetAccountId(token.AccountId);
|
||||||
client.SetRank(Rank.valueOf(token.Rank));
|
client.SetRank(Rank.valueOf(token.Rank));
|
||||||
|
|
||||||
final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid);
|
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||||
clientInformationEvent.incrementProcessingCount();
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_repository.login(uuid.toString(), client.GetPlayerName());
|
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
|
|
||||||
clientInformationEvent.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
|
||||||
// Load client in miniplugins
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
|
|
||||||
|
|
||||||
while (clientInformationEvent.processing())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(1);
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(GetPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTask(GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -235,42 +210,38 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
||||||
|
|
||||||
|
_clientLoginLock.put(client.GetPlayerName(), new Object());
|
||||||
ClientToken token = null;
|
ClientToken token = null;
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid);
|
runAsync(new Runnable()
|
||||||
clientInformationEvent.incrementProcessingCount();
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
_repository.login(uuid.toString(), client.GetPlayerName());
|
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||||
|
_clientLoginLock.remove(client.GetPlayerName());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
|
|
||||||
clientInformationEvent.decreaseProcessingCount();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TimingManager.start(client.GetPlayerName() + " GetClient.");
|
||||||
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
|
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
|
||||||
|
TimingManager.stop(client.GetPlayerName() + " GetClient.");
|
||||||
|
|
||||||
token = gson.fromJson(response, ClientToken.class);
|
token = gson.fromJson(response, ClientToken.class);
|
||||||
|
|
||||||
client.SetAccountId(token.AccountId);
|
client.SetAccountId(token.AccountId);
|
||||||
client.SetRank(Rank.valueOf(token.Rank));
|
client.SetRank(Rank.valueOf(token.Rank));
|
||||||
|
|
||||||
_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));
|
||||||
|
|
||||||
// Load client in miniplugins
|
while (_clientLoginLock.containsKey(client.GetPlayerName()))
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
|
|
||||||
|
|
||||||
while (clientInformationEvent.processing())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(1);
|
Thread.sleep(2);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
@ -431,4 +402,9 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
|
||||||
|
{
|
||||||
|
_loginProcessors.put(processor.getName(), processor);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package mineplex.core.account;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public interface ILoginProcessor
|
||||||
|
{
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
||||||
|
|
||||||
|
String getQuery(String uuid, String name);
|
||||||
|
}
|
@ -1,41 +0,0 @@
|
|||||||
package mineplex.core.account.event;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
import mineplex.core.account.repository.token.ClientToken;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class AsyncClientLoadEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private ClientToken _token;
|
|
||||||
private CoreClient _client;
|
|
||||||
|
|
||||||
public AsyncClientLoadEvent(ClientToken token, CoreClient client)
|
|
||||||
{
|
|
||||||
_token = token;
|
|
||||||
_client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreClient GetClient()
|
|
||||||
{
|
|
||||||
return _client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientToken GetClientToken()
|
|
||||||
{
|
|
||||||
return _token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package mineplex.core.account.event;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class RetrieveClientInformationEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private String _playerName;
|
|
||||||
private UUID _uuid;
|
|
||||||
private int _processingCount;
|
|
||||||
|
|
||||||
public RetrieveClientInformationEvent(String playerName, UUID uuid)
|
|
||||||
{
|
|
||||||
_playerName = playerName;
|
|
||||||
_uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlayerName()
|
|
||||||
{
|
|
||||||
return _playerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUniqueId()
|
|
||||||
{
|
|
||||||
return _uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementProcessingCount()
|
|
||||||
{
|
|
||||||
_processingCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean processing()
|
|
||||||
{
|
|
||||||
return _processingCount > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decreaseProcessingCount()
|
|
||||||
{
|
|
||||||
_processingCount--;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package mineplex.core.account.repository;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -11,10 +12,12 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.account.ILoginProcessor;
|
||||||
import mineplex.core.account.repository.token.LoginToken;
|
import mineplex.core.account.repository.token.LoginToken;
|
||||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||||
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.database.DatabaseRunnable;
|
import mineplex.core.database.DatabaseRunnable;
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
@ -28,7 +31,6 @@ public class AccountRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
||||||
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
|
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
|
||||||
private static String ACCOUNT_LOGIN_UPDATE = "UPDATE accounts SET uuid=?, name=?, lastLogin=now() WHERE uuid = ?;";
|
|
||||||
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||||
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||||
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
||||||
@ -41,9 +43,34 @@ public class AccountRepository extends RepositoryBase
|
|||||||
|
|
||||||
public AccountRepository(JavaPlugin plugin, String webAddress)
|
public AccountRepository(JavaPlugin plugin, String webAddress)
|
||||||
{
|
{
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true", "root", "tAbechAk3wR7tuTh");
|
||||||
|
|
||||||
_webAddress = webAddress;
|
_webAddress = webAddress;
|
||||||
|
|
||||||
|
Statement statement = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement = getConnection().createStatement();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,12 +79,105 @@ public class AccountRepository extends RepositoryBase
|
|||||||
executeUpdate(CREATE_ACCOUNT_TABLE);
|
executeUpdate(CREATE_ACCOUNT_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void login(String uuid, String name)
|
public void login(NautHashMap<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
||||||
{
|
{
|
||||||
int affectedRows = executeUpdate(ACCOUNT_LOGIN_UPDATE, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid));
|
Statement statement = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
|
||||||
if (affectedRows == 0)
|
try
|
||||||
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name));
|
{
|
||||||
|
statement = getConnection().createStatement();
|
||||||
|
|
||||||
|
/*
|
||||||
|
boolean statementStatus = statement.execute(
|
||||||
|
"UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"
|
||||||
|
+ "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = '" + uuid + "';"
|
||||||
|
+ "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '" + uuid + "';"
|
||||||
|
+ "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';"
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';";
|
||||||
|
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||||
|
{
|
||||||
|
loginString += loginProcessor.getQuery(uuid, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
statement.execute(loginString);
|
||||||
|
|
||||||
|
/*
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (statementStatus)
|
||||||
|
{
|
||||||
|
System.out.println("ResultSet : " + statement.getResultSet().getMetaData().getColumnCount() + " columns:");
|
||||||
|
|
||||||
|
for (int i = 0; i < statement.getResultSet().getMetaData().getColumnCount(); i++)
|
||||||
|
{
|
||||||
|
System.out.println(statement.getResultSet().getMetaData().getColumnName(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (statement.getUpdateCount() == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
System.out.println("Update statement : " + statement.getUpdateCount() + " rows affected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
statementStatus = statement.getMoreResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Done");
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean accountExists = statement.getUpdateCount() != 0;
|
||||||
|
|
||||||
|
statement.getMoreResults();
|
||||||
|
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||||
|
{
|
||||||
|
loginProcessor.processLoginResultSet(name, statement.getResultSet());
|
||||||
|
statement.getMoreResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!accountExists)
|
||||||
|
{
|
||||||
|
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultSet != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
resultSet.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetClient(String name, UUID uuid, String ipAddress)
|
public String GetClient(String name, UUID uuid, String ipAddress)
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package mineplex.core.benefit;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class BenefitData
|
||||||
|
{
|
||||||
|
public HashSet<String> Benefits = new HashSet<String>();
|
||||||
|
public boolean Loaded = false;
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package mineplex.core.benefit;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.benefit.benefits.BenefitBase;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.inventory.InventoryManager;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
||||||
|
{
|
||||||
|
private BenefitManagerRepository _repository;
|
||||||
|
|
||||||
|
private List<BenefitBase> _benefits = new ArrayList<BenefitBase>();
|
||||||
|
|
||||||
|
public BenefitManager(JavaPlugin plugin, CoreClientManager clientManager, InventoryManager inventoryManager)
|
||||||
|
{
|
||||||
|
super("Benefit Manager", plugin, clientManager);
|
||||||
|
|
||||||
|
_repository = new BenefitManagerRepository(plugin);
|
||||||
|
|
||||||
|
//_benefits.add(new Thanksgiving2014(plugin, _repository, inventoryManager));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void giveBenefit(final PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (Get(event.getPlayer()).Loaded)
|
||||||
|
{
|
||||||
|
for (final BenefitBase benefit : _benefits)
|
||||||
|
{
|
||||||
|
if (!Get(event.getPlayer()).Benefits.contains(benefit.getName()))
|
||||||
|
{
|
||||||
|
benefit.recordBenefit(event.getPlayer(), new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
benefit.rewardPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.out.println("Benefit reward failed for " + event.getPlayer().getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 100L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BenefitData AddPlayer(String player)
|
||||||
|
{
|
||||||
|
return new BenefitData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.retrievePlayerBenefitData(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
|
}
|
@ -2,23 +2,19 @@ package mineplex.core.benefit;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
import mineplex.core.database.ResultSetCallable;
|
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class RankBenefitsGiver9000Repository extends RepositoryBase
|
public class BenefitManagerRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
// private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
|
// private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
|
||||||
|
|
||||||
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
|
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
|
||||||
private static String RETRIEVE_BENEFITS = "SELECT benefit FROM rankBenefits WHERE uuid = ?;";
|
|
||||||
|
|
||||||
public RankBenefitsGiver9000Repository(JavaPlugin plugin)
|
public BenefitManagerRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
}
|
}
|
||||||
@ -34,26 +30,20 @@ public class RankBenefitsGiver9000Repository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> retrievePlayerBenefits(String uuid)
|
|
||||||
{
|
|
||||||
final List<String> benefits = new ArrayList<String>();
|
|
||||||
|
|
||||||
executeQuery(RETRIEVE_BENEFITS, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
|
||||||
{
|
|
||||||
benefits.add(resultSet.getString(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
return benefits;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addBenefit(String uuid, String benefit)
|
public boolean addBenefit(String uuid, String benefit)
|
||||||
{
|
{
|
||||||
return executeUpdate(INSERT_BENEFIT, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("benefit", 100, benefit)) > 0;
|
return executeUpdate(INSERT_BENEFIT, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("benefit", 100, benefit)) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BenefitData retrievePlayerBenefitData(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
BenefitData playerBenefit = new BenefitData();
|
||||||
|
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
playerBenefit.Benefits.add(resultSet.getString(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerBenefit;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
package mineplex.core.benefit;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class PlayerBenefit
|
|
||||||
{
|
|
||||||
public HashSet<String> Benefits = new HashSet<String>();
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
package mineplex.core.benefit;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.benefit.benefits.BenefitBase;
|
|
||||||
import mineplex.core.benefit.benefits.Thanksgiving2014;
|
|
||||||
import mineplex.core.common.util.Callback;
|
|
||||||
import mineplex.core.inventory.InventoryManager;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public class RankBenefitsGiver9000 extends MiniClientPlugin<PlayerBenefit>
|
|
||||||
{
|
|
||||||
private RankBenefitsGiver9000Repository _repository;
|
|
||||||
|
|
||||||
private List<BenefitBase> _benefits = new ArrayList<BenefitBase>();
|
|
||||||
|
|
||||||
public RankBenefitsGiver9000(JavaPlugin plugin, CoreClientManager clientManager, InventoryManager inventoryManager)
|
|
||||||
{
|
|
||||||
super("RankBenefitsGiver9000", plugin);
|
|
||||||
|
|
||||||
_repository = new RankBenefitsGiver9000Repository(plugin);
|
|
||||||
|
|
||||||
_benefits.add(new Thanksgiving2014(plugin, _repository, inventoryManager));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void giveBenefit(final PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
for (final BenefitBase benefit : _benefits)
|
|
||||||
{
|
|
||||||
if (!Get(event.getPlayer()).Benefits.contains(benefit.getName()))
|
|
||||||
{
|
|
||||||
|
|
||||||
benefit.recordBenefit(event.getPlayer(), new Callback<Boolean>()
|
|
||||||
{
|
|
||||||
public void run(Boolean success)
|
|
||||||
{
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
benefit.rewardPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
System.out.println("Benefit reward failed for " + event.getPlayer().getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PlayerBenefit AddPlayer(String player)
|
|
||||||
{
|
|
||||||
return new PlayerBenefit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
|
|
||||||
runAsync(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
for (String benefit : _repository.retrievePlayerBenefits(event.getUniqueId().toString()))
|
|
||||||
{
|
|
||||||
Get(event.getPlayerName()).Benefits.add(benefit);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
package mineplex.core.benefit.benefits;
|
package mineplex.core.benefit.benefits;
|
||||||
|
|
||||||
import mineplex.core.benefit.RankBenefitsGiver9000Repository;
|
import mineplex.core.benefit.BenefitManagerRepository;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -11,9 +11,9 @@ public abstract class BenefitBase
|
|||||||
{
|
{
|
||||||
private JavaPlugin _plugin;
|
private JavaPlugin _plugin;
|
||||||
private String _name;
|
private String _name;
|
||||||
private RankBenefitsGiver9000Repository _repository;
|
private BenefitManagerRepository _repository;
|
||||||
|
|
||||||
protected BenefitBase(JavaPlugin plugin, String name, RankBenefitsGiver9000Repository repository)
|
protected BenefitBase(JavaPlugin plugin, String name, BenefitManagerRepository repository)
|
||||||
{
|
{
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_name = name;
|
_name = name;
|
||||||
@ -25,7 +25,7 @@ public abstract class BenefitBase
|
|||||||
return _plugin;
|
return _plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RankBenefitsGiver9000Repository getRepository()
|
public BenefitManagerRepository getRepository()
|
||||||
{
|
{
|
||||||
return _repository;
|
return _repository;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package mineplex.core.benefit.benefits;
|
package mineplex.core.benefit.benefits;
|
||||||
|
|
||||||
import mineplex.core.benefit.RankBenefitsGiver9000Repository;
|
import mineplex.core.benefit.BenefitManagerRepository;
|
||||||
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.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -14,7 +14,7 @@ public class Thanksgiving2014 extends BenefitBase
|
|||||||
{
|
{
|
||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
|
|
||||||
public Thanksgiving2014(JavaPlugin plugin, RankBenefitsGiver9000Repository repository, InventoryManager inventoryManager)
|
public Thanksgiving2014(JavaPlugin plugin, BenefitManagerRepository repository, InventoryManager inventoryManager)
|
||||||
{
|
{
|
||||||
super(plugin, "Thanksgiving2014", repository);
|
super(plugin, "Thanksgiving2014", repository);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Plugin.getInventoryManager().addItemToInventory(null, Player, gadget.getGadgetType().name(), gadget.GetName(), (gadget instanceof ItemGadget ? ((ItemGadget)gadget).getAmmo().getQuantity() : gadget.getQuantity()));
|
Plugin.getInventoryManager().addItemToInventory(Player, gadget.getGadgetType().name(), gadget.GetName(), (gadget instanceof ItemGadget ? ((ItemGadget)gadget).getAmmo().getQuantity() : gadget.getQuantity()));
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}, this, (gadget instanceof ItemGadget ? ((ItemGadget)gadget).getAmmo() : gadget), CurrencyType.Coins, Player));
|
}, this, (gadget instanceof ItemGadget ? ((ItemGadget)gadget).getAmmo() : gadget), CurrencyType.Coins, Player));
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Iterator;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.database.column.Column;
|
import mineplex.core.database.column.Column;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class DonationManager extends MiniPlugin
|
|||||||
synchronized (_donorLock)
|
synchronized (_donorLock)
|
||||||
{
|
{
|
||||||
_donors.put(token.Name, new Donor(token.DonorToken));
|
_donors.put(token.Name, new Donor(token.DonorToken));
|
||||||
_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package mineplex.core.elo;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
|
public class EloClientData
|
||||||
|
{
|
||||||
|
public NautHashMap<String, Integer> Elos = new NautHashMap<String, Integer>();
|
||||||
|
}
|
@ -1,16 +1,17 @@
|
|||||||
package mineplex.core.elo;
|
package mineplex.core.elo;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class EloManager extends MiniPlugin
|
public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||||
{
|
{
|
||||||
private static Object _playerEloLock = new Object();
|
private static Object _playerEloLock = new Object();
|
||||||
|
|
||||||
@ -18,51 +19,15 @@ public class EloManager extends MiniPlugin
|
|||||||
private EloRatingSystem _ratingSystem;
|
private EloRatingSystem _ratingSystem;
|
||||||
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
||||||
|
|
||||||
public EloManager(JavaPlugin plugin)
|
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("Elo Rating", plugin);
|
super("Elo Rating", plugin, clientManager);
|
||||||
|
|
||||||
setupConfigValues(plugin);
|
_repository = new EloRepository(plugin);
|
||||||
|
|
||||||
_repository = new EloRepository(plugin.getConfig().getString("elo.connectionurl"));
|
|
||||||
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
||||||
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupConfigValues(JavaPlugin plugin)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
plugin.getConfig().addDefault("elo.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
|
|
||||||
plugin.getConfig().set("elo.connectionurl", plugin.getConfig().getString("elo.connectionurl"));
|
|
||||||
plugin.saveConfig();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void retrievePlayersElos(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
NautHashMap<String, Integer> eloMap = _repository.loadClientInformation(event.getUniqueId());
|
|
||||||
|
|
||||||
synchronized (_playerEloLock)
|
|
||||||
{
|
|
||||||
_playerElos.put(event.getUniqueId().toString(), eloMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getElo(UUID uuid, String gameType)
|
public int getElo(UUID uuid, String gameType)
|
||||||
{
|
{
|
||||||
int elo = 1000;
|
int elo = 1000;
|
||||||
@ -135,4 +100,22 @@ public class EloManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected EloClientData AddPlayer(String player)
|
||||||
|
{
|
||||||
|
return new EloClientData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,172 +1,50 @@
|
|||||||
package mineplex.core.elo;
|
package mineplex.core.elo;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class EloRepository
|
import mineplex.core.database.RepositoryBase;
|
||||||
|
import mineplex.core.database.column.ColumnInt;
|
||||||
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
|
public class EloRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private String _connectionString;
|
|
||||||
private String _userName = "root";
|
|
||||||
private String _password = "tAbechAk3wR7tuTh";
|
|
||||||
|
|
||||||
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
||||||
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
||||||
private static String RETRIEVE_ELO = "SELECT gameType, elo FROM eloRating WHERE uuid = ?;";
|
|
||||||
|
|
||||||
private Connection _connection = null;
|
public EloRepository(JavaPlugin plugin)
|
||||||
|
|
||||||
public EloRepository(String connectionUrl)
|
|
||||||
{
|
{
|
||||||
_connectionString = connectionUrl;
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
PreparedStatement preparedStatement = null;
|
executeUpdate(CREATE_ELO_TABLE);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
|
||||||
|
|
||||||
// Create table
|
|
||||||
preparedStatement = _connection.prepareStatement(CREATE_ELO_TABLE);
|
|
||||||
preparedStatement.execute();
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (preparedStatement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
preparedStatement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveElo(String uuid, String gameType, int elo)
|
public void saveElo(String uuid, String gameType, int elo)
|
||||||
{
|
{
|
||||||
PreparedStatement preparedStatement = null;
|
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
|
||||||
|
|
||||||
int affectedRows = 0;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_connection.isClosed())
|
|
||||||
{
|
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStatement = _connection.prepareStatement(INSERT_ELO);
|
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
|
|
||||||
preparedStatement.setString(1, uuid);
|
|
||||||
preparedStatement.setString(2, gameType);
|
|
||||||
preparedStatement.setInt(3, elo);
|
|
||||||
|
|
||||||
affectedRows = preparedStatement.executeUpdate();
|
|
||||||
|
|
||||||
if (affectedRows == 0)
|
|
||||||
{
|
{
|
||||||
System.out.println("Error saving Elo.");
|
EloClientData clientData = new EloClientData();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("Saved '" + uuid + "' for '" + gameType + "' new elo " + elo);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (preparedStatement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
preparedStatement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public NautHashMap<String, Integer> loadClientInformation(UUID uuid)
|
|
||||||
{
|
|
||||||
NautHashMap<String, Integer> elos = new NautHashMap<String, Integer>();
|
|
||||||
|
|
||||||
ResultSet resultSet = null;
|
|
||||||
PreparedStatement preparedStatement = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_connection.isClosed())
|
|
||||||
{
|
|
||||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
|
||||||
}
|
|
||||||
|
|
||||||
preparedStatement = _connection.prepareStatement(RETRIEVE_ELO);
|
|
||||||
preparedStatement.setString(1, uuid.toString());
|
|
||||||
|
|
||||||
resultSet = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
elos.put(resultSet.getString(1), resultSet.getInt(2));
|
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2));
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (preparedStatement != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
preparedStatement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultSet != null)
|
return clientData;
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
resultSet.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return elos;
|
@Override
|
||||||
|
protected void update()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
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.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -153,49 +152,8 @@ public class Energy extends MiniClientPlugin<ClientEnergy>
|
|||||||
Get(player).MaxEnergyMods.remove(reason);
|
Get(player).MaxEnergyMods.remove(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean b)
|
public void setEnabled(boolean b)
|
||||||
{
|
{
|
||||||
_enabled = b;
|
_enabled = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ENERGY NO LONGER USED ON ATTACK
|
|
||||||
public void AddEnergySwingMod(Player player, String reason, int amount)
|
|
||||||
{
|
|
||||||
Get(player).SwingEnergyMods.put(reason, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveEnergySwingMod(Player player, String reason)
|
|
||||||
{
|
|
||||||
Get(player).SwingEnergyMods.remove(reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void WeaponSwing(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
if (!UtilEvent.isAction(event, ActionType.L))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (!UtilGear.isWeapon(player.getItemInHand()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ModifyEnergy(player, -Get(player).SwingEnergy());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void ShootBow(EntityShootBowEvent event)
|
|
||||||
{
|
|
||||||
if (event.getEntity() instanceof Player)
|
|
||||||
ModifyEnergy((Player)event.getEntity(), -10);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.core.friend;
|
package mineplex.core.friend;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -11,9 +13,8 @@ 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.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||||
import mineplex.core.common.jsonchat.JsonMessage;
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
@ -31,19 +32,17 @@ import mineplex.core.preferences.PreferencesManager;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
public class FriendManager extends MiniClientPlugin<FriendData>
|
public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||||
{
|
{
|
||||||
private static FriendSorter _friendSorter = new FriendSorter();
|
private static FriendSorter _friendSorter = new FriendSorter();
|
||||||
|
|
||||||
private CoreClientManager _clientManager;
|
|
||||||
private PreferencesManager _preferenceManager;
|
private PreferencesManager _preferenceManager;
|
||||||
private FriendRepository _repository;
|
private FriendRepository _repository;
|
||||||
|
|
||||||
public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
|
public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
|
||||||
{
|
{
|
||||||
super("Friends", plugin);
|
super("Friends", plugin, clientManager);
|
||||||
|
|
||||||
_clientManager = clientManager;
|
|
||||||
_preferenceManager = preferences;
|
_preferenceManager = preferences;
|
||||||
_repository = new FriendRepository(plugin);
|
_repository = new FriendRepository(plugin);
|
||||||
}
|
}
|
||||||
@ -61,20 +60,6 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
|||||||
return new FriendData();
|
return new FriendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateFriends(UpdateEvent event)
|
public void updateFriends(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -262,7 +247,7 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
|||||||
|
|
||||||
public void showFriends(Player caller)
|
public void showFriends(Player caller)
|
||||||
{
|
{
|
||||||
boolean isStaff = _clientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
||||||
boolean gotAFriend = false;
|
boolean gotAFriend = false;
|
||||||
List<FriendStatus> friendStatuses = Get(caller).Friends;
|
List<FriendStatus> friendStatuses = Get(caller).Friends;
|
||||||
Collections.sort(friendStatuses, _friendSorter);
|
Collections.sort(friendStatuses, _friendSorter);
|
||||||
@ -379,4 +364,16 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
|||||||
|
|
||||||
caller.sendMessage(C.cAqua + C.Strike + "=====================================================");
|
caller.sendMessage(C.cAqua + C.Strike + "=====================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package mineplex.core.friend.data;
|
|||||||
|
|
||||||
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;
|
||||||
@ -17,15 +16,10 @@ public class FriendRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
||||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
||||||
private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;";
|
|
||||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ? FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ? FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||||
private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;";
|
private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;";
|
||||||
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
||||||
|
|
||||||
|
|
||||||
// Not mutual, need to drop accountFriend to recreate with constraint.
|
|
||||||
// On add record need to check for a reverse uuidsource/uuidtarget and set mutual
|
|
||||||
|
|
||||||
public FriendRepository(JavaPlugin plugin)
|
public FriendRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||||
@ -109,14 +103,10 @@ public class FriendRepository extends RepositoryBase
|
|||||||
return friends;
|
return friends;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FriendData loadClientInformation(final UUID uniqueId)
|
public FriendData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final FriendData friendData = new FriendData();
|
FriendData friendData = new FriendData();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_FRIEND_RECORDS, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
FriendStatus friend = new FriendStatus();
|
FriendStatus friend = new FriendStatus();
|
||||||
@ -128,8 +118,6 @@ public class FriendRepository extends RepositoryBase
|
|||||||
|
|
||||||
friendData.Friends.add(friend);
|
friendData.Friends.add(friend);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuidSource", 100, uniqueId.toString()));
|
|
||||||
|
|
||||||
return friendData;
|
return friendData;
|
||||||
}
|
}
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
package mineplex.core.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
|
||||||
import net.minecraft.server.v1_7_R4.EnumEntitySize;
|
|
||||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
|
||||||
import net.minecraft.server.v1_7_R4.Packet;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
|
||||||
import net.minecraft.server.v1_7_R4.PlayerConnection;
|
|
||||||
|
|
||||||
import mineplex.core.common.DummyEntity;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Shaun on 9/5/2014.
|
|
||||||
*/
|
|
||||||
public class ArmorStandHologram
|
|
||||||
{
|
|
||||||
private String _text;
|
|
||||||
private Packet _packet;
|
|
||||||
private int _entityId;
|
|
||||||
|
|
||||||
public ArmorStandHologram(Location location, String text)
|
|
||||||
{
|
|
||||||
_text = text;
|
|
||||||
|
|
||||||
_entityId = UtilEnt.getNewEntityId();
|
|
||||||
_packet = createArmorStandPacket(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendToPlayer(Player player)
|
|
||||||
{
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(_packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeForPlayer(Player player)
|
|
||||||
{
|
|
||||||
PacketPlayOutEntityDestroy entityDestroyPacket = new PacketPlayOutEntityDestroy(_entityId);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(entityDestroyPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PacketPlayOutSpawnEntityLiving createArmorStandPacket(Location location)
|
|
||||||
{
|
|
||||||
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
|
||||||
packet.a = _entityId;
|
|
||||||
packet.b = (byte) 30;
|
|
||||||
packet.c = MathHelper.floor(location.getX() * 32D);//(int) EnumEntitySize.SIZE_2.a(100);
|
|
||||||
packet.d = MathHelper.floor((location.getY() - 0.8) * 32D);//(int) MathHelper.floor(64 * 32.0D);
|
|
||||||
packet.e = MathHelper.floor(location.getZ() * 32D);//(int)EnumEntitySize.SIZE_2.a(100);
|
|
||||||
packet.f = 0; // Velocity X
|
|
||||||
packet.g = 0; // Velocity Y
|
|
||||||
packet.h = 0; // Velocity Z
|
|
||||||
packet.i = (byte) 0; // Yaw
|
|
||||||
packet.j = (byte) 0; // Pitch
|
|
||||||
packet.k = (byte) 0; // Head Pitch
|
|
||||||
|
|
||||||
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)location.getWorld()).getHandle()));
|
|
||||||
|
|
||||||
watcher.a(0, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(1, Short.valueOf((short)300));
|
|
||||||
watcher.a(2, _text);
|
|
||||||
watcher.a(3, Byte.valueOf((byte) 1));
|
|
||||||
watcher.a(4, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(7, Integer.valueOf(0));
|
|
||||||
watcher.a(8, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(9, Byte.valueOf((byte)0));
|
|
||||||
watcher.a(6, Float.valueOf(1.0F));
|
|
||||||
watcher.a(10, Byte.valueOf((byte)0));
|
|
||||||
|
|
||||||
// Set invisible
|
|
||||||
int i1 = watcher.getInt(0);
|
|
||||||
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
|
|
||||||
|
|
||||||
// Set small and No Gravity
|
|
||||||
byte b1 = watcher.getByte(10);
|
|
||||||
b1 = (byte)(b1 | 0x1);
|
|
||||||
b1 = (byte)(b1 | 0x2);
|
|
||||||
watcher.watch(10, Byte.valueOf(b1));
|
|
||||||
|
|
||||||
packet.l = watcher;
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +1,618 @@
|
|||||||
package mineplex.core.hologram;
|
package mineplex.core.hologram;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.entity.Player;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||||
|
import net.minecraft.server.v1_7_R4.Packet;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by shaun on 2014-09-09.
|
|
||||||
*/
|
|
||||||
public class Hologram
|
public class Hologram
|
||||||
{
|
{
|
||||||
private HorseHologram _horseHologram;
|
|
||||||
private ArmorStandHologram _armorStandHologram;
|
|
||||||
|
|
||||||
|
public enum HologramTarget
|
||||||
|
{
|
||||||
|
BLACKLIST, WHITELIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Packet _destroy1_7;
|
||||||
|
private Packet _destroy1_8;
|
||||||
|
private boolean _destroyPackets = true;
|
||||||
|
/**
|
||||||
|
* 1.7 packets uses both EntityIDs while 1.8 uses only the first.
|
||||||
|
*/
|
||||||
|
private ArrayList<Entry<Integer, Integer>> _entityIds = new ArrayList<Entry<Integer, Integer>>();
|
||||||
|
private boolean _isWitherSkull;
|
||||||
|
/**
|
||||||
|
* Keeps track of the holograms movements. This fixes offset that occasionally happens when moving a hologram around.
|
||||||
|
*/
|
||||||
|
private Vector _lastMovement;
|
||||||
private Location _location;
|
private Location _location;
|
||||||
private String _text;
|
private boolean _makePackets = true;
|
||||||
|
private Packet[] _packets1_7;
|
||||||
|
private Packet[] _packets1_8;
|
||||||
|
private HashSet<String> _playersInList = new HashSet<String>();
|
||||||
|
private ArrayList<Player> _playersTracking = new ArrayList<Player>();
|
||||||
|
private HologramTarget _target = HologramTarget.BLACKLIST;
|
||||||
|
private String[] _text = new String[0];
|
||||||
|
private int _viewDistance = 70;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
public Hologram(Location location, String text)
|
public Hologram(HologramManager hologramManager, Location location, String... text)
|
||||||
{
|
{
|
||||||
_location = location;
|
_hologramManager = hologramManager;
|
||||||
_text = text;
|
_location = location.clone();
|
||||||
|
setText(text);
|
||||||
_horseHologram = new HorseHologram(location, text);
|
|
||||||
_armorStandHologram = new ArmorStandHologram(location, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToPlayer(Player player)
|
/**
|
||||||
|
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram addPlayer(Player player)
|
||||||
{
|
{
|
||||||
if (UtilPlayer.is1_8(player))
|
return addPlayer(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram addPlayer(String player)
|
||||||
{
|
{
|
||||||
_armorStandHologram.sendToPlayer(player);
|
_playersInList.add(player);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a player entry in the hologram for Whitelist and Blacklist
|
||||||
|
*/
|
||||||
|
public boolean containsPlayer(Player player)
|
||||||
|
{
|
||||||
|
return _playersInList.contains(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a player entry in the hologram for Whitelist and Blacklist
|
||||||
|
*/
|
||||||
|
public boolean containsPlayer(String player)
|
||||||
|
{
|
||||||
|
return _playersInList.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Packet getDestroyPacket(Player player)
|
||||||
|
{
|
||||||
|
if (_destroyPackets)
|
||||||
|
{
|
||||||
|
makeDestroyPacket();
|
||||||
|
_destroyPackets = false;
|
||||||
|
}
|
||||||
|
return UtilPlayer.is1_8(player) ? _destroy1_8 : _destroy1_7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get who can see the hologram
|
||||||
|
*
|
||||||
|
* @Whitelist = Only people added can see the hologram
|
||||||
|
* @Blacklist = Anyone but people added can see the hologram
|
||||||
|
*/
|
||||||
|
public HologramTarget getHologramTarget()
|
||||||
|
{
|
||||||
|
return _target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the hologram location
|
||||||
|
*/
|
||||||
|
public Location getLocation()
|
||||||
|
{
|
||||||
|
return _location.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArrayList<Player> getNearbyPlayers()
|
||||||
|
{
|
||||||
|
ArrayList<Player> nearbyPlayers = new ArrayList<Player>();
|
||||||
|
for (Player player : getLocation().getWorld().getPlayers())
|
||||||
|
{
|
||||||
|
if (isVisible(player))
|
||||||
|
{
|
||||||
|
nearbyPlayers.add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nearbyPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Packet[] getSpawnPackets(Player player)
|
||||||
|
{
|
||||||
|
if (_makePackets)
|
||||||
|
{
|
||||||
|
makeSpawnPackets();
|
||||||
|
_makePackets = false;
|
||||||
|
}
|
||||||
|
return UtilPlayer.is1_8(player) ? _packets1_8 : _packets1_7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the text in the hologram
|
||||||
|
*/
|
||||||
|
public String[] getText()
|
||||||
|
{
|
||||||
|
// We reverse it again as the hologram would otherwise display the text from the bottom row to the top row
|
||||||
|
String[] reversed = new String[_text.length];
|
||||||
|
for (int i = 0; i < reversed.length; i++)
|
||||||
|
{
|
||||||
|
reversed[i] = _text[reversed.length - (i + 1)];
|
||||||
|
}
|
||||||
|
return reversed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the view distance the hologram is viewable from. Default is 70
|
||||||
|
*/
|
||||||
|
public int getViewDistance()
|
||||||
|
{
|
||||||
|
return _viewDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the hologram holograming?
|
||||||
|
*/
|
||||||
|
public boolean isInUse()
|
||||||
|
{
|
||||||
|
return _lastMovement != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the hologram use the wither skull for 1.8 clients?
|
||||||
|
*/
|
||||||
|
public boolean isUsingWitherSkull()
|
||||||
|
{
|
||||||
|
return _isWitherSkull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisible(Player player)
|
||||||
|
{
|
||||||
|
if (getLocation().getWorld() == player.getWorld())
|
||||||
|
{
|
||||||
|
if ((getHologramTarget() == HologramTarget.WHITELIST) == containsPlayer(player))
|
||||||
|
{
|
||||||
|
if (getLocation().distance(player.getLocation()) < getViewDistance())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeDestroyPacket()
|
||||||
|
{
|
||||||
|
int[] entityIds1_7 = new int[_entityIds.size() * 2];
|
||||||
|
int[] entityIds1_8 = new int[_entityIds.size()];
|
||||||
|
for (int i = 0; i < _entityIds.size(); i++)
|
||||||
|
{
|
||||||
|
Entry<Integer, Integer> entry = _entityIds.get(i);
|
||||||
|
entityIds1_7[i * 2] = entry.getKey();
|
||||||
|
entityIds1_7[(i * 2) + 1] = entry.getValue();
|
||||||
|
entityIds1_8[i] = entry.getKey();
|
||||||
|
}
|
||||||
|
_destroy1_7 = new PacketPlayOutEntityDestroy(entityIds1_7);
|
||||||
|
_destroy1_8 = new PacketPlayOutEntityDestroy(entityIds1_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeSpawnPackets()
|
||||||
|
{
|
||||||
|
_packets1_7 = new Packet[_text.length * 3];
|
||||||
|
_packets1_8 = new Packet[_text.length * (isUsingWitherSkull() ? 2 : 1)];
|
||||||
|
if (_entityIds.size() < _text.length)
|
||||||
|
{
|
||||||
|
_destroyPackets = true;
|
||||||
|
for (int i = _entityIds.size(); i < _text.length; i++)
|
||||||
|
{
|
||||||
|
_entityIds.add(new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_horseHologram.sendToPlayer(player);
|
_destroyPackets = true;
|
||||||
|
while (_entityIds.size() > _text.length)
|
||||||
|
{
|
||||||
|
_entityIds.remove(_text.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int textRow = 0; textRow < _text.length; textRow++)
|
||||||
|
{
|
||||||
|
Entry<Integer, Integer> entityIds = this._entityIds.get(textRow);
|
||||||
|
Packet[] packets1_7 = makeSpawnPackets1_7(textRow, entityIds.getKey(), entityIds.getValue(), _text[textRow]);
|
||||||
|
for (int i = 0; i < packets1_7.length; i++)
|
||||||
|
{
|
||||||
|
_packets1_7[(textRow * 3) + i] = packets1_7[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet[] packets1_8 = makeSpawnPackets1_8(textRow, entityIds.getKey(), _text[textRow]);
|
||||||
|
for (int i = 0; i < packets1_8.length; i++)
|
||||||
|
{
|
||||||
|
_packets1_8[(textRow * (isUsingWitherSkull() ? 2 : 1)) + i] = packets1_8[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToPlayers(Player... players)
|
private Packet[] makeSpawnPackets1_7(int height, int witherId, int horseId, String horseName)
|
||||||
{
|
{
|
||||||
for (Player player : players)
|
// Spawn wither skull
|
||||||
|
PacketPlayOutSpawnEntity spawnWitherSkull = new PacketPlayOutSpawnEntity();
|
||||||
|
spawnWitherSkull.a = witherId;
|
||||||
|
spawnWitherSkull.b = (int) (getLocation().getX() * 32);
|
||||||
|
spawnWitherSkull.c = (int) ((getLocation().getY() + 54.6 + ((double) height * 0.285D)) * 32);
|
||||||
|
spawnWitherSkull.d = (int) (getLocation().getZ() * 32);
|
||||||
|
spawnWitherSkull.j = 66;
|
||||||
|
// Spawn horse
|
||||||
|
PacketPlayOutSpawnEntityLiving spawnHorse = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
spawnHorse.a = horseId;
|
||||||
|
spawnHorse.b = 100;
|
||||||
|
spawnHorse.c = (int) (getLocation().getX() * 32);
|
||||||
|
spawnHorse.d = (int) ((getLocation().getY() + 54.83 + ((double) height * 0.285D) + 0.23D) * 32);
|
||||||
|
spawnHorse.e = (int) (getLocation().getZ() * 32);
|
||||||
|
// Setup datawatcher
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 0);
|
||||||
|
watcher.a(1, (short) 300);
|
||||||
|
watcher.a(10, horseName);
|
||||||
|
watcher.a(11, (byte) 1);
|
||||||
|
watcher.a(12, -1700000);
|
||||||
|
spawnHorse.l = watcher;
|
||||||
|
// Make horse ride wither
|
||||||
|
PacketPlayOutAttachEntity attachEntity = new PacketPlayOutAttachEntity();
|
||||||
|
attachEntity.b = horseId;
|
||||||
|
attachEntity.c = witherId;
|
||||||
|
return new Packet[]
|
||||||
{
|
{
|
||||||
sendToPlayer(player);
|
spawnWitherSkull, spawnHorse, attachEntity
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeForPlayer(Player player)
|
private Packet[] makeSpawnPackets1_8(int textRow, int entityId, String lineOfText)
|
||||||
{
|
{
|
||||||
if (UtilPlayer.is1_8(player))
|
if (this.isUsingWitherSkull())
|
||||||
{
|
{
|
||||||
_armorStandHologram.removeForPlayer(player);
|
PacketPlayOutSpawnEntity spawnPacket = new PacketPlayOutSpawnEntity();
|
||||||
|
spawnPacket.a = entityId;
|
||||||
|
spawnPacket.b = (int) (getLocation().getX() * 32);
|
||||||
|
spawnPacket.c = (int) ((getLocation().getY() + -0.55 + ((double) textRow * 0.285)) * 32);
|
||||||
|
spawnPacket.d = (int) (getLocation().getZ() * 32);
|
||||||
|
spawnPacket.j = 66;
|
||||||
|
// Setup datawatcher for wither skull
|
||||||
|
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata();
|
||||||
|
metadataPacket.a = entityId;
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 0);
|
||||||
|
watcher.a(2, lineOfText);
|
||||||
|
watcher.a(3, (byte) 1);
|
||||||
|
metadataPacket.b = watcher.c();
|
||||||
|
return new Packet[]
|
||||||
|
{
|
||||||
|
spawnPacket, metadataPacket
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_horseHologram.removeForPlayer(player);
|
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
packet.a = entityId;
|
||||||
|
packet.b = 30;
|
||||||
|
packet.c = (int) (getLocation().getX() * 32);
|
||||||
|
packet.d = (int) ((getLocation().getY() + -2.1 + ((double) textRow * 0.285)) * 32);
|
||||||
|
packet.e = (int) (getLocation().getZ() * 32);
|
||||||
|
// Setup datawatcher for armor stand
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 32);
|
||||||
|
watcher.a(2, lineOfText);
|
||||||
|
watcher.a(3, (byte) 1);
|
||||||
|
packet.l = watcher;
|
||||||
|
return new Packet[]
|
||||||
|
{
|
||||||
|
packet
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeForPlayers(Player... players)
|
/**
|
||||||
|
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram removePlayer(Player player)
|
||||||
{
|
{
|
||||||
for (Player player : players)
|
return addPlayer(player.getName());
|
||||||
{
|
|
||||||
removeForPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
|
||||||
|
*/
|
||||||
|
public Hologram removePlayer(String player)
|
||||||
|
{
|
||||||
|
_playersInList.remove(player);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set who can see the hologram
|
||||||
|
*
|
||||||
|
* @Whitelist = Only people added can see the hologram
|
||||||
|
* @Blacklist = Anyone but people added can see the hologram
|
||||||
|
*/
|
||||||
|
public Hologram setHologramTarget(HologramTarget newTarget)
|
||||||
|
{
|
||||||
|
this._target = newTarget;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the hologram to appear at this location
|
||||||
|
*/
|
||||||
|
public Hologram setLocation(Location newLocation)
|
||||||
|
{
|
||||||
|
_makePackets = true;
|
||||||
|
Location oldLocation = getLocation();
|
||||||
|
_location = newLocation.clone();
|
||||||
|
if (isInUse())
|
||||||
|
{
|
||||||
|
ArrayList<Player> canSee = getNearbyPlayers();
|
||||||
|
Iterator<Player> itel = _playersTracking.iterator();
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Player player = itel.next();
|
||||||
|
if (!canSee.contains(player))
|
||||||
|
{
|
||||||
|
itel.remove();
|
||||||
|
if (player.getWorld() == getLocation().getWorld())
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(getDestroyPacket(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itel = canSee.iterator();
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Player player = itel.next();
|
||||||
|
if (!_playersTracking.contains(player))
|
||||||
|
{
|
||||||
|
_playersTracking.add(player);
|
||||||
|
itel.remove();
|
||||||
|
for (Packet packet : getSpawnPackets(player))
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!canSee.isEmpty())
|
||||||
|
{
|
||||||
|
_lastMovement.add(new Vector(newLocation.getX() - oldLocation.getX(), newLocation.getY() - oldLocation.getY(),
|
||||||
|
newLocation.getZ() - oldLocation.getZ()));
|
||||||
|
int x = (int) Math.floor(32 * _lastMovement.getX());
|
||||||
|
int y = (int) Math.floor(32 * _lastMovement.getY());
|
||||||
|
int z = (int) Math.floor(32 * _lastMovement.getZ());
|
||||||
|
Packet[] packets1_7 = new Packet[_text.length];
|
||||||
|
Packet[] packets1_8 = new Packet[_text.length];
|
||||||
|
int i = 0;
|
||||||
|
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
|
||||||
|
{
|
||||||
|
_lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D));
|
||||||
|
for (Entry<Integer, Integer> entityId : this._entityIds)
|
||||||
|
{
|
||||||
|
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
|
||||||
|
relMove.a = entityId.getKey();
|
||||||
|
relMove.b = (byte) x;
|
||||||
|
relMove.c = (byte) y;
|
||||||
|
relMove.d = (byte) z;
|
||||||
|
packets1_7[i] = relMove;
|
||||||
|
packets1_8[i] = relMove;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = (int) Math.floor(32 * newLocation.getX());
|
||||||
|
z = (int) Math.floor(32 * newLocation.getZ());
|
||||||
|
_lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D));
|
||||||
|
for (Entry<Integer, Integer> entityId : this._entityIds)
|
||||||
|
{
|
||||||
|
for (int b = 0; b < 2; b++)
|
||||||
|
{
|
||||||
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
|
||||||
|
teleportPacket.a = entityId.getKey();
|
||||||
|
teleportPacket.b = x;
|
||||||
|
teleportPacket.c = (int) Math.floor((oldLocation.getY()
|
||||||
|
+ (b == 0 ? 54.6 : isUsingWitherSkull() ? -0.55 : -2.1) + ((double) i * 0.285)) * 32);
|
||||||
|
teleportPacket.d = z;
|
||||||
|
if (b == 0)
|
||||||
|
{
|
||||||
|
packets1_7[i] = teleportPacket;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packets1_8[i] = teleportPacket;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Player player : canSee)
|
||||||
|
{
|
||||||
|
for (Packet packet : UtilPlayer.is1_8(player) ? packets1_8 : packets1_7)
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the hologram text
|
||||||
|
*/
|
||||||
|
public Hologram setText(String... newText)
|
||||||
|
{
|
||||||
|
String[] reversed = new String[newText.length];
|
||||||
|
for (int i = 0; i < reversed.length; i++)
|
||||||
|
{
|
||||||
|
reversed[i] = newText[reversed.length - (i + 1)];
|
||||||
|
}
|
||||||
|
if (reversed.equals(_text))
|
||||||
|
return this;
|
||||||
|
_makePackets = true;
|
||||||
|
if (isInUse())
|
||||||
|
{
|
||||||
|
ArrayList<Packet> packets1_7 = new ArrayList<Packet>();
|
||||||
|
int[] destroy1_7 = new int[0];
|
||||||
|
int[] destroy1_8 = new int[0];
|
||||||
|
ArrayList<Packet> packets1_8 = new ArrayList<Packet>();
|
||||||
|
if (_text.length != reversed.length)
|
||||||
|
{
|
||||||
|
_destroyPackets = true;
|
||||||
|
}
|
||||||
|
for (int textRow = 0; textRow < Math.max(_text.length, reversed.length); textRow++)
|
||||||
|
{
|
||||||
|
// You can safely assume that _entityIds here is containing _text.length amount as this code is inside isInUse
|
||||||
|
if (textRow >= _text.length)
|
||||||
|
{
|
||||||
|
// Add entity id and send spawn packets
|
||||||
|
// You add a entity id because the new hologram needs
|
||||||
|
Entry<Integer, Integer> entry = new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId());
|
||||||
|
_entityIds.add(entry);
|
||||||
|
packets1_7.addAll(Arrays.asList(makeSpawnPackets1_7(textRow, entry.getKey(), entry.getValue(),
|
||||||
|
reversed[textRow])));
|
||||||
|
packets1_8.addAll(Arrays.asList(makeSpawnPackets1_8(textRow, entry.getKey(), reversed[textRow])));
|
||||||
|
}
|
||||||
|
else if (textRow >= reversed.length)
|
||||||
|
{
|
||||||
|
// Remove entity id and send destroy packets
|
||||||
|
Entry<Integer, Integer> entry = _entityIds.remove(reversed.length);
|
||||||
|
destroy1_7 = Arrays.copyOf(destroy1_7, destroy1_7.length + 2);
|
||||||
|
destroy1_7[destroy1_7.length - 2] = entry.getKey();
|
||||||
|
destroy1_7[destroy1_7.length - 1] = entry.getValue();
|
||||||
|
destroy1_8 = Arrays.copyOf(destroy1_8, destroy1_8.length + 1);
|
||||||
|
destroy1_8[destroy1_8.length - 1] = entry.getKey();
|
||||||
|
}
|
||||||
|
else if (!reversed[textRow].equals(_text[textRow]))
|
||||||
|
{
|
||||||
|
// Send update metadata packets
|
||||||
|
Entry<Integer, Integer> entry = _entityIds.get(textRow);
|
||||||
|
PacketPlayOutEntityMetadata metadata1_7 = new PacketPlayOutEntityMetadata();
|
||||||
|
metadata1_7.a = entry.getValue();
|
||||||
|
DataWatcher watcher1_7 = new DataWatcher(null);
|
||||||
|
watcher1_7.a(0, (byte) 0);
|
||||||
|
watcher1_7.a(1, (short) 300);
|
||||||
|
watcher1_7.a(10, reversed[textRow]);
|
||||||
|
watcher1_7.a(11, (byte) 1);
|
||||||
|
watcher1_7.a(12, -1700000);
|
||||||
|
metadata1_7.b = watcher1_7.c();
|
||||||
|
packets1_7.add(metadata1_7);
|
||||||
|
|
||||||
|
PacketPlayOutEntityMetadata metadata1_8 = new PacketPlayOutEntityMetadata();
|
||||||
|
metadata1_8.a = entry.getKey();
|
||||||
|
DataWatcher watcher1_8 = new DataWatcher(null);
|
||||||
|
watcher1_8.a(0, (byte) 0);
|
||||||
|
watcher1_8.a(2, reversed[textRow]);
|
||||||
|
watcher1_8.a(3, (byte) 1);
|
||||||
|
metadata1_8.b = watcher1_8.c();
|
||||||
|
packets1_8.add(metadata1_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (destroy1_7.length > 0)
|
||||||
|
{
|
||||||
|
packets1_7.add(new PacketPlayOutEntityDestroy(destroy1_7));
|
||||||
|
}
|
||||||
|
if (destroy1_8.length > 0)
|
||||||
|
{
|
||||||
|
packets1_8.add(new PacketPlayOutEntityDestroy(destroy1_8));
|
||||||
|
}
|
||||||
|
for (Player player : _playersTracking)
|
||||||
|
{
|
||||||
|
for (Packet packet : UtilPlayer.is1_8(player) ? packets1_8 : packets1_7)
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_text = reversed;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the hologram to use the wither skull instead of armorstand for 1.8 clients
|
||||||
|
*/
|
||||||
|
public Hologram setUsesWitherSkull()
|
||||||
|
{
|
||||||
|
_isWitherSkull = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the distance the hologram is viewable from. Default is 70
|
||||||
|
*/
|
||||||
|
public Hologram setViewDistance(int newDistance)
|
||||||
|
{
|
||||||
|
this._viewDistance = newDistance;
|
||||||
|
return setLocation(getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArrayList<Player> getPlayersTracking()
|
||||||
|
{
|
||||||
|
return _playersTracking;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the hologram
|
||||||
|
*/
|
||||||
|
public Hologram start()
|
||||||
|
{
|
||||||
|
if (!isInUse())
|
||||||
|
{
|
||||||
|
_hologramManager.addHologram(this);
|
||||||
|
_playersTracking.addAll(getNearbyPlayers());
|
||||||
|
for (Player player : _playersTracking)
|
||||||
|
{
|
||||||
|
for (Packet packet : getSpawnPackets(player))
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_lastMovement = new Vector();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the hologram
|
||||||
|
*/
|
||||||
|
public Hologram stop()
|
||||||
|
{
|
||||||
|
if (isInUse())
|
||||||
|
{
|
||||||
|
_hologramManager.removeHologram(this);
|
||||||
|
for (Player player : _playersTracking)
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(getDestroyPacket(player));
|
||||||
|
}
|
||||||
|
_playersTracking.clear();
|
||||||
|
_lastMovement = null;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package mineplex.core.hologram;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import net.minecraft.server.v1_7_R4.Packet;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class HologramManager implements Listener
|
||||||
|
{
|
||||||
|
private ArrayList<Hologram> _activeHolograms = new ArrayList<Hologram>();
|
||||||
|
|
||||||
|
public HologramManager(JavaPlugin arcadeManager)
|
||||||
|
{
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, arcadeManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addHologram(Hologram hologram)
|
||||||
|
{
|
||||||
|
_activeHolograms.add(hologram);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeHologram(Hologram hologram)
|
||||||
|
{
|
||||||
|
_activeHolograms.remove(hologram);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onTick(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK || _activeHolograms.isEmpty())
|
||||||
|
return;
|
||||||
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
Iterator<Hologram> itel = _activeHolograms.iterator();
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Hologram hologram = itel.next();
|
||||||
|
if (!worlds.contains(hologram.getLocation().getWorld()))
|
||||||
|
{
|
||||||
|
itel.remove();
|
||||||
|
hologram.stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArrayList<Player> canSee = hologram.getNearbyPlayers();
|
||||||
|
Iterator<Player> itel2 = hologram.getPlayersTracking().iterator();
|
||||||
|
while (itel2.hasNext())
|
||||||
|
{
|
||||||
|
Player player = itel2.next();
|
||||||
|
if (!canSee.contains(player))
|
||||||
|
{
|
||||||
|
itel2.remove();
|
||||||
|
if (player.getWorld() == hologram.getLocation().getWorld())
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(hologram.getDestroyPacket(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Player player : canSee)
|
||||||
|
{
|
||||||
|
if (!hologram.getPlayersTracking().contains(player))
|
||||||
|
{
|
||||||
|
hologram.getPlayersTracking().add(player);
|
||||||
|
for (Packet packet : hologram.getSpawnPackets(player))
|
||||||
|
{
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,132 +0,0 @@
|
|||||||
package mineplex.core.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityFireball;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityHorse;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntitySmallFireball;
|
|
||||||
import net.minecraft.server.v1_7_R4.Packet;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
|
||||||
import net.minecraft.server.v1_7_R4.World;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Shaun on 8/29/2014.
|
|
||||||
*/
|
|
||||||
public class HorseHologram
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* HorseHologram creates the required entities to spawn in a hologram. It is possible to send the packets for the entities to a player,
|
|
||||||
* but it is also possible to add the entities to the nmsWorld to keep them loaded into the server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private Location _location;
|
|
||||||
private String _text;
|
|
||||||
|
|
||||||
private World _nmsWorld;
|
|
||||||
private EntityFireball _fireball;
|
|
||||||
private EntityHorse _horse;
|
|
||||||
|
|
||||||
public HorseHologram(Location location, String text)
|
|
||||||
{
|
|
||||||
_location = location;
|
|
||||||
_text = text;
|
|
||||||
|
|
||||||
_nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
|
|
||||||
|
|
||||||
// Create Entities
|
|
||||||
_fireball = new EntitySmallFireball(_nmsWorld);
|
|
||||||
_horse = new EntityHorse(_nmsWorld);
|
|
||||||
|
|
||||||
// Location Data
|
|
||||||
_fireball.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0);
|
|
||||||
_horse.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0);
|
|
||||||
_horse.setAge(-1700000);
|
|
||||||
_horse.setCustomName(_text);
|
|
||||||
_horse.setCustomNameVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendToPlayer(Player player)
|
|
||||||
{
|
|
||||||
Packet fireballSpawn = getFireballSpawnPacket();
|
|
||||||
Packet horseSpawn = getHorseSpawnPacket();
|
|
||||||
Packet attachPacket = getAttachEntityPacket();
|
|
||||||
|
|
||||||
sendPacket(player, fireballSpawn);
|
|
||||||
sendPacket(player, horseSpawn);
|
|
||||||
sendPacket(player, attachPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeForPlayer(Player player)
|
|
||||||
{
|
|
||||||
Packet horseDestroy = getHorseDestroyPacket();
|
|
||||||
Packet fireballDestroy = getFireballDestroyPacket();
|
|
||||||
|
|
||||||
sendPacket(player, horseDestroy);
|
|
||||||
sendPacket(player, fireballDestroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnWithPackets()
|
|
||||||
{
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
sendToPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeWithPackets()
|
|
||||||
{
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
removeForPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String text)
|
|
||||||
{
|
|
||||||
_text = text;
|
|
||||||
_horse.setCustomName(_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText()
|
|
||||||
{
|
|
||||||
return _text;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getHorseSpawnPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutSpawnEntityLiving(_horse);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getFireballSpawnPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutSpawnEntity(_fireball, 64);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getAttachEntityPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutAttachEntity(0, _horse, _fireball);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getHorseDestroyPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutEntityDestroy(_horse.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Packet getFireballDestroyPacket()
|
|
||||||
{
|
|
||||||
return new PacketPlayOutEntityDestroy(_fireball.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendPacket(Player player, Packet packet)
|
|
||||||
{
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.core.inventory;
|
package mineplex.core.inventory;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -7,8 +9,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.inventory.command.GiveItemCommand;
|
import mineplex.core.inventory.command.GiveItemCommand;
|
||||||
@ -16,7 +18,7 @@ import mineplex.core.inventory.data.Category;
|
|||||||
import mineplex.core.inventory.data.InventoryRepository;
|
import mineplex.core.inventory.data.InventoryRepository;
|
||||||
import mineplex.core.inventory.data.Item;
|
import mineplex.core.inventory.data.Item;
|
||||||
|
|
||||||
public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
||||||
{
|
{
|
||||||
private static Object _inventoryLock = new Object();
|
private static Object _inventoryLock = new Object();
|
||||||
|
|
||||||
@ -25,9 +27,9 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
private NautHashMap<String, Item> _items = new NautHashMap<String, Item>();
|
private NautHashMap<String, Item> _items = new NautHashMap<String, Item>();
|
||||||
private NautHashMap<String, Category> _categories = new NautHashMap<String, Category>();
|
private NautHashMap<String, Category> _categories = new NautHashMap<String, Category>();
|
||||||
|
|
||||||
public InventoryManager(JavaPlugin plugin)
|
public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("Inventory Manager", plugin);
|
super("Inventory Manager", plugin, clientManager);
|
||||||
|
|
||||||
_repository = new InventoryRepository(plugin);
|
_repository = new InventoryRepository(plugin);
|
||||||
|
|
||||||
@ -69,6 +71,11 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
|
|
||||||
public void addItemToInventory(final Player player, String category, final String item, final int count)
|
public void addItemToInventory(final Player player, String category, final String item, final int count)
|
||||||
{
|
{
|
||||||
|
if (_items.containsKey(item))
|
||||||
|
{
|
||||||
|
Get(player).addItem(new ClientItem(_items.get(item), count));
|
||||||
|
}
|
||||||
|
|
||||||
addItemToInventory(null, player, category, item, count);
|
addItemToInventory(null, player, category, item, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,16 +85,15 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
{
|
{
|
||||||
public void run(Boolean success)
|
public void run(Boolean success)
|
||||||
{
|
{
|
||||||
if (success)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
System.out.println("Add item to Inventory FAILED for " + player.getName());
|
||||||
|
|
||||||
if (_items.containsKey(item))
|
if (_items.containsKey(item))
|
||||||
{
|
{
|
||||||
Get(player).addItem(new ClientItem(_items.get(item), count));
|
Get(player).addItem(new ClientItem(_items.get(item), -count));
|
||||||
}
|
}
|
||||||
System.out.println("Add item to Inventory succeeded.");
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
System.out.println("Add item to Inventory FAILED for " + player.getName());
|
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.run(success);
|
callback.run(success);
|
||||||
@ -165,23 +171,21 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
|||||||
return new ClientInventory();
|
return new ClientInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId().toString()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void AddCommands()
|
public void AddCommands()
|
||||||
{
|
{
|
||||||
addCommand(new GiveItemCommand(this));
|
addCommand(new GiveItemCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ public class InventoryRepository extends RepositoryBase
|
|||||||
private static String RETRIEVE_CATEGORIES = "SELECT id, name FROM itemCategories;";
|
private static String RETRIEVE_CATEGORIES = "SELECT id, name FROM itemCategories;";
|
||||||
|
|
||||||
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
||||||
private static String RETRIEVE_CLIENT_INVENTORY = "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = ?;";
|
|
||||||
|
|
||||||
public InventoryRepository(JavaPlugin plugin)
|
public InventoryRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
@ -98,20 +97,14 @@ public class InventoryRepository extends RepositoryBase
|
|||||||
return executeUpdate(INSERT_CLIENT_INVENTORY, new ColumnInt("itemid", itemId), new ColumnInt("count", count), new ColumnVarChar("uuid", 100, uuid)) > 0;
|
return executeUpdate(INSERT_CLIENT_INVENTORY, new ColumnInt("itemid", itemId), new ColumnInt("count", count), new ColumnVarChar("uuid", 100, uuid)) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientInventory loadClientInformation(String uuid)
|
public ClientInventory loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final ClientInventory clientInventory = new ClientInventory();
|
final ClientInventory clientInventory = new ClientInventory();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_CLIENT_INVENTORY, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
clientInventory.addItem(new ClientItem(new Item(resultSet.getString(1), resultSet.getString(2)), resultSet.getInt(3)));
|
clientInventory.addItem(new ClientItem(new Item(resultSet.getString(1), resultSet.getString(2)), resultSet.getInt(3)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
return clientInventory;
|
return clientInventory;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -210,9 +209,4 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
|||||||
{
|
{
|
||||||
return _clientManager;
|
return _clientManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package mineplex.core.movement;
|
package mineplex.core.movement;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -45,9 +44,4 @@ public class Movement extends MiniClientPlugin<ClientMovement>
|
|||||||
{
|
{
|
||||||
return new ClientMovement();
|
return new ClientMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.pet;
|
|||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
import mineplex.core.pet.repository.token.PetSalesToken;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package mineplex.core.pet;
|
package mineplex.core.pet;
|
||||||
|
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -11,14 +11,10 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||||
@ -27,15 +23,7 @@ import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
|
|||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
||||||
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -46,18 +34,13 @@ import org.bukkit.entity.Ageable;
|
|||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Skeleton;
|
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -395,11 +378,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
|||||||
return _activePetOwners.get(name);
|
return _activePetOwners.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisableAll()
|
public void DisableAll()
|
||||||
{
|
{
|
||||||
for (Player player : UtilServer.getPlayers())
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package mineplex.core.preferences;
|
package mineplex.core.preferences;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
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;
|
||||||
@ -12,9 +13,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
@ -23,7 +23,7 @@ import mineplex.core.preferences.ui.PreferencesShop;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||||
{
|
{
|
||||||
private PreferencesRepository _repository;
|
private PreferencesRepository _repository;
|
||||||
private PreferencesShop _shop;
|
private PreferencesShop _shop;
|
||||||
@ -34,7 +34,7 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
|||||||
|
|
||||||
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||||
{
|
{
|
||||||
super("Preferences", plugin);
|
super("Preferences", plugin, clientManager);
|
||||||
|
|
||||||
setupConfigValues();
|
setupConfigValues();
|
||||||
|
|
||||||
@ -64,20 +64,6 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
|||||||
return new UserPreferences();
|
return new UserPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void savePreferences(Player caller)
|
public void savePreferences(Player caller)
|
||||||
{
|
{
|
||||||
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
|
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
|
||||||
@ -134,4 +120,16 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
|||||||
{
|
{
|
||||||
_shop.attemptShopOpen(caller);
|
_shop.attemptShopOpen(caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,17 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
import mineplex.core.database.ResultSetCallable;
|
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
|
|
||||||
public class PreferencesRepository extends RepositoryBase
|
public class PreferencesRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE uuid = ?;";
|
|
||||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
|
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
|
||||||
|
|
||||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||||
@ -62,7 +59,32 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preparedStatement.addBatch();
|
preparedStatement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStatement.executeBatch();
|
int[] rowsAffected = preparedStatement.executeBatch();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (Entry<String, UserPreferences> entry : preferences.entrySet())
|
||||||
|
{
|
||||||
|
if (rowsAffected[i] < 1)
|
||||||
|
{
|
||||||
|
executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, entry.getKey()));
|
||||||
|
|
||||||
|
preparedStatement.setBoolean(1, entry.getValue().HubGames);
|
||||||
|
preparedStatement.setBoolean(2, entry.getValue().ShowPlayers);
|
||||||
|
preparedStatement.setBoolean(3, entry.getValue().ShowChat);
|
||||||
|
preparedStatement.setBoolean(4, entry.getValue().FriendChat);
|
||||||
|
preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging);
|
||||||
|
preparedStatement.setBoolean(6, entry.getValue().PartyRequests);
|
||||||
|
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
|
||||||
|
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
|
||||||
|
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
||||||
|
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
||||||
|
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
|
||||||
|
preparedStatement.setString(12, entry.getKey());
|
||||||
|
preparedStatement.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -84,19 +106,11 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserPreferences loadClientInformation(final UUID uuid)
|
public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final UserPreferences preferences = new UserPreferences();
|
final UserPreferences preferences = new UserPreferences();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_ACCOUNT_PREFERENCES, new ResultSetCallable()
|
if (resultSet.next())
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
if (!resultSet.next())
|
|
||||||
{
|
|
||||||
executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, uuid.toString()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
preferences.HubGames = resultSet.getBoolean(1);
|
preferences.HubGames = resultSet.getBoolean(1);
|
||||||
preferences.ShowPlayers = resultSet.getBoolean(2);
|
preferences.ShowPlayers = resultSet.getBoolean(2);
|
||||||
@ -110,8 +124,6 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||||
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
|
||||||
|
|
||||||
return preferences;
|
return preferences;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
package mineplex.core.stats;
|
package mineplex.core.stats;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.stats.command.GiveStatCommand;
|
import mineplex.core.stats.command.GiveStatCommand;
|
||||||
import mineplex.core.stats.command.TimeCommand;
|
import mineplex.core.stats.command.TimeCommand;
|
||||||
import mineplex.core.stats.event.StatChangeEvent;
|
import mineplex.core.stats.event.StatChangeEvent;
|
||||||
|
|
||||||
public class StatsManager extends MiniClientPlugin<PlayerStats>
|
public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||||
{
|
{
|
||||||
private static Object _statSync = new Object();
|
private static Object _statSync = new Object();
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
private NautHashMap<String, NautHashMap<String, Integer>> _statUploadQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
|
private NautHashMap<String, NautHashMap<String, Integer>> _statUploadQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||||
private Runnable _saveRunnable;
|
private Runnable _saveRunnable;
|
||||||
|
|
||||||
public StatsManager(JavaPlugin plugin)
|
public StatsManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
super("StatsManager", plugin);
|
super("Stats Manager", plugin, clientManager);
|
||||||
|
|
||||||
_repository = new StatsRepository(plugin);
|
_repository = new StatsRepository(plugin);
|
||||||
|
|
||||||
@ -117,20 +117,6 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
return new PlayerStats();
|
return new PlayerStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
event.incrementProcessingCount();
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId().toString()));
|
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerStats getOfflinePlayerStats(String playerName) throws SQLException
|
public PlayerStats getOfflinePlayerStats(String playerName) throws SQLException
|
||||||
{
|
{
|
||||||
return _repository.loadOfflinePlayerStats(playerName);
|
return _repository.loadOfflinePlayerStats(playerName);
|
||||||
@ -185,4 +171,16 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
|||||||
addCommand(new TimeCommand(this));
|
addCommand(new TimeCommand(this));
|
||||||
addCommand(new GiveStatCommand(this));
|
addCommand(new GiveStatCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadClientInformation(resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = '" + uuid + "';";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package mineplex.core.stats;
|
package mineplex.core.stats;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -14,17 +13,12 @@ import mineplex.core.database.RepositoryBase;
|
|||||||
import mineplex.core.database.ResultSetCallable;
|
import mineplex.core.database.ResultSetCallable;
|
||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
import mineplex.database.Tables;
|
import mineplex.database.Tables;
|
||||||
import mineplex.database.tables.records.AccountStatsRecord;
|
|
||||||
import mineplex.database.tables.records.StatsRecord;
|
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.Insert;
|
import org.jooq.Insert;
|
||||||
import org.jooq.InsertQuery;
|
|
||||||
import org.jooq.Query;
|
|
||||||
import org.jooq.Record;
|
|
||||||
import org.jooq.Record2;
|
import org.jooq.Record2;
|
||||||
import org.jooq.Result;
|
import org.jooq.Result;
|
||||||
import org.jooq.Update;
|
import org.jooq.Update;
|
||||||
import org.jooq.UpdateQuery;
|
|
||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
|
|
||||||
public class StatsRepository extends RepositoryBase
|
public class StatsRepository extends RepositoryBase
|
||||||
@ -32,7 +26,6 @@ public class StatsRepository extends RepositoryBase
|
|||||||
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));";
|
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));";
|
||||||
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
|
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
|
||||||
|
|
||||||
private static String RETRIEVE_PLAYER_STATS = "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = ?;";
|
|
||||||
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
||||||
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||||
|
|
||||||
@ -81,10 +74,9 @@ public class StatsRepository extends RepositoryBase
|
|||||||
executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name));
|
executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public void saveStats(NautHashMap<String, NautHashMap<Integer, Integer>> uploadQueue)
|
public void saveStats(NautHashMap<String, NautHashMap<Integer, Integer>> uploadQueue)
|
||||||
{
|
{
|
||||||
System.out.println("saving stats.");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DSLContext context = DSL.using(getConnection());
|
DSLContext context = DSL.using(getConnection());
|
||||||
@ -96,8 +88,6 @@ public class StatsRepository extends RepositoryBase
|
|||||||
{
|
{
|
||||||
for (Integer statId : uploadQueue.get(uuid).keySet())
|
for (Integer statId : uploadQueue.get(uuid).keySet())
|
||||||
{
|
{
|
||||||
System.out.println("saving stat : uuid=" + uuid + " " + statId + "=" + uploadQueue.get(uuid).get(statId));
|
|
||||||
|
|
||||||
Update update = context
|
Update update = context
|
||||||
.update(Tables.accountStats)
|
.update(Tables.accountStats)
|
||||||
.set(Tables.accountStats.value, Tables.accountStats.value.plus(uploadQueue.get(uuid).get(statId)))
|
.set(Tables.accountStats.value, Tables.accountStats.value.plus(uploadQueue.get(uuid).get(statId)))
|
||||||
@ -166,20 +156,14 @@ public class StatsRepository extends RepositoryBase
|
|||||||
return playerStats;
|
return playerStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerStats loadClientInformation(String uuid)
|
public PlayerStats loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
final PlayerStats playerStats = new PlayerStats();
|
final PlayerStats playerStats = new PlayerStats();
|
||||||
|
|
||||||
executeQuery(RETRIEVE_PLAYER_STATS, new ResultSetCallable()
|
|
||||||
{
|
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, new ColumnVarChar("uuid", 100, uuid));
|
|
||||||
|
|
||||||
return playerStats;
|
return playerStats;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.task.repository.TaskRepository;
|
import mineplex.core.task.repository.TaskRepository;
|
||||||
import mineplex.core.task.repository.TaskToken;
|
import mineplex.core.task.repository.TaskToken;
|
||||||
|
|
||||||
@ -52,9 +51,4 @@ public class TaskManager extends MiniClientPlugin<TaskClient>
|
|||||||
|
|
||||||
_repository.AddTask(client.Name, taskName);
|
_repository.AddTask(client.Name, taskName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,13 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
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.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.reward.Reward;
|
import mineplex.core.reward.Reward;
|
||||||
import mineplex.core.reward.RewardData;
|
import mineplex.core.reward.RewardData;
|
||||||
import mineplex.core.reward.RewardRarity;
|
import mineplex.core.reward.RewardRarity;
|
||||||
@ -56,15 +57,16 @@ public class Treasure
|
|||||||
private LinkedList<Animation> _animations;
|
private LinkedList<Animation> _animations;
|
||||||
|
|
||||||
private TreasureStyle _style;
|
private TreasureStyle _style;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
public Treasure(Player player, Reward[] rewards, BlockRestore blockRestore)
|
public Treasure(Player player, Reward[] rewards, BlockRestore blockRestore, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
this(player, new Random(), rewards);
|
this(player, new Random(), rewards, hologramManager);
|
||||||
|
|
||||||
_blockRestore = blockRestore;
|
_blockRestore = blockRestore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treasure(Player player, Random seed, Reward[] rewards)
|
public Treasure(Player player, Random seed, Reward[] rewards, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
_player = player;
|
_player = player;
|
||||||
_random = seed;
|
_random = seed;
|
||||||
@ -73,6 +75,7 @@ public class Treasure
|
|||||||
|
|
||||||
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||||
_animations = new LinkedList<Animation>();
|
_animations = new LinkedList<Animation>();
|
||||||
|
_hologramManager = hologramManager;
|
||||||
|
|
||||||
// _animations.add(new ParticleAnimation(this));
|
// _animations.add(new ParticleAnimation(this));
|
||||||
|
|
||||||
@ -288,7 +291,7 @@ public class Treasure
|
|||||||
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
|
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
|
||||||
|
|
||||||
data.setOpened(true);
|
data.setOpened(true);
|
||||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData);
|
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager);
|
||||||
_animations.add(chestOpenTask);
|
_animations.add(chestOpenTask);
|
||||||
|
|
||||||
// Extra effects based off the rarity of the treasure
|
// Extra effects based off the rarity of the treasure
|
||||||
|
@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilPlayer;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.event.StackerEvent;
|
import mineplex.core.event.StackerEvent;
|
||||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.pet.PetManager;
|
import mineplex.core.pet.PetManager;
|
||||||
import mineplex.core.reward.Reward;
|
import mineplex.core.reward.Reward;
|
||||||
@ -55,14 +56,16 @@ public class TreasureManager extends MiniPlugin
|
|||||||
private RewardManager _rewardManager;
|
private RewardManager _rewardManager;
|
||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore)
|
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
super("Treasure", plugin);
|
super("Treasure", plugin);
|
||||||
|
|
||||||
_playerTreasureMap = new NautHashMap<Player, Treasure>();
|
_playerTreasureMap = new NautHashMap<Player, Treasure>();
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
_blockRestore = blockRestore;
|
_blockRestore = blockRestore;
|
||||||
|
_hologramManager = hologramManager;
|
||||||
_rewardManager = new RewardManager(donationManager, inventoryManager, petManager,
|
_rewardManager = new RewardManager(donationManager, inventoryManager, petManager,
|
||||||
250, 500,
|
250, 500,
|
||||||
750, 1500,
|
750, 1500,
|
||||||
@ -108,7 +111,7 @@ public class TreasureManager extends MiniPlugin
|
|||||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
|
||||||
|
|
||||||
Reward[] rewards = _rewardManager.getRewards(player, true);
|
Reward[] rewards = _rewardManager.getRewards(player, true);
|
||||||
Treasure treasure = new Treasure(player, rewards, _blockRestore);
|
Treasure treasure = new Treasure(player, rewards, _blockRestore, _hologramManager);
|
||||||
_playerTreasureMap.put(player, treasure);
|
_playerTreasureMap.put(player, treasure);
|
||||||
|
|
||||||
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
|
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
package mineplex.core.treasure.animation;
|
package mineplex.core.treasure.animation;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.hologram.Hologram;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
|
import mineplex.core.reward.RewardData;
|
||||||
|
import mineplex.core.treasure.ChestData;
|
||||||
|
import mineplex.core.treasure.Treasure;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -8,13 +16,6 @@ import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
|||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.hologram.Hologram;
|
|
||||||
import mineplex.core.reward.RewardData;
|
|
||||||
import mineplex.core.treasure.ChestData;
|
|
||||||
import mineplex.core.treasure.Treasure;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Shaun on 8/29/2014.
|
* Created by Shaun on 8/29/2014.
|
||||||
@ -23,19 +24,22 @@ public class ChestOpenAnimation extends Animation
|
|||||||
{
|
{
|
||||||
private ChestData _chestData;
|
private ChestData _chestData;
|
||||||
private RewardData _rewardData;
|
private RewardData _rewardData;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
|
|
||||||
private Item _itemEntity;
|
private Item _itemEntity;
|
||||||
private Hologram _hologram;
|
private Hologram _hologram;
|
||||||
|
|
||||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData)
|
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
super(treasure);
|
super(treasure);
|
||||||
|
_hologramManager = hologramManager;
|
||||||
_chestData = chestData;
|
_chestData = chestData;
|
||||||
_rewardData = rewardData;
|
_rewardData = rewardData;
|
||||||
|
|
||||||
// Send chest open packet
|
// Send chest open packet
|
||||||
Block block = chestData.getBlock();
|
Block block = chestData.getBlock();
|
||||||
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(), CraftMagicNumbers.getBlock(block), 1, 1);
|
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(),
|
||||||
|
CraftMagicNumbers.getBlock(block), 1, 1);
|
||||||
for (Player other : UtilServer.getPlayers())
|
for (Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
||||||
@ -55,8 +59,9 @@ public class ChestOpenAnimation extends Animation
|
|||||||
}
|
}
|
||||||
else if (getTicks() == 15)
|
else if (getTicks() == 15)
|
||||||
{
|
{
|
||||||
_hologram = new Hologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _rewardData.getFriendlyName());
|
_hologram = new Hologram(_hologramManager, _chestData.getBlock().getLocation().add(0.5, 1.1, 0.5),
|
||||||
_hologram.sendToPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
_rewardData.getFriendlyName());
|
||||||
|
_hologram.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +69,7 @@ public class ChestOpenAnimation extends Animation
|
|||||||
{
|
{
|
||||||
if (_hologram != null)
|
if (_hologram != null)
|
||||||
{
|
{
|
||||||
_hologram.removeForPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
_hologram.stop();
|
||||||
_itemEntity.remove();
|
_itemEntity.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
|||||||
import mineplex.core.teleport.Teleport;
|
import mineplex.core.teleport.Teleport;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
@ -126,9 +127,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void Update(UpdateEvent event)
|
public void Update(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() == UpdateType.SEC)
|
|
||||||
Power();
|
|
||||||
|
|
||||||
if (event.getType() == UpdateType.FAST)
|
if (event.getType() == UpdateType.FAST)
|
||||||
CGame().UpdateSafe();
|
CGame().UpdateSafe();
|
||||||
|
|
||||||
@ -184,7 +182,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
||||||
{
|
{
|
||||||
ClansClan clan = Clans().CUtil().getOwner(event.GetLocation());
|
ClansClan clan = _clanUtility.getOwner(event.GetLocation());
|
||||||
|
|
||||||
if (clan != null)
|
if (clan != null)
|
||||||
if (!clan.IsAdmin() && !clan.GetName().equals("Spawn"))
|
if (!clan.IsAdmin() && !clan.GetName().equals("Spawn"))
|
||||||
@ -263,18 +261,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
|
|
||||||
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
|
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
|
||||||
{
|
{
|
||||||
CoreClient client = Clients().Get(event.getPlayer());
|
ClientClan client = Get(event.getPlayer());
|
||||||
|
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!client.Clan().IsClanChat())
|
if (!client.isClanChat())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
|
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
{
|
{
|
||||||
Clients().Get(event.getPlayer()).Clan().SetClanChat(false);
|
Get(event.getPlayer()).setClanChat(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,10 +285,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
if (!Get(event.getPlayer()).isAllyChat())
|
if (!Get(event.getPlayer()).isAllyChat())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
|
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
{
|
{
|
||||||
Clients().Get(event.getPlayer()).Clan().SetAllyChat(false);
|
Get(event.getPlayer()).setAllyChat(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,57 +329,36 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
|||||||
return _reclaimTime;
|
return _reclaimTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean canHurt(Player a, Player b)
|
||||||
public boolean CanHurt(Player a, Player b)
|
|
||||||
{
|
{
|
||||||
if (a.equals(b))
|
if (a.equals(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return CUtil().canHurt(a, b);
|
return _clanUtility.canHurt(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean canHurt(String a, String b)
|
||||||
public boolean CanHurt(String a, String b)
|
|
||||||
{
|
{
|
||||||
if (a.equals(b))
|
if (a.equals(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return CUtil().canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b));
|
return _clanUtility.canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isSafe(Player a)
|
||||||
public boolean IsSafe(Player a)
|
|
||||||
{
|
{
|
||||||
return CUtil().isSafe(a);
|
return _clanUtility.isSafe(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRepository GetRepository() {
|
public ClanRelation getRelation(String playerA, String playerB)
|
||||||
return _repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRepository(IRepository _repository) {
|
|
||||||
this._repository = _repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, ClansClan> GetClanMemberMap()
|
|
||||||
{
|
{
|
||||||
return _clanMemberMap;
|
return Get(playerA).getRelation(playerB);
|
||||||
}
|
|
||||||
|
|
||||||
public ClanRelation GetRelation(String playerA, String playerB)
|
|
||||||
{
|
|
||||||
return Clients().Get(playerA).Clan().GetRelation(playerB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatColor GetColorOfFor(String other, Player player)
|
public ChatColor GetColorOfFor(String other, Player player)
|
||||||
{
|
{
|
||||||
return CUtil().relChatColor(Clients().Get(player).Clan().GetRelation(other), false);
|
return _clanUtility.relChatColor(Get(player).getRelation(other), false);
|
||||||
}
|
|
||||||
|
|
||||||
public String GetServerName()
|
|
||||||
{
|
|
||||||
return _serverName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getOnlineTime()
|
public long getOnlineTime()
|
||||||
|
@ -16,6 +16,7 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.elo.EloManager;
|
import mineplex.core.elo.EloManager;
|
||||||
import mineplex.core.energy.Energy;
|
import mineplex.core.energy.Energy;
|
||||||
import mineplex.core.friend.FriendManager;
|
import mineplex.core.friend.FriendManager;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
import mineplex.core.memory.MemoryFix;
|
import mineplex.core.memory.MemoryFix;
|
||||||
@ -99,11 +100,11 @@ public class Hub extends JavaPlugin implements IRelation
|
|||||||
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
||||||
PacketHandler packetHandler = new PacketHandler(this);
|
PacketHandler packetHandler = new PacketHandler(this);
|
||||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||||
StatsManager statsManager = new StatsManager(this);
|
StatsManager statsManager = new StatsManager(this, clientManager);
|
||||||
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager);
|
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager);
|
||||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager);
|
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this));
|
||||||
|
|
||||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
|
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
|
||||||
|
|
||||||
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
|
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
|
||||||
new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
||||||
|
@ -42,9 +42,8 @@ import org.bukkit.scoreboard.Scoreboard;
|
|||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.achievement.AchievementManager;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.benefit.RankBenefitsGiver9000;
|
import mineplex.core.benefit.BenefitManager;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -65,6 +64,7 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.mount.MountManager;
|
import mineplex.core.mount.MountManager;
|
||||||
@ -144,7 +144,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
//Admin
|
//Admin
|
||||||
private boolean _gadgetsEnabled = true;
|
private boolean _gadgetsEnabled = true;
|
||||||
|
|
||||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager)
|
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager)
|
||||||
{
|
{
|
||||||
super("Hub Manager", plugin);
|
super("Hub Manager", plugin);
|
||||||
|
|
||||||
@ -172,10 +172,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
_news = new NewsManager(this);
|
_news = new NewsManager(this);
|
||||||
|
|
||||||
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
|
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
|
||||||
_inventoryManager = new InventoryManager(plugin);
|
_inventoryManager = new InventoryManager(plugin, clientManager);
|
||||||
new RankBenefitsGiver9000(plugin, clientManager, _inventoryManager);
|
new BenefitManager(plugin, clientManager, _inventoryManager);
|
||||||
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
|
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
|
||||||
_treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore);
|
_treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager);
|
||||||
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false, _treasureManager);
|
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false, _treasureManager);
|
||||||
|
|
||||||
_partyManager = partyManager;
|
_partyManager = partyManager;
|
||||||
@ -962,12 +962,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
return _news;
|
return _news;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,8 @@ public class PlayerPollData
|
|||||||
private NautHashMap<Integer, Integer> _pollAnswers;
|
private NautHashMap<Integer, Integer> _pollAnswers;
|
||||||
private long _nextPollTime;
|
private long _nextPollTime;
|
||||||
|
|
||||||
|
public boolean Loaded;
|
||||||
|
|
||||||
public PlayerPollData()
|
public PlayerPollData()
|
||||||
{
|
{
|
||||||
_pollAnswers = new NautHashMap<Integer, Integer>();
|
_pollAnswers = new NautHashMap<Integer, Integer>();
|
||||||
@ -40,7 +42,7 @@ public class PlayerPollData
|
|||||||
|
|
||||||
public boolean shouldPoll()
|
public boolean shouldPoll()
|
||||||
{
|
{
|
||||||
return System.currentTimeMillis() > _nextPollTime;
|
return Loaded && System.currentTimeMillis() > _nextPollTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
|
|||||||
import net.minecraft.util.com.google.gson.JsonObject;
|
import net.minecraft.util.com.google.gson.JsonObject;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
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.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -24,9 +23,6 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.hub.poll.command.PollCommand;
|
import mineplex.hub.poll.command.PollCommand;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Shaun on 8/16/2014.
|
|
||||||
*/
|
|
||||||
public class PollManager extends MiniClientPlugin<PlayerPollData>
|
public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||||
{
|
{
|
||||||
private PollRepository _repository;
|
private PollRepository _repository;
|
||||||
@ -57,17 +53,14 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
|
|||||||
return new PlayerPollData();
|
return new PlayerPollData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void loadClientInformation(final PlayerJoinEvent event)
|
||||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
|
||||||
{
|
{
|
||||||
event.incrementProcessingCount();
|
|
||||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Set(event.getPlayerName(), _repository.loadPollData(event.getUniqueId()));
|
Set(event.getPlayer().getName(), _repository.loadPollData(event.getPlayer().getUniqueId()));
|
||||||
event.decreaseProcessingCount();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,8 @@ public class PollRepository extends RepositoryBase
|
|||||||
}
|
}
|
||||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||||
|
|
||||||
|
pollData.Loaded = true;
|
||||||
|
|
||||||
return pollData;
|
return pollData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,10 @@ import mineplex.minecraft.game.classcombat.Class.repository.token.ClientClassTok
|
|||||||
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType;
|
|
||||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -309,9 +307,4 @@ public class ClassManager extends MiniClientPlugin<ClientClass> implements IClas
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class Illusion extends SkillActive
|
|||||||
"Invisibility ends if you release Block",
|
"Invisibility ends if you release Block",
|
||||||
"or your Illusion is killed.",
|
"or your Illusion is killed.",
|
||||||
"",
|
"",
|
||||||
"Illusion lasts up to #2#2 seconds.",
|
"Illusion lasts up to #2#1 seconds.",
|
||||||
"",
|
"",
|
||||||
"Gives Slow 2 for up to 4 seconds",
|
"Gives Slow 2 for up to 4 seconds",
|
||||||
"to nearby players upon ending."
|
"to nearby players upon ending."
|
||||||
@ -79,7 +79,7 @@ public class Illusion extends SkillActive
|
|||||||
@Override
|
@Override
|
||||||
public String GetEnergyString()
|
public String GetEnergyString()
|
||||||
{
|
{
|
||||||
return "Energy: #40#-3 and #12#-0.5 per Second";
|
return "Energy: #40#-3 and #12.5#-0.5 per Second";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,7 +130,7 @@ public class Illusion extends SkillActive
|
|||||||
Factory.Disguise().disguise(disguise, disguiseList);
|
Factory.Disguise().disguise(disguise, disguiseList);
|
||||||
|
|
||||||
//Invis
|
//Invis
|
||||||
Factory.Condition().Factory().Cloak(GetName(), player, player, 2 + 2*level, false, true);
|
Factory.Condition().Factory().Cloak(GetName(), player, player, 2 + 1*level, false, true);
|
||||||
|
|
||||||
_active.put(player, skel);
|
_active.put(player, skel);
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public class Illusion extends SkillActive
|
|||||||
|
|
||||||
if (Factory.Condition().GetActiveCondition(cur, ConditionType.CLOAK) == null ||
|
if (Factory.Condition().GetActiveCondition(cur, ConditionType.CLOAK) == null ||
|
||||||
!cur.isBlocking() ||
|
!cur.isBlocking() ||
|
||||||
!Factory.Energy().Use(cur, GetName(), 0.6 - (getLevel(cur) * 0.025), true, true) ||
|
!Factory.Energy().Use(cur, GetName(), 0.625 - (getLevel(cur) * 0.025), true, true) ||
|
||||||
skel == null ||
|
skel == null ||
|
||||||
!skel.isValid())
|
!skel.isValid())
|
||||||
{
|
{
|
||||||
|
@ -80,8 +80,8 @@ public class SeismicSlam extends SkillActive
|
|||||||
SetDesc(new String[]
|
SetDesc(new String[]
|
||||||
{
|
{
|
||||||
"Jump up and slam back into the ground.",
|
"Jump up and slam back into the ground.",
|
||||||
"Players within #6#0.5 Blocks take up to",
|
"Players within #5.5#0.5 Blocks take up to",
|
||||||
"#2#1 damage and are thrown into the air.",
|
"#1#1 damage and are thrown into the air.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class SeismicSlam extends SkillActive
|
|||||||
_live.remove(player);
|
_live.remove(player);
|
||||||
|
|
||||||
//Action
|
//Action
|
||||||
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), 6d + 0.5 * level);
|
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), 5.5d + 0.5 * level);
|
||||||
for (LivingEntity cur : targets.keySet())
|
for (LivingEntity cur : targets.keySet())
|
||||||
{
|
{
|
||||||
if (cur.equals(player))
|
if (cur.equals(player))
|
||||||
@ -145,13 +145,13 @@ public class SeismicSlam extends SkillActive
|
|||||||
|
|
||||||
//Damage Event
|
//Damage Event
|
||||||
Factory.Damage().NewDamageEvent(cur, player, null,
|
Factory.Damage().NewDamageEvent(cur, player, null,
|
||||||
DamageCause.CUSTOM, (2+level) * targets.get(cur) + 0.5, false, true, false,
|
DamageCause.CUSTOM, (1+level) * targets.get(cur) + 0.5, false, true, false,
|
||||||
player.getName(), GetName());
|
player.getName(), GetName());
|
||||||
|
|
||||||
//Velocity
|
//Velocity
|
||||||
UtilAction.velocity(cur,
|
UtilAction.velocity(cur,
|
||||||
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
|
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
|
||||||
1.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.6, true);
|
0.2 + 1.6 * targets.get(cur), true, 0, 0.2 + 1.2 * targets.get(cur), 1.6, true);
|
||||||
|
|
||||||
//Condition
|
//Condition
|
||||||
Factory.Condition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
Factory.Condition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
||||||
|
@ -19,7 +19,6 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
import mineplex.core.antistack.AntiStack;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
@ -156,7 +155,6 @@ public class AxeThrow extends SkillActive implements IThrown
|
|||||||
|
|
||||||
Player player = _thrown.remove(event.getItem());
|
Player player = _thrown.remove(event.getItem());
|
||||||
|
|
||||||
AntiStack.removeUID(event.getItem());
|
|
||||||
player.getInventory().addItem(event.getItem().getItemStack());
|
player.getInventory().addItem(event.getItem().getItemStack());
|
||||||
|
|
||||||
UtilInv.Update(event.getPlayer());
|
UtilInv.Update(event.getPlayer());
|
||||||
@ -190,7 +188,6 @@ public class AxeThrow extends SkillActive implements IThrown
|
|||||||
|
|
||||||
if (item.getTicksLived() > 400 - level * 40)
|
if (item.getTicksLived() > 400 - level * 40)
|
||||||
{
|
{
|
||||||
AntiStack.removeUID(item);
|
|
||||||
_thrown.get(item).getInventory().addItem(item.getItemStack());
|
_thrown.get(item).getInventory().addItem(item.getItemStack());
|
||||||
item.remove();
|
item.remove();
|
||||||
itemIterator.remove();
|
itemIterator.remove();
|
||||||
|
@ -55,10 +55,10 @@ public class ExplosiveShot extends SkillActive
|
|||||||
{
|
{
|
||||||
"Prepare an explosive shot;",
|
"Prepare an explosive shot;",
|
||||||
"Your next arrow will explode on",
|
"Your next arrow will explode on",
|
||||||
"impact, dealing up to 12 damage",
|
"impact, dealing up to 10 damage",
|
||||||
"and knockback. ",
|
"and knockback. ",
|
||||||
" ",
|
" ",
|
||||||
"Explosion radius of #5#1",
|
"Explosion radius of #4.5#0.5",
|
||||||
});
|
});
|
||||||
|
|
||||||
setAchievementSkill(true);
|
setAchievementSkill(true);
|
||||||
@ -210,7 +210,7 @@ public class ExplosiveShot extends SkillActive
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Velocity Players
|
//Velocity Players
|
||||||
HashMap<Player,Double> hitMap = UtilPlayer.getInRadius(loc, 5 + (level));
|
HashMap<Player,Double> hitMap = UtilPlayer.getInRadius(loc, 4.5 + (level * 0.5));
|
||||||
for (Player cur : hitMap.keySet())
|
for (Player cur : hitMap.keySet())
|
||||||
{
|
{
|
||||||
double range = hitMap.get(cur);
|
double range = hitMap.get(cur);
|
||||||
@ -220,7 +220,7 @@ public class ExplosiveShot extends SkillActive
|
|||||||
|
|
||||||
//Damage Event
|
//Damage Event
|
||||||
Factory.Damage().NewDamageEvent(cur, player, null,
|
Factory.Damage().NewDamageEvent(cur, player, null,
|
||||||
DamageCause.CUSTOM, 2 + 10 * range, false, true, false,
|
DamageCause.CUSTOM, 10 * range, false, true, false,
|
||||||
player.getName(), GetName());
|
player.getName(), GetName());
|
||||||
|
|
||||||
//Velocity
|
//Velocity
|
||||||
|
@ -170,8 +170,8 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
|
|
||||||
AddSkill(new Illusion(this, "Illusion", ClassType.Assassin, SkillType.Sword,
|
AddSkill(new Illusion(this, "Illusion", ClassType.Assassin, SkillType.Sword,
|
||||||
1, 4,
|
1, 4,
|
||||||
40, -3,
|
50, -4,
|
||||||
40000, -3000, true,
|
20000, -1000, true,
|
||||||
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
|||||||
AddSkill(new SeismicSlam(this, "Seismic Slam", ClassType.Brute, SkillType.Axe,
|
AddSkill(new SeismicSlam(this, "Seismic Slam", ClassType.Brute, SkillType.Axe,
|
||||||
1, 5,
|
1, 5,
|
||||||
0, 0,
|
0, 0,
|
||||||
30000, -3000, true,
|
30000, -2000, true,
|
||||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ public class ServerCommandManager
|
|||||||
*/
|
*/
|
||||||
private void initialize()
|
private void initialize()
|
||||||
{
|
{
|
||||||
|
/* CAUSING STUTTER LAG IN HUBS
|
||||||
final Jedis jedis = _jedisPool.getResource();
|
final Jedis jedis = _jedisPool.getResource();
|
||||||
|
|
||||||
// Spin up a new thread and subscribe to the Redis pubsub network
|
// Spin up a new thread and subscribe to the Redis pubsub network
|
||||||
@ -67,13 +68,18 @@ public class ServerCommandManager
|
|||||||
});
|
});
|
||||||
|
|
||||||
thread.start();
|
thread.start();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish a {@link ServerCommand} across the network to all live servers.
|
* Publish a {@link ServerCommand} across the network to all live servers.
|
||||||
* @param serverCommand - the {@link ServerCommand} to issue to all servers.
|
* @param serverCommand - the {@link ServerCommand} to issue to all servers.
|
||||||
*/
|
*/
|
||||||
public void publishCommand(ServerCommand serverCommand)
|
public void publishCommand(final ServerCommand serverCommand)
|
||||||
|
{
|
||||||
|
new Thread(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
{
|
{
|
||||||
Jedis jedis = _jedisPool.getResource();
|
Jedis jedis = _jedisPool.getResource();
|
||||||
|
|
||||||
@ -92,6 +98,8 @@ public class ServerCommandManager
|
|||||||
_jedisPool.returnResource(jedis);
|
_jedisPool.returnResource(jedis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming (serialized) {@link ServerCommand}.
|
* Handle an incoming (serialized) {@link ServerCommand}.
|
||||||
|
@ -57,7 +57,7 @@ public class StaffServer extends JavaPlugin
|
|||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
new FileUpdater(this, portal);
|
new FileUpdater(this, portal);
|
||||||
|
|
||||||
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this), new StatsManager(this)));
|
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), new StatsManager(this, clientManager)));
|
||||||
new Password(this, serverStatusManager.getCurrentServerName());
|
new Password(this, serverStatusManager.getCurrentServerName());
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
|
@ -20,6 +20,7 @@ import mineplex.core.disguise.DisguiseManager;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.friend.FriendManager;
|
import mineplex.core.friend.FriendManager;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
@ -107,9 +108,10 @@ public class Arcade extends JavaPlugin
|
|||||||
BlockRestore blockRestore = new BlockRestore(this);
|
BlockRestore blockRestore = new BlockRestore(this);
|
||||||
|
|
||||||
ProjectileManager projectileManager = new ProjectileManager(this);
|
ProjectileManager projectileManager = new ProjectileManager(this);
|
||||||
|
HologramManager hologramManager = new HologramManager(this);
|
||||||
|
|
||||||
//Inventory
|
//Inventory
|
||||||
InventoryManager inventoryManager = new InventoryManager(this);
|
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
|
||||||
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
||||||
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
||||||
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
||||||
@ -117,7 +119,7 @@ public class Arcade extends JavaPlugin
|
|||||||
cosmeticManager.setInterfaceSlot(7);
|
cosmeticManager.setInterfaceSlot(7);
|
||||||
|
|
||||||
//Arcade Manager
|
//Arcade Manager
|
||||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, webServerAddress);
|
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress);
|
||||||
|
|
||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
new CustomTagFix(this, packetHandler);
|
new CustomTagFix(this, packetHandler);
|
||||||
|
@ -54,6 +54,7 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.elo.EloManager;
|
import mineplex.core.elo.EloManager;
|
||||||
import mineplex.core.energy.Energy;
|
import mineplex.core.energy.Energy;
|
||||||
import mineplex.core.explosion.Explosion;
|
import mineplex.core.explosion.Explosion;
|
||||||
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.movement.Movement;
|
import mineplex.core.movement.Movement;
|
||||||
@ -145,7 +146,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
private CosmeticManager _cosmeticManager;
|
private CosmeticManager _cosmeticManager;
|
||||||
private final IdleManager _idleManager;
|
private final IdleManager _idleManager;
|
||||||
|
private HologramManager _hologramManager;
|
||||||
private AchievementManager _achievementManager;
|
private AchievementManager _achievementManager;
|
||||||
private StatsManager _statsManager;
|
private StatsManager _statsManager;
|
||||||
private ClassManager _classManager;
|
private ClassManager _classManager;
|
||||||
@ -174,7 +175,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||||
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood,
|
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood,
|
||||||
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
||||||
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, String webAddress)
|
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress)
|
||||||
{
|
{
|
||||||
super("Game Manager", plugin);
|
super("Game Manager", plugin);
|
||||||
|
|
||||||
@ -218,7 +219,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
|
|
||||||
_packetHandler = packetHandler;
|
_packetHandler = packetHandler;
|
||||||
|
|
||||||
_statsManager = new StatsManager(plugin);
|
_statsManager = new StatsManager(plugin, clientManager);
|
||||||
_taskManager = new TaskManager(plugin, webAddress);
|
_taskManager = new TaskManager(plugin, webAddress);
|
||||||
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
||||||
_inventoryManager = inventoryManager;
|
_inventoryManager = inventoryManager;
|
||||||
@ -247,6 +248,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
new GameSpectatorManager(this);
|
new GameSpectatorManager(this);
|
||||||
_gameWorldManager = new GameWorldManager(this);
|
_gameWorldManager = new GameWorldManager(this);
|
||||||
new MiscManager(this);
|
new MiscManager(this);
|
||||||
|
_hologramManager = hologramManager;
|
||||||
_idleManager = new IdleManager(this);
|
_idleManager = new IdleManager(this);
|
||||||
//new HalloweenManager(this);
|
//new HalloweenManager(this);
|
||||||
|
|
||||||
@ -272,7 +274,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, itemFactory, _achievementManager, clientManager);
|
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, itemFactory, _achievementManager, clientManager);
|
||||||
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, webAddress);
|
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, webAddress);
|
||||||
|
|
||||||
_eloManager = new EloManager(_plugin);
|
_eloManager = new EloManager(_plugin, clientManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,6 +346,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
return _disguiseManager;
|
return _disguiseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HologramManager getHologramManager()
|
||||||
|
{
|
||||||
|
return _hologramManager;
|
||||||
|
}
|
||||||
|
|
||||||
public DamageManager GetDamage()
|
public DamageManager GetDamage()
|
||||||
{
|
{
|
||||||
return _damageManager;
|
return _damageManager;
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
@ -78,6 +78,8 @@ public class Quiver extends SoloGame
|
|||||||
this.BlockBreakAllow.add(102);
|
this.BlockBreakAllow.add(102);
|
||||||
this.BlockBreakAllow.add(20);
|
this.BlockBreakAllow.add(20);
|
||||||
|
|
||||||
|
this.DeathSpectateSecs = 4;
|
||||||
|
|
||||||
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Kills", "dummy");
|
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Kills", "dummy");
|
||||||
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ public class SheepGame extends TeamGame
|
|||||||
this.TeamArmor = true;
|
this.TeamArmor = true;
|
||||||
this.TeamArmorHotbar = true;
|
this.TeamArmorHotbar = true;
|
||||||
|
|
||||||
|
this.DeathSpectateSecs = 4;
|
||||||
|
|
||||||
registerStatTrackers(
|
registerStatTrackers(
|
||||||
new SheepThiefStatTracker(this),
|
new SheepThiefStatTracker(this),
|
||||||
new SheepDropStatTracker(this),
|
new SheepDropStatTracker(this),
|
||||||
|
@ -87,6 +87,8 @@ public class SuperSmash extends SoloGame
|
|||||||
|
|
||||||
this.CompassEnabled = true;
|
this.CompassEnabled = true;
|
||||||
|
|
||||||
|
this.DeathSpectateSecs = 6;
|
||||||
|
|
||||||
this.SpawnDistanceRequirement = 16;
|
this.SpawnDistanceRequirement = 16;
|
||||||
|
|
||||||
// Add stat table here
|
// Add stat table here
|
||||||
@ -374,17 +376,16 @@ public class SuperSmash extends SoloGame
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void HungerRestore(CustomDamageEvent event)
|
public void HungerRestore(CustomDamageEvent event)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (event.IsCancelled())
|
if (event.IsCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.GetDamagerPlayer(true) == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player damager = event.GetDamagerPlayer(true);
|
Player damager = event.GetDamagerPlayer(true);
|
||||||
if (damager == null)
|
if (damager == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (damager.equals(event.GetDamageeEntity()))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false))
|
if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ public class TurfForts extends TeamGame
|
|||||||
this.ItemDrop = false;
|
this.ItemDrop = false;
|
||||||
this.ItemPickup = false;
|
this.ItemPickup = false;
|
||||||
this.DamageSelf = false;
|
this.DamageSelf = false;
|
||||||
|
this.DeathSpectateSecs = 4;
|
||||||
|
|
||||||
registerStatTrackers(
|
registerStatTrackers(
|
||||||
new BlockShreadStatTracker(this),
|
new BlockShreadStatTracker(this),
|
||||||
|
@ -129,7 +129,7 @@ public class MiscManager implements Listener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void HubCommand(PlayerCommandPreprocessEvent event)
|
public void HubCommand(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
if (event.getMessage().startsWith("/hub") || event.getMessage().startsWith("/leave"))
|
if (event.getMessage().startsWith("/lobby") || event.getMessage().startsWith("/hub") || event.getMessage().startsWith("/leave"))
|
||||||
{
|
{
|
||||||
Manager.GetPortal().SendPlayerToServer(event.getPlayer(), "Lobby");
|
Manager.GetPortal().SendPlayerToServer(event.getPlayer(), "Lobby");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user