Compare commits
55 Commits
Author | SHA1 | Date |
---|---|---|
tastybento | 0a12a26b06 | |
ISOURA | b860a4dac5 | |
tastybento | 2da0e5e82b | |
RUYSUE | a39b6a3f4a | |
tastybento | d70ee5d755 | |
tastybento | efc6b795d1 | |
tastybento | 519a2d05fc | |
tastybento | 86c089b694 | |
tastybento | 3417633c4d | |
tastybento | b16d5102b1 | |
tastybento | 4375eba030 | |
tastybento | bc1e92ee8d | |
tastybento | b88497397f | |
GIGABAIT | b45c88025f | |
tastybento | 3c9515295d | |
tastybento | 82a0630ca3 | |
BONNe | 6dbdb0f8aa | |
BONNe | a1e03af13a | |
tastybento | 2558d9d1ab | |
Rafał Chomczyk | d346b7864e | |
BONNe | 0e1cd1353c | |
tastybento | 9657d11af7 | |
tastybento | ab1a1e203c | |
tastybento | 1a90acb65f | |
tastybento | ae172b9fdf | |
tastybento | ecebbcd039 | |
tastybento | 3faed651aa | |
Dusty | 0585fd7f3a | |
Espan | 2f59225718 | |
tastybento | 9e57851c62 | |
tastybento | b998b46fd5 | |
tastybento | cb165e52b0 | |
BONNe | ebb3f05d78 | |
BONNe | fe6b020ac8 | |
BONNe | d2dde61d8b | |
BONNe | e58010547b | |
tastybento | 5a9f6495ad | |
tastybento | ff4850d32a | |
DevSolaris | 7a26acefd9 | |
tastybento | 2be57a66d2 | |
tastybento | 67c5c9f8c3 | |
tastybento | 62f1f2e966 | |
BONNe | 5a37c3da75 | |
DevSolaris | 94e9208941 | |
BONNe | 225b4d66f8 | |
BONNe | d3b45396fd | |
BONNe | d2b9540650 | |
BONNe | 363a628244 | |
DevSolaris | 8be844b59f | |
DevSolaris | b3a36c75bb | |
DevSolaris | 7dbb5d39ad | |
BONNe | fb1090717b | |
mt-gitlocalize | 39b94e09d8 | |
wiktorm12 | 5716214527 | |
BONNe | 153e8be6a0 |
|
@ -11,22 +11,22 @@ jobs:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
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@v2
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '16'
|
java-version: '17'
|
||||||
- name: Cache SonarCloud packages
|
- name: Cache SonarCloud packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.sonar/cache
|
path: ~/.sonar/cache
|
||||||
key: ${{ runner.os }}-sonar
|
key: ${{ runner.os }}-sonar
|
||||||
restore-keys: ${{ runner.os }}-sonar
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|
25
pom.xml
25
pom.xml
|
@ -54,19 +54,19 @@
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>16</java.version>
|
<java.version>17</java.version>
|
||||||
<!-- Non-minecraft related dependencies -->
|
<!-- Non-minecraft related dependencies -->
|
||||||
<powermock.version>2.0.9</powermock.version>
|
<powermock.version>2.0.9</powermock.version>
|
||||||
<!-- More visible way how to change dependency versions -->
|
<!-- More visible way how to change dependency versions -->
|
||||||
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
|
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
|
||||||
<bentobox.version>1.18.0-SNAPSHOT</bentobox.version>
|
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
|
||||||
<level.version>2.7.0-SNAPSHOT</level.version>
|
<level.version>2.7.0-SNAPSHOT</level.version>
|
||||||
<!-- Revision variable removes warning about dynamic version -->
|
<!-- Revision variable removes warning about dynamic version -->
|
||||||
<revision>${build.version}-SNAPSHOT</revision>
|
<revision>${build.version}-SNAPSHOT</revision>
|
||||||
<!-- Do not change unless you want different name for local builds. -->
|
<!-- Do not change unless you want different name for local builds. -->
|
||||||
<build.number>-LOCAL</build.number>
|
<build.number>-LOCAL</build.number>
|
||||||
<!-- This allows to change between versions. -->
|
<!-- This allows to change between versions. -->
|
||||||
<build.version>1.12.0</build.version>
|
<build.version>1.15.0</build.version>
|
||||||
<!-- Sonar Cloud -->
|
<!-- Sonar Cloud -->
|
||||||
<sonar.projectKey>BentoBoxWorld_Warps</sonar.projectKey>
|
<sonar.projectKey>BentoBoxWorld_Warps</sonar.projectKey>
|
||||||
<sonar.organization>bentobox-world</sonar.organization>
|
<sonar.organization>bentobox-world</sonar.organization>
|
||||||
|
@ -138,11 +138,6 @@
|
||||||
<version>${spigot.version}</version>
|
<version>${spigot.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>plugin-annotations</artifactId>
|
|
||||||
<version>1.2.3-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Mockito (Unit testing) -->
|
<!-- Mockito (Unit testing) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
|
@ -234,6 +229,7 @@
|
||||||
<version>3.0.0-M5</version>
|
<version>3.0.0-M5</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
|
${argLine}
|
||||||
--add-opens java.base/java.lang=ALL-UNNAMED
|
--add-opens java.base/java.lang=ALL-UNNAMED
|
||||||
--add-opens java.base/java.math=ALL-UNNAMED
|
--add-opens java.base/java.math=ALL-UNNAMED
|
||||||
--add-opens java.base/java.io=ALL-UNNAMED
|
--add-opens java.base/java.io=ALL-UNNAMED
|
||||||
|
@ -316,7 +312,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.3</version>
|
<version>0.8.10</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<append>true</append>
|
<append>true</append>
|
||||||
<excludes>
|
<excludes>
|
||||||
|
@ -327,16 +323,21 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>pre-unit-test</id>
|
<id>prepare-agent</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>prepare-agent</goal>
|
<goal>prepare-agent</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>post-unit-test</id>
|
<id>report</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>report</goal>
|
<goal>report</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<formats>
|
||||||
|
<format>XML</format>
|
||||||
|
</formats>
|
||||||
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -7,10 +7,14 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.configuration.Config;
|
import world.bentobox.bentobox.api.configuration.Config;
|
||||||
|
import world.bentobox.bentobox.api.flags.Flag;
|
||||||
|
import world.bentobox.bentobox.api.flags.clicklisteners.CycleClick;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.level.Level;
|
import world.bentobox.level.Level;
|
||||||
import world.bentobox.warps.commands.WarpCommand;
|
import world.bentobox.warps.commands.WarpCommand;
|
||||||
|
@ -71,6 +75,11 @@ public class Warp extends Addon {
|
||||||
*/
|
*/
|
||||||
private Config<Settings> settingsConfig;
|
private Config<Settings> settingsConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Warp Flag
|
||||||
|
*/
|
||||||
|
private Flag createWarpFlag;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Methods
|
// Section: Methods
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -146,6 +155,18 @@ public class Warp extends Addon {
|
||||||
logWarning("Addon did not hook into anything and is not running stand-alone");
|
logWarning("Addon did not hook into anything and is not running stand-alone");
|
||||||
this.setState(State.DISABLED);
|
this.setState(State.DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.createWarpFlag = new Flag.Builder("PLACE_WARP", Material.OAK_SIGN)
|
||||||
|
.addon(this)
|
||||||
|
.defaultRank(RanksManager.MEMBER_RANK)
|
||||||
|
.clickHandler(new CycleClick("PLACE_WARP",
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.OWNER_RANK))
|
||||||
|
.defaultSetting(false)
|
||||||
|
.mode(Flag.Mode.EXPERT)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
getPlugin().getFlagsManager().registerFlag(this, this.createWarpFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,6 +234,13 @@ public class Warp extends Addon {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the createWarpFlag
|
||||||
|
*/
|
||||||
|
public Flag getCreateWarpFlag() {
|
||||||
|
return createWarpFlag;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the island level
|
* Get the island level
|
||||||
* @param world - world
|
* @param world - world
|
||||||
|
@ -224,8 +252,11 @@ public class Warp extends Addon {
|
||||||
String name = this.getPlugin().getIWM().getAddon(world).map(g -> g.getDescription().getName()).orElse("");
|
String name = this.getPlugin().getIWM().getAddon(world).map(g -> g.getDescription().getName()).orElse("");
|
||||||
return this.getPlugin().getAddonsManager().getAddonByName(LEVEL_ADDON_NAME)
|
return this.getPlugin().getAddonsManager().getAddonByName(LEVEL_ADDON_NAME)
|
||||||
.map(l -> {
|
.map(l -> {
|
||||||
if (!name.isEmpty() && ((Level) l).getSettings().getGameModes().contains(name)) {
|
final Level addon = (Level) l;
|
||||||
return ((Level) l).getIslandLevel(world, uniqueId);
|
//getGameModes is a list of gamemodes that Level is DISABLED in,
|
||||||
|
//so we need the opposite of the contains.
|
||||||
|
if (!name.isEmpty() && !addon.getSettings().getGameModes().contains(name)) {
|
||||||
|
return addon.getIslandLevel(world, uniqueId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}).orElse(null);
|
}).orElse(null);
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
package world.bentobox.warps;
|
package world.bentobox.warps;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.annotation.dependency.Dependency;
|
|
||||||
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
|
|
||||||
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.addons.Pladdon;
|
import world.bentobox.bentobox.api.addons.Pladdon;
|
||||||
|
|
||||||
@Plugin(name="Pladdon", version="1.0")
|
|
||||||
@ApiVersion(ApiVersion.Target.v1_16)
|
|
||||||
@Dependency(value = "BentoBox")
|
|
||||||
public class WarpsPladdon extends Pladdon {
|
public class WarpsPladdon extends Pladdon {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class WarpsCommand extends CompositeCommand {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warp" : "island.warp");
|
this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warps" : "island.warps");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setDescription("warps.help.description");
|
this.setDescription("warps.help.description");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,13 @@ public class Settings implements ConfigObject
|
||||||
@ConfigEntry(path = "warplevelrestriction")
|
@ConfigEntry(path = "warplevelrestriction")
|
||||||
private int warpLevelRestriction = 10;
|
private int warpLevelRestriction = 10;
|
||||||
|
|
||||||
|
@ConfigComment("")
|
||||||
|
@ConfigComment("Should warps be removed when the island protection settings")
|
||||||
|
@ConfigComment("change, and the owner of the warp does no longer have")
|
||||||
|
@ConfigComment("the correct rank")
|
||||||
|
@ConfigEntry(path = "removeExistingWarpsWhenFlagChanges")
|
||||||
|
private boolean removeExistingWarpsWhenFlagChanges = false;
|
||||||
|
|
||||||
@ConfigComment("")
|
@ConfigComment("")
|
||||||
@ConfigComment("Text that player must put on sign to make it a warp sign")
|
@ConfigComment("Text that player must put on sign to make it a warp sign")
|
||||||
@ConfigComment("Not case sensitive!")
|
@ConfigComment("Not case sensitive!")
|
||||||
|
@ -55,7 +62,6 @@ public class Settings implements ConfigObject
|
||||||
@ConfigEntry(path = "warps-command")
|
@ConfigEntry(path = "warps-command")
|
||||||
String warpsCommand = "warps";
|
String warpsCommand = "warps";
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Constructor
|
// Section: Constructor
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -198,4 +204,18 @@ public class Settings implements ConfigObject
|
||||||
public void setWarpsCommand(String warpsCommand) {
|
public void setWarpsCommand(String warpsCommand) {
|
||||||
this.warpsCommand = warpsCommand;
|
this.warpsCommand = warpsCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the removeExistingWarpsWhenFlagChanges
|
||||||
|
*/
|
||||||
|
public boolean getRemoveExistingWarpsWhenFlagChanges() {
|
||||||
|
return removeExistingWarpsWhenFlagChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param removeExistingWarpsWhenFlagChanges the removeExistingWarpsWhenFlagChanges to set
|
||||||
|
*/
|
||||||
|
public void setRemoveExistingWarpsWhenFlagChanges(boolean removeExistingWarpsWhenFlagChanges) {
|
||||||
|
this.removeExistingWarpsWhenFlagChanges = removeExistingWarpsWhenFlagChanges;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import world.bentobox.warps.Warp;
|
||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WarpCreateEvent extends Event{
|
public class WarpCreateEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private final Location warpLoc;
|
private final Location warpLoc;
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package world.bentobox.warps.listeners;
|
package world.bentobox.warps.listeners;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -25,9 +22,11 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.events.addon.AddonEvent;
|
import world.bentobox.bentobox.api.events.addon.AddonEvent;
|
||||||
|
import world.bentobox.bentobox.api.events.flags.FlagProtectionChangeEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamKickEvent;
|
import world.bentobox.bentobox.api.events.team.TeamKickEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamLeaveEvent;
|
import world.bentobox.bentobox.api.events.team.TeamLeaveEvent;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.warps.Warp;
|
import world.bentobox.warps.Warp;
|
||||||
import world.bentobox.warps.event.WarpRemoveEvent;
|
import world.bentobox.warps.event.WarpRemoveEvent;
|
||||||
|
@ -114,7 +113,6 @@ public class WarpSignsListener implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
User user = User.getInstance(e.getPlayer());
|
User user = User.getInstance(e.getPlayer());
|
||||||
if (user == null) return;
|
|
||||||
UUID owner = addon.getWarpSignsManager().getWarpOwnerUUID(b.getLocation()).orElse(null);
|
UUID owner = addon.getWarpSignsManager().getWarpOwnerUUID(b.getLocation()).orElse(null);
|
||||||
if (isPlayersSign(e.getPlayer(), b, inWorld)) {
|
if (isPlayersSign(e.getPlayer(), b, inWorld)) {
|
||||||
addon.getWarpSignsManager().removeWarp(b.getLocation());
|
addon.getWarpSignsManager().removeWarp(b.getLocation());
|
||||||
|
@ -164,6 +162,13 @@ public class WarpSignsListener implements Listener {
|
||||||
e.setLine(0, ChatColor.RED + addon.getSettings().getWelcomeLine());
|
e.setLine(0, ChatColor.RED + addon.getSettings().getWelcomeLine());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!hasCorrectIslandRank(b, user)) {
|
||||||
|
e.setLine(0, ChatColor.RED + addon.getSettings().getWelcomeLine());
|
||||||
|
user.sendMessage("warps.error.not-correct-rank");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the player already has a sign
|
// Check if the player already has a sign
|
||||||
final Location oldSignLoc = addon.getWarpSignsManager().getWarp(b.getWorld(), user.getUniqueId());
|
final Location oldSignLoc = addon.getWarpSignsManager().getWarp(b.getWorld(), user.getUniqueId());
|
||||||
if (oldSignLoc != null) {
|
if (oldSignLoc != null) {
|
||||||
|
@ -192,6 +197,46 @@ public class WarpSignsListener implements Listener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasCorrectIslandRank(Block b, User user) {
|
||||||
|
final Optional<Island> islandOpt = plugin.getIslands().getIslandAt(b.getLocation());
|
||||||
|
|
||||||
|
if(islandOpt.isEmpty()) return false;
|
||||||
|
|
||||||
|
final Island island = islandOpt.get();
|
||||||
|
|
||||||
|
final int userRank = island.getRank(user);
|
||||||
|
|
||||||
|
return userRank >= island.getFlag(addon.getCreateWarpFlag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFlagChange(FlagProtectionChangeEvent e) {
|
||||||
|
if(!e.getEditedFlag().equals(addon.getCreateWarpFlag())) return;
|
||||||
|
if(!addon.getSettings().getRemoveExistingWarpsWhenFlagChanges()) return;
|
||||||
|
|
||||||
|
final Island island = e.getIsland();
|
||||||
|
|
||||||
|
final Map<UUID, Location> islandWarps = addon
|
||||||
|
.getWarpSignsManager()
|
||||||
|
.getWarpMap(island.getWorld())
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.filter(x -> island.inIslandSpace(x.getValue()))
|
||||||
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
|
|
||||||
|
for(Map.Entry<UUID, Location> entry : islandWarps.entrySet()) {
|
||||||
|
if(island.getRank(entry.getKey()) >= e.getSetTo()) continue;
|
||||||
|
|
||||||
|
//The user has a lower rank than the new set value.
|
||||||
|
//We need to remove the warp.
|
||||||
|
addon.getWarpSignsManager().removeWarp(island.getWorld(), entry.getKey());
|
||||||
|
|
||||||
|
if(Bukkit.getPlayer(entry.getKey()) != null) {
|
||||||
|
Objects.requireNonNull(User.getInstance(entry.getKey())).sendMessage(WARPS_DEACTIVATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean noLevelOrIsland(User user, World world) {
|
private boolean noLevelOrIsland(User user, World world) {
|
||||||
// Get level if level addon is available
|
// Get level if level addon is available
|
||||||
Long level = addon.getLevel(Util.getWorld(world), user.getUniqueId());
|
Long level = addon.getLevel(Util.getWorld(world), user.getUniqueId());
|
||||||
|
|
|
@ -21,12 +21,12 @@ import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.warps.Warp;
|
import world.bentobox.warps.Warp;
|
||||||
|
import world.bentobox.warps.event.WarpCreateEvent;
|
||||||
import world.bentobox.warps.event.WarpInitiateEvent;
|
import world.bentobox.warps.event.WarpInitiateEvent;
|
||||||
import world.bentobox.warps.objects.WarpsData;
|
import world.bentobox.warps.objects.WarpsData;
|
||||||
import world.bentobox.warps.panels.Utils;
|
import world.bentobox.warps.panels.Utils;
|
||||||
|
@ -105,7 +106,7 @@ public class WarpSignsManager {
|
||||||
}
|
}
|
||||||
getWarpMap(loc.getWorld()).put(playerUUID, loc);
|
getWarpMap(loc.getWorld()).put(playerUUID, loc);
|
||||||
saveWarpList();
|
saveWarpList();
|
||||||
Bukkit.getPluginManager().callEvent(new WarpInitiateEvent(addon, loc, playerUUID));
|
Bukkit.getPluginManager().callEvent(new WarpCreateEvent(addon, loc, playerUUID));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,15 +201,15 @@ public class WarpSignsManager {
|
||||||
warpsData = handler.loadObject(WARPS);
|
warpsData = handler.loadObject(WARPS);
|
||||||
// Load into map
|
// Load into map
|
||||||
if (warpsData != null) {
|
if (warpsData != null) {
|
||||||
warpsData.getWarpSigns().forEach((k,v) -> {
|
warpsData.getWarpSigns().forEach((location,uuid) -> {
|
||||||
if (k != null && k.getWorld() != null) {
|
if (location != null && location.getWorld() != null) {
|
||||||
if (k.getWorld().isChunkLoaded(k.getBlockX() >> 4, k.getBlockZ() >> 4)
|
if (location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)
|
||||||
&& !k.getBlock().getType().name().contains("SIGN")) {
|
&& !location.getBlock().getType().name().contains("SIGN")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to map
|
// Add to map
|
||||||
getWarpMap(k.getWorld()).put(v, k);
|
getWarpMap(location.getWorld()).put(uuid, location);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -245,8 +246,8 @@ public class WarpSignsManager {
|
||||||
if (en.getValue().equals(loc)) {
|
if (en.getValue().equals(loc)) {
|
||||||
// Inform player
|
// Inform player
|
||||||
Optional.ofNullable(addon.getServer().getPlayer(en.getKey()))
|
Optional.ofNullable(addon.getServer().getPlayer(en.getKey()))
|
||||||
.map(User::getInstance)
|
.map(User::getInstance)
|
||||||
.ifPresent(user -> user.sendMessage("warps.sign-removed"));
|
.ifPresent(user -> user.sendMessage("warps.sign-removed"));
|
||||||
// Remove sign from warp panel cache
|
// Remove sign from warp panel cache
|
||||||
addon.getSignCacheManager().removeWarp(loc.getWorld(), en.getKey());
|
addon.getSignCacheManager().removeWarp(loc.getWorld(), en.getKey());
|
||||||
it.remove();
|
it.remove();
|
||||||
|
@ -320,8 +321,8 @@ public class WarpSignsManager {
|
||||||
if (!prefix.isEmpty())
|
if (!prefix.isEmpty())
|
||||||
{
|
{
|
||||||
icon = Material.matchMaterial(
|
icon = Material.matchMaterial(
|
||||||
Utils.getPermissionValue(User.getInstance(uuid), prefix + "island.warp",
|
Utils.getPermissionValue(User.getInstance(uuid), prefix + "island.warp",
|
||||||
Material.OAK_SIGN.name()));
|
Material.OAK_SIGN.name()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -350,21 +351,38 @@ public class WarpSignsManager {
|
||||||
float yaw = Util.blockFaceToFloat(directionFacing);
|
float yaw = Util.blockFaceToFloat(directionFacing);
|
||||||
final Location actualWarp = new Location(inFront.getWorld(), inFront.getBlockX() + 0.5D, inFront.getBlockY(),
|
final Location actualWarp = new Location(inFront.getWorld(), inFront.getBlockX() + 0.5D, inFront.getBlockY(),
|
||||||
inFront.getBlockZ() + 0.5D, yaw, 30F);
|
inFront.getBlockZ() + 0.5D, yaw, 30F);
|
||||||
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND);
|
WarpInitiateEvent e = new WarpInitiateEvent(addon, actualWarp, user.getUniqueId());
|
||||||
User warpOwner = Objects.requireNonNull(User.getInstance(signOwner));
|
Bukkit.getPluginManager().callEvent(e);
|
||||||
// Hide invisible players
|
if (e.isCancelled()) {
|
||||||
if (warpOwner.isOnline() && !warpOwner.getPlayer().canSee(user.getPlayer())) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pvp) {
|
//BentoBox prevents people from teleporting to an island when
|
||||||
user.sendMessage("protection.flags.PVP_OVERWORLD.enabled");
|
//the user is banned from the island for example.
|
||||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
//By checking if the teleport succeeded before sending the messages,
|
||||||
} else {
|
//we prevent issues where no one teleported, but people still
|
||||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
//get messages about it.
|
||||||
}
|
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND).thenAccept(tpResult -> {
|
||||||
if (!warpOwner.equals(user)) {
|
if(Boolean.FALSE.equals(tpResult)) return;
|
||||||
warpOwner.sendMessage("warps.player-warped", "[name]", user.getName());
|
|
||||||
}
|
User warpOwner = Objects.requireNonNull(User.getInstance(signOwner));
|
||||||
|
// Hide invisible players
|
||||||
|
if (warpOwner.isOnline() && !warpOwner.getPlayer().canSee(user.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pvp) {
|
||||||
|
user.sendMessage("protection.flags.PVP_OVERWORLD.enabled");
|
||||||
|
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
||||||
|
} else {
|
||||||
|
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
||||||
|
}
|
||||||
|
if (!warpOwner.equals(user)) {
|
||||||
|
final String gameMode = BentoBox
|
||||||
|
.getInstance()
|
||||||
|
.getIWM()
|
||||||
|
.getFriendlyName(actualWarp.getWorld());
|
||||||
|
warpOwner.sendMessage("warps.player-warped", "[name]", user.getName(), "[gamemode]", gameMode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -412,7 +430,7 @@ public class WarpSignsManager {
|
||||||
}
|
}
|
||||||
// Find out which direction the warp is facing
|
// Find out which direction the warp is facing
|
||||||
Block b = warpSpot.getBlock();
|
Block b = warpSpot.getBlock();
|
||||||
if (b.getType().name().contains("WALL_SIGN")) {
|
if (Tag.WALL_SIGNS.isTagged(b.getType())) {
|
||||||
org.bukkit.block.data.type.WallSign s = (org.bukkit.block.data.type.WallSign) b.getBlockData();
|
org.bukkit.block.data.type.WallSign s = (org.bukkit.block.data.type.WallSign) b.getBlockData();
|
||||||
BlockFace directionFacing = s.getFacing();
|
BlockFace directionFacing = s.getFacing();
|
||||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||||
|
@ -425,7 +443,13 @@ public class WarpSignsManager {
|
||||||
warpPlayer(user, oneDown, owner, directionFacing, pvp);
|
warpPlayer(user, oneDown, owner, directionFacing, pvp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (b.getType().name().contains("SIGN")) {
|
} else if (Tag.ALL_HANGING_SIGNS.isTagged(b.getType())) {
|
||||||
|
Location below = b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN).getLocation();
|
||||||
|
if ((addon.getIslands().isSafeLocation(below))) {
|
||||||
|
warpPlayer(user, below, owner, BlockFace.DOWN, pvp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (Tag.STANDING_SIGNS.isTagged(b.getType())) {
|
||||||
org.bukkit.block.data.type.Sign s = (org.bukkit.block.data.type.Sign) b.getBlockData();
|
org.bukkit.block.data.type.Sign s = (org.bukkit.block.data.type.Sign) b.getBlockData();
|
||||||
BlockFace directionFacing = s.getRotation();
|
BlockFace directionFacing = s.getRotation();
|
||||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||||
|
|
|
@ -10,7 +10,10 @@ softdepend: AcidIsland, BSkyBlock, CaveBlock, SkyGrid, AOneBlock
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
'[gamemode].island.warp':
|
'[gamemode].island.warp':
|
||||||
description: Player can use warp or warps commands
|
description: Player can use warp command
|
||||||
|
default: true
|
||||||
|
'[gamemode].island.warps':
|
||||||
|
description: Player can use the warps command
|
||||||
default: true
|
default: true
|
||||||
'[gamemode].island.addwarp':
|
'[gamemode].island.addwarp':
|
||||||
description: Player can create a welcome warp sign
|
description: Player can create a welcome warp sign
|
||||||
|
|
|
@ -7,6 +7,11 @@
|
||||||
# Warp Restriction - needed levels to be able to create a warp
|
# Warp Restriction - needed levels to be able to create a warp
|
||||||
# 0 or negative values will disable this restriction 10 is default
|
# 0 or negative values will disable this restriction 10 is default
|
||||||
warplevelrestriction: 10
|
warplevelrestriction: 10
|
||||||
|
#
|
||||||
|
# Should warps be removed when the island protection settings
|
||||||
|
# change, and the owner of the warp does no longer have
|
||||||
|
# the correct rank
|
||||||
|
removeExistingWarpsWhenFlagChanges: true
|
||||||
#
|
#
|
||||||
# Text that player must put on sign to make it a warp sign
|
# Text that player must put on sign to make it a warp sign
|
||||||
# Not case sensitive!
|
# Not case sensitive!
|
||||||
|
|
|
@ -18,9 +18,10 @@ warps:
|
||||||
not-on-island: "&c You must be on your island to do that!"
|
not-on-island: "&c You must be on your island to do that!"
|
||||||
not-safe: "&c That warp is not safe!"
|
not-safe: "&c That warp is not safe!"
|
||||||
your-level-is: "&c Your island level is only [level] and must be higher than [required]. Run the level command."
|
your-level-is: "&c Your island level is only [level] and must be higher than [required]. Run the level command."
|
||||||
help:
|
not-correct-rank: "&c You do not have the correct rank to set a warp!"
|
||||||
|
help:
|
||||||
description: "open the warps panel"
|
description: "open the warps panel"
|
||||||
player-warped: "&2 [name] warped to your warp sign!"
|
player-warped: "&2 [name] warped to your [gamemode] warp sign!"
|
||||||
sign-removed: "&c Warp sign removed!"
|
sign-removed: "&c Warp sign removed!"
|
||||||
success: "&a Success!"
|
success: "&a Success!"
|
||||||
warpTip: "&6 Place a warp sign with [text] on the top"
|
warpTip: "&6 Place a warp sign with [text] on the top"
|
||||||
|
@ -59,4 +60,8 @@ warps:
|
||||||
# Prefix for messages that are send from server.
|
# Prefix for messages that are send from server.
|
||||||
prefix: "&l&6 [BentoBox]: &r"
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: Place Warp
|
||||||
|
description: Allow placing warp sign
|
||||||
|
|
|
@ -1,31 +1,53 @@
|
||||||
###########################################################################################################
|
---
|
||||||
# Este es un archivo YML. Tenga cuidado al editar. Revisa tus ediciones en un verificador de YAML como #
|
warp:
|
||||||
# el de http://yaml-online-parser.appspot.com #
|
help:
|
||||||
###########################################################################################################
|
description: Teletransportarte hacia el warp del jugador
|
||||||
|
parameters: "<player name>"
|
||||||
warp:
|
warps:
|
||||||
help:
|
deactivate: "&c ¡Antiguo cartel de teletransportación desactivado!"
|
||||||
description: "Teletransportarte hacia el warp del jugador"
|
error:
|
||||||
parameters: <player name>
|
does-not-exist: "&c ¡Oh, chasquido! ¡Ese teletransporte ya no existe!"
|
||||||
warps:
|
no-permission: "&c ¡No tienes permisos para hacer eso!"
|
||||||
deactivate: "&c¡El cartel viejo ha sido desactivado!"
|
no-remove: "&c ¡No puedes quitar ese cartel!"
|
||||||
error:
|
no-warps-yet: "&c No hay teletransportes disponibles todavía"
|
||||||
does-not-exist: "&c¡Oh vaya! !Ese warp ya no existe!"
|
not-enough-level: "&c ¡Tu nivel de isla no es lo suficientemente alto!"
|
||||||
no-permission: "&c¡No tienes permiso para hacer eso!"
|
not-on-island: "&c ¡Debes estar en tu isla para hacer eso!"
|
||||||
no-remove: "&c¡No puedes quitar ese cartel!"
|
not-safe: "&c ¡Ese teletransporte no es seguro!"
|
||||||
no-warps-yet: "&cNo hay warps disponibles aún"
|
your-level-is: "&c Tu nivel de isla es solo [level] y debe ser mayor que [required].
|
||||||
not-enough-level: "&c¡Tu nivel de isla no es lo suficientemente alto!"
|
Ejecuta el comando de nivel."
|
||||||
not-on-island: "&c¡Debes estar en tu isla para hacer eso!"
|
not-correct-rank: "&c ¡No tienes el rango correcto para crear un teletransporte!"
|
||||||
not-safe: "&c¡Ese warp no es seguro!"
|
help:
|
||||||
your-level-is: "&cTu nivel de isla es solo [level] y debe ser mayor que [required]"
|
description: Abre el panel de warps
|
||||||
help:
|
player-warped: "&2 [name] se ha teletransportado a tu cartel de teletransportación
|
||||||
description: "Abre el panel de warps"
|
de [gamemode]!"
|
||||||
next: "&6Siguiente página"
|
sign-removed: "&c Cartel de teletransportación eliminado!"
|
||||||
player-warped: "&2[name] ¡se ha teletransportado a tu warp!"
|
success: "&a Éxito!"
|
||||||
previous: "&6Página anterior"
|
warpTip: "&6 Coloca un cartel con [text] en la parte superior"
|
||||||
random: "&4Teletransporte aleatorio"
|
warpToPlayersSign: "&6 Teletransportandote al cartel del jugador [player]"
|
||||||
sign-removed: "&c¡Cartel removido!"
|
gui:
|
||||||
success: "&a¡Éxito!"
|
titles:
|
||||||
title: "Carteles de Warps"
|
warp-title: "&0&l Carteles de Teletransporte"
|
||||||
warpTip: "&6Coloca un cartel que contenga el texto [text] arriba"
|
buttons:
|
||||||
warpToPlayersSign: "&6Teletransportandote al warp de [player]"
|
previous:
|
||||||
|
name: "&f&l Página Anterior"
|
||||||
|
description: "&7 Ir a la página [number]"
|
||||||
|
next:
|
||||||
|
name: "&f&l Siguiente Página"
|
||||||
|
description: "&7 Ir a la página [number]"
|
||||||
|
warp:
|
||||||
|
name: "&f&l [name]"
|
||||||
|
description: "[sign_text]"
|
||||||
|
random:
|
||||||
|
name: "&f&l Teletransporte aleatorio"
|
||||||
|
description: "&7 Hmm, ¿Dónde apareceré?"
|
||||||
|
tips:
|
||||||
|
click-to-previous: "&e Clic &7 para ver la página anterior."
|
||||||
|
click-to-next: "&e Clic &7 para ver la página siguiente."
|
||||||
|
click-to-warp: "&e Clic &7 para teletransportarse."
|
||||||
|
conversations:
|
||||||
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: Colocar Teletransporte
|
||||||
|
description: Permitir colocar un cartel de teletransporte
|
||||||
|
|
|
@ -4,25 +4,50 @@ warp:
|
||||||
description: te téléporte au Warp d'un autre joueur
|
description: te téléporte au Warp d'un autre joueur
|
||||||
parameters: "<pseudo>"
|
parameters: "<pseudo>"
|
||||||
warps:
|
warps:
|
||||||
deactivate: "&cAncien panneau de Warp désactivé !"
|
deactivate: "&c Ancienne pancarte de warp désactivée !"
|
||||||
error:
|
error:
|
||||||
does-not-exist: "&cCe Warp n'existe plus !"
|
does-not-exist: "&c Oh ! Cette téléportation n'existe plus !"
|
||||||
no-permission: "&cVous n'avez pas la permission pour faire cela !"
|
no-permission: "&c Vous n'avez pas le droit de faire cela !"
|
||||||
no-remove: "&cVous ne pouvez pas supprimer ce panneau !"
|
no-remove: "&c Vous ne pouvez pas enlever cette pancarte !"
|
||||||
no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur."
|
no-warps-yet: "&c Il n'y a pas encore de téléportation disponible"
|
||||||
not-enough-level: "&cVotre niveau d'île n'est pas assez élevé pour faire cela
|
not-enough-level: "&c Le niveau de votre île n'est pas assez élevé !"
|
||||||
!"
|
not-on-island: "&c Vous devez être sur votre île pour faire cela !"
|
||||||
not-on-island: "&cVous devez être sur votre île pour faire cela !"
|
not-safe: "&c Cette téléportation n'est pas sûre !"
|
||||||
not-safe: "&cCe Warp n'est pas sûr!"
|
your-level-is: "&c Le niveau de votre île n'est que [level] et doit être supérieur
|
||||||
your-level-is: "&cVotre île est seulement niveau [level] et doit être niveau [required]."
|
à [required]. Exécutez la commande level."
|
||||||
|
not-correct-rank: "&c Vous n'avez pas le grade adéquat pour poser une chaîne !"
|
||||||
help:
|
help:
|
||||||
description: Ouvre le menu des Warps
|
description: Ouvre le menu des Warps
|
||||||
next: "&6Page suivante"
|
player-warped: "&2 [name] s'est rendu à votre pancarte de téléportation [gamemode]
|
||||||
player-warped: "& 2 [pseudo] s'est téléporté à votre panneau Warp !"
|
!"
|
||||||
previous: "&6Page précédente"
|
sign-removed: "&c Panneau de téléportation enlevé !"
|
||||||
random: "&4 Warp aléatoire "
|
success: "&a Succès !"
|
||||||
sign-removed: "&cPanneau de Warp supprimé !"
|
warpTip: "&6 Placer une pancarte de téléportation avec [text] sur le dessus"
|
||||||
success: "&aSuccès !"
|
warpToPlayersSign: "&6 Téléportation a la pancarte de [player]"
|
||||||
title: Panneau Warp
|
gui:
|
||||||
warpTip: "&6Placez un panneau et écrivez [text] sur la première ligne."
|
titles:
|
||||||
warpToPlayersSign: "&6 Téléportation vers le panneau de [pseudo]"
|
warp-title: "&0&l Pancarte de téléportation"
|
||||||
|
buttons:
|
||||||
|
previous:
|
||||||
|
name: "&f&l Page précédente"
|
||||||
|
description: "&7 Aller à la page [numéro]."
|
||||||
|
next:
|
||||||
|
name: "&f&l Page suivante"
|
||||||
|
description: "&7 Passer à la page [numéro]."
|
||||||
|
warp:
|
||||||
|
name: "&f&l [name]"
|
||||||
|
description: "[sign_text]"
|
||||||
|
random:
|
||||||
|
name: "&f&l Téléportation aléatoire"
|
||||||
|
description: "&7 Hmm, où vais-je apparaître ?"
|
||||||
|
tips:
|
||||||
|
click-to-previous: "&e Cliquez sur &7 pour afficher la page précédente."
|
||||||
|
click-to-next: "&e Cliquez sur &7 pour afficher la page suivante."
|
||||||
|
click-to-warp: "&e Cliquez sur &7 pour te téléporter."
|
||||||
|
conversations:
|
||||||
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: Place téléportation
|
||||||
|
description: Autoriser le placement d'un panneau téléportation
|
||||||
|
|
|
@ -7,22 +7,46 @@ warps:
|
||||||
deactivate: "&c Tanda warp lama dinonaktifkan!"
|
deactivate: "&c Tanda warp lama dinonaktifkan!"
|
||||||
error:
|
error:
|
||||||
does-not-exist: "&c Oh! Warp itu tidak ada lagi!"
|
does-not-exist: "&c Oh! Warp itu tidak ada lagi!"
|
||||||
no-permission: "&c Anda tidak memiliki izin untuk melakukan itu!"
|
no-permission: "&c Kamu tidak punya izin untuk melakukan itu!"
|
||||||
no-remove: "&c Anda tidak dapat menghapus tanda itu!"
|
no-remove: "&c Kamu tidak bisa menghapus tanda itu!"
|
||||||
no-warps-yet: "&c Belum ada warps yang tersedia"
|
no-warps-yet: "&c Belum ada warps yang tersedia"
|
||||||
not-enough-level: "&c Level pulaumu tidak cukup tinggi!"
|
not-enough-level: "&c Level pulaumu tidak cukup tinggi!"
|
||||||
not-on-island: "&c Anda harus berada di pulau Anda untuk melakukan itu!"
|
not-on-island: "&c Kamu harus berada di pulaumu untuk melakukan itu!"
|
||||||
not-safe: "&c Lengkungan itu tidak aman!"
|
not-safe: "&c Warp itu tidak aman!"
|
||||||
your-level-is: "&c Level pulau Anda hanya [level] dan harus lebih tinggi dari
|
your-level-is: "&c Level pulau Anda hanya [level] dan harus lebih tinggi dari
|
||||||
[required]. Jalankan perintah level."
|
[required]. Jalankan perintah level."
|
||||||
|
not-correct-rank: "&c Kamu tidak punya rank yang benar untuk mengatur warp!"
|
||||||
help:
|
help:
|
||||||
description: buka panel warps
|
description: buka panel warps
|
||||||
next: "&6 Halaman berikutnya"
|
player-warped: "&2 [name] nge-warp ke tanda warp [gamemode] kamu!"
|
||||||
player-warped: "&2 [name] mengunjungi tanda warp Anda!"
|
|
||||||
previous: "&6 Halaman sebelumnya"
|
|
||||||
random: "&4 Warp Acak"
|
|
||||||
sign-removed: "&c Tanda warp dihilangkan!"
|
sign-removed: "&c Tanda warp dihilangkan!"
|
||||||
success: "&a Sukses!"
|
success: "&a Sukses!"
|
||||||
title: Tanda Warp
|
|
||||||
warpTip: "&6 Tempatkan tanda warp dengan [text] di atas\n"
|
warpTip: "&6 Tempatkan tanda warp dengan [text] di atas\n"
|
||||||
warpToPlayersSign: "&6 Pergi ke tanda [player]'s"
|
warpToPlayersSign: "&6 Pergi ke tanda [player]"
|
||||||
|
gui:
|
||||||
|
titles:
|
||||||
|
warp-title: "&0&l Tanda Warp"
|
||||||
|
buttons:
|
||||||
|
previous:
|
||||||
|
name: "&f&l Halaman Sebelumnya"
|
||||||
|
description: "&7 Beralih ke halaman [number]"
|
||||||
|
next:
|
||||||
|
name: "&f&l Halaman Selanjutnya"
|
||||||
|
description: "&7 Beralih ke halaman [number]"
|
||||||
|
warp:
|
||||||
|
name: "&f&l [name]"
|
||||||
|
description: "[sign_text]"
|
||||||
|
random:
|
||||||
|
name: "&f&l Warp Acak"
|
||||||
|
description: "&7 Hmm, di mana aku akan muncul?"
|
||||||
|
tips:
|
||||||
|
click-to-previous: "&e Klik &7 untuk melihat halaman sebelumnya."
|
||||||
|
click-to-next: "&e Klik &7 untuk melihat halaman selanjutnya."
|
||||||
|
click-to-warp: "&e Klik &7 untuk warp."
|
||||||
|
conversations:
|
||||||
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: Tempatkan Warp
|
||||||
|
description: Izinkan menempatkan tanda warp
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
---
|
||||||
|
warp:
|
||||||
|
help:
|
||||||
|
description: teleporteer naar een speler zijn warp bord
|
||||||
|
parameters: "<speler>"
|
||||||
|
warps:
|
||||||
|
deactivate: "&c Oude warp bord is gedeactiveerd!"
|
||||||
|
error:
|
||||||
|
does-not-exist: "&c Oh nee! Deze warp bestaat niet meer!"
|
||||||
|
no-permission: "&c Je hebt geen permissies om dit te doen!"
|
||||||
|
no-remove: "&c Je kan dit bord niet weghalen!"
|
||||||
|
no-warps-yet: "&c Er bestaan nog geen warps op dit moment"
|
||||||
|
not-enough-level: "&c Je eiland level is nog niet hoog genoeg!"
|
||||||
|
not-on-island: "&c Je moet een eiland hebben om dit te doen!"
|
||||||
|
not-safe: "&c Deze warp is niet veilig!"
|
||||||
|
your-level-is: "&c Je eiland level is [level], maar het moet op zijn minst [required]
|
||||||
|
zijn. Gebruik het level commando."
|
||||||
|
not-correct-rank: "&c Je hebt niet de correcte rank om een warp te maken!"
|
||||||
|
help:
|
||||||
|
description: open het warp paneel
|
||||||
|
player-warped: "&2 [name] teleporteerde naar jou [gamemode] warp!"
|
||||||
|
sign-removed: "&c Warp bord verwijderd!"
|
||||||
|
success: "&a Geslaagd!"
|
||||||
|
warpTip: "&6 Plaats een warp bord met [text] op de eerste regel"
|
||||||
|
warpToPlayersSign: "&6 Teleporteren naar [player]'s warp"
|
||||||
|
gui:
|
||||||
|
titles:
|
||||||
|
warp-title: "&0&l Warp Borden"
|
||||||
|
buttons:
|
||||||
|
previous:
|
||||||
|
name: "&f&l Vorige pagina"
|
||||||
|
description: "&7 Ga naar pagina [number]"
|
||||||
|
next:
|
||||||
|
name: "&f&l Volgende pagina"
|
||||||
|
description: "&7 Ga naar pagina [number]"
|
||||||
|
warp:
|
||||||
|
name: "&f&l [name]"
|
||||||
|
description: "[sign_text]"
|
||||||
|
random:
|
||||||
|
name: "&f&l Willekeurige Warp"
|
||||||
|
description: "&7 Hmm, waar ga ik heen?"
|
||||||
|
tips:
|
||||||
|
click-to-previous: "&e Klik &7 om naar de vorige pagina te gaan."
|
||||||
|
click-to-next: "&e Klik &7 om naar de volgende pagina te gaan."
|
||||||
|
click-to-warp: "&e Klik &7 om te teleporteren."
|
||||||
|
conversations:
|
||||||
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: Plaats warp
|
||||||
|
description: Staat het toe om een warp bord te plaatsen
|
|
@ -1,27 +1,46 @@
|
||||||
|
---
|
||||||
warp:
|
warp:
|
||||||
help:
|
help:
|
||||||
description: teleportuje cię do tabliczki innego gracza
|
description: teleportuje cię do tabliczki innego gracza
|
||||||
parameters: <gracz>
|
parameters: "<gracz>"
|
||||||
warps:
|
warps:
|
||||||
deactivate: '&c Stary teleport zdezaktywowany!'
|
deactivate: "&c Stary teleport został zdezaktywowany!"
|
||||||
error:
|
error:
|
||||||
does-not-exist: '&c Ten teleport nie istnieje.'
|
does-not-exist: "&c Ten teleport nie istnieje."
|
||||||
no-permission: '&c Brak uprawnień!'
|
no-permission: "&c Brak uprawnień!"
|
||||||
no-remove: '&c Nie możesz usunąć tej tabliczki!'
|
no-remove: "&c Nie możesz usunąć tej tabliczki!"
|
||||||
no-warps-yet: '&c Nie ma jeszcze teleportów.'
|
no-warps-yet: "&c Nie ma jeszcze stworzonych teleportów."
|
||||||
not-enough-level: '&c Twój poziom wyspy nie jest wystarczająco wysoki!'
|
not-enough-level: "&c Twój poziom wyspy nie jest wystarczająco wysoki!"
|
||||||
not-on-island: '&c Musisz być na wyspie, by to zrobić.'
|
not-on-island: "&c Musisz być na wyspie, by to zrobić."
|
||||||
not-safe: '&c Ten teleport nie jest bezpieczny!'
|
not-safe: "&c Ten teleport nie jest bezpieczny!"
|
||||||
your-level-is: '&c Twój poziom wyspy to [level], a musi wynosić co namniej [required].
|
your-level-is: "&c Twój poziom wyspy to [level], a musi wynosić co najmniej [required].
|
||||||
Użyj komendy /is level.'
|
Użyj komendy /is level."
|
||||||
help:
|
help:
|
||||||
description: otwiera panel warpów
|
description: otwiera panel warpów
|
||||||
next: '&6 Następna strona'
|
player-warped: "&2 [name] teleportował się do twojej tabliczki!"
|
||||||
player-warped: '&2 [name] teleportował się do twojej tabliczki!'
|
sign-removed: "&c Usunięto tabliczkę!"
|
||||||
previous: '&6 Poprzednia strona'
|
success: "&a Sukces!"
|
||||||
random: '&4 Losowy teleport'
|
warpTip: "&6 Postaw tabliczkę z napisem [text]"
|
||||||
sign-removed: '&c Usunięto tabliczkę!'
|
warpToPlayersSign: "&6 Teleportowanie do tabliczki gracza [player]"
|
||||||
success: '&a Sukces!'
|
gui:
|
||||||
title: Tabliczki teleportacyjne
|
titles:
|
||||||
warpTip: '&6 Postaw tabliczkę z napisem [text]'
|
warp-title: "&0&l Lista dostępnych wysp"
|
||||||
warpToPlayersSign: '&6 Teleportowanie do tabliczki gracza [player]'
|
buttons:
|
||||||
|
previous:
|
||||||
|
name: "&f&l Poprzednia strona"
|
||||||
|
description: "&7 Przełącz na stronę [number]"
|
||||||
|
next:
|
||||||
|
name: "&f&l następna strona"
|
||||||
|
description: "&7 Przełącz na stronę [number]"
|
||||||
|
warp:
|
||||||
|
name: "&f&l [name]"
|
||||||
|
description: "[sign_text]"
|
||||||
|
random:
|
||||||
|
name: "&f&l Losowa wyspa"
|
||||||
|
description: "&7 Hmm, gdzie się pojawię?"
|
||||||
|
tips:
|
||||||
|
click-to-previous: "&e Kliknij &7, aby wyświetlić poprzednią stronę."
|
||||||
|
click-to-next: "&e Kliknij &7, aby wyświetlić następną stronę."
|
||||||
|
click-to-warp: "&e Kliknij &7, aby przenieść."
|
||||||
|
conversations:
|
||||||
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
---
|
||||||
|
warp:
|
||||||
|
help:
|
||||||
|
description: телепортація на знак варпа гравця
|
||||||
|
parameters: "<player name>"
|
||||||
|
warps:
|
||||||
|
deactivate: "&c Старий знак варпу деактивовано!"
|
||||||
|
error:
|
||||||
|
does-not-exist: "&c О, чорт! Того викривлення більше не існує!"
|
||||||
|
no-permission: "&c Ви не маєте на це дозволу!"
|
||||||
|
no-remove: "&c Ви не можете видалити цей знак!"
|
||||||
|
no-warps-yet: "&c Ще немає доступних варпів"
|
||||||
|
not-enough-level: "&c Рівень вашого острова недостатньо високий!"
|
||||||
|
not-on-island: "&c Для цього ви повинні бути на своєму острові!"
|
||||||
|
not-safe: "&c Ця варп небезпечна!"
|
||||||
|
your-level-is: "&c Рівень вашого острова становить лише [level] і має бути вищим
|
||||||
|
за [required]. Виконайте команду рівня."
|
||||||
|
not-correct-rank: "&c Ви не маєте належного рангу, щоб встановити варп!"
|
||||||
|
help:
|
||||||
|
description: відкрити панель варпів
|
||||||
|
player-warped: "&2 [name] телепортовано до вашого знака варпу [gamemode]!"
|
||||||
|
sign-removed: "&c Знак варпу видалено!"
|
||||||
|
success: "&a Успіх!"
|
||||||
|
warpTip: "&6 Розмістіть знак варпу з [text] угорі"
|
||||||
|
warpToPlayersSign: "&6 Телепортація на знак [player]."
|
||||||
|
gui:
|
||||||
|
titles:
|
||||||
|
warp-title: "&0&l Знаки варпів"
|
||||||
|
buttons:
|
||||||
|
previous:
|
||||||
|
name: "&f&l Попередня сторінка"
|
||||||
|
description: "&7 Перейти на сторінку [number]."
|
||||||
|
next:
|
||||||
|
name: "&f&l Наступна сторінка"
|
||||||
|
description: "&7 Перейти на сторінку [number]."
|
||||||
|
warp:
|
||||||
|
name: "&f&l [name]"
|
||||||
|
description: "[sign_text]"
|
||||||
|
random:
|
||||||
|
name: "&f&l Випадковий варп"
|
||||||
|
description: "&7 Хм, а де я з'явлюся?"
|
||||||
|
tips:
|
||||||
|
click-to-previous: "&e Натисніть &7, щоб переглянути попередню сторінку."
|
||||||
|
click-to-next: "&e Натисніть &7, щоб переглянути наступну сторінку."
|
||||||
|
click-to-warp: "&e Натисніть &7, щоб деформувати."
|
||||||
|
conversations:
|
||||||
|
prefix: "&l&6 [BentoBox]: &r"
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: Розмістіть варп
|
||||||
|
description: Дозволити розміщення варпів
|
|
@ -1,27 +1,60 @@
|
||||||
---
|
# ##########################################################################################
|
||||||
|
# This is a YML file. Be careful when editing. Check your edits in a YAML checker like #
|
||||||
|
# the one at http://yaml-online-parser.appspot.com #
|
||||||
|
# ##########################################################################################
|
||||||
|
|
||||||
warp:
|
warp:
|
||||||
help:
|
help:
|
||||||
description: 传送到该玩家的传送木牌处
|
description: 传送至对应玩家的坐标告示牌
|
||||||
parameters: "<player name>"
|
parameters: <player name>
|
||||||
warps:
|
warps:
|
||||||
help:
|
deactivate: '&c检测到不活跃的坐标告示牌!'
|
||||||
description: 打开传送面板
|
|
||||||
title: 传送木牌
|
|
||||||
deactivate: "&c 旧传送牌已停用!"
|
|
||||||
error:
|
error:
|
||||||
does-not-exist: "&c 哦不!那个传送点已经没了!"
|
does-not-exist: '&c啊哦! 那个传送点已经不存在了!'
|
||||||
no-permission: "&c 你无权那样做!"
|
no-permission: '&c你没有权限做这件事!'
|
||||||
no-remove: "&c 你拿不掉那个牌子的!"
|
no-remove: '&c你不能移除该告示牌!'
|
||||||
no-warps-yet: "&c 暂无可用传送点"
|
no-warps-yet: '&c尚无可用传送点.'
|
||||||
not-enough-level: "&c 你的岛等级不够高!"
|
not-enough-level: '&c你空岛的等级还不够高!'
|
||||||
not-on-island: "&c 你得在自己的岛屿上操作!"
|
not-on-island: '&c你必须在自己的空岛上做这件事!'
|
||||||
not-safe: "&c 目标传送点不安全!"
|
not-safe: '&c该传送点不安全!'
|
||||||
your-level-is: "&c 你的岛现在 [level] 级,需要 [required] 级。 试试岛屿等级命令吧。"
|
your-level-is: '&c你空岛的等级只有[level], 但必须高于[required]. 使用/is level查看等级.'
|
||||||
next: "&6 次页"
|
not-correct-rank: '&c你在团队中的地位不足以让你设立传送点!'
|
||||||
player-warped: "&2 [name] 传送到了你的传送牌!"
|
help:
|
||||||
previous: "&6 前页"
|
description: 打开传送点面板
|
||||||
random: "&4 随机传送"
|
player-warped: '&2 [name]传送到了你[gamemode]的坐标告示牌!'
|
||||||
sign-removed: "&c 拆掉传送牌了!"
|
sign-removed: '&c坐标告示牌已移除!'
|
||||||
success: "&a 成了!"
|
success: '&a成功!'
|
||||||
warpTip: "&6 放个牌子第一行写 [text]"
|
warpTip: '&6放置一个顶部为[text]的坐标告示牌'
|
||||||
warpToPlayersSign: "&6 正传送到 [player] 的牌子"
|
warpToPlayersSign: '&6正在传送至[player]的坐标告示牌'
|
||||||
|
|
||||||
|
gui:
|
||||||
|
titles:
|
||||||
|
# The title of warp panel
|
||||||
|
warp-title: '&0&l坐标告示牌'
|
||||||
|
buttons:
|
||||||
|
# Button that is used in multi-page GUIs which allows to return to previous page.
|
||||||
|
previous:
|
||||||
|
name: '&f&l上一页'
|
||||||
|
description: '&7跳转到第[number]页' # Button that is used in multi-page GUIs which allows to go to next page.
|
||||||
|
next:
|
||||||
|
name: '&f&l下一页'
|
||||||
|
description: '&7跳转到第[number]页' # Button for a warp
|
||||||
|
warp:
|
||||||
|
name: '&f&l [name]'
|
||||||
|
description: '[sign_text]' # Button for a random warp
|
||||||
|
random:
|
||||||
|
name: '&f&l随机传送'
|
||||||
|
description: '&7嗯...我会出现在哪里?'
|
||||||
|
tips:
|
||||||
|
click-to-previous: '&e点击&7 查看上一页.'
|
||||||
|
click-to-next: '&e点击&7 查看下一页.'
|
||||||
|
click-to-warp: '&e点击&7 进行传送.'
|
||||||
|
conversations:
|
||||||
|
# Prefix for messages that are send from server.
|
||||||
|
prefix: '&l&6 [BentoBox]: &r'
|
||||||
|
|
||||||
|
protection:
|
||||||
|
flags:
|
||||||
|
PLACE_WARP:
|
||||||
|
name: 放置传送点
|
||||||
|
description: 允许放置坐标告示牌
|
||||||
|
|
|
@ -19,7 +19,7 @@ warps_panel:
|
||||||
8: warp_button
|
8: warp_button
|
||||||
3:
|
3:
|
||||||
1:
|
1:
|
||||||
icon: TIPPED_ARROW:INSTANT_HEAL::::1
|
icon: tipped_arrow{CustomPotionColor:11546150}
|
||||||
title: warps.gui.buttons.previous.name
|
title: warps.gui.buttons.previous.name
|
||||||
description: warps.gui.buttons.previous.description
|
description: warps.gui.buttons.previous.description
|
||||||
data:
|
data:
|
||||||
|
@ -37,7 +37,7 @@ warps_panel:
|
||||||
7: warp_button
|
7: warp_button
|
||||||
8: warp_button
|
8: warp_button
|
||||||
9:
|
9:
|
||||||
icon: TIPPED_ARROW:JUMP::::1
|
icon: tipped_arrow{CustomPotionColor:8439583}
|
||||||
title: warps.gui.buttons.next.name
|
title: warps.gui.buttons.next.name
|
||||||
description: warps.gui.buttons.next.description
|
description: warps.gui.buttons.next.description
|
||||||
data:
|
data:
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
name: BentoBox-Warps
|
||||||
|
main: world.bentobox.warps.WarpsPladdon
|
||||||
|
version: ${project.version}${build.number}
|
||||||
|
api-version: "1.17"
|
||||||
|
|
||||||
|
authors: [tastybento]
|
||||||
|
contributors: ["The BentoBoxWorld Community"]
|
||||||
|
website: https://bentobox.world
|
||||||
|
description: ${project.description}
|
|
@ -8,7 +8,9 @@ import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -21,11 +23,11 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -40,6 +42,7 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
@ -60,8 +63,8 @@ import world.bentobox.bentobox.managers.PlaceholdersManager;
|
||||||
import world.bentobox.bentobox.managers.PlayersManager;
|
import world.bentobox.bentobox.managers.PlayersManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.warps.config.Settings;
|
import world.bentobox.warps.config.Settings;
|
||||||
|
import world.bentobox.warps.event.WarpCreateEvent;
|
||||||
import world.bentobox.warps.event.WarpInitiateEvent;
|
import world.bentobox.warps.event.WarpInitiateEvent;
|
||||||
import world.bentobox.warps.managers.SignCacheItem;
|
|
||||||
import world.bentobox.warps.managers.SignCacheManager;
|
import world.bentobox.warps.managers.SignCacheManager;
|
||||||
import world.bentobox.warps.managers.WarpSignsManager;
|
import world.bentobox.warps.managers.WarpSignsManager;
|
||||||
import world.bentobox.warps.objects.WarpsData;
|
import world.bentobox.warps.objects.WarpsData;
|
||||||
|
@ -72,7 +75,7 @@ import world.bentobox.warps.objects.WarpsData;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Bukkit.class, Util.class, DatabaseSetup.class, ChatColor.class})
|
@PrepareForTest({Bukkit.class, Util.class, DatabaseSetup.class})
|
||||||
public class WarpSignsManagerTest {
|
public class WarpSignsManagerTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -140,12 +143,15 @@ public class WarpSignsManagerTest {
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
when(player.getUniqueId()).thenReturn(uuid);
|
when(player.getUniqueId()).thenReturn(uuid);
|
||||||
|
when(player.isOnline()).thenReturn(true);
|
||||||
|
when(player.canSee(any(Player.class))).thenReturn(true);
|
||||||
User.setPlugin(plugin);
|
User.setPlugin(plugin);
|
||||||
User.getInstance(player);
|
User.getInstance(player);
|
||||||
|
|
||||||
// Locales
|
// Locales
|
||||||
LocalesManager lm = mock(LocalesManager.class);
|
LocalesManager lm = mock(LocalesManager.class);
|
||||||
when(lm.get(Mockito.any(), Mockito.any())).thenReturn(null);
|
when(lm.getAvailablePrefixes(any())).thenReturn(Collections.emptySet());
|
||||||
|
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||||
// Return the same string
|
// Return the same string
|
||||||
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
||||||
|
@ -202,6 +208,9 @@ public class WarpSignsManagerTest {
|
||||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
when(Tag.STANDING_SIGNS.isTagged(Material.ACACIA_SIGN)).thenReturn(true);
|
||||||
|
|
||||||
// Players Manager
|
// Players Manager
|
||||||
when(plugin.getPlayers()).thenReturn(pm);
|
when(plugin.getPlayers()).thenReturn(pm);
|
||||||
when(pm.getName(uuid)).thenReturn("tastybento");
|
when(pm.getName(uuid)).thenReturn("tastybento");
|
||||||
|
@ -213,6 +222,7 @@ public class WarpSignsManagerTest {
|
||||||
// IWM
|
// IWM
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock.");
|
when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock.");
|
||||||
|
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||||
|
|
||||||
// Island Manager
|
// Island Manager
|
||||||
when(addon.getIslands()).thenReturn(im);
|
when(addon.getIslands()).thenReturn(im);
|
||||||
|
@ -343,7 +353,7 @@ public class WarpSignsManagerTest {
|
||||||
public void testAddWarp() {
|
public void testAddWarp() {
|
||||||
Location loc = mock(Location.class);
|
Location loc = mock(Location.class);
|
||||||
assertTrue(wsm.addWarp(uuid, loc));
|
assertTrue(wsm.addWarp(uuid, loc));
|
||||||
verify(pim).callEvent(any(WarpInitiateEvent.class));
|
verify(pim).callEvent(any(WarpCreateEvent.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,12 +436,47 @@ public class WarpSignsManagerTest {
|
||||||
when(p.getWorld()).thenReturn(world);
|
when(p.getWorld()).thenReturn(world);
|
||||||
when(p.getName()).thenReturn("tastybento");
|
when(p.getName()).thenReturn("tastybento");
|
||||||
when(p.getLocation()).thenReturn(location);
|
when(p.getLocation()).thenReturn(location);
|
||||||
|
when(p.isOnline()).thenReturn(true);
|
||||||
|
when(p.canSee(any(Player.class))).thenReturn(true);
|
||||||
@Nullable
|
@Nullable
|
||||||
User u = User.getInstance(p);
|
User u = User.getInstance(p);
|
||||||
|
PowerMockito.when(Util.teleportAsync(any(), any(), any())).thenReturn(CompletableFuture.completedFuture(true));
|
||||||
wsm.warpPlayer(world, u, uuid);
|
wsm.warpPlayer(world, u, uuid);
|
||||||
PowerMockito.verifyStatic(Util.class);
|
PowerMockito.verifyStatic(Util.class);
|
||||||
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
|
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
|
||||||
verify(player).sendMessage("warps.player-warped");
|
verify(player).sendMessage(anyString());
|
||||||
|
verify(pim).callEvent(any(WarpInitiateEvent.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link WarpSignsManager#warpPlayer(org.bukkit.World, world.bentobox.bentobox.api.user.User, java.util.UUID)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testWarpPlayerEventCancelled() {
|
||||||
|
// Capture the event passed to callEvent
|
||||||
|
ArgumentCaptor<WarpInitiateEvent> eventCaptor = ArgumentCaptor.forClass(WarpInitiateEvent.class);
|
||||||
|
|
||||||
|
// Simulate the event being called and cancelled
|
||||||
|
doAnswer(invocation -> {
|
||||||
|
WarpInitiateEvent event = (WarpInitiateEvent) invocation.getArgument(0);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return null;
|
||||||
|
}).when(pim).callEvent(eventCaptor.capture());
|
||||||
|
|
||||||
|
Player p = mock(Player.class);
|
||||||
|
when(p.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||||
|
when(p.getWorld()).thenReturn(world);
|
||||||
|
when(p.getName()).thenReturn("tastybento");
|
||||||
|
when(p.getLocation()).thenReturn(location);
|
||||||
|
when(p.isOnline()).thenReturn(true);
|
||||||
|
when(p.canSee(any(Player.class))).thenReturn(true);
|
||||||
|
@Nullable
|
||||||
|
User u = User.getInstance(p);
|
||||||
|
PowerMockito.when(Util.teleportAsync(any(), any(), any())).thenReturn(CompletableFuture.completedFuture(true));
|
||||||
|
wsm.warpPlayer(world, u, uuid);
|
||||||
|
PowerMockito.verifyStatic(Util.class, never());
|
||||||
|
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
|
||||||
|
verify(player, never()).sendMessage(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class WarpsCommandTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSetupWarpCompositeCommand() {
|
public void testSetupWarpCompositeCommand() {
|
||||||
warpCommandWarpsCompositeCommand();
|
warpCommandWarpsCompositeCommand();
|
||||||
assertEquals("bskyblock.island.warp", wc.getPermission());
|
assertEquals("bskyblock.island.warps", wc.getPermission());
|
||||||
assertTrue(wc.isOnlyPlayer());
|
assertTrue(wc.isOnlyPlayer());
|
||||||
assertEquals("warps.help.description", wc.getDescription());
|
assertEquals("warps.help.description", wc.getDescription());
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ public class WarpsCommandTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSetupWarp() {
|
public void testSetupWarp() {
|
||||||
warpCommandWarps();
|
warpCommandWarps();
|
||||||
assertEquals(Warp.WELCOME_WARP_SIGNS + ".warp", wc.getPermission());
|
assertEquals(Warp.WELCOME_WARP_SIGNS + ".warps", wc.getPermission());
|
||||||
assertTrue(wc.isOnlyPlayer());
|
assertTrue(wc.isOnlyPlayer());
|
||||||
assertEquals("warps.help.description", wc.getDescription());
|
assertEquals("warps.help.description", wc.getDescription());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -44,7 +41,10 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
|
import world.bentobox.bentobox.api.events.flags.FlagProtectionChangeEvent;
|
||||||
|
import world.bentobox.bentobox.api.flags.Flag;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||||
import world.bentobox.bentobox.managers.IslandsManager;
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
import world.bentobox.bentobox.managers.LocalesManager;
|
import world.bentobox.bentobox.managers.LocalesManager;
|
||||||
|
@ -83,6 +83,8 @@ public class WarpSignsListenerTest {
|
||||||
private IslandsManager im;
|
private IslandsManager im;
|
||||||
@Mock
|
@Mock
|
||||||
private IslandWorldManager iwm;
|
private IslandWorldManager iwm;
|
||||||
|
@Mock
|
||||||
|
private Island island;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
@ -148,6 +150,9 @@ public class WarpSignsListenerTest {
|
||||||
when(settings.getWelcomeLine()).thenReturn("[WELCOME]");
|
when(settings.getWelcomeLine()).thenReturn("[WELCOME]");
|
||||||
when(addon.getSettings()).thenReturn(settings);
|
when(addon.getSettings()).thenReturn(settings);
|
||||||
|
|
||||||
|
island = mock(Island.class);
|
||||||
|
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||||
|
|
||||||
// On island
|
// On island
|
||||||
when(plugin.getIslands()).thenReturn(im);
|
when(plugin.getIslands()).thenReturn(im);
|
||||||
when(im.userIsOnIsland(any(World.class), any(User.class))).thenReturn(true);
|
when(im.userIsOnIsland(any(World.class), any(User.class))).thenReturn(true);
|
||||||
|
@ -299,6 +304,54 @@ public class WarpSignsListenerTest {
|
||||||
assertEquals(ChatColor.GREEN + "[WELCOME]", e.getLine(0));
|
assertEquals(ChatColor.GREEN + "[WELCOME]", e.getLine(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnCreateWithoutCorrectRankNotAllowed() {
|
||||||
|
WarpSignsListener wsl = new WarpSignsListener(addon);
|
||||||
|
SignChangeEvent e = new SignChangeEvent(block, player, lines);
|
||||||
|
when(player.hasPermission(anyString())).thenReturn(true);
|
||||||
|
when(addon.inRegisteredWorld(any())).thenReturn(true);
|
||||||
|
when(island.getRank(player.getUniqueId())).thenReturn(0);
|
||||||
|
when(island.getFlag(any())).thenReturn(1000);
|
||||||
|
wsl.onSignWarpCreate(e);
|
||||||
|
verify(player).sendMessage("warps.error.not-correct-rank");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnFlagChangeWhenSettingIsOffNothingHappens() {
|
||||||
|
Flag flag = mock(Flag.class);
|
||||||
|
|
||||||
|
when(addon.getCreateWarpFlag()).thenReturn(flag);
|
||||||
|
when(settings.getRemoveExistingWarpsWhenFlagChanges()).thenReturn(false);
|
||||||
|
WarpSignsListener wsl = new WarpSignsListener(addon);
|
||||||
|
|
||||||
|
FlagProtectionChangeEvent e = new FlagProtectionChangeEvent(island, player.getUniqueId(), flag, 1000);
|
||||||
|
|
||||||
|
wsl.onFlagChange(e);
|
||||||
|
|
||||||
|
verifyNoInteractions(island);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnFlagChangeWhenSettingIsOnWarpGetsRemoved() {
|
||||||
|
Flag flag = mock(Flag.class);
|
||||||
|
|
||||||
|
when(addon.getCreateWarpFlag()).thenReturn(flag);
|
||||||
|
when(settings.getRemoveExistingWarpsWhenFlagChanges()).thenReturn(true);
|
||||||
|
WarpSignsListener wsl = new WarpSignsListener(addon);
|
||||||
|
|
||||||
|
Map<UUID, Location> warps = Map.of(
|
||||||
|
player.getUniqueId(), block.getLocation()
|
||||||
|
);
|
||||||
|
|
||||||
|
when(wsm.getWarpMap(any())).thenReturn(warps);
|
||||||
|
when(island.inIslandSpace(any(Location.class))).thenReturn(true);
|
||||||
|
|
||||||
|
FlagProtectionChangeEvent e = new FlagProtectionChangeEvent(island, player.getUniqueId(), flag, 1000);
|
||||||
|
|
||||||
|
wsl.onFlagChange(e);
|
||||||
|
verify(addon.getWarpSignsManager()).removeWarp(any(), any());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnCreateNotGameWorldNotAllowed() {
|
public void testOnCreateNotGameWorldNotAllowed() {
|
||||||
when(settings.isAllowInOtherWorlds()).thenReturn(false);
|
when(settings.isAllowInOtherWorlds()).thenReturn(false);
|
||||||
|
|
Loading…
Reference in New Issue