mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Move the caching and static accessors from EconHandler to PlotMain
This commit is contained in:
parent
38425a1eae
commit
9c3d2cfb02
@ -178,6 +178,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
@Getter private BackupManager backupManager;
|
@Getter private BackupManager backupManager;
|
||||||
@Getter private PlatformWorldManager<World> worldManager;
|
@Getter private PlatformWorldManager<World> worldManager;
|
||||||
private final BukkitPlayerManager playerManager = new BukkitPlayerManager();
|
private final BukkitPlayerManager playerManager = new BukkitPlayerManager();
|
||||||
|
private EconHandler econ;
|
||||||
|
|
||||||
@Override public int[] getServerVersion() {
|
@Override public int[] getServerVersion() {
|
||||||
if (this.version == null) {
|
if (this.version == null) {
|
||||||
@ -902,8 +903,16 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public EconHandler getEconomyHandler() {
|
@Override public EconHandler getEconomyHandler() {
|
||||||
|
if (econ != null) {
|
||||||
|
if (econ.init() /* is inited*/) {
|
||||||
|
return econ;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BukkitEconHandler econ = new BukkitEconHandler();
|
econ = new BukkitEconHandler();
|
||||||
if (econ.init()) {
|
if (econ.init()) {
|
||||||
return econ;
|
return econ;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public class BukkitEconHandler extends EconHandler {
|
|||||||
private Economy econ;
|
private Economy econ;
|
||||||
private Permission perms;
|
private Permission perms;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean init() {
|
public boolean init() {
|
||||||
if (this.econ == null || this.perms == null) {
|
if (this.econ == null || this.perms == null) {
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
|
@ -174,11 +174,11 @@ public interface IPlotMain<P> extends ILogger {
|
|||||||
boolean initWorldEdit();
|
boolean initWorldEdit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the economy provider.
|
* Gets the economy provider, if there is one
|
||||||
*
|
*
|
||||||
* @return the PlotSquared economy manager
|
* @return the PlotSquared economy manager
|
||||||
*/
|
*/
|
||||||
EconHandler getEconomyHandler();
|
@Nullable EconHandler getEconomyHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link QueueProvider} class.
|
* Gets the {@link QueueProvider} class.
|
||||||
|
@ -35,18 +35,17 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
public abstract class EconHandler {
|
public abstract class EconHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This will be made private in the future
|
* @deprecated This will be removed in the future,
|
||||||
|
* call {@link IPlotMain#getEconomyHandler()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated public static EconHandler manager;
|
@Deprecated @Nullable public static EconHandler manager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the economy handler using
|
* Initialize the economy handler using {@link IPlotMain#getEconomyHandler()}
|
||||||
* {@link IPlotMain#getEconomyHandler()}
|
* @deprecated Call {@link #init} instead or use {@link IPlotMain#getEconomyHandler()}
|
||||||
|
* which does this already.
|
||||||
*/
|
*/
|
||||||
public static void initializeEconHandler() {
|
@Deprecated public static void initializeEconHandler() {
|
||||||
if (manager != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
manager = PlotSquared.get().IMP.getEconomyHandler();
|
manager = PlotSquared.get().IMP.getEconomyHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +53,15 @@ public abstract class EconHandler {
|
|||||||
* Return the econ handler instance, if one exists
|
* Return the econ handler instance, if one exists
|
||||||
*
|
*
|
||||||
* @return Economy handler instance
|
* @return Economy handler instance
|
||||||
|
* @deprecated Call {@link IPlotMain#getEconomyHandler()} instead
|
||||||
*/
|
*/
|
||||||
@Nullable public static EconHandler getEconHandler() {
|
@Deprecated @Nullable public static EconHandler getEconHandler() {
|
||||||
|
manager = PlotSquared.get().IMP.getEconomyHandler();
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract boolean init();
|
||||||
|
|
||||||
public double getMoney(PlotPlayer<?> player) {
|
public double getMoney(PlotPlayer<?> player) {
|
||||||
if (player instanceof ConsolePlayer) {
|
if (player instanceof ConsolePlayer) {
|
||||||
return Double.MAX_VALUE;
|
return Double.MAX_VALUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user