From 7066c113b7a0a6df65e8446ebcd2e147f9c75119 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sun, 11 Sep 2016 22:51:59 +0200 Subject: [PATCH] #154: Added command to download registered RPs --- .../dre2n/dungeonsxl/command/DCommands.java | 2 + .../command/ResourcePackCommand.java | 57 +++++++++++++++++++ .../dre2n/dungeonsxl/player/DPermissions.java | 1 + 3 files changed, 60 insertions(+) create mode 100644 core/src/main/java/io/github/dre2n/dungeonsxl/command/ResourcePackCommand.java diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/DCommands.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/DCommands.java index c1d97e11..05e41a3a 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/DCommands.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/DCommands.java @@ -48,6 +48,7 @@ public class DCommands extends BRCommands { public static PlayCommand PLAY = new PlayCommand(); public static PortalCommand PORTAL = new PortalCommand(); public static ReloadCommand RELOAD = new ReloadCommand(); + public static ResourcePackCommand RESOURCE_PACK = new ResourcePackCommand(); public static RewardsCommand REWARDS = new RewardsCommand(); public static SaveCommand SAVE = new SaveCommand(); public static StatusCommand STATUS = new StatusCommand(); @@ -78,6 +79,7 @@ public class DCommands extends BRCommands { PLAY, PORTAL, RELOAD, + RESOURCE_PACK, REWARDS, SAVE, STATUS, 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 new file mode 100644 index 00000000..0043b43a --- /dev/null +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/ResourcePackCommand.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2012-2016 Frank Baumann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package io.github.dre2n.dungeonsxl.command; + +import io.github.dre2n.commons.command.BRCommand; +import io.github.dre2n.commons.util.messageutil.MessageUtil; +import io.github.dre2n.dungeonsxl.DungeonsXL; +import io.github.dre2n.dungeonsxl.config.DMessages; +import io.github.dre2n.dungeonsxl.player.DPermissions; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.inventivetalent.rpapi.ResourcePackAPI; + +/** + * @author Daniel Saukel + */ +public class ResourcePackCommand extends BRCommand { + + DungeonsXL plugin = DungeonsXL.getInstance(); + + public ResourcePackCommand() { + setCommand("resourcepack"); + setMinArgs(1); + setMaxArgs(1); + setHelp(DMessages.HELP_CMD_RESOURCE_PACK.getMessage()); + setPermission(DPermissions.RESOURCE_PACK.getNode()); + setPlayerCommand(true); + } + + @Override + public void onExecute(String[] args, CommandSender sender) { + Player player = (Player) sender; + + String url = (String) plugin.getMainConfig().getResourcePacks().get(args[1]); + if (url == null) { + MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1])); + return; + } + + ResourcePackAPI.setResourcepack(player, url); + } + +} diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java index a5955413..3f345d4a 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java @@ -59,6 +59,7 @@ public enum DPermissions { PLAY("play", OP), PORTAL("portal", OP), RELOAD("reload", OP), + RESOURCE_PACK("resourcepack", OP), REWARDS("rewards", TRUE), SAVE("save", OP), STATUS("status", OP),