mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Fix redstone comparators + more work on plot analysis
This commit is contained in:
		@@ -1115,7 +1115,7 @@ public class PS {
 | 
			
		||||
            FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
 | 
			
		||||
        }
 | 
			
		||||
        FlagManager.addFlag(new AbstractFlag("modified-blocks", new FlagValue.IntegerValue()), true);
 | 
			
		||||
        FlagManager.addFlag(new AbstractFlag("analysis", new FlagValue.DoubleListValue()), true);
 | 
			
		||||
        FlagManager.addFlag(new AbstractFlag("analysis", new FlagValue.IntegerListValue()), true);
 | 
			
		||||
        FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue()));
 | 
			
		||||
        FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
 | 
			
		||||
        FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
 | 
			
		||||
@@ -1236,9 +1236,9 @@ public class PS {
 | 
			
		||||
        options.put("clear.auto.enabled", false);
 | 
			
		||||
        options.put("clear.auto.days", 365);
 | 
			
		||||
        options.put("clear.auto.clear-interval-seconds", Settings.CLEAR_INTERVAL);
 | 
			
		||||
        options.put("clear.auto.calibration.changes", 64);
 | 
			
		||||
        options.put("clear.auto.calibration.faces", 32);
 | 
			
		||||
        options.put("clear.auto.calibration.data", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.changes", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.faces", 2);
 | 
			
		||||
        options.put("clear.auto.calibration.data", 32);
 | 
			
		||||
        options.put("clear.auto.calibration.air", 32);
 | 
			
		||||
        options.put("clear.auto.calibration.variety", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.changes_sd", 64);
 | 
			
		||||
@@ -1246,8 +1246,7 @@ public class PS {
 | 
			
		||||
        options.put("clear.auto.calibration.data_sd", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.air_sd", 32);
 | 
			
		||||
        options.put("clear.auto.calibration.variety_sd", 1);
 | 
			
		||||
        options.put("clear.auto.threshold-percent", Settings.CLEAR_THRESHOLD);
 | 
			
		||||
        options.put("clear.ignore-if-modified", Settings.MIN_BLOCKS_CHANGED_IGNORED);
 | 
			
		||||
        options.put("clear.auto.threshold", Settings.CLEAR_THRESHOLD);
 | 
			
		||||
 | 
			
		||||
        // Schematics
 | 
			
		||||
        options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
 | 
			
		||||
@@ -1332,7 +1331,7 @@ public class PS {
 | 
			
		||||
        Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
 | 
			
		||||
        Settings.MIN_BLOCKS_CHANGED_IGNORED = config.getInt("clear.ignore-if-modified");
 | 
			
		||||
        Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
 | 
			
		||||
        Settings.CLEAR_THRESHOLD = config.getInt("clear.auto.threshold-percent");
 | 
			
		||||
        Settings.CLEAR_THRESHOLD = config.getInt("clear.auto.threshold");
 | 
			
		||||
        Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
 | 
			
		||||
        Settings.CLEAR_INTERVAL = config.getInt("clear.auto.clear-interval-seconds");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer player, final String... args) {
 | 
			
		||||
        final List<String> allowed_params = Arrays.asList("analyze", "reset-modified", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check");
 | 
			
		||||
        final List<String> allowed_params = Arrays.asList("analyze", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check");
 | 
			
		||||
        if (args.length > 0) {
 | 
			
		||||
            final String arg = args[0].toLowerCase();
 | 
			
		||||
            switch (arg) {
 | 
			
		||||
@@ -67,7 +67,6 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public void run() {
 | 
			
		||||
                            PS.log("&cTHIS FUNCTION IS A WORK IN PROGRESS");
 | 
			
		||||
                            PS.log("&c - ");
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                    return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ public class BukkitHybridUtils extends HybridUtils {
 | 
			
		||||
    private long last;
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void analyzePlot(Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
 | 
			
		||||
    public void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
 | 
			
		||||
        // TODO Auto-generated method stub
 | 
			
		||||
        // int diff, int variety, int verticies, int rotation, int height_sd
 | 
			
		||||
 | 
			
		||||
@@ -100,7 +100,6 @@ public class BukkitHybridUtils extends HybridUtils {
 | 
			
		||||
        final Runnable run = new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                int t = 0;
 | 
			
		||||
                for (Chunk chunk : processed_chunks) {
 | 
			
		||||
                    short[][] result = gen.generateExtBlockSections(world, r, chunk.getX(), chunk.getZ(), base);
 | 
			
		||||
                    int X = chunk.getX();
 | 
			
		||||
@@ -145,7 +144,6 @@ public class BukkitHybridUtils extends HybridUtils {
 | 
			
		||||
                            short old = oldblocks[y][x][z];
 | 
			
		||||
                            short now = newblocks[y][x][z];
 | 
			
		||||
                            if (old != now) {
 | 
			
		||||
                                t++;
 | 
			
		||||
                                changes[i]++;
 | 
			
		||||
                            }
 | 
			
		||||
                            if (now == 0) {
 | 
			
		||||
@@ -190,28 +188,27 @@ public class BukkitHybridUtils extends HybridUtils {
 | 
			
		||||
                analysis.air = (int) (MathMan.getMean(air) * 100);
 | 
			
		||||
                analysis.variety = (int) (MathMan.getMean(variety) * 100);
 | 
			
		||||
                
 | 
			
		||||
                analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes) * 100);
 | 
			
		||||
                analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces) * 100);
 | 
			
		||||
                analysis.data_sd = (int) (MathMan.getSD(data, analysis.data) * 100);
 | 
			
		||||
                analysis.air_sd = (int) (MathMan.getSD(air, analysis.air) * 100);
 | 
			
		||||
                analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety) * 100);
 | 
			
		||||
                analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes));
 | 
			
		||||
                analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces));
 | 
			
		||||
                analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
 | 
			
		||||
                analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
 | 
			
		||||
                analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
 | 
			
		||||
                
 | 
			
		||||
                // We'll set the flag later
 | 
			
		||||
//                List<Integer> result = new ArrayList<>();
 | 
			
		||||
//                result.add(analysis.changes);
 | 
			
		||||
//                result.add(analysis.faces);
 | 
			
		||||
//                result.add(analysis.data);
 | 
			
		||||
//                result.add(analysis.air);
 | 
			
		||||
//                result.add(analysis.variety);
 | 
			
		||||
//                
 | 
			
		||||
//                result.add(analysis.changes_sd);
 | 
			
		||||
//                result.add(analysis.faces_sd);
 | 
			
		||||
//                result.add(analysis.data_sd);
 | 
			
		||||
//                result.add(analysis.air_sd);
 | 
			
		||||
//                result.add(analysis.variety_sd);
 | 
			
		||||
//                
 | 
			
		||||
//                Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
 | 
			
		||||
//                FlagManager.addPlotFlag(plot, flag);
 | 
			
		||||
                List<Integer> result = new ArrayList<>();
 | 
			
		||||
                result.add(analysis.changes);
 | 
			
		||||
                result.add(analysis.faces);
 | 
			
		||||
                result.add(analysis.data);
 | 
			
		||||
                result.add(analysis.air);
 | 
			
		||||
                result.add(analysis.variety);
 | 
			
		||||
                
 | 
			
		||||
                result.add(analysis.changes_sd);
 | 
			
		||||
                result.add(analysis.faces_sd);
 | 
			
		||||
                result.add(analysis.data_sd);
 | 
			
		||||
                result.add(analysis.air_sd);
 | 
			
		||||
                result.add(analysis.variety_sd);
 | 
			
		||||
                
 | 
			
		||||
                Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
 | 
			
		||||
                FlagManager.addPlotFlag(plot, flag);
 | 
			
		||||
                
 | 
			
		||||
                whenDone.value = analysis;
 | 
			
		||||
                whenDone.run();
 | 
			
		||||
@@ -248,15 +245,9 @@ public class BukkitHybridUtils extends HybridUtils {
 | 
			
		||||
                else maxX = 16;
 | 
			
		||||
                if (Z == ctz) maxZ = MathMan.mod(tz);
 | 
			
		||||
                else maxZ = 16;
 | 
			
		||||
 | 
			
		||||
                System.out.print("VALUES ====================");
 | 
			
		||||
                System.out.print(X + "," + Z + " | " + cbx + "," + cbz + " | " + bx + "," + bz);
 | 
			
		||||
                System.out.print("VALUES ====================");
 | 
			
		||||
                
 | 
			
		||||
                int xb = ((X) << 4) - bx;
 | 
			
		||||
                int zb = ((Z) << 4) - bz;
 | 
			
		||||
                
 | 
			
		||||
                System.out.print(xb + "," + zb + " | " + minX + "," + minZ + " | " + maxX + "," + maxZ);
 | 
			
		||||
 | 
			
		||||
                for (int x = minX; x <= maxX; x++) {
 | 
			
		||||
                    for (int z = minZ; z <= maxZ; z++) {
 | 
			
		||||
 
 | 
			
		||||
@@ -218,10 +218,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
 | 
			
		||||
                if (plot == null) {
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "redstone")) {
 | 
			
		||||
                    return;
 | 
			
		||||
                if (FlagManager.isPlotFlagFalse(plot, "redstone")) {
 | 
			
		||||
                    event.setCancelled(true);
 | 
			
		||||
                }
 | 
			
		||||
                event.setCancelled(true);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            case 122:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,17 +1,21 @@
 | 
			
		||||
package com.intellectualcrafters.plot.object;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.lang.reflect.Array;
 | 
			
		||||
import java.util.ArrayDeque;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.mutable.MutableInt;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.Flag;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.FlagManager;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MathMan;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
 | 
			
		||||
public class PlotAnalysis {
 | 
			
		||||
@@ -82,11 +86,15 @@ public class PlotAnalysis {
 | 
			
		||||
     *  - Will be used to calibrate the threshold for plot clearing
 | 
			
		||||
     * @param whenDone
 | 
			
		||||
     */
 | 
			
		||||
    public static void calcOptimalModifiers(final Runnable whenDone) {
 | 
			
		||||
    public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
 | 
			
		||||
        if (running) {
 | 
			
		||||
            PS.log("Calibration task already in progress!");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (threshold < 0 || threshold >= 1) {
 | 
			
		||||
            PS.log("Invalid threshold provided!");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        running = true;
 | 
			
		||||
        PS.log(" - Fetching all plots");
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots());
 | 
			
		||||
@@ -142,17 +150,29 @@ public class PlotAnalysis {
 | 
			
		||||
                ratingAnalysis.start();
 | 
			
		||||
                
 | 
			
		||||
                final ArrayDeque<Plot> plotsQueue = new ArrayDeque<>(plots);
 | 
			
		||||
                Plot queuePlot;
 | 
			
		||||
                while ((queuePlot = plotsQueue.poll()) != null) {
 | 
			
		||||
                while (true) {
 | 
			
		||||
                    final Plot queuePlot = plotsQueue.poll();
 | 
			
		||||
                    if (queuePlot == null) {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    PS.log(" | " + queuePlot);
 | 
			
		||||
                    final Thread thread = Thread.currentThread();
 | 
			
		||||
                    analyzePlot(queuePlot, new RunnableVal<PlotAnalysis>() {
 | 
			
		||||
                    final Object lock = new Object();
 | 
			
		||||
                    TaskManager.runTask(new Runnable() {
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public void run() {
 | 
			
		||||
                            thread.notify();
 | 
			
		||||
                            analyzePlot(queuePlot, new RunnableVal<PlotAnalysis>() {
 | 
			
		||||
                                public void run() {
 | 
			
		||||
                                    synchronized (lock) {
 | 
			
		||||
                                        lock.notify();
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                    try {
 | 
			
		||||
                        thread.wait();
 | 
			
		||||
                        synchronized (lock) {
 | 
			
		||||
                            lock.wait();
 | 
			
		||||
                        }
 | 
			
		||||
                    } catch (InterruptedException e) {
 | 
			
		||||
                        e.printStackTrace();
 | 
			
		||||
                    }
 | 
			
		||||
@@ -184,143 +204,125 @@ public class PlotAnalysis {
 | 
			
		||||
                    variety_sd[i] = analysis.variety_sd;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                PS.log(" - $1Calculating rankings");
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_ratings = rank(ratings);
 | 
			
		||||
                int n = rank_ratings.length;
 | 
			
		||||
                
 | 
			
		||||
                int optimal_index = (int) Math.round((1 - threshold) * (n - 1));
 | 
			
		||||
                
 | 
			
		||||
                PS.log(" - $1Calculating rank correlation: ");
 | 
			
		||||
                PS.log(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the ranked plots");
 | 
			
		||||
                PS.log(" - The calculated correlation constant will be used to calibrate the threshold for auto plot clearing");
 | 
			
		||||
                PS.log(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
 | 
			
		||||
                PS.log(" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_changes = rank(changes);
 | 
			
		||||
                int[] sd_changes = getSD(rank_changes);
 | 
			
		||||
                int[] sd_changes = getSD(rank_changes, rank_ratings);
 | 
			
		||||
                int[] variance_changes = square(sd_changes);
 | 
			
		||||
                int sum_changes = sum(variance_changes);
 | 
			
		||||
                double factor_changes = getCC(n, sum_changes);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.changes = (int) (factor_changes * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) (factor_changes * 1000 / MathMan.getMean(changes));
 | 
			
		||||
                PS.log(" - | changes " + factor_changes);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_faces = rank(faces);
 | 
			
		||||
                int[] sd_faces = getSD(rank_faces);
 | 
			
		||||
                int[] sd_faces = getSD(rank_faces, rank_ratings);
 | 
			
		||||
                int[] variance_faces = square(sd_faces);
 | 
			
		||||
                int sum_faces = sum(variance_faces);
 | 
			
		||||
                double factor_faces = getCC(n, sum_faces);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.faces = (int) (factor_faces * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) (factor_faces * 1000 / MathMan.getMean(faces));
 | 
			
		||||
                PS.log(" - | faces " + factor_faces);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_data = rank(data);
 | 
			
		||||
                int[] sd_data = getSD(rank_data);
 | 
			
		||||
                int[] sd_data = getSD(rank_data, rank_ratings);
 | 
			
		||||
                int[] variance_data = square(sd_data);
 | 
			
		||||
                int sum_data = sum(variance_data);
 | 
			
		||||
                double factor_data = getCC(n, sum_data);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.data = (int) (factor_data * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data));
 | 
			
		||||
                PS.log(" - | data " + factor_data);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_air = rank(air);
 | 
			
		||||
                int[] sd_air = getSD(rank_air);
 | 
			
		||||
                int[] sd_air = getSD(rank_air, rank_ratings);
 | 
			
		||||
                int[] variance_air = square(sd_air);
 | 
			
		||||
                int sum_air = sum(variance_air);
 | 
			
		||||
                double factor_air = getCC(n, sum_air);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.air = (int) (factor_air * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air));
 | 
			
		||||
                PS.log(" - | air " + factor_air);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_variety = rank(variety);
 | 
			
		||||
                int[] sd_variety = getSD(rank_variety);
 | 
			
		||||
                int[] sd_variety = getSD(rank_variety, rank_ratings);
 | 
			
		||||
                int[] variance_variety = square(sd_variety);
 | 
			
		||||
                int sum_variety = sum(variance_variety);
 | 
			
		||||
                double factor_variety = getCC(n, sum_variety);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.variety = (int) (factor_variety * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) (factor_variety * 1000 / MathMan.getMean(variety));
 | 
			
		||||
                PS.log(" - | variety " + factor_variety);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_changes_sd = rank(changes_sd);
 | 
			
		||||
                int[] sd_changes_sd = getSD(rank_changes_sd);
 | 
			
		||||
                int[] sd_changes_sd = getSD(rank_changes_sd, rank_ratings);
 | 
			
		||||
                int[] variance_changes_sd = square(sd_changes_sd);
 | 
			
		||||
                int sum_changes_sd = sum(variance_changes_sd);
 | 
			
		||||
                double factor_changes_sd = getCC(n, sum_changes_sd);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.changes_sd = (int) (factor_changes_sd * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
 | 
			
		||||
                PS.log(" - | changes_sd " + factor_changes_sd);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_faces_sd = rank(faces_sd);
 | 
			
		||||
                int[] sd_faces_sd = getSD(rank_faces_sd);
 | 
			
		||||
                int[] sd_faces_sd = getSD(rank_faces_sd, rank_ratings);
 | 
			
		||||
                int[] variance_faces_sd = square(sd_faces_sd);
 | 
			
		||||
                int sum_faces_sd = sum(variance_faces_sd);
 | 
			
		||||
                double factor_faces_sd = getCC(n, sum_faces_sd);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.faces_sd = (int) (factor_faces_sd * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
 | 
			
		||||
                PS.log(" - | faces_sd " + factor_faces_sd);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_data_sd = rank(data_sd);
 | 
			
		||||
                int[] sd_data_sd = getSD(rank_data_sd);
 | 
			
		||||
                int[] sd_data_sd = getSD(rank_data_sd, rank_ratings);
 | 
			
		||||
                int[] variance_data_sd = square(sd_data_sd);
 | 
			
		||||
                int sum_data_sd = sum(variance_data_sd);
 | 
			
		||||
                double factor_data_sd = getCC(n, sum_data_sd);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.data_sd = (int) (factor_data_sd * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
 | 
			
		||||
                PS.log(" - | data_sd " + factor_data_sd);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_air_sd = rank(air_sd);
 | 
			
		||||
                int[] sd_air_sd = getSD(rank_air_sd);
 | 
			
		||||
                int[] sd_air_sd = getSD(rank_air_sd, rank_ratings);
 | 
			
		||||
                int[] variance_air_sd = square(sd_air_sd);
 | 
			
		||||
                int sum_air_sd = sum(variance_air_sd);
 | 
			
		||||
                double factor_air_sd = getCC(n, sum_air_sd);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.air_sd = (int) (factor_air_sd * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd));
 | 
			
		||||
                PS.log(" - | air_sd " + factor_air_sd);
 | 
			
		||||
                
 | 
			
		||||
                int[] rank_variety_sd = rank(variety_sd);
 | 
			
		||||
                int[] sd_variety_sd = getSD(rank_variety_sd);
 | 
			
		||||
                int[] sd_variety_sd = getSD(rank_variety_sd, rank_ratings);
 | 
			
		||||
                int[] variance_variety_sd = square(sd_variety_sd);
 | 
			
		||||
                int sum_variety_sd = sum(variance_variety_sd);
 | 
			
		||||
                double factor_variety_sd = getCC(n, sum_variety_sd);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.variety_sd = (int) (factor_variety_sd * 100);
 | 
			
		||||
                PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
 | 
			
		||||
                PS.log(" - | variety_sd " + factor_variety_sd);
 | 
			
		||||
                
 | 
			
		||||
                // Save modifiers
 | 
			
		||||
                
 | 
			
		||||
                
 | 
			
		||||
                PlotAnalysis analysis = getAnalysis(plots.get(Arrays.asList(rank_ratings).indexOf(optimal_index)));
 | 
			
		||||
                
 | 
			
		||||
                // Save calibration
 | 
			
		||||
                PS.log(" $1Saving calibration");
 | 
			
		||||
                YamlConfiguration config = PS.get().config;
 | 
			
		||||
                config.set("clear.auto.calibration.changes", PlotAnalysis.MODIFIERS.changes);
 | 
			
		||||
                config.set("clear.auto.calibration.faces", PlotAnalysis.MODIFIERS.faces);
 | 
			
		||||
                config.set("clear.auto.calibration.data", PlotAnalysis.MODIFIERS.data);
 | 
			
		||||
                config.set("clear.auto.calibration.air", PlotAnalysis.MODIFIERS.air);
 | 
			
		||||
                config.set("clear.auto.calibration.variety", PlotAnalysis.MODIFIERS.variety);
 | 
			
		||||
                config.set("clear.auto.calibration.changes_sd", PlotAnalysis.MODIFIERS.changes_sd);
 | 
			
		||||
                config.set("clear.auto.calibration.faces_sd", PlotAnalysis.MODIFIERS.faces_sd);
 | 
			
		||||
                config.set("clear.auto.calibration.data_sd", PlotAnalysis.MODIFIERS.data_sd);
 | 
			
		||||
                config.set("clear.auto.calibration.air_sd", PlotAnalysis.MODIFIERS.air_sd);
 | 
			
		||||
                config.set("clear.auto.calibration.variety_sd", PlotAnalysis.MODIFIERS.variety_sd);
 | 
			
		||||
                try {
 | 
			
		||||
                    PS.get().config.save(PS.get().configFile);
 | 
			
		||||
                } catch (IOException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                PS.log(" $1Done!");
 | 
			
		||||
                running = false;
 | 
			
		||||
                whenDone.run();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        // sort plots by popularity
 | 
			
		||||
        
 | 
			
		||||
        // get the arrays for each modifier
 | 
			
		||||
 | 
			
		||||
        // get the rankings for each modifier
 | 
			
		||||
        
 | 
			
		||||
        /*
 | 
			
		||||
         * For each modifier:
 | 
			
		||||
         *  - get the arrays
 | 
			
		||||
         *  - get the rankings
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void logln(Object obj) {
 | 
			
		||||
        System.out.println(log(obj));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static String log(Object obj) {
 | 
			
		||||
        String result = "";
 | 
			
		||||
        if (obj.getClass().isArray()) {
 | 
			
		||||
            String prefix = "";
 | 
			
		||||
            
 | 
			
		||||
            for(int i=0; i<Array.getLength(obj); i++){
 | 
			
		||||
                result += prefix + log(Array.get(obj, i));
 | 
			
		||||
                prefix = ",";
 | 
			
		||||
            }
 | 
			
		||||
            return "( " + result + " )";
 | 
			
		||||
        }
 | 
			
		||||
        else if (obj instanceof List<?>) {
 | 
			
		||||
            String prefix = "";
 | 
			
		||||
            for (Object element : (List<?>) obj) {
 | 
			
		||||
                result += prefix + log(element);
 | 
			
		||||
                prefix = ",";
 | 
			
		||||
            }
 | 
			
		||||
            return "[ " + result + " ]";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return obj.toString();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ import com.intellectualcrafters.plot.generator.ClassicPlotManager;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.HybridUtils;
 | 
			
		||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotHandler;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
@@ -122,40 +123,68 @@ public class ExpireManager {
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
                        RunnableVal run = new RunnableVal<Integer>() {
 | 
			
		||||
                            @Override
 | 
			
		||||
                            public void run() {
 | 
			
		||||
                                int changed = this.value;
 | 
			
		||||
                                if (Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.MIN_BLOCKS_CHANGED > 0 && manager instanceof ClassicPlotManager) {
 | 
			
		||||
                                    if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) {
 | 
			
		||||
                                        PS.log("&7[&5Expire&dManager&7] &bKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
 | 
			
		||||
                                        FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("keep"), true));
 | 
			
		||||
                                        expiredPlots.get(world).remove(plot);
 | 
			
		||||
                                        return;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    else if (changed >= Settings.MIN_BLOCKS_CHANGED_IGNORED && Settings.MIN_BLOCKS_CHANGED_IGNORED > 0) {
 | 
			
		||||
                                        PS.log("&7[&5Expire&dManager&7] &bIgnoring modified plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
 | 
			
		||||
                                        FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("modified-blocks"), value));
 | 
			
		||||
                                        expiredPlots.get(world).remove(plot);
 | 
			
		||||
                                        return;
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                if (plot.settings.isMerged()) {
 | 
			
		||||
                                    MainUtil.unlinkPlot(plot);
 | 
			
		||||
                                }
 | 
			
		||||
                                plot.delete();
 | 
			
		||||
                                expiredPlots.get(world).remove(plot);
 | 
			
		||||
                                PS.log("&7[&5Expire&dManager&7] &cDeleted expired plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
 | 
			
		||||
                                PS.log("&3 - World: " + plot.world);
 | 
			
		||||
                                if (plot.hasOwner()) {
 | 
			
		||||
                                    PS.log("&3 - Owner: " + UUIDHandler.getName(plot.owner));
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    PS.log("&3 - Owner: Unowned");
 | 
			
		||||
                                }
 | 
			
		||||
//                        RunnableVal<Integer> run = new RunnableVal<Integer>() {
 | 
			
		||||
//                            @Override
 | 
			
		||||
//                            public void run() {
 | 
			
		||||
//                                int changed = this.value;
 | 
			
		||||
//                                if (Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.MIN_BLOCKS_CHANGED > 0 && manager instanceof ClassicPlotManager) {
 | 
			
		||||
//                                    if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) {
 | 
			
		||||
//                                        PS.log("&7[&5Expire&dManager&7] &bKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
 | 
			
		||||
//                                        FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("keep"), true));
 | 
			
		||||
//                                        expiredPlots.get(world).remove(plot);
 | 
			
		||||
//                                        return;
 | 
			
		||||
//                                    }
 | 
			
		||||
//                                    else if (changed >= Settings.MIN_BLOCKS_CHANGED_IGNORED && Settings.MIN_BLOCKS_CHANGED_IGNORED > 0) {
 | 
			
		||||
//                                        PS.log("&7[&5Expire&dManager&7] &bIgnoring modified plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
 | 
			
		||||
//                                        FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("modified-blocks"), value));
 | 
			
		||||
//                                        expiredPlots.get(world).remove(plot);
 | 
			
		||||
//                                        return;
 | 
			
		||||
//                                    }
 | 
			
		||||
//                                }
 | 
			
		||||
//                                if (plot.settings.isMerged()) {
 | 
			
		||||
//                                    MainUtil.unlinkPlot(plot);
 | 
			
		||||
//                                }
 | 
			
		||||
//                                plot.delete();
 | 
			
		||||
//                                expiredPlots.get(world).remove(plot);
 | 
			
		||||
//                                PS.log("&7[&5Expire&dManager&7] &cDeleted expired plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
 | 
			
		||||
//                                PS.log("&3 - World: " + plot.world);
 | 
			
		||||
//                                if (plot.hasOwner()) {
 | 
			
		||||
//                                    PS.log("&3 - Owner: " + UUIDHandler.getName(plot.owner));
 | 
			
		||||
//                                } else {
 | 
			
		||||
//                                    PS.log("&3 - Owner: Unowned");
 | 
			
		||||
//                                }
 | 
			
		||||
//                            }
 | 
			
		||||
//                        };
 | 
			
		||||
                        if ((Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.CLEAR_THRESHOLD != 100) && plotworld.TYPE == 0) {
 | 
			
		||||
                            PlotAnalysis analysis = plot.getComplexity();
 | 
			
		||||
                            if (analysis != null) {
 | 
			
		||||
                                /*
 | 
			
		||||
                                 * TODO remove min blocks changed
 | 
			
		||||
                                 *  - it isn't an accurate way to determine plot complexity
 | 
			
		||||
                                 *  
 | 
			
		||||
                                 *  compare this plots complexity with every other plot:
 | 
			
		||||
                                 *   - If it is in the bottom (threshold)% then it will be cleared
 | 
			
		||||
                                 *   - That doesn't make sense, that would mean it would get significantly harder as time goes on.
 | 
			
		||||
                                 *   - I guess as time goes on you can become more strict?
 | 
			
		||||
                                 *    
 | 
			
		||||
                                 *    % of plots to clear - not sure how to do
 | 
			
		||||
                                 *    % within non cleared plots - doesn't work for first plot
 | 
			
		||||
                                 *    % of plots in clear queue - doesn't work if 1 plot
 | 
			
		||||
                                 *    
 | 
			
		||||
                                 *    could be determined during calibration
 | 
			
		||||
                                 *    
 | 
			
		||||
                                 *    or (faster)
 | 
			
		||||
                                 *    
 | 
			
		||||
                                 *     set threshold complexity during calibration
 | 
			
		||||
                                 *    
 | 
			
		||||
                                 *     ideal number of expired plots
 | 
			
		||||
                                 *     
 | 
			
		||||
                                 *     manually set complexity
 | 
			
		||||
                                 */
 | 
			
		||||
                            }
 | 
			
		||||
                        };
 | 
			
		||||
                        if (Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.MIN_BLOCKS_CHANGED > 0 && manager instanceof ClassicPlotManager) {
 | 
			
		||||
                            Flag flag = FlagManager.getPlotFlagAbs(plot, "modified-blocks");
 | 
			
		||||
                            
 | 
			
		||||
                            
 | 
			
		||||
                            Flag flag = FlagManager.getPlotFlagAbs(plot, "analysis");
 | 
			
		||||
                            if (flag != null) {
 | 
			
		||||
                                if ((Integer) flag.getValue() > Settings.MIN_BLOCKS_CHANGED_IGNORED) {
 | 
			
		||||
                                    PS.log("&7[&5Expire&dManager&7] &bSkipping modified: " + plot);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user