From cd0ebc3a7a56ee9d6d46f963527e76e15708a32b Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 15 Feb 2013 23:31:39 +0100 Subject: [PATCH] Added shouldPersistToDisk attribute to BaseCommand. Updated subclasses to reflect the new attribute. --- src/de/craftinc/gates/commands/BaseCommand.java | 6 ++++++ src/de/craftinc/gates/commands/CommandClose.java | 1 + src/de/craftinc/gates/commands/CommandCreate.java | 1 + src/de/craftinc/gates/commands/CommandDelete.java | 1 + src/de/craftinc/gates/commands/CommandHelp.java | 1 + src/de/craftinc/gates/commands/CommandInfo.java | 1 + src/de/craftinc/gates/commands/CommandList.java | 1 + src/de/craftinc/gates/commands/CommandOpen.java | 1 + src/de/craftinc/gates/commands/CommandRename.java | 1 + src/de/craftinc/gates/commands/CommandSetExit.java | 5 +++++ src/de/craftinc/gates/commands/CommandSetHidden.java | 1 + src/de/craftinc/gates/commands/CommandSetLocation.java | 1 + src/de/craftinc/gates/commands/CommandSetVisible.java | 1 + 13 files changed, 22 insertions(+) diff --git a/src/de/craftinc/gates/commands/BaseCommand.java b/src/de/craftinc/gates/commands/BaseCommand.java index 1ec380d..ef44908 100644 --- a/src/de/craftinc/gates/commands/BaseCommand.java +++ b/src/de/craftinc/gates/commands/BaseCommand.java @@ -30,6 +30,8 @@ public abstract class BaseCommand protected String requiredPermission; protected boolean needsPermissionAtCurrentLocation; + protected boolean shouldPersistToDisk; + public BaseCommand() { @@ -61,6 +63,10 @@ public abstract class BaseCommand } this.perform(); + + if (this.shouldPersistToDisk) { + Plugin.instance.saveGates(); + } } diff --git a/src/de/craftinc/gates/commands/CommandClose.java b/src/de/craftinc/gates/commands/CommandClose.java index eff0163..36da43c 100644 --- a/src/de/craftinc/gates/commands/CommandClose.java +++ b/src/de/craftinc/gates/commands/CommandClose.java @@ -20,6 +20,7 @@ public class CommandClose extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandCreate.java b/src/de/craftinc/gates/commands/CommandCreate.java index 9408d29..fb5d3a1 100644 --- a/src/de/craftinc/gates/commands/CommandCreate.java +++ b/src/de/craftinc/gates/commands/CommandCreate.java @@ -25,6 +25,7 @@ public class CommandCreate extends BaseLocationCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = true; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandDelete.java b/src/de/craftinc/gates/commands/CommandDelete.java index fd2b49f..78c7769 100644 --- a/src/de/craftinc/gates/commands/CommandDelete.java +++ b/src/de/craftinc/gates/commands/CommandDelete.java @@ -23,6 +23,7 @@ public class CommandDelete extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandHelp.java b/src/de/craftinc/gates/commands/CommandHelp.java index 882d437..ac4afc8 100644 --- a/src/de/craftinc/gates/commands/CommandHelp.java +++ b/src/de/craftinc/gates/commands/CommandHelp.java @@ -24,6 +24,7 @@ public class CommandHelp extends BaseCommand hasGateParam = false; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = false; } diff --git a/src/de/craftinc/gates/commands/CommandInfo.java b/src/de/craftinc/gates/commands/CommandInfo.java index 10e3a27..3cdace5 100644 --- a/src/de/craftinc/gates/commands/CommandInfo.java +++ b/src/de/craftinc/gates/commands/CommandInfo.java @@ -21,6 +21,7 @@ public class CommandInfo extends BaseCommand requiredPermission = Plugin.permissionInfo; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = false; } diff --git a/src/de/craftinc/gates/commands/CommandList.java b/src/de/craftinc/gates/commands/CommandList.java index 90087d8..f0dbbbb 100644 --- a/src/de/craftinc/gates/commands/CommandList.java +++ b/src/de/craftinc/gates/commands/CommandList.java @@ -26,6 +26,7 @@ public class CommandList extends BaseCommand helpDescription = "lists all availible gates."; requiredPermission = Plugin.permissionInfo; + shouldPersistToDisk = false; } diff --git a/src/de/craftinc/gates/commands/CommandOpen.java b/src/de/craftinc/gates/commands/CommandOpen.java index 3c61ede..d87f67b 100644 --- a/src/de/craftinc/gates/commands/CommandOpen.java +++ b/src/de/craftinc/gates/commands/CommandOpen.java @@ -20,6 +20,7 @@ public class CommandOpen extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandRename.java b/src/de/craftinc/gates/commands/CommandRename.java index 6b74fbb..89b69cb 100644 --- a/src/de/craftinc/gates/commands/CommandRename.java +++ b/src/de/craftinc/gates/commands/CommandRename.java @@ -25,6 +25,7 @@ public class CommandRename extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandSetExit.java b/src/de/craftinc/gates/commands/CommandSetExit.java index c9b87f0..44e7614 100644 --- a/src/de/craftinc/gates/commands/CommandSetExit.java +++ b/src/de/craftinc/gates/commands/CommandSetExit.java @@ -22,6 +22,7 @@ public class CommandSetExit extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = true; + shouldPersistToDisk = true; } @@ -29,8 +30,12 @@ public class CommandSetExit extends BaseCommand { try { + System.out.println(gate.getExit()); + gate.setExit(player.getLocation()); sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand."); + + System.out.println(gate.getExit()); } catch (Exception e) { sendMessage(ChatColor.RED + "Setting the exit for the gate failed! See server log for more information"); diff --git a/src/de/craftinc/gates/commands/CommandSetHidden.java b/src/de/craftinc/gates/commands/CommandSetHidden.java index 7b80b86..19b5279 100644 --- a/src/de/craftinc/gates/commands/CommandSetHidden.java +++ b/src/de/craftinc/gates/commands/CommandSetHidden.java @@ -21,6 +21,7 @@ public class CommandSetHidden extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandSetLocation.java b/src/de/craftinc/gates/commands/CommandSetLocation.java index a93c562..06b7142 100644 --- a/src/de/craftinc/gates/commands/CommandSetLocation.java +++ b/src/de/craftinc/gates/commands/CommandSetLocation.java @@ -24,6 +24,7 @@ public class CommandSetLocation extends BaseLocationCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = true; + shouldPersistToDisk = true; } diff --git a/src/de/craftinc/gates/commands/CommandSetVisible.java b/src/de/craftinc/gates/commands/CommandSetVisible.java index 2066c38..17bfc25 100644 --- a/src/de/craftinc/gates/commands/CommandSetVisible.java +++ b/src/de/craftinc/gates/commands/CommandSetVisible.java @@ -20,6 +20,7 @@ public class CommandSetVisible extends BaseCommand requiredPermission = Plugin.permissionManage; needsPermissionAtCurrentLocation = false; + shouldPersistToDisk = true; }