mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-06 00:07:20 +01:00
fix console commands, run parse command in world thread
This commit is contained in:
@@ -35,6 +35,7 @@ import com.hypixel.hytale.server.core.Message;
|
|||||||
import com.hypixel.hytale.server.core.command.system.*;
|
import com.hypixel.hytale.server.core.command.system.*;
|
||||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||||
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
|
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
|
||||||
|
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||||
import com.hypixel.hytale.server.core.universe.world.World;
|
import com.hypixel.hytale.server.core.universe.world.World;
|
||||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||||
@@ -42,7 +43,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
public final class PlaceholderCommandRouter extends AbstractPlayerCommand {
|
public final class PlaceholderCommandRouter extends AbstractCommand {
|
||||||
|
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
private static final List<PlaceholderCommand> COMMANDS = List.of(new CommandHelp(),
|
private static final List<PlaceholderCommand> COMMANDS = List.of(new CommandHelp(),
|
||||||
@@ -84,10 +85,16 @@ public final class PlaceholderCommandRouter extends AbstractPlayerCommand {
|
|||||||
this.commands = commands;
|
this.commands = commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// @NotNull
|
// @NotNull
|
||||||
// public CompletableFuture<Void> acceptCall(@NotNull final CommandSender sender, @NotNull final ParserContext parserContext,
|
// public CompletableFuture<Void> acceptCall(@NotNull final CommandSender sender, @NotNull final ParserContext parserContext,
|
||||||
// @NotNull final ParseResult parseResult) {
|
// @NotNull final ParseResult parseResult) {
|
||||||
|
//// if (sender instanceof Player || sender instanceof PlayerRef) {
|
||||||
|
//// return CompletableFuture.completedFuture(null);
|
||||||
|
//// }
|
||||||
|
//
|
||||||
// final String[] args = parserContext.getInputString().replace("papi ", "").split(" ");
|
// final String[] args = parserContext.getInputString().replace("papi ", "").split(" ");
|
||||||
//
|
//
|
||||||
// if (args.length == 0) {
|
// if (args.length == 0) {
|
||||||
@@ -124,7 +131,7 @@ public final class PlaceholderCommandRouter extends AbstractPlayerCommand {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(@NotNull final CommandContext context, @NotNull final Store<EntityStore> var2, @NotNull final Ref<EntityStore> var3, @NotNull final PlayerRef var4, @NotNull final World var5) {
|
protected @Nullable CompletableFuture<Void> execute(@NotNull final CommandContext context) {
|
||||||
final String[] args = context.getInputString().replace("papi ", "").split(" ");
|
final String[] args = context.getInputString().replace("papi ", "").split(" ");
|
||||||
final CommandSender sender = context.sender();
|
final CommandSender sender = context.sender();
|
||||||
|
|
||||||
@@ -134,7 +141,7 @@ public final class PlaceholderCommandRouter extends AbstractPlayerCommand {
|
|||||||
fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String search = args[0].toLowerCase(Locale.ROOT);
|
final String search = args[0].toLowerCase(Locale.ROOT);
|
||||||
@@ -144,7 +151,7 @@ public final class PlaceholderCommandRouter extends AbstractPlayerCommand {
|
|||||||
sender.sendMessage(Message.raw("Unknown command ").color(Color.RED).insert(Message.raw(search).color(Color.GRAY)));
|
sender.sendMessage(Message.raw("Unknown command ").color(Color.RED).insert(Message.raw(search).color(Color.GRAY)));
|
||||||
|
|
||||||
// Msg.msg(sender, "&cUnknown command &7" + search);
|
// Msg.msg(sender, "&cUnknown command &7" + search);
|
||||||
return;
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String permission = target.getPermission();
|
final String permission = target.getPermission();
|
||||||
@@ -152,15 +159,53 @@ public final class PlaceholderCommandRouter extends AbstractPlayerCommand {
|
|||||||
sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
||||||
|
|
||||||
// Msg.msg(sender, "&cYou do not have permission to do this!");
|
// Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||||
return;
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
target
|
target
|
||||||
.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
||||||
|
|
||||||
return;
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// protected void execute(@NotNull final CommandContext context, @NotNull final Store<EntityStore> var2, @NotNull final Ref<EntityStore> var3, @NotNull final PlayerRef var4, @NotNull final World var5) {
|
||||||
|
// final String[] args = context.getInputString().replace("papi ", "").split(" ");
|
||||||
|
// final CommandSender sender = context.sender();
|
||||||
|
//
|
||||||
|
// if (args.length == 0) {
|
||||||
|
// final PlaceholderCommand fallback = commands.get("version");
|
||||||
|
// if (fallback != null) {
|
||||||
|
// fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final String search = args[0].toLowerCase(Locale.ROOT);
|
||||||
|
// final PlaceholderCommand target = commands.get(search);
|
||||||
|
//
|
||||||
|
// if (target == null) {
|
||||||
|
// sender.sendMessage(Message.raw("Unknown command ").color(Color.RED).insert(Message.raw(search).color(Color.GRAY)));
|
||||||
|
//
|
||||||
|
//// Msg.msg(sender, "&cUnknown command &7" + search);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final String permission = target.getPermission();
|
||||||
|
// if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission)) {
|
||||||
|
// sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
||||||
|
//
|
||||||
|
//// Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// target
|
||||||
|
// .evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
||||||
|
//
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// @Nullable
|
// @Nullable
|
||||||
|
|||||||
@@ -51,19 +51,38 @@ public final class CommandParse extends PlaceholderCommand {
|
|||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
@NotNull @Unmodifiable final List<String> params) {
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
switch (alias.toLowerCase(Locale.ROOT)) {
|
final Runnable logic = () -> {
|
||||||
case "parserel":
|
switch (alias.toLowerCase(Locale.ROOT)) {
|
||||||
evaluateParseRelation(sender, params);
|
case "parserel":
|
||||||
break;
|
evaluateParseRelation(sender, params);
|
||||||
case "parse":
|
break;
|
||||||
evaluateParseSingular(sender, params, false, false);
|
case "parse":
|
||||||
break;
|
evaluateParseSingular(sender, params, false, false);
|
||||||
case "bcparse":
|
break;
|
||||||
evaluateParseSingular(sender, params, true, false);
|
case "bcparse":
|
||||||
break;
|
evaluateParseSingular(sender, params, true, false);
|
||||||
case "cmdparse":
|
break;
|
||||||
evaluateParseSingular(sender, params, false, true);
|
case "cmdparse":
|
||||||
break;
|
evaluateParseSingular(sender, params, false, true);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
final World world;
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
world = ((Player) sender).getWorld();
|
||||||
|
} else if (sender instanceof PlayerRef) {
|
||||||
|
UUID uuid = ((PlayerRef) sender).getWorldUuid();
|
||||||
|
world = uuid == null ? Universe.get().getDefaultWorld() : Universe.get().getWorld(uuid);
|
||||||
|
} else {
|
||||||
|
world = Universe.get().getDefaultWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world != null) {
|
||||||
|
world.execute(logic);
|
||||||
|
} else {
|
||||||
|
logic.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user