Started moving player data from the chat plugin

This commit is contained in:
Norbi Peti 2016-07-01 23:42:26 +02:00
parent e0aab55338
commit 7195ed1338
4 changed files with 92 additions and 8 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="C:/Users/Elmar-Laptop/Personal/Hobbies/The Button Rebirth/Button Plugin/Minecraft Test Server/craftbukkit-1.9.2.jar"/>
<classpathentry kind="lib" path="C:/Users/Elmar-Laptop/Personal/Hobbies/The Button Rebirth/Button Plugin/Minecraft Test Server/spigot-1.9.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server (build)/craftbukkit-1.9.2.jar"/>
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server (build)/spigot-1.9.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
bin/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/buttondevteam/

View file

@ -0,0 +1,61 @@
package buttondevteam.player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class TBMCPlayer {
public String PlayerName;
public UUID UUID;
public static HashMap<UUID, TBMCPlayer> AllPlayers = new HashMap<>();
public static TBMCPlayer AddPlayerIfNeeded(UUID uuid) {
if (!AllPlayers.containsKey(uuid)) {
TBMCPlayer player = new TBMCPlayer();
player.UUID = uuid;
Player p = Bukkit.getPlayer(uuid);
if (p != null)
player.PlayerName = p.getName();
AllPlayers.put(uuid, player);
return player;
}
return AllPlayers.get(uuid);
}
public static void Load(YamlConfiguration yc) {
ConfigurationSection cs = yc.getConfigurationSection("players");
for (String key : cs.getKeys(false)) {
ConfigurationSection cs2 = cs.getConfigurationSection(key);
TBMCPlayer mp = AddPlayerIfNeeded(java.util.UUID
.fromString(cs2.getString("uuid")));
}
}
public static void Save(YamlConfiguration yc) {
ConfigurationSection cs = yc.createSection("players");
for (TBMCPlayer mp : TBMCPlayer.AllPlayers.values()) {
ConfigurationSection cs2 = cs.createSection(mp.UUID.toString());
}
}
public static TBMCPlayer GetFromName(String name) {
Player p = Bukkit.getPlayer(name);
if (p != null)
return AllPlayers.get(p.getUniqueId());
else
return null;
}
public static TBMCPlayer GetFromPlayer(Player p) {
return TBMCPlayer.AllPlayers.get(p.getUniqueId());
}
}

View file

@ -0,0 +1,22 @@
package buttondevteam.player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class TBMCPlayerAddEvent extends Event {
private static final HandlerList handlers = new HandlerList();
public TBMCPlayerAddEvent(TBMCPlayer tbmcplayer) {
// TODO: Separate player configs, figure out how to make one TBMCPlayer
// object have all the other plugin properties
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}