mirror of
https://github.com/BentoBoxWorld/CaveBlock.git
synced 2025-02-19 01:31:47 +01:00
Merge commit '418eb7bef2c5c692d42b99a462f92a1840f9f574'
This commit is contained in:
commit
166fb54bf7
7
pom.xml
7
pom.xml
@ -50,8 +50,8 @@
|
||||
<!-- Revision variable removes warning about dynamic version -->
|
||||
<revision>${build.version}-SNAPSHOT</revision>
|
||||
<!-- This allows to change between versions and snapshots. -->
|
||||
<build.version>1.4.0</build.version>
|
||||
<build.number>0</build.number>
|
||||
<build.version>1.4.1</build.version>
|
||||
<build.number>-LOCAL</build.number>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
@ -66,7 +66,7 @@
|
||||
</activation>
|
||||
<properties>
|
||||
<!-- Override only if necessary -->
|
||||
<build.number>${env.BUILD_NUMBER}</build.number>
|
||||
<build.number>-#${env.BUILD_NUMBER}</build.number>
|
||||
<!-- GIT_BRANCH -->
|
||||
</properties>
|
||||
</profile>
|
||||
@ -84,6 +84,7 @@
|
||||
<properties>
|
||||
<!-- Override only if necessary -->
|
||||
<revision>${build.version}</revision>
|
||||
<build.number></build.number>
|
||||
<!-- GIT_BRANCH -->
|
||||
</properties>
|
||||
</profile>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package world.bentobox.caveblock;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
@ -10,6 +11,7 @@ import org.eclipse.jdt.annotation.NonNull;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
import world.bentobox.caveblock.commands.AdminCommand;
|
||||
import world.bentobox.caveblock.commands.IslandCommand;
|
||||
import world.bentobox.caveblock.generators.ChunkGeneratorWorld;
|
||||
@ -41,6 +43,16 @@ public class CaveBlock extends GameModeAddon
|
||||
{
|
||||
this.playerCommand = new IslandCommand(this);
|
||||
this.adminCommand = new AdminCommand(this);
|
||||
|
||||
// Register flags
|
||||
CaveBlock.ALTERNATIVE_TELEPORT_FLAG.addGameModeAddon(this);
|
||||
CaveBlock.SKY_WALKER_FLAG.addGameModeAddon(this);
|
||||
|
||||
this.getPlugin().getFlagsManager().registerFlag(CaveBlock.ALTERNATIVE_TELEPORT_FLAG);
|
||||
this.getPlugin().getFlagsManager().registerFlag(CaveBlock.SKY_WALKER_FLAG);
|
||||
|
||||
// Register listener
|
||||
this.registerListener(new CustomHeightLimitations(this));
|
||||
}
|
||||
|
||||
|
||||
@ -160,8 +172,6 @@ public class CaveBlock extends GameModeAddon
|
||||
createWorld();
|
||||
}
|
||||
}
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(new CustomHeightLimitations(this), this.getPlugin());
|
||||
}
|
||||
|
||||
|
||||
@ -202,14 +212,17 @@ public class CaveBlock extends GameModeAddon
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorldSettings() {
|
||||
if (settings != null) {
|
||||
new Config<>(this, Settings.class).saveConfigObject(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorldSettings()
|
||||
{
|
||||
if (this.settings != null)
|
||||
{
|
||||
new Config<>(this, Settings.class).saveConfigObject(this.settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Variables
|
||||
// ---------------------------------------------------------------------
|
||||
@ -231,6 +244,27 @@ public class CaveBlock extends GameModeAddon
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* This flag allows enables and disables alternative teleport paths. If player falls
|
||||
* into void and this flag is enabled, then he will be teleported to different world.
|
||||
*/
|
||||
public final static Flag ALTERNATIVE_TELEPORT_FLAG =
|
||||
new Flag.Builder("ALTERNATIVE_TELEPORT_FLAG", Material.ENDER_PEARL).
|
||||
type(Flag.Type.WORLD_SETTING).
|
||||
defaultSetting(false).
|
||||
build();
|
||||
|
||||
/**
|
||||
* This flag allows enables and disables to walk on top of the world without a
|
||||
* permission. When enabled, players will be able to reach other player islands through
|
||||
* top of the world.
|
||||
*/
|
||||
public final static Flag SKY_WALKER_FLAG =
|
||||
new Flag.Builder("SKY_WALKER_FLAG", Material.FEATHER).
|
||||
type(Flag.Type.WORLD_SETTING).
|
||||
defaultSetting(false).
|
||||
build();
|
||||
|
||||
/**
|
||||
* String for nether world.
|
||||
*/
|
||||
|
@ -768,36 +768,6 @@ public class Settings implements DataObject, WorldSettings
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the skyWalking object.
|
||||
* @return the skyWalking object.
|
||||
*/
|
||||
public boolean isSkyWalking()
|
||||
{
|
||||
return skyWalking;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the alternativeTeleports object.
|
||||
* @return the alternativeTeleports object.
|
||||
*/
|
||||
public boolean isAlternativeTeleports()
|
||||
{
|
||||
return alternativeTeleports;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the beaconAllowed object.
|
||||
* @return the beaconAllowed object.
|
||||
*/
|
||||
public boolean isBeaconAllowed()
|
||||
{
|
||||
return beaconAllowed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the islandCommand value.
|
||||
* @return the value of islandCommand.
|
||||
@ -1537,39 +1507,6 @@ public class Settings implements DataObject, WorldSettings
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the skyWalking object value.
|
||||
* @param skyWalking the skyWalking object new value.
|
||||
*
|
||||
*/
|
||||
public void setSkyWalking(boolean skyWalking)
|
||||
{
|
||||
this.skyWalking = skyWalking;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the alternativeTeleports object value.
|
||||
* @param alternativeTeleports the alternativeTeleports object new value.
|
||||
*
|
||||
*/
|
||||
public void setAlternativeTeleports(boolean alternativeTeleports)
|
||||
{
|
||||
this.alternativeTeleports = alternativeTeleports;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the beaconAllowed object value.
|
||||
* @param beaconAllowed the beaconAllowed object new value.
|
||||
*
|
||||
*/
|
||||
public void setBeaconAllowed(boolean beaconAllowed)
|
||||
{
|
||||
this.beaconAllowed = beaconAllowed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the debug
|
||||
*/
|
||||
@ -1708,26 +1645,6 @@ public class Settings implements DataObject, WorldSettings
|
||||
@ConfigEntry(path = "world.generation-tries", needsReset = true)
|
||||
private int numberOfBlockGenerationTries = 1;
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Allows to walk over the world roof.")
|
||||
@ConfigEntry(path = "world.sky-walking")
|
||||
private boolean skyWalking;
|
||||
|
||||
@ConfigComment("Enables different ways how to get to other worlds.")
|
||||
@ConfigComment("If players fall into void, then they will be teleported:")
|
||||
@ConfigComment(" - to nether if falls into void from over world")
|
||||
@ConfigComment(" - to the end if falls into void from nether")
|
||||
@ConfigComment(" - to over world if falls into void from the end")
|
||||
@ConfigEntry(path = "world.alternative-teleports")
|
||||
private boolean alternativeTeleports;
|
||||
|
||||
@ConfigComment("Enables ability to use beacon, if world roof is made of Bedrock. It will replace")
|
||||
@ConfigComment("bedrock with black stained glass and on beacon placing, and replace it with bedrock if")
|
||||
@ConfigComment("beacon is destroyed.")
|
||||
@ConfigComment("This will not do anything, if roof is not made of bedrock.")
|
||||
@ConfigEntry(path = "world.allow-beacon")
|
||||
private boolean beaconAllowed;
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Make over world roof of bedrock, if false, it will be made from stone")
|
||||
@ConfigEntry(path = "world.normal.roof", needsReset = true)
|
||||
|
@ -43,9 +43,9 @@ public class CustomHeightLimitations implements Listener
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final double nextY = event.getTo().getY();
|
||||
final double nextY = event.getTo() == null ? 1 : event.getTo().getY();
|
||||
|
||||
if (this.addon.getSettings().isSkyWalking() ||
|
||||
if (CaveBlock.SKY_WALKER_FLAG.isSetForWorld(player.getWorld()) ||
|
||||
player.isOp() ||
|
||||
player.isDead() ||
|
||||
player.getGameMode().equals(GameMode.CREATIVE) ||
|
||||
@ -53,9 +53,87 @@ public class CustomHeightLimitations implements Listener
|
||||
this.addon.getPlayers().isInTeleport(player.getUniqueId()) ||
|
||||
player.hasPermission("caveblock.skywalker") ||
|
||||
!Util.sameWorld(this.addon.getOverWorld(), player.getWorld()) ||
|
||||
nextY > 0 && nextY < this.worldHeight ||
|
||||
nextY < this.worldHeight ||
|
||||
// Next check will allow to go down, but never up.
|
||||
event.getFrom().getBlockY() <= event.getFrom().getBlockY() &&
|
||||
event.getFrom().getY() >= nextY &&
|
||||
event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ())
|
||||
{
|
||||
// interested only in movements that is above height limit.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Prevent to get over world height
|
||||
if (nextY >= this.worldHeight)
|
||||
{
|
||||
User.getInstance(player).sendMessage("caveblock.general.errors.cave-limit-reached");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method onPlayerTeleport disables all teleports that involves moving on top of the world.
|
||||
*
|
||||
* @param event of type PlayerTeleportEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final double nextY = event.getTo() == null ? 1 : event.getTo().getY();
|
||||
|
||||
if (CaveBlock.SKY_WALKER_FLAG.isSetForWorld(player.getWorld()) ||
|
||||
player.isOp() ||
|
||||
player.isDead() ||
|
||||
player.getGameMode().equals(GameMode.CREATIVE) ||
|
||||
player.getGameMode().equals(GameMode.SPECTATOR) ||
|
||||
this.addon.getPlayers().isInTeleport(player.getUniqueId()) ||
|
||||
player.hasPermission("caveblock.skywalker") ||
|
||||
!Util.sameWorld(this.addon.getOverWorld(), player.getWorld()) ||
|
||||
nextY < this.worldHeight ||
|
||||
// Next check will allow to go down, but never up.
|
||||
event.getFrom().getY() >= nextY &&
|
||||
event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ())
|
||||
{
|
||||
// interested only in movements that is below 0 or above height limit.
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent to get over world height
|
||||
if (nextY >= this.worldHeight)
|
||||
{
|
||||
User.getInstance(player).sendMessage("caveblock.general.errors.cave-limit-reached");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method onPlayerMove disables movement if player is falling in void and alternative
|
||||
* teleport flag is enabled.
|
||||
* It will work only when player reach negative Y coordinates.
|
||||
*
|
||||
* @param event of type PlayerMoveEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLeftWorld(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final double nextY = event.getTo() == null ? 1 : event.getTo().getY();
|
||||
|
||||
if (event.isCancelled() ||
|
||||
!CaveBlock.ALTERNATIVE_TELEPORT_FLAG.isSetForWorld(player.getWorld()) ||
|
||||
player.isDead() ||
|
||||
player.getGameMode().equals(GameMode.SPECTATOR) ||
|
||||
this.addon.getPlayers().isInTeleport(player.getUniqueId()) ||
|
||||
!Util.sameWorld(this.addon.getOverWorld(), player.getWorld()) ||
|
||||
nextY > 0 ||
|
||||
// Next check will allow to go down, but never up.
|
||||
event.getFrom().getY() <= nextY &&
|
||||
event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ())
|
||||
{
|
||||
@ -64,7 +142,7 @@ public class CustomHeightLimitations implements Listener
|
||||
}
|
||||
|
||||
// Use custom teleport to different world
|
||||
if (this.addon.getSettings().isAlternativeTeleports() && nextY <= 0)
|
||||
if (CaveBlock.ALTERNATIVE_TELEPORT_FLAG.isSetForWorld(player.getWorld()) && nextY <= 0)
|
||||
{
|
||||
switch (player.getWorld().getEnvironment())
|
||||
{
|
||||
@ -124,53 +202,6 @@ public class CustomHeightLimitations implements Listener
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent to get over world height
|
||||
if (nextY >= this.worldHeight)
|
||||
{
|
||||
User.getInstance(player).sendMessage("caveblock.general.errors.cave-limit-reached");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method onPlayerTeleport disables all teleports that involves moving on top of the world.
|
||||
*
|
||||
* @param event of type PlayerTeleportEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final double nextY = event.getTo().getY();
|
||||
|
||||
if (this.addon.getSettings().isSkyWalking() ||
|
||||
player.isOp() ||
|
||||
player.isDead() ||
|
||||
player.getGameMode().equals(GameMode.CREATIVE) ||
|
||||
player.getGameMode().equals(GameMode.SPECTATOR) ||
|
||||
this.addon.getPlayers().isInTeleport(player.getUniqueId()) ||
|
||||
player.hasPermission("caveblock.skywalker") ||
|
||||
!Util.sameWorld(this.addon.getOverWorld(), player.getWorld()) ||
|
||||
nextY > 0 && nextY < this.worldHeight ||
|
||||
// Next check will allow to go down, but never up.
|
||||
event.getFrom().getBlockY() <= event.getFrom().getBlockY() &&
|
||||
event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ())
|
||||
{
|
||||
// interested only in movements that is below 0 or above height limit.
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent to get over world height
|
||||
if (nextY >= this.worldHeight)
|
||||
{
|
||||
User.getInstance(player).sendMessage("caveblock.general.errors.cave-limit-reached");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: CaveBlock
|
||||
main: world.bentobox.caveblock.CaveBlock
|
||||
version: ${version}-#${build.number}
|
||||
version: ${version}${build.number}
|
||||
|
||||
authors: BONNe
|
||||
|
||||
|
@ -62,20 +62,6 @@ world:
|
||||
world-depth: 256
|
||||
# This indicate how many times block should be tried to generate.
|
||||
generation-tries: 2
|
||||
#
|
||||
# Allows to walk over the world roof.
|
||||
sky-walking: false
|
||||
# Enables different ways how to get to other worlds.
|
||||
# If players fall into void, then they will be teleported:
|
||||
# - to nether if falls into void from over world
|
||||
# - to the end if falls into void from nether
|
||||
# - to over world if falls into void from the end
|
||||
alternative-teleports: true
|
||||
# Enables ability to use beacon, if world roof is made of Bedrock. It will replace
|
||||
# bedrock with black stained glass and on beacon placing, and replace it with bedrock if
|
||||
# beacon is destroyed.
|
||||
# This will not do anything, if roof is not made of bedrock.
|
||||
allow-beacon: false
|
||||
normal:
|
||||
#
|
||||
# Make over world roof of bedrock, if false, it will be made from stone
|
||||
|
@ -239,4 +239,14 @@ caveblock:
|
||||
description: |-
|
||||
&aGeneral settings
|
||||
&afor this cave
|
||||
|
||||
|
||||
protection:
|
||||
flags:
|
||||
ALTERNATIVE_TELEPORT_FLAG:
|
||||
description: "&5&oThis allows to enable/disable\n&5&oability to teleport to\n&5&odiferent dimension if\n&5&oplayer falls in void."
|
||||
name: "Alternative teleports"
|
||||
hint: "Falling in void will not end in death."
|
||||
SKY_WALKER_FLAG:
|
||||
description: "&5&oThis allows to enable/disable\n&5&oability to walk on the\n&5&otop of the cave world\n&5&owithout extra permissions."
|
||||
name: "Sky Walker"
|
||||
hint: "Allows to walk on cave ceiling."
|
Loading…
Reference in New Issue
Block a user