mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Version checking + Config flag setting
This commit is contained in:
parent
2e85dded3d
commit
a4afba181c
@ -38,13 +38,16 @@ import com.intellectualcrafters.plot.listeners.*;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
|
||||
import me.confuser.barapi.BarAPI;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -1528,6 +1531,12 @@ import java.util.concurrent.TimeUnit;
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||
}
|
||||
else if (checkVersion() && Bukkit.getOnlineMode()) {
|
||||
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
|
||||
}
|
||||
else {
|
||||
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||
}
|
||||
setUUIDSaver(new PlotUUIDSaver());
|
||||
// Looks really cool xD
|
||||
getUUIDSaver().globalPopulate();
|
||||
@ -1538,6 +1547,33 @@ import java.util.concurrent.TimeUnit;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkVersion() {
|
||||
try {
|
||||
String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
||||
int a = Integer.parseInt(version[0]);
|
||||
int b = Integer.parseInt(version[1]);
|
||||
int c = 0;
|
||||
if (version.length == 3) {
|
||||
c = Integer.parseInt(version[2]);
|
||||
}
|
||||
if (a < 2) {
|
||||
if (a < 1) {
|
||||
return false;
|
||||
}
|
||||
if (b < 7) {
|
||||
return false;
|
||||
}
|
||||
if (b == 7 && c < 5) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On unload
|
||||
*/
|
||||
|
@ -111,9 +111,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
try {
|
||||
plr.teleport(Bukkit.getWorld(world).getSpawnLocation());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
catch (Exception e) {}
|
||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||
|
||||
setupMap.remove(plrname);
|
||||
@ -126,6 +124,14 @@ public class Setup extends SubCommand implements Listener {
|
||||
return true;
|
||||
} else {
|
||||
if (args[0].equalsIgnoreCase("cancel")) {
|
||||
final String world = object.world;
|
||||
PlotMain.config.set(world, null);
|
||||
try {
|
||||
PlotMain.config.save(PlotMain.configFile);
|
||||
PlotMain.config.load(PlotMain.configFile);
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupMap.remove(plrname);
|
||||
PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
|
||||
return true;
|
||||
@ -185,7 +191,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (plugin.isEnabled()) {
|
||||
if (plugin.getDefaultWorldGenerator("world", "") != null) {
|
||||
if (plugin.getDefaultWorldGenerator(world, "") != null) {
|
||||
final String name = plugin.getDescription().getName();
|
||||
generators.add(name);
|
||||
if (args[1].equals(name)) {
|
||||
|
@ -306,6 +306,9 @@ public abstract class PlotWorld {
|
||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
||||
if (this.DEFAULT_FLAGS == null) {
|
||||
this.DEFAULT_FLAGS = new ArrayList<>();
|
||||
}
|
||||
this.PVP = config.getBoolean("event.pvp");
|
||||
this.PVE = config.getBoolean("event.pve");
|
||||
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");
|
||||
@ -336,7 +339,7 @@ public abstract class PlotWorld {
|
||||
options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT);
|
||||
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
|
||||
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
|
||||
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
|
||||
options.put("flags.default", null);
|
||||
options.put("event.pvp", PlotWorld.PVP_DEFAULT);
|
||||
options.put("event.pve", PlotWorld.PVE_DEFAULT);
|
||||
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
|
||||
|
@ -315,7 +315,6 @@ import java.util.UUID;
|
||||
*/
|
||||
public static UUID getUUID(final OfflinePlayer player) {
|
||||
if (uuidWrapper == null) {
|
||||
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
uuidWrapper = new OfflineUUIDWrapper();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user