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;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
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.PacketPlayOutEntityDestroy;
|
||||
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.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, Integer>> _entityVehicleMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
|
||||
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
|
||||
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
|
||||
|
||||
private Field _destroyId;
|
||||
|
||||
@ -149,7 +152,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
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 = "";
|
||||
boolean nameShowing = false;
|
||||
@ -198,6 +201,14 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
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)
|
||||
|
@ -7,25 +7,20 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
|
||||
{
|
||||
private static Object _clientDataLock = new Object();
|
||||
|
||||
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
|
||||
|
||||
|
||||
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
|
||||
{
|
||||
super(moduleName, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void loadPlayer(RetrieveClientInformationEvent event)
|
||||
{
|
||||
loadClientInformation(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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 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.account.command.UpdateRank;
|
||||
import mineplex.core.account.event.AsyncClientLoadEvent;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.account.repository.AccountRepository;
|
||||
import mineplex.core.account.repository.token.ClientToken;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -41,11 +39,15 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
private static NautHashMap<String, Object> _clientLoginLock = new NautHashMap<String, Object>();
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
private AccountRepository _repository;
|
||||
private NautHashMap<String, CoreClient> _clientList;
|
||||
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
||||
|
||||
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||
|
||||
private Object _clientLock = new Object();
|
||||
|
||||
private static int _connectingClients = 0;
|
||||
@ -187,38 +189,11 @@ public class CoreClientManager extends MiniPlugin
|
||||
client.SetAccountId(token.AccountId);
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid);
|
||||
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();
|
||||
}
|
||||
});
|
||||
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||
|
||||
// JSON sql response
|
||||
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()
|
||||
{
|
||||
public void run()
|
||||
@ -235,42 +210,38 @@ public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");
|
||||
|
||||
_clientLoginLock.put(client.GetPlayerName(), new Object());
|
||||
ClientToken token = null;
|
||||
Gson gson = new Gson();
|
||||
|
||||
final RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid);
|
||||
clientInformationEvent.incrementProcessingCount();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.login(uuid.toString(), client.GetPlayerName());
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
|
||||
clientInformationEvent.decreaseProcessingCount();
|
||||
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||
_clientLoginLock.remove(client.GetPlayerName());
|
||||
}
|
||||
});
|
||||
|
||||
TimingManager.start(client.GetPlayerName() + " GetClient.");
|
||||
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
|
||||
TimingManager.stop(client.GetPlayerName() + " GetClient.");
|
||||
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetAccountId(token.AccountId);
|
||||
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
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
|
||||
// Load client in miniplugins
|
||||
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
|
||||
|
||||
while (clientInformationEvent.processing())
|
||||
while (_clientLoginLock.containsKey(client.GetPlayerName()))
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(1);
|
||||
Thread.sleep(2);
|
||||
}
|
||||
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.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
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.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.account.repository.token.LoginToken;
|
||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.DatabaseRunnable;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
@ -25,10 +28,9 @@ import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.core.server.remotecall.JsonWebCall;
|
||||
|
||||
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 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 ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
|
||||
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_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
||||
@ -41,9 +43,34 @@ public class AccountRepository extends RepositoryBase
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
@ -52,12 +79,105 @@ public class AccountRepository extends RepositoryBase
|
||||
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)
|
||||
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name));
|
||||
try
|
||||
{
|
||||
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)
|
||||
|
@ -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.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
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 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");
|
||||
}
|
||||
@ -33,27 +29,21 @@ public class RankBenefitsGiver9000Repository extends RepositoryBase
|
||||
protected void update()
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
import mineplex.core.benefit.RankBenefitsGiver9000Repository;
|
||||
import mineplex.core.benefit.BenefitManagerRepository;
|
||||
import mineplex.core.common.util.Callback;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -11,9 +11,9 @@ public abstract class BenefitBase
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
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;
|
||||
_name = name;
|
||||
@ -25,7 +25,7 @@ public abstract class BenefitBase
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public RankBenefitsGiver9000Repository getRepository()
|
||||
public BenefitManagerRepository getRepository()
|
||||
{
|
||||
return _repository;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.Callback;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -14,7 +14,7 @@ public class Thanksgiving2014 extends BenefitBase
|
||||
{
|
||||
private InventoryManager _inventoryManager;
|
||||
|
||||
public Thanksgiving2014(JavaPlugin plugin, RankBenefitsGiver9000Repository repository, InventoryManager inventoryManager)
|
||||
public Thanksgiving2014(JavaPlugin plugin, BenefitManagerRepository repository, InventoryManager inventoryManager)
|
||||
{
|
||||
super(plugin, "Thanksgiving2014", repository);
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
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();
|
||||
}
|
||||
}, 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.database.column.Column;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
@ -100,7 +101,7 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
|
||||
if (callable != null)
|
||||
callable.processResultSet(preparedStatement.getGeneratedKeys());
|
||||
}
|
||||
@ -138,7 +139,7 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
|
||||
callable.processResultSet(resultSet);
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -68,7 +68,7 @@ public class DonationManager extends MiniPlugin
|
||||
synchronized (_donorLock)
|
||||
{
|
||||
_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;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class EloManager extends MiniPlugin
|
||||
public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
{
|
||||
private static Object _playerEloLock = new Object();
|
||||
|
||||
@ -18,51 +19,15 @@ public class EloManager extends MiniPlugin
|
||||
private EloRatingSystem _ratingSystem;
|
||||
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
||||
|
||||
public EloManager(JavaPlugin plugin)
|
||||
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super("Elo Rating", plugin);
|
||||
|
||||
setupConfigValues(plugin);
|
||||
|
||||
_repository = new EloRepository(plugin.getConfig().getString("elo.connectionurl"));
|
||||
super("Elo Rating", plugin, clientManager);
|
||||
|
||||
_repository = new EloRepository(plugin);
|
||||
_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>>();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
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 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(String connectionUrl)
|
||||
public EloRepository(JavaPlugin plugin)
|
||||
{
|
||||
_connectionString = connectionUrl;
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
executeUpdate(CREATE_ELO_TABLE);
|
||||
}
|
||||
|
||||
public void saveElo(String uuid, String gameType, int elo)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
int affectedRows = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_ELO);
|
||||
|
||||
preparedStatement.setString(1, uuid);
|
||||
preparedStatement.setString(2, gameType);
|
||||
preparedStatement.setInt(3, elo);
|
||||
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
System.out.println("Error saving Elo.");
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
|
||||
}
|
||||
|
||||
public NautHashMap<String, Integer> loadClientInformation(UUID uuid)
|
||||
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
NautHashMap<String, Integer> elos = new NautHashMap<String, Integer>();
|
||||
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
EloClientData clientData = new EloClientData();
|
||||
|
||||
try
|
||||
while (resultSet.next())
|
||||
{
|
||||
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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2));
|
||||
}
|
||||
|
||||
return elos;
|
||||
return clientData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -153,49 +152,8 @@ public class Energy extends MiniClientPlugin<ClientEnergy>
|
||||
Get(player).MaxEnergyMods.remove(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void setEnabled(boolean 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;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@ -11,9 +13,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
@ -31,19 +32,17 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
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 CoreClientManager _clientManager;
|
||||
private PreferencesManager _preferenceManager;
|
||||
private FriendRepository _repository;
|
||||
|
||||
public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
|
||||
{
|
||||
super("Friends", plugin);
|
||||
super("Friends", plugin, clientManager);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_preferenceManager = preferences;
|
||||
_repository = new FriendRepository(plugin);
|
||||
}
|
||||
@ -61,20 +60,6 @@ public class FriendManager extends MiniClientPlugin<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
|
||||
public void updateFriends(UpdateEvent event)
|
||||
{
|
||||
@ -262,7 +247,7 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
||||
|
||||
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;
|
||||
List<FriendStatus> friendStatuses = Get(caller).Friends;
|
||||
Collections.sort(friendStatuses, _friendSorter);
|
||||
@ -379,4 +364,16 @@ public class FriendManager extends MiniClientPlugin<FriendData>
|
||||
|
||||
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.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
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 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 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 = ?;";
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
@ -109,27 +103,21 @@ public class FriendRepository extends RepositoryBase
|
||||
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()
|
||||
while (resultSet.next())
|
||||
{
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
FriendStatus friend = new FriendStatus();
|
||||
|
||||
friend.Name = resultSet.getString(1);
|
||||
friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(2));
|
||||
friend.ServerName = resultSet.getString(3);
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(4).getTime();
|
||||
|
||||
friendData.Friends.add(friend);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuidSource", 100, uniqueId.toString()));
|
||||
FriendStatus friend = new FriendStatus();
|
||||
|
||||
friend.Name = resultSet.getString(1);
|
||||
friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(2));
|
||||
friend.ServerName = resultSet.getString(3);
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(4).getTime();
|
||||
|
||||
friendData.Friends.add(friend);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import 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;
|
||||
|
||||
/**
|
||||
* Created by shaun on 2014-09-09.
|
||||
*/
|
||||
public class Hologram
|
||||
{
|
||||
private HorseHologram _horseHologram;
|
||||
private ArmorStandHologram _armorStandHologram;
|
||||
|
||||
private Location _location;
|
||||
private String _text;
|
||||
public enum HologramTarget
|
||||
{
|
||||
BLACKLIST, WHITELIST;
|
||||
}
|
||||
|
||||
public Hologram(Location location, String text)
|
||||
{
|
||||
_location = location;
|
||||
_text = text;
|
||||
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 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;
|
||||
|
||||
_horseHologram = new HorseHologram(location, text);
|
||||
_armorStandHologram = new ArmorStandHologram(location, text);
|
||||
}
|
||||
public Hologram(HologramManager hologramManager, Location location, String... text)
|
||||
{
|
||||
_hologramManager = hologramManager;
|
||||
_location = location.clone();
|
||||
setText(text);
|
||||
}
|
||||
|
||||
public void sendToPlayer(Player player)
|
||||
{
|
||||
if (UtilPlayer.is1_8(player))
|
||||
{
|
||||
_armorStandHologram.sendToPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_horseHologram.sendToPlayer(player);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
|
||||
*/
|
||||
public Hologram addPlayer(Player player)
|
||||
{
|
||||
return addPlayer(player.getName());
|
||||
}
|
||||
|
||||
public void sendToPlayers(Player... players)
|
||||
{
|
||||
for (Player player : players)
|
||||
{
|
||||
sendToPlayer(player);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
|
||||
*/
|
||||
public Hologram addPlayer(String player)
|
||||
{
|
||||
_playersInList.add(player);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void removeForPlayer(Player player)
|
||||
{
|
||||
if (UtilPlayer.is1_8(player))
|
||||
{
|
||||
_armorStandHologram.removeForPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_horseHologram.removeForPlayer(player);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Is there a player entry in the hologram for Whitelist and Blacklist
|
||||
*/
|
||||
public boolean containsPlayer(Player player)
|
||||
{
|
||||
return _playersInList.contains(player.getName());
|
||||
}
|
||||
|
||||
public void removeForPlayers(Player... players)
|
||||
{
|
||||
for (Player player : players)
|
||||
{
|
||||
removeForPlayer(player);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
_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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Packet[] makeSpawnPackets1_7(int height, int witherId, int horseId, String horseName)
|
||||
{
|
||||
// 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[]
|
||||
{
|
||||
spawnWitherSkull, spawnHorse, attachEntity
|
||||
};
|
||||
}
|
||||
|
||||
private Packet[] makeSpawnPackets1_8(int textRow, int entityId, String lineOfText)
|
||||
{
|
||||
if (this.isUsingWitherSkull())
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
|
||||
*/
|
||||
public Hologram removePlayer(Player player)
|
||||
{
|
||||
return addPlayer(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -7,8 +9,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
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.Item;
|
||||
|
||||
public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
||||
public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
||||
{
|
||||
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, 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);
|
||||
|
||||
@ -69,6 +71,11 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -78,16 +85,15 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
if (!success)
|
||||
{
|
||||
System.out.println("Add item to Inventory FAILED for " + player.getName());
|
||||
|
||||
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)
|
||||
callback.run(success);
|
||||
@ -165,23 +171,21 @@ public class InventoryManager extends MiniClientPlugin<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
|
||||
public void AddCommands()
|
||||
{
|
||||
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 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)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
|
||||
public ClientInventory loadClientInformation(String uuid)
|
||||
public ClientInventory loadClientInformation(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
final ClientInventory clientInventory = new ClientInventory();
|
||||
|
||||
executeQuery(RETRIEVE_CLIENT_INVENTORY, new ResultSetCallable()
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
clientInventory.addItem(new ClientItem(new Item(resultSet.getString(1), resultSet.getString(2)), resultSet.getInt(3)));
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid));
|
||||
clientInventory.addItem(new ClientItem(new Item(resultSet.getString(1), resultSet.getString(2)), resultSet.getInt(3)));
|
||||
}
|
||||
|
||||
return clientInventory;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -210,9 +209,4 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mineplex.core.movement;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -45,9 +44,4 @@ public class Movement extends MiniClientPlugin<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.pet.repository.token.PetSalesToken;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
@ -1,11 +1,9 @@
|
||||
package mineplex.core.pet;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -11,14 +11,10 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
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.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
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.EntityHuman;
|
||||
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.PathfinderGoalSelector;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -46,18 +34,13 @@ import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
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.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -394,11 +377,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
{
|
||||
return _activePetOwners.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void DisableAll()
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
package mineplex.core.preferences;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,9 +13,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
@ -23,7 +23,7 @@ import mineplex.core.preferences.ui.PreferencesShop;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
||||
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
{
|
||||
private PreferencesRepository _repository;
|
||||
private PreferencesShop _shop;
|
||||
@ -34,7 +34,7 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
||||
|
||||
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super("Preferences", plugin);
|
||||
super("Preferences", plugin, clientManager);
|
||||
|
||||
setupConfigValues();
|
||||
|
||||
@ -64,20 +64,6 @@ public class PreferencesManager extends MiniClientPlugin<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)
|
||||
{
|
||||
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
|
||||
@ -134,4 +120,16 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
||||
{
|
||||
_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.SQLException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
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 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=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||
@ -61,8 +58,33 @@ public class PreferencesRepository extends RepositoryBase
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
|
||||
int[] rowsAffected = preparedStatement.executeBatch();
|
||||
int i = 0;
|
||||
|
||||
preparedStatement.executeBatch();
|
||||
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)
|
||||
{
|
||||
@ -84,34 +106,24 @@ public class PreferencesRepository extends RepositoryBase
|
||||
}
|
||||
}
|
||||
|
||||
public UserPreferences loadClientInformation(final UUID uuid)
|
||||
public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException
|
||||
{
|
||||
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.ShowPlayers = resultSet.getBoolean(2);
|
||||
preferences.ShowChat = resultSet.getBoolean(3);
|
||||
preferences.FriendChat = resultSet.getBoolean(4);
|
||||
preferences.PrivateMessaging = resultSet.getBoolean(5);
|
||||
preferences.PartyRequests = resultSet.getBoolean(6);
|
||||
preferences.Invisibility = resultSet.getBoolean(7);
|
||||
preferences.HubForcefield = resultSet.getBoolean(8);
|
||||
preferences.ShowMacReports = resultSet.getBoolean(9);
|
||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
preferences.HubGames = resultSet.getBoolean(1);
|
||||
preferences.ShowPlayers = resultSet.getBoolean(2);
|
||||
preferences.ShowChat = resultSet.getBoolean(3);
|
||||
preferences.FriendChat = resultSet.getBoolean(4);
|
||||
preferences.PrivateMessaging = resultSet.getBoolean(5);
|
||||
preferences.PartyRequests = resultSet.getBoolean(6);
|
||||
preferences.Invisibility = resultSet.getBoolean(7);
|
||||
preferences.HubForcefield = resultSet.getBoolean(8);
|
||||
preferences.ShowMacReports = resultSet.getBoolean(9);
|
||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
||||
}
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package mineplex.core.stats;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.stats.command.GiveStatCommand;
|
||||
import mineplex.core.stats.command.TimeCommand;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
|
||||
public class StatsManager extends MiniClientPlugin<PlayerStats>
|
||||
public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
{
|
||||
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 Runnable _saveRunnable;
|
||||
|
||||
public StatsManager(JavaPlugin plugin)
|
||||
public StatsManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super("StatsManager", plugin);
|
||||
super("Stats Manager", plugin, clientManager);
|
||||
|
||||
_repository = new StatsRepository(plugin);
|
||||
|
||||
@ -117,20 +117,6 @@ public class StatsManager extends MiniClientPlugin<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
|
||||
{
|
||||
return _repository.loadOfflinePlayerStats(playerName);
|
||||
@ -185,4 +171,16 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
||||
addCommand(new TimeCommand(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;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -14,17 +13,12 @@ import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.AccountStatsRecord;
|
||||
import mineplex.database.tables.records.StatsRecord;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Insert;
|
||||
import org.jooq.InsertQuery;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.Update;
|
||||
import org.jooq.UpdateQuery;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
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_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 INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||
|
||||
@ -81,10 +74,9 @@ public class StatsRepository extends RepositoryBase
|
||||
executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void saveStats(NautHashMap<String, NautHashMap<Integer, Integer>> uploadQueue)
|
||||
{
|
||||
System.out.println("saving stats.");
|
||||
|
||||
try
|
||||
{
|
||||
DSLContext context = DSL.using(getConnection());
|
||||
@ -96,8 +88,6 @@ public class StatsRepository extends RepositoryBase
|
||||
{
|
||||
for (Integer statId : uploadQueue.get(uuid).keySet())
|
||||
{
|
||||
System.out.println("saving stat : uuid=" + uuid + " " + statId + "=" + uploadQueue.get(uuid).get(statId));
|
||||
|
||||
Update update = context
|
||||
.update(Tables.accountStats)
|
||||
.set(Tables.accountStats.value, Tables.accountStats.value.plus(uploadQueue.get(uuid).get(statId)))
|
||||
@ -166,20 +156,14 @@ public class StatsRepository extends RepositoryBase
|
||||
return playerStats;
|
||||
}
|
||||
|
||||
public PlayerStats loadClientInformation(String uuid)
|
||||
public PlayerStats loadClientInformation(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
final PlayerStats playerStats = new PlayerStats();
|
||||
|
||||
executeQuery(RETRIEVE_PLAYER_STATS, new ResultSetCallable()
|
||||
while (resultSet.next())
|
||||
{
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid));
|
||||
playerStats.addStat(resultSet.getString(1), resultSet.getInt(2));
|
||||
}
|
||||
|
||||
return playerStats;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.task.repository.TaskRepository;
|
||||
import mineplex.core.task.repository.TaskToken;
|
||||
|
||||
@ -52,9 +51,4 @@ public class TaskManager extends MiniClientPlugin<TaskClient>
|
||||
|
||||
_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.util.CraftMagicNumbers;
|
||||
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.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
@ -56,15 +57,16 @@ public class Treasure
|
||||
private LinkedList<Animation> _animations;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Treasure(Player player, Random seed, Reward[] rewards)
|
||||
public Treasure(Player player, Random seed, Reward[] rewards, HologramManager hologramManager)
|
||||
{
|
||||
_player = player;
|
||||
_random = seed;
|
||||
@ -73,6 +75,7 @@ public class Treasure
|
||||
|
||||
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
_animations = new LinkedList<Animation>();
|
||||
_hologramManager = hologramManager;
|
||||
|
||||
// _animations.add(new ParticleAnimation(this));
|
||||
|
||||
@ -288,7 +291,7 @@ public class Treasure
|
||||
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
|
||||
|
||||
data.setOpened(true);
|
||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData);
|
||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager);
|
||||
_animations.add(chestOpenTask);
|
||||
|
||||
// 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.event.StackerEvent;
|
||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
@ -55,14 +56,16 @@ public class TreasureManager extends MiniPlugin
|
||||
private RewardManager _rewardManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
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);
|
||||
|
||||
_playerTreasureMap = new NautHashMap<Player, Treasure>();
|
||||
_inventoryManager = inventoryManager;
|
||||
_blockRestore = blockRestore;
|
||||
_hologramManager = hologramManager;
|
||||
_rewardManager = new RewardManager(donationManager, inventoryManager, petManager,
|
||||
250, 500,
|
||||
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"));
|
||||
|
||||
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);
|
||||
|
||||
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
|
||||
|
@ -1,5 +1,13 @@
|
||||
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.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
@ -8,64 +16,61 @@ import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
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.
|
||||
*/
|
||||
public class ChestOpenAnimation extends Animation
|
||||
{
|
||||
private ChestData _chestData;
|
||||
private RewardData _rewardData;
|
||||
private ChestData _chestData;
|
||||
private RewardData _rewardData;
|
||||
private HologramManager _hologramManager;
|
||||
|
||||
private Item _itemEntity;
|
||||
private Hologram _hologram;
|
||||
private Item _itemEntity;
|
||||
private Hologram _hologram;
|
||||
|
||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData)
|
||||
{
|
||||
super(treasure);
|
||||
_chestData = chestData;
|
||||
_rewardData = rewardData;
|
||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData, HologramManager hologramManager)
|
||||
{
|
||||
super(treasure);
|
||||
_hologramManager = hologramManager;
|
||||
_chestData = chestData;
|
||||
_rewardData = rewardData;
|
||||
|
||||
// Send chest open packet
|
||||
Block block = chestData.getBlock();
|
||||
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(), CraftMagicNumbers.getBlock(block), 1, 1);
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
||||
other.playSound(block.getLocation(), Sound.CHEST_OPEN, 1, 1);
|
||||
}
|
||||
}
|
||||
// Send chest open packet
|
||||
Block block = chestData.getBlock();
|
||||
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(),
|
||||
CraftMagicNumbers.getBlock(block), 1, 1);
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
||||
other.playSound(block.getLocation(), Sound.CHEST_OPEN, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if (getTicks() == 5)
|
||||
{
|
||||
Location location = _chestData.getBlock().getLocation().add(0.5, 0.8, 0.5);
|
||||
_itemEntity = location.getWorld().dropItem(location, _rewardData.getDisplayItem());
|
||||
_itemEntity.setVelocity(new Vector(0, 0, 0));
|
||||
_itemEntity.setPickupDelay(Integer.MAX_VALUE);
|
||||
}
|
||||
else if (getTicks() == 15)
|
||||
{
|
||||
_hologram = new Hologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _rewardData.getFriendlyName());
|
||||
_hologram.sendToPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if (getTicks() == 5)
|
||||
{
|
||||
Location location = _chestData.getBlock().getLocation().add(0.5, 0.8, 0.5);
|
||||
_itemEntity = location.getWorld().dropItem(location, _rewardData.getDisplayItem());
|
||||
_itemEntity.setVelocity(new Vector(0, 0, 0));
|
||||
_itemEntity.setPickupDelay(Integer.MAX_VALUE);
|
||||
}
|
||||
else if (getTicks() == 15)
|
||||
{
|
||||
_hologram = new Hologram(_hologramManager, _chestData.getBlock().getLocation().add(0.5, 1.1, 0.5),
|
||||
_rewardData.getFriendlyName());
|
||||
_hologram.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void onFinish()
|
||||
{
|
||||
if (_hologram != null)
|
||||
{
|
||||
_hologram.removeForPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
||||
_itemEntity.remove();
|
||||
}
|
||||
}
|
||||
public void onFinish()
|
||||
{
|
||||
if (_hologram != null)
|
||||
{
|
||||
_hologram.stop();
|
||||
_itemEntity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -126,9 +127,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
||||
@EventHandler
|
||||
public void Update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
Power();
|
||||
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
CGame().UpdateSafe();
|
||||
|
||||
@ -184,7 +182,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
|
||||
{
|
||||
ClansClan clan = Clans().CUtil().getOwner(event.GetLocation());
|
||||
ClansClan clan = _clanUtility.getOwner(event.GetLocation());
|
||||
|
||||
if (clan != null)
|
||||
if (!clan.IsAdmin() && !clan.GetName().equals("Spawn"))
|
||||
@ -263,18 +261,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
||||
|
||||
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
|
||||
{
|
||||
CoreClient client = Clients().Get(event.getPlayer());
|
||||
ClientClan client = Get(event.getPlayer());
|
||||
|
||||
if (client == null)
|
||||
return false;
|
||||
|
||||
if (!client.Clan().IsClanChat())
|
||||
if (!client.isClanChat())
|
||||
return false;
|
||||
|
||||
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
|
||||
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||
if (clan == null)
|
||||
{
|
||||
Clients().Get(event.getPlayer()).Clan().SetClanChat(false);
|
||||
Get(event.getPlayer()).setClanChat(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -287,10 +285,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
||||
if (!Get(event.getPlayer()).isAllyChat())
|
||||
return false;
|
||||
|
||||
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
|
||||
ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer());
|
||||
if (clan == null)
|
||||
{
|
||||
Clients().Get(event.getPlayer()).Clan().SetAllyChat(false);
|
||||
Get(event.getPlayer()).setAllyChat(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -331,59 +329,38 @@ public class ClansManager extends MiniClientPlugin<ClientClan>
|
||||
return _reclaimTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanHurt(Player a, Player b)
|
||||
public boolean canHurt(Player a, Player b)
|
||||
{
|
||||
if (a.equals(b))
|
||||
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))
|
||||
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() {
|
||||
return _repository;
|
||||
}
|
||||
|
||||
public void SetRepository(IRepository _repository) {
|
||||
this._repository = _repository;
|
||||
}
|
||||
|
||||
public HashMap<String, ClansClan> GetClanMemberMap()
|
||||
public ClanRelation getRelation(String playerA, String playerB)
|
||||
{
|
||||
return _clanMemberMap;
|
||||
}
|
||||
|
||||
public ClanRelation GetRelation(String playerA, String playerB)
|
||||
{
|
||||
return Clients().Get(playerA).Clan().GetRelation(playerB);
|
||||
return Get(playerA).getRelation(playerB);
|
||||
}
|
||||
|
||||
@Override
|
||||
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()
|
||||
{
|
||||
return _onlineTime;
|
||||
|
@ -16,6 +16,7 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.friend.FriendManager;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
@ -99,11 +100,11 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||
StatsManager statsManager = new StatsManager(this);
|
||||
StatsManager statsManager = new StatsManager(this, clientManager);
|
||||
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 Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
||||
|
@ -42,9 +42,8 @@ import org.bukkit.scoreboard.Scoreboard;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.benefit.RankBenefitsGiver9000;
|
||||
import mineplex.core.benefit.BenefitManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -65,6 +64,7 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.mount.MountManager;
|
||||
@ -144,7 +144,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
//Admin
|
||||
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);
|
||||
|
||||
@ -172,10 +172,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_news = new NewsManager(this);
|
||||
|
||||
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
|
||||
_inventoryManager = new InventoryManager(plugin);
|
||||
new RankBenefitsGiver9000(plugin, clientManager, _inventoryManager);
|
||||
_inventoryManager = new InventoryManager(plugin, clientManager);
|
||||
new BenefitManager(plugin, clientManager, _inventoryManager);
|
||||
_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);
|
||||
|
||||
_partyManager = partyManager;
|
||||
@ -962,12 +962,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
return _news;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
|
@ -13,6 +13,8 @@ public class PlayerPollData
|
||||
private NautHashMap<Integer, Integer> _pollAnswers;
|
||||
private long _nextPollTime;
|
||||
|
||||
public boolean Loaded;
|
||||
|
||||
public PlayerPollData()
|
||||
{
|
||||
_pollAnswers = new NautHashMap<Integer, Integer>();
|
||||
@ -40,7 +42,7 @@ public class PlayerPollData
|
||||
|
||||
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 mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -24,9 +23,6 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.poll.command.PollCommand;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/16/2014.
|
||||
*/
|
||||
public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||
{
|
||||
private PollRepository _repository;
|
||||
@ -57,17 +53,14 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
|
||||
return new PlayerPollData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(final RetrieveClientInformationEvent event)
|
||||
public void loadClientInformation(final PlayerJoinEvent event)
|
||||
{
|
||||
event.incrementProcessingCount();
|
||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Set(event.getPlayerName(), _repository.loadPollData(event.getUniqueId()));
|
||||
event.decreaseProcessingCount();
|
||||
Set(event.getPlayer().getName(), _repository.loadPollData(event.getPlayer().getUniqueId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ public class PollRepository extends RepositoryBase
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
|
||||
pollData.Loaded = true;
|
||||
|
||||
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.Skill.ISkill;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType;
|
||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -309,9 +307,4 @@ public class ClassManager extends MiniClientPlugin<ClientClass> implements IClas
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class Illusion extends SkillActive
|
||||
"Invisibility ends if you release Block",
|
||||
"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",
|
||||
"to nearby players upon ending."
|
||||
@ -79,7 +79,7 @@ public class Illusion extends SkillActive
|
||||
@Override
|
||||
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
|
||||
@ -130,7 +130,7 @@ public class Illusion extends SkillActive
|
||||
Factory.Disguise().disguise(disguise, disguiseList);
|
||||
|
||||
//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);
|
||||
|
||||
@ -153,7 +153,7 @@ public class Illusion extends SkillActive
|
||||
|
||||
if (Factory.Condition().GetActiveCondition(cur, ConditionType.CLOAK) == null ||
|
||||
!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.isValid())
|
||||
{
|
||||
|
@ -80,8 +80,8 @@ public class SeismicSlam extends SkillActive
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"Jump up and slam back into the ground.",
|
||||
"Players within #6#0.5 Blocks take up to",
|
||||
"#2#1 damage and are thrown into the air.",
|
||||
"Players within #5.5#0.5 Blocks take up to",
|
||||
"#1#1 damage and are thrown into the air.",
|
||||
});
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class SeismicSlam extends SkillActive
|
||||
_live.remove(player);
|
||||
|
||||
//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())
|
||||
{
|
||||
if (cur.equals(player))
|
||||
@ -145,13 +145,13 @@ public class SeismicSlam extends SkillActive
|
||||
|
||||
//Damage Event
|
||||
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());
|
||||
|
||||
//Velocity
|
||||
UtilAction.velocity(cur,
|
||||
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
|
||||
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 mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
@ -156,7 +155,6 @@ public class AxeThrow extends SkillActive implements IThrown
|
||||
|
||||
Player player = _thrown.remove(event.getItem());
|
||||
|
||||
AntiStack.removeUID(event.getItem());
|
||||
player.getInventory().addItem(event.getItem().getItemStack());
|
||||
|
||||
UtilInv.Update(event.getPlayer());
|
||||
@ -190,7 +188,6 @@ public class AxeThrow extends SkillActive implements IThrown
|
||||
|
||||
if (item.getTicksLived() > 400 - level * 40)
|
||||
{
|
||||
AntiStack.removeUID(item);
|
||||
_thrown.get(item).getInventory().addItem(item.getItemStack());
|
||||
item.remove();
|
||||
itemIterator.remove();
|
||||
|
@ -55,10 +55,10 @@ public class ExplosiveShot extends SkillActive
|
||||
{
|
||||
"Prepare an explosive shot;",
|
||||
"Your next arrow will explode on",
|
||||
"impact, dealing up to 12 damage",
|
||||
"impact, dealing up to 10 damage",
|
||||
"and knockback. ",
|
||||
" ",
|
||||
"Explosion radius of #5#1",
|
||||
"Explosion radius of #4.5#0.5",
|
||||
});
|
||||
|
||||
setAchievementSkill(true);
|
||||
@ -210,7 +210,7 @@ public class ExplosiveShot extends SkillActive
|
||||
return;
|
||||
|
||||
//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())
|
||||
{
|
||||
double range = hitMap.get(cur);
|
||||
@ -220,7 +220,7 @@ public class ExplosiveShot extends SkillActive
|
||||
|
||||
//Damage Event
|
||||
Factory.Damage().NewDamageEvent(cur, player, null,
|
||||
DamageCause.CUSTOM, 2 + 10 * range, false, true, false,
|
||||
DamageCause.CUSTOM, 10 * range, false, true, false,
|
||||
player.getName(), GetName());
|
||||
|
||||
//Velocity
|
||||
|
@ -170,8 +170,8 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
|
||||
AddSkill(new Illusion(this, "Illusion", ClassType.Assassin, SkillType.Sword,
|
||||
1, 4,
|
||||
40, -3,
|
||||
40000, -3000, true,
|
||||
50, -4,
|
||||
20000, -1000, true,
|
||||
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||
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,
|
||||
1, 5,
|
||||
0, 0,
|
||||
30000, -3000, true,
|
||||
30000, -2000, true,
|
||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||
|
||||
|
@ -44,6 +44,7 @@ public class ServerCommandManager
|
||||
*/
|
||||
private void initialize()
|
||||
{
|
||||
/* CAUSING STUTTER LAG IN HUBS
|
||||
final Jedis jedis = _jedisPool.getResource();
|
||||
|
||||
// Spin up a new thread and subscribe to the Redis pubsub network
|
||||
@ -67,30 +68,37 @@ public class ServerCommandManager
|
||||
});
|
||||
|
||||
thread.start();
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a {@link ServerCommand} across the network to all live servers.
|
||||
* @param serverCommand - the {@link ServerCommand} to issue to all servers.
|
||||
*/
|
||||
public void publishCommand(ServerCommand serverCommand)
|
||||
public void publishCommand(final ServerCommand serverCommand)
|
||||
{
|
||||
Jedis jedis = _jedisPool.getResource();
|
||||
|
||||
try
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
String commandType = serverCommand.getClass().getSimpleName();
|
||||
String serializedCommand = Utility.serialize(serverCommand);
|
||||
jedis.publish(SERVER_COMMANDS_CHANNEL + ":" + commandType, serializedCommand);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_jedisPool.returnResource(jedis);
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
Jedis jedis = _jedisPool.getResource();
|
||||
|
||||
try
|
||||
{
|
||||
String commandType = serverCommand.getClass().getSimpleName();
|
||||
String serializedCommand = Utility.serialize(serverCommand);
|
||||
jedis.publish(SERVER_COMMANDS_CHANNEL + ":" + commandType, serializedCommand);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_jedisPool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ public class StaffServer extends JavaPlugin
|
||||
new MemoryFix(this);
|
||||
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());
|
||||
|
||||
//Updates
|
||||
|
@ -20,6 +20,7 @@ import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.friend.FriendManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
@ -107,9 +108,10 @@ public class Arcade extends JavaPlugin
|
||||
BlockRestore blockRestore = new BlockRestore(this);
|
||||
|
||||
ProjectileManager projectileManager = new ProjectileManager(this);
|
||||
HologramManager hologramManager = new HologramManager(this);
|
||||
|
||||
//Inventory
|
||||
InventoryManager inventoryManager = new InventoryManager(this);
|
||||
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
|
||||
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
||||
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
||||
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);
|
||||
|
||||
//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 CustomTagFix(this, packetHandler);
|
||||
|
@ -54,6 +54,7 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.explosion.Explosion;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.movement.Movement;
|
||||
@ -145,7 +146,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private InventoryManager _inventoryManager;
|
||||
private CosmeticManager _cosmeticManager;
|
||||
private final IdleManager _idleManager;
|
||||
|
||||
private HologramManager _hologramManager;
|
||||
private AchievementManager _achievementManager;
|
||||
private StatsManager _statsManager;
|
||||
private ClassManager _classManager;
|
||||
@ -174,7 +175,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood,
|
||||
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);
|
||||
|
||||
@ -218,7 +219,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
_packetHandler = packetHandler;
|
||||
|
||||
_statsManager = new StatsManager(plugin);
|
||||
_statsManager = new StatsManager(plugin, clientManager);
|
||||
_taskManager = new TaskManager(plugin, webAddress);
|
||||
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
||||
_inventoryManager = inventoryManager;
|
||||
@ -247,6 +248,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
new GameSpectatorManager(this);
|
||||
_gameWorldManager = new GameWorldManager(this);
|
||||
new MiscManager(this);
|
||||
_hologramManager = hologramManager;
|
||||
_idleManager = new IdleManager(this);
|
||||
//new HalloweenManager(this);
|
||||
|
||||
@ -272,7 +274,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, itemFactory, _achievementManager, clientManager);
|
||||
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, webAddress);
|
||||
|
||||
_eloManager = new EloManager(_plugin);
|
||||
_eloManager = new EloManager(_plugin, clientManager);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,6 +345,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return _disguiseManager;
|
||||
}
|
||||
|
||||
public HologramManager getHologramManager()
|
||||
{
|
||||
return _hologramManager;
|
||||
}
|
||||
|
||||
public DamageManager GetDamage()
|
||||
{
|
||||
|
@ -230,11 +230,11 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean SoupEnabled = true;
|
||||
public boolean TeamArmor = false;
|
||||
public boolean TeamArmorHotbar = false;
|
||||
public boolean TeamArmorHotbar = false;
|
||||
|
||||
public boolean GiveClock = true;
|
||||
public boolean GiveClock = true;
|
||||
|
||||
public boolean AllowParticles = true;
|
||||
public boolean AllowParticles = true;
|
||||
|
||||
public double GemMultiplier = 1;
|
||||
public boolean GemHunterEnabled = true;
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
@ -521,7 +521,7 @@ public class HideSeek extends TeamGame
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
|
@ -78,6 +78,8 @@ public class Quiver extends SoloGame
|
||||
this.BlockBreakAllow.add(102);
|
||||
this.BlockBreakAllow.add(20);
|
||||
|
||||
this.DeathSpectateSecs = 4;
|
||||
|
||||
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Kills", "dummy");
|
||||
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
|
||||
|
@ -151,6 +151,8 @@ public class SheepGame extends TeamGame
|
||||
|
||||
this.TeamArmor = true;
|
||||
this.TeamArmorHotbar = true;
|
||||
|
||||
this.DeathSpectateSecs = 4;
|
||||
|
||||
registerStatTrackers(
|
||||
new SheepThiefStatTracker(this),
|
||||
|
@ -87,8 +87,10 @@ public class SuperSmash extends SoloGame
|
||||
|
||||
this.CompassEnabled = true;
|
||||
|
||||
this.DeathSpectateSecs = 6;
|
||||
|
||||
this.SpawnDistanceRequirement = 16;
|
||||
|
||||
|
||||
// Add stat table here
|
||||
// Example
|
||||
//Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses");
|
||||
@ -374,16 +376,15 @@ public class SuperSmash extends SoloGame
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void HungerRestore(CustomDamageEvent event)
|
||||
{
|
||||
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
if (event.GetDamagerPlayer(true) == null)
|
||||
return;
|
||||
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
if (damager == null)
|
||||
return;
|
||||
|
||||
if (damager.equals(event.GetDamageeEntity()))
|
||||
return;
|
||||
|
||||
if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false))
|
||||
return;
|
||||
|
@ -134,6 +134,7 @@ public class TurfForts extends TeamGame
|
||||
this.ItemDrop = false;
|
||||
this.ItemPickup = false;
|
||||
this.DamageSelf = false;
|
||||
this.DeathSpectateSecs = 4;
|
||||
|
||||
registerStatTrackers(
|
||||
new BlockShreadStatTracker(this),
|
||||
|
@ -129,7 +129,7 @@ public class MiscManager implements Listener
|
||||
@EventHandler
|
||||
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");
|
||||
event.setCancelled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user