Luis_ST Posted December 18, 2020 Posted December 18, 2020 Is there a way to set the PermissionLevel of a player. Because i find only the Methode: playerEntity.hasPermissionLevel(?); Quote
Luis_ST Posted December 18, 2020 Author Posted December 18, 2020 (edited) On 12/18/2020 at 2:11 PM, diesieben07 said: The permission level is as follows: For the single-player "main player" it is 4. If "cheats" is enabled for "share to LAN" then connected players will also have 4. Otherwise they will have 0. For servers non-ops will have 0. Ops will have the permission level that was set in the server.properties (op-permission-level) at the time they were made op. You can set a specific permission level for an op using PlayerList#getOppedPlayers().addEntry with a new OpEntry. You cannot set the permission level for non-ops. Expand i just do this but it dont work but why: i just try tomake myself always an operator @SubscribeEvent public static void WorldTick(TickEvent.WorldTickEvent event) { World world = event.world; PlayerList playerList = world.getServer().getPlayerList(); List<? extends PlayerEntity> player = world.getPlayers(); if (!world.isRemote) { for (PlayerEntity playerEntity : player) { GameProfile gameprofile = playerEntity.getGameProfile(); UUID id = UUID.fromString("bea9c486-9207-4981-b7cf-b14a88942027"); if (!playerEntity.hasPermissionLevel(4)) { if (gameprofile.getId() == id) { playerList.addOp(gameprofile); } } } } } Edited December 18, 2020 by Luis_ST Quote
Luis_ST Posted December 18, 2020 Author Posted December 18, 2020 (edited) On 12/18/2020 at 3:13 PM, diesieben07 said: Please learn basic Java. The == operator is the wrong tool here. Expand okay thanks another quastion i creat an event which checks whether a player has been banned when its true the ban will remove but i got this error after a bit time: java.lang.NullPointerException: Unexpected error at net.luis.cave.events.client.world.OnWorldTick.PlayerLeaveWorld(OnWorldTick.java:74) ~[?:1.0] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_23_OnWorldTick_PlayerLeaveWorld_EntityLeaveWorldEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-3.0.3-service.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.3-service.jar:?] {} at net.minecraft.client.world.ClientWorld.func_217414_d(ClientWorld.java:314) ~[?:?] {re:classloading,xf:fml:xaerominimap:xaero_clientworldclass,pl:runtimedistcleaner:A} at net.minecraft.client.world.ClientWorld.func_217419_d(ClientWorld.java:167) ~[?:?] {re:classloading,xf:fml:xaerominimap:xaero_clientworldclass,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1457) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:928) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:582) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {} at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {} at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.1-32.0.108.jar:32.0] {} at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$420/1003307628.call(Unknown Source) [forge-1.16.1-32.0.108.jar:32.0] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-6.1.1.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-6.1.1.jar:?] {} and this is the event: @SubscribeEvent public static void PlayerLeaveWorld(EntityLeaveWorldEvent event) { Entity player = event.getEntity(); World world = event.getWorld(); PlayerList playerList = world.getServer().getPlayerList(); BanList banList = playerList.getBannedPlayers(); if (!world.isRemote) { if (player instanceof PlayerEntity) { GameProfile gameprofile = ((PlayerEntity) player).getGameProfile(); if (banList.isBanned(gameprofile)) { if (!banList.getEntry(gameprofile).getBanReason().equals("You have illegal equipment: Enderite!")) { banList.removeEntry(gameprofile); } } } } } Edited December 18, 2020 by Luis_ST add code Quote
Luis_ST Posted December 18, 2020 Author Posted December 18, 2020 On 12/18/2020 at 3:39 PM, diesieben07 said: This will fail on a client world, because getServer returns null. Expand so !world.isRemote will fix the problem 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.