#1423 Fix ignored review remarks
This commit is contained in:
parent
17eb7acf4d
commit
c784fc7f2e
@ -42,7 +42,7 @@ public class ServerListener implements Listener {
|
|||||||
ConsoleLogger.info("Essentials has been disabled: unhooking");
|
ConsoleLogger.info("Essentials has been disabled: unhooking");
|
||||||
} else if ("CMI".equalsIgnoreCase(pluginName)) {
|
} else if ("CMI".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHookService.unhookCmi();
|
pluginHookService.unhookCmi();
|
||||||
spawnLoader.unloadCMISpawn();
|
spawnLoader.unloadCmiSpawn();
|
||||||
ConsoleLogger.info("CMI has been disabled: unhooking");
|
ConsoleLogger.info("CMI has been disabled: unhooking");
|
||||||
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHookService.unhookMultiverse();
|
pluginHookService.unhookMultiverse();
|
||||||
@ -76,7 +76,7 @@ public class ServerListener implements Listener {
|
|||||||
spawnLoader.loadEssentialsSpawn();
|
spawnLoader.loadEssentialsSpawn();
|
||||||
} else if ("CMI".equalsIgnoreCase(pluginName)) {
|
} else if ("CMI".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHookService.tryHookToCmi();
|
pluginHookService.tryHookToCmi();
|
||||||
spawnLoader.loadCMISpawn();
|
spawnLoader.loadCmiSpawn();
|
||||||
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
||||||
protocolLibService.setup();
|
protocolLibService.setup();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,7 +134,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
/**
|
/**
|
||||||
* Load the spawn point defined in CMI.
|
* Load the spawn point defined in CMI.
|
||||||
*/
|
*/
|
||||||
public void loadCMISpawn() {
|
public void loadCmiSpawn() {
|
||||||
File cmiFolder = pluginHookService.getCmiDataFolder();
|
File cmiFolder = pluginHookService.getCmiDataFolder();
|
||||||
if (cmiFolder == null) {
|
if (cmiFolder == null) {
|
||||||
return;
|
return;
|
||||||
@ -142,8 +142,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
|
|
||||||
File cmiConfig = new File(cmiFolder, "config.yml");
|
File cmiConfig = new File(cmiFolder, "config.yml");
|
||||||
if (cmiConfig.exists()) {
|
if (cmiConfig.exists()) {
|
||||||
cmiSpawn = getLocationFromConfigurationUpper(
|
cmiSpawn = getLocationFromCmiConfiguration(YamlConfiguration.loadConfiguration(cmiConfig));
|
||||||
YamlConfiguration.loadConfiguration(cmiConfig), "Spawn.Main");
|
|
||||||
} else {
|
} else {
|
||||||
cmiSpawn = null;
|
cmiSpawn = null;
|
||||||
ConsoleLogger.info("CMI config file not found: '" + cmiConfig.getAbsolutePath() + "'");
|
ConsoleLogger.info("CMI config file not found: '" + cmiConfig.getAbsolutePath() + "'");
|
||||||
@ -153,7 +152,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
/**
|
/**
|
||||||
* Unset the spawn point defined in CMI.
|
* Unset the spawn point defined in CMI.
|
||||||
*/
|
*/
|
||||||
public void unloadCMISpawn() {
|
public void unloadCmiSpawn() {
|
||||||
cmiSpawn = null;
|
cmiSpawn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,15 +272,15 @@ public class SpawnLoader implements Reloadable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a {@link Location} object from the given path in the file configuration.
|
* Build a {@link Location} object based on the CMI configuration.
|
||||||
*
|
*
|
||||||
* @param configuration The file configuration to read from
|
* @param configuration The CMI file configuration to read from
|
||||||
* @param pathPrefix The path to get the spawn point from
|
|
||||||
*
|
*
|
||||||
* @return Location corresponding to the values in the path
|
* @return Location corresponding to the values in the path
|
||||||
*/
|
*/
|
||||||
private static Location getLocationFromConfigurationUpper(FileConfiguration configuration, String pathPrefix) {
|
private static Location getLocationFromCmiConfiguration(FileConfiguration configuration) {
|
||||||
if (containsAllSpawnFieldsUpper(configuration, pathPrefix)) {
|
final String pathPrefix = "Spawn.Main";
|
||||||
|
if (isLocationCompleteInCmiConfig(configuration, pathPrefix)) {
|
||||||
String prefix = pathPrefix + ".";
|
String prefix = pathPrefix + ".";
|
||||||
String worldName = configuration.getString(prefix + "World");
|
String worldName = configuration.getString(prefix + "World");
|
||||||
World world = Bukkit.getWorld(worldName);
|
World world = Bukkit.getWorld(worldName);
|
||||||
@ -314,18 +313,17 @@ public class SpawnLoader implements Reloadable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the file configuration contains all fields necessary to define a spawn
|
* Return whether the CMI file configuration contains all spawn fields under the given path.
|
||||||
* under the given path.
|
|
||||||
*
|
*
|
||||||
* @param configuration The file configuration to use
|
* @param cmiConfiguration The file configuration from CMI
|
||||||
* @param pathPrefix The path to verify
|
* @param pathPrefix The path to verify
|
||||||
*
|
*
|
||||||
* @return True if all spawn fields are present, false otherwise
|
* @return True if all spawn fields are present, false otherwise
|
||||||
*/
|
*/
|
||||||
private static boolean containsAllSpawnFieldsUpper(FileConfiguration configuration, String pathPrefix) {
|
private static boolean isLocationCompleteInCmiConfig(FileConfiguration cmiConfiguration, String pathPrefix) {
|
||||||
String[] fields = {"World", "X", "Y", "Z", "Yaw", "Pitch"};
|
String[] fields = {"World", "X", "Y", "Z", "Yaw", "Pitch"};
|
||||||
for (String field : fields) {
|
for (String field : fields) {
|
||||||
if (!configuration.contains(pathPrefix + "." + field)) {
|
if (!cmiConfiguration.contains(pathPrefix + "." + field)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class ServerListenerTest {
|
|||||||
checkEnableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).loadEssentialsSpawn());
|
checkEnableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).loadEssentialsSpawn());
|
||||||
checkEnableHandling(CMI, () -> {
|
checkEnableHandling(CMI, () -> {
|
||||||
verify(pluginHookService).tryHookToCmi();
|
verify(pluginHookService).tryHookToCmi();
|
||||||
verify(spawnLoader).loadCMISpawn();
|
verify(spawnLoader).loadCmiSpawn();
|
||||||
});
|
});
|
||||||
checkEnableHandling(MULTIVERSE, () -> verify(pluginHookService).tryHookToMultiverse());
|
checkEnableHandling(MULTIVERSE, () -> verify(pluginHookService).tryHookToMultiverse());
|
||||||
checkEnableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).setup());
|
checkEnableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).setup());
|
||||||
@ -74,7 +74,7 @@ public class ServerListenerTest {
|
|||||||
checkDisableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).unloadEssentialsSpawn());
|
checkDisableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).unloadEssentialsSpawn());
|
||||||
checkDisableHandling(CMI, () -> {
|
checkDisableHandling(CMI, () -> {
|
||||||
verify(pluginHookService).unhookCmi();
|
verify(pluginHookService).unhookCmi();
|
||||||
verify(spawnLoader).unloadCMISpawn();
|
verify(spawnLoader).unloadCmiSpawn();
|
||||||
});
|
});
|
||||||
checkDisableHandling(MULTIVERSE, () -> verify(pluginHookService).unhookMultiverse());
|
checkDisableHandling(MULTIVERSE, () -> verify(pluginHookService).unhookMultiverse());
|
||||||
checkDisableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).disable());
|
checkDisableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).disable());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user