Browse Source

removed old piston fix, add plot with id for snuvi, removed villager
protection

Kajetan Johannes Hammerle 2 years ago
parent
commit
215e4b2634

+ 0 - 19
src/main/java/me/km/events/CustomEventCaller.java

@@ -69,23 +69,4 @@ public class CustomEventCaller {
             }
         }
     }
-
-    @SubscribeEvent
-    public void onPiston(PistonEvent.Pre e) {
-        if(e.getPistonMoveType() != PistonMoveType.EXTEND) {
-            return;
-        }
-        PistonBlockStructureHelper helper = e.getStructureHelper();
-        if(helper == null) {
-            return;
-        }
-        helper.canMove();
-        for(BlockPos pos : helper.getBlocksToDestroy()) {
-            BlockState state = e.getWorld().getBlockState(pos);
-            Block b = state.getBlock();
-            if(b == Blocks.CACTUS || b == Blocks.BAMBOO || b == Blocks.SUGAR_CANE) {
-                e.getWorld().setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
-            }
-        }
-    }
 }

+ 0 - 8
src/main/java/me/km/plots/ProtectionEvents.java

@@ -164,12 +164,4 @@ public class ProtectionEvents {
     public void onFarmlandTrample(BlockEvent.FarmlandTrampleEvent e) {
         e.setCanceled(true);
     }
-
-    @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onAttackVillager(LivingAttackEvent e) {
-        if(e.getEntityLiving().getType() == EntityType.VILLAGER
-                && !e.getSource().isCreativePlayer()) {
-            e.setCanceled(true);
-        }
-    }
 }

+ 11 - 2
src/main/java/me/km/plots/WorldPlotMap.java

@@ -71,16 +71,25 @@ public class WorldPlotMap {
         return map.getPlotAt(pos.getX(), pos.getY(), pos.getZ());
     }
 
-    public PlotMap.Plot add(World w, BlockPos pos1, BlockPos pos2) {
+    private PlotMap getOrCreate(World w) {
         PlotMap map = maps.get(w);
         if(map == null) {
             map = new PlotMap();
             maps.put(w, map);
         }
-        return map.add(pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(),
+        return map;
+    }
+
+    public PlotMap.Plot add(World w, BlockPos pos1, BlockPos pos2) {
+        return getOrCreate(w).add(pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(),
                 pos2.getZ());
     }
 
+    public PlotMap.Plot add(World w, BlockPos pos1, BlockPos pos2, int id) {
+        return getOrCreate(w).add(pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(),
+                pos2.getZ(), id);
+    }
+
     public void remove(World w, Plot p) {
         PlotMap map = maps.get(w);
         if(map != null) {

+ 2 - 0
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -595,9 +595,11 @@ public class ScriptEvents implements BlockHarvest, Craft, ContainerClick {
             sc.setVar("command", command);
             if(args.length == 0) {
                 sc.setVar("args", new ArrayList<>());
+                sc.setVar("text_args", new ArrayList<>());
             } else {
                 sc.setVar("args", Arrays.stream(args).map(s -> SnuviUtils.convert(s))
                         .collect(Collectors.toList()));
+                sc.setVar("text_args", List.of(args));
             }
         });
     }

+ 4 - 0
src/main/java/me/km/snuviscript/commands/PlotCommands.java

@@ -36,6 +36,10 @@ public class PlotCommands {
             if(l1.getWorld() != l2.getWorld()) {
                 throw new IllegalArgumentException("worlds not equal for locations");
             }
+            if(in.length > 2) {
+                return plots.add(l1.getWorld(), l1.getBlockPos(), l2.getBlockPos(),
+                        in[2].getInt(sc));
+            }
             return plots.add(l1.getWorld(), l1.getBlockPos(), l2.getBlockPos());
         });
         sm.registerConsumer("plot.remove", (sc, in) -> {