Use regex and remove "g"
This commit is contained in:
parent
03d781ca70
commit
66cea341a5
@ -3,12 +3,14 @@ package mineplex.core.aprilfools;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.jcp.xml.dsig.internal.dom.Utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -24,14 +26,27 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
.put("friend", "matey")
|
||||
.put("friends", "mateys")
|
||||
.put("chest", "booty")
|
||||
.put("chests", "booty")
|
||||
.put("treasure", "booty")
|
||||
.put("shards", "riches")
|
||||
.put("sword", "cutlass")
|
||||
.put("my", "me")
|
||||
.put("gold", "dubloon")
|
||||
.put("dog", "seadog")
|
||||
.put("dead", "shark bait")
|
||||
.put("die", "walk the plank")
|
||||
.put("boat", "ship")
|
||||
.put("drink", "grog")
|
||||
.put("water", "grog")
|
||||
.put("flag", "jolly roger")
|
||||
.put("am", "be")
|
||||
.put("girl", "lass")
|
||||
.put("woman", "lass")
|
||||
.put("noob", "shark bait")
|
||||
.put("hack", "scurvy")
|
||||
.put("hacks", "scurvy")
|
||||
.put("hax", "scurvy")
|
||||
.put("haks", "scurvy")
|
||||
.put("hacker", "")
|
||||
.put("owner", "captain")
|
||||
.put("leader", "captain")
|
||||
.put("lt", "captain")
|
||||
@ -45,12 +60,12 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
.put(Rank.LEGEND, "Boatswain")
|
||||
.put(Rank.HERO, "Gunner")
|
||||
.put(Rank.ULTRA, "Parrot")
|
||||
.put(Rank.ALL, "Seadog")
|
||||
.build();
|
||||
|
||||
private static AprilFoolsManager _instance;
|
||||
|
||||
private boolean _enabled;
|
||||
private boolean _enabledTitle;
|
||||
|
||||
public AprilFoolsManager()
|
||||
{
|
||||
@ -58,6 +73,7 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
|
||||
_instance = this;
|
||||
_enabled = true;
|
||||
_enabledTitle = UtilServer.isHubServer() || UtilServer.isTestServer();
|
||||
|
||||
if (_enabled)
|
||||
{
|
||||
@ -82,6 +98,7 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
for (String word : message.split(" "))
|
||||
{
|
||||
String wordLower = word.toLowerCase();
|
||||
wordLower = wordLower.replaceAll("[^a-zA-Z0-9]", "");
|
||||
|
||||
if (CHAT_REPLACEMENTS.containsKey(wordLower))
|
||||
{
|
||||
@ -98,6 +115,11 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
if (word.length() > 1 && wordLower.charAt(wordLower.length() - 1) == 'g')
|
||||
{
|
||||
word = word.substring(0, word.length() - 2);
|
||||
}
|
||||
|
||||
pirateMessage += word + " ";
|
||||
}
|
||||
}
|
||||
@ -135,7 +157,7 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void updateRandomMessage(UpdateEvent event)
|
||||
{
|
||||
if (!_enabled || event.getType() != UpdateType.SLOW)
|
||||
if (!_enabledTitle || event.getType() != UpdateType.SLOW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user