-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...tbukkit-v1_19_R1/src/main/java/com/ruinscraft/panilla/craftbukkit/v1_19_R1/TempHacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.ruinscraft.panilla.craftbukkit.v1_19_R1; | ||
|
||
import com.ruinscraft.panilla.api.IPanillaPlayer; | ||
import net.minecraft.server.level.EntityPlayer; | ||
import net.minecraft.server.level.WorldServer; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
public final class TempHacks { | ||
|
||
public static EntityPlayer getEntityPlayerFromPanillaPlayer(IPanillaPlayer panillaPlayer) { | ||
// PanillaPlayer->getHandle()->CraftPlayer->getHandle()->EntityPlayer | ||
Object craftPlayerHandle = panillaPlayer.getHandle(); | ||
|
||
System.out.println(craftPlayerHandle.getClass().getCanonicalName()); | ||
|
||
try { | ||
Method craftPlayerGetHandleMethod = craftPlayerHandle.getClass().getDeclaredMethod("getHandle"); | ||
Object o = craftPlayerGetHandleMethod.invoke(craftPlayerHandle); | ||
System.out.println(o.getClass().getCanonicalName()); | ||
return (EntityPlayer) o; | ||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private static boolean paperChunkRewrite; | ||
|
||
static { | ||
try { | ||
WorldServer.class.getField("P"); | ||
paperChunkRewrite = false; | ||
} catch (NoSuchFieldException e) { | ||
paperChunkRewrite = true; | ||
} | ||
} | ||
|
||
public static boolean isPaperChunkRewrite() { | ||
return paperChunkRewrite; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters