MassiveCore - Version Synchronized Warnings
This commit is contained in:
parent
9667e27fcb
commit
70b6f5cb75
@ -24,6 +24,8 @@ public class MassiveCoreMConf extends Entity<MassiveCoreMConf>
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean checkVersionSynchronization = true;
|
||||
|
||||
public int maxTabCompletions = 100;
|
||||
|
||||
public List<String> aliasesOuterMassiveCore = MUtil.list("massivecore", "mcore");
|
||||
|
@ -20,8 +20,18 @@ import com.massivecraft.massivecore.xlib.gson.GsonBuilder;
|
||||
|
||||
public abstract class MassivePlugin extends JavaPlugin implements Listener
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// Gson
|
||||
public Gson gson;
|
||||
protected Gson gson = null;
|
||||
public Gson getGson() { return this.gson; }
|
||||
public void setGson(Gson gson) { this.gson = gson; }
|
||||
|
||||
protected boolean versionSynchronized = false;
|
||||
public boolean isVersionSynchronized() { return this.versionSynchronized; }
|
||||
public void setVersionSynchronized(boolean versionSynchronized) { this.versionSynchronized = versionSynchronized; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ENABLE
|
||||
@ -38,7 +48,8 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
|
||||
log("=== ENABLE START ===");
|
||||
|
||||
// Create Gson
|
||||
this.gson = this.getGsonBuilder().create();
|
||||
Gson gson = this.getGsonBuilder().create();
|
||||
this.setGson(gson);
|
||||
|
||||
// Listener
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
@ -60,7 +71,46 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
|
||||
|
||||
public void postEnable()
|
||||
{
|
||||
log(Txt.parse("=== ENABLE <g>COMPLETE <i>(Took <h>"+(System.currentTimeMillis()-timeEnableStart)+"ms<i>) ==="));
|
||||
long ms = System.currentTimeMillis()-timeEnableStart;
|
||||
|
||||
this.checkVersionSynchronization();
|
||||
|
||||
log(Txt.parse("=== ENABLE <g>COMPLETE <i>(Took <h>" + ms + "ms<i>) ==="));
|
||||
}
|
||||
|
||||
public void checkVersionSynchronization()
|
||||
{
|
||||
// If this plugin is version synchronized ...
|
||||
if ( ! this.isVersionSynchronized()) return;
|
||||
|
||||
// ... and checking is enabled ...
|
||||
if ( ! MassiveCoreMConf.get().checkVersionSynchronization) return;
|
||||
|
||||
// ... get the version numbers ...
|
||||
String thisVersion = this.getDescription().getVersion();
|
||||
String massiveVersion = MassiveCore.get().getDescription().getVersion();
|
||||
|
||||
// ... and if the version numbers are different ...
|
||||
if (thisVersion.equals(massiveVersion)) return;
|
||||
|
||||
// ... log a warning message ...
|
||||
String thisName = this.getDescription().getName();
|
||||
String massiveName = MassiveCore.get().getDescription().getName();
|
||||
|
||||
log(Txt.parse("<b>WARNING: You are using <pink>" + thisName + " <aqua>" + thisVersion + " <b>and <pink>" + massiveName + " <aqua>" + massiveVersion + "<b>!"));
|
||||
log(Txt.parse("<b>WARNING: They must be the exact same version to work properly!"));
|
||||
log(Txt.parse("<b>WARNING: Remember to always update all plugins at the same time!"));
|
||||
log(Txt.parse("<b>WARNING: You should stop your server and properly update."));
|
||||
|
||||
// ... and pause for 10 seconds.
|
||||
try
|
||||
{
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
catch (InterruptedException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,7 +44,7 @@ public class SimpleConfig
|
||||
{
|
||||
if (this.plugin instanceof MassivePlugin)
|
||||
{
|
||||
return ((MassivePlugin)this.plugin).gson;
|
||||
return ((MassivePlugin)this.plugin).getGson();
|
||||
}
|
||||
return MassiveCore.gson;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class Coll<E> extends CollAbstract<E>
|
||||
{
|
||||
if (this.getPlugin() instanceof MassivePlugin)
|
||||
{
|
||||
return ((MassivePlugin)this.getPlugin()).gson;
|
||||
return ((MassivePlugin)this.getPlugin()).getGson();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user