This commit is contained in:
boy0001 2015-07-27 01:08:06 +10:00
parent 9184010c9f
commit f12fdae4c2
4 changed files with 22 additions and 24 deletions

View File

@ -26,7 +26,9 @@ public interface IPlotMain {
public void disable();
public String getVersion();
public int[] getPluginVersion();
public int[] getServerVersion();
public void handleKick(UUID uuid, C c);
@ -79,6 +81,4 @@ public interface IPlotMain {
public PlayerManager initPlayerManager();
public String getServerName();
public boolean checkVersion(int major, int minor, int minor2);
}

View File

@ -134,7 +134,7 @@ public class PS {
} catch (Exception e) {
log("Could not determine file path");
}
VERSION = IMP.getVersion();
VERSION = IMP.getPluginVersion();
EconHandler.manager = IMP.getEconomyHandler();
if (getJavaVersion() < 1.7) {
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
@ -239,6 +239,10 @@ public class PS {
showDebug();
}
public boolean checkVersion(int[] version, int major, int minor, int minor2) {
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
}
/**
* Get the instance of PlotSquared
*

View File

@ -71,11 +71,11 @@ public class plugin extends SubCommand {
final ArrayList<String> strings = new ArrayList<String>() {
// $2>> $1%id$2:$1%world $2- $1%owner
{
add(String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", PS.get().IMP.getVersion()));
add(String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", PS.get().IMP.getPluginVersion()));
add(String.format("$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"));
add(String.format("$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"));
add(String.format("$2>> $1&lWebsite$2: $1http://plotsquared.com"));
add(String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? PS.get().IMP.getVersion() : PS.get().update)));
add(String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? PS.get().IMP.getPluginVersion() : PS.get().update)));
}
};
for (final String s : strings) {

View File

@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.generator.HybridUtils;
import com.plotsquared.bukkit.listeners.*;
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.plotsquared.bukkit.titles.AbstractTitle;
@ -29,6 +28,7 @@ import com.plotsquared.bukkit.util.SetupUtils;
import com.plotsquared.bukkit.util.bukkit.*;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -42,7 +42,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@ -52,9 +51,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public static BukkitMain THIS = null;
private int[] version;
@Override
public boolean checkVersion(final int major, final int minor, final int minor2) {
public int[] getServerVersion() {
if (version == null) {
try {
version = new int[3];
@ -66,10 +65,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
} catch (Exception e) {
e.printStackTrace();
return false;
return null;
}
}
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
return version;
}
@Override
@ -134,8 +133,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
@Override
public String getVersion() {
return this.getDescription().getVersion();
public int[] getPluginVersion() {
String[] split = this.getDescription().getVersion().split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
}
@Override
@ -234,13 +234,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
return new BukkitTaskManager();
}
private ArrayDeque<Entity> fastTickEntities;
private ArrayDeque<Entity> slowTickEntities;
@Override
public void runEntityTask() {
// fastTickEntities = new ArrayDeque<>();
// slowTickEntities = new ArrayDeque<>();
log(C.PREFIX.s() + "KillAllEntities started.");
TaskManager.runTaskRepeat(new Runnable() {
long ticked = 0l;
@ -257,7 +252,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
World world;
for (final PlotWorld pw : PS.get().getPlotWorldObjects()) {
PlotManager manager = PS.get().getPlotManager(pw.worldname);
world = Bukkit.getWorld(pw.worldname);
try {
for (Entity entity : world.getEntities()) {
@ -383,10 +377,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void registerPlayerEvents() {
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
if (checkVersion(1, 8, 0)) {
if (PS.get().checkVersion(this.getServerVersion(), 1, 8, 0)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
}
if (checkVersion(1, 8, 3)) {
if (PS.get().checkVersion(this.getServerVersion(), 1, 8, 3)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8_3(), this);
}
}
@ -438,7 +432,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public BlockManager initBlockManager() {
if (checkVersion(1, 8, 0)) {
if (PS.get().checkVersion(this.getServerVersion(), 1, 8, 0)) {
try {
BukkitSetBlockManager.setBlockManager = new SetBlockFast_1_8();
} catch (final Throwable e) {
@ -498,7 +492,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public UUIDWrapper initUUIDHandler() {
final boolean checkVersion = checkVersion(1, 7, 6);
final boolean checkVersion = PS.get().checkVersion(this.getServerVersion(), 1, 7, 6);
if (Settings.OFFLINE_MODE) {
if (Settings.UUID_LOWERCASE) {
UUIDHandler.setUUIDWrapper(new LowerOfflineUUIDWrapper());