Skip to content

Commit 315d5b6

Browse files
committed
fix npe in checking perms
1 parent 4b15655 commit 315d5b6

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@
11731173
+ else return this.server.getOpPermissionLevel() >= permLevel;
11741174
+ }
11751175
+
1176-
+ return this.getBukkitEntity().hasPermission("minecraft.command." + commandName) || this.getBukkitEntity().hasPermission(commandName) || this.getBukkitEntity().hasPermission(catroom.CatRoom.forgeCommandPerms.get(commandName));
1176+
+ return catroom.CatRoom.hasPlayerPermission(this, commandName);
11771177
}
11781178

11791179
public String getPlayerIP()

src/main/java/catroom/CatRoom.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import net.minecraft.command.CommandBase;
44
import net.minecraft.command.ICommand;
5+
import net.minecraft.entity.player.EntityPlayerMP;
56
import net.minecraft.world.WorldServer;
7+
import net.minecraftforge.fml.common.FMLLog;
68
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
9+
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
10+
import org.bukkit.event.world.WorldLoadEvent;
711

812
import java.util.List;
913
import java.util.Map;
@@ -19,7 +23,14 @@ public static String getForgeCommandPermission(ICommand command) {
1923

2024
public static void callBukkitWorldLoadEvent(CraftServer server, List<WorldServer> worldServerList) { // fix Nether-API
2125
for (WorldServer world : worldServerList) {
22-
server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
26+
server.getPluginManager().callEvent(new WorldLoadEvent(world.getWorld()));
2327
}
2428
}
29+
30+
public static boolean hasPlayerPermission(EntityPlayerMP player, String commandName) { // hmmm, should i move this method to another place?..
31+
CraftPlayer bukkitPlayer = player.getBukkitEntity();
32+
33+
return bukkitPlayer.hasPermission("minecraft.command." + commandName) || bukkitPlayer.hasPermission(commandName) ||
34+
(forgeCommandPerms.containsKey(commandName) && bukkitPlayer.hasPermission(forgeCommandPerms.get(commandName)));
35+
}
2536
}

src/main/java/net/minecraftforge/fml/common/ModClassLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Class<?> loadClass(String name) throws ClassNotFoundException {
103103

104104
public File[] getParentSources() {
105105
try {
106-
List<File> files = new ArrayList<File>();
106+
List<File> files = new ArrayList<>();
107107
for(URL url : this.mainClassLoader.getSources()) {
108108
URI uri = url.toURI();
109109
if(uri.getScheme().equals("file")) {

0 commit comments

Comments
 (0)