mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Several fixes
This commit is contained in:
parent
c03fab0653
commit
284c03f029
2
pom.xml
2
pom.xml
@ -88,7 +88,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>debukkit</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
|
@ -17,7 +17,6 @@
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
@ -60,12 +59,12 @@ public class MsgCommand extends BRCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
int id = NumberUtil.parseInt(args[1]);
|
||||
int id = Integer.parseInt(args[1]);
|
||||
|
||||
WorldConfig config = editWorld.getResource().getConfig();
|
||||
|
||||
if (args.length == 2) {
|
||||
String msg = config.getMsg(id, true);
|
||||
String msg = config.getMessage(id);
|
||||
|
||||
if (msg != null) {
|
||||
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
|
||||
@ -88,7 +87,7 @@ public class MsgCommand extends BRCommand {
|
||||
|
||||
if (splitMsg.length > 1) {
|
||||
msg = splitMsg[1];
|
||||
String old = config.getMsg(id, false);
|
||||
String old = config.getMessage(id);
|
||||
if (old == null) {
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_MSG_ADDED.getMessage(String.valueOf(id)));
|
||||
|
||||
@ -96,7 +95,7 @@ public class MsgCommand extends BRCommand {
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_MSG_UPDATED.getMessage(String.valueOf(id)));
|
||||
}
|
||||
|
||||
config.setMsg(msg, id);
|
||||
config.setMessage(id, msg);
|
||||
config.save();
|
||||
|
||||
} else {
|
||||
|
@ -67,7 +67,7 @@ public enum DMessages implements Messages {
|
||||
ERROR_LEAVE_GAME("Error_LeaveGame", "&4You have to leave your current game first!"),
|
||||
ERROR_LEAVE_GROUP("Error_LeaveGroup", "&4You have to leave your group first!"),
|
||||
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_FORMAT("Error_MsgFormat", "&4Please use &6\" &4to mark the beginning and the end of the message!"),
|
||||
ERROR_MSG_NO_INT("Error_MsgNoInt", "&4The argument [id] has to include a number!"),
|
||||
ERROR_NAME_IN_USE("Error_NameInUse", "&4The name &6&v1 &4is already in use."),
|
||||
ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"),
|
||||
|
@ -60,9 +60,7 @@ public class WorldConfig extends GameRules {
|
||||
|
||||
public WorldConfig(File file) {
|
||||
this.file = file;
|
||||
|
||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
load(configFile);
|
||||
}
|
||||
|
||||
@ -78,7 +76,7 @@ public class WorldConfig extends GameRules {
|
||||
Set<String> list = configSectionMessages.getKeys(false);
|
||||
for (String messagePath : list) {
|
||||
int messageId = NumberUtil.parseInt(messagePath);
|
||||
msgs.put(messageId, configSectionMessages.getString(messagePath));
|
||||
setMessage(messageId, configSectionMessages.getString(messagePath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,11 +250,11 @@ public class WorldConfig extends GameRules {
|
||||
|
||||
List<String> secureObjectIds = new ArrayList<>();
|
||||
|
||||
for (ItemStack item : secureObjects) {
|
||||
for (ItemStack item : getSecureObjects()) {
|
||||
secureObjectIds.add(plugin.getCaliburnAPI().getItems().getCustomItemId(item));
|
||||
}
|
||||
|
||||
configFile.set("secureObjects", secureObjectIds);
|
||||
configFile.set("secureObjects", secureObjects);
|
||||
|
||||
// Invited Players
|
||||
configFile.set("invitedPlayers", invitedPlayers);
|
||||
|
@ -79,7 +79,9 @@ public class Game {
|
||||
dGroups.add(dGroup);
|
||||
started = false;
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(worldName);
|
||||
world = resource.instantiateAsGameWorld();
|
||||
if (resource != null) {
|
||||
world = resource.instantiateAsGameWorld();
|
||||
}
|
||||
dGroup.setGameWorld(world);
|
||||
fetchRules();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.game;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
import java.util.ArrayList;
|
||||
@ -240,6 +239,9 @@ public class GameRules {
|
||||
* @return the requirements
|
||||
*/
|
||||
public List<Requirement> getRequirements() {
|
||||
if (requirements == null) {
|
||||
requirements = new ArrayList<>();
|
||||
}
|
||||
return requirements;
|
||||
}
|
||||
|
||||
@ -247,6 +249,9 @@ public class GameRules {
|
||||
* @return all maps needed to be finished to play this map
|
||||
*/
|
||||
public List<String> getFinishedAll() {
|
||||
if (finishedAll == null) {
|
||||
finishedAll = new ArrayList<>();
|
||||
}
|
||||
return finishedAll;
|
||||
}
|
||||
|
||||
@ -255,6 +260,13 @@ public class GameRules {
|
||||
* least one has to be finished
|
||||
*/
|
||||
public List<String> getFinished() {
|
||||
if (finishedAll == null) {
|
||||
finishedAll = new ArrayList<>();
|
||||
}
|
||||
if (finishedOne == null) {
|
||||
finishedOne = new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> merge = new ArrayList<>();
|
||||
merge.addAll(finishedAll);
|
||||
merge.addAll(finishedOne);
|
||||
@ -265,6 +277,9 @@ public class GameRules {
|
||||
* @return the rewards
|
||||
*/
|
||||
public List<Reward> getRewards() {
|
||||
if (rewards == null) {
|
||||
rewards = new ArrayList<>();
|
||||
}
|
||||
return rewards;
|
||||
}
|
||||
|
||||
@ -273,6 +288,9 @@ public class GameRules {
|
||||
* @return the gameCommandWhitelist
|
||||
*/
|
||||
public List<String> getGameCommandWhitelist() {
|
||||
if (gameCommandWhitelist == null) {
|
||||
gameCommandWhitelist = new ArrayList<>();
|
||||
}
|
||||
return gameCommandWhitelist;
|
||||
}
|
||||
|
||||
@ -280,6 +298,9 @@ public class GameRules {
|
||||
* @return the gamePermissions
|
||||
*/
|
||||
public List<String> getGamePermissions() {
|
||||
if (gamePermissions == null) {
|
||||
gamePermissions = new ArrayList<>();
|
||||
}
|
||||
return gamePermissions;
|
||||
}
|
||||
|
||||
@ -287,28 +308,24 @@ public class GameRules {
|
||||
/**
|
||||
* @param id
|
||||
* the id of the message
|
||||
* @param returnMainConfig
|
||||
* if a default value shall be returned
|
||||
*/
|
||||
public String getMsg(int id, boolean returnMainConfig) {
|
||||
String msg = msgs.get(id);
|
||||
if (msg != null) {
|
||||
return msgs.get(id);
|
||||
public String getMessage(int id) {
|
||||
if (msgs == null) {
|
||||
msgs = new HashMap<>();
|
||||
}
|
||||
if (returnMainConfig) {
|
||||
return DungeonsXL.getInstance().getMainConfig().getDefaultWorldConfig().msgs.get(id);
|
||||
}
|
||||
|
||||
return null;
|
||||
return msgs.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* the message to set
|
||||
* @param id
|
||||
* the ID of the message
|
||||
* @param msg
|
||||
* the message to set
|
||||
*/
|
||||
public void setMsg(String msg, int id) {
|
||||
public void setMessage(int id, String msg) {
|
||||
if (msgs == null) {
|
||||
msgs = new HashMap<>();
|
||||
}
|
||||
msgs.put(id, msg);
|
||||
}
|
||||
|
||||
@ -316,6 +333,9 @@ public class GameRules {
|
||||
* @return the objects to get passed to another player of the group when this player leaves
|
||||
*/
|
||||
public List<ItemStack> getSecureObjects() {
|
||||
if (secureObjects == null) {
|
||||
secureObjects = new ArrayList<>();
|
||||
}
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
@ -450,8 +470,17 @@ public class GameRules {
|
||||
}
|
||||
|
||||
/* Misc */
|
||||
msgs = defaultValues.msgs;
|
||||
secureObjects = defaultValues.secureObjects;
|
||||
if (msgs == null) {
|
||||
msgs = defaultValues.msgs;
|
||||
} else if (defaultValues.msgs != null) {
|
||||
msgs.putAll(defaultValues.msgs);
|
||||
}
|
||||
|
||||
if (secureObjects == null) {
|
||||
secureObjects = defaultValues.secureObjects;
|
||||
} else if (defaultValues.secureObjects != null) {
|
||||
secureObjects.addAll(defaultValues.secureObjects);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,7 +139,6 @@ public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
plugin.debug.start("PlayerListener#onInteract");
|
||||
Player player = event.getPlayer();
|
||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
@ -303,7 +302,6 @@ public class PlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
plugin.debug.end("PlayerListener#onInteract", true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -32,7 +32,7 @@ public class MessageSign extends DSign {
|
||||
private DSignType type = DSignTypeDefault.MESSAGE;
|
||||
|
||||
// Variables
|
||||
private String msg;
|
||||
private String msg = "UNKNOWN MESSAGE";
|
||||
private boolean initialized;
|
||||
private CopyOnWriteArrayList<Player> done = new CopyOnWriteArrayList<>();
|
||||
|
||||
@ -52,13 +52,13 @@ public class MessageSign extends DSign {
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (!lines[1].isEmpty()) {
|
||||
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
||||
String msg = getGame().getRules().getMessage(NumberUtil.parseInt(lines[1]));
|
||||
if (msg != null) {
|
||||
this.msg = msg;
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class SoundMessageSign extends DSign {
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (!lines[1].isEmpty()) {
|
||||
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
||||
String msg = getGame().getRules().getMessage(NumberUtil.parseInt(lines[1]));
|
||||
if (msg != null) {
|
||||
this.msg = msg;
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
|
Loading…
Reference in New Issue
Block a user