diff --git a/src/com/dre/managerxl/Broadcast.java b/src/com/dre/managerxl/Broadcast.java index 85e6432..d57c262 100644 --- a/src/com/dre/managerxl/Broadcast.java +++ b/src/com/dre/managerxl/Broadcast.java @@ -12,7 +12,6 @@ import org.bukkit.entity.Player; import com.dre.managerxl.broadcaster.BroadcastMsg; -import com.dre.managerxl.broadcaster.player.BroadcastPlayer; import com.dre.managerxl.broadcaster.player.BroadcastPlayerMsg; public class Broadcast { @@ -116,7 +115,7 @@ private void deleteOldMessages() { } private void deleteOldPlayerData() { - for(BroadcastPlayer bPlayer : BroadcastPlayer.list){ + for(MPlayer bPlayer : MPlayer.get()){ for (Iterator> it = bPlayer.playerMsgs.entrySet().iterator(); it.hasNext();) { Map.Entry entry = it.next(); if (entry.getValue().getBroadcastMsg() == null) { @@ -130,7 +129,7 @@ private void deleteOldPlayerData() { public static void broadcastMsg(Player player, BroadcastMsg msg){ - BroadcastPlayer bPlayer = BroadcastPlayer.getBroadcastPlayer(player.getName()); + MPlayer bPlayer = MPlayer.getOrCreate(player.getName()); BroadcastPlayerMsg bMsg = bPlayer.getBMsg(msg.getId()); bMsg.setSendCount(bMsg.getSendCount()+1); @@ -153,7 +152,7 @@ public static void broadcastMsg(Player player, BroadcastMsg msg){ } public static long getNextSendTime(Player player, BroadcastMsg msg){ - BroadcastPlayer bPlayer = BroadcastPlayer.getBroadcastPlayer(player.getName()); + MPlayer bPlayer = MPlayer.getOrCreate(player.getName()); BroadcastPlayerMsg bMsg = bPlayer.getBMsg(msg.getId()); long lastSend = bMsg.getLastSend(); int playerLevel = bMsg.getPlayerLevel(); @@ -207,7 +206,7 @@ public void saveMessages(){ public void saveData(){ FileConfiguration file = new YamlConfiguration(); - for(BroadcastPlayer bPlayer: BroadcastPlayer.list){ + for(MPlayer bPlayer: MPlayer.get()){ for(Integer id: bPlayer.playerMsgs.keySet()){ BroadcastPlayerMsg bpMsg = bPlayer.playerMsgs.get(id); file.set(bPlayer.getPlayer()+"."+id+".playerLevel", bpMsg.getPlayerLevel()); @@ -240,13 +239,13 @@ public void loadMessages(){ public void loadData(){ FileConfiguration file = YamlConfiguration.loadConfiguration(broadcastDataFile); - BroadcastPlayer bPlayer; + MPlayer bPlayer; int playerLevel; int sendCount; long lastSend; for(String name: file.getKeys(false)){ - bPlayer = BroadcastPlayer.getBroadcastPlayer(name); + bPlayer = MPlayer.getOrCreate(name); ConfigurationSection section = file.getConfigurationSection(name); for(String id: section.getKeys(false)){ playerLevel = file.getInt(name+"."+id+".playerLevel"); diff --git a/src/com/dre/managerxl/MPlayer.java b/src/com/dre/managerxl/MPlayer.java index 84d055e..0e37103 100644 --- a/src/com/dre/managerxl/MPlayer.java +++ b/src/com/dre/managerxl/MPlayer.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; @@ -12,6 +13,8 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import com.dre.managerxl.broadcaster.player.BroadcastPlayerMsg; + public class MPlayer { private static Set mPlayers = new HashSet(); @@ -25,6 +28,20 @@ public class MPlayer { private Location home; private int gameMode = 0; private long lastTeleport; + + /* BroadcasterPlayer */ + public HashMap playerMsgs = new HashMap(); + + public BroadcastPlayerMsg getBMsg(int id) { + BroadcastPlayerMsg msg = playerMsgs.get(id); + + if(msg == null){ + msg = new BroadcastPlayerMsg(id, this); + } + + return msg; + } + public MPlayer(String name) { mPlayers.add(this); diff --git a/src/com/dre/managerxl/broadcaster/player/BroadcastPlayer.java b/src/com/dre/managerxl/broadcaster/player/BroadcastPlayer.java index 8e4ea68..ea8d42b 100644 --- a/src/com/dre/managerxl/broadcaster/player/BroadcastPlayer.java +++ b/src/com/dre/managerxl/broadcaster/player/BroadcastPlayer.java @@ -1,4 +1,4 @@ -package com.dre.managerxl.broadcaster.player; +/*package com.dre.managerxl.broadcaster.player; import java.util.ArrayList; import java.util.HashMap; @@ -44,3 +44,4 @@ public BroadcastPlayerMsg getBMsg(int id) { } } +*/ \ No newline at end of file diff --git a/src/com/dre/managerxl/broadcaster/player/BroadcastPlayerMsg.java b/src/com/dre/managerxl/broadcaster/player/BroadcastPlayerMsg.java index 65bc18d..33c38bb 100644 --- a/src/com/dre/managerxl/broadcaster/player/BroadcastPlayerMsg.java +++ b/src/com/dre/managerxl/broadcaster/player/BroadcastPlayerMsg.java @@ -1,12 +1,13 @@ package com.dre.managerxl.broadcaster.player; +import com.dre.managerxl.MPlayer; import com.dre.managerxl.broadcaster.BroadcastMsg; public class BroadcastPlayerMsg { BroadcastMsg msg; - BroadcastPlayer bPlayer; + MPlayer bPlayer; private int playerLevel; @@ -14,7 +15,7 @@ public class BroadcastPlayerMsg { private long lastSend; - public BroadcastPlayerMsg(int id,BroadcastPlayer bPlayer, int playerLevel, int sendCount, long lastSend){ + public BroadcastPlayerMsg(int id,MPlayer bPlayer, int playerLevel, int sendCount, long lastSend){ this.msg = BroadcastMsg.messages.get(id); this.playerLevel = playerLevel; this.lastSend = lastSend; @@ -23,7 +24,7 @@ public BroadcastPlayerMsg(int id,BroadcastPlayer bPlayer, int playerLevel, int s bPlayer.playerMsgs.put(id, this); } - public BroadcastPlayerMsg(int id,BroadcastPlayer bPlayer){ + public BroadcastPlayerMsg(int id,MPlayer bPlayer){ this(id, bPlayer, 1, 0, 0L); }