1
0
mirror of https://github.com/BentoBoxWorld/Warps.git synced 2024-11-25 03:55:25 +01:00

style: change method name to getWarpLocation

note `line 294` of `warp.java`, I am unsure what this does and whether it should be `getWarpLocation` or not. I will leave it for the time being.
This commit is contained in:
TreemanK 2024-06-21 02:23:38 +10:00
parent 64f8a4899a
commit ef81a1c2f0
6 changed files with 17 additions and 11 deletions

View File

@ -288,7 +288,7 @@ public class Warp extends Addon {
}
return switch (requestLabel) {
case "getSortedWarps" -> getWarpSignsManager().getSortedWarps(world);
case "getWarp" -> uuid == null ? null : getWarpSignsManager().getWarp(world, uuid);
case "getWarp" -> uuid == null ? null : getWarpSignsManager().getWarpLocation(world, uuid);
case "getWarpMap" -> getWarpSignsManager().getWarpMap(world);
case "hasWarp" -> uuid == null ? null : getWarpSignsManager().hasWarp(world, uuid);
case "listWarps" -> getWarpSignsManager().listWarps(world);

View File

@ -171,7 +171,7 @@ public class WarpSignsListener implements Listener {
}
// Check if the player already has a sign
final Location oldSignLoc = addon.getWarpSignsManager().getWarp(b.getWorld(), user.getUniqueId());
final Location oldSignLoc = addon.getWarpSignsManager().getWarpLocation(b.getWorld(), user.getUniqueId());
if (oldSignLoc != null) {
// A sign already exists. Check if it still there and if
// so,

View File

@ -122,11 +122,16 @@ public class WarpSignsManager {
* @return Location of warp or null
*/
@Nullable
public Location getWarp(World world, UUID playerUUID) {
public Location getWarpLocation(World world, UUID playerUUID) {
PlayerWarp playerWarp = getWarpMap(world).get(playerUUID);
return playerWarp != null ? playerWarp.getLocation() : null;
}
@Nullable
public PlayerWarp getPlayerWarp(World world, UUID playerUUID) {
return getWarpMap(world).get(playerUUID);
}
/**
* Get the name of the warp owner by location
* @param location to search
@ -304,7 +309,7 @@ public class WarpSignsManager {
@NonNull
public SignCacheItem getSignInfo(@NonNull World world, @NonNull UUID uuid) {
//get the sign info
Location signLocation = getWarp(world, uuid);
Location signLocation = getWarpLocation(world, uuid);
if (signLocation == null || !signLocation.getBlock().getType().name().contains("SIGN")) {
return new SignCacheItem();
}
@ -398,7 +403,7 @@ public class WarpSignsManager {
* @param owner - owner of the warp
*/
public void warpPlayer(@NonNull World world, @NonNull User user, @NonNull UUID owner) {
final Location warpSpot = getWarp(world, owner);
final Location warpSpot = getWarpLocation(world, owner);
// Check if the warp spot is safe
if (warpSpot == null) {
user.sendMessage("warps.error.does-not-exist");

View File

@ -57,6 +57,7 @@ public class WarpsData implements DataObject {
PlayerWarp playerWarp = new PlayerWarp(entry.getKey(), true);
newWarpSigns.put(playerWarp, entry.getValue());
}
warpSigns.clear();
}
public void setWarpSigns(Map<PlayerWarp, UUID> warpSigns) {

View File

@ -359,19 +359,19 @@ public class WarpSignsManagerTest {
}
/**
* Test method for {@link WarpSignsManager#getWarp(org.bukkit.World, java.util.UUID)}.
* Test method for {@link WarpSignsManager#getWarpLocation(org.bukkit.World, java.util.UUID)}.
*/
@Test
public void testGetWarpWorldWorld() {
assertNull(wsm.getWarp(mock(World.class), uuid));
assertNull(wsm.getWarpLocation(mock(World.class), uuid));
}
/**
* Test method for {@link WarpSignsManager#getWarp(org.bukkit.World, java.util.UUID)}.
* Test method for {@link WarpSignsManager#getWarpLocation(org.bukkit.World, java.util.UUID)}.
*/
@Test
public void testGetWarp() {
assertEquals(location, wsm.getWarp(world, uuid));
assertEquals(location, wsm.getWarpLocation(world, uuid));
}
/**

View File

@ -133,7 +133,7 @@ public class WarpSignsListenerTest {
// Player is in world
when(wsm.getWarpMap(world)).thenReturn(list);
//Player has a warp sign already here
when(wsm.getWarp(any(), any())).thenReturn(location);
when(wsm.getWarpLocation(any(), any())).thenReturn(location);
// Unique spot
when(wsm.addWarp(any(), any())).thenReturn(true);
// Bentobox
@ -421,7 +421,7 @@ public class WarpSignsListenerTest {
@Test
public void testCreateNoSignAlreadyUniqueSpot() {
when(wsm.getWarp(any(), any())).thenReturn(null);
when(wsm.getWarpLocation(any(), any())).thenReturn(null);
when(player.hasPermission(anyString())).thenReturn(true);
WarpSignsListener wsl = new WarpSignsListener(addon);
SignChangeEvent e = new SignChangeEvent(block, player, lines);