1
mirror of https://github.com/CarmJos/cn2b2t-project.git synced 2024-09-19 22:05:45 +00:00

修改依赖

This commit is contained in:
carm 2021-10-20 22:50:33 +08:00
parent 298d8c1e4c
commit 5bf2c53708
3 changed files with 247 additions and 413 deletions

View File

@ -107,7 +107,7 @@ public class GUI {
public final void setItem(int index, GUIItem item) {
if (item == null) {
this.items[index] = new GUIItem(new ItemStack(0));
this.items[index] = new GUIItem(new ItemStack(Material.AIR));
} else {
this.items[index] = item;
}

View File

@ -13,7 +13,6 @@ import org.cn2b2t.core.managers.utils.scoreboard.CeramicScoreboard;
import org.cn2b2t.core.managers.utils.scoreboard.ScoreBoardRender;
import org.cn2b2t.core.modules.gui.GUI;
import org.cn2b2t.core.utils.UUIDUtils;
import org.spigotmc.AsyncCatcher;
import java.io.File;
import java.io.IOException;
@ -142,9 +141,6 @@ public class User {
}
public <T extends AbstractUserHandler> T getHandler(Class<T> c) {
if (isUnregistered()) {
AsyncCatcher.catchOp("handler get when user unloaded");
}
int position = c.getName().lastIndexOf('.');
String name = c.getName().substring(position + 1);
if (containsHandler(name)) {
@ -155,9 +151,6 @@ public class User {
}
public Object getHandler(String s) {
if (isUnregistered()) {
AsyncCatcher.catchOp("handler get when user unloaded");
}
if (containsHandler(s)) {
return handler.get(s);
} else {
@ -170,9 +163,6 @@ public class User {
}
public <T> T getHandler(String s, Class T) {
if (isUnregistered()) {
AsyncCatcher.catchOp("handler get when user unloaded");
}
if (containsHandler(s)) {
return (T) handler.get(s);
} else {

View File

@ -14,157 +14,18 @@ import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static net.md_5.bungee.api.ChatColor.*;
public class BBCodeChatParser {
private static final Pattern pattern;
private static final Pattern strip_bbcode_pattern;
// private final Logger logger;
// public BBCodeChatParser(final Logger logger) {
// this.logger = logger;
// }
//
// public BBCodeChatParser() {
// this(Logger.getLogger(BBCodeChatParser.class.getName()));
// }
static {
pattern = Pattern.compile("(?is)(?=\\n)|(?:[&§](?<color>[0-9A-FK-OR]))|(?:\\[(?<tag>/?(?:b|i|u|s|nocolor|nobbcode)|(?:url|command|hover|suggest|color)=(?<value>(?:(?:[^]\\[]*)\\[(?:[^]\\[]*)\\])*(?:[^]\\[]*))|/(?:url|command|hover|suggest|color))\\])|(?:\\[(?<implicitTag>url|command|suggest)\\](?=(?<implicitValue>.*?)\\[/\\k<implicitTag>\\]))");
strip_bbcode_pattern = Pattern.compile("(?is)(?:\\[(?<tag>/?(?:b|i|u|s|nocolor|nobbcode)|(?:url|command|hover|suggest|color)=(?<value>(?:(?:[^]\\[]*)\\[(?:[^]\\[]*)\\])*(?:[^]\\[]*))|/(?:url|command|hover|suggest|color))\\])|(?:\\[(?<implicitTag>url|command|suggest)\\](?=(?<implicitValue>.*?)\\[/\\k<implicitTag>\\]))");
}
// public static BaseComponent[] parseChatColor(BaseComponent[] bcs){
// List<BaseComponent> list = new LinkedList();
//
// ChatColor lastColor = ChatColor.GRAY;
// boolean lastBold = false;
// boolean lastItalic = false;
// boolean lastObfuscated = false;
// boolean lastUnderlined = false;
// boolean lastStrikethrough = false;
// for(BaseComponent bc : bcs){
// if(bc instanceof TextComponent){
// TextComponent tc = (TextComponent)bc;
// String raw = tc.getText();
// System.out.print("raw: "+raw);
// if(raw.contains("§")){
// TextComponent tce = new TextComponent();
// while(raw.contains("§")){
// if(!raw.startsWith("§")){
// tce.setText(raw.substring(0,raw.indexOf('§')));
// raw = raw.substring(raw.indexOf('§'));
// }
// if(raw.length()-1>raw.indexOf('§')){
// char c = Character.toLowerCase(raw.charAt(raw.indexOf('§')+1));
// if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
// if (!tce.getText().isEmpty()) {
// tce.setColor(lastColor);
// tce.setBold(lastBold);
// tce.setItalic(lastItalic);
// tce.setObfuscated(lastObfuscated);
// tce.setUnderlined(lastUnderlined);
// tce.setStrikethrough(lastStrikethrough);
// if(bc.getHoverEvent()!=null){
// tce.setHoverEvent(bc.getHoverEvent());
// }
// if(bc.getClickEvent()!=null){
// tce.setClickEvent(bc.getClickEvent());
// }
// list.add(tce.duplicate());
// tce = new TextComponent();
// System.out.print("动作: 输出1");
// }
// lastColor = ChatColor.getByChar(c);
// lastBold = lastItalic = lastObfuscated = lastUnderlined = lastStrikethrough = false;
// raw = raw.substring(2, raw.length()-1);
// System.out.print("动作: 染色");
// }else if(c == 'm'){
// lastStrikethrough = true;
// raw = raw.substring(2, raw.length()-1);
// System.out.print("动作: 划掉");
// }else if(c == 'n'){
// lastUnderlined = true;
// raw = raw.substring(2, raw.length()-1);
// System.out.print("动作: 下划线");
// }else if(c == 'o'){
// lastItalic = true;
// raw = raw.substring(2, raw.length()-1);
// System.out.print("动作: 斜体");
// }else if(c == 'l'){
// lastBold = true;
// raw = raw.substring(2, raw.length()-1);
// System.out.print("动作: 加粗");
// }else if(c == 'k'){
// lastObfuscated = true;
// raw = raw.substring(2, raw.length()-1);
// System.out.print("动作: 混乱");
// }else if(c == 'r'){
// lastColor = ChatColor.RESET;
// System.out.print("动作: 重设");
// }
// }else{
// raw = raw.substring(0, raw.length()-1);
// }
// if(!tce.getText().isEmpty()){
// tce.setColor(lastColor);
// tce.setBold(lastBold);
// tce.setItalic(lastItalic);
// tce.setObfuscated(lastObfuscated);
// tce.setUnderlined(lastUnderlined);
// tce.setStrikethrough(lastStrikethrough);
// if(bc.getHoverEvent()!=null){
// tce.setHoverEvent(bc.getHoverEvent());
// }
// if(bc.getClickEvent()!=null){
// tce.setClickEvent(bc.getClickEvent());
// }
// list.add((BaseComponent)tce.duplicate());
// tce = new TextComponent();
// System.out.print("动作: 输出2");
// }
// }
// if(!raw.isEmpty()){
// tce.setText(raw);
// tce.setColor(lastColor);
// tce.setBold(lastBold);
// tce.setItalic(lastItalic);
// tce.setObfuscated(lastObfuscated);
// tce.setUnderlined(lastUnderlined);
// tce.setStrikethrough(lastStrikethrough);
// if(bc.getHoverEvent()!=null){
// tce.setHoverEvent(bc.getHoverEvent());
// }
// if(bc.getClickEvent()!=null){
// tce.setClickEvent(bc.getClickEvent());
// }
// list.add((BaseComponent)tce.duplicate());
// System.out.print("动作: 输出3");
// }
// }else{
// bc.setColor(lastColor);
// bc.setBold(lastBold);
// bc.setItalic(lastItalic);
// bc.setObfuscated(lastObfuscated);
// bc.setUnderlined(lastUnderlined);
// bc.setStrikethrough(lastStrikethrough);
// list.add(bc);
// System.out.print("动作: 输出4");
// }
// }else{
// bc.setColor(lastColor);
// bc.setBold(lastBold);
// bc.setItalic(lastItalic);
// bc.setObfuscated(lastObfuscated);
// bc.setUnderlined(lastUnderlined);
// bc.setStrikethrough(lastStrikethrough);
// list.add(bc);
// System.out.print("动作: 输出5");
// }
// }
//
// return list.toArray(new BaseComponent[list.size()]);
// }
public static BaseComponent[] parse(final String text) {
final Matcher matcher = BBCodeChatParser.pattern.matcher(text);
TextComponent current = new TextComponent();
@ -194,33 +55,18 @@ public class BBCodeChatParser {
if (group_color != null && nocolorLevel <= 0) {
ChatColor color = ChatColor.getByChar(group_color.charAt(0));
if (color != null) {
Label_0458:
{
switch (color) {
case MAGIC: {
if (MAGIC.equals(color)) {
current.setObfuscated(true);
break Label_0458;
}
case BOLD: {
} else if (BOLD.equals(color)) {
current.setBold(true);
break Label_0458;
}
case STRIKETHROUGH: {
} else if (STRIKETHROUGH.equals(color)) {
current.setStrikethrough(true);
break Label_0458;
}
case UNDERLINE: {
} else if (UNDERLINE.equals(color)) {
current.setUnderlined(true);
break Label_0458;
}
case ITALIC: {
} else if (ITALIC.equals(color)) {
current.setItalic(true);
break Label_0458;
}
case RESET: {
color = ChatColor.WHITE;
break;
}
} else if (RESET.equals(color)) {
color = WHITE;
}
current = new TextComponent();
current.setColor(color);
@ -240,7 +86,6 @@ public class BBCodeChatParser {
}
parsed = true;
}
}
if (group_tag != null && nobbcodeLevel <= 0) {
if (group_tag.matches("(?is)^b$")) {
current.setBold(++forceBold > 0);
@ -278,7 +123,7 @@ public class BBCodeChatParser {
}
}
colorDeque.push(current.getColor());
if (color != null && color != ChatColor.BOLD && color != ChatColor.ITALIC && color != ChatColor.MAGIC && color != ChatColor.RESET && color != ChatColor.STRIKETHROUGH && color != ChatColor.UNDERLINE) {
if (color != null && color != ChatColor.BOLD && color != ChatColor.ITALIC && color != MAGIC && color != ChatColor.RESET && color != ChatColor.STRIKETHROUGH && color != ChatColor.UNDERLINE) {
colorDeque.push(color);
current.setColor(color);
} else {
@ -414,8 +259,7 @@ public class BBCodeChatParser {
matcher.appendTail(stringBuffer2);
current.setText(stringBuffer2.toString());
components.add(current);
return components.toArray(new BaseComponent[components.size()]);
// return parseChatColor(components.toArray(new BaseComponent[components.size()]));
return components.toArray(new BaseComponent[0]);
}
public static String stripBBCode(final String string) {