A few important fixes

This commit is contained in:
Norbi Peti 2017-01-28 23:53:08 +01:00
parent 159cef01ff
commit ef42d811b0
4 changed files with 7 additions and 22 deletions

View file

@ -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;

View file

@ -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());
}
}

View file

@ -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) {

View file

@ -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));