mirror of
https://github.com/CarmJos/MoeTeleport.git
synced 2026-06-05 00:28:16 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 47dfad862b | |||
| aa723087d4 | |||
| 55a692243d | |||
| 7862a698bd | |||
| 351f9a8590 | |||
| ce3226ee18 |
@@ -0,0 +1,38 @@
|
||||
name: Release Version
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published # 创建release的时候触发
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: "Set up JDK"
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
# cache: maven
|
||||
server-id: github
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_TOKEN
|
||||
- name: "Package"
|
||||
run: mvn -B package --file pom.xml -Dmaven.javadoc.skip=true -DskipTests
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
- name: "Upload Release Asset"
|
||||
id: upload-release-asset
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: asset/*.jar
|
||||
asset_content_type: application/java-archive
|
||||
@@ -41,7 +41,9 @@
|
||||
- 拒绝一个请求,可以限定某个玩家。
|
||||
|
||||
# /home [name]
|
||||
- 返回家 (不填name会返回第一个家,若存在home则优先返回home)
|
||||
- 返回设定的家
|
||||
- 不填name会返回第一个设置的家
|
||||
- 若存在名为“home”的家则优先返回“home”。
|
||||
# /listHome
|
||||
- 列出所有家的位置
|
||||
# /setHome [name]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<artifactId>moeteleport</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<version>1.2.0</version>
|
||||
|
||||
<name>MoeTeleport</name>
|
||||
<description>喵喵传送,简单的传送、设置家的插件。</description>
|
||||
@@ -161,12 +161,12 @@
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<outputDirectory>${project.basedir}/asset/</outputDirectory>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
||||
@@ -15,11 +15,13 @@ import cc.carm.plugin.moeteleport.manager.ConfigManager;
|
||||
import cc.carm.plugin.moeteleport.manager.RequestManager;
|
||||
import cc.carm.plugin.moeteleport.manager.TeleportManager;
|
||||
import cc.carm.plugin.moeteleport.manager.UserManager;
|
||||
import cc.carm.plugin.moeteleport.model.UserData;
|
||||
import cc.carm.plugin.moeteleport.util.ColorParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,61 +29,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
private static Main instance;
|
||||
public static boolean debugMode = true;
|
||||
|
||||
private static Main instance;
|
||||
private UserManager userManager;
|
||||
private TeleportManager teleportManager;
|
||||
private RequestManager requestManager;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
log("加载配置文件...");
|
||||
ConfigManager.initConfig();
|
||||
|
||||
log("加载用户管理器...");
|
||||
this.userManager = new UserManager(this);
|
||||
|
||||
log("加载请求管理器...");
|
||||
this.requestManager = new RequestManager(this);
|
||||
|
||||
log("注册监听器...");
|
||||
regListener(new UserListener());
|
||||
|
||||
log("注册指令...");
|
||||
registerCommand("back", new BackCommand());
|
||||
|
||||
registerCommand("home", new GoHomeCommand(), new HomeNameCompleter());
|
||||
registerCommand("delHome", new DelHomeCommand(), new HomeNameCompleter());
|
||||
registerCommand("setHome", new SetHomeCommand());
|
||||
registerCommand("listHome", new ListHomeCommand());
|
||||
|
||||
registerCommand("tpa", new TpaCommand(), new PlayerNameCompleter());
|
||||
registerCommand("tpaHere", new TpaCommand(), new PlayerNameCompleter());
|
||||
registerCommand("tpAccept", new TpHandleCommand(), new TpRequestCompleter());
|
||||
registerCommand("tpDeny", new TpHandleCommand(), new TpRequestCompleter());
|
||||
|
||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
getRequestManager().shutdown();
|
||||
|
||||
log("卸载监听器...");
|
||||
Bukkit.getServicesManager().unregisterAll(this);
|
||||
|
||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册监听器
|
||||
*
|
||||
@@ -131,4 +84,60 @@ public class Main extends JavaPlugin {
|
||||
return Main.getInstance().requestManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
log("加载配置文件...");
|
||||
ConfigManager.initConfig();
|
||||
|
||||
log("加载用户管理器...");
|
||||
this.userManager = new UserManager(this);
|
||||
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
log(" 加载现有用户数据...");
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserData data = Main.getUserManager().loadData(player.getUniqueId());
|
||||
Main.getUserManager().getUserDataMap().put(player.getUniqueId(), data);
|
||||
}
|
||||
}
|
||||
|
||||
log("加载请求管理器...");
|
||||
this.requestManager = new RequestManager(this);
|
||||
|
||||
log("注册监听器...");
|
||||
regListener(new UserListener());
|
||||
|
||||
log("注册指令...");
|
||||
registerCommand("back", new BackCommand());
|
||||
|
||||
registerCommand("home", new GoHomeCommand(), new HomeNameCompleter());
|
||||
registerCommand("delHome", new DelHomeCommand(), new HomeNameCompleter());
|
||||
registerCommand("setHome", new SetHomeCommand());
|
||||
registerCommand("listHome", new ListHomeCommand());
|
||||
|
||||
registerCommand("tpa", new TpaCommand(), new PlayerNameCompleter());
|
||||
registerCommand("tpaHere", new TpaCommand(), new PlayerNameCompleter());
|
||||
registerCommand("tpAccept", new TpHandleCommand(), new TpRequestCompleter());
|
||||
registerCommand("tpDeny", new TpHandleCommand(), new TpRequestCompleter());
|
||||
|
||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
getRequestManager().shutdown();
|
||||
|
||||
log("卸载监听器...");
|
||||
Bukkit.getServicesManager().unregisterAll(this);
|
||||
|
||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import cc.carm.plugin.moeteleport.configuration.values.ConfigValueMap;
|
||||
|
||||
public class PluginConfig {
|
||||
|
||||
public static final ConfigValueMap<String, Integer> PERMISSIONS = new ConfigValueMap<>(
|
||||
"permissions", s -> s, Integer.class
|
||||
public static final ConfigValueMap<Integer, String> PERMISSIONS = new ConfigValueMap<>(
|
||||
"permissions", Integer::parseInt, String.class
|
||||
);
|
||||
|
||||
public static final ConfigValueList<String> DANGEROUS_TYPES = new ConfigValueList<>(
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Objects;
|
||||
public class DataLocation implements Cloneable {
|
||||
|
||||
public static final DecimalFormat format = new DecimalFormat("0.00");
|
||||
private String worldName;
|
||||
private final String worldName;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
@@ -38,6 +38,32 @@ public class DataLocation implements Cloneable {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public static DataLocation deserializeText(String s) {
|
||||
if (s == null || !s.contains(";")) return null;
|
||||
String[] args = StringUtils.split(s, ";");
|
||||
if (args.length < 4) return null;
|
||||
try {
|
||||
String worldName = args[0];
|
||||
double x = NumberConversions.toDouble(args[1]);
|
||||
double y = NumberConversions.toDouble(args[2]);
|
||||
double z = NumberConversions.toDouble(args[3]);
|
||||
float yaw = 0;
|
||||
float pitch = 0;
|
||||
if (args.length == 6) {
|
||||
yaw = NumberConversions.toFloat(args[4]);
|
||||
pitch = NumberConversions.toFloat(args[5]);
|
||||
}
|
||||
return new DataLocation(worldName, x, y, z, yaw, pitch);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static DataLocation parseString(String s) {
|
||||
return deserializeText(s);
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return worldName;
|
||||
}
|
||||
@@ -82,12 +108,10 @@ public class DataLocation implements Cloneable {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
|
||||
public @NotNull Location getBukkitLocation(World world) {
|
||||
return new Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
|
||||
}
|
||||
|
||||
|
||||
public @Nullable Location getBukkitLocation() {
|
||||
World world = Bukkit.getWorld(getWorldName());
|
||||
if (world == null) return null;
|
||||
@@ -143,30 +167,4 @@ public class DataLocation implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public static DataLocation deserializeText(String s) {
|
||||
if (s == null || !s.contains(";")) return null;
|
||||
String[] args = StringUtils.split(s, ";");
|
||||
if (args.length < 4) return null;
|
||||
try {
|
||||
String worldName = args[0];
|
||||
double x = NumberConversions.toDouble(args[1]);
|
||||
double y = NumberConversions.toDouble(args[2]);
|
||||
double z = NumberConversions.toDouble(args[3]);
|
||||
float yaw = 0;
|
||||
float pitch = 0;
|
||||
if (args.length == 6) {
|
||||
yaw = NumberConversions.toFloat(args[4]);
|
||||
pitch = NumberConversions.toFloat(args[5]);
|
||||
}
|
||||
return new DataLocation(worldName, x, y, z, yaw, pitch);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static DataLocation parseString(String s) {
|
||||
return deserializeText(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,16 +41,17 @@ public class UserManager {
|
||||
}
|
||||
|
||||
public int getMaxHome(Player player) {
|
||||
Map<String, Integer> permissions = PluginConfig.PERMISSIONS.get();
|
||||
int value = PluginConfig.DEFAULT_HOME.get();
|
||||
for (Map.Entry<String, Integer> entry : permissions.entrySet()) {
|
||||
if (entry.getValue() > value && player.hasPermission(
|
||||
Main.getInstance().getName() + "." + entry.getKey()
|
||||
Map<Integer, String> permissions = PluginConfig.PERMISSIONS.get();
|
||||
int current = PluginConfig.DEFAULT_HOME.get();
|
||||
|
||||
for (Map.Entry<Integer, String> entry : permissions.entrySet()) {
|
||||
if (entry.getKey() > current && player.hasPermission(
|
||||
Main.getInstance().getName() + "." + entry.getValue()
|
||||
)) {
|
||||
value = entry.getValue();
|
||||
current = entry.getKey();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
return current;
|
||||
}
|
||||
|
||||
public HashMap<UUID, UserData> getUserDataMap() {
|
||||
|
||||
@@ -17,15 +17,11 @@ public class UserData {
|
||||
|
||||
private final @NotNull File dataFile;
|
||||
private final @NotNull FileConfiguration dataConfig;
|
||||
|
||||
private @Nullable Location lastLocation;
|
||||
|
||||
private LinkedHashMap<String, DataLocation> homeLocations;
|
||||
|
||||
private final HashSet<UUID/*receiverUUID*/> sentRequests = new HashSet<>(); // 记录发出的请求
|
||||
private final ConcurrentHashMap<UUID/*senderUUID*/, TeleportRequest> receivedRequests = new ConcurrentHashMap<>(); // 记录收到的传送请求
|
||||
|
||||
public boolean enableAutoSelect = false;
|
||||
private @Nullable Location lastLocation;
|
||||
private LinkedHashMap<String, DataLocation> homeLocations;
|
||||
|
||||
public UserData(@NotNull File dataFolder, @NotNull UUID uuid) {
|
||||
this(new File(dataFolder, uuid + ".yml"));
|
||||
@@ -100,14 +96,14 @@ public class UserData {
|
||||
return receivedRequests;
|
||||
}
|
||||
|
||||
public void setEnableAutoSelect(boolean enableAutoSelect) {
|
||||
this.enableAutoSelect = enableAutoSelect;
|
||||
}
|
||||
|
||||
public boolean isEnableAutoSelect() {
|
||||
return enableAutoSelect;
|
||||
}
|
||||
|
||||
public void setEnableAutoSelect(boolean enableAutoSelect) {
|
||||
this.enableAutoSelect = enableAutoSelect;
|
||||
}
|
||||
|
||||
public @NotNull File getDataFile() {
|
||||
return dataFile;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package cc.carm.plugin.moeteleport.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -7,8 +6,7 @@ import java.util.regex.Pattern;
|
||||
public class ColorParser {
|
||||
|
||||
public static String parse(String text) {
|
||||
text = parseHexColor(text);
|
||||
return parseColor(text);
|
||||
return parseColor(parseHexColor(text));
|
||||
}
|
||||
|
||||
public static String parseColor(final String text) {
|
||||
|
||||
Reference in New Issue
Block a user