mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-02 17:00:19 +01:00
commit
28506adc88
@ -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 RenameCommand RENAME = new RenameCommand();
|
||||
public static ResourcePackCommand RESOURCE_PACK = new ResourcePackCommand();
|
||||
public static RewardsCommand REWARDS = new RewardsCommand();
|
||||
public static SaveCommand SAVE = new SaveCommand();
|
||||
@ -79,6 +80,7 @@ public class DCommands extends BRCommands {
|
||||
PLAY,
|
||||
PORTAL,
|
||||
RELOAD,
|
||||
RENAME,
|
||||
RESOURCE_PACK,
|
||||
REWARDS,
|
||||
SAVE,
|
||||
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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.config.DungeonConfig;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class RenameCommand extends BRCommand {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
public RenameCommand() {
|
||||
setCommand("rename");
|
||||
setMinArgs(2);
|
||||
setMaxArgs(2);
|
||||
setHelp(DMessages.HELP_CMD_RENAME.getMessage());
|
||||
setPermission(DPermissions.RENAME.getNode());
|
||||
setPlayerCommand(true);
|
||||
setConsoleCommand(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[1]);
|
||||
if (resource == null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_MAP.getMessage(args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
resource.setName(args[2]);
|
||||
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
|
||||
|
||||
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
|
||||
DungeonConfig dConfig = dungeon.getConfig();
|
||||
FileConfiguration config = dConfig.getConfig();
|
||||
File file = dConfig.getFile();
|
||||
|
||||
if (dConfig.getStartFloor() == resource) {
|
||||
config.set("startFloor", args[2]);
|
||||
}
|
||||
|
||||
if (dConfig.getEndFloor() == resource) {
|
||||
config.set("endFloor", args[2]);
|
||||
}
|
||||
|
||||
List<String> list = config.getStringList("floors");
|
||||
int i = 0;
|
||||
for (DResourceWorld floor : dConfig.getFloors()) {
|
||||
if (floor == resource) {
|
||||
list.set(i, args[2]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
config.set("floors", list);
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) {
|
||||
if (protection instanceof GroupSign) {
|
||||
if (((GroupSign) protection).getMapName().equals(args[1])) {
|
||||
((GroupSign) protection).setMapName(args[2]);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
} else if (protection instanceof GameSign) {
|
||||
if (((GameSign) protection).getMapName().equals(args[1])) {
|
||||
((GameSign) protection).setMapName(args[2]);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
plugin.getGlobalProtections().saveAll();
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_RENAME_SUCCESS.getMessage(args[1], args[2]));
|
||||
}
|
||||
|
||||
}
|
@ -53,6 +53,7 @@ public enum DMessages implements Messages {
|
||||
CMD_MSG_ADDED("Cmd_Msg_Added", "&6New Messages (&4&v1&6) added!"),
|
||||
CMD_MSG_UPDATED("Cmd_Msg_Updated", "&6Messages (&4&v1&6) updated!"),
|
||||
CMD_RELOAD_DONE("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL."),
|
||||
CMD_RENAME_SUCCESS("Cmd_Rename_Success", "&6Successfully renamed the map &4&v1&6 to &4&v2&6."),
|
||||
CMD_SAVE_SUCCESS("Cmd_Save_Success", "&6Map saved!"),
|
||||
CMD_UNINVITE_SUCCESS("Cmd_Uninvite_Success", "&4&v1&6's permission to edit the map &4&v2&6 has been removed successfully."),
|
||||
ERROR_BED("Error_Bed", "&4You cannot use a bed while in a dungeon!"),
|
||||
@ -130,6 +131,7 @@ public enum DMessages implements Messages {
|
||||
HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to play a dungeon without a portal"),
|
||||
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_RENAME("Help_Cmd_Rename", "/dxl rename [old name] [new name] - Changes the name of a map to the new one. This command does NOT break dungeons that include this map."),
|
||||
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"),
|
||||
|
@ -59,6 +59,7 @@ public enum DPermissions {
|
||||
PLAY("play", OP),
|
||||
PORTAL("portal", OP),
|
||||
RELOAD("reload", OP),
|
||||
RENAME("rename", OP),
|
||||
RESOURCE_PACK("resourcepack", OP),
|
||||
REWARDS("rewards", TRUE),
|
||||
SAVE("save", OP),
|
||||
@ -85,7 +86,7 @@ public enum DPermissions {
|
||||
// Kits
|
||||
ADMINISTRATOR("*", OP),
|
||||
HALF_EDITOR("halfeditor", OP, ESCAPE, LIST, MESSAGE, SAVE),
|
||||
FULL_EDITOR("fulleditor", OP, HALF_EDITOR, EDIT, PLAY, SIGN, TEST),
|
||||
FULL_EDITOR("fulleditor", OP, HALF_EDITOR, EDIT, PLAY, RENAME, SIGN, TEST),
|
||||
HALF_PLAYER("halfplayer", TRUE, CHAT, ESCAPE, GAME, HELP, JOIN, LEAVE, LIVES, MAIN, SETTINGS, SETTINGS_PLAYER),
|
||||
FULL_PLAYER("fullplayer", OP, HALF_PLAYER, GROUP);
|
||||
|
||||
|
@ -98,6 +98,7 @@ public class DResourceWorld {
|
||||
*/
|
||||
public void setName(String name) {
|
||||
folder.renameTo(new File(folder.getParentFile(), name));
|
||||
folder = new File(folder.getParentFile(), name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user