Upcoming release v1.1.0 - #3
SebiTimeWaster wants to merge 22 commits into
Conversation
…et was not set by '/setspawn'
…et was not set by '/setspawn'
…et was not set by '/setspawn'
✅ Duplicate Code ReportTwo engines run in parallel for cross-validation. Each has its own thresholds tuned to its baseline - the real safety net is the per-engine "max increase vs base" check. ✅ PMD CPD
|
| PR | Base | Change | |
|---|---|---|---|
| Clones | 19 | 16 | 🫤 +3 |
| Duplicated lines | 123 | 140 | 👍 -17 |
| Duplication | 4.25% | 6.70% | ❤️ -2.45% |
| Rule | Limit | Status |
|---|---|---|
| Max duplication | 5% | ✅ Pass (4.25%) |
| Max increase vs base | +0.1% | ✅ Pass (-2.45%) |
⚠️ 19 new clones introduced
- 4 lines:
src/main/java/timewaster/publicteleport/commands/Warps.java:78<->src/main/java/timewaster/publicteleport/commands/Warps.java:32 - 8 lines:
src/main/java/timewaster/publicteleport/commands/Tpa.java:6<->src/main/java/timewaster/publicteleport/commands/Warps.java:9 - 8 lines:
src/main/java/timewaster/publicteleport/commands/Spawn.java:3<->src/main/java/timewaster/publicteleport/commands/Warps.java:9 - 4 lines:
src/main/java/timewaster/publicteleport/commands/Portals.java:5<->src/main/java/timewaster/publicteleport/commands/Warps.java:3 - 6 lines:
src/main/java/timewaster/publicteleport/commands/Homes.java:1<->src/main/java/timewaster/publicteleport/commands/Warps.java:1 - 19 lines:
src/main/java/timewaster/publicteleport/commands/Homes.java:7<->src/main/java/timewaster/publicteleport/commands/Warps.java:7 - 3 lines:
src/main/java/timewaster/publicteleport/commands/Homes.java:101<->src/main/java/timewaster/publicteleport/commands/Warps.java:91 - 8 lines:
src/main/java/timewaster/publicteleport/commands/Help.java:9<->src/main/java/timewaster/publicteleport/commands/Warps.java:9 - 9 lines:
src/main/java/timewaster/publicteleport/commands/Back.java:1<->src/main/java/timewaster/publicteleport/commands/Warps.java:9 - 7 lines:
src/main/java/timewaster/publicteleport/Teleports.java:3<->src/main/java/timewaster/publicteleport/commands/Portals.java:3 - 15 lines:
src/main/java/timewaster/publicteleport/Teleports.java:189<->src/main/java/timewaster/publicteleport/Teleports.java:142 - 4 lines:
src/main/java/timewaster/publicteleport/TeleportSafety.java:13<->src/main/java/timewaster/publicteleport/commands/Portals.java:30 - 9 lines:
src/main/java/timewaster/publicteleport/Storage.java:375<->src/main/java/timewaster/publicteleport/Storage.java:325 - 5 lines:
src/main/java/timewaster/publicteleport/Storage.java:439<->src/main/java/timewaster/publicteleport/Storage.java:408 - 8 lines:
src/main/java/timewaster/publicteleport/Requests.java:1<->src/main/java/timewaster/publicteleport/commands/Portals.java:3 - 9 lines:
src/main/java/timewaster/publicteleport/Requests.java:244<->src/main/java/timewaster/publicteleport/Requests.java:206 - 6 lines:
src/main/java/timewaster/publicteleport/Registrar.java:75<->src/main/java/timewaster/publicteleport/commands/Portals.java:267 - 5 lines:
src/main/java/timewaster/publicteleport/Registrar.java:223<->src/main/java/timewaster/publicteleport/Registrar.java:197 - 5 lines:
src/main/java/timewaster/publicteleport/Portals.java:9<->src/main/java/timewaster/publicteleport/Utils.java:11
Powered by astubbs/duplicate-code-cross-check
| return false; | ||
| } | ||
|
|
||
| Teleport target = Teleport.create(player, argValue); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Homes.java:58
| @@ -296,7 +306,7 @@ public Boolean setTeleport(ServerPlayer player, Teleport newTeleport, boolean is | |||
| int numTeleports = 0; | |||
|
|
|||
| if (teleports == null) { | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:356
| return false; | ||
| } | ||
| public static boolean teleportPlayer(ServerPlayer player, Teleport teleportTarget) { | ||
| ServerLevel level = TeleportSafety.getLevelFromDimension(player, teleportTarget.dimension()); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Teleports.java:186
| * @param newPortal the {@link Portal} to add or update | ||
| * @return {@code true} if successful, {@code false} on file error | ||
| */ | ||
| public boolean setPortal(ServerPlayer player, Portal newPortal) { |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:418
| dispatcher.register(Commands.literal("setwarp").requires(PERMISSIONS_OWNER) | ||
| .then(Registrar.buildArgumentString("name", typeNone, (ServerPlayer player, String argValue) -> { | ||
| dispatcher.register(Commands.literal("setwarp").requires(Commands.hasPermission(Commands.LEVEL_OWNERS)) | ||
| .then(Registrar.buildArgumentString("name", NONE, (ServerPlayer player, String argValue) -> { |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:81
| if (argValue.equals("back")) { | ||
| Messages.sendMessage(player, "home_reserved_name", Messages.MessageType.WARNING); | ||
| Messages.sendMessage(player, "home_reserved_name", WARNING); | ||
| return false; |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:37
| @@ -157,7 +197,7 @@ public static RequiredArgumentBuilder<CommandSourceStack, String> buildArgumentS | |||
| SuggestionType suggestionType, BiFunction<ServerPlayer, String, Boolean> callback) { | |||
| return Commands.argument(argName, Objects.requireNonNull(StringArgumentType.word())) | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Registrar.java:224
|
|
||
| if (!TeleportSafety.isBlockTeleportable(player, target)) { | ||
| Messages.sendMessage(player, "teleport_unsafe_set", Messages.MessageType.ERROR, "Spawn"); | ||
| Messages.sendMessage(player, "teleport_unsafe_set", ERROR, "Spawn"); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:43
| } | ||
|
|
||
| if (type == SuggestionType.PORTALS) { | ||
| List<Portal> portals = PublicTeleport.storage.getPortals(); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Portals.java:263
| @@ -296,7 +323,7 @@ public Boolean setTeleport(ServerPlayer player, Teleport newTeleport, boolean is | |||
| int numTeleports = 0; | |||
|
|
|||
| if (teleports == null) { | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:373
| return false; | ||
| } | ||
| public static boolean teleportPlayer(ServerPlayer player, Teleport teleportTarget) { | ||
| ServerLevel level = TeleportSafety.getLevelFromDimension(player, teleportTarget.dimension()); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Teleports.java:189
| * @param newPortal the {@link Portal} to add or update | ||
| * @return {@code true} if successful, {@code false} on file error | ||
| */ | ||
| public boolean setPortal(ServerPlayer player, Portal newPortal) { |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:435
| .then(Registrar.buildArgumentString("name", typeNone, (ServerPlayer player, String argValue) -> { | ||
| if (argValue.equals("spawn")) { | ||
| dispatcher.register(Commands.literal("setwarp").requires(Commands.hasPermission(Commands.LEVEL_OWNERS)) | ||
| .then(Registrar.buildArgumentString("name", NONE, (ServerPlayer player, String argValue) -> { |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:84
| @@ -157,7 +200,7 @@ public static RequiredArgumentBuilder<CommandSourceStack, String> buildArgumentS | |||
| SuggestionType suggestionType, BiFunction<ServerPlayer, String, Boolean> callback) { | |||
| return Commands.argument(argName, Objects.requireNonNull(StringArgumentType.word())) | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Registrar.java:227
|
|
||
| if (!TeleportSafety.isBlockTeleportable(player, target)) { | ||
| Messages.sendMessage(player, "teleport_unsafe_set", Messages.MessageType.ERROR, "Spawn"); | ||
| Messages.sendMessage(player, "teleport_unsafe_set", ERROR, "Spawn"); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:46
| } | ||
|
|
||
| if (type == SuggestionType.PORTALS) { | ||
| List<Portal> portals = PublicTeleport.storage.getPortals(); |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Portals.java:266
| return Teleports.teleportPlayer(player, "home", false); | ||
| }))); | ||
|
|
||
| dispatcher.register(Commands.literal("homes") |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:97
| @@ -110,14 +126,18 @@ private Map<String, String> loadTranslations() { | |||
| try { | |||
| modContainer = fabricLoader.getModContainer(PublicTeleport.MOD_ID).get(); | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:136
| @@ -192,26 +202,22 @@ public static boolean cancelRequest(ServerPlayer sender) { | |||
| * @return {@code true} if a matching request was found and executed | |||
| */ | |||
| public static boolean acceptRequest(@Nullable ServerPlayer sender, ServerPlayer receiver) { | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Requests.java:242
| .then(Registrar.buildArgumentString("name", typeNone, (ServerPlayer player, String argValue) -> { | ||
| if (argValue.equals("spawn")) { | ||
| dispatcher.register(Commands.literal("setwarp").requires(Commands.hasPermission(Commands.LEVEL_OWNERS)) | ||
| .then(Registrar.buildArgumentString("name", NONE, (ServerPlayer player, String argValue) -> { |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/commands/Warps.java:78
| @@ -192,26 +204,22 @@ public static boolean cancelRequest(ServerPlayer sender) { | |||
| * @return {@code true} if a matching request was found and executed | |||
| */ | |||
| public static boolean acceptRequest(@Nullable ServerPlayer sender, ServerPlayer receiver) { | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Requests.java:244
| * @param newPortal the {@link Portal} to add or update | ||
| * @return {@code true} if successful, {@code false} on file error | ||
| */ | ||
| public boolean setPortal(ServerPlayer player, Portal newPortal) { |
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:439
| @@ -157,8 +196,8 @@ public static RequiredArgumentBuilder<CommandSourceStack, String> buildArgumentS | |||
| SuggestionType suggestionType, BiFunction<ServerPlayer, String, Boolean> callback) { | |||
| return Commands.argument(argName, Objects.requireNonNull(StringArgumentType.word())) | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Registrar.java:223
| @@ -296,32 +325,34 @@ public Boolean setTeleport(ServerPlayer player, Teleport newTeleport, boolean is | |||
| int numTeleports = 0; | |||
|
|
|||
| if (teleports == null) { | |||
There was a problem hiding this comment.
src/main/java/timewaster/publicteleport/Storage.java:377
8732491 to
c71e8d2
Compare
Release Notes:
/setspawn