mirror of
https://github.com/BentoBoxWorld/Warps.git
synced 2024-11-21 18:15:17 +01:00
Merge remote-tracking branch 'origin/develop'
Conflicts: .gitignore
This commit is contained in:
commit
c62de9d021
92
.gitignore
vendored
92
.gitignore
vendored
@ -1,4 +1,88 @@
|
||||
/target/
|
||||
/.DS_Store
|
||||
/.classpath
|
||||
/.project
|
||||
# Git
|
||||
*.orig
|
||||
!.gitignore
|
||||
/.settings/
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
*.stackdump
|
||||
[Dd]esktop.ini
|
||||
$RECYCLE.BIN/
|
||||
*.lnk
|
||||
|
||||
# Linux
|
||||
*~
|
||||
.fuse_hidden*
|
||||
.directory
|
||||
.Trash-*
|
||||
.nfs*
|
||||
|
||||
# MacOS
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
._*
|
||||
|
||||
# Java
|
||||
*.class
|
||||
*.log
|
||||
*.ctxt
|
||||
.mtj.tmp/
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
hs_err_pid*
|
||||
|
||||
# Maven
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
# Intellij
|
||||
*.iml
|
||||
*.java___jb_tmp___
|
||||
.idea/*
|
||||
*.ipr
|
||||
*.iws
|
||||
/out/
|
||||
.idea_modules/
|
||||
|
||||
# Eclipse
|
||||
*.pydevproject
|
||||
.metadata
|
||||
.gradle
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.project
|
||||
.externalToolBuilders/
|
||||
*.launch
|
||||
.cproject
|
||||
.classpath
|
||||
.buildpath
|
||||
.target
|
||||
|
||||
# NetBeans
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
|
20
pom.xml
20
pom.xml
@ -8,9 +8,9 @@
|
||||
<artifactId>warps</artifactId>
|
||||
<version>${revision}</version>
|
||||
|
||||
<name>WelcomeWarpSigns</name>
|
||||
<description>WelcomeWarpSigns is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland.</description>
|
||||
<url>https://github.com/BentoBoxWorld/addon-welcomewarpsigns</url>
|
||||
<name>Warps</name>
|
||||
<description>Warps is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland.</description>
|
||||
<url>https://github.com/BentoBoxWorld/Warps</url>
|
||||
<inceptionYear>2018</inceptionYear>
|
||||
|
||||
<developers>
|
||||
@ -25,19 +25,19 @@
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/BentoBoxWorld/addon-welcomewarpsigns.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:BentoBoxWorld/addon-welcomewarpsigns.git</developerConnection>
|
||||
<url>https://github.com/BentoBoxWorld/addon-welcomewarpsigns</url>
|
||||
<connection>scm:git:https://github.com/BentoBoxWorld/Warps.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:BentoBoxWorld/Warps.git</developerConnection>
|
||||
<url>https://github.com/BentoBoxWorld/Warps</url>
|
||||
</scm>
|
||||
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://ci.codemc.org/job/BentoBoxWorld/job/addon-welcomewarpsigns</url>
|
||||
<url>http://ci.codemc.org/job/BentoBoxWorld/job/Warps</url>
|
||||
</ciManagement>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/BentoBoxWorld/addon-welcomewarpsigns/issues</url>
|
||||
<url>https://github.com/BentoBoxWorld/Warps/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<distributionManagement>
|
||||
@ -66,7 +66,7 @@
|
||||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>1.9.1</build.version>
|
||||
<build.version>1.9.3</build.version>
|
||||
</properties>
|
||||
|
||||
<!-- Profiles will allow to automatically change build version. -->
|
||||
@ -331,4 +331,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
@ -4,19 +4,23 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* Stores info on a warp sign
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class SignCache {
|
||||
public class SignCacheItem {
|
||||
@Expose
|
||||
private final List<String> signText;
|
||||
@Expose
|
||||
private final Material type;
|
||||
/**
|
||||
* @param signText
|
||||
* @param type
|
||||
*/
|
||||
public SignCache(List<String> signText, Material type) {
|
||||
public SignCacheItem(List<String> signText, Material type) {
|
||||
this.signText = signText;
|
||||
this.type = type;
|
||||
}
|
79
src/main/java/world/bentobox/warps/SignCacheManager.java
Normal file
79
src/main/java/world/bentobox/warps/SignCacheManager.java
Normal file
@ -0,0 +1,79 @@
|
||||
package world.bentobox.warps;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import world.bentobox.bentobox.database.Database;
|
||||
import world.bentobox.warps.objects.SignCache;
|
||||
|
||||
public class SignCacheManager {
|
||||
private Map<World, Map<UUID, SignCacheItem>> cachedSigns = new HashMap<>();
|
||||
private Warp addon;
|
||||
// Database handler for level data
|
||||
private Database<SignCache> handler;
|
||||
|
||||
public SignCacheManager(Warp addon) {
|
||||
this.addon = addon;
|
||||
handler = new Database<>(addon, SignCache.class);
|
||||
// Load the sign caches
|
||||
loadCache();
|
||||
}
|
||||
|
||||
private void loadCache() {
|
||||
handler.loadObjects().forEach(w -> {
|
||||
World world = Bukkit.getWorld(w.getUniqueId());
|
||||
if (world != null) {
|
||||
cachedSigns.put(world, w.getSigns());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void saveCache() {
|
||||
cachedSigns.forEach((w, m) -> handler.saveObject(new SignCache(w, m)));
|
||||
}
|
||||
|
||||
Material getSignIcon(World world, UUID warpOwner) {
|
||||
// Add the worlds if we haven't seen this before
|
||||
cachedSigns.putIfAbsent(world, new HashMap<>());
|
||||
if (cachedSigns.get(world).containsKey(warpOwner)) {
|
||||
return cachedSigns.get(world).get(warpOwner).getType();
|
||||
}
|
||||
// Not in cache
|
||||
SignCacheItem sc = addon.getWarpSignsManager().getSignInfo(world, warpOwner);
|
||||
cachedSigns.get(world).put(warpOwner, sc);
|
||||
return sc.getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sign text and cache it
|
||||
* @param playerUUID
|
||||
* @return sign text in a list
|
||||
*/
|
||||
List<String> getSign(World world, UUID playerUUID) {
|
||||
// Add the worlds if we haven't seen this before
|
||||
cachedSigns.putIfAbsent(world, new HashMap<>());
|
||||
if (cachedSigns.get(world).containsKey(playerUUID)) {
|
||||
return cachedSigns.get(world).get(playerUUID).getSignText();
|
||||
}
|
||||
SignCacheItem result = addon.getWarpSignsManager().getSignInfo(world, playerUUID);
|
||||
cachedSigns.get(world).put(playerUUID, result);
|
||||
return result.getSignText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes sign text from the cache
|
||||
* @param world - world
|
||||
* @param key - uuid of owner
|
||||
*/
|
||||
void removeWarp(World world, UUID key) {
|
||||
cachedSigns.putIfAbsent(world, new HashMap<>());
|
||||
cachedSigns.get(world).remove(key);
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ import world.bentobox.level.Level;
|
||||
import world.bentobox.warps.commands.WarpCommand;
|
||||
import world.bentobox.warps.commands.WarpsCommand;
|
||||
import world.bentobox.warps.config.Settings;
|
||||
import world.bentobox.warps.listeners.WarpSignsListener;
|
||||
|
||||
/**
|
||||
* Addin to BentoBox that enables welcome warp signs
|
||||
@ -147,6 +148,8 @@ public class Warp extends Addon {
|
||||
// Save the warps
|
||||
if (warpSignsManager != null)
|
||||
warpSignsManager.saveWarpList();
|
||||
if (warpPanelManager != null)
|
||||
warpPanelManager.saveCache();
|
||||
}
|
||||
|
||||
|
||||
@ -171,7 +174,7 @@ public class Warp extends Addon {
|
||||
|
||||
/**
|
||||
* Get warp panel manager
|
||||
* @return
|
||||
* @return Warp Panel Manager
|
||||
*/
|
||||
public WarpPanelManager getWarpPanelManager() {
|
||||
return warpPanelManager;
|
||||
|
@ -1,9 +1,7 @@
|
||||
package world.bentobox.warps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -21,20 +19,19 @@ public class WarpPanelManager {
|
||||
private static final int PANEL_MAX_SIZE = 52;
|
||||
private Warp addon;
|
||||
// This is a cache of signs
|
||||
private Map<World, Map<UUID, SignCache>> cachedSigns = new HashMap<>();
|
||||
|
||||
|
||||
private SignCacheManager signCacheManager;
|
||||
|
||||
public WarpPanelManager(Warp addon) {
|
||||
this.addon = addon;
|
||||
signCacheManager = new SignCacheManager(addon);
|
||||
}
|
||||
|
||||
private PanelItem getPanelItem(World world, UUID warpOwner) {
|
||||
PanelItemBuilder pib = new PanelItemBuilder()
|
||||
.name(addon.getSettings().getNameFormat() + addon.getPlugin().getPlayers().getName(warpOwner))
|
||||
.description(getSign(world, warpOwner))
|
||||
.description(signCacheManager.getSign(world, warpOwner))
|
||||
.clickHandler((panel, clicker, click, slot) -> hander(world, clicker, warpOwner));
|
||||
Material icon = getSignIcon(world, warpOwner);
|
||||
Material icon = signCacheManager.getSignIcon(world, warpOwner);
|
||||
if (icon.equals(Material.PLAYER_HEAD)) {
|
||||
return pib.icon(addon.getPlayers().getName(warpOwner)).build();
|
||||
} else {
|
||||
@ -44,7 +41,10 @@ public class WarpPanelManager {
|
||||
|
||||
private boolean hander(World world, User clicker, UUID warpOwner) {
|
||||
clicker.closeInventory();
|
||||
addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner);
|
||||
String playerCommand = addon.getPlugin().getIWM().getAddon(world).map(gm -> gm.getPlayerCommand().map(c -> c.getLabel()).orElse("")).orElse("");
|
||||
String command = addon.getSettings().getWarpCommand() + " " + addon.getPlayers().getName(warpOwner);
|
||||
clicker.getPlayer().performCommand((playerCommand.isEmpty() ? "" : playerCommand + " ") + command);
|
||||
//addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -56,35 +56,6 @@ public class WarpPanelManager {
|
||||
.icon(Material.END_CRYSTAL).build();
|
||||
}
|
||||
|
||||
private Material getSignIcon(World world, UUID warpOwner) {
|
||||
// Add the worlds if we haven't seen this before
|
||||
cachedSigns.putIfAbsent(world, new HashMap<>());
|
||||
if (cachedSigns.get(world).containsKey(warpOwner)) {
|
||||
return cachedSigns.get(world).get(warpOwner).getType();
|
||||
}
|
||||
// Not in cache
|
||||
SignCache sc = addon.getWarpSignsManager().getSignInfo(world, warpOwner);
|
||||
cachedSigns.get(world).put(warpOwner, sc);
|
||||
return sc.getType();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets sign text and cache it
|
||||
* @param playerUUID
|
||||
* @return sign text in a list
|
||||
*/
|
||||
private List<String> getSign(World world, UUID playerUUID) {
|
||||
// Add the worlds if we haven't seen this before
|
||||
cachedSigns.putIfAbsent(world, new HashMap<>());
|
||||
if (cachedSigns.get(world).containsKey(playerUUID)) {
|
||||
return cachedSigns.get(world).get(playerUUID).getSignText();
|
||||
}
|
||||
SignCache result = addon.getWarpSignsManager().getSignInfo(world, playerUUID);
|
||||
cachedSigns.get(world).put(playerUUID, result);
|
||||
return result.getSignText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the warp panel for the user
|
||||
* @param world - world
|
||||
@ -145,11 +116,15 @@ public class WarpPanelManager {
|
||||
|
||||
/**
|
||||
* Removes sign text from the cache
|
||||
* @param key
|
||||
* @param world - world
|
||||
* @param key - uuid of owner
|
||||
*/
|
||||
public void removeWarp(World world, UUID key) {
|
||||
cachedSigns.putIfAbsent(world, new HashMap<>());
|
||||
cachedSigns.get(world).remove(key);
|
||||
signCacheManager.removeWarp(world, key);
|
||||
}
|
||||
|
||||
public void saveCache() {
|
||||
signCacheManager.saveCache();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import world.bentobox.warps.objects.WarpsData;
|
||||
*/
|
||||
public class WarpSignsManager {
|
||||
private static final int MAX_WARPS = 600;
|
||||
private static final String WARPS = "warps";
|
||||
private BentoBox plugin;
|
||||
// Map of all warps stored as player, warp sign Location
|
||||
private Map<World, Map<UUID, Location>> worldsWarpList;
|
||||
@ -74,7 +75,7 @@ public class WarpSignsManager {
|
||||
this.addon = addon;
|
||||
this.plugin = plugin;
|
||||
// Set up the database handler
|
||||
// Note that these are saved by the BSkyBlock database
|
||||
// Note that these are saved by the BentoBox database
|
||||
handler = new Database<>(addon, WarpsData.class);
|
||||
// Load the warps
|
||||
loadWarpList();
|
||||
@ -176,11 +177,11 @@ public class WarpSignsManager {
|
||||
/**
|
||||
* Load the warps and check if they still exist
|
||||
*/
|
||||
private void loadWarpList() {
|
||||
addon.getLogger().info("Loading warps...");
|
||||
void loadWarpList() {
|
||||
addon.log("Loading warps...");
|
||||
worldsWarpList = new HashMap<>();
|
||||
if (handler.objectExists("warps")) {
|
||||
warpsData = handler.loadObject("warps");
|
||||
if (handler.objectExists(WARPS)) {
|
||||
warpsData = handler.loadObject(WARPS);
|
||||
// Load into map
|
||||
if (warpsData != null) {
|
||||
warpsData.getWarpSigns().forEach((k,v) -> {
|
||||
@ -189,6 +190,8 @@ public class WarpSignsManager {
|
||||
getWarpMap(k.getWorld()).put(v, k);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
warpsData = new WarpsData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,7 +266,7 @@ public class WarpSignsManager {
|
||||
* @return Sign's content and type
|
||||
*/
|
||||
@NonNull
|
||||
public SignCache getSignInfo(@NonNull World world, @NonNull UUID uuid) {
|
||||
public SignCacheItem getSignInfo(@NonNull World world, @NonNull UUID uuid) {
|
||||
List<String> result = new ArrayList<>();
|
||||
//get the sign info
|
||||
Location signLocation = getWarp(world, uuid);
|
||||
@ -297,14 +300,14 @@ public class WarpSignsManager {
|
||||
}
|
||||
|
||||
if (icon == null || icon.name().contains("SIGN")) {
|
||||
return new SignCache(result, Material.valueOf(sign.getType().name().replace("WALL_", "")));
|
||||
return new SignCacheItem(result, Material.valueOf(sign.getType().name().replace("WALL_", "")));
|
||||
} else {
|
||||
return new SignCache(result, icon);
|
||||
return new SignCacheItem(result, icon);
|
||||
}
|
||||
} else {
|
||||
addon.getWarpSignsManager().removeWarp(world, uuid);
|
||||
}
|
||||
return new SignCache(Collections.emptyList(), Material.AIR);
|
||||
return new SignCacheItem(Collections.emptyList(), Material.AIR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,7 @@ import java.util.stream.Collectors;
|
||||
import org.bukkit.World;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.DelayedTeleportCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.warps.Warp;
|
||||
|
||||
@ -18,7 +19,7 @@ import world.bentobox.warps.Warp;
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class WarpCommand extends CompositeCommand {
|
||||
public class WarpCommand extends DelayedTeleportCommand {
|
||||
|
||||
private Warp addon;
|
||||
|
||||
@ -28,7 +29,7 @@ public class WarpCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
public WarpCommand(Warp addon) {
|
||||
super(addon.getSettings().getWarpCommand());
|
||||
super(addon, addon.getSettings().getWarpCommand());
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
@ -59,7 +60,7 @@ public class WarpCommand extends CompositeCommand {
|
||||
return false;
|
||||
} else {
|
||||
// Warp exists!
|
||||
addon.getWarpSignsManager().warpPlayer(world, user, foundWarp);
|
||||
this.delayCommand(user, () -> addon.getWarpSignsManager().warpPlayer(world, user, foundWarp));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package world.bentobox.warps;
|
||||
package world.bentobox.warps.listeners;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -17,8 +17,11 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.events.team.TeamEvent.TeamKickEvent;
|
||||
import world.bentobox.bentobox.api.events.team.TeamEvent.TeamLeaveEvent;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.warps.Warp;
|
||||
import world.bentobox.warps.event.WarpRemoveEvent;
|
||||
|
||||
/**
|
||||
@ -41,6 +44,20 @@ public class WarpSignsListener implements Listener {
|
||||
this.plugin = addon.getPlugin();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerLeave(TeamLeaveEvent e) {
|
||||
// Remove any warp signs from this game mode
|
||||
addon.getWarpSignsManager().removeWarp(e.getIsland().getWorld(), e.getPlayerUUID());
|
||||
User.getInstance(e.getPlayerUUID()).sendMessage("warps.deactivate");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerLeave(TeamKickEvent e) {
|
||||
// Remove any warp signs from this game mode
|
||||
addon.getWarpSignsManager().removeWarp(e.getIsland().getWorld(), e.getPlayerUUID());
|
||||
User.getInstance(e.getPlayerUUID()).sendMessage("warps.deactivate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a sign has been broken
|
||||
* @param e - event
|
54
src/main/java/world/bentobox/warps/objects/SignCache.java
Normal file
54
src/main/java/world/bentobox/warps/objects/SignCache.java
Normal file
@ -0,0 +1,54 @@
|
||||
package world.bentobox.warps.objects;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import world.bentobox.bentobox.database.objects.DataObject;
|
||||
import world.bentobox.warps.SignCacheItem;
|
||||
|
||||
public class SignCache implements DataObject {
|
||||
|
||||
@Expose
|
||||
private String uniqueId = "";
|
||||
@Expose
|
||||
private Map<UUID, SignCacheItem> signs = new HashMap<>();
|
||||
|
||||
public SignCache() {
|
||||
// Required by YAML database
|
||||
}
|
||||
|
||||
public SignCache(World w, Map<UUID, SignCacheItem> m) {
|
||||
this.uniqueId = w.getName();
|
||||
this.signs = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUniqueId(String uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the signs
|
||||
*/
|
||||
public Map<UUID, SignCacheItem> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param signs the signs to set
|
||||
*/
|
||||
public void setSigns(Map<UUID, SignCacheItem> signs) {
|
||||
this.signs = signs;
|
||||
}
|
||||
|
||||
}
|
@ -39,5 +39,5 @@ random-allowed: true
|
||||
allow-in-other-worlds: false
|
||||
#
|
||||
# Warp and warps commands. You can change them if they clash with other addons or plugins.
|
||||
warp-command: wwarp
|
||||
warps-command: wwarps
|
||||
warp-command: warp
|
||||
warps-command: warps
|
||||
|
35
src/main/resources/locales/cs.yml
Normal file
35
src/main/resources/locales/cs.yml
Normal file
@ -0,0 +1,35 @@
|
||||
###########################################################################################
|
||||
# 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 #
|
||||
# #
|
||||
# Translation by: CZghost #
|
||||
###########################################################################################
|
||||
|
||||
warp:
|
||||
help:
|
||||
description: "Teleportovat se na warp ceduli hráče"
|
||||
parameters: <player name>
|
||||
warps:
|
||||
deactivate: "&c Stará warp cedule deaktivována!"
|
||||
error:
|
||||
does-not-exist: "&c Sakra! Tento warp již neexistuje!"
|
||||
no-permission: "&c Na toto nemáš oprávnění!"
|
||||
no-remove: "&c Nemůžeš odstranit tuto ceduli!"
|
||||
no-warps-yet: "&c Nejsou k dispozici žádné warpy"
|
||||
not-enough-level: "&c Úroveň tvého ostrova není dostatečně vysoká!"
|
||||
not-on-island: "&c K tomuto musíš být na svém ostrově!"
|
||||
not-safe: "&c Tento warp není bezpečný!"
|
||||
your-level-is: "&c Úroveň tvého ostrova je jen [level], musí být vyšší než [required]. Spusť příkaz pro úroveň."
|
||||
help:
|
||||
description: "otevřít panel warpů"
|
||||
next: "&6 Další stránka"
|
||||
player-warped: "&2 [name] se teleportoval na tvou warp ceduli!"
|
||||
previous: "&6 Předchozí stránka"
|
||||
random: "&4 Náhodný warp"
|
||||
sign-removed: "&c Warp cedule odstraněna!"
|
||||
success: "&a Úspěch!"
|
||||
title: "Warp cedule"
|
||||
warpTip: "&6 Polož warp ceduli s [text] na vrchu"
|
||||
warpToPlayersSign: "&6 Teleportuji tě na ceduli [player]"
|
||||
|
||||
|
@ -11,11 +11,11 @@ warps:
|
||||
deactivate: "&cRégi teleport tábla deaktiválva!"
|
||||
error:
|
||||
does-not-exist: "&cAjjaj! Ez a teleport nem létezik!"
|
||||
no-permission: "&CNincs jogod ehhez!"
|
||||
no-remove: "&CNem törölheted ezt a táblát!"
|
||||
no-warps-yet: "&CJelenleg nem érhetőek el teleportok"
|
||||
not-enough-level: "&CA szigeted szintje nem elég magas!"
|
||||
not-on-island: "&CEhhez szigeten kell lenned!"
|
||||
no-permission: "&cNincs jogod ehhez!"
|
||||
no-remove: "&cNem törölheted ezt a táblát!"
|
||||
no-warps-yet: "&cJelenleg nem érhetőek el teleportok"
|
||||
not-enough-level: "&cA szigeted szintje nem elég magas!"
|
||||
not-on-island: "&cEhhez szigeten kell lenned!"
|
||||
not-safe: "&cEz a teleport nem biztonságos!"
|
||||
your-level-is: "&cJelenleg a sziget szinted [level], és nagyobbnak kell lennie, mint [required]."
|
||||
help:
|
||||
@ -24,8 +24,8 @@ warps:
|
||||
player-warped: "&2[name] teleportált a teleport tábládhoz!"
|
||||
previous: "&6Előző oldal"
|
||||
random: "&4Véletlenszerű Teleport"
|
||||
sign-removed: "&CTeleport tábla törölve!"
|
||||
success: "&ASikeres!"
|
||||
sign-removed: "&cTeleport tábla törölve!"
|
||||
success: "&aSikeres!"
|
||||
title: "Teleport Táblák"
|
||||
warpTip: "&6Helyezz le egy teleport táblát a következő szöveggel [text] a tetején"
|
||||
warpToPlayersSign: "&6Teleportálás [player] táblájához"
|
||||
|
@ -4,25 +4,25 @@ warp:
|
||||
description: pārvietoties pie spēlētāja uzaicinājuma zīmes
|
||||
parameters: "<spēlētāja vārds>"
|
||||
warps:
|
||||
deactivate: "&cIepriekšējā uzaicinājumu zīme ir deaktivizēta!"
|
||||
error:
|
||||
does-not-exist: "&cAk vai! Uzaicinājuma zīme vairāk neeksistē!"
|
||||
no-permission: "&CTev nav nepieciešamās atļaujas, lai veiktu darbību!"
|
||||
no-remove: "&CTu nevari noņemt šo zīmi!"
|
||||
not-enough-level: "&CTavas salas līmenis ir pārāk zems!"
|
||||
not-on-island: "&CTev ir jāatrodas uz savas salas, lai veiktu šo darbību!"
|
||||
not-safe: "&cŠī uzaicinājuma zīme nav droša!"
|
||||
no-warps-yet: "&CNav neviena aktīva uzaicinājuma zīme."
|
||||
your-level-is: "&cTavas salas līmenis ir tikai [level], bet ir nepieciešams vismaz
|
||||
[required]. Vari mēģināt pārrēķināt savas salas līmeni."
|
||||
help:
|
||||
description: atver uzaicinājumu zīmju sarakstu
|
||||
next: "&6Nākošā lapa"
|
||||
player-warped: "&2[name] pārvietotojās pie tavas uzaicinājuma zīmes!"
|
||||
previous: "&6Iepriekšējā lapa"
|
||||
sign-removed: "&CUzaicinājuma zīme noņemta!"
|
||||
success: "&AVeiksmīgi!"
|
||||
title: Uzaicinājuma Zīmes
|
||||
warpTip: "&6Novieto zīmi ar tekstu [text] pirmajā rindā"
|
||||
warpToPlayersSign: "&6Pārvietojās uz [player] uzaicinājuma zīmes"
|
||||
random: "&4Nejauša Zīmes Izvēle"
|
||||
deactivate: "&c Iepriekšēja uzaicinājuma zīme deaktivizēta!"
|
||||
error:
|
||||
does-not-exist: "&c Oh! Šī uzaicinājuma zīme vairs neeksistē!"
|
||||
no-permission: "&c Tev nav atļaujas veikt šo darbību!"
|
||||
no-remove: "&c Tu nevari noņemt šo zīmi!"
|
||||
no-warps-yet: "&c Diemžēl neviens uzaicinājums nav pieejams."
|
||||
not-enough-level: "&c Tavs salas līmenis nav pietiekošs."
|
||||
not-on-island: "&c Tev ir jābūt uz savas salas, lai veiktu šo darbību!"
|
||||
not-safe: "&c Šīs uzaicinājums nav drošs!"
|
||||
your-level-is: "&c Tavas salas līmenis ir [level], bet ir nepieciešams vismaz
|
||||
[required]. Mēģini pārrēķināt salas līmeni."
|
||||
next: "&6 Nākošā lapa"
|
||||
player-warped: "&2 [name] ieradās pie uzaicinājuma zīmes!"
|
||||
previous: "&6 Iepriekšējā lapa"
|
||||
random: "&4 Nejaušs uzaicinājums"
|
||||
sign-removed: "&c Uzaicinājuma zīme noņemta!"
|
||||
success: "&a Izdevās!"
|
||||
warpTip: "&6 Izveido zīmi ar [text] pirmajā rindā"
|
||||
warpToPlayersSign: "&6 Pārvietojas uz [player] uzaicinājuma zīmi."
|
||||
|
@ -4,24 +4,24 @@ warp:
|
||||
description: 传送到该玩家的传送木牌处
|
||||
parameters: "<player name>"
|
||||
warps:
|
||||
error:
|
||||
no-permission: "&C权限不足!"
|
||||
no-remove: "&C无权移除传送木牌!"
|
||||
not-enough-level: "&C岛屿等级不够高!"
|
||||
no-warps-yet: "&C暂无可用传送木牌"
|
||||
your-level-is: "&c岛屿当前等级 [level], 需要等级 [required]"
|
||||
does-not-exist: "&c那个传送已经不存在了!"
|
||||
not-on-island: "&C操作必须在你的岛屿上进行!"
|
||||
not-safe: "&c那个传送不安全!"
|
||||
help:
|
||||
description: 打开传送面板
|
||||
next: "&6下一页"
|
||||
previous: "&6上一页"
|
||||
sign-removed: "&C传送木牌已移除!"
|
||||
success: "&A成功!"
|
||||
title: 传送木牌
|
||||
warpTip: "&6放置一个第一行是 [text] 的木牌以创建传送木牌"
|
||||
warpToPlayersSign: "&6正传送到 [player] 的传送木牌"
|
||||
deactivate: "&c旧传送牌已不再使用!"
|
||||
player-warped: "&2[name] 刚刚传送到了你的传送牌!"
|
||||
random: "&4随机传送"
|
||||
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] 级。 试试岛屿等级命令吧。"
|
||||
next: "&6 次页"
|
||||
player-warped: "&2 [name] 传送到了你的传送牌!"
|
||||
previous: "&6 前页"
|
||||
random: "&4 随机传送"
|
||||
sign-removed: "&c 拆掉传送牌了!"
|
||||
success: "&a 成了!"
|
||||
warpTip: "&6 放个牌子第一行写 [text]"
|
||||
warpToPlayersSign: "&6 正传送到 [player] 的牌子"
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@ -37,6 +38,8 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
||||
import world.bentobox.bentobox.database.DatabaseSetup;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.warps.config.Settings;
|
||||
|
||||
@ -45,7 +48,7 @@ import world.bentobox.warps.config.Settings;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class})
|
||||
@PrepareForTest({Bukkit.class, DatabaseSetup.class})
|
||||
public class WarpPanelManagerTest {
|
||||
|
||||
@Mock
|
||||
@ -63,6 +66,20 @@ public class WarpPanelManagerTest {
|
||||
private UUID uuid;
|
||||
@Mock
|
||||
private Settings settings;
|
||||
@Mock
|
||||
private static AbstractDatabaseHandler<Object> handler;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
// This has to be done beforeClass otherwise the tests will interfere with each other
|
||||
handler = mock(AbstractDatabaseHandler.class);
|
||||
// Database
|
||||
PowerMockito.mockStatic(DatabaseSetup.class);
|
||||
DatabaseSetup dbSetup = mock(DatabaseSetup.class);
|
||||
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
|
||||
when(dbSetup.getHandler(any())).thenReturn(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
@ -127,7 +144,7 @@ public class WarpPanelManagerTest {
|
||||
when(wsm.getWarp(any(), any())).thenReturn(location);
|
||||
|
||||
// Sign cache
|
||||
SignCache sc = mock(SignCache.class);
|
||||
SignCacheItem sc = mock(SignCacheItem.class);
|
||||
when(sc.getSignText()).thenReturn(Collections.singletonList("[welcome]"));
|
||||
when(sc.getType()).thenReturn(sign_type);
|
||||
when(wsm.getSignInfo(any(), any())).thenReturn(sc);
|
||||
|
@ -9,6 +9,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -211,10 +212,7 @@ public class WarpSignsManagerTest {
|
||||
|
||||
// WarpPanelManager
|
||||
when(addon.getWarpPanelManager()).thenReturn(wpm);
|
||||
|
||||
// User
|
||||
|
||||
|
||||
|
||||
wsm = new WarpSignsManager(addon, plugin);
|
||||
}
|
||||
|
||||
@ -292,7 +290,7 @@ public class WarpSignsManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testWarpSignsManager() throws Exception {
|
||||
verify(logger).info("Loading warps...");
|
||||
verify(addon).log("Loading warps...");
|
||||
verify(load).getWarpSigns();
|
||||
verify(block).getType();
|
||||
}
|
||||
@ -417,7 +415,7 @@ public class WarpSignsManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGetSignInfo() {
|
||||
SignCache sc = wsm.getSignInfo(world, uuid);
|
||||
SignCacheItem sc = wsm.getSignInfo(world, uuid);
|
||||
assertEquals(Material.ACACIA_SIGN, sc.getType());
|
||||
}
|
||||
|
||||
@ -447,4 +445,34 @@ public class WarpSignsManagerTest {
|
||||
assertFalse(wsm.hasWarp(world, UUID.randomUUID()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#loadWarpList()}.
|
||||
*/
|
||||
@Test
|
||||
public void testLoadWarpListNoWarpTable() {
|
||||
// Run again but with no database table
|
||||
when(handler.objectExists(anyString())).thenReturn(false);
|
||||
wsm = new WarpSignsManager(addon, plugin);
|
||||
// Save
|
||||
wsm.saveWarpList();
|
||||
// Default load in constructor check
|
||||
verify(addon, times(2)).log(eq("Loading warps..."));
|
||||
assertTrue(wsm.getWarpMap(world).isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.WarpSignsManager#loadWarpList()}.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testLoadWarpListEmptyWarpTable() throws Exception {
|
||||
// Run again but with no data in table
|
||||
when(handler.loadObject(anyString())).thenReturn(null);
|
||||
wsm = new WarpSignsManager(addon, plugin);
|
||||
// Save
|
||||
wsm.saveWarpList();
|
||||
// Default load in constructor check
|
||||
verify(addon, times(2)).log(eq("Loading warps..."));
|
||||
assertTrue(wsm.getWarpMap(world).isEmpty());
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,16 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -65,6 +70,12 @@ public class WarpCommandTest {
|
||||
private WarpSignsManager wsm;
|
||||
@Mock
|
||||
private PlayersManager pm;
|
||||
@Mock
|
||||
private PluginManager pim;
|
||||
@Mock
|
||||
private world.bentobox.bentobox.Settings s;
|
||||
@Mock
|
||||
private BukkitScheduler sch;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
@ -112,6 +123,20 @@ public class WarpCommandTest {
|
||||
when(addon.getPlayers()).thenReturn(pm);
|
||||
// Repeat twice because it is asked twice
|
||||
when(pm.getName(any())).thenReturn("tastybento", "tastybento", "poslovich", "poslovich", "BONNe", "BONNe", "Joe");
|
||||
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// BentoBox settings
|
||||
when(plugin.getSettings()).thenReturn(s);
|
||||
when(s.getDelayTime()).thenReturn(0);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Mockito.framework().clearInlineMocks();
|
||||
}
|
||||
|
||||
public void warpCommandWarpCompositeCommand() {
|
||||
@ -124,6 +149,7 @@ public class WarpCommandTest {
|
||||
wc = new WarpCommand(addon);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.warps.commands.WarpCommand#setup()}.
|
||||
*/
|
||||
@ -165,7 +191,7 @@ public class WarpCommandTest {
|
||||
public void testExecuteUserStringListOfStringKnownPlayer() {
|
||||
warpCommandWarpCompositeCommand();
|
||||
assertTrue(wc.execute(user, "warp", Collections.singletonList("tastybento")));
|
||||
verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
//verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +201,7 @@ public class WarpCommandTest {
|
||||
public void testExecuteUserStringListOfStringKnownPlayerWarp() {
|
||||
warpCommandWarp();
|
||||
assertTrue(wc.execute(user, "warp", Collections.singletonList("tastybento")));
|
||||
verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
//verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +211,7 @@ public class WarpCommandTest {
|
||||
public void testExecuteUserStringListOfStringKnownPlayerMixedCase() {
|
||||
warpCommandWarpCompositeCommand();
|
||||
assertTrue(wc.execute(user, "warp", Collections.singletonList("tAsTyBEnTo")));
|
||||
verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
//verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,7 +221,7 @@ public class WarpCommandTest {
|
||||
public void testExecuteUserStringListOfStringKnownPlayerStartOnly() {
|
||||
warpCommandWarpCompositeCommand();
|
||||
assertTrue(wc.execute(user, "warp", Collections.singletonList("tAsTy")));
|
||||
verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
//verify(wsm).warpPlayer(eq(world), eq(user), any());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package world.bentobox.warps;
|
||||
package world.bentobox.warps.listeners;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -50,7 +50,10 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlaceholdersManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.warps.Warp;
|
||||
import world.bentobox.warps.WarpSignsManager;
|
||||
import world.bentobox.warps.config.Settings;
|
||||
import world.bentobox.warps.listeners.WarpSignsListener;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
Loading…
Reference in New Issue
Block a user