mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2025-01-26 18:11:42 +01:00
Merge remote-tracking branch 'origin/gamemode' into develop
Uses new GameModeAddon API
This commit is contained in:
commit
d728c2ebe0
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>world.bentobox</groupId>
|
<groupId>world.bentobox</groupId>
|
||||||
<artifactId>AcidIsland</artifactId>
|
<artifactId>AcidIsland</artifactId>
|
||||||
<version>0.5.1-SNAPSHOT</version>
|
<version>0.6.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>AcidIsland</name>
|
<name>AcidIsland</name>
|
||||||
<description>AcidIsland is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description>
|
<description>AcidIsland is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description>
|
||||||
@ -91,7 +91,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>world.bentobox</groupId>
|
<groupId>world.bentobox</groupId>
|
||||||
<artifactId>bentobox</artifactId>
|
<artifactId>bentobox</artifactId>
|
||||||
<version>0.18.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,37 +1,41 @@
|
|||||||
package world.bentobox.acidisland;
|
package world.bentobox.acidisland;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.WorldType;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import world.bentobox.acidisland.commands.AcidCommand;
|
import world.bentobox.acidisland.commands.AcidCommand;
|
||||||
import world.bentobox.acidisland.commands.AiCommand;
|
import world.bentobox.acidisland.commands.AiCommand;
|
||||||
import world.bentobox.acidisland.listeners.AcidEffect;
|
import world.bentobox.acidisland.listeners.AcidEffect;
|
||||||
import world.bentobox.acidisland.listeners.LavaCheck;
|
import world.bentobox.acidisland.listeners.LavaCheck;
|
||||||
import world.bentobox.acidisland.world.AcidIslandWorld;
|
|
||||||
import world.bentobox.acidisland.world.AcidTask;
|
import world.bentobox.acidisland.world.AcidTask;
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.acidisland.world.ChunkGeneratorWorld;
|
||||||
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
import world.bentobox.bentobox.api.configuration.Config;
|
import world.bentobox.bentobox.api.configuration.Config;
|
||||||
|
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add-on to BentoBox that enables AcidIsland
|
* Add-on to BentoBox that enables AcidIsland
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AcidIsland extends Addon {
|
public class AcidIsland extends GameModeAddon {
|
||||||
|
|
||||||
private static AcidIsland addon;
|
private static AcidIsland addon;
|
||||||
private AISettings settings;
|
private AISettings settings;
|
||||||
private AcidIslandWorld aiw;
|
|
||||||
private AcidTask acidTask;
|
private AcidTask acidTask;
|
||||||
|
|
||||||
|
private static final String NETHER = "_nether";
|
||||||
|
private static final String THE_END = "_the_end";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
addon = this;
|
addon = this;
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
// Load settings
|
// Load settings
|
||||||
settings = new Config<>(this, AISettings.class).loadConfigObject();
|
settings = new Config<>(this, AISettings.class).loadConfigObject();
|
||||||
// Create worlds
|
|
||||||
aiw = new AcidIslandWorld(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,21 +65,6 @@ public class AcidIsland extends Addon {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the aiw
|
|
||||||
*/
|
|
||||||
public AcidIslandWorld getAiw() {
|
|
||||||
return aiw;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method to obtain the AcidIsland overworld
|
|
||||||
* @return Island World
|
|
||||||
*/
|
|
||||||
public World getIslandWorld() {
|
|
||||||
return aiw.getOverWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String string) {
|
public void log(String string) {
|
||||||
getPlugin().log(string);
|
getPlugin().log(string);
|
||||||
@ -85,4 +74,45 @@ public class AcidIsland extends Addon {
|
|||||||
return addon;
|
return addon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createWorlds() {
|
||||||
|
String worldName = settings.getWorldName();
|
||||||
|
if (getServer().getWorld(worldName) == null) {
|
||||||
|
getLogger().info("Creating AcidIsland...");
|
||||||
|
}
|
||||||
|
// Create the world if it does not exist
|
||||||
|
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(addon))
|
||||||
|
.createWorld();
|
||||||
|
|
||||||
|
// Make the nether if it does not exist
|
||||||
|
if (settings.isNetherGenerate()) {
|
||||||
|
if (getServer().getWorld(worldName + NETHER) == null) {
|
||||||
|
log("Creating AcidIsland's Nether...");
|
||||||
|
}
|
||||||
|
if (!settings.isNetherIslands()) {
|
||||||
|
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
|
||||||
|
} else {
|
||||||
|
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(addon))
|
||||||
|
.environment(World.Environment.NETHER).createWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Make the end if it does not exist
|
||||||
|
if (settings.isEndGenerate()) {
|
||||||
|
if (getServer().getWorld(worldName + THE_END) == null) {
|
||||||
|
log("Creating AcidIsland's End World...");
|
||||||
|
}
|
||||||
|
if (!settings.isEndIslands()) {
|
||||||
|
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
|
||||||
|
} else {
|
||||||
|
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(addon))
|
||||||
|
.environment(World.Environment.THE_END).createWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorldSettings getWorldSettings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package world.bentobox.acidisland.commands;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import world.bentobox.acidisland.AcidIsland;
|
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.commands.admin.AdminClearresetsCommand;
|
import world.bentobox.bentobox.api.commands.admin.AdminClearresetsCommand;
|
||||||
@ -37,7 +36,6 @@ public class AcidCommand extends CompositeCommand {
|
|||||||
setOnlyPlayer(false);
|
setOnlyPlayer(false);
|
||||||
setParametersHelp("commands.admin.help.parameters");
|
setParametersHelp("commands.admin.help.parameters");
|
||||||
setDescription("commands.admin.help.description");
|
setDescription("commands.admin.help.description");
|
||||||
setWorld(((AcidIsland)getAddon()).getIslandWorld());
|
|
||||||
new AdminVersionCommand(this);
|
new AdminVersionCommand(this);
|
||||||
new AdminTeleportCommand(this, "tp");
|
new AdminTeleportCommand(this, "tp");
|
||||||
new AdminTeleportCommand(this, "tpnether");
|
new AdminTeleportCommand(this, "tpnether");
|
||||||
|
@ -3,7 +3,6 @@ package world.bentobox.acidisland.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import world.bentobox.acidisland.AcidIsland;
|
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.commands.island.IslandBanCommand;
|
import world.bentobox.bentobox.api.commands.island.IslandBanCommand;
|
||||||
@ -40,8 +39,6 @@ public class AiCommand extends CompositeCommand {
|
|||||||
setOnlyPlayer(true);
|
setOnlyPlayer(true);
|
||||||
// Permission
|
// Permission
|
||||||
setPermission("island");
|
setPermission("island");
|
||||||
// Set up world
|
|
||||||
setWorld(((AcidIsland)getAddon()).getIslandWorld());
|
|
||||||
// Set up subcommands
|
// Set up subcommands
|
||||||
new IslandAboutCommand(this);
|
new IslandAboutCommand(this);
|
||||||
new IslandInfoCommand(this);
|
new IslandInfoCommand(this);
|
||||||
|
@ -67,7 +67,7 @@ public class AcidEffect implements Listener {
|
|||||||
public void onSeaBounce(PlayerMoveEvent e) {
|
public void onSeaBounce(PlayerMoveEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)
|
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)
|
||||||
&& player.getWorld().equals(addon.getIslandWorld()) && player.getLocation().getBlockY() < 1) {
|
&& player.getWorld().equals(addon.getOverWorld()) && player.getLocation().getBlockY() < 1) {
|
||||||
player.setVelocity(new Vector(player.getVelocity().getX(), 1D, player.getVelocity().getZ()));
|
player.setVelocity(new Vector(player.getVelocity().getX(), 1D, player.getVelocity().getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ public class AcidEffect implements Listener {
|
|||||||
|| player.getGameMode().equals(GameMode.CREATIVE)
|
|| player.getGameMode().equals(GameMode.CREATIVE)
|
||||||
|| player.getGameMode().equals(GameMode.SPECTATOR)
|
|| player.getGameMode().equals(GameMode.SPECTATOR)
|
||||||
|| addon.getPlayers().isInTeleport(player.getUniqueId())
|
|| addon.getPlayers().isInTeleport(player.getUniqueId())
|
||||||
|| !Util.sameWorld(addon.getIslandWorld(), player.getWorld())
|
|| !Util.sameWorld(addon.getOverWorld(), player.getWorld())
|
||||||
|| (!player.isOp() && player.hasPermission("acidisland.mod.noburn"))
|
|| (!player.isOp() && player.hasPermission("acidisland.mod.noburn"))
|
||||||
|| (!player.isOp() && player.hasPermission("admin.noburn"))
|
|| (!player.isOp() && player.hasPermission("admin.noburn"))
|
||||||
|| (player.isOp() && !addon.getSettings().isAcidDamageOp())) {
|
|| (player.isOp() && !addon.getSettings().isAcidDamageOp())) {
|
||||||
@ -349,7 +349,7 @@ public class AcidEffect implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onWeatherChange(final WeatherChangeEvent e) {
|
public void onWeatherChange(final WeatherChangeEvent e) {
|
||||||
if (e.getWorld().equals(addon.getIslandWorld())) {
|
if (e.getWorld().equals(addon.getOverWorld())) {
|
||||||
this.isRaining = e.toWeatherState();
|
this.isRaining = e.toWeatherState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class LavaCheck implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onCleanstoneGen(BlockFromToEvent e) {
|
public void onCleanstoneGen(BlockFromToEvent e) {
|
||||||
// Only do this in AcidIsland over world
|
// Only do this in AcidIsland over world
|
||||||
if (!e.getBlock().getWorld().equals(addon.getIslandWorld()) || addon.getSettings().getAcidDamage() <= 0
|
if (!e.getBlock().getWorld().equals(addon.getOverWorld()) || addon.getSettings().getAcidDamage() <= 0
|
||||||
// TODO: backward compatibility hack
|
// TODO: backward compatibility hack
|
||||||
|| !(e.getToBlock().getType().name().equals("WATER"))) {
|
|| !(e.getToBlock().getType().name().equals("WATER"))) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
package world.bentobox.acidisland.world;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.WorldType;
|
|
||||||
|
|
||||||
import world.bentobox.acidisland.AcidIsland;
|
|
||||||
import world.bentobox.bentobox.util.Util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the AI worlds and registers them with BSkyBlock
|
|
||||||
* @author tastybento
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class AcidIslandWorld {
|
|
||||||
|
|
||||||
private static final String NETHER = "_nether";
|
|
||||||
private static final String THE_END = "_the_end";
|
|
||||||
private World islandWorld;
|
|
||||||
private World netherWorld;
|
|
||||||
private World endWorld;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a register worlds with BSkyBlock
|
|
||||||
* @param addon - addon
|
|
||||||
*/
|
|
||||||
public AcidIslandWorld(AcidIsland addon) {
|
|
||||||
String worldName = addon.getSettings().getWorldName();
|
|
||||||
if (addon.getServer().getWorld(worldName) == null) {
|
|
||||||
addon.getLogger().info("Creating AcidIsland...");
|
|
||||||
}
|
|
||||||
// Create the world if it does not exist
|
|
||||||
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(addon))
|
|
||||||
.createWorld();
|
|
||||||
addon.getPlugin().registerWorld(islandWorld, addon.getSettings());
|
|
||||||
|
|
||||||
// Make the nether if it does not exist
|
|
||||||
if (addon.getSettings().isNetherGenerate()) {
|
|
||||||
if (addon.getServer().getWorld(worldName + NETHER) == null) {
|
|
||||||
addon.log("Creating AcidIsland's Nether...");
|
|
||||||
}
|
|
||||||
if (!addon.getSettings().isNetherIslands()) {
|
|
||||||
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
|
|
||||||
} else {
|
|
||||||
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(addon))
|
|
||||||
.environment(World.Environment.NETHER).createWorld();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Make the end if it does not exist
|
|
||||||
if (addon.getSettings().isEndGenerate()) {
|
|
||||||
if (addon.getServer().getWorld(worldName + THE_END) == null) {
|
|
||||||
addon.log("Creating AcidIsland's End World...");
|
|
||||||
}
|
|
||||||
if (!addon.getSettings().isEndIslands()) {
|
|
||||||
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
|
|
||||||
} else {
|
|
||||||
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(addon))
|
|
||||||
.environment(World.Environment.THE_END).createWorld();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load schematics
|
|
||||||
addon.getPlugin().getSchemsManager().loadIslands(islandWorld);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a player is in any of the island worlds
|
|
||||||
* @param loc - player to check
|
|
||||||
* @return true if in a world or false if not
|
|
||||||
*/
|
|
||||||
public boolean inWorld(Location loc) {
|
|
||||||
return Util.sameWorld(loc.getWorld(), islandWorld);
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getOverWorld() {
|
|
||||||
return islandWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getNetherWorld() {
|
|
||||||
return netherWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getEndWorld() {
|
|
||||||
return endWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -55,13 +55,13 @@ public class AcidTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Stream<Entity> getEntityStream() {
|
private Stream<Entity> getEntityStream() {
|
||||||
Stream<Entity> entityStream = addon.getIslandWorld().getEntities().stream();
|
Stream<Entity> entityStream = addon.getOverWorld().getEntities().stream();
|
||||||
// Nether and end
|
// Nether and end
|
||||||
if (addon.getSettings().isNetherGenerate() && addon.getSettings().isNetherIslands()) {
|
if (addon.getSettings().isNetherGenerate() && addon.getSettings().isNetherIslands()) {
|
||||||
entityStream = Stream.concat(entityStream, addon.getAiw().getNetherWorld().getEntities().stream());
|
entityStream = Stream.concat(entityStream, addon.getNetherWorld().getEntities().stream());
|
||||||
}
|
}
|
||||||
if (addon.getSettings().isEndGenerate() && addon.getSettings().isEndIslands()) {
|
if (addon.getSettings().isEndGenerate() && addon.getSettings().isEndIslands()) {
|
||||||
entityStream = Stream.concat(entityStream, addon.getAiw().getEndWorld().getEntities().stream());
|
entityStream = Stream.concat(entityStream, addon.getEndWorld().getEntities().stream());
|
||||||
}
|
}
|
||||||
return entityStream;
|
return entityStream;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import world.bentobox.acidisland.AcidIsland;
|
|||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class ChunkGeneratorWorld extends ChunkGenerator {
|
public class ChunkGeneratorWorld extends ChunkGenerator {
|
||||||
|
|
||||||
private final AcidIsland addon;
|
private final AcidIsland addon;
|
||||||
private final Random rand = new Random();
|
private final Random rand = new Random();
|
||||||
|
Loading…
Reference in New Issue
Block a user