Remade user data managing, added a test #30
4 changed files with 7 additions and 22 deletions
|
@ -1,11 +1,9 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
|
|
@ -6,24 +6,17 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
/*@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void OnPlayerJoin(PlayerJoinEvent event) {
|
||||
TBMCPlayer player = TBMCPlayer.loadPlayer(event.getPlayer());
|
||||
if (player == null) {
|
||||
TBMCCoreAPI.SendException("Error on player join!", new Exception("Player is null"));
|
||||
event.getPlayer().sendMessage("§c[TBMC] Failed to load player data! The error has been sent to the devs.");
|
||||
} else
|
||||
TBMCPlayer.joinPlayer(player);
|
||||
TBMCPlayerBase.joinPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void OnPlayerLeave(PlayerQuitEvent event) {
|
||||
TBMCPlayer player = TBMCPlayer.getPlayer(event.getPlayer());
|
||||
TBMCPlayer.savePlayer(player);
|
||||
TBMCPlayer.quitPlayer(player);
|
||||
}*/
|
||||
TBMCPlayerBase.quitPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public abstract class ChromaGamerBase implements AutoCloseable {
|
|||
try {
|
||||
T obj = cl.newInstance();
|
||||
final File file = new File(TBMC_PLAYERS_DIR + getFolderForType(cl), fname + ".yml");
|
||||
file.mkdirs();
|
||||
file.getParentFile().mkdirs();
|
||||
obj.plugindata = YamlConfiguration.loadConfiguration(file);
|
||||
return obj;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -38,13 +38,6 @@ public abstract class TBMCPlayerBase extends ChromaGamerBase {
|
|||
return getUUID().toString();
|
||||
}
|
||||
|
||||
// protected ConfigurationSection plugindata;
|
||||
|
||||
/*
|
||||
* public static void load() { super.load(); plugindata = super.plugindata.getConfigurationSection(getPluginName()); if (plugindata == null) plugindata =
|
||||
* super.plugindata.createSection(getPluginName()); } protected void save() { plugindata = super.plugindata.createSection(getPluginName(), plugindata.getValues(true)); super.save(); }
|
||||
*/
|
||||
|
||||
static {
|
||||
addPlayerType(TBMCPlayerBase.class, FOLDER_NAME);
|
||||
}
|
||||
|
@ -137,6 +130,7 @@ public abstract class TBMCPlayerBase extends ChromaGamerBase {
|
|||
player.setPlayerName(p.getName());
|
||||
Bukkit.getLogger().info("Renaming done.");
|
||||
}
|
||||
playermap.put(p.getUniqueId() + "-" + TBMCPlayer.class.getSimpleName(), player);
|
||||
|
||||
// Load in other plugins
|
||||
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerLoadEvent(player));
|
||||
|
|
Loading…
Reference in a new issue