feat: 添加管理员指令
This commit is contained in:
@@ -49,9 +49,9 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// 对于 Bukkit 插件
|
// 对于 Bukkit 插件
|
||||||
compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.4")
|
compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.7.0-SNAPSHOT")
|
||||||
// 对于 BungeeCord 插件
|
// 对于 BungeeCord 插件
|
||||||
compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.4")
|
compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.7.0-SNAPSHOT")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -77,13 +77,13 @@ dependencies {
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hamster3.mc.plugin</groupId>
|
<groupId>cn.hamster3.mc.plugin</groupId>
|
||||||
<artifactId>ball-bukkit</artifactId>
|
<artifactId>ball-bukkit</artifactId>
|
||||||
<version>1.6.4</version>
|
<version>1.7.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--对于 BungeeCord 插件-->
|
<!--对于 BungeeCord 插件-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hamster3.mc.plugin</groupId>
|
<groupId>cn.hamster3.mc.plugin</groupId>
|
||||||
<artifactId>ball-bungee</artifactId>
|
<artifactId>ball-bungee</artifactId>
|
||||||
<version>1.6.4</version>
|
<version>1.7.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -3,7 +3,6 @@ package cn.hamster3.mc.plugin.ball.bukkit.listener;
|
|||||||
import cn.hamster3.mc.plugin.ball.bukkit.HamsterBallPlugin;
|
import cn.hamster3.mc.plugin.ball.bukkit.HamsterBallPlugin;
|
||||||
import cn.hamster3.mc.plugin.ball.bukkit.data.BukkitLocation;
|
import cn.hamster3.mc.plugin.ball.bukkit.data.BukkitLocation;
|
||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.event.operate.*;
|
import cn.hamster3.mc.plugin.ball.common.event.operate.*;
|
||||||
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
||||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||||
@@ -95,9 +94,6 @@ public class BallBukkitListener implements Listener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDispatchConsoleCommand(DispatchConsoleCommandEvent event) {
|
public void onDispatchConsoleCommand(DispatchConsoleCommandEvent event) {
|
||||||
if (event.getType() != null && event.getType() != BallServerType.GAME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getServerID() != null && !BallAPI.getInstance().isLocalServer(event.getServerID())) {
|
if (event.getServerID() != null && !BallAPI.getInstance().isLocalServer(event.getServerID())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -106,9 +102,6 @@ public class BallBukkitListener implements Listener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDispatchPlayerCommand(DispatchPlayerCommandEvent event) {
|
public void onDispatchPlayerCommand(DispatchPlayerCommandEvent event) {
|
||||||
if (event.getType() != null && event.getType() != BallServerType.GAME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getUuid() != null) {
|
if (event.getUuid() != null) {
|
||||||
Player player = Bukkit.getPlayer(event.getUuid());
|
Player player = Bukkit.getPlayer(event.getUuid());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
@@ -12,7 +12,7 @@ public class BungeeBallCommand extends Command {
|
|||||||
public static final BungeeBallCommand INSTANCE = new BungeeBallCommand();
|
public static final BungeeBallCommand INSTANCE = new BungeeBallCommand();
|
||||||
|
|
||||||
public BungeeBallCommand() {
|
public BungeeBallCommand() {
|
||||||
super("hamster-ball", "hamster.ball.admin", "ball");
|
super("hamster-bungee-ball", "hamster.ball.admin", "bungee-ball", "bball");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -2,7 +2,6 @@ package cn.hamster3.mc.plugin.ball.bungee.listener;
|
|||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.bungee.HamsterBallPlugin;
|
import cn.hamster3.mc.plugin.ball.bungee.HamsterBallPlugin;
|
||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.event.operate.*;
|
import cn.hamster3.mc.plugin.ball.common.event.operate.*;
|
||||||
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
@@ -23,9 +22,6 @@ public class BallBungeeListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDispatchConsoleCommand(DispatchConsoleCommandEvent event) {
|
public void onDispatchConsoleCommand(DispatchConsoleCommandEvent event) {
|
||||||
if (event.getType() != null && event.getType() != BallServerType.PROXY) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getServerID() != null && !BallAPI.getInstance().isLocalServer(event.getServerID())) {
|
if (event.getServerID() != null && !BallAPI.getInstance().isLocalServer(event.getServerID())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -35,9 +31,6 @@ public class BallBungeeListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDispatchPlayerCommandEvent(DispatchPlayerCommandEvent event) {
|
public void onDispatchPlayerCommandEvent(DispatchPlayerCommandEvent event) {
|
||||||
if (event.getType() != null && event.getType() != BallServerType.GAME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxyServer server = ProxyServer.getInstance();
|
ProxyServer server = ProxyServer.getInstance();
|
||||||
if (event.getUuid() != null) {
|
if (event.getUuid() != null) {
|
||||||
ProxiedPlayer player = server.getPlayer(event.getUuid());
|
ProxiedPlayer player = server.getPlayer(event.getUuid());
|
||||||
|
@@ -257,11 +257,10 @@ public abstract class BallAPI {
|
|||||||
*/
|
*/
|
||||||
public void dispatchConsoleCommand(@Nullable BallServerType type, @Nullable String serverID, @NotNull String command) {
|
public void dispatchConsoleCommand(@Nullable BallServerType type, @Nullable String serverID, @NotNull String command) {
|
||||||
sendBallMessage(BALL_CHANNEL, new BallMessage(
|
sendBallMessage(BALL_CHANNEL, new BallMessage(
|
||||||
getLocalServerId(), null, BallServerType.GAME,
|
getLocalServerId(), null, type,
|
||||||
BallActions.DispatchConsoleCommand.name(),
|
BallActions.DispatchConsoleCommand.name(),
|
||||||
CoreAPI.getInstance().getGson().toJsonTree(new DispatchConsoleCommandEvent(type, serverID, command))
|
CoreAPI.getInstance().getGson().toJsonTree(new DispatchConsoleCommandEvent(serverID, command))
|
||||||
), false);
|
), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,9 +272,9 @@ public abstract class BallAPI {
|
|||||||
*/
|
*/
|
||||||
public void dispatchPlayerCommand(@Nullable BallServerType type, @Nullable UUID uuid, @NotNull String command) {
|
public void dispatchPlayerCommand(@Nullable BallServerType type, @Nullable UUID uuid, @NotNull String command) {
|
||||||
sendBallMessage(BALL_CHANNEL, new BallMessage(
|
sendBallMessage(BALL_CHANNEL, new BallMessage(
|
||||||
getLocalServerId(), null, BallServerType.GAME,
|
getLocalServerId(), null, type,
|
||||||
BallActions.DispatchPlayerCommand.name(),
|
BallActions.DispatchPlayerCommand.name(),
|
||||||
CoreAPI.getInstance().getGson().toJsonTree(new DispatchPlayerCommandEvent(type, uuid, command))
|
CoreAPI.getInstance().getGson().toJsonTree(new DispatchPlayerCommandEvent(uuid, command))
|
||||||
), false);
|
), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
package cn.hamster3.mc.plugin.ball.common.command;
|
package cn.hamster3.mc.plugin.ball.common.command;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
||||||
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
||||||
|
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SudoAllConsoleCommand extends ChildCommand {
|
public class SudoAllConsoleCommand extends ChildCommand {
|
||||||
public static final SudoAllConsoleCommand INSTANCE = new SudoAllConsoleCommand();
|
public static final SudoAllConsoleCommand INSTANCE = new SudoAllConsoleCommand();
|
||||||
@@ -22,7 +25,7 @@ public class SudoAllConsoleCommand extends ChildCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getUsage() {
|
public @NotNull String getUsage() {
|
||||||
return "sudo-all-console <服务器ID> <命令内容>";
|
return "sudo-all-console <服务器类型> <命令内容>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,22 +40,36 @@ public class SudoAllConsoleCommand extends ChildCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
public boolean onCommand(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(BallCommand.INSTANCE.getUsage() + " " + getUsage());
|
sender.sendMessage(BallCommand.INSTANCE.getUsage() + " " + getUsage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder(args[0]);
|
BallServerType serverType;
|
||||||
for (int i = 1; i < args.length; i++) {
|
try {
|
||||||
|
serverType = BallServerType.valueOf(args[0].toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
sender.sendMessage("§c未知的服务器类型: " + args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
StringBuilder builder = new StringBuilder(args[1]);
|
||||||
|
for (int i = 2; i < args.length; i++) {
|
||||||
builder.append(" ").append(args[i]);
|
builder.append(" ").append(args[i]);
|
||||||
}
|
}
|
||||||
String command = builder.toString();
|
String command = builder.toString();
|
||||||
BallAPI.getInstance().dispatchConsoleCommand(null, null, command);
|
BallAPI.getInstance().dispatchConsoleCommand(serverType, null, command);
|
||||||
sender.sendMessage("§a已强制所有服务器控制台执行命令: §e/" + command);
|
sender.sendMessage("§a已强制所有服务器控制台执行命令: §e/" + command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable List<String> onTabComplete(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
public @Nullable List<String> onTabComplete(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
return Arrays.stream(BallServerType.values())
|
||||||
|
.map(Enum::name)
|
||||||
|
.filter(o -> o.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||||
|
.limit(10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,11 +3,14 @@ package cn.hamster3.mc.plugin.ball.common.command;
|
|||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
||||||
|
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SudoAllPlayerCommand extends ChildCommand {
|
public class SudoAllPlayerCommand extends ChildCommand {
|
||||||
public static final SudoAllPlayerCommand INSTANCE = new SudoAllPlayerCommand();
|
public static final SudoAllPlayerCommand INSTANCE = new SudoAllPlayerCommand();
|
||||||
@@ -22,7 +25,7 @@ public class SudoAllPlayerCommand extends ChildCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getUsage() {
|
public @NotNull String getUsage() {
|
||||||
return "sudo-all-player <命令内容>";
|
return "sudo-all-player <服务器类型> <命令内容>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,22 +40,36 @@ public class SudoAllPlayerCommand extends ChildCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
public boolean onCommand(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(BallCommand.INSTANCE.getUsage() + " " + getUsage());
|
sender.sendMessage(BallCommand.INSTANCE.getUsage() + " " + getUsage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder(args[0]);
|
BallServerType serverType;
|
||||||
for (int i = 1; i < args.length; i++) {
|
try {
|
||||||
|
serverType = BallServerType.valueOf(args[0].toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
sender.sendMessage("§c未知的服务器类型: " + args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
StringBuilder builder = new StringBuilder(args[1]);
|
||||||
|
for (int i = 2; i < args.length; i++) {
|
||||||
builder.append(" ").append(args[i]);
|
builder.append(" ").append(args[i]);
|
||||||
}
|
}
|
||||||
String command = builder.toString();
|
String command = builder.toString();
|
||||||
BallAPI.getInstance().dispatchPlayerCommand(null, null, command);
|
BallAPI.getInstance().dispatchPlayerCommand(serverType, null, command);
|
||||||
sender.sendMessage("§a已强制所有玩家执行命令: §e/" + command);
|
sender.sendMessage("§a已强制所有玩家执行命令: §e/" + command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable List<String> onTabComplete(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
public @Nullable List<String> onTabComplete(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
return Arrays.stream(BallServerType.values())
|
||||||
|
.map(Enum::name)
|
||||||
|
.filter(o -> o.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||||
|
.limit(10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package cn.hamster3.mc.plugin.ball.common.command;
|
package cn.hamster3.mc.plugin.ball.common.command;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
||||||
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerInfo;
|
import cn.hamster3.mc.plugin.ball.common.entity.BallServerInfo;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
package cn.hamster3.mc.plugin.ball.common.command;
|
package cn.hamster3.mc.plugin.ball.common.command;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.AdaptCommandSender;
|
||||||
|
import cn.hamster3.mc.plugin.ball.common.command.adapt.ChildCommand;
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo;
|
import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo;
|
||||||
|
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -25,7 +27,7 @@ public class SudoPlayerCommand extends ChildCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getUsage() {
|
public @NotNull String getUsage() {
|
||||||
return "sudo-player <玩家名|UUID> <命令内容>";
|
return "sudo-player <服务器类型> <玩家名|UUID> <命令内容>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,43 +42,59 @@ public class SudoPlayerCommand extends ChildCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
public boolean onCommand(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
||||||
if (args.length < 2) {
|
if (args.length < 3) {
|
||||||
sender.sendMessage(BallCommand.INSTANCE.getUsage() + " " + getUsage());
|
sender.sendMessage(BallCommand.INSTANCE.getUsage() + " " + getUsage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
BallServerType serverType;
|
||||||
|
try {
|
||||||
|
serverType = BallServerType.valueOf(args[0].toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
sender.sendMessage("§c未知的服务器类型: " + args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
BallPlayerInfo info;
|
BallPlayerInfo info;
|
||||||
try {
|
try {
|
||||||
UUID uuid = UUID.fromString(args[0]);
|
UUID uuid = UUID.fromString(args[1]);
|
||||||
info = BallAPI.getInstance().getPlayerInfo(uuid);
|
info = BallAPI.getInstance().getPlayerInfo(uuid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
info = BallAPI.getInstance().getPlayerInfo(args[0]);
|
info = BallAPI.getInstance().getPlayerInfo(args[1]);
|
||||||
}
|
}
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
sender.sendMessage("§c未找到玩家 " + args[0]);
|
sender.sendMessage("§c未找到玩家 " + args[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!info.isOnline()) {
|
if (!info.isOnline()) {
|
||||||
sender.sendMessage("§c玩家 " + args[0] + " 不在线");
|
sender.sendMessage("§c玩家 " + args[1] + " 不在线");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder(args[1]);
|
StringBuilder builder = new StringBuilder(args[2]);
|
||||||
for (int i = 2; i < args.length; i++) {
|
for (int i = 3; i < args.length; i++) {
|
||||||
builder.append(" ").append(args[i]);
|
builder.append(" ").append(args[i]);
|
||||||
}
|
}
|
||||||
String command = builder.toString();
|
String command = builder.toString();
|
||||||
BallAPI.getInstance().dispatchPlayerCommand(null, info.getUuid(), command);
|
BallAPI.getInstance().dispatchPlayerCommand(serverType, info.getUuid(), command);
|
||||||
sender.sendMessage("§a已强制玩家 " + info.getName() + " 执行命令: §e/" + command);
|
sender.sendMessage("§a已强制玩家 " + info.getName() + " 执行命令: §e/" + command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable List<String> onTabComplete(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
public @Nullable List<String> onTabComplete(@NotNull AdaptCommandSender sender, @NotNull String[] args) {
|
||||||
if (args.length == 1) {
|
switch (args.length) {
|
||||||
return BallAPI.getInstance().getAllPlayerInfo().values().stream()
|
case 1: {
|
||||||
.map(BallPlayerInfo::getName)
|
return Arrays.stream(BallServerType.values())
|
||||||
.filter(o -> o.toLowerCase().startsWith(args[0].toLowerCase()))
|
.map(Enum::name)
|
||||||
.limit(10)
|
.filter(o -> o.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||||
.collect(Collectors.toList());
|
.limit(10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
return BallAPI.getInstance().getAllPlayerInfo().values().stream()
|
||||||
|
.map(BallPlayerInfo::getName)
|
||||||
|
.filter(o -> o.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
.limit(10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package cn.hamster3.mc.plugin.ball.common.event.operate;
|
package cn.hamster3.mc.plugin.ball.common.event.operate;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -9,8 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DispatchConsoleCommandEvent {
|
public class DispatchConsoleCommandEvent {
|
||||||
@Nullable
|
|
||||||
private final BallServerType type;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String serverID;
|
private final String serverID;
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package cn.hamster3.mc.plugin.ball.common.event.operate;
|
package cn.hamster3.mc.plugin.ball.common.event.operate;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -11,8 +10,6 @@ import java.util.UUID;
|
|||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DispatchPlayerCommandEvent {
|
public class DispatchPlayerCommandEvent {
|
||||||
@Nullable
|
|
||||||
private final BallServerType type;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@@ -100,8 +100,8 @@ public class HamsterBallPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommandMeta commandMeta = proxyServer.getCommandManager()
|
CommandMeta commandMeta = proxyServer.getCommandManager()
|
||||||
.metaBuilder("hamster-ball")
|
.metaBuilder("hamster-velocity-ball")
|
||||||
.aliases("ball")
|
.aliases("velocity-ball", "vball")
|
||||||
.plugin(this)
|
.plugin(this)
|
||||||
.build();
|
.build();
|
||||||
proxyServer.getCommandManager().register(commandMeta, VelocityBallCommand.INSTANCE);
|
proxyServer.getCommandManager().register(commandMeta, VelocityBallCommand.INSTANCE);
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package cn.hamster3.mc.plugin.ball.velocity.listener;
|
package cn.hamster3.mc.plugin.ball.velocity.listener;
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.event.operate.*;
|
import cn.hamster3.mc.plugin.ball.common.event.operate.*;
|
||||||
import cn.hamster3.mc.plugin.ball.velocity.HamsterBallPlugin;
|
import cn.hamster3.mc.plugin.ball.velocity.HamsterBallPlugin;
|
||||||
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
||||||
@@ -23,9 +22,6 @@ public class BallVelocityListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDispatchConsoleCommand(DispatchConsoleCommandEvent event) {
|
public void onDispatchConsoleCommand(DispatchConsoleCommandEvent event) {
|
||||||
if (event.getType() != null && event.getType() != BallServerType.PROXY) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getServerID() != null && !BallAPI.getInstance().isLocalServer(event.getServerID())) {
|
if (event.getServerID() != null && !BallAPI.getInstance().isLocalServer(event.getServerID())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -35,9 +31,6 @@ public class BallVelocityListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDispatchPlayerCommand(DispatchPlayerCommandEvent event) {
|
public void onDispatchPlayerCommand(DispatchPlayerCommandEvent event) {
|
||||||
if (event.getType() != null && event.getType() != BallServerType.GAME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxyServer server = HamsterBallPlugin.getInstance().getProxyServer();
|
ProxyServer server = HamsterBallPlugin.getInstance().getProxyServer();
|
||||||
if (event.getUuid() != null) {
|
if (event.getUuid() != null) {
|
||||||
Player player = server.getPlayer(event.getUuid()).orElse(null);
|
Player player = server.getPlayer(event.getUuid()).orElse(null);
|
||||||
|
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "cn.hamster3.mc.plugin"
|
group = "cn.hamster3.mc.plugin"
|
||||||
version = "1.6.5-SNAPSHOT"
|
version = "1.7.0-SNAPSHOT"
|
||||||
description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
|
description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
Reference in New Issue
Block a user