Rewrote message system

This commit is contained in:
Daniel Saukel 2015-12-28 17:46:52 +01:00
parent 231dfff5c3
commit f9e616b3cf
35 changed files with 452 additions and 334 deletions

View File

@ -1,5 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -12,7 +13,7 @@ public class ChatCommand extends DCommand {
setCommand("chat");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Chat"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_CHAT));
setPlayerCommand(true);
}
@ -22,17 +23,17 @@ public class ChatCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player);
if (dplayer == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_GROUP));
return;
}
if (dplayer.isInDungeonChat()) {
dplayer.setInDungeonChat(false);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_NormalChat"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHAT_NORMAL_CHAT));
} else {
dplayer.setInDungeonChat(true);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chat_DungeonChat"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHAT_DUNGEON_CHAT));
}
}

View File

@ -1,5 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import org.bukkit.command.CommandSender;
@ -11,7 +12,7 @@ public class ChatSpyCommand extends DCommand {
setCommand("chatspy");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Chatspy"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_CHATSPY));
setPermission("dxl.chatspy");
setPlayerCommand(true);
}
@ -22,11 +23,11 @@ public class ChatSpyCommand extends DCommand {
if (plugin.getChatSpyers().contains(player)) {
plugin.getChatSpyers().remove(player);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chatspy_Stopped"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHATSPY_STOPPED));
} else {
plugin.getChatSpyers().add(player);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Chatspy_Start"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHATSPY_START));
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -14,7 +15,7 @@ public class CreateCommand extends DCommand {
setMinArgs(1);
setMaxArgs(1);
setCommand("create");
setHelp(plugin.getDMessages().get("Help_Cmd_Create"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_CREATE));
setPermission("dxl.create");
setPlayerCommand(true);
setConsoleCommand(true);
@ -27,8 +28,8 @@ public class CreateCommand extends DCommand {
if (sender instanceof ConsoleCommandSender) {
if (name.length() <= 15) {
// Msg create
plugin.getLogger().info(plugin.getDMessages().get("Log_NewDungeon"));
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_NEW_DUNGEON));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_GENERATE_NEW_WORLD));
// Create World
EditWorld editWorld = new EditWorld();
@ -38,24 +39,24 @@ public class CreateCommand extends DCommand {
editWorld.delete();
// MSG Done
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
} else {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_NameToLong"));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_NAME_TO_LONG));
}
} else if (sender instanceof Player) {
Player player = (Player) sender;
if (DPlayer.get(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
if (name.length() <= 15) {
// Msg create
plugin.getLogger().info(plugin.getDMessages().get("Log_NewDungeon"));
plugin.getLogger().info(plugin.getDMessages().get("Log_GenerateNewWorld"));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_NEW_DUNGEON));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_GENERATE_NEW_WORLD));
// Create World
EditWorld editWorld = new EditWorld();
@ -63,7 +64,7 @@ public class CreateCommand extends DCommand {
editWorld.setMapName(name);
// MSG Done
plugin.getLogger().info(plugin.getDMessages().get("Log_WorldGenerationFinished"));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
// Tp Player
if (editWorld.getLobby() == null) {
@ -74,7 +75,7 @@ public class CreateCommand extends DCommand {
}
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NameToLong"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NAME_TO_LONG));
}
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import org.bukkit.ChatColor;
@ -9,7 +10,8 @@ import org.bukkit.entity.Player;
public abstract class DCommand {
public DungeonsXL plugin = DungeonsXL.getPlugin();
static DungeonsXL plugin = DungeonsXL.getPlugin();
DMessages dMessages = plugin.getDMessages();
public boolean costsMoney;
private String command;

View File

@ -1,5 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -15,7 +16,7 @@ public class DeletePortalCommand extends DCommand {
setCommand("deleteportal");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_DeletePortal"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_DELETE_PORTAL));
setPermission("dxl.deleteportal");
setPlayerCommand(true);
}
@ -27,10 +28,10 @@ public class DeletePortalCommand extends DCommand {
if (dPortal != null) {
dPortal.delete();
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalDeleted"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_DELETED));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPortal"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PORTAL));
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -14,7 +15,7 @@ public class EditCommand extends DCommand {
setCommand("edit");
setMinArgs(1);
setMaxArgs(1);
setHelp(plugin.getDMessages().get("Help_Cmd_Edit"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_EDIT));
setPlayerCommand(true);
}
@ -28,22 +29,22 @@ public class EditCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player);
if ( !(EditWorld.isInvitedPlayer(dungeonName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoPermission"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PERMISSIONS));
return;
}
if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
if (dgroup != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}
if (eworld == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", dungeonName));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, dungeonName));
return;
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -14,7 +15,7 @@ public class EscapeCommand extends DCommand {
setCommand("escape");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Escape"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_ESCAPE));
setPlayerCommand(true);
}
@ -25,7 +26,7 @@ public class EscapeCommand extends DCommand {
if (dplayer != null) {
if ( !dplayer.isEditing()) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
@ -44,10 +45,10 @@ public class EscapeCommand extends DCommand {
DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
dgroup.removePlayer(player);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Leave_Success"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
return;
}
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -3,6 +3,7 @@ package io.github.dre2n.dungeonsxl.command;
import java.util.ArrayList;
import java.util.List;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -14,7 +15,7 @@ public class HelpCommand extends DCommand {
setCommand("help");
setMinArgs(0);
setMaxArgs(1);
setHelp(plugin.getDMessages().get("Help_Cmd_Help"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_HELP));
setPlayerCommand(true);
setConsoleCommand(true);
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import io.github.dre2n.dungeonsxl.util.UUIDUtil;
@ -12,7 +13,7 @@ public class InviteCommand extends DCommand {
setMinArgs(2);
setMaxArgs(2);
setCommand("invite");
setHelp(plugin.getDMessages().get("Help_Cmd_Invite"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_INVITE));
setPermission("dxl.invite");
setPlayerCommand(true);
setConsoleCommand(true);
@ -21,10 +22,10 @@ public class InviteCommand extends DCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Invite_Success", args[1], args[2]));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.CMD_INVITE_SUCCESS, args[1], args[2]));
} else {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, args[2]));
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -14,7 +15,7 @@ public class LeaveCommand extends DCommand {
setCommand("leave");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Leave"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_LEAVE));
setPlayerCommand(true);
}
@ -25,24 +26,24 @@ public class LeaveCommand extends DCommand {
if (GameWorld.get(player.getWorld()) != null) {
if (GameWorld.get(player.getWorld()).isTutorial()) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NoLeaveInTutorial"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_LEAVE_IN_TUTORIAL));
return;
}
}
if (dplayer != null) {
dplayer.leave();
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Leave_Success"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
} else {
DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
dgroup.removePlayer(player);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Leave_Success"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
return;
}
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -5,6 +5,7 @@ import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -19,7 +20,7 @@ public class ListCommand extends DCommand {
setCommand("list");
setMinArgs(0);
setMaxArgs(3);
setHelp(plugin.getDMessages().get("Help_Cmd_List"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_LIST));
setPlayerCommand(true);
setConsoleCommand(true);
}

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -14,7 +14,7 @@ public class LivesCommand extends DCommand {
setCommand("lives");
setMinArgs(0);
setMaxArgs(1);
setHelp(plugin.getDMessages().get("Help_Cmd_Lives"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_LIVES));
setPlayerCommand(true);
setConsoleCommand(true);
}
@ -32,16 +32,16 @@ public class LivesCommand extends DCommand {
player = (Player) sender;
} else {
MessageUtil.sendMessage(sender, DungeonsXL.getPlugin().getDMessages().get("Error_NoConsoleCommand", getCommand()));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_NO_CONSOLE_COMMAND, getCommand()));
return;
}
DPlayer dPlayer = DPlayer.get(player);
if (dPlayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.getLives())));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LIVES).replaceAll("v1", player.getName()).replaceAll("v2", String.valueOf(dPlayer.getLives())));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -3,6 +3,7 @@ package io.github.dre2n.dungeonsxl.command;
import java.io.File;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
@ -14,7 +15,7 @@ public class MainCommand extends DCommand {
public MainCommand() {
setCommand("main");
setHelp(plugin.getDMessages().get("Help_Cmd_main"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_MAIN));
setPlayerCommand(true);
setConsoleCommand(true);
}
@ -23,6 +24,7 @@ public class MainCommand extends DCommand {
public void onExecute(String[] args, CommandSender sender) {
PluginManager plugins = Bukkit.getServer().getPluginManager();
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
int players = plugin.getDPlayers().size();
@ -41,10 +43,10 @@ public class MainCommand extends DCommand {
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[2] + "&f" + MessageUtil.BIG_X[2] + MessageUtil.BIG_L[2]);
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[3] + "&f" + MessageUtil.BIG_X[3] + MessageUtil.BIG_L[3]);
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[4] + "&f" + MessageUtil.BIG_X[4] + MessageUtil.BIG_L[4]);
MessageUtil.sendCenteredMessage(sender, "&b&l####### " + plugin.getDMessages().get("Cmd_Main_Welcome") + "&7 v" + plugin.getDescription().getVersion() + " &b&l#######");
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Loaded", String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Compatibility", String.valueOf(internals), vault, mythicMobs));
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Help"));
MessageUtil.sendCenteredMessage(sender, "&b&l####### " + dMessages.getMessage(Messages.CMD_MAIN_WELCOME) + "&7 v" + plugin.getDescription().getVersion() + " &b&l#######");
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_LOADED, String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_COMPATIBILITY, String.valueOf(internals), vault, mythicMobs));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_HELP));
MessageUtil.sendCenteredMessage(sender, "&7\u00a92012-2015 Frank Baumann & contributors; lcsd. under GPLv3.");
}

View File

@ -2,6 +2,7 @@ package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -17,7 +18,7 @@ public class MsgCommand extends DCommand {
setMinArgs( -1);
setMaxArgs( -1);
setCommand("msg");
setHelp(plugin.getDMessages().get("Help_Cmd_Msg"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_MSG));
setPermission("dxl.msg");
setPlayerCommand(true);
}
@ -28,7 +29,7 @@ public class MsgCommand extends DCommand {
EditWorld editWorld = EditWorld.get(player.getWorld());
if (editWorld == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
return;
}
@ -49,7 +50,7 @@ public class MsgCommand extends DCommand {
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgIdNotExist", "" + id));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_MSG_ID_NOT_EXIST, "" + id));
}
} else {
@ -68,22 +69,22 @@ public class MsgCommand extends DCommand {
msg = splitMsg[1];
String old = confreader.getMsg(id, false);
if (old == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Added", "" + id));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_MSG_ADDED, "" + id));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Msg_Updated", "" + id));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_MSG_UPDATED, "" + id));
}
confreader.setMsg(msg, id);
confreader.save();
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgFormat"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_MSG_FORMAT));
}
}
} catch (NumberFormatException e) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_MsgNoInt"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_MSG_NO_INT));
}
}

View File

@ -1,10 +1,10 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -20,7 +20,7 @@ public class PlayCommand extends DCommand {
setCommand("play");
setMinArgs(1);
setMaxArgs(2);
setHelp(plugin.getDMessages().get("Help_Cmd_Play"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_PLAY));
setPermission("dxl.play");
setPlayerCommand(true);
}
@ -31,7 +31,7 @@ public class PlayCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
@ -63,7 +63,7 @@ public class PlayCommand extends DCommand {
}
if ( !multiFloor && !EditWorld.exist(identifier)) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", identifier));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
return;
}
@ -74,19 +74,19 @@ public class PlayCommand extends DCommand {
WorldConfig confReader = new WorldConfig(file);
if (confReader != null) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_COOLDOWN, "" + confReader.getTimeToNextPlay()));
}
}
return;
}
if ( !GameWorld.checkRequirements(mapName, player)) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Requirements"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_REQUIREMENTS));
return;
}
if (DGroup.get(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}

View File

@ -1,5 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -15,7 +16,7 @@ public class PortalCommand extends DCommand {
setCommand("portal");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Portal"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_PORTAL));
setPermission("dxl.portal");
setPlayerCommand(true);
}
@ -26,7 +27,7 @@ public class PortalCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
}
DPortal dportal = DPortal.get(player);
@ -36,11 +37,11 @@ public class PortalCommand extends DCommand {
dportal.setPlayer(player);
dportal.setWorld(player.getWorld());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalIntroduction"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION));
} else {
plugin.getDPortals().remove(dportal);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalAbort"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_ABORT));
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
@ -16,7 +17,7 @@ public class ReloadCommand extends DCommand {
setCommand("reload");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Reload"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_RELOAD));
setPermission("dxl.reload");
setPlayerCommand(true);
setConsoleCommand(true);
@ -26,6 +27,7 @@ public class ReloadCommand extends DCommand {
public void onExecute(String[] args, CommandSender sender) {
PluginManager plugins = Bukkit.getServer().getPluginManager();
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
int players = plugin.getDPlayers().size();
@ -51,9 +53,9 @@ public class ReloadCommand extends DCommand {
plugin.loadDungeons();
MessageUtil.sendPluginTag(sender, plugin);
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Reload_Done"));
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Loaded", String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, plugin.getDMessages().get("Cmd_Main_Compatibility", String.valueOf(internals), vault, mythicMobs));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_RELOAD_DONE));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_LOADED, String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_COMPATIBILITY, String.valueOf(internals), vault, mythicMobs));
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import org.bukkit.command.CommandSender;
@ -12,7 +13,7 @@ public class SaveCommand extends DCommand {
setCommand("save");
setMinArgs(0);
setMaxArgs(0);
setHelp(plugin.getDMessages().get("Help_Cmd_Save"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_SAVE));
setPermission("dxl.save");
setPlayerCommand(true);
}
@ -23,10 +24,10 @@ public class SaveCommand extends DCommand {
EditWorld eworld = EditWorld.get(player.getWorld());
if (eworld != null) {
eworld.save();
MessageUtil.sendMessage(player, plugin.getDMessages().get("Cmd_Save_Success"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_SAVE_SUCCESS));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -3,6 +3,7 @@ package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -16,7 +17,7 @@ public class TestCommand extends DCommand {
setCommand("test");
setMinArgs(1);
setMaxArgs(2);
setHelp(plugin.getDMessages().get("Help_Cmd_Test"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_TEST));
setPermission("dxl.test");
setPlayerCommand(true);
}
@ -27,7 +28,7 @@ public class TestCommand extends DCommand {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveDungeon"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
@ -56,12 +57,12 @@ public class TestCommand extends DCommand {
}
if ( !multiFloor && !EditWorld.exist(identifier)) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", identifier));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
return;
}
if (DGroup.get(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_LeaveGroup"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import io.github.dre2n.dungeonsxl.util.UUIDUtil;
@ -12,7 +13,7 @@ public class UninviteCommand extends DCommand {
setCommand("uninvite");
setMinArgs(2);
setMaxArgs(2);
setHelp(plugin.getDMessages().get("Help_Cmd_Uninvite"));
setHelp(dMessages.getMessage(Messages.HELP_CMD_UNINVITE));
setPermission("dxl.uninvite");
setPlayerCommand(true);
setConsoleCommand(true);
@ -21,10 +22,10 @@ public class UninviteCommand extends DCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.removeInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]), args[1])) {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Cmd_Uninvite_Success", args[1], args[2]));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.CMD_UNINVITE_SUCCESS, args[1], args[2]));
} else {
MessageUtil.sendMessage(sender, plugin.getDMessages().get("Error_DungeonNotExist", args[2]));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, args[2]));
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.dungeon;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -22,7 +23,7 @@ public class DLootInventory {
public DLootInventory(Player player, ItemStack[] itemStacks) {
plugin.getDLootInventories().add(this);
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DungeonsXL.getPlugin().getDMessages().get("Player_Treasures")));
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', plugin.getDMessages().getMessage(Messages.PLAYER_TREASURES)));
for (ItemStack itemStack : itemStacks) {
if (itemStack != null) {
inventory.addItem(itemStack);

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.dungeon.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -80,9 +81,9 @@ public class GameChest {
msg = msg.substring(0, msg.length() - 1);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", msg));
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LOOT_ADDED, msg));
if (moneyReward != 0) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LootAdded", String.valueOf(moneyReward)));
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LOOT_ADDED, String.valueOf(moneyReward)));
}
}
}
@ -109,7 +110,8 @@ public class GameChest {
}
if ( !gameChest.isUsed) {
MessageUtil.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().get("Error_ChestIsOpened"));
MessageUtil
.sendMessage(DungeonsXL.getPlugin().getServer().getPlayer(event.getPlayer().getUniqueId()), DungeonsXL.getPlugin().getDMessages().getMessage(Messages.ERROR_CHEST_IS_OPENED));
event.setCancelled(true);
continue;
}

View File

@ -2,200 +2,243 @@ package io.github.dre2n.dungeonsxl.file;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class DMessages {
private Map<String, String> entries = new TreeMap<String, String>();
private Map<String, String> defaults = new TreeMap<String, String>();
public enum Messages {
LOG_NEW_DUNGEON("Log_NewDungeon", "&6New Dungeon"),
LOG_GENERATE_NEW_WORLD("Log_GenerateNewWorld", "&6Generate new world..."),
LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"),
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"),
LOG_ERROR_NO_CONSOLE_COMMAND("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as Console!"),
PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"),
PLAYER_LOOT_ADDED("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!"),
PLAYER_READY("Player_Ready", "&6You are now ready for the Dungeon!"),
PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the Dungeon!"),
PLAYER_WAIT_FOR_OTHER_PLAYERS("Player_WaitForOtherPlayers", "&6Waiting for teammates..."),
PLAYER_LEAVE_GROUP("Player_LeaveGroup", "&6You have successfully left your group!"),
PLAYER_OFFLINE("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!"),
PLAYER_OFFLINE_NEVER("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!"),
PLAYER_LEFT_GROUP("Player_LeftGroup", "&Player &4&v1&6 has left the Group!"),
PLAYER_JOIN_GROUP("Player_JoinGroup", "&Player &4&v1&6 has joined the Group!"),
PLAYER_PORTAL_ABORT("Player_PortalAbort", "&6Portal creation cancelled!"),
PLAYER_PORTAL_INTRODUCTION("Player_PortalIntroduction", "&6Click the two edges of the Portal with the wooden sword!"),
PLAYER_PORTAL_DELETED("Player_PortalDeleted", "&6Portal deleted!"),
PLAYER_PORTAL_PROGRESS("Player_PortalProgress", "&6First Block, now the second one!"),
PLAYER_PORTAL_CREATED("Player_PortalCreated", "&6Portal created!"),
PLAYER_SIGN_CREATED("Player_SignCreated", "&6Sign created!"),
PLAYER_SIGN_COPIED("Player_SignCopied", "&6Copied!"),
PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block-ID: &2&v1"),
PLAYER_DEATH("Player_Death", "&6You died, lives left: &2v1"),
PLAYER_DEATH_KICK("Player_DeathKick", "&2v1&6 died and lost his last life."),
PLAYER_TREASURES("Player_Treasures", "&1Treasures"),
CMD_CHAT_DUNGEON_CHAT("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat"),
CMD_CHAT_NORMAL_CHAT("Cmd_Chat_NormalChat", "&6You are now in the public chat"),
CMD_CHATSPY_STOPPED("Cmd_Chatspy_Stopped", "&6You stopped spying the DXL-chat!"),
CMD_CHATSPY_START("Cmd_Chatspy_Start", "&You started spying the DXL-chat!"),
CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!"),
CMD_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"),
CMD_MAIN_WELCOME("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL"),
CMD_MAIN_LOADED("Cmd_Main_Loaded", "&eMaps: &o[&v1] &eDungeons: &o[&v2] &eLoaded: &o[&v3] &ePlayers: &o[&v4]"),
CMD_MAIN_COMPATIBILITY("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eMythicMobs: &o[&v3]"),
CMD_MAIN_HELP("Cmd_Main_Help", "&7Type in &o/dxl help&r&7 for further information."),
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_SAVE_SUCCESS("Cmd_Save_Success", "&6Dungeon saved!"),
CMD_UNINVITE_SUCCESS("Cmd_Uninvite_Success", "&4&v1&6 was successfully uninvited to edit the Dungeon &4&v1&6!"),
CMD_LIVES("Cmd_Lives", "&4v1&6 has &4v2 &6lives left."),
ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."),
ERROR_ENDERCHEST("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!"),
ERROR_BED("Error_Bed", "&4You cannot use a bed while in a Dungeon!"),
ERROR_DISPENSER("Error_Dispenser", "&4You cannot access this dispenser!"),
ERROR_READY("Error_Ready", "&4Choose your class first!"),
ERROR_COOLDOWN("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!"),
ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!"),
ERROR_LEFT_CLICK("Error_Leftklick", "&4You have to use Left-Click on this sign!"),
ERROR_DROP("Error_Drop", "&4You cannot drop safe items"),
ERROR_CMD("Error_Cmd", "&4Commands are not allowed while in a dungeon!"),
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4You have to join a group first!"),
ERROR_NO_PERMISSIONS("Error_NoPermissions", "&4You have no permission to do this!"),
ERROR_CMD_NOT_EXIST_1("Error_CmdNotExist1", "&4Command &6&v1&4 does not exist!"),
ERROR_CMD_NOT_EXIST_2("Error_CmdNotExist2", "&4Pleaser enter &6/dxl help&4 for help!"),
ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"),
ERROR_DUNGEON_NOT_EXIST("Error_DungeonNotExist", "&4Dungeon &6&v1&4 does not exist!"),
ERROR_LEAVE_DUNGEON("Error_LeaveDungeon", "&4You have to leave your current dungeon first!"),
ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"),
ERROR_LEAVE_GROUP("Error_LeaveGroup", "&4You have to leave your group first!"),
ERROR_NO_LEAVE_IN_TUTORIAL("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!"),
ERROR_MSG_ID_NOT_EXIST("Error_MsgIdNotExist", "&4Messages with Id &6&v1&4 does not exist!"),
ERROR_MSG_FORMAT("Error_MsgFormat", "&4The Messages has to be between \"!"),
ERROR_MSG_NO_INT("Error_MsgNoInt", "&4Argument <id> has to include a number!"),
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
ERROR_NO_PORTAL("Error_NoPortal", "&4You have to look at a portal!"),
ERROR_NO_PLAYER_COMMAND("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!"),
ERROR_NO_CONSOLE_COMMAND("Error_NoConsoleCommand", "&6/dxl &v1&4 cannot be executed as console!"),
ERROR_SIGN_WRONG_FORMAT("Error_SignWrongFormat", "&4The sign is not written correctly!"),
HELP_CMD_CHAT("Help_Cmd_Chat", "/dxl chat - Change the Chat-Mode"),
HELP_CMD_CHATSPY("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode"),
HELP_CMD_CREATE("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon"),
HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit <name> - Edit an existing dungeon"),
HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"),
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"),
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"),
HELP_CMD_ESCAPE("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!"),
HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"),
HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"),
HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message"),
HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon"),
HELP_CMD_DELETE_PORTAL("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at"),
HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"),
HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"),
HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to join a game without a portal"),
HELP_CMD_TEST("Help_Cmd_Test", "/dxl test ([dungeon|map]) [name] - Tests a dungeon"),
HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left"),
HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon");
private String identifier;
private String message;
Messages(String identifier, String message) {
this.identifier = identifier;
this.message = message;
}
/**
* @return the identifier
*/
public String getIdentifier() {
return identifier;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message
* the message to set
*/
public void setMessage(String message) {
this.message = message;
}
// Static
/**
* @param identifer
* the identifer to set
*/
public static Messages fromIdentifier(String identifier) {
for (Messages message : Messages.values()) {
if (message.getIdentifier().equals(identifier)) {
return message;
}
}
return null;
}
/**
* @return a FileConfiguration containing all messages
*/
public static FileConfiguration toConfig() {
FileConfiguration config = new YamlConfiguration();
for (Messages message : Messages.values()) {
config.set(message.getIdentifier(), message.getMessage());
}
return config;
}
}
private File file;
private boolean changed;
private FileConfiguration config;
public DMessages(File file) {
setDefaults();
/* Load */
this.file = file;
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
if ( !file.exists()) {
try {
file.createNewFile();
config = Messages.toConfig();
config.save(file);
Set<String> keySet = configFile.getKeys(false);
} catch (IOException exception) {
exception.printStackTrace();
}
} else {
config = YamlConfiguration.loadConfiguration(file);
load();
}
}
public void load() {
if (config != null) {
Set<String> keySet = config.getKeys(false);
for (String key : keySet) {
entries.put(key, configFile.getString(key));
Messages.fromIdentifier(key).setMessage(config.getString(key));
}
}
}
/* Check */
check();
}
public boolean changed() {
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
if ( !Messages.toConfig().getValues(false).equals(config.getValues(false))) {
return true;
private void setDefaults() {
/* Log */
defaults.put("Log_NewDungeon", "&6New Dungeon");
defaults.put("Log_GenerateNewWorld", "&6Generate new world...");
defaults.put("Log_WorldGenerationFinished", "&6World generation finished!");
defaults.put("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!");
defaults.put("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!");
defaults.put("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as Console!");
/* Player */
defaults.put("Player_CheckpointReached", "&6Checkpoint reached!");
defaults.put("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!");
defaults.put("Player_Ready", "&6You are now ready for the Dungeon!");
defaults.put("Player_FinishedDungeon", "&6You successfully finished the Dungeon!");
defaults.put("Player_WaitForOtherPlayers", "&6Waiting for teammates...");
defaults.put("Player_LeaveGroup", "&6You have successfully left your group!");
defaults.put("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!");
defaults.put("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!");
defaults.put("Player_LeftGroup", "&Player &4&v1&6 has left the Group!");
defaults.put("Player_JoinGroup", "&Player &4&v1&6 has joined the Group!");
defaults.put("Player_PortalAbort", "&6Portal creation cancelled!");
defaults.put("Player_PortalIntroduction", "&6Click the two edges of the Portal with the wooden sword!");
defaults.put("Player_PortalDeleted", "&6Portal deleted!");
defaults.put("Player_PortalProgress", "&6First Block, now the second one!");
defaults.put("Player_PortalCreated", "&6Portal created!");
defaults.put("Player_SignCreated", "&6Sign created!");
defaults.put("Player_SignCopied", "&6Copied!");
defaults.put("Player_BlockInfo", "&6Block-ID: &2&v1");
defaults.put("Player_Death", "&6You died, lives left: &2v1");
defaults.put("Player_DeathKick", "&2v1&6 died and lost his last life.");
defaults.put("Player_Treasures", "&1Treasures");
/* Cmds */
defaults.put("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat");
defaults.put("Cmd_Chat_NormalChat", "&6You are now in the public chat");
defaults.put("Cmd_Chatspy_Stopped", "&6You stopped spying the DXL-chat!");
defaults.put("Cmd_Chatspy_Start", "&You started spying the DXL-chat!");
defaults.put("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!");
defaults.put("Cmd_Leave_Success", "&6You have successfully left your group!");
defaults.put("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL");
defaults.put("Cmd_Main_Loaded", "&eDungeons: &o[&v1] &eLoaded: &o[&v2] &ePlayers: &o[&v3]");
defaults.put("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eMythicMobs: &o[&v3]");
defaults.put("Cmd_Main_Help", "&7Type in &o/dxl help&r&7 for further information.");
defaults.put("Cmd_Msg_Added", "&6New Message (&4&v1&6) added!");
defaults.put("Cmd_Msg_Updated", "&6Message (&4&v1&6) updated!");
defaults.put("Cmd_Reload_Done", "&7Successfully reloaded DungeonsXL.");
defaults.put("Cmd_Save_Success", "&6Dungeon saved!");
defaults.put("Cmd_Uninvite_Success", "&4&v1&6 was successfully uninvited to edit the Dungeon &4&v1&6!");
defaults.put("Cmd_Lives", "&4v1&6 has &4v2 &6lives left.");
/* Errors */
defaults.put("Error_ChestIsOpened", "&4This chest has already been opened.");
defaults.put("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!");
defaults.put("Error_Bed", "&4You cannot use a bed while in a Dungeon!");
defaults.put("Error_Dispenser", "&4You cannot access this dispenser!");
defaults.put("Error_Ready", "&4Choose your class first!");
defaults.put("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!");
defaults.put("Error_Requirements", "&4You don't fulfill the requirements for this Dungeon!");
defaults.put("Error_Leftklick", "&4You have to use Left-Click on this sign!");
defaults.put("Error_Drop", "&4You cannot drop safe items");
defaults.put("Error_Cmd", "&4Commands are not allowed while in a dungeon!");
defaults.put("Error_NotInGroup", "&4You have to join a group first!");
defaults.put("Error_NoPermissions", "&4You have no permission to do this!");
defaults.put("Error_CmdNotExist1", "&4Command &6&v1&4 does not exist!");
defaults.put("Error_CmdNotExist2", "&4Pleaser enter &6/dxl help&4 for help!");
defaults.put("Error_NotInDungeon", "&4You are not in a dungeon!");
defaults.put("Error_DungeonNotExist", "&4Dungeon &6&v1&4 does not exist!");
defaults.put("Error_LeaveDungeon", "&4You have to leave your current dungeon first!");
defaults.put("Error_NameToLong", "&4The name may not be longer than 15 characters!");
defaults.put("Error_LeaveGroup", "&4You have to leave your group first!");
defaults.put("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!");
defaults.put("Error_MsgIdNotExist", "&4Message with Id &6&v1&4 does not exist!");
defaults.put("Error_MsgFormat", "&4The Message has to be between \"!");
defaults.put("Error_MsgNoInt", "&4Argument <id> has to include a number!");
defaults.put("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!");
defaults.put("Error_NoPortal", "&4You have to look at a portal!");
defaults.put("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!");
defaults.put("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as console!");
defaults.put("Error_SignWrongFormat", "&4The sign is not written correctly!");
/* Help */
defaults.put("Help_Cmd_Chat", "/dxl chat - Change the Chat-Mode");
defaults.put("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode");
defaults.put("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon");
defaults.put("Help_Cmd_Edit", "/dxl edit <name> - Edit an existing dungeon");
defaults.put("Help_Cmd_Help", "/dxl help <page> - Shows the help page");
defaults.put("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon");
defaults.put("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon");
defaults.put("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!");
defaults.put("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons");
defaults.put("Help_Cmd_Main", "/dxl - General status information");
defaults.put("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message");
defaults.put("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon");
defaults.put("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at");
defaults.put("Help_Cmd_Reload", "/dxl reload - Reloads the plugin");
defaults.put("Help_Cmd_Save", "/dxl save - Saves the current dungeon");
defaults.put("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to join a game without a portal");
defaults.put("Help_Cmd_Test", "/dxl test ([dungeon|map]) [name] - Tests a dungeon");
defaults.put("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left");
defaults.put("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon");
}
private void check() {
for (String defaultEntry : defaults.keySet()) {
if ( !entries.containsKey(defaultEntry)) {
entries.put(defaultEntry, defaults.get(defaultEntry));
changed = true;
}
} else {
return false;
}
}
public void save() {
if ( !changed) {
if ( !changed()) {
return;
}
/* Copy old File */
File source = new File(file.getPath());
String filePath = file.getPath();
File temp = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
if (temp.exists()) {
temp.delete();
}
source.renameTo(temp);
/* Save */
FileConfiguration configFile = new YamlConfiguration();
for (String key : entries.keySet()) {
configFile.set(key, entries.get(key));
}
File oldMessages = new File(filePath.substring(0, filePath.length() - 4) + "_old.yml");
try {
configFile.save(file);
Messages.toConfig().save(oldMessages);
} catch (IOException e) {
e.printStackTrace();
} catch (IOException exception) {
exception.printStackTrace();
}
}
public String get(String key, String... args) {
String entry = entries.get(key);
if (entry == null) {
return entry;
}
public String getMessage(Messages message, String... args) {
String output = message.getMessage();
int i = 0;
for (String arg : args) {
i++;
if (arg != null) {
entry = entry.replace("&v" + i, arg);
output = output.replace("&v" + i, arg);
} else {
entry = entry.replace("&v" + i, "null");
output = output.replace("&v" + i, "null");
}
}
return entry;
return output;
}
}

View File

@ -3,6 +3,7 @@ package io.github.dre2n.dungeonsxl.file;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
@ -23,6 +24,35 @@ public class MainConfig {
public WorldConfig defaultDungeon;
public MainConfig(File file) {
if ( !file.exists()) {
try {
file.createNewFile();
FileConfiguration configFile = new YamlConfiguration();
configFile.set("language", "en");
configFile.set("enableEconomy", true);
configFile.set("tutorialActivated", false);
configFile.set("tutorialDungeon", "tutorial");
configFile.set("tutorialStartGroup", "default");
configFile.set("tutorialEndGroup", "player");
configFile.set("tutorialEndGroup", "player");
ConfigurationSection defaultDungeon = configFile.createSection("default");
defaultDungeon.set("initialLives", 3);
defaultDungeon.set("timeUntilKickOfflinePlayer", 10000);
defaultDungeon.set("keepInventoryOnEnter", false);
defaultDungeon.set("keepInventoryOnDeath", true);
defaultDungeon.set("keepInventoryOnFinish", false);
defaultDungeon.set("keepInventoryOnEscape", false);
configFile.save(file);
} catch (IOException exception) {
exception.printStackTrace();
}
} else {
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
/* Main Config */
@ -51,12 +81,13 @@ public class MainConfig {
}
/* Default Dungeon Config */
ConfigurationSection configSetion = configFile.getConfigurationSection("default");
if (configSetion != null) {
defaultDungeon = new WorldConfig(configSetion);
ConfigurationSection configSection = configFile.getConfigurationSection("default");
if (configSection != null) {
defaultDungeon = new WorldConfig(configSection);
WorldConfig.defaultConfig = defaultDungeon;
}
}
}
/**
* @return the language

View File

@ -2,6 +2,7 @@ package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -86,7 +87,7 @@ public class DPortal {
DGroup dgroup = DGroup.get(player);
if (dgroup == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_NotInGroup"));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NOT_IN_GROUP));
return;
}
@ -95,7 +96,7 @@ public class DPortal {
}
if (dgroup.getGameWorld() == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getMapName()));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.get(player).getMapName()));
return;
}

View File

@ -4,6 +4,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -376,12 +377,17 @@ public class GroupSign {
return false;
}
if (DGroup.get(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_LEAVE_GROUP));
return true;
}
if ( !GameWorld.canPlayDungeon(groupSign.mapName, player)) {
File file = new File(plugin.getDataFolder() + "/maps/" + groupSign.mapName, "config.yml");
if (file != null) {
WorldConfig confReader = new WorldConfig(file);
if (confReader != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_COOLDOWN, String.valueOf(confReader.getTimeToNextPlay())));
}
}
@ -389,7 +395,7 @@ public class GroupSign {
}
if ( !GameWorld.checkRequirements(groupSign.mapName, player)) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Requirements"));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_REQUIREMENTS));
return true;
}
@ -410,8 +416,8 @@ public class GroupSign {
}
Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(strNewGrp)) {
if (DGroup.get(player) == null) {
if (groupSign.isMultiFloor()) {
groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor());
@ -419,14 +425,11 @@ public class GroupSign {
groupSign.dGroups[column] = new DGroup(player, groupSign.mapName, groupSign.isMultiFloor());
}
groupSign.update();
}
} else if (topSign.getLine(0).equals(strJoinGrp)) {
if (DGroup.get(player) == null) {
groupSign.dGroups[column].addPlayer(player);
groupSign.update();
}
}
return true;
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -52,7 +53,7 @@ public class LeaveSign {
DGroup dgroup = DGroup.get(player);
if (dgroup != null) {
dgroup.removePlayer(player);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_LeaveGroup"));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LEAVE_GROUP));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
return true;
}
}

View File

@ -4,6 +4,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
@ -30,6 +31,8 @@ import org.bukkit.scheduler.BukkitRunnable;
public class BlockListener implements Listener {
static DungeonsXL plugin = DungeonsXL.getPlugin();
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPhysics(BlockPhysicsEvent event) {
if (event.getBlock().getType() != Material.PORTAL) {
@ -59,7 +62,7 @@ public class BlockListener implements Listener {
// DGSign destroying
if (GroupSign.getSign(block) != null) {
DungeonsXL.getPlugin().getGroupSigns().remove(GroupSign.getSign(block));
plugin.getGroupSigns().remove(GroupSign.getSign(block));
}
// Deny LeaveSignblocks destroying
@ -178,16 +181,16 @@ public class BlockListener implements Listener {
}
if ( !player.hasPermission(dsign.getType().getBuildPermission())) {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_NoPermissions"));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NO_PERMISSIONS));
}
if (dsign.check()) {
editWorld.checkSign(block);
editWorld.getSign().add(block);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_SIGN_CREATED));
} else {
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_SignWrongFormat"));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_SIGN_WRONG_FORMAT));
}
}
}
@ -217,7 +220,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockRedstoneEvent(BlockRedstoneEvent event) {
new RedstoneEventTask(event.getBlock()).runTaskLater(DungeonsXL.getPlugin(), 1);
new RedstoneEventTask(event.getBlock()).runTaskLater(plugin, 1);
}
public class RedstoneEventTask extends BukkitRunnable {
@ -229,7 +232,7 @@ public class BlockListener implements Listener {
@Override
public void run() {
for (GameWorld gameWorld : DungeonsXL.getPlugin().getGameWorlds()) {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (block.getWorld() == gameWorld.getWorld()) {
RedstoneTrigger.updateAll(gameWorld);
}

View File

@ -4,6 +4,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import io.github.dre2n.dungeonsxl.command.DCommand;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -24,7 +25,7 @@ public class CommandListener implements CommandExecutor {
if (dCommand != null) {
if (sender instanceof ConsoleCommandSender) {
if ( !dCommand.isConsoleCommand()) {
MessageUtil.sendMessage(sender, dMessages.get("Log_Error_NoConsoleCommand", dCommand.getCommand()));
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.LOG_ERROR_NO_CONSOLE_COMMAND, dCommand.getCommand()));
return false;
}
}
@ -33,13 +34,13 @@ public class CommandListener implements CommandExecutor {
Player player = (Player) sender;
if ( !dCommand.isPlayerCommand()) {
MessageUtil.sendMessage(player, dMessages.get("Error_NoPlayerCommand", dCommand.getCommand()));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PLAYER_COMMAND, dCommand.getCommand()));
return false;
} else {
if (dCommand.getPermission() != null) {
if ( !dCommand.playerHasPermissions(player)) {
MessageUtil.sendMessage(player, dMessages.get("Error_NoPermissions"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PERMISSIONS));
return false;
}
}

View File

@ -6,6 +6,8 @@ import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameChest;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
@ -16,7 +18,6 @@ import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
import io.github.dre2n.dungeonsxl.util.MiscUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -46,7 +47,8 @@ import org.bukkit.scheduler.BukkitRunnable;
public class PlayerListener implements Listener {
public DungeonsXL plugin = DungeonsXL.getPlugin();
DungeonsXL plugin = DungeonsXL.getPlugin();
DMessages dMessages = plugin.getDMessages();
@EventHandler(priority = EventPriority.HIGH)
public void onDeath(PlayerDeathEvent event) {
@ -67,7 +69,8 @@ public class PlayerListener implements Listener {
dPlayer.setLives(dPlayer.getLives() - 1);
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
Bukkit.broadcastMessage(plugin.getDMessages().get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
MessageUtil.broadcastMessage(dMessages.getMessage(Messages.PLAYER_DEATH_KICK, player.getName()));
// TODO: This Runnable is a workaround for a bug I couldn't find, yet...
new BukkitRunnable() {
public void run() {
@ -76,7 +79,7 @@ public class PlayerListener implements Listener {
}.runTaskLater(plugin, 1L);
} else if ( !(dPlayer.getLives() == -1)) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_Death").replaceAll("v1", String.valueOf(dPlayer.getLives())));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_DEATH, String.valueOf(dPlayer.getLives())));
} else if (dConfig != null) {
if (dConfig.getKeepInventoryOnDeath()) {
@ -101,13 +104,13 @@ public class PlayerListener implements Listener {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.ENDER_CHEST) {
if ( !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Enderchest"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_ENDERCHEST));
event.setCancelled(true);
}
} else if (clickedBlock.getType() == Material.BED_BLOCK) {
if ( !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Bed"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_BED));
event.setCancelled(true);
}
}
@ -119,7 +122,7 @@ public class PlayerListener implements Listener {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.DISPENSER) {
if ( !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Dispenser"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DISPENSER));
event.setCancelled(true);
}
}
@ -137,13 +140,13 @@ public class PlayerListener implements Listener {
if (dportal.getPlayer() == player) {
if (dportal.getBlock1() == null) {
dportal.setBlock1(event.getClickedBlock());
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalProgress"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_PROGRESS));
} else if (dportal.getBlock2() == null) {
dportal.setBlock2(event.getClickedBlock());
dportal.setActive(true);
dportal.create();
MessageUtil.sendMessage(player, plugin.getDMessages().get("Player_PortalCreated"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_CREATED));
}
event.setCancelled(true);
}
@ -223,7 +226,7 @@ public class PlayerListener implements Listener {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
trigger.onTrigger(player);
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Leftklick"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEFT_CLICK));
}
}
@ -234,7 +237,7 @@ public class PlayerListener implements Listener {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
dPlayer.setDClass(ChatColor.stripColor(classSign.getLine(1)));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Leftklick"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEFT_CLICK));
}
return;
}
@ -274,7 +277,7 @@ public class PlayerListener implements Listener {
for (Material material : gameWorld.getConfig().getSecureObjects()) {
if (material == event.getItemDrop().getItemStack().getType()) {
event.setCancelled(true);
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Drop"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DROP));
return;
}
}
@ -403,11 +406,11 @@ public class PlayerListener implements Listener {
dPlayer.leave();
} else if (timeUntilKickOfflinePlayer > 0) {
dGroup.sendMessage(plugin.getDMessages().get("Player_Offline", dPlayer.getPlayer().getName(), "" + timeUntilKickOfflinePlayer), player);
dGroup.sendMessage(dMessages.getMessage(Messages.PLAYER_OFFLINE, dPlayer.getPlayer().getName(), "" + timeUntilKickOfflinePlayer), player);
dPlayer.setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
} else {
dGroup.sendMessage(plugin.getDMessages().get("Player_OfflineNever", dPlayer.getPlayer().getName()), player);
dGroup.sendMessage(dMessages.getMessage(Messages.PLAYER_OFFLINE_NEVER, dPlayer.getPlayer().getName()), player);
}
} else if (dPlayer.isEditing()) {
@ -463,7 +466,7 @@ public class PlayerListener implements Listener {
}
if (dGroup.getGameWorld() == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_TutorialNotExist"));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_TUTORIAL_NOT_EXIST));
continue;
}
@ -491,7 +494,7 @@ public class PlayerListener implements Listener {
String[] splittedCmd = event.getMessage().split(" ");
if ( !splittedCmd[0].equalsIgnoreCase("/dungeon") && !splittedCmd[0].equalsIgnoreCase("/dungeonsxl") && !splittedCmd[0].equalsIgnoreCase("/dxl")) {
MessageUtil.sendMessage(event.getPlayer(), plugin.getDMessages().get("Error_Cmd"));
MessageUtil.sendMessage(event.getPlayer(), dMessages.getMessage(Messages.ERROR_CMD));
event.setCancelled(true);
}
}

View File

@ -2,6 +2,7 @@ package io.github.dre2n.dungeonsxl.mob;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
import java.util.Arrays;
@ -24,6 +25,8 @@ import org.bukkit.inventory.meta.ItemMeta;
public class DMobType {
static DungeonsXL plugin = DungeonsXL.getPlugin();
private String name;
private EntityType type;
@ -116,7 +119,7 @@ public class DMobType {
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
if (type == null) {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobType", configFile.getString(mobName + ".Type")));
plugin.getLogger().info(plugin.getDMessages().getMessage(Messages.LOG_ERROR_MOBTYPE, configFile.getString(mobName + ".Type")));
continue;
}
@ -198,7 +201,7 @@ public class DMobType {
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
}
} else {
DungeonsXL.getPlugin().getLogger().info(DungeonsXL.getPlugin().getDMessages().get("Log_Error_MobEnchantment", splittedEnchantment[0]));
plugin.getLogger().info(plugin.getDMessages().getMessage(Messages.LOG_ERROR_MOB_ENCHANTMENT, splittedEnchantment[0]));
}
}
}
@ -237,8 +240,8 @@ public class DMobType {
}
}
if (DungeonsXL.getPlugin().getMainConfig().defaultDungeon != null) {
for (DMobType mobType : DungeonsXL.getPlugin().getMainConfig().defaultDungeon.getMobTypes()) {
if (plugin.getMainConfig().defaultDungeon != null) {
for (DMobType mobType : plugin.getMainConfig().defaultDungeon.getMobTypes()) {
if (mobType.name.equalsIgnoreCase(name)) {
return mobType;
}

View File

@ -4,6 +4,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -60,7 +61,7 @@ public class DGroup {
public void addPlayer(Player player) {
// Send message
for (Player groupPlayer : getPlayers()) {
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().get("Player_JoinGroup", player.getName()));
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_JOIN_GROUP, player.getName()));
}
// Add player
@ -77,7 +78,7 @@ public class DGroup {
// Send message
for (Player groupPlayer : getPlayers()) {
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().get("Player_LeftGroup", player.getName()));
MessageUtil.sendMessage(groupPlayer, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LEFT_GROUP, player.getName()));
}
// Check group

View File

@ -6,6 +6,8 @@ import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -36,6 +38,7 @@ import org.bukkit.potion.PotionEffect;
public class DPlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin();
DMessages dMessages = plugin.getDMessages();
// Variables
private Player player;
@ -59,7 +62,7 @@ public class DPlayer {
private ItemStack[] respawnArmor;
private String[] linesCopy;
private Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(getPlayer(), 45, plugin.getDMessages().get("Player_Treasures"));
private Inventory treasureInv = DungeonsXL.getPlugin().getServer().createInventory(getPlayer(), 45, dMessages.getMessage(Messages.PLAYER_TREASURES));
private double treasureMoney = 0;
private int initialLives = -1;
@ -253,7 +256,7 @@ public class DPlayer {
}
public void finishFloor(String specifiedFloor) {
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON));
isFinished = true;
DGroup dGroup = DGroup.get(getPlayer());
@ -268,7 +271,7 @@ public class DPlayer {
for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player);
if ( !dplayer.isFinished) {
MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
return;
}
}
@ -319,7 +322,7 @@ public class DPlayer {
}
public void finish() {
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_FinishedDungeon"));
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON));
isFinished = true;
DGroup dGroup = DGroup.get(getPlayer());
@ -334,7 +337,7 @@ public class DPlayer {
for (Player player : dGroup.getPlayers()) {
DPlayer dplayer = get(player);
if ( !dplayer.isFinished) {
MessageUtil.sendMessage(this.getPlayer(), plugin.getDMessages().get("Player_WaitForOtherPlayers"));
MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
return;
}
}
@ -385,14 +388,14 @@ public class DPlayer {
}
} else {
linesCopy = lines;
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_SignCopied"));
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_SIGN_COPIED));
}
} else {
String info = "" + block.getType();
if (block.getData() != 0) {
info = info + "," + block.getData();
}
MessageUtil.sendMessage(getPlayer(), plugin.getDMessages().get("Player_BlockInfo", info));
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_BLOCK_INFO, info));
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -43,7 +43,7 @@ public class CheckpointSign extends DSign {
for (DPlayer dplayer : DPlayer.get(getGameWorld().getWorld())) {
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.getPlayer(), DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
}
remove();
@ -60,7 +60,7 @@ public class CheckpointSign extends DSign {
if ( !done.contains(dplayer)) {
done.add(dplayer);
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_CheckpointReached"));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
}
}

View File

@ -2,6 +2,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.MessageUtil;
@ -68,11 +69,11 @@ public class ReadySign extends DSign {
if (getGameWorld().getSignClass().isEmpty() || dplayer.getDClass() != null) {
dplayer.ready();
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().get("Player_Ready"));
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_READY));
return;
} else {
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().get("Error_Ready"));
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.ERROR_READY));
}
}