mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 11:13:45 +01:00 
			
		
		
		
	Fixes
Progress towards #515 Fixes #512 Fixes #514 Fixes (possibly) #529 Fixes #535 Update to latest sponge
This commit is contained in:
		@@ -527,6 +527,45 @@ public class PS {
 | 
				
			|||||||
        return sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, null);
 | 
					        return sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, null);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    public ArrayList<Plot> sortPlotsByTemp(Collection<Plot> plots) {
 | 
				
			||||||
 | 
					        int max = 0;
 | 
				
			||||||
 | 
					        int overflowCount = 0;
 | 
				
			||||||
 | 
					        for (Plot plot : plots) {
 | 
				
			||||||
 | 
					            if (plot.temp > 0) {
 | 
				
			||||||
 | 
					                if (plot.temp > max) {
 | 
				
			||||||
 | 
					                    max = plot.temp;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                overflowCount++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Plot[] array = new Plot[max + 1];
 | 
				
			||||||
 | 
					        List<Plot> overflow = new ArrayList<>(overflowCount);
 | 
				
			||||||
 | 
					        for (Plot plot : plots) {
 | 
				
			||||||
 | 
					            if (plot.temp <= 0) {
 | 
				
			||||||
 | 
					                overflow.add(plot);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                array[plot.temp] = plot;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        ArrayList<Plot> result = new ArrayList<>(plots.size());
 | 
				
			||||||
 | 
					        for (Plot plot : array) {
 | 
				
			||||||
 | 
					            if (plot != null) {
 | 
				
			||||||
 | 
					                result.add(plot);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Collections.sort(overflow, new Comparator<Plot>() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public int compare(Plot a, Plot b) {
 | 
				
			||||||
 | 
					                return a.hashCode() - b.hashCode();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        result.addAll(overflow);
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sort plots by hashcode
 | 
					     * Sort plots by hashcode
 | 
				
			||||||
     * @param plots
 | 
					     * @param plots
 | 
				
			||||||
@@ -834,7 +873,7 @@ public class PS {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public enum SortType { CREATION_DATE, DISTANCE_FROM_ORIGIN; }
 | 
					    public enum SortType { CREATION_DATE, CREATION_DATE_TIMESTAMP, DISTANCE_FROM_ORIGIN; }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sort a collection of plots by world (with a priority world), then by hashcode
 | 
					     * Sort a collection of plots by world (with a priority world), then by hashcode
 | 
				
			||||||
@@ -887,6 +926,9 @@ public class PS {
 | 
				
			|||||||
        for (String world : worlds) {
 | 
					        for (String world : worlds) {
 | 
				
			||||||
            switch (type) {
 | 
					            switch (type) {
 | 
				
			||||||
                case CREATION_DATE:
 | 
					                case CREATION_DATE:
 | 
				
			||||||
 | 
					                    toReturn.addAll(sortPlotsByTemp(map.get(world)));
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case CREATION_DATE_TIMESTAMP:
 | 
				
			||||||
                    toReturn.addAll(sortPlotsByTimestamp(map.get(world)));
 | 
					                    toReturn.addAll(sortPlotsByTimestamp(map.get(world)));
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case DISTANCE_FROM_ORIGIN:
 | 
					                case DISTANCE_FROM_ORIGIN:
 | 
				
			||||||
@@ -1477,13 +1519,14 @@ public class PS {
 | 
				
			|||||||
    public void disable() {
 | 
					    public void disable() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            TASK = null;
 | 
					            TASK = null;
 | 
				
			||||||
 | 
					            database = null;
 | 
				
			||||||
            // Validate that all data in the db is correct
 | 
					            // Validate that all data in the db is correct
 | 
				
			||||||
            DBFunc.validatePlots(getPlotsRaw());
 | 
					            DBFunc.validatePlots(getPlotsRaw());
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // Close the connection
 | 
					            // Close the connection
 | 
				
			||||||
            database.closeConnection();
 | 
					            DBFunc.close();
 | 
				
			||||||
            UUIDHandler.handleShutdown();
 | 
					            UUIDHandler.handleShutdown();
 | 
				
			||||||
        } catch (NullPointerException | SQLException e) {
 | 
					        } catch (NullPointerException e) {
 | 
				
			||||||
            log("&cCould not close database connection!");
 | 
					            log("&cCould not close database connection!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1630,7 +1673,7 @@ public class PS {
 | 
				
			|||||||
        FlagManager.addFlag(new AbstractFlag("weather") {
 | 
					        FlagManager.addFlag(new AbstractFlag("weather") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public PlotWeather parseValueRaw(final String value) {
 | 
					            public PlotWeather parseValueRaw(final String value) {
 | 
				
			||||||
                switch (value) {
 | 
					                switch (value.toLowerCase()) {
 | 
				
			||||||
                    case "rain":
 | 
					                    case "rain":
 | 
				
			||||||
                    case "storm":
 | 
					                    case "storm":
 | 
				
			||||||
                    case "on":
 | 
					                    case "on":
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,8 +51,7 @@ public class Home extends SubCommand {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean onCommand(final PlotPlayer plr, String[] args) {
 | 
					    public boolean onCommand(final PlotPlayer plr, String[] args) {
 | 
				
			||||||
        
 | 
					        final ArrayList<Plot> plots = PS.get().sortPlotsByTemp(PS.get().getPlots(plr));//PS.get().sortPlots(PS.get().getPlots(plr), SortType.CREATION_DATE, null);
 | 
				
			||||||
        final ArrayList<Plot> plots = PS.get().sortPlots(PS.get().getPlots(plr), SortType.CREATION_DATE, null);
 | 
					 | 
				
			||||||
        if (plots.size() == 1) {
 | 
					        if (plots.size() == 1) {
 | 
				
			||||||
            MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
 | 
					            MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
 | 
				
			|||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Collections;
 | 
					import java.util.Collections;
 | 
				
			||||||
import java.util.Comparator;
 | 
					import java.util.Comparator;
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.Map.Entry;
 | 
					import java.util.Map.Entry;
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -147,6 +148,7 @@ public class Rate extends SubCommand {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            if (plot.getSettings().ratings == null) {
 | 
					            if (plot.getSettings().ratings == null) {
 | 
				
			||||||
 | 
					                if (!Settings.CACHE_RATINGS) {
 | 
				
			||||||
                    TaskManager.runTaskAsync(new Runnable() {
 | 
					                    TaskManager.runTaskAsync(new Runnable() {
 | 
				
			||||||
                        @Override
 | 
					                        @Override
 | 
				
			||||||
                        public void run() {
 | 
					                        public void run() {
 | 
				
			||||||
@@ -156,6 +158,8 @@ public class Rate extends SubCommand {
 | 
				
			|||||||
                    });
 | 
					                    });
 | 
				
			||||||
                    return true;
 | 
					                    return true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                plot.getSettings().ratings = new HashMap<UUID, Integer>();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            run.run();
 | 
					            run.run();
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -196,6 +200,7 @@ public class Rate extends SubCommand {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        if (plot.getSettings().ratings == null) {
 | 
					        if (plot.getSettings().ratings == null) {
 | 
				
			||||||
 | 
					            if (!Settings.CACHE_RATINGS) {
 | 
				
			||||||
                TaskManager.runTaskAsync(new Runnable() {
 | 
					                TaskManager.runTaskAsync(new Runnable() {
 | 
				
			||||||
                    @Override
 | 
					                    @Override
 | 
				
			||||||
                    public void run() {
 | 
					                    public void run() {
 | 
				
			||||||
@@ -205,6 +210,8 @@ public class Rate extends SubCommand {
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            plot.getSettings().ratings = new HashMap<UUID, Integer>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        run.run();
 | 
					        run.run();
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,10 +68,10 @@ public class Visit extends SubCommand {
 | 
				
			|||||||
        UUID user = UUIDHandler.getCachedUUID(args[0], null);
 | 
					        UUID user = UUIDHandler.getCachedUUID(args[0], null);
 | 
				
			||||||
        if (user != null ) {
 | 
					        if (user != null ) {
 | 
				
			||||||
            // do plots by username
 | 
					            // do plots by username
 | 
				
			||||||
            plots = PS.get().sortPlots(PS.get().getPlots(user), SortType.CREATION_DATE, null);
 | 
					            plots = PS.get().sortPlotsByTemp(PS.get().getPlots(user));
 | 
				
			||||||
        } else if (PS.get().isPlotWorld(args[0])) {
 | 
					        } else if (PS.get().isPlotWorld(args[0])) {
 | 
				
			||||||
            // do plots by world
 | 
					            // do plots by world
 | 
				
			||||||
            plots = PS.get().sortPlots(PS.get().getPlotsInWorld(args[0]), SortType.CREATION_DATE, null);
 | 
					            plots = PS.get().sortPlots(PS.get().getPlotsInWorld(args[0]), SortType.DISTANCE_FROM_ORIGIN, null);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
 | 
					            Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -138,7 +138,8 @@ public class list extends SubCommand {
 | 
				
			|||||||
                    MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
 | 
					                    MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
 | 
				
			||||||
                    return false;
 | 
					                    return false;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                plots = new ArrayList<>(PS.get().getPlots(plr));
 | 
					                sort = false;
 | 
				
			||||||
 | 
					                plots = PS.get().sortPlotsByTemp(PS.get().getPlots(plr));
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            case "shared": {
 | 
					            case "shared": {
 | 
				
			||||||
@@ -283,7 +284,8 @@ public class list extends SubCommand {
 | 
				
			|||||||
                        MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player");
 | 
					                        MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player");
 | 
				
			||||||
                        return false;
 | 
					                        return false;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    plots = new ArrayList<>(PS.get().getPlots(uuid));
 | 
					                    sort = false;
 | 
				
			||||||
 | 
					                    plots = PS.get().sortPlotsByTemp(PS.get().getPlots(uuid));
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -334,4 +334,6 @@ public interface AbstractDB {
 | 
				
			|||||||
     * Don't fuck with this one, unless you enjoy it rough
 | 
					     * Don't fuck with this one, unless you enjoy it rough
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    boolean deleteTables();
 | 
					    boolean deleteTables();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void close();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -420,4 +420,8 @@ public class DBFunc {
 | 
				
			|||||||
    public static void setPosition(final PlotCluster cluster, final String position) {
 | 
					    public static void setPosition(final PlotCluster cluster, final String position) {
 | 
				
			||||||
        dbManager.setPosition(cluster, position);
 | 
					        dbManager.setPosition(cluster, position);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void close() {
 | 
				
			||||||
 | 
					        dbManager.close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -108,6 +108,25 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
            tasks = new ConcurrentLinkedQueue<>();
 | 
					            tasks = new ConcurrentLinkedQueue<>();
 | 
				
			||||||
            plotTasks.put(plot, tasks);
 | 
					            plotTasks.put(plot, tasks);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (task == null) {
 | 
				
			||||||
 | 
					            task = new UniqueStatement(plot.hashCode() + "") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public PreparedStatement get() throws SQLException {
 | 
				
			||||||
 | 
					                    return null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void set(PreparedStatement stmt) throws SQLException {}
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void addBatch(PreparedStatement stmt) throws SQLException {}
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void execute(PreparedStatement stmt) throws SQLException {}
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        tasks.add(task);
 | 
					        tasks.add(task);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@@ -140,24 +159,22 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
        TaskManager.runTaskAsync(new Runnable() {
 | 
					        TaskManager.runTaskAsync(new Runnable() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void run() {
 | 
					            public void run() {
 | 
				
			||||||
                commit();
 | 
					 | 
				
			||||||
                long last = System.currentTimeMillis();
 | 
					                long last = System.currentTimeMillis();
 | 
				
			||||||
                while (true) {
 | 
					                while (true) {
 | 
				
			||||||
                    if (PS.get().getDatabase().getConnection() == null) {
 | 
					                    if (PS.get().getDatabase() == null) {
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    // schedule reconnect
 | 
					                    // schedule reconnect
 | 
				
			||||||
                    if (Settings.DB.USE_MYSQL && System.currentTimeMillis() - last > 550000) {
 | 
					                    if (Settings.DB.USE_MYSQL && System.currentTimeMillis() - last > 550000) {
 | 
				
			||||||
                        last = System.currentTimeMillis();
 | 
					                        last = System.currentTimeMillis();
 | 
				
			||||||
                        commit();
 | 
					 | 
				
			||||||
                        try {
 | 
					                        try {
 | 
				
			||||||
                            connection.close();
 | 
					                            close();
 | 
				
			||||||
                            connection = PS.get().getDatabase().forceConnection();
 | 
					                            connection = PS.get().getDatabase().forceConnection();
 | 
				
			||||||
                        } catch (SQLException | ClassNotFoundException e) {
 | 
					                        } catch (SQLException | ClassNotFoundException e) {
 | 
				
			||||||
                            e.printStackTrace();
 | 
					                            e.printStackTrace();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    sendBatch();
 | 
					                    if (!sendBatch()) {
 | 
				
			||||||
                        try {
 | 
					                        try {
 | 
				
			||||||
                            Thread.sleep(50);
 | 
					                            Thread.sleep(50);
 | 
				
			||||||
                        } catch (InterruptedException e) {
 | 
					                        } catch (InterruptedException e) {
 | 
				
			||||||
@@ -165,6 +182,7 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.prefix = p;
 | 
					        this.prefix = p;
 | 
				
			||||||
        // Set timout
 | 
					        // Set timout
 | 
				
			||||||
@@ -182,14 +200,10 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    public boolean sendBatch() {
 | 
					    public boolean sendBatch() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            try {
 | 
					            if (globalTasks.size() > 0) {
 | 
				
			||||||
                if (connection.getAutoCommit()) {
 | 
					                if (connection.getAutoCommit()) {
 | 
				
			||||||
                    connection.setAutoCommit(false);
 | 
					                    connection.setAutoCommit(false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } catch (SQLException e) {
 | 
					 | 
				
			||||||
                e.printStackTrace();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (globalTasks.size() > 0) {
 | 
					 | 
				
			||||||
                Runnable task = globalTasks.remove();
 | 
					                Runnable task = globalTasks.remove();
 | 
				
			||||||
                if (task != null) {
 | 
					                if (task != null) {
 | 
				
			||||||
                    task.run();
 | 
					                    task.run();
 | 
				
			||||||
@@ -197,8 +211,12 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                commit();
 | 
					                commit();
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            int count = 0;
 | 
					            int count = -1;
 | 
				
			||||||
            if (plotTasks.size() > 0) {
 | 
					            if (plotTasks.size() > 0) {
 | 
				
			||||||
 | 
					                count = 0;
 | 
				
			||||||
 | 
					                if (connection.getAutoCommit()) {
 | 
				
			||||||
 | 
					                    connection.setAutoCommit(false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                String method = null;
 | 
					                String method = null;
 | 
				
			||||||
                PreparedStatement stmt = null;
 | 
					                PreparedStatement stmt = null;
 | 
				
			||||||
                UniqueStatement task = null;
 | 
					                UniqueStatement task = null;
 | 
				
			||||||
@@ -232,6 +250,10 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (clusterTasks.size() > 0) {
 | 
					            if (clusterTasks.size() > 0) {
 | 
				
			||||||
 | 
					                count = 0;
 | 
				
			||||||
 | 
					                if (connection.getAutoCommit()) {
 | 
				
			||||||
 | 
					                    connection.setAutoCommit(false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                String method = null;
 | 
					                String method = null;
 | 
				
			||||||
                PreparedStatement stmt = null;
 | 
					                PreparedStatement stmt = null;
 | 
				
			||||||
                UniqueStatement task = null;
 | 
					                UniqueStatement task = null;
 | 
				
			||||||
@@ -239,11 +261,11 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                ArrayList<PlotCluster> keys = new ArrayList<>(clusterTasks.keySet());
 | 
					                ArrayList<PlotCluster> keys = new ArrayList<>(clusterTasks.keySet());
 | 
				
			||||||
                for (int i = 0; i < keys.size(); i++) {
 | 
					                for (int i = 0; i < keys.size(); i++) {
 | 
				
			||||||
                    PlotCluster plot = keys.get(i);
 | 
					                    PlotCluster plot = keys.get(i);
 | 
				
			||||||
                    if (plotTasks.get(plot).size() == 0) {
 | 
					                    if (clusterTasks.get(plot).size() == 0) {
 | 
				
			||||||
                        plotTasks.remove(plot);
 | 
					                        clusterTasks.remove(plot);
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    task = plotTasks.get(plot).remove();
 | 
					                    task = clusterTasks.get(plot).remove();
 | 
				
			||||||
                    count++;
 | 
					                    count++;
 | 
				
			||||||
                    if (task != null) {
 | 
					                    if (task != null) {
 | 
				
			||||||
                        if (task._method == null || !task._method.equals(method)) {
 | 
					                        if (task._method == null || !task._method.equals(method)) {
 | 
				
			||||||
@@ -264,18 +286,20 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                    stmt.close();
 | 
					                    stmt.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            commit();
 | 
					            if (count > 0) {
 | 
				
			||||||
            if (count != 0) {
 | 
					 | 
				
			||||||
                commit();
 | 
					                commit();
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            else if (count != -1) {
 | 
				
			||||||
 | 
					                if (!connection.getAutoCommit()) {
 | 
				
			||||||
 | 
					                    connection.setAutoCommit(true);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (clusterTasks.size() > 0) {
 | 
					            if (clusterTasks.size() > 0) {
 | 
				
			||||||
                clusterTasks.clear();
 | 
					                clusterTasks.clear();
 | 
				
			||||||
                commit();
 | 
					 | 
				
			||||||
               }
 | 
					               }
 | 
				
			||||||
            if (plotTasks.size() > 0) {
 | 
					            if (plotTasks.size() > 0) {
 | 
				
			||||||
                plotTasks.clear();
 | 
					                plotTasks.clear();
 | 
				
			||||||
                commit();
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        catch (Exception e) {
 | 
					        catch (Exception e) {
 | 
				
			||||||
@@ -355,7 +379,7 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                            // Populating structures
 | 
					                            // Populating structures
 | 
				
			||||||
                            final PreparedStatement stmt = connection.prepareStatement(GET_ALL_PLOTS);
 | 
					                            final PreparedStatement stmt = connection.prepareStatement(GET_ALL_PLOTS);
 | 
				
			||||||
                            final ResultSet result = stmt.executeQuery();
 | 
					                            try (ResultSet result = stmt.executeQuery()) {
 | 
				
			||||||
                                while (result.next()) {
 | 
					                                while (result.next()) {
 | 
				
			||||||
                                    final int id = result.getInt("id");
 | 
					                                    final int id = result.getInt("id");
 | 
				
			||||||
                                    int x = result.getInt("plot_id_x");
 | 
					                                    int x = result.getInt("plot_id_x");
 | 
				
			||||||
@@ -381,6 +405,7 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                                        }
 | 
					                                        }
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                            createSettings(settings, new Runnable() {
 | 
					                            createSettings(settings, new Runnable() {
 | 
				
			||||||
                                @Override
 | 
					                                @Override
 | 
				
			||||||
                                public void run() {
 | 
					                                public void run() {
 | 
				
			||||||
@@ -843,10 +868,10 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    public void commit() {
 | 
					    public void commit() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            if (this.connection.getAutoCommit()) {
 | 
					            if (!this.connection.getAutoCommit()) {
 | 
				
			||||||
                this.connection.setAutoCommit(false);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
                this.connection.commit();
 | 
					                this.connection.commit();
 | 
				
			||||||
 | 
					                this.connection.setAutoCommit(true);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } catch (SQLException e) {
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -1065,7 +1090,6 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        PreparedStatement stmt = null;
 | 
					        PreparedStatement stmt = null;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            commit();
 | 
					 | 
				
			||||||
            commit();
 | 
					            commit();
 | 
				
			||||||
            if (plot.temp > 0) {
 | 
					            if (plot.temp > 0) {
 | 
				
			||||||
                return plot.temp;
 | 
					                return plot.temp;
 | 
				
			||||||
@@ -2326,7 +2350,7 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void run() {
 | 
					            public void run() {
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    SQLManager.this.connection.close();
 | 
					                    close();
 | 
				
			||||||
                    SQLManager.this.connection = PS.get().getDatabase().forceConnection();
 | 
					                    SQLManager.this.connection = PS.get().getDatabase().forceConnection();
 | 
				
			||||||
                    final Statement stmt = connection.createStatement();
 | 
					                    final Statement stmt = connection.createStatement();
 | 
				
			||||||
                    stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`");
 | 
					                    stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`");
 | 
				
			||||||
@@ -2382,6 +2406,13 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            if (connection.getAutoCommit()) {
 | 
				
			||||||
 | 
					                connection.setAutoCommit(false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
 | 
					        ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
 | 
				
			||||||
        ArrayList<Plot> toCreate = new ArrayList<>();
 | 
					        ArrayList<Plot> toCreate = new ArrayList<>();
 | 
				
			||||||
        for (Plot plot : PS.get().getPlotsRaw()) {
 | 
					        for (Plot plot : PS.get().getPlotsRaw()) {
 | 
				
			||||||
@@ -2473,8 +2504,8 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                    setFlags(plot, pf.values());
 | 
					                    setFlags(plot, pf.values());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // TODO comments
 | 
					            // TODO comments (null)
 | 
				
			||||||
            // TODO ratings
 | 
					            // TODO ratings (null)
 | 
				
			||||||
            // TODO alias
 | 
					            // TODO alias
 | 
				
			||||||
            // TODO unconnected entries from helpers, trusted, denied, comments, settings, rating
 | 
					            // TODO unconnected entries from helpers, trusted, denied, comments, settings, rating
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -2487,11 +2518,15 @@ public class SQLManager implements AbstractDB {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        commit();
 | 
				
			||||||
        PS.debug("$4Done!");
 | 
					    }
 | 
				
			||||||
        try {
 | 
					
 | 
				
			||||||
            connection.commit();
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void close() {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            connection.close();
 | 
				
			||||||
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        catch (SQLException e) {}
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -45,7 +45,7 @@ public class Flag {
 | 
				
			|||||||
        this.key = key;
 | 
					        this.key = key;
 | 
				
			||||||
        this.value = key.parseValueRaw(value);
 | 
					        this.value = key.parseValueRaw(value);
 | 
				
			||||||
        if (this.value == null) {
 | 
					        if (this.value == null) {
 | 
				
			||||||
            throw new IllegalArgumentException(key.getValueDesc());
 | 
					            throw new IllegalArgumentException(key.getValueDesc() + " (" + value + ")");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -163,6 +163,7 @@ public class Plot {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.timestamp = timestamp;
 | 
					        this.timestamp = timestamp;
 | 
				
			||||||
 | 
					        this.temp = temp;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1362,14 +1362,14 @@ public class MainUtil {
 | 
				
			|||||||
        Plot p2 = PS.get().getPlot(world, newPlot);
 | 
					        Plot p2 = PS.get().getPlot(world, newPlot);
 | 
				
			||||||
        if (p1 == null || p1.owner == null) {
 | 
					        if (p1 == null || p1.owner == null) {
 | 
				
			||||||
            if (p2 != null && p2.owner != null) {
 | 
					            if (p2 != null && p2.owner != null) {
 | 
				
			||||||
                moveData(p2, p1, whenDone);
 | 
					                moveData(p2, getPlot(world, current), whenDone);
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (p2 == null || p2.owner == null) {
 | 
					        if (p2 == null || p2.owner == null) {
 | 
				
			||||||
            if (p1 != null && p1.owner != null) {
 | 
					            if (p1 != null && p1.owner != null) {
 | 
				
			||||||
                moveData(p1, p2, whenDone);
 | 
					                moveData(p1, getPlot(world, newPlot), whenDone);
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
@@ -1395,21 +1395,24 @@ public class MainUtil {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public static boolean moveData(final Plot plot1, final Plot plot2, final Runnable whenDone) {
 | 
					    public static boolean moveData(final Plot plot1, final Plot plot2, final Runnable whenDone) {
 | 
				
			||||||
        if (plot1.owner == null) {
 | 
					        if (plot1.owner == null) {
 | 
				
			||||||
            TaskManager.runTaskLater(whenDone, 1);
 | 
					            PS.debug(plot2 +" is unowned (single)");
 | 
				
			||||||
 | 
					            TaskManager.runTask(whenDone);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        final Plot pos1 = getBottomPlot(plot1);
 | 
					        final Plot pos1 = getBottomPlot(plot1);
 | 
				
			||||||
        final Plot pos2 = getTopPlot(plot1);
 | 
					        final Plot pos2 = getTopPlot(plot1);
 | 
				
			||||||
        final PlotId size = MainUtil.getSize(plot1);
 | 
					        final PlotId size = MainUtil.getSize(plot1);
 | 
				
			||||||
        if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) {
 | 
					        if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) {
 | 
				
			||||||
            TaskManager.runTaskLater(whenDone, 1);
 | 
					            PS.debug(plot2 +" is unowned (multi)");
 | 
				
			||||||
 | 
					            TaskManager.runTask(whenDone);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        final int offset_x = plot2.id.x - pos1.id.x;
 | 
					        final int offset_x = plot2.id.x - pos1.id.x;
 | 
				
			||||||
        final int offset_y = plot2.id.y - pos1.id.y;
 | 
					        final int offset_y = plot2.id.y - pos1.id.y;
 | 
				
			||||||
        final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
 | 
					        final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
 | 
				
			||||||
        for (final PlotId id : selection) {
 | 
					        for (final PlotId id : selection) {
 | 
				
			||||||
            DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
 | 
					            String worldOriginal = plot1.world;
 | 
				
			||||||
 | 
					            PlotId idOriginal = new PlotId(id.x, id.y);
 | 
				
			||||||
            final Plot plot = PS.get().getPlot(plot1.world, id);
 | 
					            final Plot plot = PS.get().getPlot(plot1.world, id);
 | 
				
			||||||
            Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
 | 
					            Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
 | 
				
			||||||
            raw.get(plot1.world).remove(id);
 | 
					            raw.get(plot1.world).remove(id);
 | 
				
			||||||
@@ -1417,6 +1420,7 @@ public class MainUtil {
 | 
				
			|||||||
            plot.id.y += offset_y;
 | 
					            plot.id.y += offset_y;
 | 
				
			||||||
            plot.id.recalculateHash();
 | 
					            plot.id.recalculateHash();
 | 
				
			||||||
            raw.get(plot2.world).put(plot.id, plot);
 | 
					            raw.get(plot2.world).put(plot.id, plot);
 | 
				
			||||||
 | 
					            DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        TaskManager.runTaskLater(whenDone, 1);
 | 
					        TaskManager.runTaskLater(whenDone, 1);
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -1760,6 +1764,9 @@ public class MainUtil {
 | 
				
			|||||||
        if (plot.getSettings().ratings != null) {
 | 
					        if (plot.getSettings().ratings != null) {
 | 
				
			||||||
            rating = plot.getSettings().ratings;
 | 
					            rating = plot.getSettings().ratings;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        else if (Settings.CACHE_RATINGS) {
 | 
				
			||||||
 | 
					            rating = new HashMap<>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            rating = DBFunc.getRatings(plot);
 | 
					            rating = DBFunc.getRatings(plot);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -1790,6 +1797,9 @@ public class MainUtil {
 | 
				
			|||||||
        if (plot.getSettings().ratings != null) {
 | 
					        if (plot.getSettings().ratings != null) {
 | 
				
			||||||
            rating = plot.getSettings().ratings;
 | 
					            rating = plot.getSettings().ratings;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        else if (Settings.CACHE_RATINGS) {
 | 
				
			||||||
 | 
					            rating = new HashMap<>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            rating = DBFunc.getRatings(plot);
 | 
					            rating = DBFunc.getRatings(plot);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -126,8 +126,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onDisable() {
 | 
					    public void onDisable() {
 | 
				
			||||||
        Bukkit.getScheduler().cancelTasks(this);
 | 
					 | 
				
			||||||
        PS.get().disable();
 | 
					        PS.get().disable();
 | 
				
			||||||
 | 
					        Bukkit.getScheduler().cancelTasks(this);
 | 
				
			||||||
        THIS = null;
 | 
					        THIS = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -178,6 +178,8 @@ public class EntityWrapper {
 | 
				
			|||||||
        this.x = loc.getX();
 | 
					        this.x = loc.getX();
 | 
				
			||||||
        this.y = loc.getY();
 | 
					        this.y = loc.getY();
 | 
				
			||||||
        this.z = loc.getZ();
 | 
					        this.z = loc.getZ();
 | 
				
			||||||
 | 
					        System.out.print("ENTITY: " + entity.getType());
 | 
				
			||||||
 | 
					        System.out.print("ENTITY: " + entity.getType().getTypeId());
 | 
				
			||||||
        this.id = entity.getType().getTypeId();
 | 
					        this.id = entity.getType().getTypeId();
 | 
				
			||||||
        if (depth == 0) {
 | 
					        if (depth == 0) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -494,12 +494,14 @@ public class BukkitChunkManager extends ChunkManager {
 | 
				
			|||||||
    public static void restoreEntities(final World world, final int x_offset, final int z_offset) {
 | 
					    public static void restoreEntities(final World world, final int x_offset, final int z_offset) {
 | 
				
			||||||
        for (final EntityWrapper entity : entities) {
 | 
					        for (final EntityWrapper entity : entities) {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
 | 
					                System.out.print("RESTORING ENTITIE!: " + EntityType.fromId(entity.id));
 | 
				
			||||||
                entity.spawn(world, x_offset, z_offset);
 | 
					                entity.spawn(world, x_offset, z_offset);
 | 
				
			||||||
            } catch (final Exception e) {
 | 
					            } catch (final Exception e) {
 | 
				
			||||||
                PS.debug("Failed to restore entity (e): " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id));
 | 
					                PS.debug("Failed to restore entity (e): " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id));
 | 
				
			||||||
                e.printStackTrace();
 | 
					                e.printStackTrace();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        entities.clear();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void restoreBlocks(final World world, final int x_offset, final int z_offset) {
 | 
					    public static void restoreBlocks(final World world, final int x_offset, final int z_offset) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ import org.bukkit.World;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.intellectualcrafters.plot.PS;
 | 
					import com.intellectualcrafters.plot.PS;
 | 
				
			||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
					import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
				
			||||||
 | 
					import com.intellectualcrafters.plot.util.TaskManager;
 | 
				
			||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
 | 
					import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
 | 
				
			||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
 | 
					import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
 | 
				
			||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
 | 
					import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
 | 
				
			||||||
@@ -87,13 +88,21 @@ public class SendChunk {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (unload) {
 | 
					            if (unload) {
 | 
				
			||||||
 | 
					                TaskManager.runTask(new Runnable() {
 | 
				
			||||||
 | 
					                    @Override
 | 
				
			||||||
 | 
					                    public void run() {
 | 
				
			||||||
                        try {
 | 
					                        try {
 | 
				
			||||||
                            chunk.unload(true, true);
 | 
					                            chunk.unload(true, true);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        catch (Exception e) {
 | 
					                        catch (Exception e) {
 | 
				
			||||||
                    e.printStackTrace();
 | 
					                            String worldname = chunk.getWorld().getName();
 | 
				
			||||||
 | 
					                            PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
 | 
				
			||||||
 | 
					                            PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
 | 
				
			||||||
 | 
					                            PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "level_old.dat may be corrupt (try repairing or removing these)");
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ import org.spongepowered.api.Server;
 | 
				
			|||||||
import org.spongepowered.api.block.BlockState;
 | 
					import org.spongepowered.api.block.BlockState;
 | 
				
			||||||
import org.spongepowered.api.block.BlockType;
 | 
					import org.spongepowered.api.block.BlockType;
 | 
				
			||||||
import org.spongepowered.api.block.BlockTypes;
 | 
					import org.spongepowered.api.block.BlockTypes;
 | 
				
			||||||
import org.spongepowered.api.data.manipulator.block.StoneData;
 | 
					import org.spongepowered.api.data.manipulator.mutable.block.StoneData;
 | 
				
			||||||
import org.spongepowered.api.entity.player.Player;
 | 
					import org.spongepowered.api.entity.player.Player;
 | 
				
			||||||
import org.spongepowered.api.event.Subscribe;
 | 
					import org.spongepowered.api.event.Subscribe;
 | 
				
			||||||
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
 | 
					import org.spongepowered.api.event.entity.player.PlayerChatEvent;
 | 
				
			||||||
@@ -261,7 +261,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
 | 
				
			|||||||
            case 0: {
 | 
					            case 0: {
 | 
				
			||||||
                this.modify = new WorldModify(generator, false);
 | 
					                this.modify = new WorldModify(generator, false);
 | 
				
			||||||
                game.getRegistry().registerWorldGeneratorModifier(modify);
 | 
					                game.getRegistry().registerWorldGeneratorModifier(modify);
 | 
				
			||||||
                Optional<World> builder = game.getRegistry().getWorldBuilder()
 | 
					                Optional<World> builder = game.getRegistry().createWorldBuilder()
 | 
				
			||||||
                .name(world)
 | 
					                .name(world)
 | 
				
			||||||
                .enabled(true)
 | 
					                .enabled(true)
 | 
				
			||||||
                .loadsOnStartup(true)
 | 
					                .loadsOnStartup(true)
 | 
				
			||||||
@@ -277,7 +277,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
 | 
				
			|||||||
            default: {
 | 
					            default: {
 | 
				
			||||||
                this.modify = new WorldModify(generator, true);
 | 
					                this.modify = new WorldModify(generator, true);
 | 
				
			||||||
                game.getRegistry().registerWorldGeneratorModifier(modify);
 | 
					                game.getRegistry().registerWorldGeneratorModifier(modify);
 | 
				
			||||||
                Optional<World> builder = game.getRegistry().getWorldBuilder()
 | 
					                Optional<World> builder = game.getRegistry().createWorldBuilder()
 | 
				
			||||||
                .name(world)
 | 
					                .name(world)
 | 
				
			||||||
                .enabled(true)
 | 
					                .enabled(true)
 | 
				
			||||||
                .loadsOnStartup(true)
 | 
					                .loadsOnStartup(true)
 | 
				
			||||||
@@ -365,7 +365,6 @@ public class SpongeMain implements IPlotMain, PluginContainer {
 | 
				
			|||||||
                        if (state == null) {
 | 
					                        if (state == null) {
 | 
				
			||||||
                            continue;
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    state.getManipulator(StoneData.class);
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Throwable e) {}
 | 
					                catch (Throwable e) {}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,9 +8,13 @@ import java.util.Random;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.spongepowered.api.block.BlockState;
 | 
					import org.spongepowered.api.block.BlockState;
 | 
				
			||||||
import org.spongepowered.api.block.BlockType;
 | 
					import org.spongepowered.api.block.BlockType;
 | 
				
			||||||
 | 
					import org.spongepowered.api.util.DiscreteTransform3;
 | 
				
			||||||
import org.spongepowered.api.world.Chunk;
 | 
					import org.spongepowered.api.world.Chunk;
 | 
				
			||||||
import org.spongepowered.api.world.World;
 | 
					import org.spongepowered.api.world.World;
 | 
				
			||||||
 | 
					import org.spongepowered.api.world.extent.ImmutableBlockVolume;
 | 
				
			||||||
import org.spongepowered.api.world.extent.MutableBlockVolume;
 | 
					import org.spongepowered.api.world.extent.MutableBlockVolume;
 | 
				
			||||||
 | 
					import org.spongepowered.api.world.extent.StorageType;
 | 
				
			||||||
 | 
					import org.spongepowered.api.world.extent.UnmodifiableBlockVolume;
 | 
				
			||||||
import org.spongepowered.api.world.gen.GeneratorPopulator;
 | 
					import org.spongepowered.api.world.gen.GeneratorPopulator;
 | 
				
			||||||
import org.spongepowered.api.world.gen.Populator;
 | 
					import org.spongepowered.api.world.gen.Populator;
 | 
				
			||||||
import org.spongepowered.api.world.gen.WorldGenerator;
 | 
					import org.spongepowered.api.world.gen.WorldGenerator;
 | 
				
			||||||
@@ -283,6 +287,48 @@ public class AugmentedPopulator implements Populator {
 | 
				
			|||||||
            public void setBlockType(Vector3i v, BlockType t) {
 | 
					            public void setBlockType(Vector3i v, BlockType t) {
 | 
				
			||||||
                setBlockType(v.getX(), v.getY(), v.getZ(), t);
 | 
					                setBlockType(v.getX(), v.getY(), v.getZ(), t);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public MutableBlockVolume getBlockCopy() {
 | 
				
			||||||
 | 
					             // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return this;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public MutableBlockVolume getBlockCopy(StorageType arg0) {
 | 
				
			||||||
 | 
					             // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return this;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public ImmutableBlockVolume getImmutableBlockCopy() {
 | 
				
			||||||
 | 
					                // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public UnmodifiableBlockVolume getUnmodifiableBlockView() {
 | 
				
			||||||
 | 
					                // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public MutableBlockVolume getBlockView(DiscreteTransform3 arg0) {
 | 
				
			||||||
 | 
					                // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return this;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public MutableBlockVolume getBlockView(Vector3i arg0, Vector3i arg1) {
 | 
				
			||||||
 | 
					                // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return this;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public MutableBlockVolume getRelativeBlockView() {
 | 
				
			||||||
 | 
					                // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					                return this;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        this.populator.populate(world, blocks , null);
 | 
					        this.populator.populate(world, blocks , null);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,6 @@ import org.spongepowered.api.event.block.BlockMoveEvent;
 | 
				
			|||||||
import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
 | 
					import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
 | 
				
			||||||
import org.spongepowered.api.event.block.FloraGrowEvent;
 | 
					import org.spongepowered.api.event.block.FloraGrowEvent;
 | 
				
			||||||
import org.spongepowered.api.event.entity.EntityChangeBlockEvent;
 | 
					import org.spongepowered.api.event.entity.EntityChangeBlockEvent;
 | 
				
			||||||
import org.spongepowered.api.event.entity.EntityExplosionEvent;
 | 
					 | 
				
			||||||
import org.spongepowered.api.event.entity.EntitySpawnEvent;
 | 
					import org.spongepowered.api.event.entity.EntitySpawnEvent;
 | 
				
			||||||
import org.spongepowered.api.event.entity.EntityTeleportEvent;
 | 
					import org.spongepowered.api.event.entity.EntityTeleportEvent;
 | 
				
			||||||
import org.spongepowered.api.event.entity.player.PlayerBreakBlockEvent;
 | 
					import org.spongepowered.api.event.entity.player.PlayerBreakBlockEvent;
 | 
				
			||||||
@@ -41,11 +40,13 @@ import org.spongepowered.api.event.entity.player.PlayerQuitEvent;
 | 
				
			|||||||
import org.spongepowered.api.event.message.CommandEvent;
 | 
					import org.spongepowered.api.event.message.CommandEvent;
 | 
				
			||||||
import org.spongepowered.api.event.network.PlayerConnectionEvent;
 | 
					import org.spongepowered.api.event.network.PlayerConnectionEvent;
 | 
				
			||||||
import org.spongepowered.api.event.world.ChunkPreGenerateEvent;
 | 
					import org.spongepowered.api.event.world.ChunkPreGenerateEvent;
 | 
				
			||||||
 | 
					import org.spongepowered.api.event.world.WorldOnExplosionEvent;
 | 
				
			||||||
import org.spongepowered.api.network.PlayerConnection;
 | 
					import org.spongepowered.api.network.PlayerConnection;
 | 
				
			||||||
import org.spongepowered.api.text.Text;
 | 
					import org.spongepowered.api.text.Text;
 | 
				
			||||||
import org.spongepowered.api.text.Texts;
 | 
					import org.spongepowered.api.text.Texts;
 | 
				
			||||||
import org.spongepowered.api.util.command.CommandSource;
 | 
					import org.spongepowered.api.util.command.CommandSource;
 | 
				
			||||||
import org.spongepowered.api.world.World;
 | 
					import org.spongepowered.api.world.World;
 | 
				
			||||||
 | 
					import org.spongepowered.api.world.explosion.Explosion;
 | 
				
			||||||
import org.spongepowered.api.world.extent.Extent;
 | 
					import org.spongepowered.api.world.extent.Extent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.flowpowered.math.vector.Vector3d;
 | 
					import com.flowpowered.math.vector.Vector3d;
 | 
				
			||||||
@@ -110,7 +111,8 @@ public class MainListener {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        final Location loc = SpongeUtil.getLocation(event.getLocation());
 | 
					        final Location loc = SpongeUtil.getLocation(event.getLocation());
 | 
				
			||||||
        final String world = loc.getWorld();
 | 
					        final String world = loc.getWorld();
 | 
				
			||||||
        if (!PS.get().isPlotWorld(world)) {
 | 
					        PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
				
			||||||
 | 
					        if (plotworld == null) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Plot plot = MainUtil.getPlot(loc);
 | 
					        Plot plot = MainUtil.getPlot(loc);
 | 
				
			||||||
@@ -132,8 +134,10 @@ public class MainListener {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        if (!plotworld.MOB_SPAWNING) {
 | 
				
			||||||
            event.setCancelled(true);
 | 
					            event.setCancelled(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @Subscribe
 | 
					    @Subscribe
 | 
				
			||||||
    public void onBlockChange(EntityChangeBlockEvent event) {
 | 
					    public void onBlockChange(EntityChangeBlockEvent event) {
 | 
				
			||||||
@@ -164,7 +168,7 @@ public class MainListener {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    @Subscribe
 | 
					    @Subscribe
 | 
				
			||||||
    public void onBlockMove(BlockMoveEvent event) {
 | 
					    public void onBlockMove(BlockMoveEvent event) {
 | 
				
			||||||
        org.spongepowered.api.world.Location block = event.getBlocks().get(0);
 | 
					        org.spongepowered.api.world.Location block = event.getLocations().get(0);
 | 
				
			||||||
        Extent extent = block.getExtent();
 | 
					        Extent extent = block.getExtent();
 | 
				
			||||||
        if (extent instanceof World) {
 | 
					        if (extent instanceof World) {
 | 
				
			||||||
            World world = (World) extent;
 | 
					            World world = (World) extent;
 | 
				
			||||||
@@ -172,7 +176,7 @@ public class MainListener {
 | 
				
			|||||||
            if (!PS.get().isPlotWorld(worldname)) {
 | 
					            if (!PS.get().isPlotWorld(worldname)) {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            event.filter(new Predicate<org.spongepowered.api.world.Location>() {
 | 
					            event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() {
 | 
				
			||||||
                @Override
 | 
					                @Override
 | 
				
			||||||
                public boolean apply(org.spongepowered.api.world.Location loc) {
 | 
					                public boolean apply(org.spongepowered.api.world.Location loc) {
 | 
				
			||||||
                    if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
 | 
					                    if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
 | 
				
			||||||
@@ -186,7 +190,7 @@ public class MainListener {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    @Subscribe
 | 
					    @Subscribe
 | 
				
			||||||
    public void onFloraGrow(FloraGrowEvent event) {
 | 
					    public void onFloraGrow(FloraGrowEvent event) {
 | 
				
			||||||
        org.spongepowered.api.world.Location block = event.getBlock();
 | 
					        org.spongepowered.api.world.Location block = event.getLocation();
 | 
				
			||||||
        Extent extent = block.getExtent();
 | 
					        Extent extent = block.getExtent();
 | 
				
			||||||
        if (extent instanceof World) {
 | 
					        if (extent instanceof World) {
 | 
				
			||||||
            World world = (World) extent;
 | 
					            World world = (World) extent;
 | 
				
			||||||
@@ -258,16 +262,19 @@ public class MainListener {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @Subscribe
 | 
					    @Subscribe
 | 
				
			||||||
    public void onBigBoom(final EntityExplosionEvent event) {
 | 
					    public void onBigBoom(final WorldOnExplosionEvent event) {
 | 
				
			||||||
        Location loc = SpongeUtil.getLocation(event.getExplosionLocation());
 | 
					        World worldObj = event.getWorld();
 | 
				
			||||||
        final String world = loc.getWorld();
 | 
					        final String world = worldObj.getName();
 | 
				
			||||||
        if (!PS.get().isPlotWorld(world)) {
 | 
					        if (!PS.get().isPlotWorld(world)) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        Explosion explosion = event.getExplosion();
 | 
				
			||||||
 | 
					        Vector3d origin = explosion.getOrigin();
 | 
				
			||||||
 | 
					        Location loc = new Location(world, origin.getFloorX(), origin.getFloorY(), origin.getFloorZ());
 | 
				
			||||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
					        final Plot plot = MainUtil.getPlot(loc);
 | 
				
			||||||
        if ((plot != null) && plot.hasOwner()) {
 | 
					        if ((plot != null) && plot.hasOwner()) {
 | 
				
			||||||
            if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
 | 
					            if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
 | 
				
			||||||
                event.filter(new Predicate<org.spongepowered.api.world.Location>() {
 | 
					                event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() {
 | 
				
			||||||
                    @Override
 | 
					                    @Override
 | 
				
			||||||
                    public boolean apply(org.spongepowered.api.world.Location loc) {
 | 
					                    public boolean apply(org.spongepowered.api.world.Location loc) {
 | 
				
			||||||
                        if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
 | 
					                        if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
 | 
				
			||||||
@@ -276,14 +283,35 @@ public class MainListener {
 | 
				
			|||||||
                        return true;
 | 
					                        return true;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					                event.filterEntities(new Predicate<Entity>() {
 | 
				
			||||||
 | 
					                    @Override
 | 
				
			||||||
 | 
					                    public boolean apply(Entity entity) {
 | 
				
			||||||
 | 
					                        if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
 | 
				
			||||||
 | 
					                            return false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (MainUtil.isPlotArea(loc)) {
 | 
					        if (MainUtil.isPlotArea(loc)) {
 | 
				
			||||||
            event.setYield(0);
 | 
					            explosion.shouldBreakBlocks(false);
 | 
				
			||||||
 | 
					            explosion.canCauseFire(false);
 | 
				
			||||||
 | 
					            explosion.setRadius(0);
 | 
				
			||||||
 | 
					            event.filterEntities(new Predicate<Entity>() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public boolean apply(Entity entity) {
 | 
				
			||||||
 | 
					                    if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
 | 
				
			||||||
 | 
					                        return false;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
 | 
					            if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
 | 
				
			||||||
                event.filter(new Predicate<org.spongepowered.api.world.Location>() {
 | 
					                event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() {
 | 
				
			||||||
                    @Override
 | 
					                    @Override
 | 
				
			||||||
                    public boolean apply(org.spongepowered.api.world.Location loc) {
 | 
					                    public boolean apply(org.spongepowered.api.world.Location loc) {
 | 
				
			||||||
                        if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
 | 
					                        if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
 | 
				
			||||||
@@ -292,6 +320,15 @@ public class MainListener {
 | 
				
			|||||||
                        return true;
 | 
					                        return true;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					                event.filterEntities(new Predicate<Entity>() {
 | 
				
			||||||
 | 
					                    @Override
 | 
				
			||||||
 | 
					                    public boolean apply(Entity entity) {
 | 
				
			||||||
 | 
					                        if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
 | 
				
			||||||
 | 
					                            return false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -317,7 +354,7 @@ public class MainListener {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    @Subscribe
 | 
					    @Subscribe
 | 
				
			||||||
    public void onRedstoneEvent(BlockRedstoneUpdateEvent event) {
 | 
					    public void onRedstoneEvent(BlockRedstoneUpdateEvent event) {
 | 
				
			||||||
        org.spongepowered.api.world.Location block = event.getBlock();
 | 
					        org.spongepowered.api.world.Location block = event.getLocation();
 | 
				
			||||||
        Location loc = SpongeUtil.getLocation(block);
 | 
					        Location loc = SpongeUtil.getLocation(block);
 | 
				
			||||||
        if (loc == null || !PS.get().isPlotWorld(loc.getWorld())) {
 | 
					        if (loc == null || !PS.get().isPlotWorld(loc.getWorld())) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
@@ -356,11 +393,11 @@ public class MainListener {
 | 
				
			|||||||
        Player player = event.getEntity();
 | 
					        Player player = event.getEntity();
 | 
				
			||||||
        World world = player.getWorld();
 | 
					        World world = player.getWorld();
 | 
				
			||||||
        String worldname = world.getName();
 | 
					        String worldname = world.getName();
 | 
				
			||||||
        org.spongepowered.api.world.Location blockLoc = event.getBlock();
 | 
					        org.spongepowered.api.world.Location blockLoc = event.getLocation();
 | 
				
			||||||
        final Location loc = SpongeUtil.getLocation(worldname, event.getBlock());
 | 
					        final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
 | 
				
			||||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
					        final Plot plot = MainUtil.getPlot(loc);
 | 
				
			||||||
        if (plot != null) {
 | 
					        if (plot != null) {
 | 
				
			||||||
            if (event.getBlock().getY() == 0) {
 | 
					            if (blockLoc.getY() == 0) {
 | 
				
			||||||
                event.setCancelled(true);
 | 
					                event.setCancelled(true);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -403,11 +440,11 @@ public class MainListener {
 | 
				
			|||||||
        Player player = event.getEntity();
 | 
					        Player player = event.getEntity();
 | 
				
			||||||
        World world = player.getWorld();
 | 
					        World world = player.getWorld();
 | 
				
			||||||
        String worldname = world.getName();
 | 
					        String worldname = world.getName();
 | 
				
			||||||
        org.spongepowered.api.world.Location blockLoc = event.getBlock();
 | 
					        org.spongepowered.api.world.Location blockLoc = event.getLocation();
 | 
				
			||||||
        final Location loc = SpongeUtil.getLocation(worldname, event.getBlock());
 | 
					        final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
 | 
				
			||||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
					        final Plot plot = MainUtil.getPlot(loc);
 | 
				
			||||||
        if (plot != null) {
 | 
					        if (plot != null) {
 | 
				
			||||||
            if (event.getBlock().getY() == 0) {
 | 
					            if (blockLoc.getY() == 0) {
 | 
				
			||||||
                event.setCancelled(true);
 | 
					                event.setCancelled(true);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -450,11 +487,11 @@ public class MainListener {
 | 
				
			|||||||
        Player player = event.getEntity();
 | 
					        Player player = event.getEntity();
 | 
				
			||||||
        World world = player.getWorld();
 | 
					        World world = player.getWorld();
 | 
				
			||||||
        String worldname = world.getName();
 | 
					        String worldname = world.getName();
 | 
				
			||||||
        org.spongepowered.api.world.Location blockLoc = event.getBlock();
 | 
					        org.spongepowered.api.world.Location blockLoc = event.getLocation();
 | 
				
			||||||
        final Location loc = SpongeUtil.getLocation(worldname, event.getBlock());
 | 
					        final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
 | 
				
			||||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
					        final Plot plot = MainUtil.getPlot(loc);
 | 
				
			||||||
        if (plot != null) {
 | 
					        if (plot != null) {
 | 
				
			||||||
            if (event.getBlock().getY() == 0) {
 | 
					            if (blockLoc.getY() == 0) {
 | 
				
			||||||
                event.setCancelled(true);
 | 
					                event.setCancelled(true);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,12 @@
 | 
				
			|||||||
package com.plotsquared.sponge.object;
 | 
					package com.plotsquared.sponge.object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.HashSet;
 | 
					import java.util.HashSet;
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.spongepowered.api.data.key.Keys;
 | 
				
			||||||
 | 
					import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData;
 | 
				
			||||||
 | 
					import org.spongepowered.api.data.value.mutable.Value;
 | 
				
			||||||
import org.spongepowered.api.entity.player.Player;
 | 
					import org.spongepowered.api.entity.player.Player;
 | 
				
			||||||
import org.spongepowered.api.entity.player.gamemode.GameMode;
 | 
					import org.spongepowered.api.entity.player.gamemode.GameMode;
 | 
				
			||||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
 | 
					import org.spongepowered.api.entity.player.gamemode.GameModes;
 | 
				
			||||||
@@ -47,7 +51,11 @@ public class SpongePlayer extends PlotPlayer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public long getPreviousLogin() {
 | 
					    public long getPreviousLogin() {
 | 
				
			||||||
        return (long) (player.getJoinData().getLastPlayed().getSeconds()) * 1000;
 | 
					        Value<Date> data = player.getJoinData().lastPlayed();
 | 
				
			||||||
 | 
					        if (data.exists()) {
 | 
				
			||||||
 | 
					            return last = data.get().getSeconds() * 1000;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -168,7 +176,7 @@ public class SpongePlayer extends PlotPlayer {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public PlotGamemode getGamemode() {
 | 
					    public PlotGamemode getGamemode() {
 | 
				
			||||||
        // TODO Auto-generated method stub
 | 
					        // TODO Auto-generated method stub
 | 
				
			||||||
        GameMode gamemode = player.getGameModeData().getValue();
 | 
					        GameMode gamemode = player.getGameModeData().type().get();
 | 
				
			||||||
        if (gamemode == GameModes.ADVENTURE) {
 | 
					        if (gamemode == GameModes.ADVENTURE) {
 | 
				
			||||||
            return PlotGamemode.ADVENTURE;
 | 
					            return PlotGamemode.ADVENTURE;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -187,20 +195,20 @@ public class SpongePlayer extends PlotPlayer {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void setGamemode(PlotGamemode gamemode) {
 | 
					    public void setGamemode(PlotGamemode gamemode) {
 | 
				
			||||||
        // TODO Auto-generated method stub
 | 
					        // TODO Auto-generated method stub
 | 
				
			||||||
        switch (gamemode) {
 | 
					//        switch (gamemode) {
 | 
				
			||||||
            case ADVENTURE:
 | 
					//            case ADVENTURE:
 | 
				
			||||||
                player.getGameModeData().setGameMode(GameModes.ADVENTURE);
 | 
					//                player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
 | 
				
			||||||
                return;
 | 
					//                return;
 | 
				
			||||||
            case CREATIVE:
 | 
					//            case CREATIVE:
 | 
				
			||||||
                player.getGameModeData().setGameMode(GameModes.CREATIVE);
 | 
					//                player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
 | 
				
			||||||
                return;
 | 
					//                return;
 | 
				
			||||||
            case SPECTATOR:
 | 
					//            case SPECTATOR:
 | 
				
			||||||
                player.getGameModeData().setGameMode(GameModes.SPECTATOR);
 | 
					//                player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
 | 
				
			||||||
                return;
 | 
					//                return;
 | 
				
			||||||
            case SURVIVAL:
 | 
					//            case SURVIVAL:
 | 
				
			||||||
                player.getGameModeData().setGameMode(GameModes.SURVIVAL);
 | 
					//                player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
 | 
				
			||||||
                return;
 | 
					//                return;
 | 
				
			||||||
        }
 | 
					//        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,21 @@
 | 
				
			|||||||
package com.plotsquared.sponge.util;
 | 
					package com.plotsquared.sponge.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.spongepowered.api.block.BlockState;
 | 
					import org.spongepowered.api.block.BlockState;
 | 
				
			||||||
import org.spongepowered.api.block.BlockType;
 | 
					import org.spongepowered.api.block.BlockType;
 | 
				
			||||||
import org.spongepowered.api.block.BlockTypes;
 | 
					import org.spongepowered.api.block.BlockTypes;
 | 
				
			||||||
import org.spongepowered.api.block.tileentity.Sign;
 | 
					import org.spongepowered.api.block.tileentity.Sign;
 | 
				
			||||||
import org.spongepowered.api.data.manipulator.tileentity.SignData;
 | 
					import org.spongepowered.api.block.tileentity.TileEntity;
 | 
				
			||||||
 | 
					import org.spongepowered.api.data.key.Keys;
 | 
				
			||||||
 | 
					import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData;
 | 
				
			||||||
import org.spongepowered.api.text.Text;
 | 
					import org.spongepowered.api.text.Text;
 | 
				
			||||||
import org.spongepowered.api.world.World;
 | 
					import org.spongepowered.api.world.World;
 | 
				
			||||||
import org.spongepowered.api.world.biome.BiomeType;
 | 
					import org.spongepowered.api.world.biome.BiomeType;
 | 
				
			||||||
import org.spongepowered.api.world.biome.BiomeTypes;
 | 
					import org.spongepowered.api.world.biome.BiomeTypes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.common.base.Optional;
 | 
				
			||||||
import com.intellectualcrafters.plot.object.Location;
 | 
					import com.intellectualcrafters.plot.object.Location;
 | 
				
			||||||
import com.intellectualcrafters.plot.object.PlotBlock;
 | 
					import com.intellectualcrafters.plot.object.PlotBlock;
 | 
				
			||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
 | 
					import com.intellectualcrafters.plot.object.schematic.PlotItem;
 | 
				
			||||||
@@ -132,13 +136,22 @@ public class SpongeBlockManager extends BlockManager {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String[] getSign(Location loc) {
 | 
					    public String[] getSign(Location loc) {
 | 
				
			||||||
        BlockState block = SpongeUtil.getWorld(loc.getWorld()).getBlock(loc.getX(), loc.getY(), loc.getZ());
 | 
					        World world = SpongeUtil.getWorld(loc.getWorld());
 | 
				
			||||||
        if (!(block instanceof Sign)) {
 | 
					        Optional<TileEntity> block = world.getTileEntity(loc.getX(), loc.getY(), loc.getZ());
 | 
				
			||||||
 | 
					        if (!block.isPresent()) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        TileEntity tile = block.get();
 | 
				
			||||||
 | 
					        if (!(tile instanceof Sign)) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Sign sign = (Sign) tile;
 | 
				
			||||||
 | 
					        Optional<List<Text>> optional = tile.get(Keys.SIGN_LINES);
 | 
				
			||||||
 | 
					        if (!optional.isPresent()) {
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Sign sign = (Sign) block;
 | 
					 | 
				
			||||||
        String[] result = new String[4];
 | 
					        String[] result = new String[4];
 | 
				
			||||||
        List<Text> lines = sign.getData().get().getLines();
 | 
					        List<Text> lines = optional.get();
 | 
				
			||||||
        for (int i = 0; i < 4; i++) {
 | 
					        for (int i = 0; i < 4; i++) {
 | 
				
			||||||
            result[i] = lines.get(i).toString();
 | 
					            result[i] = lines.get(i).toString();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -161,15 +174,20 @@ public class SpongeBlockManager extends BlockManager {
 | 
				
			|||||||
    public void functionSetSign(String worldname, int x, int y, int z, String[] lines) {
 | 
					    public void functionSetSign(String worldname, int x, int y, int z, String[] lines) {
 | 
				
			||||||
        World world = SpongeUtil.getWorld(worldname);
 | 
					        World world = SpongeUtil.getWorld(worldname);
 | 
				
			||||||
        world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState());
 | 
					        world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState());
 | 
				
			||||||
        BlockState block = world.getBlock(x, y, z);
 | 
					        Optional<TileEntity> block = world.getTileEntity(x, y, z);
 | 
				
			||||||
        if (!(block instanceof Sign)) {
 | 
					        if (!block.isPresent()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Sign sign = (Sign) block;
 | 
					        TileEntity tile = block.get();
 | 
				
			||||||
        SignData data = sign.getData().get();
 | 
					        if (!(tile instanceof Sign)) {
 | 
				
			||||||
        for (int i = 0; i < 4; i++) {
 | 
					            return;
 | 
				
			||||||
            data.setLine(i, SpongeMain.THIS.getText(lines[i]));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        Sign sign = (Sign) tile;
 | 
				
			||||||
 | 
					        List<Text> text = new ArrayList<>(4);
 | 
				
			||||||
 | 
					        for (int i = 0; i < 4; i++) {
 | 
				
			||||||
 | 
					            text.add(SpongeMain.THIS.getText(lines[i]));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        sign.offer(Keys.SIGN_LINES, text);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
 | 
				
			|||||||
    public ItemStackBuilder builder;
 | 
					    public ItemStackBuilder builder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public SpongeInventoryUtil() {
 | 
					    public SpongeInventoryUtil() {
 | 
				
			||||||
        this.builder = SpongeMain.THIS.getGame().getRegistry().getItemBuilder();
 | 
					        this.builder = SpongeMain.THIS.getGame().getRegistry().createItemBuilder();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -184,7 +184,7 @@ public class SpongeMetrics {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Begin hitting the server with glorious data
 | 
					            // Begin hitting the server with glorious data
 | 
				
			||||||
            TaskBuilder builder = game.getScheduler().getTaskBuilder();
 | 
					            TaskBuilder builder = game.getScheduler().createTaskBuilder();
 | 
				
			||||||
            builder.async()
 | 
					            builder.async()
 | 
				
			||||||
            .interval(TimeUnit.MINUTES.toMillis(PING_INTERVAL))
 | 
					            .interval(TimeUnit.MINUTES.toMillis(PING_INTERVAL))
 | 
				
			||||||
            .execute(new Runnable() {
 | 
					            .execute(new Runnable() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ public class SpongeTaskManager extends TaskManager {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int taskRepeat(Runnable r, int interval) {
 | 
					    public int taskRepeat(Runnable r, int interval) {
 | 
				
			||||||
        int val = i.incrementAndGet();
 | 
					        int val = i.incrementAndGet();
 | 
				
			||||||
        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
 | 
					        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
 | 
				
			||||||
        TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
 | 
					        TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
 | 
				
			||||||
        Task task = built.submit(SpongeMain.THIS.getPlugin());
 | 
					        Task task = built.submit(SpongeMain.THIS.getPlugin());
 | 
				
			||||||
        tasks.put(val, task);
 | 
					        tasks.put(val, task);
 | 
				
			||||||
@@ -28,7 +28,7 @@ public class SpongeTaskManager extends TaskManager {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int taskRepeatAsync(Runnable r, int interval) {
 | 
					    public int taskRepeatAsync(Runnable r, int interval) {
 | 
				
			||||||
        int val = i.incrementAndGet();
 | 
					        int val = i.incrementAndGet();
 | 
				
			||||||
        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
 | 
					        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
 | 
				
			||||||
        TaskBuilder built = builder.delay(interval).async().interval(interval).execute(r);
 | 
					        TaskBuilder built = builder.delay(interval).async().interval(interval).execute(r);
 | 
				
			||||||
        Task task = built.submit(SpongeMain.THIS.getPlugin());
 | 
					        Task task = built.submit(SpongeMain.THIS.getPlugin());
 | 
				
			||||||
        tasks.put(val, task);
 | 
					        tasks.put(val, task);
 | 
				
			||||||
@@ -37,25 +37,25 @@ public class SpongeTaskManager extends TaskManager {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void taskAsync(Runnable r) {
 | 
					    public void taskAsync(Runnable r) {
 | 
				
			||||||
        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
 | 
					        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
 | 
				
			||||||
        builder.async().execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
					        builder.async().execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void task(Runnable r) {
 | 
					    public void task(Runnable r) {
 | 
				
			||||||
        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
 | 
					        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
 | 
				
			||||||
        builder.execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
					        builder.execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void taskLater(Runnable r, int delay) {
 | 
					    public void taskLater(Runnable r, int delay) {
 | 
				
			||||||
        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
 | 
					        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
 | 
				
			||||||
        builder.delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
					        builder.delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void taskLaterAsync(Runnable r, int delay) {
 | 
					    public void taskLaterAsync(Runnable r, int delay) {
 | 
				
			||||||
        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
 | 
					        TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
 | 
				
			||||||
        builder.async().delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
					        builder.async().delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user