Réorganisation des dépendances + configuration avancée des projets

This commit is contained in:
Marc Baloup 2016-11-26 19:00:43 +01:00
parent 40942fb25f
commit 13655c1efa
11 changed files with 30 additions and 836 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target/
dependency-reduced-pom.xml

13
pom.xml
View File

@ -21,6 +21,12 @@
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.11-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>fr.pandacube.local_dependencies</groupId>
<artifactId>bungeeperms</artifactId>
@ -28,12 +34,5 @@
<scope>system</scope>
<systemPath>${project.basedir}/../libs/BungeePerms-3.0-alpha1-modif.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>fr.pandacube.pandacube</groupId>
<artifactId></artifactId>
<version>${project.version}</version>
</dependency>
-->
</dependencies>
</project>

View File

@ -0,0 +1,23 @@
package fr.pandacube.java.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
public class ThrowableUtil {
public static String stacktraceToString(Throwable t) {
if (t == null) return null;
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
try (PrintStream ps = new PrintStream(os, false, "UTF-8")) {
t.printStackTrace(ps);
ps.flush();
}
return os.toString("UTF-8");
} catch (IOException e) {
return null;
}
}
}

View File

@ -1,82 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public enum ChatColor {
BLACK('0', "black"),
DARK_BLUE('1', "dark_blue"),
DARK_GREEN('2', "dark_green"),
DARK_AQUA('3', "dark_aqua"),
DARK_RED('4', "dark_red"),
DARK_PURPLE('5', "dark_purple"),
GOLD('6', "gold"),
GRAY('7', "gray"),
DARK_GRAY('8', "dark_gray"),
BLUE('9', "blue"),
GREEN('a', "green"),
AQUA('b', "aqua"),
RED('c', "red"),
LIGHT_PURPLE('d', "light_purple"),
YELLOW('e', "yellow"),
WHITE('f', "white"),
MAGIC('k', "obfuscated"),
BOLD('l', "bold"),
STRIKETHROUGH('m', "strikethrough"),
UNDERLINE('n', "underline"),
ITALIC('o', "italic"),
RESET('r', "reset");
public static final char COLOR_CHAR = '\u00a7';
public static final String ALL_CODES = "0123456789AaBbCcDdEeFfKkLlMmNnOoRr";
public static final Pattern STRIP_COLOR_PATTERN;
private static final Map<Character, ChatColor> BY_CHAR;
private final char code;
private final String toString;
private final String name;
private ChatColor(char code, String name) {
this.code = code;
this.name = name;
toString = new String(new char[] { '\u00a7', code });
}
@Override
public String toString() {
return toString;
}
public static String stripColor(String input) {
if (input == null) return null;
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
}
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
char[] b2 = textToTranslate.toCharArray();
for (int i = 0; i < b2.length - 1; ++i) {
if (b2[i] != altColorChar || "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b2[i + 1]) <= -1) continue;
b2[i] = 167;
b2[i + 1] = Character.toLowerCase(b2[i + 1]);
}
return new String(b2);
}
public static ChatColor getByChar(char code) {
return BY_CHAR.get(Character.valueOf(code));
}
public String getName() {
return name;
}
static {
STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
BY_CHAR = new HashMap<>();
for (ChatColor colour : ChatColor.values())
BY_CHAR.put(Character.valueOf(colour.code), colour);
}
}

View File

@ -1,10 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api;
public enum ChatMessageType {
CHAT, SYSTEM, ACTION_BAR;
private ChatMessageType() {}
}

View File

@ -1,215 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.util.ArrayList;
import java.util.List;
import net.md_5.bungee.api.ChatColor;
public abstract class BaseComponent {
BaseComponent parent;
private ChatColor color;
private Boolean bold;
private Boolean italic;
private Boolean underlined;
private Boolean strikethrough;
private Boolean obfuscated;
private String insertion;
private List<BaseComponent> extra;
private ClickEvent clickEvent;
private HoverEvent hoverEvent;
BaseComponent(BaseComponent old) {
setColor(old.getColorRaw());
setBold(old.isBoldRaw());
setItalic(old.isItalicRaw());
setUnderlined(old.isUnderlinedRaw());
setStrikethrough(old.isStrikethroughRaw());
setObfuscated(old.isObfuscatedRaw());
setInsertion(old.getInsertion());
setClickEvent(old.getClickEvent());
setHoverEvent(old.getHoverEvent());
if (old.getExtra() != null) for (BaseComponent component : old.getExtra())
this.addExtra(component.duplicate());
}
public abstract BaseComponent duplicate();
public static /* varargs */ String toLegacyText(BaseComponent... components) {
StringBuilder builder = new StringBuilder();
for (BaseComponent msg : components)
builder.append(msg.toLegacyText());
return builder.toString();
}
public static /* varargs */ String toPlainText(BaseComponent... components) {
StringBuilder builder = new StringBuilder();
for (BaseComponent msg : components)
builder.append(msg.toPlainText());
return builder.toString();
}
public ChatColor getColor() {
if (color == null) {
if (parent == null) return ChatColor.WHITE;
return parent.getColor();
}
return color;
}
public ChatColor getColorRaw() {
return color;
}
public boolean isBold() {
if (bold == null) return parent != null && parent.isBold();
return bold;
}
public Boolean isBoldRaw() {
return bold;
}
public boolean isItalic() {
if (italic == null) return parent != null && parent.isItalic();
return italic;
}
public Boolean isItalicRaw() {
return italic;
}
public boolean isUnderlined() {
if (underlined == null) return parent != null && parent.isUnderlined();
return underlined;
}
public Boolean isUnderlinedRaw() {
return underlined;
}
public boolean isStrikethrough() {
if (strikethrough == null) return parent != null && parent.isStrikethrough();
return strikethrough;
}
public Boolean isStrikethroughRaw() {
return strikethrough;
}
public boolean isObfuscated() {
if (obfuscated == null) return parent != null && parent.isObfuscated();
return obfuscated;
}
public Boolean isObfuscatedRaw() {
return obfuscated;
}
public void setExtra(List<BaseComponent> components) {
for (BaseComponent component : components)
component.parent = this;
extra = components;
}
public void addExtra(String text) {
this.addExtra(new TextComponent(text));
}
public void addExtra(BaseComponent component) {
if (extra == null) extra = new ArrayList<>();
component.parent = this;
extra.add(component);
}
public boolean hasFormatting() {
return color != null || bold != null || italic != null || underlined != null || strikethrough != null
|| obfuscated != null || hoverEvent != null || clickEvent != null;
}
public String toPlainText() {
StringBuilder builder = new StringBuilder();
this.toPlainText(builder);
return builder.toString();
}
void toPlainText(StringBuilder builder) {
if (extra != null) for (BaseComponent e2 : extra)
e2.toPlainText(builder);
}
public String toLegacyText() {
StringBuilder builder = new StringBuilder();
this.toLegacyText(builder);
return builder.toString();
}
void toLegacyText(StringBuilder builder) {
if (extra != null) for (BaseComponent e2 : extra)
e2.toLegacyText(builder);
}
public void setColor(ChatColor color) {
this.color = color;
}
public void setBold(Boolean bold) {
this.bold = bold;
}
public void setItalic(Boolean italic) {
this.italic = italic;
}
public void setUnderlined(Boolean underlined) {
this.underlined = underlined;
}
public void setStrikethrough(Boolean strikethrough) {
this.strikethrough = strikethrough;
}
public void setObfuscated(Boolean obfuscated) {
this.obfuscated = obfuscated;
}
public void setInsertion(String insertion) {
this.insertion = insertion;
}
public void setClickEvent(ClickEvent clickEvent) {
this.clickEvent = clickEvent;
}
public void setHoverEvent(HoverEvent hoverEvent) {
this.hoverEvent = hoverEvent;
}
@Override
public String toString() {
return "BaseComponent(color=" + (getColor()) + ", bold=" + bold + ", italic=" + italic + ", underlined="
+ underlined + ", strikethrough=" + strikethrough + ", obfuscated=" + obfuscated + ", insertion="
+ getInsertion() + ", extra=" + getExtra() + ", clickEvent=" + getClickEvent() + ", hoverEvent="
+ getHoverEvent() + ")";
}
public BaseComponent() {}
public String getInsertion() {
return insertion;
}
public List<BaseComponent> getExtra() {
return extra;
}
public ClickEvent getClickEvent() {
return clickEvent;
}
public HoverEvent getHoverEvent() {
return hoverEvent;
}
}

View File

@ -1,37 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.beans.ConstructorProperties;
public final class ClickEvent {
private final Action action;
private final String value;
public Action getAction() {
return action;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return "ClickEvent(action=" + (getAction()) + ", value=" + getValue() + ")";
}
@ConstructorProperties(value = { "action", "value" })
public ClickEvent(Action action, String value) {
this.action = action;
this.value = value;
}
public static enum Action {
OPEN_URL, OPEN_FILE, RUN_COMMAND, SUGGEST_COMMAND, CHANGE_PAGE;
private Action() {}
}
}

View File

@ -1,122 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.util.ArrayList;
import java.util.List;
import net.md_5.bungee.api.ChatColor;
public class ComponentBuilder {
private TextComponent current;
private final List<BaseComponent> parts = new ArrayList<>();
public ComponentBuilder(ComponentBuilder original) {
current = new TextComponent(original.current);
for (BaseComponent baseComponent : original.parts)
parts.add(baseComponent.duplicate());
}
public ComponentBuilder(String text) {
current = new TextComponent(text);
}
public ComponentBuilder append(String text) {
return this.append(text, FormatRetention.ALL);
}
public ComponentBuilder append(String text, FormatRetention retention) {
parts.add(current);
current = new TextComponent(current);
current.setText(text);
retain(retention);
return this;
}
public ComponentBuilder color(ChatColor color) {
current.setColor(color);
return this;
}
public ComponentBuilder bold(boolean bold) {
current.setBold(bold);
return this;
}
public ComponentBuilder italic(boolean italic) {
current.setItalic(italic);
return this;
}
public ComponentBuilder underlined(boolean underlined) {
current.setUnderlined(underlined);
return this;
}
public ComponentBuilder strikethrough(boolean strikethrough) {
current.setStrikethrough(strikethrough);
return this;
}
public ComponentBuilder obfuscated(boolean obfuscated) {
current.setObfuscated(obfuscated);
return this;
}
public ComponentBuilder insertion(String insertion) {
current.setInsertion(insertion);
return this;
}
public ComponentBuilder event(ClickEvent clickEvent) {
current.setClickEvent(clickEvent);
return this;
}
public ComponentBuilder event(HoverEvent hoverEvent) {
current.setHoverEvent(hoverEvent);
return this;
}
public ComponentBuilder reset() {
return retain(FormatRetention.NONE);
}
public ComponentBuilder retain(FormatRetention retention) {
TextComponent previous = current;
switch (retention) {
case NONE: {
current = new TextComponent(current.getText());
break;
}
case ALL: {
break;
}
case EVENTS: {
current = new TextComponent(current.getText());
current.setInsertion(previous.getInsertion());
current.setClickEvent(previous.getClickEvent());
current.setHoverEvent(previous.getHoverEvent());
break;
}
case FORMATTING: {
current.setClickEvent(null);
current.setHoverEvent(null);
}
}
return this;
}
public BaseComponent[] create() {
parts.add(current);
return parts.toArray(new BaseComponent[parts.size()]);
}
public static enum FormatRetention {
NONE, FORMATTING, EVENTS, ALL;
private FormatRetention() {}
}
}

View File

@ -1,38 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.beans.ConstructorProperties;
import java.util.Arrays;
public final class HoverEvent {
private final Action action;
private final BaseComponent[] value;
public Action getAction() {
return action;
}
public BaseComponent[] getValue() {
return value;
}
@Override
public String toString() {
return "HoverEvent(action=" + (getAction()) + ", value=" + Arrays.deepToString(getValue()) + ")";
}
@ConstructorProperties(value = { "action", "value" })
public HoverEvent(Action action, BaseComponent[] value) {
this.action = action;
this.value = value;
}
public static enum Action {
SHOW_TEXT, SHOW_ACHIEVEMENT, SHOW_ITEM, SHOW_ENTITY;
private Action() {}
}
}

View File

@ -1,152 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.beans.ConstructorProperties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.md_5.bungee.api.ChatColor;
public class TextComponent extends BaseComponent {
private static final Pattern url = Pattern.compile("^(?:(https?)://)?([-\\w_\\.]{2,}\\.[a-z]{2,4})(/\\S*)?$");
private String text;
public static BaseComponent[] fromLegacyText(String message) {
ArrayList<TextComponent> components = new ArrayList<>();
StringBuilder builder = new StringBuilder();
TextComponent component = new TextComponent();
Matcher matcher = url.matcher(message);
block8:
for (int i = 0; i < message.length(); ++i) {
TextComponent old;
char c2 = message.charAt(i);
if (c2 == '\u00a7') {
ChatColor format;
if ((c2 = message.charAt(++i)) >= 'A' && c2 <= 'Z') c2 = (char) (c2 + 32);
if ((format = ChatColor.getByChar(c2)) == null) continue;
if (builder.length() > 0) {
old = component;
component = new TextComponent(old);
old.setText(builder.toString());
builder = new StringBuilder();
components.add(old);
}
switch (format) {
case BOLD: {
component.setBold(true);
continue block8;
}
case ITALIC: {
component.setItalic(true);
continue block8;
}
case UNDERLINE: {
component.setUnderlined(true);
continue block8;
}
case STRIKETHROUGH: {
component.setStrikethrough(true);
continue block8;
}
case MAGIC: {
component.setObfuscated(true);
continue block8;
}
case RESET: {
format = ChatColor.WHITE;
}
default:
}
component = new TextComponent();
component.setColor(format);
continue;
}
int pos = message.indexOf(32, i);
if (pos == -1) pos = message.length();
if (matcher.region(i, pos).find()) {
if (builder.length() > 0) {
old = component;
component = new TextComponent(old);
old.setText(builder.toString());
builder = new StringBuilder();
components.add(old);
}
old = component;
component = new TextComponent(old);
String urlString = message.substring(i, pos);
component.setText(urlString);
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
urlString.startsWith("http") ? urlString : "http://" + urlString));
components.add(component);
i += pos - i - 1;
component = old;
continue;
}
builder.append(c2);
}
if (builder.length() > 0) {
component.setText(builder.toString());
components.add(component);
}
if (components.isEmpty()) components.add(new TextComponent(""));
return components.toArray(new BaseComponent[components.size()]);
}
public TextComponent(TextComponent textComponent) {
super(textComponent);
setText(textComponent.getText());
}
public /* varargs */ TextComponent(BaseComponent... extras) {
setText("");
setExtra(new ArrayList<>(Arrays.asList(extras)));
}
@Override
public BaseComponent duplicate() {
return new TextComponent(this);
}
@Override
protected void toPlainText(StringBuilder builder) {
builder.append(text);
super.toPlainText(builder);
}
@Override
protected void toLegacyText(StringBuilder builder) {
builder.append(getColor());
if (isBold()) builder.append(ChatColor.BOLD);
if (isItalic()) builder.append(ChatColor.ITALIC);
if (isUnderlined()) builder.append(ChatColor.UNDERLINE);
if (isStrikethrough()) builder.append(ChatColor.STRIKETHROUGH);
if (isObfuscated()) builder.append(ChatColor.MAGIC);
builder.append(text);
super.toLegacyText(builder);
}
@Override
public String toString() {
return String.format("TextComponent{text=%s, %s}", text, super.toString());
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@ConstructorProperties(value = { "text" })
public TextComponent(String text) {
this.text = text;
}
public TextComponent() {}
}

View File

@ -1,173 +0,0 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.md_5.bungee.api.ChatColor;
public class TranslatableComponent extends BaseComponent {
private final ResourceBundle locales = ResourceBundle.getBundle("mojang-translations/en_US");
private final Pattern format = Pattern.compile("%(?:(\\d+)\\$)?([A-Za-z%]|$)");
private String translate;
private List<BaseComponent> with;
public TranslatableComponent(TranslatableComponent original) {
super(original);
setTranslate(original.getTranslate());
if (original.getWith() != null) {
ArrayList<BaseComponent> temp = new ArrayList<>();
for (BaseComponent baseComponent : original.getWith())
temp.add(baseComponent.duplicate());
setWith(temp);
}
}
public /* varargs */ TranslatableComponent(String translate, Object... with) {
setTranslate(translate);
ArrayList<BaseComponent> temp = new ArrayList<>();
for (Object w : with) {
if (w instanceof String) {
temp.add(new TextComponent((String) w));
continue;
}
temp.add((BaseComponent) w);
}
setWith(temp);
}
@Override
public BaseComponent duplicate() {
return new TranslatableComponent(this);
}
public void setWith(List<BaseComponent> components) {
for (BaseComponent component : components)
component.parent = this;
with = components;
}
public void addWith(String text) {
this.addWith(new TextComponent(text));
}
public void addWith(BaseComponent component) {
if (with == null) with = new ArrayList<>();
component.parent = this;
with.add(component);
}
@Override
protected void toPlainText(StringBuilder builder) {
String trans;
try {
trans = locales.getString(translate);
} catch (MissingResourceException ex) {
trans = translate;
}
Matcher matcher = format.matcher(trans);
int position = 0;
int i = 0;
while (matcher.find(position)) {
int pos = matcher.start();
if (pos != position) builder.append(trans.substring(position, pos));
position = matcher.end();
String formatCode = matcher.group(2);
switch (formatCode.charAt(0)) {
case 'd':
case 's': {
String withIndex = matcher.group(1);
with.get(withIndex != null ? Integer.parseInt(withIndex) - 1 : i++).toPlainText(builder);
break;
}
case '%': {
builder.append('%');
}
}
}
if (trans.length() != position) builder.append(trans.substring(position, trans.length()));
super.toPlainText(builder);
}
@Override
protected void toLegacyText(StringBuilder builder) {
String trans;
try {
trans = locales.getString(translate);
} catch (MissingResourceException e) {
trans = translate;
}
Matcher matcher = format.matcher(trans);
int position = 0;
int i = 0;
while (matcher.find(position)) {
int pos = matcher.start();
if (pos != position) {
addFormat(builder);
builder.append(trans.substring(position, pos));
}
position = matcher.end();
String formatCode = matcher.group(2);
switch (formatCode.charAt(0)) {
case 'd':
case 's': {
String withIndex = matcher.group(1);
with.get(withIndex != null ? Integer.parseInt(withIndex) - 1 : i++).toLegacyText(builder);
break;
}
case '%': {
addFormat(builder);
builder.append('%');
}
}
}
if (trans.length() != position) {
addFormat(builder);
builder.append(trans.substring(position, trans.length()));
}
super.toLegacyText(builder);
}
private void addFormat(StringBuilder builder) {
builder.append(getColor());
if (isBold()) builder.append(ChatColor.BOLD);
if (isItalic()) builder.append(ChatColor.ITALIC);
if (isUnderlined()) builder.append(ChatColor.UNDERLINE);
if (isStrikethrough()) builder.append(ChatColor.STRIKETHROUGH);
if (isObfuscated()) builder.append(ChatColor.MAGIC);
}
public ResourceBundle getLocales() {
return locales;
}
public Pattern getFormat() {
return format;
}
public String getTranslate() {
return translate;
}
public List<BaseComponent> getWith() {
return with;
}
public void setTranslate(String translate) {
this.translate = translate;
}
@Override
public String toString() {
return "TranslatableComponent(locales=" + getLocales() + ", format=" + getFormat() + ", translate="
+ getTranslate() + ", with=" + getWith() + ")";
}
public TranslatableComponent() {}
}