mirror of
https://github.com/BentoBoxWorld/Warps.git
synced 2025-02-20 06:12:35 +01:00
commit
4ae619c261
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -14,11 +14,11 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
- name: Set up JDK 16
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '16'
|
||||
java-version: '17'
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
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>1.23.0</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.13.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.7</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
|
||||
|
@ -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());
|
||||
|
@ -27,7 +27,6 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
@ -246,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();
|
||||
@ -321,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
|
||||
{
|
||||
@ -351,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
52
src/main/resources/locales/nl.yml
Normal file
52
src/main/resources/locales/nl.yml
Normal file
@ -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 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 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."
|
||||
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: "[sing_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"
|
||||
|
9
src/main/resources/plugin.yml
Normal file
9
src/main/resources/plugin.yml
Normal file
@ -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,7 +21,6 @@ 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;
|
||||
@ -61,7 +60,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 +70,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 +138,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);
|
||||
@ -213,6 +214,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 +428,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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
Block a user