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:
Florian CUNY 2020-04-04 15:38:29 +02:00
parent 2c7316ba21
commit 962b7d734a
6 changed files with 1 additions and 130 deletions

10
pom.xml
View File

@ -74,7 +74,6 @@
<bstats.version>1.7</bstats.version>
<vault.version>1.7</vault.version>
<placeholderapi.version>2.10.5</placeholderapi.version>
<mvdwplaceholderapi.version>master-SNAPSHOT</mvdwplaceholderapi.version>
<githubapi.version>d5f5e0bbd8</githubapi.version>
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
<worldedit.version>7.0.0</worldedit.version>
@ -250,15 +249,6 @@
<version>${placeholderapi.version}</version>
<scope>provided</scope>
</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 -->
<dependency>
<groupId>us.dynmap</groupId>

View File

@ -24,7 +24,6 @@ import world.bentobox.bentobox.hooks.DynmapHook;
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
import world.bentobox.bentobox.hooks.VaultHook;
import world.bentobox.bentobox.hooks.WorldEditHook;
import world.bentobox.bentobox.hooks.placeholders.MVdWPlaceholderAPIHook;
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
import world.bentobox.bentobox.listeners.BannedCommands;
import world.bentobox.bentobox.listeners.BlockEndDragon;
@ -169,7 +168,6 @@ public class BentoBox extends JavaPlugin {
Bukkit.getScheduler().runTask(instance, () -> {
final long enableStart = System.currentTimeMillis();
hooksManager.registerHook(new PlaceholderAPIHook());
hooksManager.registerHook(new MVdWPlaceholderAPIHook());
// Setup the Placeholders manager
placeholdersManager = new PlaceholdersManager(this);

View File

@ -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);
}
}

View File

@ -11,7 +11,6 @@ import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
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.lists.GameModePlaceholder;
@ -37,8 +36,6 @@ public class PlaceholdersManager {
public void registerPlaceholder(@NonNull String placeholder, @NonNull PlaceholderReplacer replacer) {
// Register it in PlaceholderAPI
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
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) {
// Unregister it from PlaceholderAPI
getPlaceholderAPIHook().ifPresent(hook -> hook.unregisterPlaceholder(placeholder));
// Not supported by MVdW
}
/**
@ -97,7 +91,6 @@ public class PlaceholdersManager {
}
// Unregister it from PlaceholderAPI
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);
}
/**
* 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
* @param addon the addon, not null
@ -128,7 +111,6 @@ public class PlaceholdersManager {
* @since 1.4.0
*/
public boolean isPlaceholder(@NonNull Addon addon, @NonNull String placeholder) {
// MVdW will always return false
return getPlaceholderAPIHook().map(h -> h.isPlaceholder(addon, placeholder)).orElse(false);
}
@ -144,12 +126,6 @@ public class PlaceholdersManager {
if (papi.isPresent()) {
string = papi.get().replacePlaceholders(player, string);
}
Optional<MVdWPlaceholderAPIHook> mvdw = getMVdWPlaceholderAPIHook();
if (mvdw.isPresent()) {
string = mvdw.get().replacePlaceholders(player, string);
}
return string;
}
}

View File

@ -11,7 +11,7 @@ load: STARTUP
loadbefore: [Multiverse-Core, Residence]
softdepend: [Vault, PlaceholderAPI, MVdWPlaceholderAPI, dynmap, WorldEdit, WorldBorderAPI]
softdepend: [Vault, PlaceholderAPI, dynmap, WorldEdit, WorldBorderAPI]
permissions:
bentobox.admin:

View File

@ -23,7 +23,6 @@ import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.AddonDescription;
import world.bentobox.bentobox.api.addons.GameModeAddon;
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.lists.GameModePlaceholder;
@ -44,8 +43,6 @@ public class PlaceholdersManagerTest {
private HooksManager hm;
@Mock
private PlaceholderAPIHook hook;
@Mock
private MVdWPlaceholderAPIHook hook2;
@Before
public void setUp() throws Exception {
@ -63,8 +60,6 @@ public class PlaceholdersManagerTest {
Optional<Hook> optionalHook = Optional.of(hook);
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
when(hook.isPlaceholder(any(), any())).thenReturn(false);
Optional<Hook> optionalHook2 = Optional.of(hook2);
when(hm.getHook(eq("MVdWPlaceholderAPI"))).thenReturn(optionalHook2);
// Placeholder manager
pm = new PlaceholdersManager(plugin);
@ -82,7 +77,6 @@ public class PlaceholdersManagerTest {
public void testRegisterGameModePlaceholdersAllDefaults() {
pm.registerDefaultPlaceholders(addon);
verify(hook, times(GameModePlaceholder.values().length)).registerPlaceholder(any(), anyString(), any());
verify(hook2, times(GameModePlaceholder.values().length)).registerPlaceholder(any(), anyString(), any());
}
/**