Skip to content

Commit

Permalink
Clean up unnecessary code in permission-api-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Jun 27, 2024
1 parent 26e9a5b commit 2ce7a52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@

package net.legacyfabric.fabric.impl.permission;

import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;

import net.legacyfabric.fabric.api.permission.v1.PermissionsApiHolder;
import net.legacyfabric.fabric.api.permission.v1.PlayerPermissionsApi;
Expand All @@ -44,19 +40,7 @@ public String getId() {

@Override
public boolean hasPermission(ServerPlayerEntity player, String perm) {
return getServer().getPlayerManager().canCheat(player.getUsername());
}
}

protected static MinecraftServer getServer() {
try {
return MinecraftServer.getServer();
} catch (NoSuchMethodError e) {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
return MinecraftClient.getInstance().getServer();
} else {
return (MinecraftServer) FabricLoader.getInstance().getGameInstance();
}
return player.server.getPlayerManager().canCheat(player.getUsername());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@

package net.legacyfabric.fabric.impl.permission;

import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;

import net.legacyfabric.fabric.api.permission.v1.PermissionsApiHolder;
import net.legacyfabric.fabric.api.permission.v1.PlayerPermissionsApi;
Expand All @@ -44,19 +40,7 @@ public String getId() {

@Override
public boolean hasPermission(ServerPlayerEntity player, String perm) {
return getServer().getPlayerManager().isOperator(player.getGameProfile());
}
}

protected static MinecraftServer getServer() {
try {
return MinecraftServer.getServer();
} catch (NoSuchMethodError e) {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
return MinecraftClient.getInstance().getServer();
} else {
return (MinecraftServer) FabricLoader.getInstance().getGameInstance();
}
return player.server.getPlayerManager().isOperator(player.getGameProfile());
}
}
}

0 comments on commit 2ce7a52

Please sign in to comment.