Per-World Generators

This commit is contained in:
Fabrizio La Rosa 2020-06-14 17:09:29 +02:00
parent 93ee9d5092
commit 2892bd7192
4 changed files with 38 additions and 9 deletions

View File

@ -1,6 +1,7 @@
package com.songoda.skyblock.generator;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.island.IslandWorld;
import java.util.List;
@ -8,12 +9,14 @@ import java.util.List;
public class Generator {
private String name;
private IslandWorld isWorld;
private CompatibleMaterial materials;
private List<GeneratorMaterial> generatorMaterials;
private boolean permission;
public Generator(String name, CompatibleMaterial materials, List<GeneratorMaterial> generatorMaterials, boolean permission) {
public Generator(String name, IslandWorld isWorld, CompatibleMaterial materials, List<GeneratorMaterial> generatorMaterials, boolean permission) {
this.name = name;
this.isWorld = isWorld;
this.materials = materials;
this.generatorMaterials = generatorMaterials;
this.permission = permission;
@ -23,6 +26,10 @@ public class Generator {
return name;
}
public IslandWorld getIsWorld() {
return isWorld;
}
public CompatibleMaterial getMaterials() {
return materials;
}

View File

@ -5,6 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -56,6 +57,7 @@ public class GeneratorManager {
}
generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"),
IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal")),
oreMaterials[rnd.nextInt(oreMaterials.length)], generatorMaterials,
configLoad.getBoolean("Generators." + generatorList + ".Permission")));
}
@ -150,10 +152,10 @@ public class GeneratorManager {
return CompatibleMaterial.COBBLESTONE;
}
public void addGenerator(String name, List<GeneratorMaterial> generatorMaterials, boolean permission) {
public void addGenerator(String name, IslandWorld isWorld, List<GeneratorMaterial> generatorMaterials, boolean permission) {
CompatibleMaterial[] oreMaterials = new CompatibleMaterial[]{CompatibleMaterial.COAL, CompatibleMaterial.CHARCOAL, CompatibleMaterial.DIAMOND,
CompatibleMaterial.IRON_INGOT, CompatibleMaterial.GOLD_INGOT, CompatibleMaterial.EMERALD};
generatorStorage.add(new Generator(name, oreMaterials[new Random().nextInt(oreMaterials.length)],
generatorStorage.add(new Generator(name, isWorld, oreMaterials[new Random().nextInt(oreMaterials.length)],
generatorMaterials, permission));
}

View File

@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.generator.GeneratorManager;
import com.songoda.skyblock.generator.GeneratorMaterial;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
@ -277,7 +278,7 @@ public class Generator implements Listener {
configLoad.getString("Island.Admin.Generator.Characters.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
generatorManager.addGenerator(event1.getName(), new ArrayList<>(), false);
generatorManager.addGenerator(event1.getName(), IslandWorld.Normal, new ArrayList<>(), false);
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Generator.Created.Message")

View File

@ -1,6 +1,7 @@
Generators:
Default:
Name: Default
Normal:
Name: Normal
World: Normal
Permission: false
Materials:
COBBLESTONE:
@ -15,3 +16,21 @@ Generators:
Chance: 5.5
DIAMOND_ORE:
Chance: 2.5
Nether:
Name: Nether
World: Nether
Permission: false
Materials:
NETHERRACK:
Chance: 80
GLOWSTONE:
Chance: 10.0
QUARTZ_ORE:
Chance: 10.0
End:
Name: End
World: End
Permission: false
Materials:
END_STONE:
Chance: 100.0