mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-11 18:37:35 +01:00
Merge pull request #1428 from AuthMe/1423-cmi-support
#1423 Implement CMI spawn integration
This commit is contained in:
commit
81db4168e4
@ -1,8 +1,8 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
||||||
<!-- File auto-generated on Tue Oct 31 15:56:59 CET 2017. See docs/config/config.tpl.md -->
|
<!-- File auto-generated on Tue Nov 28 12:49:57 CET 2017. See docs/config/config.tpl.md -->
|
||||||
|
|
||||||
## AuthMe Configuration
|
## AuthMe Configuration
|
||||||
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
||||||
with which you can configure various settings. This following is the initial contents of
|
with which you can configure various settings. This following is the initial contents of
|
||||||
the generated config.yml file.
|
the generated config.yml file.
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ settings:
|
|||||||
# Hide the chat log from players who are not authenticated?
|
# Hide the chat log from players who are not authenticated?
|
||||||
hideChat: false
|
hideChat: false
|
||||||
# Allowed commands for unauthenticated players
|
# Allowed commands for unauthenticated players
|
||||||
allowCommands:
|
allowCommands:
|
||||||
- '/login'
|
- '/login'
|
||||||
- '/register'
|
- '/register'
|
||||||
- '/l'
|
- '/l'
|
||||||
@ -158,7 +158,7 @@ settings:
|
|||||||
enabled: false
|
enabled: false
|
||||||
# WorldNames where we need to force the spawn location
|
# WorldNames where we need to force the spawn location
|
||||||
# Case-sensitive!
|
# Case-sensitive!
|
||||||
worlds:
|
worlds:
|
||||||
- 'world'
|
- 'world'
|
||||||
- 'world_nether'
|
- 'world_nether'
|
||||||
- 'world_the_end'
|
- 'world_the_end'
|
||||||
@ -202,8 +202,8 @@ settings:
|
|||||||
# Should we display all other accounts from a player when he joins?
|
# Should we display all other accounts from a player when he joins?
|
||||||
# permission: /authme.admin.accounts
|
# permission: /authme.admin.accounts
|
||||||
displayOtherAccounts: true
|
displayOtherAccounts: true
|
||||||
# Spawn priority; values: authme, essentials, multiverse, default
|
# Spawn priority; values: authme, essentials, cmi, multiverse, default
|
||||||
spawnPriority: 'authme,essentials,multiverse,default'
|
spawnPriority: 'authme,essentials,cmi,multiverse,default'
|
||||||
# Maximum Login authorized by IP
|
# Maximum Login authorized by IP
|
||||||
maxLoginPerIp: 0
|
maxLoginPerIp: 0
|
||||||
# Maximum Join authorized by IP
|
# Maximum Join authorized by IP
|
||||||
@ -258,7 +258,7 @@ settings:
|
|||||||
# - '123456'
|
# - '123456'
|
||||||
# - 'password'
|
# - 'password'
|
||||||
# - 'help'
|
# - 'help'
|
||||||
unsafePasswords:
|
unsafePasswords:
|
||||||
- '123456'
|
- '123456'
|
||||||
- 'password'
|
- 'password'
|
||||||
- 'qwerty'
|
- 'qwerty'
|
||||||
@ -364,7 +364,7 @@ Email:
|
|||||||
# Delay in minute for the recall scheduler
|
# Delay in minute for the recall scheduler
|
||||||
delayRecall: 5
|
delayRecall: 5
|
||||||
# Blacklist these domains for emails
|
# Blacklist these domains for emails
|
||||||
emailBlacklisted:
|
emailBlacklisted:
|
||||||
- '10minutemail.com'
|
- '10minutemail.com'
|
||||||
# Whitelist ONLY these domains for emails
|
# Whitelist ONLY these domains for emails
|
||||||
emailWhitelisted: []
|
emailWhitelisted: []
|
||||||
@ -391,12 +391,12 @@ Protection:
|
|||||||
# Countries allowed to join the server and register. For country codes, see
|
# Countries allowed to join the server and register. For country codes, see
|
||||||
# http://dev.maxmind.com/geoip/legacy/codes/iso3166/
|
# http://dev.maxmind.com/geoip/legacy/codes/iso3166/
|
||||||
# PLEASE USE QUOTES!
|
# PLEASE USE QUOTES!
|
||||||
countries:
|
countries:
|
||||||
- 'US'
|
- 'US'
|
||||||
- 'GB'
|
- 'GB'
|
||||||
# Countries not allowed to join the server and register
|
# Countries not allowed to join the server and register
|
||||||
# PLEASE USE QUOTES!
|
# PLEASE USE QUOTES!
|
||||||
countriesBlacklist:
|
countriesBlacklist:
|
||||||
- 'A1'
|
- 'A1'
|
||||||
# Do we need to enable automatic antibot system?
|
# Do we need to enable automatic antibot system?
|
||||||
enableAntiBot: true
|
enableAntiBot: true
|
||||||
@ -555,9 +555,9 @@ Converter:
|
|||||||
password: ''
|
password: ''
|
||||||
```
|
```
|
||||||
|
|
||||||
To change settings on a running server, save your changes to config.yml and use
|
To change settings on a running server, save your changes to config.yml and use
|
||||||
`/authme reload`.
|
`/authme reload`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Tue Oct 31 15:56:59 CET 2017
|
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Tue Nov 28 12:49:57 CET 2017
|
||||||
|
@ -40,6 +40,10 @@ public class ServerListener implements Listener {
|
|||||||
if ("Essentials".equalsIgnoreCase(pluginName)) {
|
if ("Essentials".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHookService.unhookEssentials();
|
pluginHookService.unhookEssentials();
|
||||||
ConsoleLogger.info("Essentials has been disabled: unhooking");
|
ConsoleLogger.info("Essentials has been disabled: unhooking");
|
||||||
|
} else if ("CMI".equalsIgnoreCase(pluginName)) {
|
||||||
|
pluginHookService.unhookCmi();
|
||||||
|
spawnLoader.unloadCMISpawn();
|
||||||
|
ConsoleLogger.info("CMI has been disabled: unhooking");
|
||||||
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHookService.unhookMultiverse();
|
pluginHookService.unhookMultiverse();
|
||||||
ConsoleLogger.info("Multiverse-Core has been disabled: unhooking");
|
ConsoleLogger.info("Multiverse-Core has been disabled: unhooking");
|
||||||
@ -70,6 +74,9 @@ public class ServerListener implements Listener {
|
|||||||
pluginHookService.tryHookToMultiverse();
|
pluginHookService.tryHookToMultiverse();
|
||||||
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
|
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
|
||||||
spawnLoader.loadEssentialsSpawn();
|
spawnLoader.loadEssentialsSpawn();
|
||||||
|
} else if ("CMI".equalsIgnoreCase(pluginName)) {
|
||||||
|
pluginHookService.tryHookToCmi();
|
||||||
|
spawnLoader.loadCMISpawn();
|
||||||
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
||||||
protocolLibService.setup();
|
protocolLibService.setup();
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ public class PluginHookService {
|
|||||||
|
|
||||||
private final PluginManager pluginManager;
|
private final PluginManager pluginManager;
|
||||||
private Essentials essentials;
|
private Essentials essentials;
|
||||||
|
private Plugin cmi;
|
||||||
private MultiverseCore multiverse;
|
private MultiverseCore multiverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +34,7 @@ public class PluginHookService {
|
|||||||
public PluginHookService(PluginManager pluginManager) {
|
public PluginHookService(PluginManager pluginManager) {
|
||||||
this.pluginManager = pluginManager;
|
this.pluginManager = pluginManager;
|
||||||
tryHookToEssentials();
|
tryHookToEssentials();
|
||||||
|
tryHookToCmi();
|
||||||
tryHookToMultiverse();
|
tryHookToMultiverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +62,19 @@ public class PluginHookService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If CMI is hooked into, return CMI' data folder.
|
||||||
|
*
|
||||||
|
* @return The CMI data folder, or null if unavailable
|
||||||
|
*/
|
||||||
|
public File getCmiDataFolder() {
|
||||||
|
Plugin plugin = pluginManager.getPlugin("CMI");
|
||||||
|
if(plugin == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return plugin.getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the spawn of the given world as defined by Multiverse (if available).
|
* Return the spawn of the given world as defined by Multiverse (if available).
|
||||||
*
|
*
|
||||||
@ -76,10 +91,10 @@ public class PluginHookService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------
|
// ------
|
||||||
// "Is plugin available" methods
|
// "Is plugin available" methods
|
||||||
// ------
|
// ------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if we have a hook to Essentials, false otherwise
|
* @return true if we have a hook to Essentials, false otherwise
|
||||||
*/
|
*/
|
||||||
@ -87,6 +102,13 @@ public class PluginHookService {
|
|||||||
return essentials != null;
|
return essentials != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if we have a hook to CMI, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isCmiAvailable() {
|
||||||
|
return cmi != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if we have a hook to Multiverse, false otherwise
|
* @return true if we have a hook to Multiverse, false otherwise
|
||||||
*/
|
*/
|
||||||
@ -109,6 +131,17 @@ public class PluginHookService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to create a hook into CMI.
|
||||||
|
*/
|
||||||
|
public void tryHookToCmi() {
|
||||||
|
try {
|
||||||
|
cmi = getPlugin(pluginManager, "CMI", Plugin.class);
|
||||||
|
} catch (Exception | NoClassDefFoundError ignored) {
|
||||||
|
cmi = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create a hook into Multiverse.
|
* Attempts to create a hook into Multiverse.
|
||||||
*/
|
*/
|
||||||
@ -123,6 +156,7 @@ public class PluginHookService {
|
|||||||
// ------
|
// ------
|
||||||
// Unhook methods
|
// Unhook methods
|
||||||
// ------
|
// ------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unhooks from Essentials.
|
* Unhooks from Essentials.
|
||||||
*/
|
*/
|
||||||
@ -130,6 +164,13 @@ public class PluginHookService {
|
|||||||
essentials = null;
|
essentials = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unhooks from CMI.
|
||||||
|
*/
|
||||||
|
public void unhookCmi() {
|
||||||
|
cmi = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unhooks from Multiverse.
|
* Unhooks from Multiverse.
|
||||||
*/
|
*/
|
||||||
@ -140,6 +181,7 @@ public class PluginHookService {
|
|||||||
// ------
|
// ------
|
||||||
// Helpers
|
// Helpers
|
||||||
// ------
|
// ------
|
||||||
|
|
||||||
private static <T extends Plugin> T getPlugin(PluginManager pluginManager, String name, Class<T> clazz)
|
private static <T extends Plugin> T getPlugin(PluginManager pluginManager, String name, Class<T> clazz)
|
||||||
throws Exception, NoClassDefFoundError {
|
throws Exception, NoClassDefFoundError {
|
||||||
if (pluginManager.isPluginEnabled(name)) {
|
if (pluginManager.isPluginEnabled(name)) {
|
||||||
@ -150,5 +192,4 @@ public class PluginHookService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
private FileConfiguration authMeConfiguration;
|
private FileConfiguration authMeConfiguration;
|
||||||
private String[] spawnPriority;
|
private String[] spawnPriority;
|
||||||
private Location essentialsSpawn;
|
private Location essentialsSpawn;
|
||||||
|
private Location cmiSpawn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -130,6 +131,32 @@ public class SpawnLoader implements Reloadable {
|
|||||||
essentialsSpawn = null;
|
essentialsSpawn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the spawn point defined in CMI.
|
||||||
|
*/
|
||||||
|
public void loadCMISpawn() {
|
||||||
|
File cmiFolder = pluginHookService.getCmiDataFolder();
|
||||||
|
if (cmiFolder == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File cmiConfig = new File(cmiFolder, "config.yml");
|
||||||
|
if (cmiConfig.exists()) {
|
||||||
|
cmiSpawn = getLocationFromConfigurationUpper(
|
||||||
|
YamlConfiguration.loadConfiguration(cmiConfig), "Spawn.Main");
|
||||||
|
} else {
|
||||||
|
cmiSpawn = null;
|
||||||
|
ConsoleLogger.info("CMI config file not found: '" + cmiConfig.getAbsolutePath() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unset the spawn point defined in CMI.
|
||||||
|
*/
|
||||||
|
public void unloadCMISpawn() {
|
||||||
|
cmiSpawn = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the spawn location for the given player. The source of the spawn location varies
|
* Return the spawn location for the given player. The source of the spawn location varies
|
||||||
* depending on the spawn priority setting.
|
* depending on the spawn priority setting.
|
||||||
@ -162,6 +189,9 @@ public class SpawnLoader implements Reloadable {
|
|||||||
case "essentials":
|
case "essentials":
|
||||||
spawnLoc = essentialsSpawn;
|
spawnLoc = essentialsSpawn;
|
||||||
break;
|
break;
|
||||||
|
case "cmi":
|
||||||
|
spawnLoc = cmiSpawn;
|
||||||
|
break;
|
||||||
case "authme":
|
case "authme":
|
||||||
spawnLoc = getSpawn();
|
spawnLoc = getSpawn();
|
||||||
break;
|
break;
|
||||||
@ -242,6 +272,28 @@ public class SpawnLoader implements Reloadable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a {@link Location} object from the given path in the file configuration.
|
||||||
|
*
|
||||||
|
* @param configuration The file configuration to read from
|
||||||
|
* @param pathPrefix The path to get the spawn point from
|
||||||
|
*
|
||||||
|
* @return Location corresponding to the values in the path
|
||||||
|
*/
|
||||||
|
private static Location getLocationFromConfigurationUpper(FileConfiguration configuration, String pathPrefix) {
|
||||||
|
if (containsAllSpawnFieldsUpper(configuration, pathPrefix)) {
|
||||||
|
String prefix = pathPrefix + ".";
|
||||||
|
String worldName = configuration.getString(prefix + "World");
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if (!StringUtils.isEmpty(worldName) && world != null) {
|
||||||
|
return new Location(world, configuration.getDouble(prefix + "X"),
|
||||||
|
configuration.getDouble(prefix + "Y"), configuration.getDouble(prefix + "Z"),
|
||||||
|
getFloat(configuration, prefix + "Yaw"), getFloat(configuration, prefix + "Pitch"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the file configuration contains all fields necessary to define a spawn
|
* Return whether the file configuration contains all fields necessary to define a spawn
|
||||||
* under the given path.
|
* under the given path.
|
||||||
@ -261,6 +313,25 @@ public class SpawnLoader implements Reloadable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether the file configuration contains all fields necessary to define a spawn
|
||||||
|
* under the given path.
|
||||||
|
*
|
||||||
|
* @param configuration The file configuration to use
|
||||||
|
* @param pathPrefix The path to verify
|
||||||
|
*
|
||||||
|
* @return True if all spawn fields are present, false otherwise
|
||||||
|
*/
|
||||||
|
private static boolean containsAllSpawnFieldsUpper(FileConfiguration configuration, String pathPrefix) {
|
||||||
|
String[] fields = {"World", "X", "Y", "Z", "Yaw", "Pitch"};
|
||||||
|
for (String field : fields) {
|
||||||
|
if (!configuration.contains(pathPrefix + "." + field)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a property as a float from the given file configuration.
|
* Retrieve a property as a float from the given file configuration.
|
||||||
*
|
*
|
||||||
@ -274,4 +345,5 @@ public class SpawnLoader implements Reloadable {
|
|||||||
// This behavior is consistent with FileConfiguration#getDouble
|
// This behavior is consistent with FileConfiguration#getDouble
|
||||||
return (value instanceof Number) ? ((Number) value).floatValue() : 0;
|
return (value instanceof Number) ? ((Number) value).floatValue() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,9 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||||||
public static final Property<Boolean> DISPLAY_OTHER_ACCOUNTS =
|
public static final Property<Boolean> DISPLAY_OTHER_ACCOUNTS =
|
||||||
newProperty("settings.restrictions.displayOtherAccounts", true);
|
newProperty("settings.restrictions.displayOtherAccounts", true);
|
||||||
|
|
||||||
@Comment("Spawn priority; values: authme, essentials, multiverse, default")
|
@Comment("Spawn priority; values: authme, essentials, cmi, multiverse, default")
|
||||||
public static final Property<String> SPAWN_PRIORITY =
|
public static final Property<String> SPAWN_PRIORITY =
|
||||||
newProperty("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
|
newProperty("settings.restrictions.spawnPriority", "authme,essentials,cmi,multiverse,default");
|
||||||
|
|
||||||
@Comment("Maximum Login authorized by IP")
|
@Comment("Maximum Login authorized by IP")
|
||||||
public static final Property<Integer> MAX_LOGIN_PER_IP =
|
public static final Property<Integer> MAX_LOGIN_PER_IP =
|
||||||
|
@ -31,6 +31,7 @@ public class ServerListenerTest {
|
|||||||
|
|
||||||
private static final String ESSENTIALS = "Essentials";
|
private static final String ESSENTIALS = "Essentials";
|
||||||
private static final String ESSENTIALS_SPAWN = "EssentialsSpawn";
|
private static final String ESSENTIALS_SPAWN = "EssentialsSpawn";
|
||||||
|
private static final String CMI = "CMI";
|
||||||
private static final String MULTIVERSE = "Multiverse-Core";
|
private static final String MULTIVERSE = "Multiverse-Core";
|
||||||
private static final String PROTOCOL_LIB = "ProtocolLib";
|
private static final String PROTOCOL_LIB = "ProtocolLib";
|
||||||
|
|
||||||
@ -58,6 +59,10 @@ public class ServerListenerTest {
|
|||||||
public void shouldForwardPluginNameOnEnable() {
|
public void shouldForwardPluginNameOnEnable() {
|
||||||
checkEnableHandling(ESSENTIALS, () -> verify(pluginHookService).tryHookToEssentials());
|
checkEnableHandling(ESSENTIALS, () -> verify(pluginHookService).tryHookToEssentials());
|
||||||
checkEnableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).loadEssentialsSpawn());
|
checkEnableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).loadEssentialsSpawn());
|
||||||
|
checkEnableHandling(CMI, () -> {
|
||||||
|
verify(pluginHookService).tryHookToCmi();
|
||||||
|
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());
|
||||||
checkEnableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader));
|
checkEnableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader));
|
||||||
@ -67,6 +72,10 @@ public class ServerListenerTest {
|
|||||||
public void shouldForwardPluginNameOnDisable() {
|
public void shouldForwardPluginNameOnDisable() {
|
||||||
checkDisableHandling(ESSENTIALS, () -> verify(pluginHookService).unhookEssentials());
|
checkDisableHandling(ESSENTIALS, () -> verify(pluginHookService).unhookEssentials());
|
||||||
checkDisableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).unloadEssentialsSpawn());
|
checkDisableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).unloadEssentialsSpawn());
|
||||||
|
checkDisableHandling(CMI, () -> {
|
||||||
|
verify(pluginHookService).unhookCmi();
|
||||||
|
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());
|
||||||
checkDisableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader));
|
checkDisableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader));
|
||||||
|
@ -35,6 +35,8 @@ public class PluginHookServiceTest {
|
|||||||
|
|
||||||
/** The plugin name of Essentials. */
|
/** The plugin name of Essentials. */
|
||||||
private static final String ESSENTIALS = "Essentials";
|
private static final String ESSENTIALS = "Essentials";
|
||||||
|
/** The plugin name of CMI. */
|
||||||
|
private static final String CMI = "CMI";
|
||||||
/** The plugin name of Multiverse-Core. */
|
/** The plugin name of Multiverse-Core. */
|
||||||
private static final String MULTIVERSE = "Multiverse-Core";
|
private static final String MULTIVERSE = "Multiverse-Core";
|
||||||
|
|
||||||
@ -71,6 +73,19 @@ public class PluginHookServiceTest {
|
|||||||
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(true));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldHookIntoCmiAtInitialization() {
|
||||||
|
// given
|
||||||
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
|
setPluginAvailable(pluginManager, CMI, Plugin.class);
|
||||||
|
|
||||||
|
// when
|
||||||
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(pluginHookService.isCmiAvailable(), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldHookIntoMultiverseAtInitialization() {
|
public void shouldHookIntoMultiverseAtInitialization() {
|
||||||
// given
|
// given
|
||||||
@ -175,6 +190,7 @@ public class PluginHookServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
|
||||||
|
assertThat(pluginHookService.isCmiAvailable(), equalTo(false));
|
||||||
assertThat(pluginHookService.isMultiverseAvailable(), equalTo(false));
|
assertThat(pluginHookService.isMultiverseAvailable(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user