Browse Source

new plot commands

Kajetan Johannes Hammerle 4 years ago
parent
commit
cf0a83e3be

+ 1 - 1
build.gradle

@@ -17,7 +17,7 @@ version = '1.0'
 group = 'me.hammerle.km'
 archivesBaseName = 'km'
 
-sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
+//sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
 
 minecraft {
     mappings channel: 'snapshot', version: '20190719-1.14.3'

+ 38 - 0
src/main/java/me/km/plots/PlotMap.java

@@ -476,4 +476,42 @@ public class PlotMap
             ex.printStackTrace();
         }
     }
+    
+    public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
+    {
+        if(minX > maxX)
+        {
+            int tmp = minX;
+            minX = maxX;
+            maxX = tmp;
+        }
+
+        if(minY > maxY)
+        {
+            int tmp = minY;
+            minY = maxY;
+            maxY = tmp;
+        }
+
+        if(minZ > maxZ)
+        {
+            int tmp = minZ;
+            minZ = maxZ;
+            maxZ = tmp;
+        }
+            
+        ArrayList<Plot> list = new ArrayList<>();
+        
+        Plot p = last;
+        while(p != null)
+        {
+            if(maxX > p.minX && p.maxX > minX && maxY > p.minY && p.maxY > minY && maxZ > p.minZ && p.maxZ > minZ)
+            {
+                list.add(p);
+            }
+            p = p.previous;
+        }
+        
+        return list;
+    }
 }

+ 10 - 0
src/main/java/me/km/plots/WorldPlotMap.java

@@ -122,6 +122,16 @@ public class WorldPlotMap
         return Collections.EMPTY_LIST.iterator();
     }
     
+    public List<Plot> getIntersectingPlots(IWorld w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
+    {
+        PlotMap map = maps.get(w);
+        if(map != null)
+        {
+            return map.getIntersectingPlots(minX, minY, minZ, maxX, maxY, maxZ);
+        }
+        return Collections.EMPTY_LIST;
+    }
+    
     public void save()
     {
         File f = new File("plot_storage");

+ 11 - 0
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -1860,6 +1860,17 @@ public class MinecraftFunctions
             }
             return plots.getIterator(word);
         });
+        sm.registerFunction("plot.intersecting", (sc, in) -> 
+                plots.getIntersectingPlots((IWorld) in[0].get(sc), in[1].getInt(sc), 
+                        in[2].getInt(sc), in[3].getInt(sc), in[4].getInt(sc), 
+                        in[5].getInt(sc), in[6].getInt(sc)));
+        
+        sm.registerFunction("plot.getminx", (sc, in) -> (double) ((Plot) in[0].get(sc)).getMinX());
+        sm.registerFunction("plot.getminy", (sc, in) -> (double) ((Plot) in[0].get(sc)).getMinY());
+        sm.registerFunction("plot.getminz", (sc, in) -> (double) ((Plot) in[0].get(sc)).getMinZ());
+        sm.registerFunction("plot.getmaxx", (sc, in) -> (double) ((Plot) in[0].get(sc)).getMaxX());
+        sm.registerFunction("plot.getmaxy", (sc, in) -> (double) ((Plot) in[0].get(sc)).getMaxY());
+        sm.registerFunction("plot.getmaxz", (sc, in) -> (double) ((Plot) in[0].get(sc)).getMaxZ());
         
         // ---------------------------------------------------------------------  
         // block protection library