Skip to content

Commit

Permalink
#41: Also apply renaming to data
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Dec 3, 2016
1 parent 147ffa8 commit 58dca28
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
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;
Expand Down Expand Up @@ -86,6 +89,27 @@ public void onExecute(String[] args, CommandSender sender) {
} 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]));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public String getName() {
*/
public void setName(String name) {
folder.renameTo(new File(folder.getParentFile(), name));
folder = new File(folder.getParentFile(), name);
}

/**
Expand Down

0 comments on commit 58dca28

Please sign in to comment.