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

View File

@ -134,7 +134,7 @@ public class PS {
} catch (Exception e) { } catch (Exception e) {
log("Could not determine file path"); log("Could not determine file path");
} }
VERSION = IMP.getVersion(); VERSION = IMP.getPluginVersion();
EconHandler.manager = IMP.getEconomyHandler(); EconHandler.manager = IMP.getEconomyHandler();
if (getJavaVersion() < 1.7) { if (getJavaVersion() < 1.7) {
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 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(); 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 * Get the instance of PlotSquared
* *

View File

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