mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
world optimization and beginning of messages stuff
This commit is contained in:
parent
2fa5afe40f
commit
2aba16cff2
@ -4,9 +4,10 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.plex.cache.MongoPlayerData;
|
import me.totalfreedom.plex.cache.MongoPlayerData;
|
||||||
import me.totalfreedom.plex.cache.SQLPlayerData;
|
import me.totalfreedom.plex.cache.SQLPlayerData;
|
||||||
import me.totalfreedom.plex.config.MainConfig;
|
import me.totalfreedom.plex.config.Config;
|
||||||
import me.totalfreedom.plex.handlers.CommandHandler;
|
import me.totalfreedom.plex.handlers.CommandHandler;
|
||||||
import me.totalfreedom.plex.handlers.ListenerHandler;
|
import me.totalfreedom.plex.handlers.ListenerHandler;
|
||||||
|
import me.totalfreedom.plex.message.MessageManager;
|
||||||
import me.totalfreedom.plex.rank.RankManager;
|
import me.totalfreedom.plex.rank.RankManager;
|
||||||
import me.totalfreedom.plex.storage.MongoConnection;
|
import me.totalfreedom.plex.storage.MongoConnection;
|
||||||
import me.totalfreedom.plex.storage.RedisConnection;
|
import me.totalfreedom.plex.storage.RedisConnection;
|
||||||
@ -14,8 +15,7 @@ import me.totalfreedom.plex.storage.SQLConnection;
|
|||||||
import me.totalfreedom.plex.storage.StorageType;
|
import me.totalfreedom.plex.storage.StorageType;
|
||||||
import me.totalfreedom.plex.util.PlexLog;
|
import me.totalfreedom.plex.util.PlexLog;
|
||||||
import me.totalfreedom.plex.util.PlexUtils;
|
import me.totalfreedom.plex.util.PlexUtils;
|
||||||
import me.totalfreedom.plex.world.impl.Flatlands;
|
import me.totalfreedom.plex.world.CustomWorld;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -23,7 +23,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
public class Plex extends JavaPlugin
|
public class Plex extends JavaPlugin
|
||||||
{
|
{
|
||||||
private static Plex plugin;
|
private static Plex plugin;
|
||||||
public MainConfig config;
|
public Config config;
|
||||||
private StorageType storageType = StorageType.SQLITE;
|
private StorageType storageType = StorageType.SQLITE;
|
||||||
|
|
||||||
private SQLConnection sqlConnection;
|
private SQLConnection sqlConnection;
|
||||||
@ -34,8 +34,7 @@ public class Plex extends JavaPlugin
|
|||||||
private SQLPlayerData sqlPlayerData;
|
private SQLPlayerData sqlPlayerData;
|
||||||
|
|
||||||
private RankManager rankManager;
|
private RankManager rankManager;
|
||||||
|
private MessageManager messageManager;
|
||||||
public World flatlands;
|
|
||||||
|
|
||||||
public static Plex get()
|
public static Plex get()
|
||||||
{
|
{
|
||||||
@ -46,7 +45,7 @@ public class Plex extends JavaPlugin
|
|||||||
public void onLoad()
|
public void onLoad()
|
||||||
{
|
{
|
||||||
plugin = this;
|
plugin = this;
|
||||||
config = new MainConfig(this);
|
config = new Config(this, "config.yml");
|
||||||
saveResource("database.db", false);
|
saveResource("database.db", false);
|
||||||
|
|
||||||
sqlConnection = new SQLConnection();
|
sqlConnection = new SQLConnection();
|
||||||
@ -94,6 +93,10 @@ public class Plex extends JavaPlugin
|
|||||||
rankManager.importDefaultRanks();
|
rankManager.importDefaultRanks();
|
||||||
PlexLog.log("Rank Manager initialized");
|
PlexLog.log("Rank Manager initialized");
|
||||||
|
|
||||||
|
messageManager = new MessageManager();
|
||||||
|
messageManager.generateMessages();
|
||||||
|
PlexLog.log("Message Manager initialized");
|
||||||
|
|
||||||
generateWorlds();
|
generateWorlds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +113,8 @@ public class Plex extends JavaPlugin
|
|||||||
private void generateWorlds()
|
private void generateWorlds()
|
||||||
{
|
{
|
||||||
PlexLog.log("Generating any worlds if needed...");
|
PlexLog.log("Generating any worlds if needed...");
|
||||||
flatlands = new Flatlands().generate();
|
for (String key : config.getConfigurationSection("worlds").getKeys(false))
|
||||||
|
CustomWorld.generateConfigFlatWorld(key);
|
||||||
PlexLog.log("Finished with world generation!");
|
PlexLog.log("Finished with world generation!");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,6 +16,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class PlexCommand extends Command implements TabExecutor, IPlexCommand
|
public abstract class PlexCommand extends Command implements TabExecutor, IPlexCommand
|
||||||
{
|
{
|
||||||
|
protected static Plex plugin = Plex.get();
|
||||||
|
|
||||||
private final CommandParameters params;
|
private final CommandParameters params;
|
||||||
private final CommandPermissions perms;
|
private final CommandPermissions perms;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class TestCMD extends PlexCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
sender.sendMessage("HIIII BICH");
|
sender.sendMessage(plugin.getMessageManager().getMessage("test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,4 @@ public class CommandSource
|
|||||||
this.player = sender instanceof Player ? Bukkit.getPlayer(sender.getName()) : null;
|
this.player = sender instanceof Player ? Bukkit.getPlayer(sender.getName()) : null;
|
||||||
this.plexPlayer = sender instanceof Player ? PlayerCache.getPlexPlayerMap().get(((Player)sender).getUniqueId()) : null;
|
this.plexPlayer = sender instanceof Player ? PlayerCache.getPlexPlayerMap().get(((Player)sender).getUniqueId()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,15 +4,17 @@ import java.io.File;
|
|||||||
import me.totalfreedom.plex.Plex;
|
import me.totalfreedom.plex.Plex;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class MainConfig extends YamlConfiguration
|
public class Config extends YamlConfiguration
|
||||||
{
|
{
|
||||||
private Plex plugin;
|
private Plex plugin;
|
||||||
private File file;
|
private File file;
|
||||||
|
private String name;
|
||||||
|
|
||||||
public MainConfig(Plex plugin)
|
public Config(Plex plugin, String name)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.file = new File(plugin.getDataFolder(), "config.yml");
|
this.file = new File(plugin.getDataFolder(), name);
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
@ -46,6 +48,6 @@ public class MainConfig extends YamlConfiguration
|
|||||||
|
|
||||||
private void saveDefault()
|
private void saveDefault()
|
||||||
{
|
{
|
||||||
plugin.saveResource("config.yml", false);
|
plugin.saveResource(name, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|||||||
import me.totalfreedom.plex.listener.PlexListener;
|
import me.totalfreedom.plex.listener.PlexListener;
|
||||||
import me.totalfreedom.plex.listener.impl.ChatListener;
|
import me.totalfreedom.plex.listener.impl.ChatListener;
|
||||||
import me.totalfreedom.plex.listener.impl.PlayerListener;
|
import me.totalfreedom.plex.listener.impl.PlayerListener;
|
||||||
|
import me.totalfreedom.plex.listener.impl.WorldListener;
|
||||||
import me.totalfreedom.plex.util.PlexLog;
|
import me.totalfreedom.plex.util.PlexLog;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,6 +18,7 @@ public class ListenerHandler
|
|||||||
{
|
{
|
||||||
listeners.add(new ChatListener());
|
listeners.add(new ChatListener());
|
||||||
listeners.add(new PlayerListener());
|
listeners.add(new PlayerListener());
|
||||||
|
listeners.add(new WorldListener());
|
||||||
|
|
||||||
PlexLog.log(String.format("Registered %s listeners!", listeners.size()));
|
PlexLog.log(String.format("Registered %s listeners!", listeners.size()));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package me.totalfreedom.plex.listener.impl;
|
||||||
|
|
||||||
|
import me.totalfreedom.plex.cache.PlayerCache;
|
||||||
|
import me.totalfreedom.plex.listener.PlexListener;
|
||||||
|
import me.totalfreedom.plex.player.PlexPlayer;
|
||||||
|
import me.totalfreedom.plex.rank.enums.Rank;
|
||||||
|
import me.totalfreedom.plex.util.PlexUtils;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
public class WorldListener extends PlexListener
|
||||||
|
{
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPlace(BlockPlaceEvent e)
|
||||||
|
{
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
||||||
|
World world = player.getWorld();
|
||||||
|
switch (world.getName())
|
||||||
|
{
|
||||||
|
case "adminworld":
|
||||||
|
{
|
||||||
|
if (plexPlayer.getRankFromString().isAtleast(Rank.ADMIN))
|
||||||
|
return;
|
||||||
|
e.setCancelled(true);
|
||||||
|
player.sendMessage(PlexUtils.color(plugin.getMessageManager().getMessage("noAdminWorldBlockPlace")));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package me.totalfreedom.plex.message;
|
||||||
|
|
||||||
|
import me.totalfreedom.plex.Plex;
|
||||||
|
import me.totalfreedom.plex.util.PlexLog;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class MessageManager
|
||||||
|
{
|
||||||
|
private final File messages;
|
||||||
|
|
||||||
|
public MessageManager()
|
||||||
|
{
|
||||||
|
this.messages = new File(Plex.get().getDataFolder(), "messages.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateMessages()
|
||||||
|
{
|
||||||
|
if (messages.exists())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
messages.createNewFile();
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
if (obj.length() == 0)
|
||||||
|
{
|
||||||
|
obj.put("test", "this is a test message!");
|
||||||
|
obj.put("noAdminWorldBlockPlace", "&cYou are not allowed to place blocks in the admin world!");
|
||||||
|
obj.put("noAdminWorldBlockBreak", "&cYou are not allowed to break blocks in the admin world!");
|
||||||
|
FileWriter writer = new FileWriter(messages);
|
||||||
|
writer.append(obj.toString(4));
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
PlexLog.log("Generating messages.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage(String s)
|
||||||
|
{
|
||||||
|
if (!messages.exists())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileInputStream stream = new FileInputStream(messages);
|
||||||
|
JSONTokener tokener = new JSONTokener(stream);
|
||||||
|
JSONObject object = new JSONObject(tokener);
|
||||||
|
return (String) object.get(s);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -4,12 +4,15 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import me.totalfreedom.plex.Plex;
|
import me.totalfreedom.plex.Plex;
|
||||||
import me.totalfreedom.plex.storage.StorageType;
|
import me.totalfreedom.plex.storage.StorageType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.PluginCommandYamlParser;
|
import org.bukkit.command.PluginCommandYamlParser;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class PlexUtils
|
public class PlexUtils
|
||||||
@ -60,4 +63,13 @@ public class PlexUtils
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String color(String s)
|
||||||
|
{
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warpToWorld(Player player, World world)
|
||||||
|
{
|
||||||
|
player.teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0), 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package me.totalfreedom.plex.world;
|
||||||
|
|
||||||
|
import me.totalfreedom.plex.Plex;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConfigurationChunkGenerator extends FlatChunkGenerator
|
||||||
|
{
|
||||||
|
private static Plex plugin = Plex.get();
|
||||||
|
|
||||||
|
private final String worldName;
|
||||||
|
|
||||||
|
public ConfigurationChunkGenerator(String worldName, BlockPopulator... populators)
|
||||||
|
{
|
||||||
|
super(0, populators);
|
||||||
|
this.worldName = worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createLoopChunkData(int x, int y, int z, ChunkData chunk)
|
||||||
|
{
|
||||||
|
int height = -1;
|
||||||
|
Map<Material, Integer> blocks = new LinkedHashMap<>();
|
||||||
|
for (String key : plugin.config.getConfigurationSection("worlds." + worldName + ".parameters").getKeys(false))
|
||||||
|
{
|
||||||
|
Material material = Material.getMaterial(key.toUpperCase());
|
||||||
|
if (material == null) continue;
|
||||||
|
int count = plugin.config.getInt("worlds." + worldName + ".parameters." + key);
|
||||||
|
height += count;
|
||||||
|
blocks.put(material, count);
|
||||||
|
}
|
||||||
|
for (Map.Entry<Material, Integer> entry : blocks.entrySet())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < entry.getValue(); i++, height--)
|
||||||
|
chunk.setBlock(x, height, z, entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,24 @@
|
|||||||
package me.totalfreedom.plex.world;
|
package me.totalfreedom.plex.world;
|
||||||
|
|
||||||
|
import me.totalfreedom.plex.Plex;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CustomWorld extends WorldCreator
|
public class CustomWorld extends WorldCreator
|
||||||
{
|
{
|
||||||
|
private static Plex plugin = Plex.get();
|
||||||
|
|
||||||
private final CustomChunkGenerator chunks;
|
private final CustomChunkGenerator chunks;
|
||||||
|
|
||||||
public CustomWorld(String name, CustomChunkGenerator generator)
|
private CustomWorld(String name, CustomChunkGenerator generator)
|
||||||
{
|
{
|
||||||
super(name);
|
super(name);
|
||||||
this.chunks = generator;
|
this.chunks = generator;
|
||||||
@ -25,4 +35,34 @@ public class CustomWorld extends WorldCreator
|
|||||||
{
|
{
|
||||||
return this.createWorld();
|
return this.createWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static World generateConfigFlatWorld(String name)
|
||||||
|
{
|
||||||
|
if (!plugin.config.contains("worlds." + name))
|
||||||
|
return null;
|
||||||
|
CustomWorld customWorld = new CustomWorld(name, new ConfigurationChunkGenerator(name))
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public World generate()
|
||||||
|
{
|
||||||
|
boolean addFeatures = Bukkit.getWorld(name) == null;
|
||||||
|
World world = super.generate();
|
||||||
|
if (addFeatures)
|
||||||
|
{
|
||||||
|
Block block = world.getBlockAt(0, world.getHighestBlockYAt(0, 0) + 1, 0);
|
||||||
|
block.setType(Material.OAK_SIGN);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Sign)
|
||||||
|
{
|
||||||
|
Sign sign = (Sign) state;
|
||||||
|
sign.setLine(1, Objects.requireNonNull(plugin.config.getString("worlds." + name + ".name")));
|
||||||
|
sign.setLine(2, "- 0, 0 -");
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return customWorld.generate();
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,17 +2,13 @@ package me.totalfreedom.plex.world;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class NoiseOptions
|
public class NoiseOptions
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private final int x;
|
private final int x;
|
||||||
@Getter
|
|
||||||
private final int y;
|
private final int y;
|
||||||
@Getter
|
|
||||||
private final double frequency;
|
private final double frequency;
|
||||||
@Getter
|
|
||||||
private final double amplitude;
|
private final double amplitude;
|
||||||
@Getter
|
|
||||||
private final boolean normalized;
|
private final boolean normalized;
|
||||||
|
|
||||||
public NoiseOptions(int x, int y, double frequency, double amplitude, boolean normalized)
|
public NoiseOptions(int x, int y, double frequency, double amplitude, boolean normalized)
|
||||||
|
@ -2,9 +2,9 @@ package me.totalfreedom.plex.world;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class OctaveOptions extends NoiseOptions
|
public class OctaveOptions extends NoiseOptions
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private final int octaves;
|
private final int octaves;
|
||||||
|
|
||||||
public OctaveOptions(int x, int y, double frequency, double amplitude, boolean normalized, int octaves)
|
public OctaveOptions(int x, int y, double frequency, double amplitude, boolean normalized, int octaves)
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
package me.totalfreedom.plex.world.impl;
|
|
||||||
|
|
||||||
import me.totalfreedom.plex.Plex;
|
|
||||||
import me.totalfreedom.plex.world.CustomWorld;
|
|
||||||
import me.totalfreedom.plex.world.FlatChunkGenerator;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.generator.BlockPopulator;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class Flatlands extends CustomWorld
|
|
||||||
{
|
|
||||||
private static Plex plugin = Plex.get();
|
|
||||||
|
|
||||||
public Flatlands()
|
|
||||||
{
|
|
||||||
super("flatlands", new FlatlandsChunkGenerator());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public World generate()
|
|
||||||
{
|
|
||||||
World world = super.generate();
|
|
||||||
Block block = world.getBlockAt(0, 51, 0);
|
|
||||||
block.setType(Material.OAK_SIGN);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Sign)
|
|
||||||
{
|
|
||||||
Sign sign = (Sign) state;
|
|
||||||
sign.setLine(1, "Flatlands");
|
|
||||||
sign.setLine(2, "- 0, 0 -");
|
|
||||||
sign.update();
|
|
||||||
}
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FlatlandsChunkGenerator extends FlatChunkGenerator
|
|
||||||
{
|
|
||||||
public FlatlandsChunkGenerator()
|
|
||||||
{
|
|
||||||
super(50, new FlatlandsBlockPopulator());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createLoopChunkData(int x, int y, int z, ChunkData chunk)
|
|
||||||
{
|
|
||||||
int height = this.height;
|
|
||||||
for (String key : plugin.config.getConfigurationSection("server.flatlands.parameters").getKeys(false))
|
|
||||||
{
|
|
||||||
Material material = Material.getMaterial(key.toUpperCase());
|
|
||||||
if (material == null) continue;
|
|
||||||
int count = plugin.config.getInt("server.flatlands.parameters." + key);
|
|
||||||
for (int i = 0; i < count; i++, height--)
|
|
||||||
chunk.setBlock(x, height, z, material);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FlatlandsBlockPopulator extends BlockPopulator
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void populate(World world, Random random, Chunk chunk)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,14 +3,6 @@
|
|||||||
server:
|
server:
|
||||||
test: "test string"
|
test: "test string"
|
||||||
|
|
||||||
flatlands:
|
|
||||||
generate: true
|
|
||||||
parameters:
|
|
||||||
grass_block: 1
|
|
||||||
dirt: 32
|
|
||||||
stone: 16
|
|
||||||
bedrock: 1
|
|
||||||
|
|
||||||
data:
|
data:
|
||||||
central:
|
central:
|
||||||
storage: sqlite # use mariadb, mongodb, or sqlite here
|
storage: sqlite # use mariadb, mongodb, or sqlite here
|
||||||
@ -23,4 +15,27 @@ data:
|
|||||||
auth: true
|
auth: true
|
||||||
hostname: 127.0.0.1
|
hostname: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
password: ""
|
password: ""
|
||||||
|
|
||||||
|
worlds:
|
||||||
|
flatlands:
|
||||||
|
name: "Flatlands"
|
||||||
|
parameters:
|
||||||
|
grass_block: 1
|
||||||
|
dirt: 32
|
||||||
|
stone: 16
|
||||||
|
bedrock: 1
|
||||||
|
adminworld:
|
||||||
|
name: "Admin World"
|
||||||
|
parameters:
|
||||||
|
grass_block: 1
|
||||||
|
dirt: 32
|
||||||
|
stone: 16
|
||||||
|
bedrock: 1
|
||||||
|
masterbuilderworld:
|
||||||
|
name: "MB World"
|
||||||
|
parameters:
|
||||||
|
grass_block: 1
|
||||||
|
dirt: 32
|
||||||
|
stone: 16
|
||||||
|
bedrock: 1
|
Loading…
Reference in New Issue
Block a user