Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Some command framework cleanup
Most notably, remove the synchronization on the commands map, which is unnecessary since it is not modified after startup.
Dieser Commit ist enthalten in:
Ursprung
af8c26a4a5
Commit
2ae34b69af
@ -80,8 +80,8 @@ public class CommandExecutor {
|
|||||||
Map<String, GeyserCommand> commands = geyser.getCommandManager().getCommands();
|
Map<String, GeyserCommand> commands = geyser.getCommandManager().getCommands();
|
||||||
|
|
||||||
// Only show commands they have permission to use
|
// Only show commands they have permission to use
|
||||||
for (String name : commands.keySet()) {
|
for (Map.Entry<String, GeyserCommand> entry : commands.entrySet()) {
|
||||||
GeyserCommand geyserCommand = commands.get(name);
|
GeyserCommand geyserCommand = entry.getValue();
|
||||||
if (sender.hasPermission(geyserCommand.getPermission())) {
|
if (sender.hasPermission(geyserCommand.getPermission())) {
|
||||||
|
|
||||||
if (geyserCommand.isBedrockOnly()) {
|
if (geyserCommand.isBedrockOnly()) {
|
||||||
@ -89,7 +89,7 @@ public class CommandExecutor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
availableCommands.add(name);
|
availableCommands.add(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import java.util.*;
|
|||||||
public abstract class CommandManager {
|
public abstract class CommandManager {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<String, GeyserCommand> commands = Collections.synchronizedMap(new HashMap<>());
|
private final Map<String, GeyserCommand> commands = new HashMap<>();
|
||||||
|
|
||||||
private final GeyserImpl geyser;
|
private final GeyserImpl geyser;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.command.defaults;
|
package org.geysermc.geyser.command.defaults;
|
||||||
|
|
||||||
|
import org.geysermc.common.PlatformType;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.command.CommandSender;
|
import org.geysermc.geyser.command.CommandSender;
|
||||||
import org.geysermc.geyser.command.GeyserCommand;
|
import org.geysermc.geyser.command.GeyserCommand;
|
||||||
@ -60,16 +61,17 @@ public class HelpCommand extends GeyserCommand {
|
|||||||
sender.sendMessage(header);
|
sender.sendMessage(header);
|
||||||
|
|
||||||
Map<String, GeyserCommand> cmds = geyser.getCommandManager().getCommands();
|
Map<String, GeyserCommand> cmds = geyser.getCommandManager().getCommands();
|
||||||
for (String cmdName : cmds.keySet()) {
|
for (Map.Entry<String, GeyserCommand> entry : cmds.entrySet()) {
|
||||||
GeyserCommand cmd = cmds.get(cmdName);
|
GeyserCommand cmd = entry.getValue();
|
||||||
|
|
||||||
if (sender.hasPermission(cmd.getPermission())) {
|
// Standalone hack-in since it doesn't have a concept of permissions
|
||||||
|
if (geyser.getPlatformType() == PlatformType.STANDALONE || sender.hasPermission(cmd.getPermission())) {
|
||||||
// Only list commands the player can actually run
|
// Only list commands the player can actually run
|
||||||
if (cmd.isBedrockOnly() && session == null) {
|
if (cmd.isBedrockOnly() && session == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "/geyser " + cmdName + ChatColor.WHITE + ": " +
|
sender.sendMessage(ChatColor.YELLOW + "/geyser " + entry.getKey() + ChatColor.WHITE + ": " +
|
||||||
GeyserLocale.getPlayerLocaleString(cmd.getDescription(), sender.getLocale()));
|
GeyserLocale.getPlayerLocaleString(cmd.getDescription(), sender.getLocale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ import org.geysermc.geyser.session.cache.ChunkCache;
|
|||||||
import org.geysermc.geyser.translator.inventory.LecternInventoryTranslator;
|
import org.geysermc.geyser.translator.inventory.LecternInventoryTranslator;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class GeyserWorldManager extends WorldManager {
|
public class GeyserWorldManager extends WorldManager {
|
||||||
|
|
||||||
private static final Object2ObjectMap<String, String> gameruleCache = new Object2ObjectOpenHashMap<>();
|
private static final Object2ObjectMap<String, String> gameruleCache = new Object2ObjectOpenHashMap<>();
|
||||||
@ -107,12 +109,12 @@ public class GeyserWorldManager extends WorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerGameMode(GeyserSession session, GameMode gameMode) {
|
public void setPlayerGameMode(GeyserSession session, GameMode gameMode) {
|
||||||
session.sendDownstreamPacket(new ServerboundChatPacket("/gamemode " + gameMode.name().toLowerCase()));
|
session.sendDownstreamPacket(new ServerboundChatPacket("/gamemode " + gameMode.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDifficulty(GeyserSession session, Difficulty difficulty) {
|
public void setDifficulty(GeyserSession session, Difficulty difficulty) {
|
||||||
session.sendDownstreamPacket(new ServerboundChatPacket("/difficulty " + difficulty.name().toLowerCase()));
|
session.sendDownstreamPacket(new ServerboundChatPacket("/difficulty " + difficulty.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren