mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-24 21:02:48 +02:00
Removed MVdWPlaceholderAPIHook and all related methods
It was increasingly causing issues, ranging from long start times, unreliability with some of our placeholders, to much more... There's a way for MVdWPAPI users to get PAPI's placeholders, so they should definitely use that instead.
This commit is contained in:
parent
2c7316ba21
commit
962b7d734a
10
pom.xml
10
pom.xml
@ -74,7 +74,6 @@
|
|||||||
<bstats.version>1.7</bstats.version>
|
<bstats.version>1.7</bstats.version>
|
||||||
<vault.version>1.7</vault.version>
|
<vault.version>1.7</vault.version>
|
||||||
<placeholderapi.version>2.10.5</placeholderapi.version>
|
<placeholderapi.version>2.10.5</placeholderapi.version>
|
||||||
<mvdwplaceholderapi.version>master-SNAPSHOT</mvdwplaceholderapi.version>
|
|
||||||
<githubapi.version>d5f5e0bbd8</githubapi.version>
|
<githubapi.version>d5f5e0bbd8</githubapi.version>
|
||||||
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
|
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
|
||||||
<worldedit.version>7.0.0</worldedit.version>
|
<worldedit.version>7.0.0</worldedit.version>
|
||||||
@ -250,15 +249,6 @@
|
|||||||
<version>${placeholderapi.version}</version>
|
<version>${placeholderapi.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<!-- We have to use a forked version of this api because Maxim
|
|
||||||
had the brilliant idea to make one of the dependencies rely on an illegal
|
|
||||||
artifact thus making its repository unusable. -->
|
|
||||||
<groupId>com.github.BentoBoxWorld</groupId>
|
|
||||||
<artifactId>MVdWPlaceholderAPI</artifactId>
|
|
||||||
<version>${mvdwplaceholderapi.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- Hooks -->
|
<!-- Hooks -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
|
@ -24,7 +24,6 @@ import world.bentobox.bentobox.hooks.DynmapHook;
|
|||||||
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
|
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
|
||||||
import world.bentobox.bentobox.hooks.VaultHook;
|
import world.bentobox.bentobox.hooks.VaultHook;
|
||||||
import world.bentobox.bentobox.hooks.WorldEditHook;
|
import world.bentobox.bentobox.hooks.WorldEditHook;
|
||||||
import world.bentobox.bentobox.hooks.placeholders.MVdWPlaceholderAPIHook;
|
|
||||||
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
||||||
import world.bentobox.bentobox.listeners.BannedCommands;
|
import world.bentobox.bentobox.listeners.BannedCommands;
|
||||||
import world.bentobox.bentobox.listeners.BlockEndDragon;
|
import world.bentobox.bentobox.listeners.BlockEndDragon;
|
||||||
@ -169,7 +168,6 @@ public class BentoBox extends JavaPlugin {
|
|||||||
Bukkit.getScheduler().runTask(instance, () -> {
|
Bukkit.getScheduler().runTask(instance, () -> {
|
||||||
final long enableStart = System.currentTimeMillis();
|
final long enableStart = System.currentTimeMillis();
|
||||||
hooksManager.registerHook(new PlaceholderAPIHook());
|
hooksManager.registerHook(new PlaceholderAPIHook());
|
||||||
hooksManager.registerHook(new MVdWPlaceholderAPIHook());
|
|
||||||
// Setup the Placeholders manager
|
// Setup the Placeholders manager
|
||||||
placeholdersManager = new PlaceholdersManager(this);
|
placeholdersManager = new PlaceholdersManager(this);
|
||||||
|
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
package world.bentobox.bentobox.hooks.placeholders;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
|
||||||
|
|
||||||
import be.maximvdw.placeholderapi.PlaceholderAPI;
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
|
||||||
import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
|
|
||||||
import world.bentobox.bentobox.api.user.User;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides interfacing needed to register and get placeholders from MVdWPlaceholderAPI.
|
|
||||||
* @author Poslovitch
|
|
||||||
* @since 1.5.0
|
|
||||||
*/
|
|
||||||
public class MVdWPlaceholderAPIHook extends PlaceholderHook {
|
|
||||||
|
|
||||||
public MVdWPlaceholderAPIHook() {
|
|
||||||
super("MVdWPlaceholderAPI");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hook() {
|
|
||||||
return true; // There are no special checks to run when hooking into MVdWPlaceholderAPI.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFailureCause() {
|
|
||||||
return "the version of MVdWPlaceholderAPI you're using is incompatible with this hook";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void registerPlaceholder(@NonNull String placeholder, @NonNull PlaceholderReplacer replacer) {
|
|
||||||
PlaceholderAPI.registerPlaceholder(BentoBox.getInstance(), "bentobox_" + placeholder,
|
|
||||||
event -> replacer.onReplace(User.getInstance(event.getPlayer())));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void registerPlaceholder(@NonNull Addon addon, @NonNull String placeholder, @NonNull PlaceholderReplacer replacer) {
|
|
||||||
PlaceholderAPI.registerPlaceholder(BentoBox.getInstance(), addon.getDescription().getName().toLowerCase() + "_" + placeholder,
|
|
||||||
event -> replacer.onReplace(User.getInstance(event.getPlayer())));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
* <b>This is not supported by MVdWPlaceholderAPI. #HighQualityContent.</b>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void unregisterPlaceholder(@NonNull String placeholder) {
|
|
||||||
// Do nothing: not supported by MVdW. #HighQualityContent
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
* <b>This is not supported by MVdWPlaceholderAPI. #HighQualityContent.</b>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void unregisterPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
|
|
||||||
// Do nothing: not supported by MVdW. #HighQualityContent
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
* <b>This is not supported by MVdWPlaceholderAPI. #HighQualityContent.</b>
|
|
||||||
* As a result, this will <b>always return {@code false}</b>.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
|
|
||||||
return false; // Do nothing: not supported by MVdW. #HighQualityContent
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@NonNull
|
|
||||||
public String replacePlaceholders(@NonNull Player player, @NonNull String string) {
|
|
||||||
return PlaceholderAPI.replacePlaceholders(player, string);
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,6 @@ import world.bentobox.bentobox.BentoBox;
|
|||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
|
import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
|
||||||
import world.bentobox.bentobox.hooks.placeholders.MVdWPlaceholderAPIHook;
|
|
||||||
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
||||||
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
||||||
|
|
||||||
@ -37,8 +36,6 @@ public class PlaceholdersManager {
|
|||||||
public void registerPlaceholder(@NonNull String placeholder, @NonNull PlaceholderReplacer replacer) {
|
public void registerPlaceholder(@NonNull String placeholder, @NonNull PlaceholderReplacer replacer) {
|
||||||
// Register it in PlaceholderAPI
|
// Register it in PlaceholderAPI
|
||||||
getPlaceholderAPIHook().ifPresent(hook -> hook.registerPlaceholder(placeholder, replacer));
|
getPlaceholderAPIHook().ifPresent(hook -> hook.registerPlaceholder(placeholder, replacer));
|
||||||
// Register it in MVdWPlaceholderAPI
|
|
||||||
getMVdWPlaceholderAPIHook().ifPresent(hook -> hook.registerPlaceholder(placeholder, replacer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,8 +53,6 @@ public class PlaceholdersManager {
|
|||||||
}
|
}
|
||||||
// Register it in PlaceholderAPI
|
// Register it in PlaceholderAPI
|
||||||
getPlaceholderAPIHook().ifPresent(hook -> hook.registerPlaceholder(addon, placeholder, replacer));
|
getPlaceholderAPIHook().ifPresent(hook -> hook.registerPlaceholder(addon, placeholder, replacer));
|
||||||
// Register it in MVdWPlaceholderAPI
|
|
||||||
getMVdWPlaceholderAPIHook().ifPresent(hook -> hook.registerPlaceholder(addon, placeholder, replacer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +75,6 @@ public class PlaceholdersManager {
|
|||||||
public void unregisterPlaceholder(@NonNull String placeholder) {
|
public void unregisterPlaceholder(@NonNull String placeholder) {
|
||||||
// Unregister it from PlaceholderAPI
|
// Unregister it from PlaceholderAPI
|
||||||
getPlaceholderAPIHook().ifPresent(hook -> hook.unregisterPlaceholder(placeholder));
|
getPlaceholderAPIHook().ifPresent(hook -> hook.unregisterPlaceholder(placeholder));
|
||||||
// Not supported by MVdW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +91,6 @@ public class PlaceholdersManager {
|
|||||||
}
|
}
|
||||||
// Unregister it from PlaceholderAPI
|
// Unregister it from PlaceholderAPI
|
||||||
getPlaceholderAPIHook().ifPresent(hook -> hook.unregisterPlaceholder(addon, placeholder));
|
getPlaceholderAPIHook().ifPresent(hook -> hook.unregisterPlaceholder(addon, placeholder));
|
||||||
// Not supported by MVdW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,16 +103,6 @@ public class PlaceholdersManager {
|
|||||||
return plugin.getHooks().getHook("PlaceholderAPI").map(hook -> (PlaceholderAPIHook) hook);
|
return plugin.getHooks().getHook("PlaceholderAPI").map(hook -> (PlaceholderAPIHook) hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an Optional containing the MVdWPlaceholderAPIHook instance, or an empty Optional otherwise.
|
|
||||||
* @return Optional containing the MVdWPlaceholderAPIHook instance or an empty Optional otherwise.
|
|
||||||
* @since 1.5.0
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
private Optional<MVdWPlaceholderAPIHook> getMVdWPlaceholderAPIHook() {
|
|
||||||
return plugin.getHooks().getHook("MVdWPlaceholderAPI").map(hook -> (MVdWPlaceholderAPIHook) hook);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a placeholder with this name is already registered
|
* Checks if a placeholder with this name is already registered
|
||||||
* @param addon the addon, not null
|
* @param addon the addon, not null
|
||||||
@ -128,7 +111,6 @@ public class PlaceholdersManager {
|
|||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
|
public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
|
||||||
// MVdW will always return false
|
|
||||||
return getPlaceholderAPIHook().map(h -> h.isPlaceholder(addon, placeholder)).orElse(false);
|
return getPlaceholderAPIHook().map(h -> h.isPlaceholder(addon, placeholder)).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,12 +126,6 @@ public class PlaceholdersManager {
|
|||||||
if (papi.isPresent()) {
|
if (papi.isPresent()) {
|
||||||
string = papi.get().replacePlaceholders(player, string);
|
string = papi.get().replacePlaceholders(player, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<MVdWPlaceholderAPIHook> mvdw = getMVdWPlaceholderAPIHook();
|
|
||||||
if (mvdw.isPresent()) {
|
|
||||||
string = mvdw.get().replacePlaceholders(player, string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ load: STARTUP
|
|||||||
|
|
||||||
loadbefore: [Multiverse-Core, Residence]
|
loadbefore: [Multiverse-Core, Residence]
|
||||||
|
|
||||||
softdepend: [Vault, PlaceholderAPI, MVdWPlaceholderAPI, dynmap, WorldEdit, WorldBorderAPI]
|
softdepend: [Vault, PlaceholderAPI, dynmap, WorldEdit, WorldBorderAPI]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
bentobox.admin:
|
bentobox.admin:
|
||||||
|
@ -23,7 +23,6 @@ import world.bentobox.bentobox.BentoBox;
|
|||||||
import world.bentobox.bentobox.api.addons.AddonDescription;
|
import world.bentobox.bentobox.api.addons.AddonDescription;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
import world.bentobox.bentobox.api.hooks.Hook;
|
import world.bentobox.bentobox.api.hooks.Hook;
|
||||||
import world.bentobox.bentobox.hooks.placeholders.MVdWPlaceholderAPIHook;
|
|
||||||
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
||||||
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
||||||
|
|
||||||
@ -44,8 +43,6 @@ public class PlaceholdersManagerTest {
|
|||||||
private HooksManager hm;
|
private HooksManager hm;
|
||||||
@Mock
|
@Mock
|
||||||
private PlaceholderAPIHook hook;
|
private PlaceholderAPIHook hook;
|
||||||
@Mock
|
|
||||||
private MVdWPlaceholderAPIHook hook2;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@ -63,8 +60,6 @@ public class PlaceholdersManagerTest {
|
|||||||
Optional<Hook> optionalHook = Optional.of(hook);
|
Optional<Hook> optionalHook = Optional.of(hook);
|
||||||
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
|
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
|
||||||
when(hook.isPlaceholder(any(), any())).thenReturn(false);
|
when(hook.isPlaceholder(any(), any())).thenReturn(false);
|
||||||
Optional<Hook> optionalHook2 = Optional.of(hook2);
|
|
||||||
when(hm.getHook(eq("MVdWPlaceholderAPI"))).thenReturn(optionalHook2);
|
|
||||||
|
|
||||||
// Placeholder manager
|
// Placeholder manager
|
||||||
pm = new PlaceholdersManager(plugin);
|
pm = new PlaceholdersManager(plugin);
|
||||||
@ -82,7 +77,6 @@ public class PlaceholdersManagerTest {
|
|||||||
public void testRegisterGameModePlaceholdersAllDefaults() {
|
public void testRegisterGameModePlaceholdersAllDefaults() {
|
||||||
pm.registerDefaultPlaceholders(addon);
|
pm.registerDefaultPlaceholders(addon);
|
||||||
verify(hook, times(GameModePlaceholder.values().length)).registerPlaceholder(any(), anyString(), any());
|
verify(hook, times(GameModePlaceholder.values().length)).registerPlaceholder(any(), anyString(), any());
|
||||||
verify(hook2, times(GameModePlaceholder.values().length)).registerPlaceholder(any(), anyString(), any());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user