mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Nothing is implemented, but it can compile and "run" on sponge now.
This commit is contained in:
		@@ -5,8 +5,7 @@ import com.intellectualcrafters.plot.generator.HybridUtils;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.*;
 | 
			
		||||
import com.plotsquared.bukkit.listeners.APlotListener;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
import com.plotsquared.listener.APlotListener;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 
 | 
			
		||||
@@ -12,9 +12,7 @@ import com.intellectualcrafters.plot.flag.FlagValue;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.*;
 | 
			
		||||
import com.intellectualcrafters.plot.object.*;
 | 
			
		||||
import com.intellectualcrafters.plot.util.*;
 | 
			
		||||
import com.plotsquared.bukkit.listeners.APlotListener;
 | 
			
		||||
import com.plotsquared.bukkit.object.comment.CommentManager;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
import com.plotsquared.listener.APlotListener;
 | 
			
		||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
 | 
			
		||||
 | 
			
		||||
import java.io.*;
 | 
			
		||||
@@ -73,136 +71,143 @@ public class PS {
 | 
			
		||||
     * @param imp_class
 | 
			
		||||
     */
 | 
			
		||||
    public PS(final IPlotMain imp_class) {
 | 
			
		||||
        instance = this;
 | 
			
		||||
        SetupUtils.generators = new HashMap<>();
 | 
			
		||||
        IMP = imp_class;
 | 
			
		||||
        try {
 | 
			
		||||
            FILE = new File(PS.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log("Could not determine file path");
 | 
			
		||||
        }
 | 
			
		||||
        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.");
 | 
			
		||||
            // Didn't know of any other link :D
 | 
			
		||||
            log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
 | 
			
		||||
            IMP.disable();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (getJavaVersion() < 1.8) {
 | 
			
		||||
            log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
 | 
			
		||||
        }
 | 
			
		||||
        this.TASK = IMP.getTaskManager();
 | 
			
		||||
        if (C.ENABLED.s().length() > 0) {
 | 
			
		||||
            log(C.ENABLED.s());
 | 
			
		||||
        }
 | 
			
		||||
        setupConfigs();
 | 
			
		||||
        this.translationFile = new File(IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
 | 
			
		||||
        C.load(translationFile);
 | 
			
		||||
        setupDefaultFlags();
 | 
			
		||||
        setupDatabase();
 | 
			
		||||
        CommentManager.registerDefaultInboxes();
 | 
			
		||||
        // Tasks
 | 
			
		||||
        if (Settings.KILL_ROAD_MOBS) {
 | 
			
		||||
            IMP.runEntityTask();
 | 
			
		||||
        }
 | 
			
		||||
        // Events
 | 
			
		||||
        IMP.registerCommands();
 | 
			
		||||
        IMP.registerPlayerEvents();
 | 
			
		||||
        IMP.registerInventoryEvents();
 | 
			
		||||
        IMP.registerPlotPlusEvents();
 | 
			
		||||
        IMP.registerForceFieldEvents();
 | 
			
		||||
        IMP.registerWorldEditEvents();
 | 
			
		||||
        IMP.registerWorldEvents();
 | 
			
		||||
        if (Settings.METRICS) {
 | 
			
		||||
            IMP.startMetrics();
 | 
			
		||||
        } else {
 | 
			
		||||
            log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
 | 
			
		||||
        }
 | 
			
		||||
        IMP.startMetrics();
 | 
			
		||||
        if (Settings.TNT_LISTENER) {
 | 
			
		||||
            IMP.registerTNTListener();
 | 
			
		||||
        }
 | 
			
		||||
        if (Settings.CHUNK_PROCESSOR) {
 | 
			
		||||
            IMP.registerChunkProcessor();
 | 
			
		||||
        }
 | 
			
		||||
        // create UUIDWrapper
 | 
			
		||||
        UUIDHandler.implementation = IMP.initUUIDHandler();
 | 
			
		||||
        UUIDHandler.implementation.startCaching(null); // TODO maybe a notification when this is done?
 | 
			
		||||
        // create event util class
 | 
			
		||||
        EventUtil.manager = IMP.initEventUtil();
 | 
			
		||||
        // create Hybrid utility class
 | 
			
		||||
        HybridUtils.manager = IMP.initHybridUtils();
 | 
			
		||||
        // Inventory utility class
 | 
			
		||||
        InventoryUtil.manager = IMP.initInventoryUtil();
 | 
			
		||||
        // create setup util class
 | 
			
		||||
        SetupUtils.manager = IMP.initSetupUtils();
 | 
			
		||||
        // Set block
 | 
			
		||||
        BlockManager.manager = IMP.initBlockManager();
 | 
			
		||||
        // Set chunk
 | 
			
		||||
        ChunkManager.manager = IMP.initChunkManager();
 | 
			
		||||
        // Plot listener
 | 
			
		||||
        APlotListener.manager = IMP.initPlotListener();
 | 
			
		||||
        // Player manager
 | 
			
		||||
        PlayerManager.manager = IMP.initPlayerManager();
 | 
			
		||||
 | 
			
		||||
        // Check for updates
 | 
			
		||||
        TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                URL url = getUpdate();
 | 
			
		||||
                if (url != null) {
 | 
			
		||||
                    update = url;
 | 
			
		||||
                    log("&6You are running an older version of PlotSquared...");
 | 
			
		||||
                    log("&8 - &3Use: &7/plot update");
 | 
			
		||||
                    log("&8 - &3Or: &7" + url);
 | 
			
		||||
                }
 | 
			
		||||
                else if (LAST_VERSION != null && !VERSION.equals(LAST_VERSION)) {
 | 
			
		||||
                    log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
 | 
			
		||||
                }
 | 
			
		||||
            instance = this;
 | 
			
		||||
            SetupUtils.generators = new HashMap<>();
 | 
			
		||||
            IMP = imp_class;
 | 
			
		||||
            try {
 | 
			
		||||
                FILE = new File(PS.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
 | 
			
		||||
            } catch (Exception e) {
 | 
			
		||||
                FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared.jar");
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                log("Could not determine file path");
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        
 | 
			
		||||
        // PlotMe
 | 
			
		||||
        if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
 | 
			
		||||
            TaskManager.runTaskLater(new Runnable() {
 | 
			
		||||
 | 
			
		||||
            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.");
 | 
			
		||||
                // Didn't know of any other link :D
 | 
			
		||||
                log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
 | 
			
		||||
                IMP.disable();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (getJavaVersion() < 1.8) {
 | 
			
		||||
                log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
 | 
			
		||||
            }
 | 
			
		||||
            this.TASK = IMP.getTaskManager();
 | 
			
		||||
            if (C.ENABLED.s().length() > 0) {
 | 
			
		||||
                log(C.ENABLED.s());
 | 
			
		||||
            }
 | 
			
		||||
            setupConfigs();
 | 
			
		||||
            this.translationFile = new File(IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
 | 
			
		||||
            C.load(translationFile);
 | 
			
		||||
            setupDefaultFlags();
 | 
			
		||||
            setupDatabase();
 | 
			
		||||
            CommentManager.registerDefaultInboxes();
 | 
			
		||||
            // Tasks
 | 
			
		||||
            if (Settings.KILL_ROAD_MOBS) {
 | 
			
		||||
                IMP.runEntityTask();
 | 
			
		||||
            }
 | 
			
		||||
            // Events
 | 
			
		||||
            IMP.registerCommands();
 | 
			
		||||
            IMP.registerPlayerEvents();
 | 
			
		||||
            IMP.registerInventoryEvents();
 | 
			
		||||
            IMP.registerPlotPlusEvents();
 | 
			
		||||
            IMP.registerForceFieldEvents();
 | 
			
		||||
            IMP.registerWorldEditEvents();
 | 
			
		||||
            IMP.registerWorldEvents();
 | 
			
		||||
            if (Settings.METRICS) {
 | 
			
		||||
                IMP.startMetrics();
 | 
			
		||||
            } else {
 | 
			
		||||
                log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
 | 
			
		||||
            }
 | 
			
		||||
            IMP.startMetrics();
 | 
			
		||||
            if (Settings.TNT_LISTENER) {
 | 
			
		||||
                IMP.registerTNTListener();
 | 
			
		||||
            }
 | 
			
		||||
            if (Settings.CHUNK_PROCESSOR) {
 | 
			
		||||
                IMP.registerChunkProcessor();
 | 
			
		||||
            }
 | 
			
		||||
            // create UUIDWrapper
 | 
			
		||||
            UUIDHandler.implementation = IMP.initUUIDHandler();
 | 
			
		||||
            UUIDHandler.startCaching(null); // TODO maybe a notification when this is done?
 | 
			
		||||
            // create event util class
 | 
			
		||||
            EventUtil.manager = IMP.initEventUtil();
 | 
			
		||||
            // create Hybrid utility class
 | 
			
		||||
            HybridUtils.manager = IMP.initHybridUtils();
 | 
			
		||||
            // Inventory utility class
 | 
			
		||||
            InventoryUtil.manager = IMP.initInventoryUtil();
 | 
			
		||||
            // create setup util class
 | 
			
		||||
            SetupUtils.manager = IMP.initSetupUtils();
 | 
			
		||||
            // Set block
 | 
			
		||||
            BlockManager.manager = IMP.initBlockManager();
 | 
			
		||||
            // Set chunk
 | 
			
		||||
            ChunkManager.manager = IMP.initChunkManager();
 | 
			
		||||
            // Plot listener
 | 
			
		||||
            APlotListener.manager = IMP.initPlotListener();
 | 
			
		||||
            // Player manager
 | 
			
		||||
            PlayerManager.manager = IMP.initPlayerManager();
 | 
			
		||||
    
 | 
			
		||||
            // Check for updates
 | 
			
		||||
            TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    if (IMP.initPlotMeConverter()) {
 | 
			
		||||
                        log("&c=== IMPORTANT ===");
 | 
			
		||||
                        log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
 | 
			
		||||
                        log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
 | 
			
		||||
                        log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
 | 
			
		||||
                        log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
 | 
			
		||||
                    URL url = getUpdate();
 | 
			
		||||
                    if (url != null) {
 | 
			
		||||
                        update = url;
 | 
			
		||||
                        log("&6You are running an older version of PlotSquared...");
 | 
			
		||||
                        log("&8 - &3Use: &7/plot update");
 | 
			
		||||
                        log("&8 - &3Or: &7" + url);
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (LAST_VERSION != null && !StringMan.join(VERSION,".").equals(LAST_VERSION)) {
 | 
			
		||||
                        log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }, 200);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // Auto clearing
 | 
			
		||||
        if (Settings.AUTO_CLEAR) {
 | 
			
		||||
            ExpireManager.runTask();
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // World generators:
 | 
			
		||||
        ConfigurationSection section = config.getConfigurationSection("worlds");
 | 
			
		||||
        if (section != null) {
 | 
			
		||||
            for (String world : section.getKeys(false)) {
 | 
			
		||||
                if (BlockManager.manager.isWorld(world)) {
 | 
			
		||||
                    break;
 | 
			
		||||
            });
 | 
			
		||||
            
 | 
			
		||||
            // PlotMe
 | 
			
		||||
            if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
 | 
			
		||||
                TaskManager.runTaskLater(new Runnable() {
 | 
			
		||||
    
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        if (IMP.initPlotMeConverter()) {
 | 
			
		||||
                            log("&c=== IMPORTANT ===");
 | 
			
		||||
                            log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
 | 
			
		||||
                            log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
 | 
			
		||||
                            log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
 | 
			
		||||
                            log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }, 200);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // Auto clearing
 | 
			
		||||
            if (Settings.AUTO_CLEAR) {
 | 
			
		||||
                ExpireManager.runTask();
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // World generators:
 | 
			
		||||
            ConfigurationSection section = config.getConfigurationSection("worlds");
 | 
			
		||||
            if (section != null) {
 | 
			
		||||
                for (String world : section.getKeys(false)) {
 | 
			
		||||
                    if (BlockManager.manager.isWorld(world)) {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
    
 | 
			
		||||
            // Copy files
 | 
			
		||||
            copyFile("town.template", "templates");
 | 
			
		||||
            copyFile("skyblock.template", "templates");
 | 
			
		||||
            copyFile("german.yml", "translations");
 | 
			
		||||
            copyFile("s_chinese_unescaped.yml", "translations");
 | 
			
		||||
            copyFile("s_chinese.yml", "translations");
 | 
			
		||||
            copyFile("italian.yml", "translations");
 | 
			
		||||
            showDebug();
 | 
			
		||||
        }
 | 
			
		||||
        catch (Throwable e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Copy files
 | 
			
		||||
        copyFile("town.template", "templates");
 | 
			
		||||
        copyFile("skyblock.template", "templates");
 | 
			
		||||
        copyFile("german.yml", "translations");
 | 
			
		||||
        copyFile("s_chinese_unescaped.yml", "translations");
 | 
			
		||||
        copyFile("s_chinese.yml", "translations");
 | 
			
		||||
        copyFile("italian.yml", "translations");
 | 
			
		||||
        showDebug();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean checkVersion(int[] version, int major, int minor, int minor2) {
 | 
			
		||||
@@ -1260,7 +1265,7 @@ public class PS {
 | 
			
		||||
     */
 | 
			
		||||
    public void setupConfig() {
 | 
			
		||||
        LAST_VERSION = config.getString("version");
 | 
			
		||||
        config.set("version", VERSION);
 | 
			
		||||
        config.set("version", StringMan.join(VERSION,"."));
 | 
			
		||||
        
 | 
			
		||||
        final Map<String, Object> options = new HashMap<>();
 | 
			
		||||
        // Command confirmation
 | 
			
		||||
@@ -1553,7 +1558,7 @@ public class PS {
 | 
			
		||||
     * Setup the storage file (load + save missing nodes)
 | 
			
		||||
     */
 | 
			
		||||
    private void setupStorage() {
 | 
			
		||||
        storage.set("version", VERSION);
 | 
			
		||||
        storage.set("version", StringMan.join(VERSION,"."));
 | 
			
		||||
        final Map<String, Object> options = new HashMap<>();
 | 
			
		||||
        options.put("mysql.use", false);
 | 
			
		||||
        options.put("sqlite.use", true);
 | 
			
		||||
@@ -1611,7 +1616,7 @@ public class PS {
 | 
			
		||||
     * Setup the style.yml file
 | 
			
		||||
     */
 | 
			
		||||
    private void setupStyle() {
 | 
			
		||||
        style.set("version", VERSION);
 | 
			
		||||
        style.set("version", StringMan.join(VERSION,"."));
 | 
			
		||||
        final Map<String, Object> o = new HashMap<>();
 | 
			
		||||
        o.put("color.1", "6");
 | 
			
		||||
        o.put("color.2", "7");
 | 
			
		||||
 
 | 
			
		||||
@@ -28,8 +28,8 @@ import com.intellectualcrafters.plot.util.*;
 | 
			
		||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
 | 
			
		||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
 | 
			
		||||
import com.plotsquared.bukkit.generator.HybridGen;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.generator.ChunkGenerator;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 
 | 
			
		||||
@@ -27,9 +27,10 @@ import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.CommentInbox;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
 | 
			
		||||
import com.intellectualcrafters.plot.util.CommentManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.plotsquared.bukkit.object.comment.CommentManager;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ public class Delete extends SubCommand {
 | 
			
		||||
        if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
            return !sendMessage(plr, C.UNLINK_REQUIRED);
 | 
			
		||||
        }
 | 
			
		||||
        if (((!plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUIDWrapper().getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
 | 
			
		||||
        if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
 | 
			
		||||
            return !sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
 
 | 
			
		||||
@@ -26,10 +26,11 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.CommentInbox;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
 | 
			
		||||
import com.intellectualcrafters.plot.util.CommentManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
import com.plotsquared.bukkit.object.comment.CommentManager;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 
 | 
			
		||||
@@ -28,8 +28,9 @@ import com.intellectualcrafters.plot.flag.Flag;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.FlagManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.*;
 | 
			
		||||
import com.intellectualcrafters.plot.util.*;
 | 
			
		||||
import com.plotsquared.bukkit.listeners.APlotListener;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
import com.plotsquared.listener.APlotListener;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 
 | 
			
		||||
@@ -23,14 +23,16 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.SetupObject;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetupUtils;
 | 
			
		||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
 | 
			
		||||
import com.plotsquared.bukkit.generator.HybridGen;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.generator.ChunkGenerator;
 | 
			
		||||
 | 
			
		||||
@@ -52,14 +54,11 @@ public class Setup extends SubCommand {
 | 
			
		||||
    public void displayGenerators(PlotPlayer plr) {
 | 
			
		||||
        StringBuffer message = new StringBuffer();
 | 
			
		||||
        message.append("&6What generator do you want?");
 | 
			
		||||
        for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) {
 | 
			
		||||
        for (Entry<String, PlotGenerator<?>> entry : SetupUtils.generators.entrySet()) {
 | 
			
		||||
            if (entry.getKey().equals("PlotSquared")) {
 | 
			
		||||
                message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)");
 | 
			
		||||
            }
 | 
			
		||||
            else if (entry.getValue() instanceof HybridGen) {
 | 
			
		||||
                message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)");
 | 
			
		||||
            }
 | 
			
		||||
            else if (entry.getValue() instanceof BukkitPlotGenerator) {
 | 
			
		||||
            else if (entry.getValue().isFull()) {
 | 
			
		||||
                message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
@@ -119,7 +118,7 @@ public class Setup extends SubCommand {
 | 
			
		||||
                List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"});
 | 
			
		||||
                List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"});
 | 
			
		||||
                ArrayList<String> types = new ArrayList<>();
 | 
			
		||||
                if (SetupUtils.generators.get(object.setupGenerator) instanceof BukkitPlotGenerator) {
 | 
			
		||||
                if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
 | 
			
		||||
                    types.add("default");
 | 
			
		||||
                }
 | 
			
		||||
                types.add("augmented");
 | 
			
		||||
@@ -140,13 +139,13 @@ public class Setup extends SubCommand {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                object.type = allTypes.indexOf(args[0].toLowerCase());
 | 
			
		||||
                ChunkGenerator gen = SetupUtils.generators.get(object.setupGenerator);
 | 
			
		||||
                PlotGenerator<?> gen = SetupUtils.generators.get(object.setupGenerator);
 | 
			
		||||
                if (object.type == 0) {
 | 
			
		||||
                    object.current++;
 | 
			
		||||
                    if (object.step == null) {
 | 
			
		||||
                        object.plotManager = object.setupGenerator;
 | 
			
		||||
                        object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                        ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
 | 
			
		||||
                        object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                        SetupUtils.generators.get(object.plotManager).processSetup(object);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (object.step.length == 0) {
 | 
			
		||||
                        object.current = 4;
 | 
			
		||||
@@ -157,17 +156,17 @@ public class Setup extends SubCommand {
 | 
			
		||||
                    final ConfigurationNode step = object.step[object.setup_index];
 | 
			
		||||
                    sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (gen instanceof BukkitPlotGenerator) {
 | 
			
		||||
                    if (gen.isFull()) {
 | 
			
		||||
                        object.plotManager = object.setupGenerator;
 | 
			
		||||
                        object.setupGenerator = null;
 | 
			
		||||
                        object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                        ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
 | 
			
		||||
                        object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                        SetupUtils.generators.get(object.plotManager).processSetup(object);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        object.plotManager = "PlotSquared";
 | 
			
		||||
                        MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
 | 
			
		||||
                        MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
 | 
			
		||||
                        object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                        object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                    }
 | 
			
		||||
                    MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
 | 
			
		||||
                }
 | 
			
		||||
@@ -183,7 +182,7 @@ public class Setup extends SubCommand {
 | 
			
		||||
                object.terrain = terrain.indexOf(args[0].toLowerCase());
 | 
			
		||||
                object.current++;
 | 
			
		||||
                if (object.step == null) {
 | 
			
		||||
                    object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                    object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
 | 
			
		||||
                }
 | 
			
		||||
                final ConfigurationNode step = object.step[object.setup_index];
 | 
			
		||||
                sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
 | 
			
		||||
 
 | 
			
		||||
@@ -28,8 +28,8 @@ import com.intellectualcrafters.plot.config.ConfigurationNode;
 | 
			
		||||
import com.intellectualcrafters.plot.object.*;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetupUtils;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 
 | 
			
		||||
@@ -209,10 +209,8 @@ public enum C {
 | 
			
		||||
    /*
 | 
			
		||||
     * Title Stuff
 | 
			
		||||
     */
 | 
			
		||||
    TITLE_ENTERED_PLOT("Plot: %world%;%x%;%z%", "Titles"),
 | 
			
		||||
    TITLE_ENTERED_PLOT_COLOR("GOLD", "Titles"),
 | 
			
		||||
    TITLE_ENTERED_PLOT_SUB("Owned by %s", "Titles"),
 | 
			
		||||
    TITLE_ENTERED_PLOT_SUB_COLOR("RED", "Titles"),
 | 
			
		||||
    TITLE_ENTERED_PLOT("$1Plot: %world%;%x%;%z%", "Titles"),
 | 
			
		||||
    TITLE_ENTERED_PLOT_SUB("$4Owned by %s", "Titles"),
 | 
			
		||||
    PREFIX_GREETING("$1%id%$2> ", "Titles"),
 | 
			
		||||
    PREFIX_FAREWELL("$1%id%$2> ", "Titles"),
 | 
			
		||||
    /*
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.generator;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotCluster;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.SetupObject;
 | 
			
		||||
 | 
			
		||||
public abstract class PlotGenerator<T> {
 | 
			
		||||
    public final String world;
 | 
			
		||||
@@ -46,4 +47,6 @@ public abstract class PlotGenerator<T> {
 | 
			
		||||
    public abstract boolean isFull();
 | 
			
		||||
    
 | 
			
		||||
    public abstract String getName();
 | 
			
		||||
    
 | 
			
		||||
    public abstract void processSetup(SetupObject object);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
package com.intellectualcrafters.plot.object;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetupUtils;
 | 
			
		||||
 | 
			
		||||
public class SetupObject {
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,77 @@
 | 
			
		||||
package com.intellectualcrafters.plot.util;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.*;
 | 
			
		||||
import com.plotsquared.bukkit.titles.AbstractTitle;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CommentManager {
 | 
			
		||||
    public static HashMap<String, CommentInbox> inboxes = new HashMap<>();
 | 
			
		||||
    
 | 
			
		||||
    public static void sendTitle(final PlotPlayer player, final Plot plot) {
 | 
			
		||||
        if (!Settings.COMMENT_NOTIFICATIONS) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.isOwner(player.getUUID())) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        TaskManager.runTaskLaterAsync(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                Collection<CommentInbox> boxes = CommentManager.inboxes.values();
 | 
			
		||||
                final AtomicInteger count = new AtomicInteger(0);
 | 
			
		||||
                final AtomicInteger size = new AtomicInteger(boxes.size());
 | 
			
		||||
                for (final CommentInbox inbox : inboxes.values()) {
 | 
			
		||||
                    inbox.getComments(plot, new RunnableVal() {
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public void run() {
 | 
			
		||||
                            int total;
 | 
			
		||||
                            if (value != null) {
 | 
			
		||||
                                int num = 0;
 | 
			
		||||
                                for (PlotComment comment : (ArrayList<PlotComment>) value) {
 | 
			
		||||
                                    if (comment.timestamp > getTimestamp(player, inbox.toString())) {
 | 
			
		||||
                                        num++;
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                total = count.addAndGet(num);
 | 
			
		||||
                            }
 | 
			
		||||
                            else {
 | 
			
		||||
                                total = count.get();
 | 
			
		||||
                            }
 | 
			
		||||
                            if (size.decrementAndGet() == 0 && total > 0) {
 | 
			
		||||
                                AbstractTitle.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total));
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }, 20);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static long getTimestamp(PlotPlayer player, String inbox) {
 | 
			
		||||
        Object meta = player.getMeta("inbox:"+inbox);
 | 
			
		||||
        if (meta == null) {
 | 
			
		||||
            return player.getPreviousLogin();
 | 
			
		||||
        }
 | 
			
		||||
        return (Long) meta;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void addInbox(CommentInbox inbox) {
 | 
			
		||||
        inboxes.put(inbox.toString().toLowerCase(), inbox);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void registerDefaultInboxes() {
 | 
			
		||||
        addInbox(new InboxReport());
 | 
			
		||||
        addInbox(new InboxPublic());
 | 
			
		||||
        addInbox(new InboxOwner());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotCluster;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.plotsquared.bukkit.util.SetupUtils;
 | 
			
		||||
 | 
			
		||||
public abstract class EventUtil {
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,106 @@ public class MathMan {
 | 
			
		||||
        }
 | 
			
		||||
        return count / array.length;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns [x, y, z]
 | 
			
		||||
     * @param yaw
 | 
			
		||||
     * @param pitch
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public static float[] getDirection(float yaw, float pitch) {
 | 
			
		||||
        double pitch_sin = Math.sin(pitch);
 | 
			
		||||
        return new float[] {
 | 
			
		||||
                (float) (pitch_sin * Math.cos(yaw)),
 | 
			
		||||
                (float) (pitch_sin * Math.sin(yaw)),
 | 
			
		||||
                (float) Math.cos(pitch)
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns [ pitch, yaw ]
 | 
			
		||||
     * @param x
 | 
			
		||||
     * @param y
 | 
			
		||||
     * @param z
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public static float[] getPitchAndYaw(float x, float y, float z) {
 | 
			
		||||
        float distance = sqrtApprox(z * z + x * x);
 | 
			
		||||
        return new float[] { atan2(y, distance), atan2(x, z) };
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private static final int ATAN2_BITS = 7;
 | 
			
		||||
    
 | 
			
		||||
    private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
 | 
			
		||||
    private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
 | 
			
		||||
    private static final int ATAN2_COUNT = ATAN2_MASK + 1;
 | 
			
		||||
    private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
 | 
			
		||||
    
 | 
			
		||||
    private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
 | 
			
		||||
    
 | 
			
		||||
    private static final float[] atan2 = new float[ATAN2_COUNT];
 | 
			
		||||
    
 | 
			
		||||
    static {
 | 
			
		||||
        for (int i = 0; i < ATAN2_DIM; i++) {
 | 
			
		||||
            for (int j = 0; j < ATAN2_DIM; j++) {
 | 
			
		||||
                float x0 = (float) i / ATAN2_DIM;
 | 
			
		||||
                float y0 = (float) j / ATAN2_DIM;
 | 
			
		||||
                
 | 
			
		||||
                atan2[j * ATAN2_DIM + i] = (float) Math.atan2(y0, x0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static final float atan2(float y, float x) {
 | 
			
		||||
        float add, mul;
 | 
			
		||||
        
 | 
			
		||||
        if (x < 0.0f) {
 | 
			
		||||
            if (y < 0.0f) {
 | 
			
		||||
                x = -x;
 | 
			
		||||
                y = -y;
 | 
			
		||||
                
 | 
			
		||||
                mul = 1.0f;
 | 
			
		||||
            } else {
 | 
			
		||||
                x = -x;
 | 
			
		||||
                mul = -1.0f;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            add = -3.141592653f;
 | 
			
		||||
        } else {
 | 
			
		||||
            if (y < 0.0f) {
 | 
			
		||||
                y = -y;
 | 
			
		||||
                mul = -1.0f;
 | 
			
		||||
            } else {
 | 
			
		||||
                mul = 1.0f;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            add = 0.0f;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
 | 
			
		||||
        
 | 
			
		||||
        int xi = (int) (x * invDiv);
 | 
			
		||||
        int yi = (int) (y * invDiv);
 | 
			
		||||
        
 | 
			
		||||
        return (atan2[yi * ATAN2_DIM + xi] + add) * mul;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static float sqrtApprox(float f) {
 | 
			
		||||
        return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static double sqrtApprox(double d) {
 | 
			
		||||
        return Double.longBitsToDouble( ( ( Double.doubleToLongBits( d )-(1l<<52) )>>1 ) + ( 1l<<61 ) );
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static float invSqrt(float x) {
 | 
			
		||||
        float xhalf = 0.5f*x;
 | 
			
		||||
        int i = Float.floatToIntBits(x);
 | 
			
		||||
        i = 0x5f3759df - (i>>1);
 | 
			
		||||
        x = Float.intBitsToFloat(i);
 | 
			
		||||
        x = x*(1.5f - xhalf*x*x);
 | 
			
		||||
        return x;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static int getPositiveId(int i) {
 | 
			
		||||
        if (i < 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package com.intellectualcrafters.plot.util;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.SetupObject;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.generator.ChunkGenerator;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public abstract class SetupUtils {
 | 
			
		||||
 | 
			
		||||
    public static SetupUtils manager;
 | 
			
		||||
    
 | 
			
		||||
    public final static Map<String, SetupObject> setupMap = new HashMap<>();
 | 
			
		||||
    public static HashMap<String, PlotGenerator<?>> generators = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    public abstract void updateGenerators();
 | 
			
		||||
 | 
			
		||||
    public abstract String getGenerator(PlotWorld plotworld);
 | 
			
		||||
    
 | 
			
		||||
    public abstract String setupWorld(final SetupObject object);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user