Added temporary fix for TBMCPlugins/ButtonChat#56
This commit is contained in:
parent
b4d4023e9c
commit
ed4cb11b87
1 changed files with 9 additions and 2 deletions
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -30,7 +31,7 @@ import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
public class TBMCPlayer implements AutoCloseable {
|
public class TBMCPlayer implements AutoCloseable {
|
||||||
private static final String TBMC_PLAYERS_DIR = "TBMC/players";
|
private static final String TBMC_PLAYERS_DIR = "TBMC/players";
|
||||||
|
|
||||||
private HashMap<String, Object> data = new HashMap<>();
|
private ConcurrentHashMap<String, Object> data = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -254,6 +255,8 @@ public class TBMCPlayer implements AutoCloseable {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ConcurrentHashMap<Class<? extends TBMCPlayer>, TBMCPlayer> playermap = new ConcurrentHashMap<>(); // TODO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the TBMCPlayer object as a specific plugin player, keeping it's data *
|
* Gets the TBMCPlayer object as a specific plugin player, keeping it's data *
|
||||||
*
|
*
|
||||||
|
@ -262,12 +265,16 @@ public class TBMCPlayer implements AutoCloseable {
|
||||||
* @param cl
|
* @param cl
|
||||||
* The TBMCPlayer subclass
|
* The TBMCPlayer subclass
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends TBMCPlayer> T asPluginPlayer(Class<T> cl) {
|
public <T extends TBMCPlayer> T asPluginPlayer(Class<T> cl) {
|
||||||
T obj = null;
|
T obj = null;
|
||||||
|
if (playermap.containsKey(cl))
|
||||||
|
return (T) playermap.get(cl);
|
||||||
try {
|
try {
|
||||||
obj = cl.newInstance();
|
obj = cl.newInstance();
|
||||||
((TBMCPlayer) obj).uuid = uuid;
|
((TBMCPlayer) obj).uuid = uuid;
|
||||||
((TBMCPlayer) obj).data.putAll(data);
|
// ((TBMCPlayer) obj).data.putAll(data);
|
||||||
|
playermap.put(cl, obj);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue