Fixes and more helpful error messages

This commit is contained in:
Norbi Peti 2018-04-18 22:44:31 +02:00
parent 4006cdad58
commit e5053a0483
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 27 additions and 25 deletions

View file

@ -106,7 +106,7 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>jitpack.io</id>
<id>jitpack</id>
<url>https://jitpack.io/</url>
</repository>
<repository>
@ -198,7 +198,7 @@
<dependency>
<groupId>com.github.webbukkit</groupId>
<artifactId>Dynmap</artifactId>
<version>master-SNAPSHOT</version>
<version>v2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>

View file

@ -58,15 +58,15 @@ public class NColorCommand extends UCommandBase {
return true;
}
if (nameparts.length < towncolors.length) {
player.sendMessage("§cYou need more vertical lines (|) in your name.");
player.sendMessage("§cYou need more vertical lines (|) in your name. (Should have " + (towncolors.length - 1) + ")");
return true;
}
if (nameparts.length > towncolors.length * 2) {
player.sendMessage("§cYou have waay too many vertical lines (|) in your name.");
player.sendMessage("§cYou have waay too many vertical lines (|) in your name. (Should have " + (towncolors.length - 1) + ")");
return true;
}
if (nameparts.length > towncolors.length) {
player.sendMessage("§cYou have too many vertical lines (|) in your name.");
player.sendMessage("§cYou have too many vertical lines (|) in your name. (Should have " + (towncolors.length - 1) + ")");
return true;
}
ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class).NameColorLocations()

View file

@ -45,6 +45,7 @@ public class TownColorCommand extends AdminCommandBase {
if (!c.isPresent()) { //^^ Skip black
sender.sendMessage("§cThe color '" + args[i] + "' cannot be found."); //ˇˇ Skip black
sender.sendMessage("§cAvailable colors: " + Arrays.stream(Color.values()).skip(1).map(col -> String.format("§%x%s§r", col.ordinal(), col.getName())).collect(Collectors.joining(", ")));
sender.sendMessage("§cMake sure to type them exactly as shown above.");
return true;
}
clrs[i - 1] = c.get();

View file

@ -1,24 +1,20 @@
package buttondevteam.chat.formatting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import buttondevteam.chat.ChatProcessing;
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
import buttondevteam.lib.chat.Color;
import buttondevteam.lib.chat.Priority;
import lombok.Builder;
import lombok.Data;
import lombok.val;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import buttondevteam.chat.ChatProcessing;
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
import buttondevteam.lib.chat.*;
import lombok.Builder;
import lombok.Data;
import lombok.val;
/**
* A {@link ChatFormatter} shows what formatting to use based on regular expressions. {@link ChatFormatter#Combine(List, String, TellrawPart)} is used to turn it into a {@link TellrawPart}, combining
* intersecting parts found, for example when {@code _abc*def*ghi_} is said in chat, it'll turn it into an underlined part, then an underlined <i>and italics</i> part, finally an underlined part
@ -279,8 +275,8 @@ public final class ChatFormatter {
if (rce.isPresent())
e = rce.get()[0];
DebugCommand.SendDebugMessage("After RC - Start: " + s + " - End: " + e);
if (e - s < 1) {
DebugCommand.SendDebugMessage("Skipping section because of remchars (length would be " + (e - s) + ")");
if (e - s < 0) { //e-s==0 means the end char is the same as start char, so one char message
DebugCommand.SendDebugMessage("Skipping section because of remchars (length would be " + (e - s + 1) + ")");
continue;
}
originaltext = str.substring(s, e + 1);

View file

@ -45,7 +45,7 @@ public class PlayerJoinLeaveListener implements Listener {
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
@Override
public void run() {
p.setPlayerListName(p.getName() + mp.GetFormattedFlair());
mp.FlairUpdate();
}
};
tt.mp = cp;
@ -78,8 +78,6 @@ public class PlayerJoinLeaveListener implements Listener {
String nwithoutformatting = PluginMain.essentials.getUser(p).getNickname();
updatePlayerColors(p);
int index;
if (nwithoutformatting != null) {
while ((index = nwithoutformatting.indexOf("§k")) != -1)
@ -90,7 +88,9 @@ public class PlayerJoinLeaveListener implements Listener {
nwithoutformatting = p.getName();
PlayerListener.nicknames.put(nwithoutformatting, p.getUniqueId());
cp.FlairUpdate();
Bukkit.getScheduler().runTask(PluginMain.Instance, () -> {
updatePlayerColors(p, cp); //TODO: Doesn't have effect
});
if (cp.ChatOnly || p.getGameMode().equals(GameMode.SPECTATOR)) {
cp.ChatOnly = false;
@ -141,7 +141,12 @@ public class PlayerJoinLeaveListener implements Listener {
}
}
public static void updatePlayerColors(Player player) {
public static void updatePlayerColors(Player player) { //Probably while ingame (/u ncolor)
updatePlayerColors(player, ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class));
}
public static void updatePlayerColors(Player player, ChatPlayer cp) { //Probably at join
player.setDisplayName(getPlayerDisplayName(player));
cp.FlairUpdate(); //Update in list
}
}