Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
支持库 v1.0 基础完成
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonLake committed Jun 15, 2017
1 parent 1230a08 commit eedd848
Show file tree
Hide file tree
Showing 14 changed files with 708 additions and 4 deletions.
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>jar-with-dependencies</descriptorRefs>
</configuration>
<executions>
<execution>
<id>mark-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down
53 changes: 52 additions & 1 deletion src/main/java/com/minecraft/moonlake/chat/ChatClickEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,43 @@

package com.minecraft.moonlake.chat;

/**
* <h1>ChatClickEvent</h1>
* 聊天组件点击事件
*
* @version 1.0
* @author Month_Light
*/
public class ChatClickEvent {

private final Action action;
private final String value;

/**
* 聊天组件点击事件构造函数
*
* @param action 交互类型
* @param value 值
*/
public ChatClickEvent(Action action, String value) {
this.action = action;
this.value = value;
}

/**
* 获取此聊天组件点击事件的交互类型
*
* @return 交互类型
*/
public Action getAction() {
return action;
}

/**
* 获取此聊天组件点击事件的值
*
* @return 值
*/
public String getValue() {
return value;
}
Expand Down Expand Up @@ -62,15 +85,43 @@ public String toString() {
'}';
}

/**
* <h1>Action</h1>
* 聊天组件点击事件交互类型
*
* @version 1.0
* @author Month_Light
*/
public enum Action {


/**
* 交互类型: 打开链接
*/
OPEN_URL,
/**
* 交互类型: 打开文件
*/
OPEN_FILE,
/**
* 交互类型: 执行命令
*/
RUN_COMMAND,
/**
* 交互类型: 替换命令
*/
SUGGEST_COMMAND,
/**
* 交互类型: 改变页面
*/
CHANGE_PAGE,
;

/**
* 从名称返回聊天组件点击事件交互类型
*
* @param name 名称
* @return Action
*/
public static Action fromName(String name) {
return Action.valueOf(name.toUpperCase());
}
Expand Down
100 changes: 100 additions & 0 deletions src/main/java/com/minecraft/moonlake/chat/ChatColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,152 @@

package com.minecraft.moonlake.chat;

/**
* <h1>ChatColor</h1>
* 聊天组件颜色
*
* @version 1.0
* @author Month_Light
*/
public enum ChatColor {

/**
* <div style='background-color: rgb(0, 0, 0)'><span style='color: white'>\u00260 黑色</span></div>
*/
BLACK('0'),
/**
* <div style='background-color: rgb(0, 0, 170)'><span style='color: white'>\u00261 深蓝</span></div>
*/
DARK_BLUE('1'),
/**
* <div style='background-color: rgb(0, 170, 0)'><span style='color: white'>\u00262 深绿</span></div>
*/
DARK_GREEN('2'),
/**
* <div style='background-color: rgb(0, 170, 170)'><span style='color: white'>\u00263 深青</span></div>
*/
DARK_AQUA('3'),
/**
* <div style='background-color: rgb(170, 0, 0)'><span style='color: white'>\u00264 深红</span></div>
*/
DARK_RED('4'),
/**
* <div style='background-color: rgb(170, 0, 170)'><span style='color: white'>\u00265 深紫</span></div>
*/
DARK_PURPLE('5'),
/**
* <div style='background-color: rgb(255, 170, 0)'><span style='color: white'>\u00266 橙色</span></div>
*/
GOLD('6'),
/**
* <div style='background-color: rgb(85, 85, 85)'><span style='color: white'>\u00267 灰色</span></div>
*/
GRAY('7'),
/**
* <div style='background-color: rgb(170, 170, 170)'><span style='color: white'>\u00268 深灰</span></div>
*/
DARK_GRAY('8'),
/**
* <div style='background-color: rgb(85, 85, 255)'><span style='color: white'>\u00269 蓝色</span></div>
*/
BLUE('9'),
/**
* <div style='background-color: rgb(85, 255, 85)'><span style='color: white'>\u0026a 绿色</span></div>
*/
GREEN('a'),
/**
* <div style='background-color: rgb(85, 255, 255)'><span style='color: white'>\u0026b 青色</span></div>
*/
AQUA('b'),
/**
* <div style='background-color: rgb(255, 85, 85)'><span style='color: white'>\u0026c 红色</span></div>
*/
RED('c'),
/**
* <div style='background-color: rgb(255, 85, 255)'><span style='color: white'>\u0026d 紫色</span></div>
*/
LIGHT_PURPLE('d'),
/**
* <div style='background-color: rgb(255, 255, 85)'><span style='color: black'>\u0026e 黄色</span></div>
*/
YELLOW('e'),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'>\u0026f 白色</span></div>
*/
WHITE('f'),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'>\u0026k 随机字符</span></div>
*/
OBFUSCATED('k', true),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'><b>\u0026l 文字加粗</b></span></div>
*/
BOLD('l', true),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'><s>\u0026m 文字删除线</s></span></div>
*/
STRIKETHROUGH('m', true),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'><u>\u0026n 文字下划线</u></span></div>
*/
UNDERLINE('n', true),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'><i>\u0026o 文字斜体</i></span></div>
*/
ITALIC('o', true),
/**
* <div style='background-color: rgb(255, 255, 255)'><span style='color: black'>\u0026r 重置</span></div>
*/
RESET('r'),
;

private final char code;
private final boolean format;

/**
* 聊天组件颜色构造函数
*
* @param code 颜色码
*/
ChatColor(char code) {
this(code, false);
}

/**
* 聊天组件颜色构造函数
*
* @param code 颜色码
* @param format 是否文字格式符
*/
ChatColor(char code, boolean format) {
this.code = code;
this.format = format;
}

/**
* 获取此聊天组件颜色的颜色码
*
* @return 颜色嘛
*/
public char getCode() {
return code;
}

/**
* 获取此聊天组件颜色是否为文字格式符
*
* @return 是否文字格式符
*/
public boolean isFormat() {
return format;
}

/**
* 从名称返回聊天组件颜色
*
* @param name 名称
* @return ChatColor
*/
public static ChatColor fromName(String name) {
return ChatColor.valueOf(name.toUpperCase());
}
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/com/minecraft/moonlake/chat/ChatComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,79 @@

import java.util.List;

/**
* <h1>ChatComponent</h1>
* 聊天组件接口
*
* @version 1.0
* @author Month_Light
*/
public interface ChatComponent {

/**
* 获取此聊天组件的聊天样式对象
*
* @return 聊天样式对象
*/
ChatStyle getStyle();

/**
* 设置此聊天组件的聊天样式对象
*
* @param style 聊天样式对象
* @throws IllegalArgumentException 如果聊天样式对象为 {@code null} 则抛出异常
*/
ChatComponent setStyle(ChatStyle style);

/**
* 获取此聊天组件附加组件列表
*
* @return 附加组件列表
*/
List<ChatComponent> getExtras();

/**
* 获取此聊天组件附加组件列表大小
*
* @return 附加组件列表大小
*/
int getExtraSize();

/**
* 将指定文本附加到此聊天组件的附加列表中
*
* @param text 文本
* @throws IllegalArgumentException 如果文本对象为 {@code null} 则抛出异常
*/
ChatComponent append(String text);

/**
* 将指定聊天组件附加到此聊天组件的附加列表中
*
* @param extra 附加
* @throws IllegalArgumentException 如果附加对象为 {@code null} 则抛出异常
*/
ChatComponent append(ChatComponent extra);

/**
* 将此聊天组件转换为 Json 格式字符串
*
* @return Json
*/
String toJson();

/**
* 将此聊天组件转换为源文本内容
*
* @return 源文本内容
*/
String toRaw();

/**
* 将此聊天组件转换为源文本内容
*
* @param color 是否附加颜色
* @return 源文本内容
*/
String toRaw(boolean color);
}
11 changes: 11 additions & 0 deletions src/main/java/com/minecraft/moonlake/chat/ChatComponentBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,22 @@
import java.util.ArrayList;
import java.util.List;

/**
* <h1>ChatComponentBase</h1>
* 聊天组件基础抽象实现类
*
* @version 1.0
* @author Month_Light
* @see ChatComponent
*/
public abstract class ChatComponentBase implements ChatComponent {

private ChatStyle style;
private List<ChatComponent> extras;

/**
* 聊天组件基础抽象实现类构造函数
*/
ChatComponentBase() {
this.extras = new ArrayList<>();
}
Expand Down
Loading

0 comments on commit eedd848

Please sign in to comment.