Added shouldPersistToDisk attribute to BaseCommand. Updated subclasses to reflect the new attribute.

This commit is contained in:
Tobias Ottenweller 2013-02-15 23:31:39 +01:00
parent dd5a60cb2a
commit cd0ebc3a7a
13 changed files with 22 additions and 0 deletions

View File

@ -30,6 +30,8 @@ public abstract class BaseCommand
protected String requiredPermission; protected String requiredPermission;
protected boolean needsPermissionAtCurrentLocation; protected boolean needsPermissionAtCurrentLocation;
protected boolean shouldPersistToDisk;
public BaseCommand() public BaseCommand()
{ {
@ -61,6 +63,10 @@ public abstract class BaseCommand
} }
this.perform(); this.perform();
if (this.shouldPersistToDisk) {
Plugin.instance.saveGates();
}
} }

View File

@ -20,6 +20,7 @@ public class CommandClose extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = true;
} }

View File

@ -25,6 +25,7 @@ public class CommandCreate extends BaseLocationCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = true; needsPermissionAtCurrentLocation = true;
shouldPersistToDisk = true;
} }

View File

@ -23,6 +23,7 @@ public class CommandDelete extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = true;
} }

View File

@ -24,6 +24,7 @@ public class CommandHelp extends BaseCommand
hasGateParam = false; hasGateParam = false;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = false;
} }

View File

@ -21,6 +21,7 @@ public class CommandInfo extends BaseCommand
requiredPermission = Plugin.permissionInfo; requiredPermission = Plugin.permissionInfo;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = false;
} }

View File

@ -26,6 +26,7 @@ public class CommandList extends BaseCommand
helpDescription = "lists all availible gates."; helpDescription = "lists all availible gates.";
requiredPermission = Plugin.permissionInfo; requiredPermission = Plugin.permissionInfo;
shouldPersistToDisk = false;
} }

View File

@ -20,6 +20,7 @@ public class CommandOpen extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = true;
} }

View File

@ -25,6 +25,7 @@ public class CommandRename extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = true;
} }

View File

@ -22,6 +22,7 @@ public class CommandSetExit extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = true; needsPermissionAtCurrentLocation = true;
shouldPersistToDisk = true;
} }
@ -29,8 +30,12 @@ public class CommandSetExit extends BaseCommand
{ {
try try
{ {
System.out.println(gate.getExit());
gate.setExit(player.getLocation()); gate.setExit(player.getLocation());
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand."); sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
System.out.println(gate.getExit());
} }
catch (Exception e) { catch (Exception e) {
sendMessage(ChatColor.RED + "Setting the exit for the gate failed! See server log for more information"); sendMessage(ChatColor.RED + "Setting the exit for the gate failed! See server log for more information");

View File

@ -21,6 +21,7 @@ public class CommandSetHidden extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = true;
} }

View File

@ -24,6 +24,7 @@ public class CommandSetLocation extends BaseLocationCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = true; needsPermissionAtCurrentLocation = true;
shouldPersistToDisk = true;
} }

View File

@ -20,6 +20,7 @@ public class CommandSetVisible extends BaseCommand
requiredPermission = Plugin.permissionManage; requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = false; needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = true;
} }