Tweak some stuff and implement cobblegens.
This commit is contained in:
parent
fb50af566a
commit
b7f5b15534
|
|
@ -4,9 +4,9 @@ import com.alttd.cometskyblock.commands.challenges.ChallengeCommand;
|
||||||
import com.alttd.cometskyblock.commands.island.IslandCommand;
|
import com.alttd.cometskyblock.commands.island.IslandCommand;
|
||||||
import com.alttd.cometskyblock.configuration.*;
|
import com.alttd.cometskyblock.configuration.*;
|
||||||
import com.alttd.cometskyblock.listeners.BedListener;
|
import com.alttd.cometskyblock.listeners.BedListener;
|
||||||
|
import com.alttd.cometskyblock.listeners.CobbestoneGeneratorListener;
|
||||||
import com.alttd.cometskyblock.listeners.PlayerJoinListener;
|
import com.alttd.cometskyblock.listeners.PlayerJoinListener;
|
||||||
import com.alttd.cometskyblock.managers.IslandManager;
|
import com.alttd.cometskyblock.managers.IslandManager;
|
||||||
import com.alttd.cometskyblock.managers.PlayerManager;
|
|
||||||
import com.alttd.cometskyblock.worldgenerator.MasterWorldGenerator;
|
import com.alttd.cometskyblock.worldgenerator.MasterWorldGenerator;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
@ -23,9 +23,9 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
@Getter private ConfigurationContainer<DatabaseConfiguration> databaseConfiguration;
|
@Getter private ConfigurationContainer<DatabaseConfiguration> databaseConfiguration;
|
||||||
@Getter private ConfigurationContainer<MessageConfiguration> messagesConfiguration;
|
@Getter private ConfigurationContainer<MessageConfiguration> messagesConfiguration;
|
||||||
@Getter private ConfigurationContainer<ChallengesConfiguration> challengesConfiguration;
|
@Getter private ConfigurationContainer<ChallengesConfiguration> challengesConfiguration;
|
||||||
|
@Getter private ConfigurationContainer<CobblestoneGeneratorConfiguration> cobblestoneGeneratorConfiguration;
|
||||||
|
|
||||||
@Getter private IslandManager islandManager;
|
@Getter private IslandManager islandManager;
|
||||||
@Getter private PlayerManager playerManager;
|
|
||||||
@Getter private MasterWorldGenerator worldGenerator;
|
@Getter private MasterWorldGenerator worldGenerator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -52,7 +52,6 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
|
|
||||||
// load worlds & manager
|
// load worlds & manager
|
||||||
islandManager = new IslandManager(this);
|
islandManager = new IslandManager(this);
|
||||||
playerManager = new PlayerManager(this);
|
|
||||||
worldGenerator = new MasterWorldGenerator(this);
|
worldGenerator = new MasterWorldGenerator(this);
|
||||||
|
|
||||||
worldGenerator.checkMasterIslandWorld();
|
worldGenerator.checkMasterIslandWorld();
|
||||||
|
|
@ -73,6 +72,7 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
databaseConfiguration = ConfigurationContainer.load(logger, path, DatabaseConfiguration.class, "database");
|
databaseConfiguration = ConfigurationContainer.load(logger, path, DatabaseConfiguration.class, "database");
|
||||||
messagesConfiguration = ConfigurationContainer.load(logger, path, MessageConfiguration.class, "messages");
|
messagesConfiguration = ConfigurationContainer.load(logger, path, MessageConfiguration.class, "messages");
|
||||||
challengesConfiguration = ConfigurationContainer.load(logger, path, ChallengesConfiguration.class, "challenges");
|
challengesConfiguration = ConfigurationContainer.load(logger, path, ChallengesConfiguration.class, "challenges");
|
||||||
|
cobblestoneGeneratorConfiguration = ConfigurationContainer.load(logger, path, CobblestoneGeneratorConfiguration.class, "coblestonegenerator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadCommands() {
|
public void loadCommands() {
|
||||||
|
|
@ -86,6 +86,7 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
final PluginManager pm = getServer().getPluginManager();
|
final PluginManager pm = getServer().getPluginManager();
|
||||||
pm.registerEvents(new PlayerJoinListener(this), this);
|
pm.registerEvents(new PlayerJoinListener(this), this);
|
||||||
pm.registerEvents(new BedListener(this), this);
|
pm.registerEvents(new BedListener(this), this);
|
||||||
|
pm.registerEvents(new CobbestoneGeneratorListener(this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@ import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
||||||
import com.alttd.cometskyblock.island.Island;
|
import com.alttd.cometskyblock.island.Island;
|
||||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleport to your island & create an island if you do not have one yet
|
* Teleport to your island & create an island if you do not have one yet
|
||||||
|
|
@ -47,7 +49,7 @@ public class IslandGo extends PlayerSubCommand {
|
||||||
id = plugin.islandManager().getLastID();
|
id = plugin.islandManager().getLastID();
|
||||||
plugin.getLogger().warning("Caught a NumberFormatException while generating island for player " + player.getUniqueId());
|
plugin.getLogger().warning("Caught a NumberFormatException while generating island for player " + player.getUniqueId());
|
||||||
}
|
}
|
||||||
// TODO - builder patterns?
|
// TODO - refactor plugin to use IslandCreator to create/recreate islands
|
||||||
Island island = Island.getIsland(world.getUID());
|
Island island = Island.getIsland(world.getUID());
|
||||||
island.owner(player.getUniqueId());
|
island.owner(player.getUniqueId());
|
||||||
island.worldName(world.getName());
|
island.worldName(world.getName());
|
||||||
|
|
@ -55,6 +57,16 @@ public class IslandGo extends PlayerSubCommand {
|
||||||
islandPlayer.islandOwner(true);
|
islandPlayer.islandOwner(true);
|
||||||
islandPlayer.islandUUID(island.islandUUID());
|
islandPlayer.islandUUID(island.islandUUID());
|
||||||
islandPlayer.islandId(id);
|
islandPlayer.islandId(id);
|
||||||
|
player.getEnderChest().clear();
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.setTotalExperience(0);
|
||||||
|
player.setExp(0);
|
||||||
|
player.setFoodLevel(20);
|
||||||
|
player.setSaturation(20);
|
||||||
|
player.getInventory().addItem(
|
||||||
|
new ItemStack(Material.LAVA_BUCKET),
|
||||||
|
new ItemStack(Material.WATER_BUCKET)
|
||||||
|
);
|
||||||
player.teleportAsync(world.getSpawnLocation());
|
player.teleportAsync(world.getSpawnLocation());
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,28 @@ package com.alttd.cometskyblock.commands.island;
|
||||||
|
|
||||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
||||||
|
import com.alttd.cometskyblock.commands.SubCommand;
|
||||||
import com.alttd.cometskyblock.configuration.MessageConfiguration;
|
import com.alttd.cometskyblock.configuration.MessageConfiguration;
|
||||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class IslandRestart extends PlayerSubCommand {
|
public class IslandRestart extends PlayerSubCommand {
|
||||||
|
|
||||||
public IslandRestart(CometSkyBlockPlugin plugin) {
|
public IslandRestart(CometSkyBlockPlugin plugin) {
|
||||||
super(plugin, "restart");
|
super(plugin, "restart");
|
||||||
|
registerSubCommand(new IslandRestartConfirm(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO -- IslandRestartCommand, add a one day delay on trying to reset again!
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||||
|
if (!islandPlayer.islandOwner()) {
|
||||||
|
// You must be the islandOwner to do this command.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// create new Island request and wait for x time to do /island restart confirm
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.alttd.cometskyblock.commands.island;
|
||||||
|
|
||||||
|
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
|
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
||||||
|
import com.alttd.cometskyblock.island.Island;
|
||||||
|
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class IslandRestartConfirm extends PlayerSubCommand {
|
||||||
|
|
||||||
|
public IslandRestartConfirm(CometSkyBlockPlugin plugin) {
|
||||||
|
super(plugin, "restart");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO -- IslandRestartCommand, add a one day delay on trying to reset again!
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||||
|
if (!islandPlayer.islandOwner()) {
|
||||||
|
// You must be the islandOwner to do this command.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// check if they have an island request, if not run create request code and ask to rerun command
|
||||||
|
|
||||||
|
// Teleport everyone on the island to spawnworld
|
||||||
|
Island island = Island.getIsland(islandPlayer.islandUUID());
|
||||||
|
if (island == null) {
|
||||||
|
// could not load island
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
World islandWorld = plugin.worldGenerator().loadIslandWorld(island.worldName());
|
||||||
|
if (islandWorld == null) {
|
||||||
|
// could not load world
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
Location spawnLocation = world.getSpawnLocation();
|
||||||
|
for (Player target : islandWorld.getPlayers()) {
|
||||||
|
target.teleport(spawnLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// teleport owner to the new island and give new starter gear
|
||||||
|
|
||||||
|
// send message to all online members that a new island has been created
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.alttd.cometskyblock.commands.island;
|
||||||
|
|
||||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
||||||
|
import com.alttd.cometskyblock.configuration.MessageConfiguration;
|
||||||
import com.alttd.cometskyblock.island.Island;
|
import com.alttd.cometskyblock.island.Island;
|
||||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -18,8 +19,9 @@ public class IslandVisit extends PlayerSubCommand {
|
||||||
// TODO -- finish IslandVisitCommand and Request
|
// TODO -- finish IslandVisitCommand and Request
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||||
|
MessageConfiguration.Commands.Island.Visit visit = plugin.messagesConfiguration().get().commands().island().visit();
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
// send usage
|
player.sendRichMessage(plugin.messagesConfiguration().get().commands().island().commandUsage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
package com.alttd.cometskyblock.island;
|
|
||||||
|
|
||||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
|
||||||
import com.alttd.cometskyblock.configuration.CobblestoneGeneratorConfiguration;
|
|
||||||
import com.alttd.cometskyblock.configuration.ConfigurationContainer;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class CobblestoneGenerator {
|
|
||||||
|
|
||||||
private ConfigurationContainer<CobblestoneGeneratorConfiguration> cobblestoneGeneratorConfiguration;
|
|
||||||
|
|
||||||
public CobblestoneGenerator(CometSkyBlockPlugin plugin) {
|
|
||||||
cobblestoneGeneratorConfiguration = ConfigurationContainer.load(plugin.getSLF4JLogger(), plugin.getDataFolder().toPath(), CobblestoneGeneratorConfiguration.class, "coblestonegenerator");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -150,4 +150,13 @@ public class Island extends YamlConfiguration {
|
||||||
public boolean visitNeedsRequest() {
|
public boolean visitNeedsRequest() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int cobblegenLevel() {
|
||||||
|
return getInt("island.generator.level", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cobblegenLevel(int id) {
|
||||||
|
set("island.generator.level", id);
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.alttd.cometskyblock.listeners;
|
||||||
|
|
||||||
|
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
|
import com.alttd.cometskyblock.island.CobblestoneGeneratorLevel;
|
||||||
|
import com.alttd.cometskyblock.island.Island;
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockFormEvent;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class CobbestoneGeneratorListener implements Listener {
|
||||||
|
|
||||||
|
private final CometSkyBlockPlugin plugin;
|
||||||
|
public static Cache<Location, Long> generatorCache = CacheBuilder.newBuilder()
|
||||||
|
.maximumSize(1000)
|
||||||
|
.expireAfterAccess(10, TimeUnit.MINUTES)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public CobbestoneGeneratorListener(CometSkyBlockPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void cobblestoneGeneratorForm(BlockFormEvent blockFormEvent) {
|
||||||
|
Block block = blockFormEvent.getNewState().getBlock();
|
||||||
|
Material newmaterial = blockFormEvent.getNewState().getType();
|
||||||
|
Location location = blockFormEvent.getNewState().getLocation();
|
||||||
|
if (newmaterial.equals(Material.COBBLESTONE)) {
|
||||||
|
Island island = Island.getIsland(block.getWorld().getUID());
|
||||||
|
if (island.worldName() == null || island.worldName().isEmpty()) // Worlds not generated by us will have this as null or empty
|
||||||
|
return;
|
||||||
|
|
||||||
|
blockFormEvent.getNewState().setType(rollGenerator(island.cobblegenLevel(), location));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// @EventHandler
|
||||||
|
// public void cobblestoneGeneratorDrops(BlockBreakEvent event) {
|
||||||
|
// // TODO - multiply drops from cobble gen?
|
||||||
|
// Block block = event.getBlock();
|
||||||
|
// if (block.getType().equals(Material.COBBLESTONE)) {
|
||||||
|
// if (relativeEqualsMaterial(block, Material.LAVA)) { // any other way to detect if they are from cobble gen
|
||||||
|
// // set some data during blockform event?
|
||||||
|
// if (relativeEqualsMaterial(block, Material.WATER)) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
private Material rollGenerator(int generatorLevel, Location location) {
|
||||||
|
double random = Math.random() * 100;
|
||||||
|
double checkedChance = 0;
|
||||||
|
|
||||||
|
for (CobblestoneGeneratorLevel cobblestoneGeneratorLevel : plugin.cobblestoneGeneratorConfiguration().get().levels()) {
|
||||||
|
if (cobblestoneGeneratorLevel.level() <= generatorLevel) {
|
||||||
|
checkedChance += cobblestoneGeneratorLevel.chance();
|
||||||
|
if (checkedChance > random) {
|
||||||
|
return cobblestoneGeneratorLevel.type();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Material.COBBLESTONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer getRequiredIslandLevel(int generatorLevel) {
|
||||||
|
CobblestoneGeneratorLevel level = getLevel(generatorLevel);
|
||||||
|
return level != null ? level.islandLevel() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CobblestoneGeneratorLevel getLevel(int generatorLevel) {
|
||||||
|
if (generatorLevel == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (plugin.cobblestoneGeneratorConfiguration().get().levels().size() < generatorLevel) {
|
||||||
|
return getLevel(generatorLevel - 1);
|
||||||
|
}
|
||||||
|
for (CobblestoneGeneratorLevel level : plugin.cobblestoneGeneratorConfiguration().get().levels()) {
|
||||||
|
if (level.level() == generatorLevel) {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean relativeEqualsMaterial(Block block, Material material) {
|
||||||
|
return block.getRelative(BlockFace.NORTH).getType().equals(material)
|
||||||
|
|| block.getRelative(BlockFace.EAST).getType().equals(material)
|
||||||
|
|| block.getRelative(BlockFace.SOUTH).getType().equals(material)
|
||||||
|
|| block.getRelative(BlockFace.WEST).getType().equals(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.alttd.cometskyblock.managers;
|
||||||
|
|
||||||
|
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
// TODO - refactor plugin to use IslandCreator to create/recreate islands
|
||||||
|
public class IslandCreator {
|
||||||
|
|
||||||
|
private final CometSkyBlockPlugin plugin;
|
||||||
|
private final UUID playerUUID;
|
||||||
|
|
||||||
|
private String oldIsland = null; // used during island restart
|
||||||
|
|
||||||
|
public IslandCreator(CometSkyBlockPlugin plugin, UUID playerId) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.playerUUID = playerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IslandCreator oldIsland(String oldIsland) {
|
||||||
|
this.oldIsland = oldIsland;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isNumber(String input) {
|
||||||
|
try {
|
||||||
|
Integer.parseInt(input);
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNewIsland() {
|
||||||
|
final int id = plugin.islandManager().getNextId();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,9 +4,6 @@ import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||||
import com.alttd.cometskyblock.configuration.ConfigurationContainer;
|
import com.alttd.cometskyblock.configuration.ConfigurationContainer;
|
||||||
import com.alttd.cometskyblock.configuration.IslandConfiguration;
|
import com.alttd.cometskyblock.configuration.IslandConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class IslandManager {
|
public class IslandManager {
|
||||||
|
|
||||||
private final CometSkyBlockPlugin plugin;
|
private final CometSkyBlockPlugin plugin;
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
package com.alttd.cometskyblock.managers;
|
|
||||||
|
|
||||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
|
||||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class PlayerManager {
|
|
||||||
|
|
||||||
private final CometSkyBlockPlugin plugin;
|
|
||||||
protected final Map<UUID, IslandPlayer> islandPlayers = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
public PlayerManager(CometSkyBlockPlugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addIslandPlayer(UUID uuid, IslandPlayer islandPlayer) {
|
|
||||||
islandPlayers.putIfAbsent(uuid, islandPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void removeIslandPlayer(UUID uuid) {
|
|
||||||
islandPlayers.remove(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -5,9 +5,11 @@ import com.alttd.cometskyblock.util.WeightedChoice;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.LimitedRegion;
|
import org.bukkit.generator.LimitedRegion;
|
||||||
import org.bukkit.generator.WorldInfo;
|
import org.bukkit.generator.WorldInfo;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
@ -17,11 +19,9 @@ public class IslandGenerator extends BlockPopulator {
|
||||||
private final WeightedChoice<Material> stones = new WeightedChoice<Material>().add(60, Material.STONE).add(10, Material.ANDESITE).add(10, Material.DIORITE).add(10, Material.GRANITE).add(10, Material.COAL_ORE);
|
private final WeightedChoice<Material> stones = new WeightedChoice<Material>().add(60, Material.STONE).add(10, Material.ANDESITE).add(10, Material.DIORITE).add(10, Material.GRANITE).add(10, Material.COAL_ORE);
|
||||||
private final WeightedChoice<Material> dirts = new WeightedChoice<Material>().add(80, Material.DIRT).add(20, Material.COARSE_DIRT);
|
private final WeightedChoice<Material> dirts = new WeightedChoice<Material>().add(80, Material.DIRT).add(20, Material.COARSE_DIRT);
|
||||||
private final WeightedChoice<Material> flora = new WeightedChoice<Material>().add(70, Material.SHORT_GRASS).add(10, Material.RED_TULIP).add(10, Material.OXEYE_DAISY).add(10, Material.CORNFLOWER);
|
private final WeightedChoice<Material> flora = new WeightedChoice<Material>().add(70, Material.SHORT_GRASS).add(10, Material.RED_TULIP).add(10, Material.OXEYE_DAISY).add(10, Material.CORNFLOWER);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull LimitedRegion limitedRegion) {
|
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull LimitedRegion limitedRegion) {
|
||||||
// Always generate an island at 0 0 and add spread some random in the world
|
if ((x == 0 && z == 0)/* || random.nextInt(10000) < 1*/) {
|
||||||
if ((x == 0 && z == 0) || random.nextInt(10000) < 1) {
|
|
||||||
// set starting values
|
// set starting values
|
||||||
int startY = 63;
|
int startY = 63;
|
||||||
int startX = x * 16;
|
int startX = x * 16;
|
||||||
|
|
@ -68,6 +68,7 @@ public class IslandGenerator extends BlockPopulator {
|
||||||
if (!limitedRegion.generateTree(location, random, TreeType.TREE)) {
|
if (!limitedRegion.generateTree(location, random, TreeType.TREE)) {
|
||||||
limitedRegion.setType(startX + treeX, startY, startX + treeZ, Material.OAK_SAPLING);
|
limitedRegion.setType(startX + treeX, startY, startX + treeZ, Material.OAK_SAPLING);
|
||||||
}
|
}
|
||||||
|
// TODO - add barrel with loottable for starter gear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user