Config file was not being read.

Signs removed by breaking blocks under them and then replaced were not
being correctly handled. Now they are deleted and remade. No need for
the "duplicate sign" text.

https://github.com/BentoBoxWorld/Warps/issues/47
https://github.com/BentoBoxWorld/Warps/issues/46
https://github.com/BentoBoxWorld/Warps/issues/32
This commit is contained in:
tastybento 2019-09-13 18:13:03 -07:00
parent 8de53d1a81
commit 0814f22424
13 changed files with 28 additions and 40 deletions

View File

@ -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.6.2</build.version>
<build.version>1.7.0</build.version>
</properties>
<!-- Profiles will allow to automatically change build version. -->

View File

@ -57,6 +57,11 @@ public class Warp extends Addon {
*/
private boolean hooked;
/**
* Settings config object
*/
private Config<Settings> settingsConfig;
// ---------------------------------------------------------------------
// Section: Methods
// ---------------------------------------------------------------------
@ -142,8 +147,10 @@ public class Warp extends Addon {
* This method loads addon configuration settings in memory.
*/
private void loadSettings() {
this.settings = new Config<>(this, Settings.class).loadConfigObject();
if (settingsConfig == null) {
settingsConfig = new Config<>(this, Settings.class);
}
this.settings = settingsConfig.loadConfigObject();
if (this.settings == null) {
// Disable
this.logError("WelcomeWarp settings could not load! Addon disabled.");

View File

@ -155,13 +155,8 @@ public class WarpSignsListener implements Listener {
for (int i = 1; i<4; i++) {
e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i)));
}
} else {
user.sendMessage("warps.error.duplicate");
e.setLine(0, ChatColor.RED + addon.getSettings().getWelcomeLine());
for (int i = 1; i<4; i++) {
e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i)));
}
}
// Else null player
}
}

View File

@ -85,10 +85,15 @@ public class WarpSignsManager {
* @return true if successful, false if not
*/
public boolean addWarp(final UUID playerUUID, final Location loc) {
// Do not allow null players to set warps or warps to be in the same location
if (playerUUID == null || getWarpMap(loc.getWorld()).containsValue(loc)) {
// Do not allow null players to set warps
if (playerUUID == null) {
return false;
}
// Check for warps placed in a location where there was a warp before
if (getWarpMap(loc.getWorld()).containsValue(loc)) {
// remove the warp at this location, then place it
this.removeWarp(loc);
}
getWarpMap(loc.getWorld()).put(playerUUID, loc);
saveWarpList();
Bukkit.getPluginManager().callEvent(new WarpInitiateEvent(addon, loc, playerUUID));
@ -266,16 +271,16 @@ public class WarpSignsManager {
// Get the sign type
String prefix = this.plugin.getIWM().getAddon(world).map(
Addon::getPermissionPrefix).orElse("");
Addon::getPermissionPrefix).orElse("");
Material icon;
if (!prefix.isEmpty())
{
icon = Material.matchMaterial(
this.getPermissionValue(User.getInstance(uuid),
prefix + "island.warp",
this.addon.getSettings().getIcon()));
this.getPermissionValue(User.getInstance(uuid),
prefix + "island.warp",
this.addon.getSettings().getIcon()));
}
else
{
@ -489,9 +494,9 @@ public class WarpSignsManager {
String permPrefix = permissionPrefix + ".";
List<String> permissions = user.getEffectivePermissions().stream().
map(PermissionAttachmentInfo::getPermission).
filter(permission -> permission.startsWith(permPrefix)).
collect(Collectors.toList());
map(PermissionAttachmentInfo::getPermission).
filter(permission -> permission.startsWith(permPrefix)).
collect(Collectors.toList());
for (String permission : permissions)
{

View File

@ -9,7 +9,7 @@ import world.bentobox.bentobox.api.configuration.ConfigObject;
import world.bentobox.bentobox.api.configuration.StoreAt;
@StoreAt(filename="config.yml", path="addons/WelcomeWarps")
@StoreAt(filename="config.yml", path="addons/Warps")
@ConfigComment("WelcomeWarps Configuration [version]")
@ConfigComment("This config file is dynamic and saved when the server is shutdown.")
@ConfigComment("You cannot edit it while the server is running because changes will")
@ -21,13 +21,13 @@ public class Settings implements ConfigObject
@ConfigComment("Warp Restriction - needed levels to be able to create a warp")
@ConfigComment("0 or negative values will disable this restriction 10 is default")
@ConfigEntry(path = "warplevelrestriction")
private int warpLevelRestriction;
private int warpLevelRestriction = 10;
@ConfigComment("")
@ConfigComment("Text that player must put on sign to make it a warp sign")
@ConfigComment("Not case sensitive!")
@ConfigEntry(path = "welcomeLine")
private String welcomeLine;
private String welcomeLine = "[Welcome]";
@ConfigComment("")
@ConfigComment("Icon that will be displayed in Warps list. SIGN counts for any kind of sign and the type of")

View File

@ -11,7 +11,6 @@ warps:
deactivate: "&cOld warp sign deactivated!"
error:
does-not-exist: "&cOh snap! That warp no longer exists!"
duplicate: "&CDuplicate sign placed"
no-permission: "&CYou do not have permission to do that!"
no-remove: "&CYou cannot remove that sign!"
no-warps-yet: "&CThere are no warps available yet"

View File

@ -11,7 +11,6 @@ warps:
deactivate: "&cViejo cartel a sido desactivado!"
error:
does-not-exist: "&cOh snap! Ese warp ya no existe!"
duplicate: "&CCartel duplicado puesto"
no-permission: "&CNo tienes permiso para hacer eso!"
no-remove: "&CNo puedes quitar ese cartel!"
no-warps-yet: "&CNo hay warps disponibles aun"

View File

@ -11,7 +11,6 @@ warps:
deactivate: "&cAncien panneau de Warp désactivé !"
error:
does-not-exist: "&cCe Warp n'existe plus !"
duplicate: "&cPanneau dupliqué placé."
no-permission: "&cVous n'avez pas la permission pour faire cela !"
no-remove: "&cVous ne pouvez pas supprimer ce panneau !"
no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur."

View File

@ -11,7 +11,6 @@ warps:
deactivate: "&c前のワープサインが無効になりました!"
error:
does-not-exist: "&cそのワープはもう存在しません"
duplicate: "&C重複サインを配置"
no-permission: "&C許可がありません"
no-remove: "&Cワープサインは外せません"
no-warps-yet: "&C利用可能なワープはまだありません"

View File

@ -7,7 +7,6 @@ warps:
deactivate: "&cIepriekšējā uzaicinājumu zīme ir deaktivizēta!"
error:
does-not-exist: "&cAk vai! Uzaicinājuma zīme vairāk neeksistē!"
duplicate: "&CAtkārtota zīme uzlikta"
no-permission: "&CTev nav nepieciešamās atļaujas, lai veiktu darbību!"
no-remove: "&CTu nevari noņemt šo zīmi!"
no-warps-yet: "&CNav neviena aktīva uzaicinājuma zīme."

View File

@ -11,7 +11,6 @@ warps:
deactivate: "&cEski ada warpı silindi!"
error:
does-not-exist: "&4Malasef sorun oluştu. Tekrar dene."
duplicate: "&9İki bölge tabelası birleştirildi."
no-permission: "&4Buna yetkin yok!"
no-remove: "&4Bu tabelayı kıramazsın!"
no-warps-yet: "&4Böyle bir bölge henüz yok."

View File

@ -11,7 +11,6 @@ warps:
deactivate: "&c禁用的旧转移标志!"
error:
does-not-exist: "&c转移不再存在!"
duplicate: "&C木牌重复"
no-permission: "&C权限不足!"
no-remove: "&C无权移除传送木牌!"
no-warps-yet: "&C暂无可用传送木牌"

View File

@ -345,18 +345,6 @@ public class WarpSignsListenerTest {
assertEquals(ChatColor.GREEN + "[WELCOME]", e.getLine(0));
}
@Test
public void testCreateNoSignAlreadyDuplicateSpot() {
when(wsm.addWarp(any(), any())).thenReturn(false);
when(wsm.getWarp(any(), any())).thenReturn(null);
when(player.hasPermission(anyString())).thenReturn(true);
WarpSignsListener wsl = new WarpSignsListener(addon);
SignChangeEvent e = new SignChangeEvent(block, player, lines);
wsl.onSignWarpCreate(e);
verify(player).sendMessage("warps.error.duplicate");
assertEquals(ChatColor.RED + "[WELCOME]", e.getLine(0));
}
@Test
public void testCreateNoSignDeactivateOldSign() {
when(player.hasPermission(anyString())).thenReturn(true);