Compare commits
49 Commits
Author | SHA1 | Date |
---|---|---|
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
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '16'
|
||||
java-version: '17'
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
|
|
25
pom.xml
25
pom.xml
|
@ -54,19 +54,19 @@
|
|||
<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>
|
||||
<!-- Non-minecraft related dependencies -->
|
||||
<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.18.0-SNAPSHOT</bentobox.version>
|
||||
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
|
||||
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
|
||||
<level.version>2.7.0-SNAPSHOT</level.version>
|
||||
<!-- Revision variable removes warning about dynamic version -->
|
||||
<revision>${build.version}-SNAPSHOT</revision>
|
||||
<!-- 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.12.0</build.version>
|
||||
<build.version>1.15.0</build.version>
|
||||
<!-- Sonar Cloud -->
|
||||
<sonar.projectKey>BentoBoxWorld_Warps</sonar.projectKey>
|
||||
<sonar.organization>bentobox-world</sonar.organization>
|
||||
|
@ -138,11 +138,6 @@
|
|||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>plugin-annotations</artifactId>
|
||||
<version>1.2.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- Mockito (Unit testing) -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
|
@ -234,6 +229,7 @@
|
|||
<version>3.0.0-M5</version>
|
||||
<configuration>
|
||||
<argLine>
|
||||
${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
|
||||
|
@ -316,7 +312,7 @@
|
|||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.3</version>
|
||||
<version>0.8.10</version>
|
||||
<configuration>
|
||||
<append>true</append>
|
||||
<excludes>
|
||||
|
@ -327,16 +323,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>
|
||||
|
|
|
@ -7,10 +7,14 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
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.level.Level;
|
||||
import world.bentobox.warps.commands.WarpCommand;
|
||||
|
@ -71,6 +75,11 @@ public class Warp extends Addon {
|
|||
*/
|
||||
private Config<Settings> settingsConfig;
|
||||
|
||||
/**
|
||||
* Create Warp Flag
|
||||
*/
|
||||
private Flag createWarpFlag;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Methods
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -146,6 +155,18 @@ public class Warp extends Addon {
|
|||
logWarning("Addon did not hook into anything and is not running stand-alone");
|
||||
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 the createWarpFlag
|
||||
*/
|
||||
public Flag getCreateWarpFlag() {
|
||||
return createWarpFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the island level
|
||||
* @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("");
|
||||
return this.getPlugin().getAddonsManager().getAddonByName(LEVEL_ADDON_NAME)
|
||||
.map(l -> {
|
||||
if (!name.isEmpty() && ((Level) l).getSettings().getGameModes().contains(name)) {
|
||||
return ((Level) l).getIslandLevel(world, uniqueId);
|
||||
final Level addon = (Level) l;
|
||||
//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;
|
||||
}).orElse(null);
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
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.Pladdon;
|
||||
|
||||
@Plugin(name="Pladdon", version="1.0")
|
||||
@ApiVersion(ApiVersion.Target.v1_16)
|
||||
@Dependency(value = "BentoBox")
|
||||
|
||||
public class WarpsPladdon extends Pladdon {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class WarpsCommand extends CompositeCommand {
|
|||
*/
|
||||
@Override
|
||||
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.setDescription("warps.help.description");
|
||||
}
|
||||
|
|
|
@ -23,6 +23,13 @@ public class Settings implements ConfigObject
|
|||
@ConfigEntry(path = "warplevelrestriction")
|
||||
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("Text that player must put on sign to make it a warp sign")
|
||||
@ConfigComment("Not case sensitive!")
|
||||
|
@ -55,7 +62,6 @@ public class Settings implements ConfigObject
|
|||
@ConfigEntry(path = "warps-command")
|
||||
String warpsCommand = "warps";
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Constructor
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -198,4 +204,18 @@ public class Settings implements ConfigObject
|
|||
public void setWarpsCommand(String 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package world.bentobox.warps.listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -25,9 +22,11 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
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.TeamLeaveEvent;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.warps.Warp;
|
||||
import world.bentobox.warps.event.WarpRemoveEvent;
|
||||
|
@ -114,7 +113,6 @@ public class WarpSignsListener implements Listener {
|
|||
return;
|
||||
}
|
||||
User user = User.getInstance(e.getPlayer());
|
||||
if (user == null) return;
|
||||
UUID owner = addon.getWarpSignsManager().getWarpOwnerUUID(b.getLocation()).orElse(null);
|
||||
if (isPlayersSign(e.getPlayer(), b, inWorld)) {
|
||||
addon.getWarpSignsManager().removeWarp(b.getLocation());
|
||||
|
@ -164,6 +162,13 @@ public class WarpSignsListener implements Listener {
|
|||
e.setLine(0, ChatColor.RED + addon.getSettings().getWelcomeLine());
|
||||
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
|
||||
final Location oldSignLoc = addon.getWarpSignsManager().getWarp(b.getWorld(), user.getUniqueId());
|
||||
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) {
|
||||
// Get level if level addon is available
|
||||
Long level = addon.getLevel(Util.getWorld(world), user.getUniqueId());
|
||||
|
|
|
@ -21,12 +21,12 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
|
@ -200,15 +200,15 @@ public class WarpSignsManager {
|
|||
warpsData = handler.loadObject(WARPS);
|
||||
// Load into map
|
||||
if (warpsData != null) {
|
||||
warpsData.getWarpSigns().forEach((k,v) -> {
|
||||
if (k != null && k.getWorld() != null) {
|
||||
if (k.getWorld().isChunkLoaded(k.getBlockX() >> 4, k.getBlockZ() >> 4)
|
||||
&& !k.getBlock().getType().name().contains("SIGN")) {
|
||||
warpsData.getWarpSigns().forEach((location,uuid) -> {
|
||||
if (location != null && location.getWorld() != null) {
|
||||
if (location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)
|
||||
&& !location.getBlock().getType().name().contains("SIGN")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to map
|
||||
getWarpMap(k.getWorld()).put(v, k);
|
||||
getWarpMap(location.getWorld()).put(uuid, location);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -245,8 +245,8 @@ public class WarpSignsManager {
|
|||
if (en.getValue().equals(loc)) {
|
||||
// Inform player
|
||||
Optional.ofNullable(addon.getServer().getPlayer(en.getKey()))
|
||||
.map(User::getInstance)
|
||||
.ifPresent(user -> user.sendMessage("warps.sign-removed"));
|
||||
.map(User::getInstance)
|
||||
.ifPresent(user -> user.sendMessage("warps.sign-removed"));
|
||||
// Remove sign from warp panel cache
|
||||
addon.getSignCacheManager().removeWarp(loc.getWorld(), en.getKey());
|
||||
it.remove();
|
||||
|
@ -320,8 +320,8 @@ public class WarpSignsManager {
|
|||
if (!prefix.isEmpty())
|
||||
{
|
||||
icon = Material.matchMaterial(
|
||||
Utils.getPermissionValue(User.getInstance(uuid), prefix + "island.warp",
|
||||
Material.OAK_SIGN.name()));
|
||||
Utils.getPermissionValue(User.getInstance(uuid), prefix + "island.warp",
|
||||
Material.OAK_SIGN.name()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -350,21 +350,33 @@ public class WarpSignsManager {
|
|||
float yaw = Util.blockFaceToFloat(directionFacing);
|
||||
final Location actualWarp = new Location(inFront.getWorld(), inFront.getBlockX() + 0.5D, inFront.getBlockY(),
|
||||
inFront.getBlockZ() + 0.5D, yaw, 30F);
|
||||
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND);
|
||||
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)) {
|
||||
warpOwner.sendMessage("warps.player-warped", "[name]", user.getName());
|
||||
}
|
||||
//BentoBox prevents people from teleporting to an island when
|
||||
//the user is banned from the island for example.
|
||||
//By checking if the teleport succeeded before sending the messages,
|
||||
//we prevent issues where no one teleported, but people still
|
||||
//get messages about it.
|
||||
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND).thenAccept(tpResult -> {
|
||||
if(Boolean.FALSE.equals(tpResult)) return;
|
||||
|
||||
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 +424,7 @@ public class WarpSignsManager {
|
|||
}
|
||||
// Find out which direction the warp is facing
|
||||
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();
|
||||
BlockFace directionFacing = s.getFacing();
|
||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||
|
@ -425,7 +437,13 @@ public class WarpSignsManager {
|
|||
warpPlayer(user, oneDown, owner, directionFacing, pvp);
|
||||
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();
|
||||
BlockFace directionFacing = s.getRotation();
|
||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||
|
|
|
@ -10,7 +10,10 @@ softdepend: AcidIsland, BSkyBlock, CaveBlock, SkyGrid, AOneBlock
|
|||
|
||||
permissions:
|
||||
'[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
|
||||
'[gamemode].island.addwarp':
|
||||
description: Player can create a welcome warp sign
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
# Warp Restriction - needed levels to be able to create a warp
|
||||
# 0 or negative values will disable this restriction 10 is default
|
||||
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
|
||||
# Not case sensitive!
|
||||
|
|
|
@ -18,9 +18,10 @@ warps:
|
|||
not-on-island: "&c You must be on your island to do that!"
|
||||
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."
|
||||
help:
|
||||
not-correct-rank: "&c You do not have the correct rank to set a warp!"
|
||||
help:
|
||||
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!"
|
||||
success: "&a Success!"
|
||||
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: "&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 #
|
||||
# el de http://yaml-online-parser.appspot.com #
|
||||
###########################################################################################################
|
||||
|
||||
warp:
|
||||
help:
|
||||
description: "Teletransportarte hacia el warp del jugador"
|
||||
parameters: <player name>
|
||||
warps:
|
||||
deactivate: "&c¡El cartel viejo ha sido desactivado!"
|
||||
error:
|
||||
does-not-exist: "&c¡Oh vaya! !Ese warp ya no existe!"
|
||||
no-permission: "&c¡No tienes permiso para hacer eso!"
|
||||
no-remove: "&c¡No puedes quitar ese cartel!"
|
||||
no-warps-yet: "&cNo hay warps disponibles aún"
|
||||
not-enough-level: "&c¡Tu nivel de isla no es lo suficientemente alto!"
|
||||
not-on-island: "&c¡Debes estar en tu isla para hacer eso!"
|
||||
not-safe: "&c¡Ese warp no es seguro!"
|
||||
your-level-is: "&cTu nivel de isla es solo [level] y debe ser mayor que [required]"
|
||||
help:
|
||||
description: "Abre el panel de warps"
|
||||
next: "&6Siguiente página"
|
||||
player-warped: "&2[name] ¡se ha teletransportado a tu warp!"
|
||||
previous: "&6Página anterior"
|
||||
random: "&4Teletransporte aleatorio"
|
||||
sign-removed: "&c¡Cartel removido!"
|
||||
success: "&a¡Éxito!"
|
||||
title: "Carteles de Warps"
|
||||
warpTip: "&6Coloca un cartel que contenga el texto [text] arriba"
|
||||
warpToPlayersSign: "&6Teletransportandote al warp de [player]"
|
||||
---
|
||||
warp:
|
||||
help:
|
||||
description: Teletransportarte hacia el warp del jugador
|
||||
parameters: "<player name>"
|
||||
warps:
|
||||
deactivate: "&c ¡Antiguo cartel de teletransportación desactivado!"
|
||||
error:
|
||||
does-not-exist: "&c ¡Oh, chasquido! ¡Ese teletransporte ya no existe!"
|
||||
no-permission: "&c ¡No tienes permisos para hacer eso!"
|
||||
no-remove: "&c ¡No puedes quitar ese cartel!"
|
||||
no-warps-yet: "&c No hay teletransportes disponibles todavía"
|
||||
not-enough-level: "&c ¡Tu nivel de isla no es lo suficientemente alto!"
|
||||
not-on-island: "&c ¡Debes estar en tu isla para hacer eso!"
|
||||
not-safe: "&c ¡Ese teletransporte no es seguro!"
|
||||
your-level-is: "&c Tu nivel de isla es solo [level] y debe ser mayor que [required].
|
||||
Ejecuta el comando de nivel."
|
||||
not-correct-rank: "&c ¡No tienes el rango correcto para crear un teletransporte!"
|
||||
help:
|
||||
description: Abre el panel de warps
|
||||
player-warped: "&2 [name] se ha teletransportado a tu cartel de teletransportación
|
||||
de [gamemode]!"
|
||||
sign-removed: "&c Cartel de teletransportación eliminado!"
|
||||
success: "&a Éxito!"
|
||||
warpTip: "&6 Coloca un cartel con [text] en la parte superior"
|
||||
warpToPlayersSign: "&6 Teletransportandote al cartel del jugador [player]"
|
||||
gui:
|
||||
titles:
|
||||
warp-title: "&0&l Carteles de Teletransporte"
|
||||
buttons:
|
||||
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
|
||||
|
|
|
@ -7,22 +7,46 @@ warps:
|
|||
deactivate: "&c Tanda warp lama dinonaktifkan!"
|
||||
error:
|
||||
does-not-exist: "&c Oh! Warp itu tidak ada lagi!"
|
||||
no-permission: "&c Anda tidak memiliki izin untuk melakukan itu!"
|
||||
no-remove: "&c Anda tidak dapat menghapus tanda itu!"
|
||||
no-permission: "&c Kamu tidak punya izin untuk melakukan itu!"
|
||||
no-remove: "&c Kamu tidak bisa menghapus tanda itu!"
|
||||
no-warps-yet: "&c Belum ada warps yang tersedia"
|
||||
not-enough-level: "&c Level pulaumu tidak cukup tinggi!"
|
||||
not-on-island: "&c Anda harus berada di pulau Anda untuk melakukan itu!"
|
||||
not-safe: "&c Lengkungan itu tidak aman!"
|
||||
not-on-island: "&c Kamu harus berada di pulaumu untuk melakukan itu!"
|
||||
not-safe: "&c Warp itu tidak aman!"
|
||||
your-level-is: "&c Level pulau Anda hanya [level] dan harus lebih tinggi dari
|
||||
[required]. Jalankan perintah level."
|
||||
not-correct-rank: "&c Kamu tidak punya rank yang benar untuk mengatur warp!"
|
||||
help:
|
||||
description: buka panel warps
|
||||
next: "&6 Halaman berikutnya"
|
||||
player-warped: "&2 [name] mengunjungi tanda warp Anda!"
|
||||
previous: "&6 Halaman sebelumnya"
|
||||
random: "&4 Warp Acak"
|
||||
player-warped: "&2 [name] nge-warp ke tanda warp [gamemode] kamu!"
|
||||
sign-removed: "&c Tanda warp dihilangkan!"
|
||||
success: "&a Sukses!"
|
||||
title: Tanda Warp
|
||||
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:
|
||||
help:
|
||||
description: teleportuje cię do tabliczki innego gracza
|
||||
parameters: <gracz>
|
||||
parameters: "<gracz>"
|
||||
warps:
|
||||
deactivate: '&c Stary teleport zdezaktywowany!'
|
||||
deactivate: "&c Stary teleport został zdezaktywowany!"
|
||||
error:
|
||||
does-not-exist: '&c Ten teleport nie istnieje.'
|
||||
no-permission: '&c Brak uprawnień!'
|
||||
no-remove: '&c Nie możesz usunąć tej tabliczki!'
|
||||
no-warps-yet: '&c Nie ma jeszcze teleportów.'
|
||||
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-safe: '&c Ten teleport nie jest bezpieczny!'
|
||||
your-level-is: '&c Twój poziom wyspy to [level], a musi wynosić co namniej [required].
|
||||
Użyj komendy /is level.'
|
||||
does-not-exist: "&c Ten teleport nie istnieje."
|
||||
no-permission: "&c Brak uprawnień!"
|
||||
no-remove: "&c Nie możesz usunąć tej tabliczki!"
|
||||
no-warps-yet: "&c Nie ma jeszcze stworzonych teleportów."
|
||||
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-safe: "&c Ten teleport nie jest bezpieczny!"
|
||||
your-level-is: "&c Twój poziom wyspy to [level], a musi wynosić co najmniej [required].
|
||||
Użyj komendy /is level."
|
||||
help:
|
||||
description: otwiera panel warpów
|
||||
next: '&6 Następna strona'
|
||||
player-warped: '&2 [name] teleportował się do twojej tabliczki!'
|
||||
previous: '&6 Poprzednia strona'
|
||||
random: '&4 Losowy teleport'
|
||||
sign-removed: '&c Usunięto tabliczkę!'
|
||||
success: '&a Sukces!'
|
||||
title: Tabliczki teleportacyjne
|
||||
warpTip: '&6 Postaw tabliczkę z napisem [text]'
|
||||
warpToPlayersSign: '&6 Teleportowanie do tabliczki gracza [player]'
|
||||
player-warped: "&2 [name] teleportował się do twojej tabliczki!"
|
||||
sign-removed: "&c Usunięto tabliczkę!"
|
||||
success: "&a Sukces!"
|
||||
warpTip: "&6 Postaw tabliczkę z napisem [text]"
|
||||
warpToPlayersSign: "&6 Teleportowanie do tabliczki gracza [player]"
|
||||
gui:
|
||||
titles:
|
||||
warp-title: "&0&l Lista dostępnych wysp"
|
||||
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: Дозволити розміщення варпів
|
|
@ -19,7 +19,7 @@ warps_panel:
|
|||
8: warp_button
|
||||
3:
|
||||
1:
|
||||
icon: TIPPED_ARROW:INSTANT_HEAL::::1
|
||||
icon: tipped_arrow{CustomPotionColor:11546150}
|
||||
title: warps.gui.buttons.previous.name
|
||||
description: warps.gui.buttons.previous.description
|
||||
data:
|
||||
|
@ -37,7 +37,7 @@ warps_panel:
|
|||
7: warp_button
|
||||
8: warp_button
|
||||
9:
|
||||
icon: TIPPED_ARROW:JUMP::::1
|
||||
icon: tipped_arrow{CustomPotionColor:8439583}
|
||||
title: warps.gui.buttons.next.name
|
||||
description: warps.gui.buttons.next.description
|
||||
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}
|
|
@ -21,11 +21,11 @@ import java.util.concurrent.CompletableFuture;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -61,7 +61,6 @@ import world.bentobox.bentobox.managers.PlayersManager;
|
|||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.warps.config.Settings;
|
||||
import world.bentobox.warps.event.WarpInitiateEvent;
|
||||
import world.bentobox.warps.managers.SignCacheItem;
|
||||
import world.bentobox.warps.managers.SignCacheManager;
|
||||
import world.bentobox.warps.managers.WarpSignsManager;
|
||||
import world.bentobox.warps.objects.WarpsData;
|
||||
|
@ -72,7 +71,7 @@ import world.bentobox.warps.objects.WarpsData;
|
|||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class, Util.class, DatabaseSetup.class, ChatColor.class})
|
||||
@PrepareForTest({Bukkit.class, Util.class, DatabaseSetup.class})
|
||||
public class WarpSignsManagerTest {
|
||||
|
||||
@Mock
|
||||
|
@ -140,12 +139,15 @@ public class WarpSignsManagerTest {
|
|||
|
||||
// Player
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
when(player.isOnline()).thenReturn(true);
|
||||
when(player.canSee(any(Player.class))).thenReturn(true);
|
||||
User.setPlugin(plugin);
|
||||
User.getInstance(player);
|
||||
|
||||
// Locales
|
||||
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);
|
||||
// Return the same string
|
||||
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
||||
|
@ -202,6 +204,9 @@ public class WarpSignsManagerTest {
|
|||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
// Tags
|
||||
when(Tag.STANDING_SIGNS.isTagged(Material.ACACIA_SIGN)).thenReturn(true);
|
||||
|
||||
// Players Manager
|
||||
when(plugin.getPlayers()).thenReturn(pm);
|
||||
when(pm.getName(uuid)).thenReturn("tastybento");
|
||||
|
@ -213,6 +218,7 @@ public class WarpSignsManagerTest {
|
|||
// IWM
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock.");
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
|
||||
// Island Manager
|
||||
when(addon.getIslands()).thenReturn(im);
|
||||
|
@ -426,12 +432,15 @@ public class WarpSignsManagerTest {
|
|||
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);
|
||||
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
|
||||
verify(player).sendMessage("warps.player-warped");
|
||||
verify(player).sendMessage(anyString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -123,7 +123,7 @@ public class WarpsCommandTest {
|
|||
@Test
|
||||
public void testSetupWarpCompositeCommand() {
|
||||
warpCommandWarpsCompositeCommand();
|
||||
assertEquals("bskyblock.island.warp", wc.getPermission());
|
||||
assertEquals("bskyblock.island.warps", wc.getPermission());
|
||||
assertTrue(wc.isOnlyPlayer());
|
||||
assertEquals("warps.help.description", wc.getDescription());
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class WarpsCommandTest {
|
|||
@Test
|
||||
public void testSetupWarp() {
|
||||
warpCommandWarps();
|
||||
assertEquals(Warp.WELCOME_WARP_SIGNS + ".warp", wc.getPermission());
|
||||
assertEquals(Warp.WELCOME_WARP_SIGNS + ".warps", wc.getPermission());
|
||||
assertTrue(wc.isOnlyPlayer());
|
||||
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.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -44,7 +41,10 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
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.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
|
@ -83,6 +83,8 @@ public class WarpSignsListenerTest {
|
|||
private IslandsManager im;
|
||||
@Mock
|
||||
private IslandWorldManager iwm;
|
||||
@Mock
|
||||
private Island island;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
@ -148,6 +150,9 @@ public class WarpSignsListenerTest {
|
|||
when(settings.getWelcomeLine()).thenReturn("[WELCOME]");
|
||||
when(addon.getSettings()).thenReturn(settings);
|
||||
|
||||
island = mock(Island.class);
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// On island
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
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));
|
||||
}
|
||||
|
||||
@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
|
||||
public void testOnCreateNotGameWorldNotAllowed() {
|
||||
when(settings.isAllowInOtherWorlds()).thenReturn(false);
|
||||
|
|
Loading…
Reference in New Issue