Преглед изворни кода

new setup and partial formatting

Kajetan Johannes Hammerle пре 3 година
родитељ
комит
42d15b03ed

+ 4 - 5
.gitignore

@@ -5,11 +5,10 @@
 gradle.properties
 gradlew
 /.gradle
-/.nb-gradle
-.nb-gradle-properties
-runClient.launch
-runServer.launch
 /libs
 LineCounter.jar
-cleanEclipse.sh
 uploadMod.sh
+.classpath
+.project
+.settings
+bin

+ 9 - 5
src/main/java/me/km/KajetansMod.java

@@ -83,7 +83,8 @@ public class KajetansMod {
     }
 
     private static boolean findOreBiome(BiomeLoadingEvent e) {
-        for(Supplier<ConfiguredFeature<?, ?>> a : e.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES)) {
+        for(Supplier<ConfiguredFeature<?, ?>> a : e.getGeneration()
+                .getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES)) {
             ConfiguredFeature<?, ?> cf = a.get();
             if(unpack(cf)) {
                 return true;
@@ -104,10 +105,13 @@ public class KajetansMod {
         return false;
     }
 
-    private static void addOre(BiomeGenerationSettingsBuilder builder, Block ore, int maxCount, int spawnTries, int maxHeight) {
-        builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(
-                new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD,
-                        ore.getDefaultState(), maxCount)).range(maxHeight).square().func_242731_b(spawnTries));
+    private static void addOre(BiomeGenerationSettingsBuilder builder, Block ore, int maxCount,
+            int spawnTries, int maxHeight) {
+        builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE
+                .withConfiguration(
+                        new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD,
+                                ore.getDefaultState(), maxCount))
+                .range(maxHeight).square().func_242731_b(spawnTries));
     }
 
     private static void addFeatures(BiomeGenerationSettingsBuilder builder) {

+ 21 - 27
src/main/java/me/km/ObjectRegistry.java

@@ -1,6 +1,5 @@
 package me.km;
 
-import java.util.function.Supplier;
 import me.km.blocks.ModBlocks;
 import me.km.blocks.cookingpot.TileEntityCookingPot;
 import me.km.entities.ModEntities;
@@ -11,10 +10,7 @@ import net.minecraft.entity.EntityType;
 import net.minecraft.item.Item;
 import net.minecraft.item.Items;
 import net.minecraft.tileentity.TileEntityType;
-import net.minecraft.world.gen.GenerationStage;
-import net.minecraft.world.gen.feature.ConfiguredFeature;
 import net.minecraftforge.event.RegistryEvent;
-import net.minecraftforge.event.world.BiomeLoadingEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 import net.minecraftforge.fml.common.Mod;
 
@@ -27,33 +23,31 @@ public class ObjectRegistry {
 
     @SubscribeEvent
     public static void onBlockMissing(RegistryEvent.MissingMappings<Block> e) {
-        e.getMappings().stream()
-                .forEach((missing) -> {
-                    String key = missing.key.toString();
-                    if(key.contains("cauldron")) {
-                        missing.remap(ModBlocks.cookingPotCopper);
-                    } else if(key.contains("campfire")) {
-                        missing.remap(Blocks.CAMPFIRE);
-                    } else if(key.contains("spikes")) {
-                        missing.remap(ModBlocks.spikesCopper);
-                    } else if(key.contains("campfire")) {
-                        missing.remap(Blocks.CAMPFIRE);
-                    } else if(key.contains("barrel")) {
-                        missing.remap(Blocks.BARREL);
-                    } else if(key.contains("poison") || key.contains("honey")) {
-                        missing.remap(Blocks.WATER);
-                    } else {
-                        missing.remap(Blocks.STONE);
-                    }
-                });
+        e.getMappings().stream().forEach((missing) -> {
+            String key = missing.key.toString();
+            if(key.contains("cauldron")) {
+                missing.remap(ModBlocks.cookingPotCopper);
+            } else if(key.contains("campfire")) {
+                missing.remap(Blocks.CAMPFIRE);
+            } else if(key.contains("spikes")) {
+                missing.remap(ModBlocks.spikesCopper);
+            } else if(key.contains("campfire")) {
+                missing.remap(Blocks.CAMPFIRE);
+            } else if(key.contains("barrel")) {
+                missing.remap(Blocks.BARREL);
+            } else if(key.contains("poison") || key.contains("honey")) {
+                missing.remap(Blocks.WATER);
+            } else {
+                missing.remap(Blocks.STONE);
+            }
+        });
     }
 
     @SubscribeEvent
     public static void onItemMissing(RegistryEvent.MissingMappings<Item> e) {
-        e.getMappings().stream()
-                .forEach((missing) -> {
-                    missing.remap(Items.APPLE);
-                });
+        e.getMappings().stream().forEach((missing) -> {
+            missing.remap(Items.APPLE);
+        });
     }
 
     @SubscribeEvent

+ 4 - 4
src/main/java/me/km/Server.java

@@ -75,7 +75,8 @@ public class Server {
         commands.registerCommand(new CommandScript(scripts, server));
 
         // data base connection
-        databank = new DataBank(logger, conf.getString(null, "user", "root"), conf.getString(null, "password", ""));
+        databank = new DataBank(logger, conf.getString(null, "user", "root"),
+                conf.getString(null, "password", ""));
         if(!databank.openDataBankConnection()) {
             logger.print("------------------------------------------------");
             logger.print("Starting server with dummy databank");
@@ -111,9 +112,8 @@ public class Server {
         } else {
             scriptBank = new ScriptBank(databank, playerManager);
         }
-        MinecraftFunctions.registerFunctions(
-                scripts.getScriptManager(), scripts, perms, scheduler, server, playerBank,
-                customEventCaller, scriptBank, databank, plotMap, commands);
+        MinecraftFunctions.registerFunctions(scripts.getScriptManager(), scripts, perms, scheduler,
+                server, playerBank, customEventCaller, scriptBank, databank, plotMap, commands);
 
         scheduler.scheduleTask(() -> scripts.startScript(null, "startscript"));
     }

+ 18 - 16
src/main/java/me/km/plots/PlotMap.java

@@ -128,19 +128,17 @@ public class PlotMap {
 
         @Override
         public String toString() {
-            return String.format("Plot(%d, %d, %d, %d, %d, %d)", minX, minY, minZ, maxX, maxY, maxZ);
+            return String.format("Plot(%d, %d, %d, %d, %d, %d)", minX, minY, minZ, maxX, maxY,
+                    maxZ);
         }
     }
 
     private static int idCounter = 0;
 
     private static final int SIZE_FACTOR = 64;
-    private final static int[] PRIMES
-            = {
-                17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911, 43853, 87719,
-                175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
-                44917381, 89834777, 179669557, 359339171, 718678369
-            };
+    private final static int[] PRIMES = {17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911,
+            43853, 87719, 175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
+            44917381, 89834777, 179669557, 359339171, 718678369};
 
     private int primeIndex = 0;
     private int size = 0;
@@ -219,7 +217,8 @@ public class PlotMap {
     }
 
     public List<Plot> getPlotAt(int x, int y, int z) {
-        ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
+        ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR),
+                Math.floorDiv(z, SIZE_FACTOR), plots.length)];
         if(list == null) {
             return new ArrayList<>();
         }
@@ -227,7 +226,8 @@ public class PlotMap {
     }
 
     public boolean anyPlotMatches(int x, int y, int z, boolean empty, Predicate<Plot> pred) {
-        ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
+        ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR),
+                Math.floorDiv(z, SIZE_FACTOR), plots.length)];
         if(list == null) {
             return empty;
         }
@@ -331,7 +331,7 @@ public class PlotMap {
 
     public void save(String path) {
         File f = new File(path);
-        try(DataOutputStream out = new DataOutputStream(new FileOutputStream(f))) {
+        try (DataOutputStream out = new DataOutputStream(new FileOutputStream(f))) {
             Iterator<Plot> iter = getIterator();
             while(iter.hasNext()) {
                 Plot p = iter.next();
@@ -352,7 +352,7 @@ public class PlotMap {
                 out.writeInt(p.flags);
                 out.writeUTF(p.name);
             }
-        } catch(IOException ex) {
+        } catch (IOException ex) {
             ex.printStackTrace();
         }
     }
@@ -361,7 +361,7 @@ public class PlotMap {
         if(!f.exists()) {
             return;
         }
-        try(DataInputStream in = new DataInputStream(new FileInputStream(f))) {
+        try (DataInputStream in = new DataInputStream(new FileInputStream(f))) {
             while(true) {
                 int id = in.readInt();
                 int minX = in.readShort();
@@ -381,13 +381,14 @@ public class PlotMap {
                 p.flags = in.readInt();
                 p.name = in.readUTF();
             }
-        } catch(EOFException ex) {
-        } catch(IOException ex) {
+        } catch (EOFException ex) {
+        } catch (IOException ex) {
             ex.printStackTrace();
         }
     }
 
-    public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
+    public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY,
+            int maxZ) {
         if(minX > maxX) {
             int tmp = minX;
             minX = maxX;
@@ -410,7 +411,8 @@ public class PlotMap {
 
         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) {
+            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;

+ 6 - 3
src/main/java/me/km/plots/WorldPlotMap.java

@@ -31,7 +31,8 @@ public class WorldPlotMap {
             return empty;
         }
         if(p == null) {
-            return map.anyPlotMatches(pos.getX(), pos.getY(), pos.getZ(), empty, plot -> plot.hasFlags(flag));
+            return map.anyPlotMatches(pos.getX(), pos.getY(), pos.getZ(), empty,
+                    plot -> plot.hasFlags(flag));
         }
         UUID uuid = p.getUniqueID();
         return map.anyPlotMatches(pos.getX(), pos.getY(), pos.getZ(), empty,
@@ -76,7 +77,8 @@ public class WorldPlotMap {
             map = new PlotMap();
             maps.put(w, map);
         }
-        return map.add(pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(), pos2.getZ());
+        return map.add(pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(),
+                pos2.getZ());
     }
 
     public void remove(World w, Plot p) {
@@ -102,7 +104,8 @@ public class WorldPlotMap {
         return Collections.EMPTY_LIST.iterator();
     }
 
-    public List<Plot> getIntersectingPlots(World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
+    public List<Plot> getIntersectingPlots(World 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);

+ 1 - 1
src/main/java/me/km/snuviscript/FakeMerchant.java

@@ -30,7 +30,7 @@ public class FakeMerchant extends Entity implements IMerchant {
 
     @Override
     public void setCustomer(PlayerEntity p) {
-        if(p != null) {
+        if (p != null) {
             world = p.world;
             setPosition(p.getPosX(), p.getPosY(), p.getPosZ());
         }

+ 10 - 8
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -12,10 +12,11 @@ import net.minecraft.server.MinecraftServer;
 import me.km.snuviscript.commands.*;
 
 public class MinecraftFunctions {
-    public static void registerFunctions(ScriptManager sm, Scripts scripts, Permissions perms, SnuviScheduler scheduler, 
-            MinecraftServer server, IPlayerBank playerBank, CustomEventCaller cec, IScriptBank scriptBank, 
-            DataBank dataBank, WorldPlotMap plots, ModCommandManager commands) {
-        CommandCommands.registerFunctions(sm, scripts, perms, server, commands);        
+    public static void registerFunctions(ScriptManager sm, Scripts scripts, Permissions perms,
+            SnuviScheduler scheduler, MinecraftServer server, IPlayerBank playerBank,
+            CustomEventCaller cec, IScriptBank scriptBank, DataBank dataBank, WorldPlotMap plots,
+            ModCommandManager commands) {
+        CommandCommands.registerFunctions(sm, scripts, perms, server, commands);
         PermissionCommands.registerFunctions(sm, perms);
         TableCommands.registerFunctions(sm);
         TitleCommands.registerFunctions(sm);
@@ -30,21 +31,22 @@ public class MinecraftFunctions {
         EntityCommands.registerFunctions(sm, scheduler);
         LivingCommands.registerFunctions(sm);
         HumanCommands.registerFunctions(sm);
-        DeprecatedCommands.registerFunctions(sm, scripts, perms, scheduler, server, playerBank, cec, scriptBank, dataBank, plots, commands);
-        DatabankCommands.registerFunctions(sm, scheduler, dataBank);      
+        DeprecatedCommands.registerFunctions(sm, scripts, perms, scheduler, server, playerBank, cec,
+                scriptBank, dataBank, plots, commands);
+        DatabankCommands.registerFunctions(sm, scheduler, dataBank);
         PlotCommands.registerFunctions(sm, plots);
         ScriptCommands.registerFunctions(sm, scripts, server);
         ScoreboardCommands.registerFunctions(sm, scripts, perms, server);
         DisplayCommands.registerFunctions(sm, scripts, perms, server);
         StatusCommands.registerFunctions(sm, scripts, perms, server);
         ItemStackDisplayCommands.registerFunctions(sm, scripts, perms, server);
-        HeadCommands.registerFunctions(sm, scripts, perms, server);     
+        HeadCommands.registerFunctions(sm, scripts, perms, server);
         ParticleCommands.registerFunctions(sm);
         SoundCommands.registerFunctions(sm);
         InventoryCommands.registerFunctions(sm);
         DataCommands.registerFunctions(sm, scheduler);
         ReadCommands.registerFunctions(sm, server);
-        TextCommands.registerFunctions(sm);       
+        TextCommands.registerFunctions(sm);
         BanCommands.registerFunctions(sm, server);
         ShopCommands.registerFunctions(sm);
         ErrorCommands.registerFunctions(sm);