1
0
mirror of https://github.com/BentoBoxWorld/BentoBox.git synced 2025-03-22 19:50:43 +01:00

Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.git into develop

This commit is contained in:
tastybento 2019-06-16 09:14:06 -07:00
commit c864ba7ab6
5 changed files with 266 additions and 37 deletions
pom.xml
src/main
java/world/bentobox/bentobox
resources

23
pom.xml
View File

@ -13,6 +13,27 @@
<url>https://github.com/BentoBoxWorld/BentoBox</url>
<inceptionYear>2017</inceptionYear>
<developers>
<developer>
<name>Florian Cuny</name>
<id>Poslovitch</id>
<email>poslovitch@bentobox.world</email>
<timezone>1</timezone>
<roles>
<role>Project manager</role>
<role>Developer</role>
</roles>
</developer>
<developer>
<id>tastybento</id>
<email>tastybento@bentobox.world</email>
<timezone>-8</timezone>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/BentoBoxWorld/BentoBox.git</connection>
<developerConnection>scm:git:git@github.com:BentoBoxWorld/BentoBox.git</developerConnection>
@ -59,7 +80,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.5.2</build.version>
<build.version>1.5.3</build.version>
</properties>
<!-- Profiles will allow to automatically change build version. -->

View File

@ -14,6 +14,12 @@ import world.bentobox.bentobox.database.objects.Island;
@FunctionalInterface
public interface GameModePlaceholderReplacer {
/**
* @param addon the GameModeAddon that registered the placeholder, cannot be null.
* @param user the User to which the placeholder will be shown, can be null.
* @param island the Island of the User, can be null.
* @return the String containing the requested value or an empty String.
*/
@NonNull
String onReplace(@NonNull GameModeAddon addon, @Nullable User user, @Nullable Island island);
}

View File

@ -1,5 +1,6 @@
package world.bentobox.bentobox.listeners;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World.Environment;
import org.bukkit.event.EventHandler;
@ -7,7 +8,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
@ -22,26 +24,41 @@ public class BlockEndDragon implements Listener {
}
/**
* This listener moves the end exit island high up in the sky
* @param e - event
* Adds a portal frame at the top of the world, when a player joins an island End world.
* This prevents the Ender Dragon from spawning: if any portal frame exists, then the dragon is considered killed already.
* @param event PlayerChangedWorldEvent
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEnd(ChunkLoadEvent e) {
if (!e.getWorld().getEnvironment().equals(Environment.THE_END)
|| e.getChunk().getX() != 0
|| e.getChunk().getZ() != 0
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(e.getWorld())
|| !plugin.getIWM().inWorld(e.getWorld())
|| !plugin.getIWM().isEndGenerate(e.getWorld())
|| !plugin.getIWM().isEndIslands(e.getWorld())
|| e.getChunk().getBlock(0, 255, 0).getType().equals(Material.END_PORTAL))
{
// No need to process.
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
Location location = event.getPlayer().getLocation();
if (!plugin.getIWM().isIslandEnd(location.getWorld())
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(location.getWorld())
|| location.getWorld().getBlockAt(0, 255, 0).getType().equals(Material.END_PORTAL)) {
return;
}
// Setting a End Portal at the top will trick dragon legacy check.
e.getChunk().getBlock(0, 255, 0).setType(Material.END_PORTAL, false);
location.getWorld().getBlockAt(0, 255, 0).setType(Material.END_PORTAL, false);
}
/**
* Adds a portal frame at the top of the world, when a player joins an island End world.
* This prevents the Ender Dragon from spawning: if any portal frame exists, then the dragon is considered killed already.
* @param event PlayerJoinEvent
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerJoinWorld(PlayerJoinEvent event) {
Location location = event.getPlayer().getLocation();
if (!plugin.getIWM().isIslandEnd(location.getWorld())
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(location.getWorld())
|| location.getWorld().getBlockAt(0, 255, 0).getType().equals(Material.END_PORTAL)) {
return;
}
// Setting a End Portal at the top will trick dragon legacy check.
location.getWorld().getBlockAt(0, 255, 0).setType(Material.END_PORTAL, false);
}
/**

View File

@ -1,109 +1,294 @@
package world.bentobox.bentobox.lists;
import world.bentobox.bentobox.api.placeholders.GameModePlaceholderReplacer;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.bentobox.util.Util;
import java.text.DateFormat;
import java.time.Instant;
import java.util.Date;
import java.util.Optional;
public enum GameModePlaceholder {
/* World-related */
WORLD_FRIENDLY_NAME("world_friendly_name", (addon, user, island) -> addon.getWorldSettings().getFriendlyName()),
/**
* Displays the amount of islands in the world.
* Returns the amount of islands in the world.
* @since 1.5.0
*/
WORLD_ISLANDS("world_islands", (addon, user, island) -> String.valueOf(addon.getIslands().getIslandCount(addon.getOverWorld()))),
/* Island-related */
// TODO: change the two next placeholders as they're related to the worlds instead of the islands
ISLAND_DISTANCE("island_distance", (addon, user, island) -> String.valueOf(addon.getWorldSettings().getIslandDistance())),
/**
* Displays the island distance as a diameter (it is therefore equivalent to twice the island distance).
* Returns the island distance as a diameter (it is therefore equivalent to twice the island distance).
* @since 1.5.0
*/
ISLAND_DISTANCE_DIAMETER("island_distance_diameter", (addon, user, island) -> String.valueOf(2 * addon.getWorldSettings().getIslandDistance())),
// ----------------------------------
/**
* Returns the island's protection range.
* @since 1.4.0
*/
ISLAND_PROTECTION_RANGE("island_protection_range", (addon, user, island) -> island == null ? "" : String.valueOf(island.getProtectionRange())),
/**
* Displays the island protection range as a diameter (it is therefore equivalent to twice the island protection range).
* Returns the island's protection range as a diameter (it is therefore equivalent to twice the island protection range).
* @since 1.5.0
*/
ISLAND_PROTECTION_RANGE_DIAMETER("island_protection_range_diameter", (addon, user, island) -> island == null ? "" : String.valueOf(2 * island.getProtectionRange())),
ISLAND_OWNER("island_owner", (addon, user, island) -> island == null ? "" : addon.getPlayers().getName(island.getOwner())),
ISLAND_CREATION_DATE("island_creation_date", (addon, user, island) -> island == null ? "" : DateFormat.getInstance().format(Date.from(Instant.ofEpochMilli(island.getCreatedDate())))),
ISLAND_SPAWNPOINT("island_spawnpoint", (addon, user, island) -> island == null ? "" : Util.xyz(island.getCenter().toVector())),
ISLAND_NAME("island_name", (addon, user, island) -> island == null ? "" : (island.getName() == null ? "" : island.getName())),
/**
* Displays the coordinates of the island's center.
* @deprecated As of 1.5.2, for removal; use {@link #ISLAND_CENTER} instead.
*/
@Deprecated
ISLAND_SPAWNPOINT("island_spawnpoint", (addon, user, island) -> island == null ? "" : Util.xyz(island.getCenter().toVector())),
ISLAND_NAME("island_name", (addon, user, island) -> {
if (island == null || island.getName() == null) {
return "";
}
return island.getName();
}),
/**
* Returns the coordinates of the island's center.
* @since 1.5.0
*/
ISLAND_CENTER("island_center", (addon, user, island) -> island == null ? "" : Util.xyz(island.getCenter().toVector())),
/**
* Displays the X coordinate of the island's center.
* Returns the X coordinate of the island's center.
* @since 1.5.0
*/
ISLAND_CENTER_X("island_center_x", (addon, user, island) -> island == null ? "" : String.valueOf(island.getCenter().getBlockX())),
/**
* Displays the Y coordinate of the island's center.
* Returns the Y coordinate of the island's center.
* @since 1.5.0
*/
ISLAND_CENTER_Y("island_center_y", (addon, user, island) -> island == null ? "" : String.valueOf(island.getCenter().getBlockY())),
/**
* Displays the Z coordinate of the island's center.
* Returns the Z coordinate of the island's center.
* @since 1.5.0
*/
ISLAND_CENTER_Z("island_center_z", (addon, user, island) -> island == null ? "" : String.valueOf(island.getCenter().getBlockZ())),
/**
* Displays the maximum number of members the island can have
* Returns the maximum number of members the island can have
* @since 1.5.0
*/
ISLAND_MEMBERS_MAX("island_members_max", (addon, user, island) -> island == null ? "" : String.valueOf(user.getPermissionValue(addon.getPermissionPrefix() + "team.maxsize", addon.getPlugin().getIWM().getMaxTeamSize(addon.getOverWorld())))),
/**
* Displays the amount of players that are at least MEMBER on this island.
* Returns the amount of players that are at least MEMBER on this island.
* @since 1.5.0
*/
ISLAND_MEMBERS_COUNT("island_members_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getMemberSet().size())),
/**
* Displays the amount of players that are TRUSTED on this island.
* Returns the amount of players that are TRUSTED on this island.
* @since 1.5.0
*/
ISLAND_TRUSTEES_COUNT("island_trustees_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getMemberSet(RanksManager.TRUSTED_RANK, false).size())),
/**
* Displays the amount of players that are TRUSTED on this island.
* Returns the amount of players that are TRUSTED on this island.
* @since 1.5.0
*/
ISLAND_COOPS_COUNT("island_coops_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getMemberSet(RanksManager.COOP_RANK, false).size())),
/**
* Displays the amount of players that are currently visiting the island.
* Returns the amount of players that are currently visiting the island.
* @since 1.5.0
*/
ISLAND_VISITORS_COUNT("island_visitors_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getVisitors().size())),
/**
* Displays the amount of players banned from the island.
* Returns the amount of players banned from the island.
* @since 1.5.0
*/
ISLAND_BANS_COUNT("island_bans_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getBanned().size())),
/* Visited island-related (= island the user is standing on) */
/**
* Returns the protection range of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_PROTECTION_RANGE("visited_island_protection_range", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getProtectionRange())).orElse("");
}),
/**
* Returns the protection range of the island the player is standing on as a diameter.
* @since 1.5.2
*/
VISITED_ISLAND_PROTECTION_RANGE_DIAMETER("visited_island_protection_range_diameter", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(2*value.getProtectionRange())).orElse("");
}),
/**
* Returns the name of the owner of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_OWNER("visited_island_owner", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> addon.getPlayers().getName(value.getOwner())).orElse("");
}),
/**
* Returns the formatted creation date of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_CREATION_DATE("visited_island_creation_date", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> DateFormat.getInstance().format(Date.from(Instant.ofEpochMilli(value.getCreatedDate())))).orElse("");
}),
/**
* Returns the name of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_NAME("visited_island_name", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(Island::getName).orElse("");
}),
/**
* Returns the coordinates of the center of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_CENTER("visited_island_center", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> Util.xyz(value.getCenter().toVector())).orElse("");
}),
/**
* Returns the X coordinate of the center of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_CENTER_X("visited_island_center_x", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getCenter().getBlockX())).orElse("");
}),
/**
* Returns the Y coordinate of the center of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_CENTER_Y("visited_island_center_y", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getCenter().getBlockY())).orElse("");
}),
/**
* Returns the Z coordinate of the center of the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_CENTER_Z("visited_island_center_z", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getCenter().getBlockZ())).orElse("");
}),
/**
* Returns the maximum number of members the island the player is standing on can have.
* @since 1.5.2
*/
VISITED_ISLAND_MEMBERS_MAX("visited_island_members_max", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(user.getPermissionValue(addon.getPermissionPrefix() + "team.maxsize", addon.getPlugin().getIWM().getMaxTeamSize(addon.getOverWorld())))).orElse("");
}),
/**
* Returns the amount of players that are at least MEMBER on the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_MEMBERS_COUNT("visited_island_members_count", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getMemberSet().size())).orElse("");
}),
/**
* Returns the amount of players that are TRUSTED on the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_TRUSTEES_COUNT("visited_island_trustees_count", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getMemberSet(RanksManager.TRUSTED_RANK, false).size())).orElse("");
}),
/**
* Returns the amount of players that are TRUSTED on the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_COOPS_COUNT("visited_island_coops_count", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getMemberSet(RanksManager.COOP_RANK, false).size())).orElse("");
}),
/**
* Returns the amount of players that are currently visiting the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_VISITORS_COUNT("visited_island_visitors_count", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getVisitors().size())).orElse("");
}),
/**
* Returns the amount of players banned from the island the player is standing on.
* @since 1.5.2
*/
VISITED_ISLAND_BANS_COUNT("visited_island_bans_count", (addon, user, island) -> {
if (user == null || !user.isPlayer() || user.getLocation() == null) {
return "";
}
Optional<Island> visitedIsland = addon.getIslands().getIslandAt(user.getLocation());
return visitedIsland.map(value -> String.valueOf(value.getBanned().size())).orElse("");
}),
/* Player-related */
/**
* Displays whether this player has an island or not.
* Returns whether this player has an island or not.
* @since 1.5.0
*/
HAS_ISLAND("has_island", (addon, user, island) -> String.valueOf(island != null)),
/**
* Displays the rank this player has on his island.
* Returns the rank this player has on his island.
* @since 1.5.0
*/
RANK("rank", (addon, user, island) -> (island == null || user == null) ? "" : user.getTranslation(addon.getPlugin().getRanksManager().getRank(island.getRank(user)))),
/**
* Displays how many times this player reset his island.
* Returns how many times this player reset his island.
* @since 1.5.0
*/
RESETS("resets", (addon, user, island) -> String.valueOf(addon.getPlayers().getResets(addon.getOverWorld(), user.getUniqueId()))),
/**
* Displays how many times this player can reset his island.
* Returns how many times this player can reset his island.
* {@code -1} is unlimited.
* @since 1.5.0
*/

View File

@ -1,4 +1,4 @@
# BentoBox Configuration 1.5.1
# BentoBox Configuration 1.5.2
# This config file is dynamic and is updated right after BentoBox loaded its settings from it.
# You can edit it while the server is online and you can do '/bbox reload' to take the changes into account.
# However, it is a better practice to edit this file while the server is offline.
@ -102,4 +102,4 @@ web:
# However, as the GitHub API data does not get updated instantly, this value cannot be set less than 15 minutes.
# Setting this to 0 will make BentoBox download data only at startup.
# Added since 1.5.0.
connection-interval: 10
connection-interval: 60