mirror of
https://github.com/CarmJos/MoeTeleport.git
synced 2026-06-05 00:28:16 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8d2d060dc | |||
| 3b3e678fc7 | |||
| 47dfad862b | |||
| aa723087d4 | |||
| 55a692243d | |||
| 7862a698bd | |||
| 351f9a8590 | |||
| ce3226ee18 | |||
| 5461063263 | |||
| c7b0bf8261 |
@@ -1,7 +1,7 @@
|
|||||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||||
|
|
||||||
name: Build
|
name: Build & Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# 支持手动触发构建
|
# 支持手动触发构建
|
||||||
@@ -29,10 +29,15 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
- name: "Target Stage"
|
|
||||||
run: mkdir staging && cp target/*.jar staging
|
- name: "Target Staging"
|
||||||
|
run: |
|
||||||
|
mkdir artifacts
|
||||||
|
cp -vrf target/ artifacts/target/
|
||||||
|
cp -vrf asset/*.jar artifacts
|
||||||
|
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Artifact
|
name: Artifact
|
||||||
path: staging
|
path: artifacts
|
||||||
@@ -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]
|
# /home [name]
|
||||||
- 返回家 (不填name会返回第一个家,若存在home则优先返回home)
|
- 返回设定的家
|
||||||
|
- 不填name会返回第一个设置的家
|
||||||
|
- 若存在名为“home”的家则优先返回“home”。
|
||||||
# /listHome
|
# /listHome
|
||||||
- 列出所有家的位置
|
- 列出所有家的位置
|
||||||
# /setHome [name]
|
# /setHome [name]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>moeteleport</artifactId>
|
<artifactId>moeteleport</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>1.2.1</version>
|
||||||
|
|
||||||
<name>MoeTeleport</name>
|
<name>MoeTeleport</name>
|
||||||
<description>喵喵传送,简单的传送、设置家的插件。</description>
|
<description>喵喵传送,简单的传送、设置家的插件。</description>
|
||||||
@@ -161,12 +161,12 @@
|
|||||||
<goals>
|
<goals>
|
||||||
<goal>shade</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<finalName>${project.name}-${project.version}</finalName>
|
||||||
|
<outputDirectory>${project.basedir}/asset/</outputDirectory>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<filters>
|
<filters>
|
||||||
<filter>
|
<filter>
|
||||||
<artifact>*:*</artifact>
|
<artifact>*:*</artifact>
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ import cc.carm.plugin.moeteleport.command.tpa.TpaCommand;
|
|||||||
import cc.carm.plugin.moeteleport.listener.UserListener;
|
import cc.carm.plugin.moeteleport.listener.UserListener;
|
||||||
import cc.carm.plugin.moeteleport.manager.ConfigManager;
|
import cc.carm.plugin.moeteleport.manager.ConfigManager;
|
||||||
import cc.carm.plugin.moeteleport.manager.RequestManager;
|
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.manager.UserManager;
|
||||||
|
import cc.carm.plugin.moeteleport.model.UserData;
|
||||||
import cc.carm.plugin.moeteleport.util.ColorParser;
|
import cc.carm.plugin.moeteleport.util.ColorParser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -27,61 +28,11 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
|
|
||||||
private static Main instance;
|
|
||||||
public static boolean debugMode = true;
|
public static boolean debugMode = true;
|
||||||
|
private static Main instance;
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
private TeleportManager teleportManager;
|
|
||||||
private RequestManager requestManager;
|
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 +82,65 @@ public class Main extends JavaPlugin {
|
|||||||
return Main.getInstance().requestManager;
|
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();
|
||||||
|
|
||||||
|
log("关闭所有请求...");
|
||||||
|
getRequestManager().shutdown();
|
||||||
|
|
||||||
|
log("保存用户数据...");
|
||||||
|
getUserManager().getUserDataMap().values().forEach(UserData::save);
|
||||||
|
getUserManager().getUserDataMap().clear();
|
||||||
|
|
||||||
|
log("卸载监听器...");
|
||||||
|
Bukkit.getServicesManager().unregisterAll(this);
|
||||||
|
|
||||||
|
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package cc.carm.plugin.moeteleport.command;
|
||||||
|
|
||||||
|
import cc.carm.plugin.moeteleport.manager.ConfigManager;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class MoeTeleportCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command,
|
||||||
|
@NotNull String s, @NotNull String[] args) {
|
||||||
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
|
commandSender.sendMessage("Reloading config...");
|
||||||
|
ConfigManager.reload();
|
||||||
|
commandSender.sendMessage("Config reloaded.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,8 +6,8 @@ import cc.carm.plugin.moeteleport.configuration.values.ConfigValueMap;
|
|||||||
|
|
||||||
public class PluginConfig {
|
public class PluginConfig {
|
||||||
|
|
||||||
public static final ConfigValueMap<String, Integer> PERMISSIONS = new ConfigValueMap<>(
|
public static final ConfigValueMap<Integer, String> PERMISSIONS = new ConfigValueMap<>(
|
||||||
"permissions", s -> s, Integer.class
|
"permissions", Integer::parseInt, String.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigValueList<String> DANGEROUS_TYPES = new ConfigValueList<>(
|
public static final ConfigValueList<String> DANGEROUS_TYPES = new ConfigValueList<>(
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.Objects;
|
|||||||
public class DataLocation implements Cloneable {
|
public class DataLocation implements Cloneable {
|
||||||
|
|
||||||
public static final DecimalFormat format = new DecimalFormat("0.00");
|
public static final DecimalFormat format = new DecimalFormat("0.00");
|
||||||
private String worldName;
|
private final String worldName;
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
private double z;
|
private double z;
|
||||||
@@ -38,6 +38,32 @@ public class DataLocation implements Cloneable {
|
|||||||
this.yaw = yaw;
|
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() {
|
public String getWorldName() {
|
||||||
return worldName;
|
return worldName;
|
||||||
}
|
}
|
||||||
@@ -82,12 +108,10 @@ public class DataLocation implements Cloneable {
|
|||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public @NotNull Location getBukkitLocation(World world) {
|
public @NotNull Location getBukkitLocation(World world) {
|
||||||
return new Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
|
return new Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public @Nullable Location getBukkitLocation() {
|
public @Nullable Location getBukkitLocation() {
|
||||||
World world = Bukkit.getWorld(getWorldName());
|
World world = Bukkit.getWorld(getWorldName());
|
||||||
if (world == null) return null;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -50,13 +49,13 @@ public class ConfigValueMap<K, V> {
|
|||||||
if (valueCache != null) return valueCache;
|
if (valueCache != null) return valueCache;
|
||||||
ConfigurationSection section = getConfiguration().getConfigurationSection(this.configSection);
|
ConfigurationSection section = getConfiguration().getConfigurationSection(this.configSection);
|
||||||
if (section == null) return new LinkedHashMap<>();
|
if (section == null) return new LinkedHashMap<>();
|
||||||
Set<String> keys = getConfiguration().getKeys(false);
|
Set<String> keys = section.getKeys(false);
|
||||||
if (keys.isEmpty()) return new LinkedHashMap<>();
|
if (keys.isEmpty()) return new LinkedHashMap<>();
|
||||||
else {
|
else {
|
||||||
LinkedHashMap<K, V> result = new LinkedHashMap<>();
|
LinkedHashMap<K, V> result = new LinkedHashMap<>();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
K finalKey = keyCast.apply(key);
|
K finalKey = keyCast.apply(key);
|
||||||
Object val = getConfiguration().get(this.configSection);
|
Object val = section.get(key);
|
||||||
V finalValue = this.valueClazz.isInstance(val) ? this.valueClazz.cast(val) : null;
|
V finalValue = this.valueClazz.isInstance(val) ? this.valueClazz.cast(val) : null;
|
||||||
if (finalKey != null && finalValue != null) {
|
if (finalKey != null && finalValue != null) {
|
||||||
result.put(finalKey, finalValue);
|
result.put(finalKey, finalValue);
|
||||||
@@ -67,7 +66,8 @@ public class ConfigValueMap<K, V> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(HashMap<K, V> valuesMap) {
|
public void set(LinkedHashMap<K, V> valuesMap) {
|
||||||
|
this.valueCache = valuesMap;
|
||||||
getConfiguration().createSection(this.configSection, valuesMap);
|
getConfiguration().createSection(this.configSection, valuesMap);
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class UserListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDeath(PlayerQuitEvent event) {
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Main.getRequestManager().cancelAllRequests(player);
|
Main.getRequestManager().cancelAllRequests(player);
|
||||||
Main.getUserManager().getData(player).save(); //保存
|
Main.getUserManager().getData(player).save(); //保存
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ public class TeleportManager {
|
|||||||
return false; // not transparent (will suffocate)
|
return false; // not transparent (will suffocate)
|
||||||
}
|
}
|
||||||
Block ground = leg.getRelative(BlockFace.DOWN);
|
Block ground = leg.getRelative(BlockFace.DOWN);
|
||||||
return ground.getType().isSolid()
|
return !PluginConfig.DANGEROUS_TYPES.get().contains(ground.getType().name());
|
||||||
&& !PluginConfig.DANGEROUS_TYPES.get().contains(ground.getType().name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,16 +41,17 @@ public class UserManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHome(Player player) {
|
public int getMaxHome(Player player) {
|
||||||
Map<String, Integer> permissions = PluginConfig.PERMISSIONS.get();
|
Map<Integer, String> permissions = PluginConfig.PERMISSIONS.get();
|
||||||
int value = PluginConfig.DEFAULT_HOME.get();
|
int current = PluginConfig.DEFAULT_HOME.get();
|
||||||
for (Map.Entry<String, Integer> entry : permissions.entrySet()) {
|
|
||||||
if (entry.getValue() > value && player.hasPermission(
|
for (Map.Entry<Integer, String> entry : permissions.entrySet()) {
|
||||||
Main.getInstance().getName() + "." + entry.getKey()
|
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() {
|
public HashMap<UUID, UserData> getUserDataMap() {
|
||||||
|
|||||||
@@ -17,15 +17,11 @@ public class UserData {
|
|||||||
|
|
||||||
private final @NotNull File dataFile;
|
private final @NotNull File dataFile;
|
||||||
private final @NotNull FileConfiguration dataConfig;
|
private final @NotNull FileConfiguration dataConfig;
|
||||||
|
|
||||||
private @Nullable Location lastLocation;
|
|
||||||
|
|
||||||
private LinkedHashMap<String, DataLocation> homeLocations;
|
|
||||||
|
|
||||||
private final HashSet<UUID/*receiverUUID*/> sentRequests = new HashSet<>(); // 记录发出的请求
|
private final HashSet<UUID/*receiverUUID*/> sentRequests = new HashSet<>(); // 记录发出的请求
|
||||||
private final ConcurrentHashMap<UUID/*senderUUID*/, TeleportRequest> receivedRequests = new ConcurrentHashMap<>(); // 记录收到的传送请求
|
private final ConcurrentHashMap<UUID/*senderUUID*/, TeleportRequest> receivedRequests = new ConcurrentHashMap<>(); // 记录收到的传送请求
|
||||||
|
|
||||||
public boolean enableAutoSelect = false;
|
public boolean enableAutoSelect = false;
|
||||||
|
private @Nullable Location lastLocation;
|
||||||
|
private LinkedHashMap<String, DataLocation> homeLocations;
|
||||||
|
|
||||||
public UserData(@NotNull File dataFolder, @NotNull UUID uuid) {
|
public UserData(@NotNull File dataFolder, @NotNull UUID uuid) {
|
||||||
this(new File(dataFolder, uuid + ".yml"));
|
this(new File(dataFolder, uuid + ".yml"));
|
||||||
@@ -100,14 +96,14 @@ public class UserData {
|
|||||||
return receivedRequests;
|
return receivedRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnableAutoSelect(boolean enableAutoSelect) {
|
|
||||||
this.enableAutoSelect = enableAutoSelect;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnableAutoSelect() {
|
public boolean isEnableAutoSelect() {
|
||||||
return enableAutoSelect;
|
return enableAutoSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEnableAutoSelect(boolean enableAutoSelect) {
|
||||||
|
this.enableAutoSelect = enableAutoSelect;
|
||||||
|
}
|
||||||
|
|
||||||
public @NotNull File getDataFile() {
|
public @NotNull File getDataFile() {
|
||||||
return dataFile;
|
return dataFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package cc.carm.plugin.moeteleport.util;
|
package cc.carm.plugin.moeteleport.util;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -7,8 +6,7 @@ import java.util.regex.Pattern;
|
|||||||
public class ColorParser {
|
public class ColorParser {
|
||||||
|
|
||||||
public static String parse(String text) {
|
public static String parse(String text) {
|
||||||
text = parseHexColor(text);
|
return parseColor(parseHexColor(text));
|
||||||
return parseColor(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String parseColor(final String text) {
|
public static String parseColor(final String text) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ defaultHome: 1
|
|||||||
permissions:
|
permissions:
|
||||||
# 以下命令全部为 MoeTeleport 的子节点
|
# 以下命令全部为 MoeTeleport 的子节点
|
||||||
# 如 "home.vip" 的权限全拼就是 "MoeTeleport.home.vip"
|
# 如 "home.vip" 的权限全拼就是 "MoeTeleport.home.vip"
|
||||||
"home.vip": 10 # 最多可以设置10个家
|
10: "home.vip" # 最多可以设置10个家
|
||||||
|
|
||||||
# 传送请求过期时间
|
# 传送请求过期时间
|
||||||
expireTime: 30
|
expireTime: 30
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ not-online:
|
|||||||
- "&f目标玩家并不在线,无法发送请求。"
|
- "&f目标玩家并不在线,无法发送请求。"
|
||||||
tpa:
|
tpa:
|
||||||
- "&d%(player) &f请求传送到您身边,您有 &5%(expire)秒 &f的时间回应。"
|
- "&d%(player) &f请求传送到您身边,您有 &5%(expire)秒 &f的时间回应。"
|
||||||
- "&a&l[同意] &f输入 &5/tpaccept &f同意该请求。"
|
- "&a&l[command=/tpAccept %(player)][同意][/command] &f输入 &5/tpaccept &f同意该请求。"
|
||||||
- "&c&l[拒绝] &f输入 &5/tpdeny &f拒绝该请求。"
|
- "&c&l[command=/tpDeny %(player)][拒绝][/command] &f输入 &5/tpdeny &f拒绝该请求。"
|
||||||
tpahere:
|
tpahere:
|
||||||
- "&d%(player) &f请求传送您到Ta身边,您有 &5%(expire)秒 &f的时间回应。"
|
- "&d%(player) &f请求传送您到Ta身边,您有 &5%(expire)秒 &f的时间回应。"
|
||||||
- "&a&l[同意] &f输入 &5/tpaccept &f同意该请求。"
|
- "&a&l[command=/tpAccept %(player)][同意][/command] &f输入 &5/tpaccept &f同意该请求。"
|
||||||
- "&c&l[拒绝] &f输入 &5/tpdeny &f拒绝该请求。"
|
- "&c&l[command=/tpDeny %(player)][拒绝][/command] &f输入 &5/tpdeny &f拒绝该请求。"
|
||||||
tpaccept:
|
tpaccept:
|
||||||
- "&f您同意了 &d%(player) &f的传送请求。"
|
- "&f您同意了 &d%(player) &f的传送请求。"
|
||||||
tpdeny:
|
tpdeny:
|
||||||
@@ -38,7 +38,7 @@ no-request-player:
|
|||||||
- "&f您当前没有收到来自 &d%(player) &f的传送请求。"
|
- "&f您当前没有收到来自 &d%(player) &f的传送请求。"
|
||||||
multi-requests:
|
multi-requests:
|
||||||
- "&f您当前有&d%(num)条请求&f待处理,请输入 &5/%(command) <玩家名> &f决定回应谁的请求。"
|
- "&f您当前有&d%(num)条请求&f待处理,请输入 &5/%(command) <玩家名> &f决定回应谁的请求。"
|
||||||
- "&f您也可以再次输入 &5/%(command) &f直接回应最近的一条请求。"
|
- "&f您也可以再次输入 &5/%(command) &f快速回应最近的一条请求。"
|
||||||
request-sent-timeout:
|
request-sent-timeout:
|
||||||
- "&f发往 &d%(player) &f的传送请求已超时。"
|
- "&f发往 &d%(player) &f的传送请求已超时。"
|
||||||
request-received-timeout:
|
request-received-timeout:
|
||||||
@@ -48,13 +48,13 @@ teleporting:
|
|||||||
dangerous:
|
dangerous:
|
||||||
- "&f目标地点不安全,传送被取消。"
|
- "&f目标地点不安全,传送被取消。"
|
||||||
dangerous-here:
|
dangerous-here:
|
||||||
- "&f当前地点不安全,无法发送传送请求。"
|
- "&f当前地点不安全,传送被取消。"
|
||||||
notAvailable:
|
notAvailable:
|
||||||
- "&f目标地点暂时无法前往,传送被取消。"
|
- "&f目标地点暂时无法前往,传送被取消。"
|
||||||
|
|
||||||
home-list-header:
|
home-list-header:
|
||||||
- "&f您当前设定的所有家:"
|
- "&f您当前设定的所有家:"
|
||||||
home-list-object: "&8#&f%(id) &d%(location)"
|
home-list-object: "&8# &f%(id) &d%(location) &7[command=/home %(id)]✈[/command]"
|
||||||
home-not-found:
|
home-not-found:
|
||||||
- "&f您还没有设置这个家,请先输入 &5/setHome <家名称> &f设置一个吧!"
|
- "&f您还没有设置这个家,请先输入 &5/setHome <家名称> &f设置一个吧!"
|
||||||
home-set:
|
home-set:
|
||||||
|
|||||||
@@ -13,7 +13,16 @@ permissions:
|
|||||||
description: "插件的主权限节点"
|
description: "插件的主权限节点"
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
|
"MoeTeleport.admin":
|
||||||
|
description: "插件的管理员权限节点"
|
||||||
|
default: op
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
"MoeTeleport":
|
||||||
|
description: "插件的主命令,用于重载插件或查看插件信息。"
|
||||||
|
permission: "MoeTeleport.admin"
|
||||||
|
usage: "/MoeTeleport reload"
|
||||||
|
|
||||||
"back":
|
"back":
|
||||||
description: 返回传送前的上一个地点。
|
description: 返回传送前的上一个地点。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user