refactor!: MultiverseCore plugin mess

This commit is contained in:
Ben Woo 2023-02-08 15:33:59 +08:00
parent a6ee8a55ca
commit a403380375
7 changed files with 393 additions and 851 deletions

View File

@ -17,7 +17,7 @@ import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import org.bukkit.entity.Player;
/**
@ -26,17 +26,6 @@ import org.bukkit.entity.Player;
* This API contains a bunch of useful things you can get out of Multiverse in general!
*/
public interface Core {
/**
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
* interfacing with Vault.
*
* @return the Vault handler for Multiverse.
* @deprecated we are now using {@link #getEconomist()} for all economy needs.
*/
@Deprecated
VaultHandler getVaultHandler();
/**
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without
* worrying about any of the messy details.
@ -52,12 +41,11 @@ public interface Core {
void loadConfigs();
/**
* Gets the Multiverse message system. This allows you to send messages
* to users at specified intervals.
* Gets the {@link UnsafeCallWrapper} class.
*
* @return The loaded {@link MultiverseMessaging}.
* @return A non-null {@link UnsafeCallWrapper}.
*/
MultiverseMessaging getMessaging();
UnsafeCallWrapper getUnsafeCallWrapper();
/**
* Gets the {@link MVPlayerSession} for the given player.
@ -101,12 +89,19 @@ public interface Core {
*/
MVWorldManager getMVWorldManager();
/**
* Saves the Multiverse-Config.
*
* @return Whether the Multiverse-Config was successfully saved
*/
boolean saveMVConfig();
/**
* Saves all configs.
*
* @return Whether the config was successfully saved
*/
boolean saveMVConfigs();
boolean saveAllConfigs();
/**
* Gets the {@link AnchorManager}.
@ -115,39 +110,6 @@ public interface Core {
*/
AnchorManager getAnchorManager();
/**
* Previously used by queued commands to regenerate a world on a delay.
* Do not use api method for any other purpose.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String, boolean)} instead.
*/
@Deprecated
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
/**
* Used by queued commands to regenerate a world on a delay.
* Do not use api method for any other purpose.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
* @param keepGameRules If GameRules should be kept on world regen.
*
* @return True if success, false if fail.
*
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String, boolean)} instead.
*/
@Deprecated
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed, Boolean keepGameRules);
/**
* Decrements the number of plugins that have specifically hooked into core.
*/

View File

@ -8,25 +8,11 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
/**
* This interface is implemented by every official Multiverse-plugin.
*/
public interface MVPlugin {
/**
* Adds This plugin's version information to the buffer and returns the new string.
*
* @param buffer The string that contains Core and all other MV plugins' versions.
*
* @return A modified buffer that contains this MVPlugin's version information.
*
* @deprecated This is now deprecated, nobody needs it any longer.
* All version info-dumping is now done with {@link MVVersionEvent}.
*/
@Deprecated
String dumpVersionInfo(String buffer);
/**
* Gets the reference to MultiverseCore.
*

View File

@ -81,11 +81,6 @@ public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
*/
protected abstract void onPluginEnable();
@Override
public final String dumpVersionInfo(String buffer) {
throw new UnsupportedOperationException("This is gone.");
}
@Override
public final MultiverseCore getCore() {
if (this.core == null)

View File

@ -40,7 +40,7 @@ public class DebugCommand extends MultiverseCommand {
int level) {
this.plugin.getMVConfig().setGlobalDebug(level);
this.plugin.saveMVConfigs();
this.plugin.saveAllConfigs();
this.displayDebugMode(issuer);
}

View File

@ -279,11 +279,11 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
}
if (entity instanceof Player) {
Player p = (Player) entity;
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
p.sendMessage("No safe locations found!");
Logging.finer("No safe location found for " + p.getName());
} else if (entity.getPassenger() instanceof Player) {
Player p = (Player) entity.getPassenger();
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
p.sendMessage("No safe locations found!");
Logging.finer("No safe location found for " + p.getName());
}
Logging.fine("Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");

View File

@ -305,7 +305,7 @@ public class TestWorldProperties {
/* ****************************************** *
* Test saving/loading
* ****************************************** */
assertTrue(core.saveMVConfigs());
assertTrue(core.saveAllConfigs());
// change a value here
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(core.getDataFolder(), "worlds.yml"));
WorldProperties worldObj = (WorldProperties) config.get("worlds.world");