2
0
lennartVH01 9 жил өмнө
parent
commit
529899ab4d

+ 1 - 1
plugin.yml

@@ -10,7 +10,7 @@ commands:
     permission: AbbaCaving.player
     permission-message: You don't have permission to use this command!
   abbaadmin:
-    aliases: [aba, abbaa]
+    aliases: [aa, abbaa]
     description: Abba Admin Command
     permission: AbbaCaving.admin
     permission-message: You don't have permission to use this command!

+ 1 - 1
src/me/lennartVH01/AbbaAdminCommand.java

@@ -192,7 +192,7 @@ public class AbbaAdminCommand implements CommandExecutor, TabCompleter{
 			}
 			if(abaGame.getState() == AbbaGame.GameState.FINISHED){
 				abaGame.calcScores();
-				
+				return true;
 			}else{
 				sender.sendMessage("§cGame not finished yet!");
 				return false;

+ 2 - 4
src/me/lennartVH01/AbbaGame.java

@@ -425,10 +425,10 @@ public class AbbaGame implements ConfigurationSerializable{
 		
 		List<String> playerChestList = new ArrayList<String>();
 		for(AbbaChest aChest:chestList.getOccupiedChests()){
-			playerChestList.add(String.format("%d;%d;%d;%s", aChest.getChest().getX(), aChest.getChest().getY(), aChest.getChest().getZ(), aChest.getOwnerId().toString()));
+			playerChestList.add(String.format("%d;%d;%d;%s", aChest.getSign().getX(), aChest.getSign().getY(), aChest.getSign().getZ(), aChest.getOwnerId().toString()));
 		}
 		for(AbbaChest aChest:chestList.getFreeChests()){
-			playerChestList.add(String.format("%d;%d;%d", aChest.getChest().getX(), aChest.getChest().getY(), aChest.getChest().getZ()));
+			playerChestList.add(String.format("%d;%d;%d", aChest.getSign().getX(), aChest.getSign().getY(), aChest.getSign().getZ()));
 		}
 		abbaMap.put("Chests", playerChestList);
 		//TODO SERIALIZE PLAYERS
@@ -443,8 +443,6 @@ public class AbbaGame implements ConfigurationSerializable{
 		AbbaGame game = new AbbaGame((String) inputMap.get("Name"), (Location) inputMap.get("Spawn"), (int) inputMap.get("Duration"), (int) inputMap.get("PlayerCap"));
 		
 		game.setOpen((boolean) inputMap.get("Open"));
-		game.setDuration((int) inputMap.get("Duration"));
-		game.setPlayerCap((int) inputMap.get("PlayerCap"));
 		
 		for(String input:(List<String>) inputMap.get("Chests")){
 			String[] args = input.split(";");

+ 24 - 4
src/me/lennartVH01/AbbaTools.java

@@ -9,6 +9,8 @@ import java.util.UUID;
 import me.lennartVH01.AbbaGame.JoinResult;
 
 import org.bukkit.Location;
+import org.bukkit.block.Chest;
+import org.bukkit.block.Sign;
 import org.bukkit.configuration.file.FileConfiguration;
 import org.bukkit.entity.Player;
 import org.bukkit.event.block.BlockBreakEvent;
@@ -19,6 +21,7 @@ import org.bukkit.inventory.ItemStack;
 
 
 
+
 public class AbbaTools{
 	public static Main plugin;
 	public static List<ValueItemPair> itemPairs;
@@ -161,15 +164,32 @@ public class AbbaTools{
 		
 	}
 	public static void onSignPlace(SignChangeEvent e){
-		
+		if(e.getPlayer().hasPermission(Permission.REGISTER_CHEST.toString())){
+			if(e.getLine(0).equalsIgnoreCase("[abba]")){
+				AbbaGame game;
+				if(e.getLine(1).equals("")){
+					game = getAbbaGame();
+				}else{
+					game = getAbbaGame(e.getLine(1));
+				}
+				if(game != null){
+					if(game.addChest((Chest) BlockUtils.getAttachedBlock(e.getBlock()), (Sign) e.getBlock())){
+						e.setLine(0, "§9[Abba]");
+					}
+				}
+			}
+		}
 	}
 	
 	
 	public static void deserialize(List<AbbaGame> gameList){
-		games = gameList;
+		
 		for(AbbaGame game:gameList){
-			for(UUID id:game.getPlayerIDs()){
-				playerGameMap.put(id, game);
+			if(game != null){
+				games.add(game);
+				for(UUID id:game.getPlayerIDs()){
+					playerGameMap.put(id, game);
+				}
 			}
 		}
 	}

+ 4 - 0
src/me/lennartVH01/EventListener.java

@@ -8,6 +8,7 @@ import org.bukkit.event.block.SignChangeEvent;
 import org.bukkit.event.inventory.InventoryOpenEvent;
 import org.bukkit.event.inventory.InventoryType;
 import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
 
 public class EventListener implements Listener{
 	public static Main plugin;
@@ -19,6 +20,9 @@ public class EventListener implements Listener{
 	public void onPlayerQuit(PlayerQuitEvent e){
 		AbbaTools.leave(e.getPlayer().getUniqueId());
 	}
+	public void onPlayerTeleport(PlayerTeleportEvent e){
+		AbbaTools.leave(e.getPlayer().getUniqueId());
+	}
 	
 	@EventHandler(ignoreCancelled = true)
 	public void onChestOpen(InventoryOpenEvent e){

+ 2 - 1
src/me/lennartVH01/Permission.java

@@ -8,7 +8,8 @@ public enum Permission{
 	
 	JOIN_FULL("AbbaCaving.joinFull"),
 	JOIN_CLOSED("AbbaCaving.joinClosed"),
-	JOIN_WHITELISTED("AbbaCaving.joinWhilelisted");
+	JOIN_WHITELISTED("AbbaCaving.joinWhilelisted"),
+	REGISTER_CHEST("AbbaCaving.registerChest");
 	
 	private final String permission;
 	private Permission(String permission){