Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Is there a way to set the PermissionLevel of a player.

Because i find only the Methode:

				playerEntity.hasPermissionLevel(?);

 

  • Author
58 minutes ago, 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.

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 by Luis_ST

  • Author
21 minutes ago, diesieben07 said:

Please learn basic Java. The == operator is the wrong tool here.

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 by Luis_ST
add code

  • Author
4 minutes ago, diesieben07 said:

This will fail on a client world, because getServer returns null.

so

!world.isRemote

 will fix the problem

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.