mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 22:01:07 +00:00
Change Java whitespace handling in .editorconfig (#425)
* Change whitespace handling in .editorconfig * Reformat code * fix format error * Reformat code --------- Co-authored-by: Zoë Gidiere <duplexsys@protonmail.com>
This commit is contained in:
+2
-2
@@ -15,11 +15,11 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class BiomeStructures implements Properties {
|
||||
private final Set<ConfiguredStructure> structures;
|
||||
|
||||
|
||||
public BiomeStructures(Set<ConfiguredStructure> structures) {
|
||||
this.structures = structures;
|
||||
}
|
||||
|
||||
|
||||
public Set<ConfiguredStructure> getStructures() {
|
||||
return structures;
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class BiomeStructuresTemplate implements ObjectTemplate<BiomeStructures>
|
||||
@Value("structures")
|
||||
@Default
|
||||
private @Meta Set<@Meta ConfiguredStructure> structures = Collections.emptySet();
|
||||
|
||||
|
||||
@Override
|
||||
public BiomeStructures get() {
|
||||
return new BiomeStructures(structures);
|
||||
|
||||
+6
-6
@@ -18,16 +18,16 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
public class StructureAddon implements AddonInitializer {
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new StructureConfigType(), addon.key("STRUCTURE"), 2))
|
||||
.failThrough();
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new StructureConfigType(), addon.key("STRUCTURE"), 2))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -19,17 +19,17 @@ public class StructureConfigType implements ConfigType<StructureTemplate, Config
|
||||
public static final TypeKey<ConfiguredStructure> CONFIGURED_STRUCTURE_TYPE_KEY = new TypeKey<>() {
|
||||
};
|
||||
private final ConfigFactory<StructureTemplate, ConfiguredStructure> factory = new StructureFactory();
|
||||
|
||||
|
||||
@Override
|
||||
public StructureTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new StructureTemplate();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigFactory<StructureTemplate, ConfiguredStructure> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypeKey<ConfiguredStructure> getTypeKey() {
|
||||
return CONFIGURED_STRUCTURE_TYPE_KEY;
|
||||
|
||||
+7
-7
@@ -23,28 +23,28 @@ public class StructureTemplate implements AbstractableTemplate {
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
|
||||
@Value("scripts")
|
||||
private @Meta ProbabilityCollection<@Meta Structure> structure;
|
||||
|
||||
|
||||
@Value("spawn.start")
|
||||
private @Meta Range y;
|
||||
|
||||
|
||||
@Value("spawn")
|
||||
private @Meta StructureSpawn spawn;
|
||||
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public ProbabilityCollection<Structure> getStructures() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
public Range getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
public StructureSpawn getSpawn() {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
+6
-6
@@ -18,31 +18,31 @@ public class TerraStructure implements ConfiguredStructure {
|
||||
private final ProbabilityCollection<Structure> structure;
|
||||
private final Range spawnStart;
|
||||
private final StructureSpawn spawn;
|
||||
|
||||
|
||||
private final String id;
|
||||
|
||||
|
||||
public TerraStructure(ProbabilityCollection<Structure> structures, Range spawnStart, StructureSpawn spawn, String id) {
|
||||
this.structure = structures;
|
||||
this.spawnStart = spawnStart;
|
||||
this.spawn = spawn;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ProbabilityCollection<Structure> getStructure() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Range getSpawnStart() {
|
||||
return spawnStart;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StructureSpawn getSpawn() {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return id;
|
||||
|
||||
+6
-6
@@ -30,7 +30,7 @@ public class Entry {
|
||||
private final Item item;
|
||||
private final long weight;
|
||||
private final List<LootFunction> functions = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates an Entry from a JSON representation.
|
||||
*
|
||||
@@ -39,14 +39,14 @@ public class Entry {
|
||||
public Entry(JSONObject entry, Platform platform) {
|
||||
String id = entry.get("name").toString();
|
||||
this.item = platform.getItemHandle().createItem(id);
|
||||
|
||||
|
||||
long weight1;
|
||||
try {
|
||||
weight1 = (long) entry.get("weight");
|
||||
} catch(NullPointerException e) {
|
||||
weight1 = 1;
|
||||
}
|
||||
|
||||
|
||||
this.weight = weight1;
|
||||
if(entry.containsKey("functions")) {
|
||||
for(Object function : (JSONArray) entry.get("functions")) {
|
||||
@@ -75,13 +75,13 @@ public class Entry {
|
||||
if(((JSONObject) function).containsKey("disabled_enchants"))
|
||||
disabled = (JSONArray) ((JSONObject) function).get("disabled_enchants");
|
||||
functions.add(
|
||||
new EnchantFunction(Math.toIntExact(minEnchant), Math.toIntExact(maxEnchant), disabled, platform));
|
||||
new EnchantFunction(Math.toIntExact(minEnchant), Math.toIntExact(maxEnchant), disabled, platform));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches a single ItemStack from the Entry, applying all functions to it.
|
||||
*
|
||||
@@ -96,7 +96,7 @@ public class Entry {
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the weight attribute of the Entry.
|
||||
*
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ import com.dfsek.terra.api.inventory.ItemStack;
|
||||
*/
|
||||
public class LootTableImpl implements com.dfsek.terra.api.structure.LootTable {
|
||||
private final List<Pool> pools = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a LootTable from a JSON String.
|
||||
*
|
||||
@@ -42,7 +42,7 @@ public class LootTableImpl implements com.dfsek.terra.api.structure.LootTable {
|
||||
pools.add(new Pool((JSONObject) pool, platform));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fillInventory(Inventory i, Random r) {
|
||||
List<ItemStack> loot = getLoot(r);
|
||||
@@ -68,7 +68,7 @@ public class LootTableImpl implements com.dfsek.terra.api.structure.LootTable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getLoot(Random r) {
|
||||
List<ItemStack> itemList = new ArrayList<>();
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ public class Pool {
|
||||
private final int max;
|
||||
private final int min;
|
||||
private final ProbabilityCollection<Entry> entries;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a Pool from a JSON representation.
|
||||
*
|
||||
@@ -42,13 +42,13 @@ public class Pool {
|
||||
max = Math.toIntExact((Long) ((JSONObject) amount).get("max"));
|
||||
min = Math.toIntExact((Long) ((JSONObject) amount).get("min"));
|
||||
}
|
||||
|
||||
|
||||
for(Object entryJSON : (JSONArray) pool.get("entries")) {
|
||||
Entry entry = new Entry((JSONObject) entryJSON, platform);
|
||||
entries.add(entry, Math.toIntExact(entry.getWeight()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches a list of items from the pool using the provided Random instance.
|
||||
*
|
||||
@@ -57,7 +57,7 @@ public class Pool {
|
||||
* @return List<ItemStack> - The list of items fetched.
|
||||
*/
|
||||
public List<ItemStack> getItems(Random r) {
|
||||
|
||||
|
||||
int rolls = r.nextInt(max - min + 1) + min;
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for(int i = 0; i < rolls; i++) {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import com.dfsek.terra.api.inventory.ItemStack;
|
||||
public class AmountFunction implements LootFunction {
|
||||
private final int max;
|
||||
private final int min;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates an AmountFunction.
|
||||
*
|
||||
@@ -30,7 +30,7 @@ public class AmountFunction implements LootFunction {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
public class DamageFunction implements LootFunction {
|
||||
private final int max;
|
||||
private final int min;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a DamageFunction.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ public class DamageFunction implements LootFunction {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
|
||||
+7
-7
@@ -28,15 +28,15 @@ public class EnchantFunction implements LootFunction {
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
private final Platform platform;
|
||||
|
||||
|
||||
|
||||
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, Platform platform) {
|
||||
this.max = max;
|
||||
this.min = min;
|
||||
this.disabled = disabled;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
@@ -48,7 +48,7 @@ public class EnchantFunction implements LootFunction {
|
||||
@Override
|
||||
public ItemStack apply(ItemStack original, Random r) {
|
||||
if(original.getItemMeta() == null) return original;
|
||||
|
||||
|
||||
double enchant = (r.nextDouble() * (max - min)) + min;
|
||||
List<Enchantment> possible = new ArrayList<>();
|
||||
for(Enchantment ench : platform.getItemHandle().getEnchantments()) {
|
||||
@@ -70,9 +70,9 @@ public class EnchantFunction implements LootFunction {
|
||||
meta.addEnchantment(chosen, Math.max(lvl, 1));
|
||||
} catch(IllegalArgumentException e) {
|
||||
LOGGER.warn(
|
||||
"Attempted to enchant {} with {} at level {}, but an unexpected exception occurred! Usually this is caused by a " +
|
||||
"misbehaving enchantment plugin.",
|
||||
original.getType(), chosen, Math.max(lvl, 1));
|
||||
"Attempted to enchant {} with {} at level {}, but an unexpected exception occurred! Usually this is caused by a " +
|
||||
"misbehaving enchantment plugin.",
|
||||
original.getType(), chosen, Math.max(lvl, 1));
|
||||
}
|
||||
}
|
||||
original.setItemMeta(meta);
|
||||
|
||||
Reference in New Issue
Block a user