mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
finished ExpireManager
This commit is contained in:
parent
70357da5f3
commit
8885895a1c
@ -21,6 +21,7 @@
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||
import com.intellectualcrafters.plot.commands.Auto;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
@ -48,6 +49,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import me.confuser.barapi.BarAPI;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -55,10 +57,15 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.UnknownDependencyException;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
@ -170,13 +177,16 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
|
||||
/**
|
||||
* If plotme converter is enabled
|
||||
*/
|
||||
private static boolean CONVERT_PLOTME = enablePlotMe();
|
||||
/**
|
||||
* Return an instance of MySQL
|
||||
*/
|
||||
public static MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a range of permissions e.g. 'plots.plot.<0-100>'<br> Returns highest integer in range.
|
||||
*
|
||||
@ -520,7 +530,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @param string message
|
||||
*/
|
||||
public static void sendConsoleSenderMessage(final String string) {
|
||||
if (getMain().getServer().getConsoleSender() == null) {
|
||||
if (PlotMain.main == null || getMain().getServer().getConsoleSender() == null) {
|
||||
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string)));
|
||||
} else {
|
||||
getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
|
||||
@ -835,7 +845,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public static void worldLoad(WorldLoadEvent event) {
|
||||
if (!UUIDHandler.CACHED) {
|
||||
UUIDHandler.cacheAll();
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("PlotMe") != null) {
|
||||
if (CONVERT_PLOTME) {
|
||||
try {
|
||||
new PlotMeConverter(PlotMain.getMain()).runAsync();
|
||||
} catch (final Exception e) {
|
||||
@ -1236,35 +1246,42 @@ import java.util.concurrent.TimeUnit;
|
||||
Logger.add(LogLevel.GENERAL, "Logger enabled");
|
||||
}
|
||||
|
||||
public static boolean enablePlotMe() {
|
||||
File file = new File(new File("").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe-Core.jar");
|
||||
if (file.exists()) {
|
||||
sendConsoleSenderMessage("&b==== Copying 'PlotMe-Core.jar' to 'PlotMe_JAR_relocated' for conversion purposes ===");
|
||||
sendConsoleSenderMessage("&3 - Please ignore the below stacktrace...");
|
||||
try {
|
||||
File to = new File(new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe_JAR_relocated" + File.separator + "PlotMe-Core.jar");
|
||||
File parent = to.getParentFile();
|
||||
if(!parent.exists()){
|
||||
parent.mkdirs();
|
||||
}
|
||||
to.createNewFile();
|
||||
Files.copy(file, to);
|
||||
file.delete();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
file = new File(new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe.jar");
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* On Load.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
final public void onEnable() {
|
||||
|
||||
/* <sarcasm>
|
||||
* Oh, is this what it looks like?
|
||||
* Are we stealing coding from PlotMe again?
|
||||
*/
|
||||
|
||||
//Plugin competition = Bukkit.getPluginManager().getPlugin("PlotSquared");
|
||||
Plugin competition = Bukkit.getPluginManager().getPlugin("PlotMe");
|
||||
if (competition != null) {
|
||||
getPluginLoader().disablePlugin(competition);
|
||||
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
||||
CONVERT_PLOTME = true;
|
||||
}
|
||||
/*
|
||||
* Oh no! How unethical of us to steal this above code from PlotMe and only change 1 line of code!
|
||||
* If only we were good enough to code something like this ourselves!
|
||||
*
|
||||
* You guys are hilarious how you intentionally try to make it difficult for your users to to switch plot plugins.
|
||||
* If we didn't know any better, we'd say you're abusing your position as the most used plot plugin.
|
||||
* </sarcasm>
|
||||
* Side note from Empire92: Your continued bullying doesn't give me much incentive to support PlotMe with any of my other plugins:
|
||||
* - VoxelSniperRegions
|
||||
* - BiomeGenerator
|
||||
*/
|
||||
|
||||
PlotMain.main = this;
|
||||
// Setup the logger mechanics
|
||||
setupLogger();
|
||||
|
@ -24,6 +24,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.InfoInventory;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
@ -174,7 +175,7 @@ import java.util.UUID;
|
||||
final String trusted = getPlayerList(plot.trusted);
|
||||
final String denied = getPlayerList(plot.denied);
|
||||
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
|
||||
final String flags = "&6" + (StringUtils.join(plot.settings.flags, "").length() > 0 ? StringUtils.join(plot.settings.flags, "&7, &6") : "none");
|
||||
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
|
||||
final boolean build = (player == null) || plot.hasRights(player);
|
||||
|
||||
String owner = "none";
|
||||
|
@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -53,7 +54,6 @@ public class PlotMeConverter {
|
||||
* PlotMain Object
|
||||
*/
|
||||
private final PlotMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -70,15 +70,15 @@ public class PlotMeConverter {
|
||||
public void runAsync() throws Exception {
|
||||
// We have to make it wait a couple of seconds
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sendMessage("Conversion has started");
|
||||
sendMessage("Connecting to PlotMe DB");
|
||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
final Plugin plotMePlugin = Bukkit.getPluginManager().getPlugin("PlotMe");
|
||||
final FileConfiguration plotConfig = plotMePlugin.getConfig();
|
||||
String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||
File plotMeFile = new File(dataFolder + "config.yml");
|
||||
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
|
||||
int count = 0;
|
||||
|
||||
Connection connection;
|
||||
@ -93,7 +93,7 @@ public class PlotMeConverter {
|
||||
connection = mySQL.openConnection();
|
||||
}
|
||||
else {
|
||||
connection = new SQLite(PlotMain.getMain(), plotMePlugin.getDataFolder() + File.separator +"plots.db").openConnection();
|
||||
connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator +"plots.db").openConnection();
|
||||
}
|
||||
sendMessage("Collecting plot data");
|
||||
ResultSet r;
|
||||
@ -105,9 +105,9 @@ public class PlotMeConverter {
|
||||
stmt = connection.createStatement();
|
||||
r = stmt.executeQuery("SELECT * FROM `plotmePlots`");
|
||||
while (r.next()) {
|
||||
count++;
|
||||
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
String name = r.getString("owner");
|
||||
System.out.print("NAME: "+name);
|
||||
String world = r.getString("world");
|
||||
if (!plotSize.containsKey(world)) {
|
||||
int size = r.getInt("topZ") - r.getInt("bottomZ");
|
||||
@ -131,7 +131,6 @@ public class PlotMeConverter {
|
||||
|
||||
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
|
||||
while (r.next()) {
|
||||
count++;
|
||||
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
String name = r.getString("player");
|
||||
String world = r.getString("world");
|
||||
@ -200,7 +199,7 @@ public class PlotMeConverter {
|
||||
}
|
||||
}
|
||||
|
||||
File PLOTME_DG_FILE = new File(plotMePlugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (PLOTME_DG_FILE.exists()) {
|
||||
YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||
try {
|
||||
@ -301,8 +300,6 @@ public class PlotMeConverter {
|
||||
}
|
||||
|
||||
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
|
||||
sendMessage("Disabling PlotMe...");
|
||||
Bukkit.getPluginManager().disablePlugin(plotMePlugin);
|
||||
sendMessage("Conversion has finished");
|
||||
PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion.");
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -21,11 +21,13 @@
|
||||
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -312,8 +314,14 @@ public abstract class PlotWorld {
|
||||
this.DEFAULT_FLAGS = new Flag[] {};
|
||||
}
|
||||
else {
|
||||
try {
|
||||
this.DEFAULT_FLAGS = FlagManager.parseFlags(flags);
|
||||
}
|
||||
catch (Exception e) {
|
||||
PlotMain.sendConsoleSenderMessage("&cInvalid default flags for "+this.worldname+": "+StringUtils.join(flags,","));
|
||||
this.DEFAULT_FLAGS = new Flag[] {};
|
||||
}
|
||||
}
|
||||
this.PVP = config.getBoolean("event.pvp");
|
||||
this.PVE = config.getBoolean("event.pve");
|
||||
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");
|
||||
|
@ -87,7 +87,6 @@ public class ExpireManager {
|
||||
final World worldobj = Bukkit.getWorld(world);
|
||||
final PlotManager manager = PlotMain.getPlotManager(world);
|
||||
manager.clearPlot(worldobj, plot, false);
|
||||
PlotHelper.clear(worldobj, plot, true);
|
||||
PlotHelper.removeSign(worldobj, plot);
|
||||
DBFunc.delete(world, plot);
|
||||
PlotMain.removePlot(world, plot.id, true);
|
||||
@ -100,7 +99,7 @@ public class ExpireManager {
|
||||
}
|
||||
|
||||
}
|
||||
}, 1, 20);
|
||||
}, 1200, 1200);
|
||||
}
|
||||
|
||||
public static boolean isExpired(UUID uuid) {
|
||||
|
Loading…
Reference in New Issue
Block a user