-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial v1_16 submodule as duplicate of v1_15
- Loading branch information
1 parent
ca86331
commit 4f9d04b
Showing
45 changed files
with
5,765 additions
and
0 deletions.
There are no files selected for viewing
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
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,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.denizenscript</groupId> | ||
<artifactId>denizen-parent</artifactId> | ||
<version>1.1.5-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>denizen-v1_16</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.denizenscript</groupId> | ||
<artifactId>denizen</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>compile</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.16.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot</artifactId> | ||
<version>1.16.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
218 changes: 218 additions & 0 deletions
218
v1_16/src/main/java/com/denizenscript/denizen/nms/v1_16/Handler.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,218 @@ | ||
package com.denizenscript.denizen.nms.v1_16; | ||
|
||
import com.denizenscript.denizen.nms.NMSHandler; | ||
import com.denizenscript.denizen.nms.abstracts.*; | ||
import com.denizenscript.denizen.nms.v1_16.helpers.*; | ||
import com.denizenscript.denizen.nms.v1_16.impl.BiomeNMSImpl; | ||
import com.denizenscript.denizen.nms.v1_16.impl.ProfileEditorImpl; | ||
import com.denizenscript.denizen.nms.v1_16.impl.SidebarImpl; | ||
import com.denizenscript.denizen.nms.v1_16.impl.blocks.BlockLightImpl; | ||
import com.denizenscript.denizen.nms.v1_16.impl.jnbt.CompoundTagImpl; | ||
import com.denizenscript.denizen.nms.v1_16.impl.network.handlers.DenizenPacketListenerImpl; | ||
import com.denizenscript.denizen.nms.util.jnbt.Tag; | ||
import com.denizenscript.denizen.utilities.packets.DenizenPacketHandler; | ||
import com.google.common.collect.Iterables; | ||
import com.mojang.authlib.GameProfile; | ||
import com.mojang.authlib.properties.Property; | ||
import com.denizenscript.denizen.nms.util.PlayerProfile; | ||
import com.denizenscript.denizen.nms.util.ReflectionHelper; | ||
import com.denizenscript.denizen.nms.util.jnbt.CompoundTag; | ||
import com.denizenscript.denizencore.utilities.CoreUtilities; | ||
import com.denizenscript.denizencore.utilities.debugging.Debug; | ||
import net.minecraft.server.v1_16_R1.Entity; | ||
import net.minecraft.server.v1_16_R1.IInventory; | ||
import net.minecraft.server.v1_16_R1.INamableTileEntity; | ||
import net.minecraft.server.v1_16_R1.MinecraftServer; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.block.Biome; | ||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer; | ||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; | ||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventory; | ||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventoryCustom; | ||
import org.bukkit.craftbukkit.v1_16_R1.util.CraftChatMessage; | ||
import org.bukkit.craftbukkit.v1_16_R1.util.CraftMagicNumbers; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.Inventory; | ||
import org.spigotmc.AsyncCatcher; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Map; | ||
|
||
public class Handler extends NMSHandler { | ||
|
||
public Handler() { | ||
advancementHelper = new AdvancementHelperImpl(); | ||
animationHelper = new AnimationHelperImpl(); | ||
blockHelper = new BlockHelperImpl(); | ||
chunkHelper = new ChunkHelperImpl(); | ||
customEntityHelper = new CustomEntityHelperImpl(); | ||
entityHelper = new EntityHelperImpl(); | ||
fishingHelper = new FishingHelperImpl(); | ||
itemHelper = new ItemHelperImpl(); | ||
soundHelper = new SoundHelperImpl(); | ||
packetHelper = new PacketHelperImpl(); | ||
particleHelper = new ParticleHelperImpl(); | ||
playerHelper = new PlayerHelperImpl(); | ||
worldHelper = new WorldHelperImpl(); | ||
} | ||
|
||
private final ProfileEditor profileEditor = new ProfileEditorImpl(); | ||
|
||
private boolean wasAsyncCatcherEnabled; | ||
|
||
@Override | ||
public void disableAsyncCatcher() { | ||
wasAsyncCatcherEnabled = AsyncCatcher.enabled; | ||
AsyncCatcher.enabled = false; | ||
} | ||
|
||
@Override | ||
public void undisableAsyncCatcher() { | ||
AsyncCatcher.enabled = wasAsyncCatcherEnabled; | ||
} | ||
|
||
@Override | ||
public boolean isCorrectMappingsCode() { | ||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals("5684afcc1835d966e1b6eb0ed3f72edb"); | ||
} | ||
|
||
@Override | ||
public double[] getRecentTps() { | ||
return ((CraftServer) Bukkit.getServer()).getServer().recentTps; | ||
} | ||
|
||
@Override | ||
public void enablePacketInterception(DenizenPacketHandler packetHandler) { | ||
DenizenPacketListenerImpl.enable(packetHandler); | ||
} | ||
|
||
@Override | ||
public CompoundTag createCompoundTag(Map<String, Tag> value) { | ||
return new CompoundTagImpl(value); | ||
} | ||
|
||
@Override | ||
public Sidebar createSidebar(Player player) { | ||
return new SidebarImpl(player); | ||
} | ||
|
||
@Override | ||
public BlockLight createBlockLight(Location location, int lightLevel, long ticks) { | ||
return BlockLightImpl.createLight(location, lightLevel, ticks); | ||
} | ||
|
||
@Override | ||
public PlayerProfile fillPlayerProfile(PlayerProfile playerProfile) { | ||
try { | ||
if (playerProfile != null) { | ||
GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName()); | ||
gameProfile.getProperties().get("textures").clear(); | ||
if (playerProfile.getTextureSignature() != null) { | ||
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature())); | ||
} | ||
else { | ||
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture())); | ||
} | ||
MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer(); | ||
GameProfile gameProfile1 = null; | ||
if (gameProfile.getId() != null) { | ||
gameProfile1 = minecraftServer.getUserCache().getProfile(gameProfile.getId()); | ||
} | ||
if (gameProfile1 == null && gameProfile.getName() != null) { | ||
gameProfile1 = minecraftServer.getUserCache().getProfile(gameProfile.getName()); | ||
} | ||
if (gameProfile1 == null) { | ||
gameProfile1 = gameProfile; | ||
} | ||
if (playerProfile.hasTexture()) { | ||
gameProfile1.getProperties().get("textures").clear(); | ||
if (playerProfile.getTextureSignature() != null) { | ||
gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature())); | ||
} | ||
else { | ||
gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture())); | ||
} | ||
} | ||
if (Iterables.getFirst(gameProfile1.getProperties().get("textures"), null) == null) { | ||
gameProfile1 = minecraftServer.getMinecraftSessionService().fillProfileProperties(gameProfile1, true); | ||
} | ||
Property property = Iterables.getFirst(gameProfile1.getProperties().get("textures"), null); | ||
return new PlayerProfile(gameProfile1.getName(), gameProfile1.getId(), | ||
property != null ? property.getValue() : null, | ||
property != null ? property.getSignature() : null); | ||
} | ||
} | ||
catch (Exception e) { | ||
if (Debug.verbose) { | ||
Debug.echoError(e); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getPort() { | ||
return ((CraftServer) Bukkit.getServer()).getServer().getPort(); | ||
} | ||
|
||
@Override | ||
public String getTitle(Inventory inventory) { | ||
IInventory nms = ((CraftInventory) inventory).getInventory(); | ||
if (nms instanceof INamableTileEntity) { | ||
return CraftChatMessage.fromComponent(((INamableTileEntity) nms).getDisplayName()); | ||
} | ||
else if (MINECRAFT_INVENTORY.isInstance(nms)) { | ||
try { | ||
return (String) INVENTORY_TITLE.get(nms); | ||
} | ||
catch (IllegalAccessException e) { | ||
Debug.echoError(e); | ||
} | ||
} | ||
return "Chest"; | ||
} | ||
|
||
public static final Class MINECRAFT_INVENTORY; | ||
public static final Field INVENTORY_TITLE; | ||
public static final Field ENTITY_BUKKITYENTITY = ReflectionHelper.getFields(Entity.class).get("bukkitEntity"); | ||
|
||
static { | ||
Class minecraftInv = null; | ||
Field title = null; | ||
try { | ||
for (Class clzz : CraftInventoryCustom.class.getDeclaredClasses()) { | ||
if (CoreUtilities.toLowerCase(clzz.getName()).contains("minecraftinventory")) { // MinecraftInventory. | ||
minecraftInv = clzz; | ||
title = clzz.getDeclaredField("title"); | ||
title.setAccessible(true); | ||
break; | ||
} | ||
} | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
MINECRAFT_INVENTORY = minecraftInv; | ||
INVENTORY_TITLE = title; | ||
} | ||
|
||
@Override | ||
public PlayerProfile getPlayerProfile(Player player) { | ||
GameProfile gameProfile = ((CraftPlayer) player).getProfile(); | ||
Property property = Iterables.getFirst(gameProfile.getProperties().get("textures"), null); | ||
return new PlayerProfile(gameProfile.getName(), gameProfile.getId(), | ||
property != null ? property.getValue() : null, | ||
property != null ? property.getSignature() : null); | ||
} | ||
|
||
@Override | ||
public ProfileEditor getProfileEditor() { | ||
return profileEditor; | ||
} | ||
|
||
@Override | ||
public BiomeNMS getBiomeNMS(Biome biome) { | ||
return new BiomeNMSImpl(biome); | ||
} | ||
} |
Oops, something went wrong.