From c79867d44cda3ef7591fa19d5854f52de90a8cce Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 13 Sep 2016 18:39:22 +0200 Subject: [PATCH] #154: Added reset function --- .../dre2n/dungeonsxl/command/ResourcePackCommand.java | 6 ++++++ .../io/github/dre2n/dungeonsxl/config/DMessages.java | 2 ++ .../github/dre2n/dungeonsxl/sign/ResourcePackSign.java | 10 ++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/ResourcePackCommand.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/ResourcePackCommand.java index 0043b43a..6caf1a9c 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/ResourcePackCommand.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/ResourcePackCommand.java @@ -45,6 +45,12 @@ public class ResourcePackCommand extends BRCommand { public void onExecute(String[] args, CommandSender sender) { Player player = (Player) sender; + if (args[1].equalsIgnoreCase("reset")) { + // Placeholder to reset to default + ResourcePackAPI.setResourcepack(player, "http://google.com"); + return; + } + String url = (String) plugin.getMainConfig().getResourcePacks().get(args[1]); if (url == null) { MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1])); diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java b/core/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java index a6764fb5..ebe2078c 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java @@ -85,6 +85,7 @@ public enum DMessages implements Messages { ERROR_NO_SUCH_GROUP("Error_NoSuchGroup", "&4The group &6&v1&4 does not exist!"), ERROR_NO_SUCH_MAP("Error_NoSuchMap", "&4The world &6&v1&4 does not exist!"), ERROR_NO_SUCH_PLAYER("Error_NoSuchPlayer", "&4The player &6&v1&4 does not exist!"), + ERROR_NO_SUCH_RESOURCE_PACK("Error_NoSuchResourcePack", "&4The resource pack &6&v1 &4is not registered in the main configuration file!"), ERROR_NO_SUCH_SHOP("Error_NoSuchShop", "&4Shop &v1 &4not found..."), ERROR_NOT_CAPTAIN("Error_NotCaptain", "&4You are not the captain of your group!"), ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"), @@ -130,6 +131,7 @@ public enum DMessages implements Messages { HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal ([material=portal])- Creates a portal that leads into a dungeon"), HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"), HELP_CMD_REWARDS("Help_Cmd_Rewards", "/dxl rewards - Gives all left item rewards to the player"), + HELP_CMD_RESOURCE_PACK("Help_Cmd_ResourcePack", "/dxl resourcepack [ID] - Downloads a resourcepack registered in the main configuration file; use 'reset' to reset"), HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"), HELP_CMD_STATUS("Help_Cmd_Status", "/dxl status - Shows the technical status of DungeonsXL"), HELP_CMD_SETTINGS("Help_Cmd_Settings", "/dxl settings ([edit|global|player])- Opens the settings menu"), diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/sign/ResourcePackSign.java b/core/src/main/java/io/github/dre2n/dungeonsxl/sign/ResourcePackSign.java index c99c1973..e16436fe 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/sign/ResourcePackSign.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/sign/ResourcePackSign.java @@ -61,12 +61,18 @@ public class ResourcePackSign extends DSign { /* Actions */ @Override public boolean check() { - return plugin.getMainConfig().getResourcePacks().get(lines[1]) != null; + return plugin.getMainConfig().getResourcePacks().get(lines[1]) != null || lines[1].equalsIgnoreCase("reset"); } @Override public void onInit() { - Object url = plugin.getMainConfig().getResourcePacks().get(lines[1]); + Object url = null; + if (lines[1].equalsIgnoreCase("reset")) { + // Placeholder to reset to default + url = "http://google.com"; + } else { + url = plugin.getMainConfig().getResourcePacks().get(lines[1]); + } if (url instanceof String) { resourcePack = (String) url;