Custom data, waiting for JLO
This commit is contained in:
parent
63635e7cf8
commit
baf0f254bb
@ -18,6 +18,7 @@ import mineplex.core.account.command.UpdateRank;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.account.repository.AccountRepository;
|
||||
import mineplex.core.account.repository.CustomPlayerDataRepository;
|
||||
import mineplex.core.account.repository.token.ClientToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
@ -35,7 +36,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -57,6 +57,8 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
||||
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
||||
|
||||
private CustomPlayerDataRepository _customDataRepository;
|
||||
|
||||
public CoreClientManager(JavaPlugin plugin, String webServer)
|
||||
{
|
||||
@ -66,6 +68,8 @@ public class CoreClientManager extends MiniPlugin
|
||||
_repository = new AccountRepository(plugin, webServer);
|
||||
_clientList = new NautHashMap<String, CoreClient>();
|
||||
_duplicateLoginGlitchPreventionList = new HashSet<String>();
|
||||
|
||||
_customDataRepository = new CustomPlayerDataRepository(plugin);
|
||||
}
|
||||
|
||||
public AccountRepository getRepository()
|
||||
@ -580,4 +584,12 @@ public class CoreClientManager extends MiniPlugin
|
||||
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
return playerInfo == null ? -1 : playerInfo.getAccountId();
|
||||
}
|
||||
|
||||
public void addCustomData(Player player, String key, Object data)
|
||||
{
|
||||
if (data == null || player == null || key == null)
|
||||
return;
|
||||
|
||||
_customDataRepository
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class CustomPlayerData
|
||||
{
|
||||
private int _id;
|
||||
private String _key;
|
||||
|
||||
public CustomPlayerData(int id, String key)
|
||||
{
|
||||
_id = id;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package mineplex.core.account.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CustomPlayerData;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class CustomPlayerDataRepository extends RepositoryBase
|
||||
{
|
||||
private static final String RETRIEVE_KEYS = "SELECT id, key FROM customDataKeys;";
|
||||
private static final String INSERT_KEY = "INSERT INTO customDataKeys (key) VALUES (?);";
|
||||
|
||||
private ArrayList<CustomPlayerData> _playerDataTypes;
|
||||
|
||||
public CustomPlayerDataRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
_playerDataTypes = new ArrayList<>();
|
||||
|
||||
executeQuery(RETRIEVE_KEYS, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
_playerDataTypes.add(new CustomPlayerData(resultSet.getInt("id"), resultSet.getString("key")));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update() {}
|
||||
|
||||
public void addKey(String key)
|
||||
{
|
||||
//TODO: add the key with auto-increment ID
|
||||
//executeUpdate(INSERT_KEY, new ColumnVarChar(""))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user