-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the npc prefix check less strict and more precise
- Loading branch information
1 parent
6fc581d
commit 24cf037
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Towny/src/test/java/com/palmergames/bukkit/towny/listeners/LoginListenerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.palmergames.bukkit.towny.listeners; | ||
|
||
import be.seeseemelk.mockbukkit.MockBukkit; | ||
import com.palmergames.bukkit.towny.TownySettings; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static com.palmergames.bukkit.towny.listeners.TownyLoginListener.isPossibleNPCName; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class LoginListenerTests { | ||
@BeforeAll | ||
public static void init() { | ||
MockBukkit.getOrCreateMock(); | ||
TownySettings.loadDefaultConfig(); | ||
} | ||
|
||
@Test | ||
void testNpcPrefix() { | ||
final String npcPrefix = TownySettings.getNPCPrefix(); | ||
|
||
assertFalse(isPossibleNPCName(npcPrefix)); // The npc prefix itself is not a possible npc name | ||
assertTrue(isPossibleNPCName(npcPrefix + "1")); | ||
assertTrue(isPossibleNPCName(npcPrefix + "99999999")); | ||
|
||
assertFalse(isPossibleNPCName(npcPrefix + "A")); | ||
assertFalse(isPossibleNPCName(npcPrefix + "1A")); | ||
assertFalse(isPossibleNPCName("name")); | ||
} | ||
} |