mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36: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.object.*;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||||
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||||
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
import me.confuser.barapi.BarAPI;
|
import me.confuser.barapi.BarAPI;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -1528,6 +1531,12 @@ import java.util.concurrent.TimeUnit;
|
|||||||
if (Settings.OFFLINE_MODE) {
|
if (Settings.OFFLINE_MODE) {
|
||||||
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||||
}
|
}
|
||||||
|
else if (checkVersion() && Bukkit.getOnlineMode()) {
|
||||||
|
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||||
|
}
|
||||||
setUUIDSaver(new PlotUUIDSaver());
|
setUUIDSaver(new PlotUUIDSaver());
|
||||||
// Looks really cool xD
|
// Looks really cool xD
|
||||||
getUUIDSaver().globalPopulate();
|
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
|
* On unload
|
||||||
*/
|
*/
|
||||||
|
@ -111,9 +111,7 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
try {
|
try {
|
||||||
plr.teleport(Bukkit.getWorld(world).getSpawnLocation());
|
plr.teleport(Bukkit.getWorld(world).getSpawnLocation());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {}
|
||||||
|
|
||||||
}
|
|
||||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
|
|
||||||
setupMap.remove(plrname);
|
setupMap.remove(plrname);
|
||||||
@ -126,6 +124,14 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (args[0].equalsIgnoreCase("cancel")) {
|
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);
|
setupMap.remove(plrname);
|
||||||
PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
|
PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
|
||||||
return true;
|
return true;
|
||||||
@ -185,7 +191,7 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
|
|
||||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled()) {
|
||||||
if (plugin.getDefaultWorldGenerator("world", "") != null) {
|
if (plugin.getDefaultWorldGenerator(world, "") != null) {
|
||||||
final String name = plugin.getDescription().getName();
|
final String name = plugin.getDescription().getName();
|
||||||
generators.add(name);
|
generators.add(name);
|
||||||
if (args[1].equals(name)) {
|
if (args[1].equals(name)) {
|
||||||
|
@ -306,6 +306,9 @@ public abstract class PlotWorld {
|
|||||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||||
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
||||||
|
if (this.DEFAULT_FLAGS == null) {
|
||||||
|
this.DEFAULT_FLAGS = new ArrayList<>();
|
||||||
|
}
|
||||||
this.PVP = config.getBoolean("event.pvp");
|
this.PVP = config.getBoolean("event.pvp");
|
||||||
this.PVE = config.getBoolean("event.pve");
|
this.PVE = config.getBoolean("event.pve");
|
||||||
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");
|
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.merge", PlotWorld.MERGE_PRICE_DEFAULT);
|
||||||
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
|
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
|
||||||
options.put("chat.enabled", PlotWorld.PLOT_CHAT_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.pvp", PlotWorld.PVP_DEFAULT);
|
||||||
options.put("event.pve", PlotWorld.PVE_DEFAULT);
|
options.put("event.pve", PlotWorld.PVE_DEFAULT);
|
||||||
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_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) {
|
public static UUID getUUID(final OfflinePlayer player) {
|
||||||
if (uuidWrapper == null) {
|
if (uuidWrapper == null) {
|
||||||
|
|
||||||
if (Settings.OFFLINE_MODE) {
|
if (Settings.OFFLINE_MODE) {
|
||||||
uuidWrapper = new OfflineUUIDWrapper();
|
uuidWrapper = new OfflineUUIDWrapper();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user