Added command refresh after persmission change

This commit is contained in:
Elias Müller 2023-10-01 18:11:32 +02:00
parent de79433c32
commit 8fddabe00f
4 changed files with 4 additions and 7 deletions
.gitignore
build/tmp/compileJava
src/main/java/eu/mhsl/minenet/minigames

2
.gitignore vendored

@ -28,4 +28,4 @@ replay_pid*
.idea
.gradle
build
build/*

@ -16,10 +16,10 @@ public class OpCommand extends Command {
addSyntax((sender, context) -> {
Player target = MinecraftServer.getConnectionManager().getPlayer(context.getRaw("target"));
if(target != null)
if(target != null) {
target.addPermission(new Permission("admin"));
else
new ChatMessage(Icon.ERROR).appendStatic("Spieler nicht gefunden").send(sender);
target.refreshCommands();
} else new ChatMessage(Icon.ERROR).appendStatic("Spieler nicht gefunden").send(sender);
}, ArgumentType.Entity("target").onlyPlayers(true));
}
}

@ -23,10 +23,7 @@ public class AddEntityToInstanceEventListener implements EventListener<AddEntity
@Override
public @NotNull Result run(@NotNull AddEntityToInstanceEvent event) {
if(event.getEntity() instanceof Player p) {
MinecraftServer.getSchedulerManager().scheduleNextTick(p::refreshCommands, ExecutionType.ASYNC);
new ActionBarMessage().appendStatic(Component.text("Instance: ", NamedTextColor.DARK_GRAY)).appendStatic(event.getInstance().getUniqueId().toString()).send(p);
new ChatMessage(Icon.SCIENCE).appendStatic(Component.text(event.getInstance().getUniqueId().toString())).send(p);
p.addEffect(new Potion(PotionEffect.BLINDNESS, (byte) 1, 20)); //TODO Uncomment, currently buggy causes disconnect see https://github.com/Minestom/Minestom/discussions/1302
}