Minor - fix incorrect javadoc and add unit test for Messages#reload

This commit is contained in:
ljacqu
2016-02-12 23:38:00 +01:00
parent 57da572b23
commit fcfe26f34d
5 changed files with 54 additions and 39 deletions
@@ -16,7 +16,7 @@ public class Messages {
private FileConfiguration configuration;
private String fileName;
private File defaultFile;
private final File defaultFile;
private FileConfiguration defaultConfiguration;
/**
@@ -91,7 +91,6 @@ public class Messages {
* Retrieve the message from the text file.
*
* @param key The message key to retrieve
*
* @return The message from the file
*/
public String retrieveSingle(MessageKey key) {
@@ -100,6 +99,8 @@ public class Messages {
/**
* Reload the messages manager.
*
* @param messagesFile The new file to load messages from
*/
public void reload(File messagesFile) {
initializeFile(messagesFile);
@@ -119,9 +120,7 @@ public class Messages {
defaultConfiguration = YamlConfiguration.loadConfiguration(defaultFile);
}
String message = defaultConfiguration.getString(code);
return (message == null)
? "Error retrieving message '" + code + "'"
: message;
return message == null ? getDefaultErrorMessage(code) : message;
}
private static String getDefaultErrorMessage(String code) {
@@ -80,18 +80,17 @@ public class AsynchronousJoin {
if (Settings.getMaxJoinPerIp > 0
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
&& !ip.equalsIgnoreCase("127.0.0.1")
&& !ip.equalsIgnoreCase("localhost")) {
if (plugin.hasJoinedIp(player.getName(), ip)) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
&& !ip.equalsIgnoreCase("localhost")
&& plugin.hasJoinedIp(player.getName(), ip)) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.kickPlayer("A player with the same IP is already in game!");
}
@Override
public void run() {
player.kickPlayer("A player with the same IP is already in game!");
}
});
return;
}
});
return;
}
final Location spawnLoc = plugin.getSpawnLocation(player);
final boolean isAuthAvailable = database.isAuthAvailable(name);
@@ -104,12 +103,9 @@ public class AsynchronousJoin {
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
if (!tpEvent.isCancelled() && player.isOnline() && tpEvent.getTo() != null
&& tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
@@ -155,25 +151,21 @@ public class AsynchronousJoin {
return;
}
if (!Settings.noTeleport) {
if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
if (!Settings.noTeleport && !needFirstSpawn() && Settings.isTeleportToSpawnEnabled
|| (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
}
}
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled() && player.isOnline() && tpEvent.getTo() != null
&& tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
});
}
});
}
}