4
1
mirror of https://e.coding.net/circlecloud/MiaoChat.git synced 2024-12-21 19:08:47 +00:00

init: 项目初始化

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-09-05 15:59:11 +08:00
commit 4462a9baed
15 changed files with 610 additions and 0 deletions

8
.classpath Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
# Eclipse stuff
/.settings
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
/repo
# vim
.*.sw[a-p]
# various other potential build files
/build
/bin
/dist
/manifest.mf
/world
# Mac filesystem dust
*.DS_Store
# intellij
*.iml
*.ipr
*.iws
.idea/
# Project Stuff
/src/main/resources/Soulbound
# Atlassian Stuff
/atlassian-ide-plugin.xml

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MiaoChat</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

65
class.dict Normal file
View File

@ -0,0 +1,65 @@
IIIIiI
IIiIiI
iiIIiI
Iiiiii
IIIIIi
IiIiII
iiIIIi
iIIIii
iIiiIi
iiiIiI
IiiIii
iIiiiI
iiiIIi
IIiIII
IIIIii
IIIiii
iiiiII
iIIiII
IIiiII
iiIIii
IiiIII
iIiIII
IiIIii
iiIiiI
iIiiII
IiiIiI
iiiIII
IIiIIi
iIiIiI
iiIiii
IiIiii
IiIIiI
IiiIIi
IiIIIi
IIiiIi
iIIiIi
iIIIII
IIIiIi
iiiiiI
iIiIIi
IIIiiI
iiiiIi
iiIiIi
IIiiiI
IiiiII
iIIiii
iIiIii
IiIiiI
IIiIii
IiIIII
IIIIII
iIIIIi
IIIiII
iiiiii
IiiiiI
IiIiIi
iiiIii
iIIIiI
iIIiiI
iIiiii
iiIiII
IIiiii
iiIIII
IiiiIi
llllll

BIN
lib/PlaceholderAPI.jar Normal file

Binary file not shown.

24
obf.dict Normal file
View File

@ -0,0 +1,24 @@
if
try
for
int
new
true
null
this
else
void
enum
final
false
class
catch
import
double
public
static
boolean
package
finally
private
protected

134
pom.xml Normal file
View File

@ -0,0 +1,134 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId>
<artifactId>MiaoChat</artifactId>
<version>1.0</version>
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>pw.yumc:YumCore</include>
<include>cn.citycraft:PluginHelper</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>pw.yumc.YumCore</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation>
<relocation>
<pattern>cn.citycraft.PluginHelper</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<options>
<option>-repackageclasses nul.${project.groupId}.for.${project.artifactId}.class</option>
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<ciManagement>
<system>Jenkins</system>
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement>
<properties>
<update.description></update.description>
<update.changes></update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>yumc-repo</id>
<url>http://repo.yumc.pw/content/groups/public/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>jtb</id>
<name>YUMC</name>
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<type>jar</type>
<version>1.10.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>PluginHelper</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>pw.yumc</groupId>
<artifactId>YumCore</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>pw.yumc</groupId>
<artifactId>PlaceholderAPI</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/PlaceholderAPI.jar</systemPath>
</dependency>
</dependencies>
</project>

56
proguard.conf Normal file
View File

@ -0,0 +1,56 @@
# -----不优化-----
-dontoptimize
# -----忽略所有警告-----
-dontwarn
-dontnote
# -----混淆时应用侵入式重载-----
-overloadaggressively
# -----启用混淆字典-----
-obfuscationdictionary obf.dict
-classobfuscationdictionary class.dict
-packageobfuscationdictionary class.dict
# -----保留所有属性
-keepattributes **
# -----公共数据不混淆-----
-keep class cn.citycraft.CommonData.** {*;}
# -----保护所有实体中的字段名称-----
-keepclassmembers class * implements java.io.Serializable { <fields>; }
# -----保护监听方法不被清理-----
-keepclassmembers class * implements org.bukkit.event.Listener {
@org.bukkit.event.EventHandler <methods>;
}
# -----保护枚举方法的完整性-----
-keep enum ** {*;}
# -----保护配置注入不被清理-----
-keepclassmembers class * extends **.config.InjectConfigurationSection {
<fields>;
}
-keepclassmembers class * extends **.config.InjectConfig {
<fields>;
}
# -----保护注解命令方法不被清理-----
-keepclassmembers class **.commands.annotation.** { <methods>; }
-keepclassmembers class * implements **.commands.CommandExecutor { <methods>; }
-keepclassmembers class **.commands.HandlerCommand { <methods>; }
-keepclassmembers class * implements **.commands.HandlerCommands {
@**.commands.HandlerCommand <methods>;
@**.commands.HandlerTabComplete <methods>;
}
# -----保护注解NotProguard标记-----
-keep class **.NotProguard
-keep @**.NotProguard class * {*;}
-keepclassmembers class * {
@**.NotProguard <fields>;
@**.NotProguard <methods>;
}
# -----保护命令解析正常-----
-keepnames class * extends **.commands.BaseCommand

View File

@ -0,0 +1,47 @@
package pw.yumc.MiaoChat;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import pw.yumc.MiaoChat.config.ChatConfig;
import pw.yumc.MiaoChat.listeners.ChatListener;
import pw.yumc.YumCore.commands.CommandArgument;
import pw.yumc.YumCore.commands.CommandExecutor;
import pw.yumc.YumCore.commands.CommandManager;
import pw.yumc.YumCore.commands.annotation.Cmd;
import pw.yumc.YumCore.commands.annotation.Help;
import pw.yumc.YumCore.config.FileConfig;
public class MiaoChat extends JavaPlugin implements CommandExecutor {
private ChatConfig chatConfig;
private FileConfig config;
public ChatConfig getChatConfig() {
return chatConfig;
}
@Override
public FileConfiguration getConfig() {
return config;
}
@Override
public void onEnable() {
new ChatListener();
new CommandManager("MiaoChat", this);
}
@Override
public void onLoad() {
config = new FileConfig();
chatConfig = new ChatConfig();
}
@Cmd(permission = "MiaoChat.reload")
@Help("重载配置文件")
public void reload(final CommandArgument e) {
config.reload();
chatConfig.reload();
e.getSender().sendMessage("§a配置文件已重载!");
}
}

View File

@ -0,0 +1,6 @@
package pw.yumc.MiaoChat.config;
public enum CLICKTYPE {
COMMAND,
SUGGEST;
}

View File

@ -0,0 +1,51 @@
package pw.yumc.MiaoChat.config;
import java.util.LinkedList;
import java.util.List;
import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.config.FileConfig;
public class ChatConfig {
private static String PrefixKey = "Format.Prefix";
private static String SuffixKey = "Format.Suffix";
private final FileConfig config;
private final List<ChatMessagePart> prefixs;
private final List<ChatMessagePart> suffixs;
private ChatMessagePart player;
public ChatConfig() {
config = P.getConfig();
prefixs = new LinkedList<>();
suffixs = new LinkedList<>();
reload();
}
public ChatMessagePart getPlayer() {
return player;
}
public List<ChatMessagePart> getPrefixs() {
return prefixs;
}
public List<ChatMessagePart> getSuffixs() {
return suffixs;
}
public void reload() {
prefixs.clear();
if (config.isSet(PrefixKey)) {
for (final String part : config.getConfigurationSection(PrefixKey).getKeys(false)) {
prefixs.add(new ChatMessagePart(config.getConfigurationSection(PrefixKey + "." + part)));
}
}
player = new ChatMessagePart(config.getConfigurationSection("Format.Player"));
suffixs.clear();
if (config.isSet(SuffixKey)) {
for (final String part : config.getConfigurationSection(SuffixKey).getKeys(false)) {
suffixs.add(new ChatMessagePart(config.getConfigurationSection(SuffixKey + "." + part)));
}
}
}
}

View File

@ -0,0 +1,52 @@
package pw.yumc.MiaoChat.config;
import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
import pw.yumc.YumCore.config.ConfigNode;
import pw.yumc.YumCore.config.InjectConfigurationSection;
import pw.yumc.YumCore.tellraw.Tellraw;
public class ChatMessagePart extends InjectConfigurationSection {
private String text;
private List<String> tip;
@ConfigNode("click.type")
private String typestring;
private transient CLICKTYPE type = CLICKTYPE.SUGGEST;
@ConfigNode("click.command")
private String command;
public ChatMessagePart(final ConfigurationSection config) {
super(config);
if (typestring != null) {
type = CLICKTYPE.valueOf(typestring);
}
}
public Tellraw then(final Tellraw tr, final Player p) {
tr.then(f(p, text));
if (tip != null && !tip.isEmpty()) {
tr.tip(f(p, tip));
}
if (command != null && !command.isEmpty()) {
final String tc = f(p, command);
if (type == CLICKTYPE.SUGGEST) {
tr.suggest(tc);
} else if (type == CLICKTYPE.COMMAND) {
tr.command(tc);
}
}
return tr;
}
private List<String> f(final Player player, final List<String> text) {
return PlaceholderAPI.setPlaceholders(player, text);
}
private String f(final Player player, final String text) {
return PlaceholderAPI.setPlaceholders(player, text);
}
}

View File

@ -0,0 +1,44 @@
package pw.yumc.MiaoChat.listeners;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import pw.yumc.MiaoChat.MiaoChat;
import pw.yumc.MiaoChat.config.ChatConfig;
import pw.yumc.MiaoChat.config.ChatMessagePart;
import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.statistic.Statistics;
import pw.yumc.YumCore.tellraw.Tellraw;
import pw.yumc.YumCore.update.SubscribeTask;
public class ChatListener implements Listener {
MiaoChat plugin = P.getPlugin();
public ChatListener() {
Bukkit.getPluginManager().registerEvents(this, P.instance);
new Statistics();
new SubscribeTask(true, true);
}
@EventHandler
public void onChat(final AsyncPlayerChatEvent e) {
e.setCancelled(true);
final Player p = e.getPlayer();
final ChatConfig cc = plugin.getChatConfig();
final String msg = e.getMessage();
final Tellraw tr = Tellraw.create();
for (final ChatMessagePart cmp : cc.getPrefixs()) {
cmp.then(tr, p);
}
cc.getPlayer().then(tr, p);
for (final ChatMessagePart cmp : cc.getSuffixs()) {
cmp.then(tr, p);
}
tr.then(ChatColor.translateAlternateColorCodes('&', msg));
tr.broadcast();
}
}

View File

@ -0,0 +1,40 @@
#格式化配置
Format:
#前缀配置 于玩家名称前
Prefix:
#顺序
1:
#文本 支持PAPI变量
text: '&6[&a%player_world%&6]'
#悬浮提示 支持PAPI
tip:
- '&6当前所在位置:'
- '&6世界: &d%layer_world%'
- '&6坐标: &aX:%layer_x% Y: %player_y% Z: %player_z%'
- '&c点击即可TP我!'
#点击操作
click:
#操作类型: [COMMAND,SUGGEST]
#COMMAND代表执行命令
#SUGGEST代表命令补全
type: 'COMMAND'
#命令 支持PAPI
command: '/tpa %player_name%'
#玩家名称配置
Player:
text: '&6[&b%player_name%&6] '
tip:
- '点击与我聊天'
click:
type: 'SUGGEST'
command: '/tell %player_name%'
#后缀配置 于玩家名称后 由于一般没人用 我注释掉了
# Suffix:
# 1:
# text: '[变量1]'
# tip:
# - '变量1提示'
# click:
# type: 'COMMAND'
# command: 'say 命令执行'

View File

@ -0,0 +1,22 @@
name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜
website: ${ciManagement.url}
commands:
${project.artifactId}:
description: ${project.artifactId} - ${project.description}
aliases:
- mct
- mchat
usage: §b使用/${project.artifactId} help 查看帮助!
permission: ${project.artifactId}.reload
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions:
${project.artifactId}.use:
description: ${project.artifactId} 使用!
default: true
${project.artifactId}.reload:
description: 重新载入插件!
default: op