Skip to content

Commit

Permalink
Version 4.1.0 (#95)
Browse files Browse the repository at this point in the history
* Version 3.2.1

* Remove potential NPE issues

* Version 3.3.0

* Added config option to show or not show particles.

* Add Chinese Translation (#63)

* Rename zh_CN.json to zh_CN.yml (#64)

* Add a clearer message when WBAPI is not found (#65)

It is not mandatory to use WorldBorderAPI, so it should be clear for the user
that they have a choice besides integrating with it.

* Remove `hooked` field (refactor) (#66)

Removing the `hooked` field because it was used locally
and could be removed as a simple refactoring to shorter and simpler code.

* Unify wording of WBAPI-excluded configs (#67)

* Unify wording of WBAPI-excluded configs

* Add `show-particles` to README

* Clarify message for show-particles setting

* Implement per-player border type (#69)

* Rename PlayerBorder.barrier to show

* Move player event handlers to PlayerListener

* Remove PlayerBorder

* Implement PerPlayerBorderProxy

Currently defaulting to Customer (non-wbapi) border

* Add BorderTypeCommand

* Create BorderType

* Add messages to BorderTypeCommand

* Prepare PerPlayerBorderProxy for handling edge cases

The user may not have a border type set, then we return with the default.
The user's border type may be unavailable now for two reasons:
1. Border type has been disabled after a server/plugin restart
2. Border type is obsolete and does not exist anymore (forward compatibility).

* Fix message reference at BorderTypeCommand

* Use null for missing wbapiBorder

It is fine since it is never used

* Avoid wbapi "border show" spam on player move

* At command, replace args.isEmpty() with size() != 1

To also show help if more parameters are passed than necessary

* Small refactor

* Fix set-type permission in addon.yml

* Update README

Co-authored-by: tastybento <tastybento@users.noreply.github.com>

* Cleanup documentation (#70)

* Remove commented code

* Purify config.yml

As I see, this is just another place to duplicate our settings, documentation and changes to these.
This file is generated if missing.

* Cleanup Settings.java

This is another place where we duplicated documentation.

* Purify README.md

* Fix failing test: testIsUseWbapi

* Revert "Cleanup Settings.java"

This reverts commit f8e931c.

* Format Settings.java and add documentation link

* Regenerate config.yml

* Avoid raw Optional#get

* Enum elements should be all caps by convention.

* Use isEmpty.

Using Collection.size() to test for emptiness works, but using
Collection.isEmpty() makes the code more readable and can be more
performant. The time complexity of any isEmpty() method implementation
should be O(1) whereas some implementations of size() can be O(n).

In this case, it's not a big deal, just a code smell.

* Map to new variable

* 1.18 support for Particle.BARRIER_BLOCK

* Translate id.yml via GitLocalize (#71)

Co-authored-by: Alunite? <xcionsspro30@gmail.com>

* Translate hu.yml via GitLocalize (#72)

Co-authored-by: VerusBungee <gangmastergriefing@gmail.com>

* Taiwan translation (#73)

* Translate zh-TW.yml via GitLocalize

* Update zh-TW.yml

Co-authored-by: davgo0103 <davvgo@gmail.com>
Co-authored-by: tastybento <tastybento@users.noreply.github.com>

* korean translation (#74)

* Translate ko.yml via GitLocalize

* Update ko.yml

Co-authored-by: chickiyeah <ruddls030@naver.com>
Co-authored-by: tastybento <tastybento@users.noreply.github.com>

* Polish translation (#75)

* Translate pl.yml via GitLocalize

* Update pl.yml

Co-authored-by: PICIGIT <piotrp.p@wp.pl>
Co-authored-by: tastybento <tastybento@users.noreply.github.com>

* Switch to use new Bukkit / Paper WorldBorder API (#78)

* Switch to use new Bukkit / Paper WorldBorder API

* Fix nether vanilla border (#80)

Vanilla World Border automatically converts coordinates by dimension multiplayer.
So in the nether it is required to counter it with extra processing.

Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>

* disabled enderpearls and chorus fruits + fix (#82)

* run show task ; teleport visitors back in boundaries, bypass spectators (#83)

* Implement a toggle between border types just by writing border type command.

Requested by #87

* Implement new placeholder: %border_type%

Requested by #86

* Disable border changing from other worlds.

This could lead to a showing up a virtual border where it should not be.

* Translate ru.yml via GitLocalize (#93)

Co-authored-by: Marmur2020 <marmur2020@gmail.com>

* Translate pl.yml via GitLocalize (#92)

Co-authored-by: wiktorm12 <wiktorm12@gmail.com>

* Update French translation (#91)

* Translate fr.yml via GitLocalize

* Translate fr.yml via GitLocalize

Co-authored-by: HipppB <hippolyte.bach@eleve.isep.fr>
Co-authored-by: organizatsiya <organizatsiya.wildguns@gmail.com>

* Translate de.yml via GitLocalize (#89)

Co-authored-by: 0x4096 <rjansengd@gmail.com>

* Update Spanish translation (#90)

* Translate es.yml via GitLocalize

* Translate es.yml via GitLocalize

Co-authored-by: roy0510 <roytacruz@gmail.com>
Co-authored-by: plebexer <plebexer@gmail.com>

* Update to Java 17

* Permission cannot have a - in it.

Changed the permission for the type command to "border.type" instead of
"border.set-type" because with the hyphen in it, Bukkit always grants
the permission for some reason.

Addresses #96

* Added test class for type command

Had to make some classes non-final so they can be mocked.

* Added IslandBorderCommand test class

* Add ${argLine} to get jacoco coverage

* Fix code smells.

* Fix code smell

* Fix Jacoco errors

* Use default settings in config if player does not have permissions. (#98)

Redoes the config.yml as well.
Adds test classes.

Relates to #97

* Config types (#99)

* Use default settings in config if player does not have permissions.

Redoes the config.yml as well.
Adds test classes.

Relates to #97

* Remove unused import.

* Adds offset config to enable border to be bigger than protection range

#75
Adds test class for ShowBarrier.

* Added ShowVirtualWorldBorder test class

#75

* Finishes up #97

---------

Co-authored-by: hutu <63152686+hutuY@users.noreply.github.com>
Co-authored-by: Károly Ozsvárt <arphox@users.noreply.github.com>
Co-authored-by: gitlocalize-app[bot] <55277160+gitlocalize-app[bot]@users.noreply.github.com>
Co-authored-by: Alunite? <xcionsspro30@gmail.com>
Co-authored-by: VerusBungee <gangmastergriefing@gmail.com>
Co-authored-by: davgo0103 <davvgo@gmail.com>
Co-authored-by: chickiyeah <ruddls030@naver.com>
Co-authored-by: PICIGIT <piotrp.p@wp.pl>
Co-authored-by: evlad <emmanuelvlad@gmail.com>
Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
Co-authored-by: BONNe <bonne@bonne.id.lv>
Co-authored-by: Marmur2020 <marmur2020@gmail.com>
Co-authored-by: wiktorm12 <wiktorm12@gmail.com>
Co-authored-by: HipppB <hippolyte.bach@eleve.isep.fr>
Co-authored-by: organizatsiya <organizatsiya.wildguns@gmail.com>
Co-authored-by: 0x4096 <rjansengd@gmail.com>
Co-authored-by: roy0510 <roytacruz@gmail.com>
Co-authored-by: plebexer <plebexer@gmail.com>
  • Loading branch information
19 people committed Feb 26, 2023
1 parent 24c0a99 commit 6cf5c6f
Show file tree
Hide file tree
Showing 34 changed files with 2,003 additions and 368 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 16
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 16
java-version: 17
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand Down
78 changes: 2 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,9 @@
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=BentoBoxWorld_Border&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=BentoBoxWorld_Border)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=BentoBoxWorld_Border&metric=security_rating)](https://sonarcloud.io/dashboard?id=BentoBoxWorld_Border)

**Border** shows a world border around islands. The world border is the Minecraft world border and players cannot go outside of it or a barrier block border that can show up when required.
**Border** can create and show a border around islands which players cannot pass.

##Features##

* Minecraft vanilla world border (requires WorldBorderAPI plugin - see below)
* Alternative barrier blocks border - can block transit or just show where the border is using particles.
* Option to show maximum border - uses 🚫 particle.

## Installation
1. Put this jar into the BentoBox addons folder
2. Restart

## Configuration

The config.yml file contains a number of options.

### Disabled GameModes
By default, Border will operate in all game mode worlds on the BentoBox server. To disable a game mode it is necessary to write its name on new line that starts with -. Example:
```
disabled-gamemodes:
- BSkyBlock
```

### Use WorldBorderAPI (WBAPI)
If you want to use the vanilla world border then you must download the WorldBorderAPI plugin. You can find them here: https://github.com/yannicklamprecht/WorldBorderAPI/releases

Players cannot exit past the vanilla world border, so it will completely block movement outside of a player's protected island area. If you do not want this, then do not use WBAPI.

To activate WBAPI, set this to true in the config.yml:

```
use-wbapi: true
```

### Use barrier blocks.
This only applies if you are not using WBAPI.

If true, the the border will use barrier blocks to prevent most players from exiting the border. If players do manage to exit it, they will get teleported back inside it.

If false, the border is indicated by particles only.

The default is to use barrier blocks.

```
use-barrier-blocks: true
```

### Default border behavior
Players can turn the border on and off if they have the right permission using the border command. This setting makes the default on or off:

```
show-by-default: true
```

### Show max-protection range border.

This only applies if you are not using WBAPI.

This is a visual border only and not a barrier. It displays the 🚫 particle. This is useful for game modes like Boxed where the player's protection area can move around.

```
show-max-border: true
```

## Commands

There is one command that turns the border on or off. Since Version 3.0.0 it requires a permission:

/[player command] border

## Permissions

There is one permission to allow/disallow use of the border command:

`[gamemode].border.toggle`

This permission is not given by default.
**See the full documentation [here](https://docs.bentobox.world/en/latest/addons/Border/).**

## Like this addon?
[Sponsor tastybento](https://github.com/sponsors/tastybento) to get more addons like this and make this one better!
Expand Down
81 changes: 40 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>16</java.version>
<java.version>17</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.17.0</bentobox.version>
<spigot.version>1.19.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.22.1-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>3.2.0</build.version>
<build.version>4.1.0</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand Down Expand Up @@ -102,30 +102,6 @@
<build.number></build.number>
</properties>
</profile>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>tastybento-github</sonar.organization>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.1.1168</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<repositories>
Expand All @@ -141,10 +117,6 @@
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>eldonexus</id>
<url>https://eldonexus.de/repository/maven-releases/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -180,11 +152,6 @@
<version>${bentobox.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.yannicklamprecht.worldborderapi</groupId>
<artifactId>api</artifactId>
<version>1.170.0</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -234,7 +201,34 @@
<version>3.0.0-M5</version>
<configuration>
<argLine>
--illegal-access=permit
${argLine}
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens
java.base/java.util.stream=ALL-UNNAMED
--add-opens java.base/java.text=ALL-UNNAMED
--add-opens
java.base/java.util.regex=ALL-UNNAMED
--add-opens
java.base/java.nio.channels.spi=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens
java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/sun.nio.fs=ALL-UNNAMED
--add-opens java.base/sun.nio.cs=ALL-UNNAMED
--add-opens java.base/java.nio.file=ALL-UNNAMED
--add-opens
java.base/java.nio.charset=ALL-UNNAMED
--add-opens
java.base/java.lang.reflect=ALL-UNNAMED
--add-opens
java.logging/java.util.logging=ALL-UNNAMED
--add-opens java.base/java.lang.ref=ALL-UNNAMED
--add-opens java.base/java.util.jar=ALL-UNNAMED
--add-opens java.base/java.util.zip=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand Down Expand Up @@ -269,7 +263,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.7</version>
<configuration>
<append>true</append>
<excludes>
Expand All @@ -280,16 +274,21 @@
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
75 changes: 47 additions & 28 deletions src/main/java/world/bentobox/border/Border.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
package world.bentobox.border;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
import org.eclipse.jdt.annotation.NonNull;

import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.metadata.MetaDataValue;
import world.bentobox.bentobox.util.Util;
import world.bentobox.border.commands.IslandBorderCommand;
import world.bentobox.border.listeners.PlayerBorder;
import world.bentobox.border.listeners.BorderShower;
import world.bentobox.border.listeners.PlayerListener;
import world.bentobox.border.listeners.ShowBarrier;
import world.bentobox.border.listeners.ShowVirtualWorldBorder;

public final class Border extends Addon {
public class Border extends Addon {

private PlayerBorder playerBorder;
private BorderShower borderShower;

private Settings settings;

private boolean hooked;

private Config<Settings> config = new Config<>(this, Settings.class);

private @NonNull List<GameModeAddon> gameModes = new ArrayList<>();

private final Set<BorderType> availableBorderTypes = EnumSet.of(BorderType.VANILLA, BorderType.BARRIER);

@Override
public void onLoad() {
// Save default config.yml
Expand All @@ -38,35 +42,23 @@ public void onLoad() {

@Override
public void onEnable() {
// Check for WorldBorderAPI
if (getSettings().isUseWbapi()) {
Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldBorderAPI");
if (plugin == null || !plugin.isEnabled()) {
logError("WorldBorderAPI not found. Download from https://github.com/yannicklamprecht/WorldBorderAPI/releases");
logError("Disabling addon");
this.setState(State.DISABLED);
return;
}
}
gameModes.clear();
playerBorder = new PlayerBorder(this);
// Register commands
getPlugin().getAddonsManager().getGameModeAddons().forEach(gameModeAddon -> {

if (!this.settings.getDisabledGameModes().contains(gameModeAddon.getDescription().getName())) {

hooked = true;
gameModes.add(gameModeAddon);

log("Border hooking into " + gameModeAddon.getDescription().getName());
gameModeAddon.getPlayerCommand().ifPresent(c -> new IslandBorderCommand(this, c, "border"));
}
});

if (hooked) {
// Register listeners
registerListener(new PlayerListener(this));
registerListener(playerBorder);
if (!gameModes.isEmpty()) {
borderShower = this.createBorder();
this.registerListener(new PlayerListener(this));
this.registerPlaceholders();
}
}

Expand All @@ -75,11 +67,14 @@ public void onDisable() {
// Nothing to do here
}

/**
* @return the playerBorder
*/
public PlayerBorder getPlayerBorder() {
return playerBorder;
private BorderShower createBorder() {
BorderShower customBorder = new ShowBarrier(this);
BorderShower wbapiBorder = new ShowVirtualWorldBorder(this);
return new PerPlayerBorderProxy(this, customBorder, wbapiBorder);
}

public BorderShower getBorderShower() {
return borderShower;
}

/**
Expand Down Expand Up @@ -110,4 +105,28 @@ public Settings getSettings() {
public boolean inGameWorld(World world) {
return gameModes.stream().anyMatch(gm -> gm.inWorld(Util.getWorld(world)));
}

public Set<BorderType> getAvailableBorderTypesView() {
return Collections.unmodifiableSet(availableBorderTypes);
}


/**
* Placeholder registration.
*/
private void registerPlaceholders()
{
if (this.getPlugin().getPlaceholdersManager() == null)
{
return;
}

// Border is per player, not per gamemode.
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
"type",
user -> BorderType.fromId(user.getMetaData(PerPlayerBorderProxy.BORDER_BORDERTYPE_META_DATA).
orElse(new MetaDataValue(getSettings().getType().getId())).asByte()).
orElse(getSettings().getType()).
getCommandLabel());
}
}

0 comments on commit 6cf5c6f

Please sign in to comment.