Add CaveBlock default BluePrint.

Add AdminSwitchCommand

Optimize code that checks if player can walk on top of the world.
Remove AlternativeTeleports, as it is moved to VoidPortals addon.
This commit is contained in:
BONNe 2019-05-26 18:44:34 +03:00
parent a6e39196af
commit c778a1ba03
21 changed files with 993 additions and 13498 deletions

24
pom.xml
View File

@ -121,7 +121,10 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<filtering>false</filtering>
<includes>
<include>*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/locales</directory>
@ -132,11 +135,12 @@
</includes>
</resource>
<resource>
<directory>src/main/resources/schems</directory>
<targetPath>./schems</targetPath>
<filtering>false</filtering>
<directory>src/main/resources/blueprints</directory>
<targetPath>./blueprints</targetPath>
<filtering>true</filtering>
<includes>
<include>*.schem</include>
<include>*.json</include>
<include>*.blu</include>
</includes>
</resource>
</resources>
@ -152,7 +156,7 @@
<version>3.1.0</version>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>schem</nonFilteredFileExtension>
<nonFilteredFileExtension>blu</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
@ -206,14 +210,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<minimizeJar>false</minimizeJar>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>

View File

@ -49,10 +49,7 @@ public class CaveBlock extends GameModeAddon
{
// 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
@ -246,16 +243,6 @@ 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

View File

@ -1550,7 +1550,7 @@ public class Settings implements WorldSettings
@ConfigComment("World difficulty setting - PEACEFUL, EASY, NORMAL, HARD")
@ConfigComment("Other plugins may override this setting")
@ConfigEntry(path = "world.difficulty")
private Difficulty difficulty = Difficulty.NORMAL;
private Difficulty difficulty = Difficulty.HARD;
@ConfigComment("Radius of cave in blocks. (So distance between caves is twice this)")
@ConfigComment("Will be rounded up to the nearest 16 blocks.")

View File

@ -70,6 +70,9 @@ public class AdminCommand extends CompositeCommand {
new AdminTrashCommand(this);
new AdminEmptyTrashCommand(this);
new AdminSwitchtoCommand(this);
// Switch
new AdminSwitchCommand(this);
}
@Override

View File

@ -3,7 +3,6 @@ package world.bentobox.caveblock.listeners;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -13,7 +12,6 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
import world.bentobox.bentobox.util.teleport.SafeSpotTeleport;
import world.bentobox.caveblock.CaveBlock;
@ -45,19 +43,7 @@ public class CustomHeightLimitations implements Listener
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())
if (this.shouldNotBeCancelled(nextY, player, event.getFrom(), event.getTo()))
{
// interested only in movements that is above height limit.
return;
@ -84,19 +70,7 @@ public class CustomHeightLimitations implements Listener
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())
if (this.shouldNotBeCancelled(nextY, player, event.getFrom(), event.getTo()))
{
// interested only in movements that is below 0 or above height limit.
return;
@ -111,98 +85,30 @@ public class CustomHeightLimitations implements Listener
}
/**
* 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
* This method checks and returns if current player movement from location to to location should be
* managed by current addon.
* @param nextY NextY location for player.
* @param player Player who makes movement
* @param from Start location
* @param to Next location
* @return {@code true} if addon should not manage current movement, {@code false} otherwise.
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLeftWorld(PlayerMoveEvent event)
private boolean shouldNotBeCancelled(double nextY, Player player, Location from, Location to)
{
Player player = event.getPlayer();
final double nextY = event.getTo() == null ? 1 : event.getTo().getY();
if (event.isCancelled() ||
!CaveBlock.ALTERNATIVE_TELEPORT_FLAG.isSetForWorld(player.getWorld()) ||
return nextY < this.worldHeight ||
from == to ||
from.getY() >= nextY &&
from.getBlockX() == to.getBlockX() &&
from.getBlockZ() == to.getBlockZ() ||
player.isOp() ||
player.isDead() ||
player.getGameMode().equals(GameMode.CREATIVE) ||
player.getGameMode().equals(GameMode.SPECTATOR) ||
player.hasPermission("caveblock.skywalker") ||
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())
{
// interested only in movements that is below 0 or above height limit.
return;
}
// Use custom teleport to different world
if (CaveBlock.ALTERNATIVE_TELEPORT_FLAG.isSetForWorld(player.getWorld()) && nextY <= 0)
{
switch (player.getWorld().getEnvironment())
{
case NORMAL:
{
// From normal world users will get to nether.
Location to = this.addon.getIslands().getIslandAt(event.getFrom()).
map(i -> i.getSpawnPoint(World.Environment.NETHER)).
orElse(event.getFrom().toVector().toLocation(this.addon.getNetherWorld()));
event.setCancelled(true);
new SafeSpotTeleport.Builder(this.addon.getPlugin()).
entity(event.getPlayer()).
location(to).
portal().
build();
break;
}
case NETHER:
{
// From nether world users will get to the end.
Location to = this.addon.getIslands().getIslandAt(event.getFrom()).
map(i -> i.getSpawnPoint(World.Environment.THE_END)).
orElse(event.getFrom().toVector().toLocation(this.addon.getEndWorld()));
event.setCancelled(true);
new SafeSpotTeleport.Builder(this.addon.getPlugin()).
entity(event.getPlayer()).
location(to).
portal().
build();
break;
}
case THE_END:
{
// From the end users will get to over world.
Location to = this.addon.getIslands().getIslandAt(event.getFrom()).
map(i -> i.getSpawnPoint(World.Environment.NORMAL)).
orElse(event.getFrom().toVector().toLocation(this.addon.getOverWorld()));
event.setCancelled(true);
new SafeSpotTeleport.Builder(this.addon.getPlugin()).
entity(event.getPlayer()).
location(to).
portal().
build();
break;
}
default:
break;
}
}
CaveBlock.SKY_WALKER_FLAG.isSetForWorld(player.getWorld());
}

View File

@ -21,14 +21,14 @@ permissions:
description: Let the player use the sethome command
default: true
caveblock.island.info:
description: Let the player check their cave level
default: true
caveblock.island.sethome:
description: Let the player set their cave teleport point
description: Let the player check other players info
default: true
caveblock.island.lock:
description: Allows cave locking
default: false
default: true
caveblock.island.near:
description: Players can see nearby cave names
default: true
caveblock.island.expel:
description: Allows expelling of visitors
default: true
@ -49,7 +49,7 @@ permissions:
default: true
caveblock.island.reset:
description: Player can use the cave reset or restart command
default: true
default: true
caveblock.island.team:
description: Let a player use team commands
default: true
@ -59,21 +59,18 @@ permissions:
caveblock.island.team.coop:
description: Let a player use team coop commands
default: true
caveblock.island.team.promote:
description: Let a player use promote commands
default: true
caveblock.settings.*:
description: Allow use of settings on cave
default: true
caveblock.mod.info:
description: Let a moderator see info on a player
default: op
caveblock.mod.resethome:
description: Allows setting or reseting of a player's home position
default: op
caveblock.mod.clearreset:
description: Allow clearing of cave reset limit
default: false
caveblock.mod.tp:
description: Allows teleport to an cave
default: op
caveblock.mod.bypasscooldowns:
description: Allow moderator to bypass cooldowns
default: op
@ -83,21 +80,24 @@ permissions:
caveblock.mod.bypassexpel:
description: Allow moderator to bypass cave expulsion
default: op
caveblock.mod.switch:
description: Allows moderator to switch bypass protection on and off
default: op
caveblock.mod.lock:
description: Locks or unlocks an cave
description: Locks or unlocks a cave
default: op
caveblock.mod.bypasslock:
description: Bypasses an cave lock
description: Bypasses a cave lock
default: op
caveblock.mod.bypassban:
description: Bypasses cave ban
default: op
caveblock.mod.team:
description: Enables modification of teams via kick and add commands
default: false
caveblock.mod.name:
description: Enables naming of player's caves
default: false
caveblock.mod.resetname:
description: Enables reset of player's cave names
default: false
caveblock.admin.tp:
description: Allows teleport to a cave
default: op
caveblock.admin.clearresetall:
description: Allow clearing of cave reset limit of all players
default: op
@ -107,17 +107,11 @@ permissions:
caveblock.admin.delete:
description: Let a player completely remove a player (including cave)
default: op
caveblock.admin.deleteisland:
description: Let a player completely remove the cave the player is on
default: op
caveblock.admin.register:
description: Let a player register the nearest cave to another player.
default: op
caveblock.admin.unregister:
description: Removes a player from an cave without deleting the cave blocks.
default: op
caveblock.admin.purge:
description: Let a player purge old caves.
description: Removes a player from a cave without deleting the cave blocks.
default: op
caveblock.admin.setspawn:
description: Allows use of spawn tools
@ -125,18 +119,15 @@ permissions:
caveblock.admin.setrange:
description: Allows setting of cave protection range
default: op
caveblock.admin.reserve:
description: Reserves an empty spot for a player's next cave
default: op
caveblock.admin.settingsreset:
description: Resets all the caves to default protection settings
default: op
caveblock.admin.noban:
description: Player cannot be banned from an cave
description: Player cannot be banned from a cave
default: op
caveblock.admin.noexpel:
description: Player cannot be expelled from a cave
default: op
caveblock.admin.setlanguage:
description: Resets all player languages and sets the default language
default: op
caveblock.skywalker:
description: Allows player to walk over the heigh limit.
default: op

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,17 @@
{
"uniqueId": "default",
"icon": "STONE",
"displayName": "§eThe Default CaveBlock",
"description": [
"§bStandard cave, with a cow - moo!",
"§aIncludes an Overworld cave",
"§cIncludes a Nether cave",
"§6Includes an End cave"
],
"requirePermission": false,
"blueprints": {
"NORMAL": "cave",
"NETHER": "nether-cave",
"THE_END": "end-cave"
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -15,7 +15,7 @@ world:
world-name: caveblock-world
# World difficulty setting - PEACEFUL, EASY, NORMAL, HARD
# Other plugins may override this setting
difficulty: NORMAL
difficulty: HARD
# Radius of cave in blocks. (So distance between caves is twice this)
# Will be rounded up to the nearest 16 blocks.
# It is the same for every dimension : Overworld, Nether and End.

File diff suppressed because it is too large Load Diff

View File

@ -1,310 +0,0 @@
blocks:
-3,0,0:
bd: minecraft:obsidian
-3,1,0:
bd: minecraft:end_stone
-2,-1,0:
bd: minecraft:end_stone
-2,0,-2:
bd: minecraft:end_stone_bricks
-2,0,-1:
bd: minecraft:end_stone_bricks
-2,0,0:
bd: minecraft:end_stone_bricks
-2,0,1:
bd: minecraft:end_stone_bricks
-2,0,2:
bd: minecraft:end_stone
-2,1,-2:
bd: minecraft:end_stone_bricks
-2,1,-1:
bd: minecraft:end_stone_bricks
-2,1,0:
bd: minecraft:end_stone_bricks
-2,1,1:
bd: minecraft:end_stone_bricks
-2,1,2:
bd: minecraft:end_stone
-2,2,-1:
bd: minecraft:end_stone
-2,2,0:
bd: minecraft:end_stone
-2,3,-1:
bd: minecraft:chorus_plant[down=true,east=false,north=false,south=false,up=true,west=false]
-2,4,-1:
bd: minecraft:chorus_plant[down=true,east=false,north=false,south=false,up=true,west=false]
-2,5,-1:
bd: minecraft:chorus_flower[age=0]
-1,-2,0:
bd: minecraft:end_stone
-1,-1,-1:
bd: minecraft:end_stone
-1,-1,0:
bd: minecraft:end_stone
-1,-1,1:
bd: minecraft:end_stone
-1,0,-2:
bd: minecraft:end_stone_bricks
-1,0,0:
bd: minecraft:purple_shulker_box[facing=up]
inventory:
'0':
==: org.bukkit.inventory.ItemStack
v: 1631
type: OBSIDIAN
'11':
==: org.bukkit.inventory.ItemStack
v: 1631
type: ENDERMAN_SPAWN_EGG
'15':
==: org.bukkit.inventory.ItemStack
v: 1631
type: ELYTRA
'22':
==: org.bukkit.inventory.ItemStack
v: 1631
type: END_ROD
-1,0,1:
bd: minecraft:end_stone_bricks
-1,0,2:
bd: minecraft:end_stone
-1,1,-2:
bd: minecraft:end_rod[facing=east]
-1,1,-1:
bd: minecraft:air
-1,1,0:
bd: minecraft:air
-1,1,1:
bd: minecraft:end_stone_bricks
-1,1,2:
bd: minecraft:end_stone
-1,1,3:
bd: minecraft:end_stone
-1,2,-2:
bd: minecraft:end_stone
-1,2,-1:
bd: minecraft:end_stone
-1,2,0:
bd: minecraft:end_stone
-1,2,1:
bd: minecraft:end_stone
-1,3,-3:
bd: minecraft:chorus_plant[down=false,east=true,north=false,south=false,up=true,west=false]
-1,4,-3:
bd: minecraft:chorus_plant[down=true,east=false,north=false,south=false,up=true,west=false]
-1,5,-3:
bd: minecraft:chorus_plant[down=true,east=false,north=false,south=false,up=true,west=false]
-1,6,-4:
bd: minecraft:chorus_plant[down=false,east=false,north=false,south=true,up=true,west=false]
-1,6,-3:
bd: minecraft:chorus_plant[down=true,east=true,north=true,south=false,up=false,west=false]
-1,7,-4:
bd: minecraft:chorus_plant[down=true,east=false,north=false,south=false,up=true,west=false]
-1,8,-4:
bd: minecraft:chorus_flower[age=1]
0,-2,-1:
bd: minecraft:end_stone
0,-2,1:
bd: minecraft:end_stone
0,-1,-2:
bd: minecraft:end_stone
0,-1,-1:
bd: minecraft:end_stone
0,-1,0:
bd: minecraft:end_stone
0,-1,1:
bd: minecraft:end_stone
0,-1,2:
bd: minecraft:end_stone
0,0,-3:
bd: minecraft:obsidian
0,0,-2:
bd: minecraft:end_stone_bricks
0,0,-1:
bd: minecraft:air
0,0,0:
bd: minecraft:air
0,0,1:
bd: minecraft:end_stone_bricks
0,0,2:
bd: minecraft:end_stone_bricks
0,0,3:
bd: minecraft:obsidian
0,1,-3:
bd: minecraft:end_stone
0,1,-2:
bd: minecraft:end_stone_bricks
0,1,-1:
bd: minecraft:air
0,1,0:
bd: minecraft:air
0,1,1:
bd: minecraft:end_stone_bricks
0,1,2:
bd: minecraft:end_stone
0,1,3:
bd: minecraft:end_stone_bricks
0,2,-3:
bd: minecraft:end_stone
0,2,-2:
bd: minecraft:end_stone
0,2,-1:
bd: minecraft:end_stone
0,2,0:
bd: minecraft:end_stone
0,2,1:
bd: minecraft:end_stone
0,3,-3:
bd: minecraft:chorus_plant[down=false,east=false,north=false,south=false,up=false,west=true]
0,6,-3:
bd: minecraft:chorus_flower[age=1]
1,-2,0:
bd: minecraft:end_stone
1,-1,-1:
bd: minecraft:end_stone
1,-1,0:
bd: minecraft:end_stone
1,-1,1:
bd: minecraft:end_stone
1,0,-2:
bd: minecraft:end_stone_bricks
1,0,-1:
bd: minecraft:air
1,0,0:
bd: minecraft:air
1,0,1:
bd: minecraft:purpur_stairs[facing=south,half=bottom,shape=straight,waterlogged=false]
1,0,2:
bd: minecraft:end_stone
1,1,-2:
bd: minecraft:end_stone_bricks
1,1,-1:
bd: minecraft:air
1,1,0:
bd: minecraft:air
1,1,1:
bd: minecraft:air
1,1,2:
bd: minecraft:purpur_stairs[facing=south,half=bottom,shape=straight,waterlogged=false]
1,1,3:
bd: minecraft:end_stone
1,2,-2:
bd: minecraft:end_stone
1,2,-1:
bd: minecraft:end_stone
1,2,0:
bd: minecraft:air
1,2,1:
bd: minecraft:air
1,2,2:
bd: minecraft:air
1,3,0:
bd: minecraft:air
1,3,1:
bd: minecraft:air
1,3,2:
bd: minecraft:air
2,-1,-1:
bd: minecraft:end_stone_bricks
2,-1,0:
bd: minecraft:end_stone
2,0,-2:
bd: minecraft:end_stone
2,0,-1:
bd: minecraft:end_stone_bricks
2,0,0:
bd: minecraft:end_stone
2,0,1:
bd: minecraft:end_stone
2,0,2:
bd: minecraft:end_stone
2,1,-2:
bd: minecraft:end_stone_bricks
2,1,-1:
bd: minecraft:end_stone
2,1,0:
bd: minecraft:end_rod[facing=up]
2,1,2:
bd: minecraft:end_stone
2,1,3:
bd: minecraft:end_stone_bricks
2,2,-2:
bd: minecraft:end_stone_bricks
2,2,-1:
bd: minecraft:end_stone
2,2,0:
bd: minecraft:end_stone
2,2,1:
bd: minecraft:end_stone
2,3,-2:
bd: minecraft:end_stone_bricks
3,0,-2:
bd: minecraft:end_stone
3,0,0:
bd: minecraft:obsidian
3,1,-2:
bd: minecraft:end_stone
3,1,-1:
bd: minecraft:end_stone_bricks
3,1,1:
bd: minecraft:end_stone
3,1,2:
bd: minecraft:end_stone_bricks
3,2,-2:
bd: minecraft:end_stone
3,2,-1:
bd: minecraft:end_stone
3,3,-2:
bd: minecraft:end_stone
3,4,-2:
bd: minecraft:end_stone
3,5,-2:
bd: minecraft:end_stone
3,6,-2:
bd: minecraft:end_stone
3,7,-2:
bd: minecraft:obsidian
-1,1,-1:
bd: minecraft:air
-1,1,0:
bd: minecraft:air
0,0,-1:
bd: minecraft:air
0,1,-1:
bd: minecraft:air
0,1,0:
bd: minecraft:air
1,0,-1:
bd: minecraft:air
1,0,0:
bd: minecraft:air
1,1,-1:
bd: minecraft:air
1,1,0:
bd: minecraft:air
1,1,1:
bd: minecraft:air
1,2,0:
bd: minecraft:air
1,2,1:
bd: minecraft:air
1,2,2:
bd: minecraft:air
1,3,0:
bd: minecraft:air
1,3,1:
bd: minecraft:air
1,3,2:
bd: minecraft:air
attached:
0,0,0:
bd: minecraft:oak_sign[rotation=8,waterlogged=false]
lines:
- '[spawn_here]'
- ''
- ''
- ''
size:
xsize: 7
ysize: 11
zsize: 8

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff