mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 20:45:27 +01:00
Merge branch 'development'
This commit is contained in:
commit
3ad279ebe4
2
.gitignore
vendored
2
.gitignore
vendored
@ -210,3 +210,5 @@ gradle-app.setting
|
||||
|
||||
### Gradle Patch ###
|
||||
**/build/
|
||||
|
||||
.DS_Store
|
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.3.37"
|
||||
version: "2.3.38"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
13
Core/pom.xml
13
Core/pom.xml
@ -115,9 +115,9 @@
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.papermc</groupId>
|
||||
<artifactId>paper</artifactId>
|
||||
<version>1.15.2</version>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.1</version>
|
||||
</dependency>
|
||||
<!--dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@ -217,6 +217,13 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_16_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End NMS -->
|
||||
<!-- Start Plugin Hooks -->
|
||||
<dependency>
|
||||
|
@ -4,6 +4,7 @@ import com.songoda.core.compatibility.ServerProject;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -315,7 +316,11 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
// If we're on Paper 1.8, we need to register timings (spigot creates timings on init, paper creates it on register)
|
||||
// later versions of paper create timings if needed when the command is executed
|
||||
if (ServerProject.isServer(ServerProject.PAPER, ServerProject.TACO) && ServerVersion.isServerVersionBelow(ServerVersion.V1_9)) {
|
||||
commandObject.timings = co.aikar.timings.TimingsManager.getCommandTiming(plugin.getName().toLowerCase(), commandObject);
|
||||
Class<?> clazz = Class.forName("co.aikar.timings.TimingsManager");
|
||||
Method method = clazz.getMethod("getCommandTiming", String.class, Command.class);
|
||||
Field field = PluginCommand.class.getField("timings");
|
||||
|
||||
field.set(commandObject, method.invoke(null, plugin.getName().toLowerCase(), commandObject));
|
||||
}
|
||||
|
||||
// Set command action
|
||||
|
@ -91,6 +91,9 @@ public class ClientVersion {
|
||||
case 575:
|
||||
case 578:
|
||||
return ServerVersion.V1_15;
|
||||
case 735:
|
||||
case 736:
|
||||
return ServerVersion.V1_16;
|
||||
}
|
||||
return version > 498 ? ServerVersion.getServerVersion() : ServerVersion.UNKNOWN;
|
||||
}
|
||||
|
@ -12,6 +12,12 @@ import java.util.*;
|
||||
*/
|
||||
public enum CompatibleBiome {
|
||||
|
||||
/* 1.16 */
|
||||
SOUL_SAND_VALLEY(ServerVersion.V1_16),
|
||||
CRIMSON_FOREST(ServerVersion.V1_16),
|
||||
WARPED_FOREST(ServerVersion.V1_16),
|
||||
BASALT_DELTAS(ServerVersion.V1_16),
|
||||
|
||||
BADLANDS(ServerVersion.V1_13, v("MESA")),
|
||||
BADLANDS_PLATEAU(ServerVersion.V1_13, v(ServerVersion.V1_9, "MESA_CLEAR_ROCK"), v("MESA_PLATEAU")),
|
||||
BAMBOO_JUNGLE(ServerVersion.V1_14),
|
||||
@ -57,7 +63,7 @@ public enum CompatibleBiome {
|
||||
MOUNTAIN_EDGE(ServerVersion.V1_13, v(ServerVersion.V1_9, "SMALLER_EXTREME_HILLS")),
|
||||
MUSHROOM_FIELDS(ServerVersion.V1_13, v("MUSHROOM_ISLAND")),
|
||||
MUSHROOM_FIELD_SHORE(ServerVersion.V1_13, v(ServerVersion.V1_9, "MUSHROOM_ISLAND_SHORE"), v("MUSHROOM_SHORE")),
|
||||
NETHER(ServerVersion.V1_13, v("HELL")),
|
||||
NETHER_WASTES(ServerVersion.V1_16, v(ServerVersion.V1_13, "NETHER"), v("HELL")),
|
||||
OCEAN(),
|
||||
PLAINS(),
|
||||
RIVER(),
|
||||
|
@ -29,6 +29,110 @@ public enum CompatibleMaterial {
|
||||
|
||||
*/
|
||||
|
||||
/* 1.16 */
|
||||
ANCIENT_DEBRIES(),
|
||||
BASALT(),
|
||||
BLACKSTONE(),
|
||||
BLACKSTONE_STAIRS(),
|
||||
BLACKSTONE_WALL(),
|
||||
BLASTSTONE_SLAB(),
|
||||
CHAIN(),
|
||||
CHISELED_NETHER_BRICKS(),
|
||||
CHISELED_POLISHED_BLACKSTONE(),
|
||||
CRACKED_NETHER_BRICKS(),
|
||||
CRACKED_POLISHED_BLACKSTONE_BRICKS(),
|
||||
CRIMSON_BUTTON(),
|
||||
CRIMSON_DOOR(),
|
||||
CRIMSON_FENCE(),
|
||||
CRIMSON_FENCE_GATE(),
|
||||
CRIMSON_FUNGUS(),
|
||||
CRIMSON_HYPHAE(),
|
||||
CRIMSON_NYLIUM(),
|
||||
CRIMSON_PLANKS(),
|
||||
CRIMSON_PRESSURE_PLATE(),
|
||||
CRIMSON_ROOTS(),
|
||||
CRIMSON_SIGN(),
|
||||
CRIMSON_SLAB(),
|
||||
CRIMSON_STAIRS(),
|
||||
CRIMSON_STEM(),
|
||||
CRIMSON_TRAPDOOR(),
|
||||
CRIMSON_WALL_SIGN(),
|
||||
CRYING_OBSIDIAN(),
|
||||
GILDED_BLACKSTONE(),
|
||||
HOGLIN_SPAWN_EGG(),
|
||||
LODESTONE(),
|
||||
MUSIC_DISC_PIGSTEP(),
|
||||
NETHERITE_AXE(),
|
||||
NETHERITE_BLOCK(),
|
||||
NETHERITE_BOOTS(),
|
||||
NETHERITE_CHESTPLATE(),
|
||||
NETHERITE_HELMET(),
|
||||
NETHERITE_HOE(),
|
||||
NETHERITE_INGOT(),
|
||||
NETHERITE_LEGGINGS(),
|
||||
NETHERITE_PICKAXE(),
|
||||
NETHERITE_SCRAP(),
|
||||
NETHERITE_SHOVEL(),
|
||||
NETHERITE_SWORD(),
|
||||
NETHER_GOLD_ORE(),
|
||||
NETHER_SPROUTS(),
|
||||
PIGLIN_BANNER_PATTERN(),
|
||||
PIGLIN_SPAWN_EGG(),
|
||||
POLISHED_BASALT(),
|
||||
POLISHED_BLACKSTONE(),
|
||||
POLISHED_BLACKSTONE_BRICKS(),
|
||||
POLISHED_BLACKSTONE_BRICK_SLAB(),
|
||||
POLISHED_BLACKSTONE_BRICK_STAIRS(),
|
||||
POLISHED_BLACKSTONE_BRICK_WALL(),
|
||||
POLISHED_BLACKSTONE_BUTTON(),
|
||||
POLISHED_BLACKSTONE_PRESSURE_PLATE(),
|
||||
POLISHED_BLACKSTONE_SLAB(),
|
||||
POLISHED_BLACKSTONE_STAIRS(),
|
||||
POLISHED_BLACKSTONE_WALL(),
|
||||
POTTED_CRIMSON_FUNGUS(),
|
||||
POTTED_CRIMSON_ROOTS(),
|
||||
POTTED_WARPED_FUNGUS(),
|
||||
POTTED_WARPED_ROOTS(),
|
||||
QUARTZ_BRICKS(),
|
||||
RESPAWN_ANCHOR(),
|
||||
SHROOMLIGHT(),
|
||||
SOUL_CAMPFIRE(),
|
||||
SOUL_FIRE(),
|
||||
SOUL_LANTERN(),
|
||||
SOUL_SOIL(),
|
||||
SOUL_TORCH(),
|
||||
SOUL_WALL_TORCH(),
|
||||
STRIDER_SPAWN_EGG(),
|
||||
STRIPPED_CRIMSON_HYPHAE(),
|
||||
STRIPPED_CRIMSON_STEM(),
|
||||
STRIPPED_WARPED_HYPHAE(),
|
||||
STRIPPED_WARPED_STEM(),
|
||||
TARGET(),
|
||||
TWISTING_VINES(),
|
||||
TWISTING_VINES_PLANT(),
|
||||
WARPED_BUTTON(),
|
||||
WARPED_DOOR(),
|
||||
WARPED_FENCE(),
|
||||
WARPED_FENCE_GATE(),
|
||||
WARPED_FUNGUS(),
|
||||
WARPED_FUNGUS_ON_A_STICK(),
|
||||
WARPED_HYPHAE(),
|
||||
WARPED_NYLIUM(),
|
||||
WARPED_PLANKS(),
|
||||
WARPED_PRESSURE_PLATE(),
|
||||
WARPED_ROOTS(),
|
||||
WARPED_SIGN(),
|
||||
WARPED_SLAB(),
|
||||
WARPED_STAIRS(),
|
||||
WARPED_STEM(),
|
||||
WARPED_TRAPDOOR(),
|
||||
WARPED_WALL_SIGN(),
|
||||
WARPED_WART_BLOCK(),
|
||||
WEEPING_VINES(),
|
||||
WEEPING_VINES_PLANT(),
|
||||
ZOGLIN_SPAWN_EGG(),
|
||||
ZOMBIFIED_PIGLIN_SPAWN_EGG(),
|
||||
|
||||
/* 1.15 */
|
||||
BEE_SPAWN_EGG(),
|
||||
BEE_NEST(),
|
||||
@ -1038,7 +1142,7 @@ public enum CompatibleMaterial {
|
||||
lookupMap.put(m.legacy, m);
|
||||
continue;
|
||||
}
|
||||
lookupMap.put(m.name(), m);
|
||||
lookupMap.put(m.name(), m);
|
||||
if (!m.usesCompatibility()) {
|
||||
lookupMap.put(m.material + ":" + (m.data == null ? "" : m.data), m);
|
||||
}
|
||||
@ -1684,12 +1788,10 @@ public enum CompatibleMaterial {
|
||||
*/
|
||||
public EntityType getEggType() {
|
||||
String entityName = this.name().replace("_SPAWN_EGG", "");
|
||||
if (entityName.equals("MOOSHROOM")) {
|
||||
return EntityType.MUSHROOM_COW;
|
||||
}
|
||||
if (entityName.equals("ZOMBIE_PIGMAN")) {
|
||||
return EntityType.PIG_ZOMBIE;
|
||||
}
|
||||
if (entityName.equals("MOOSHROOM"))
|
||||
entityName = "MUSHROOM_COW";
|
||||
else if (entityName.equals("ZOMBIE_PIGMAN"))
|
||||
entityName = "PIG_ZOMBIE";
|
||||
try {
|
||||
return EntityType.valueOf(entityName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -2214,7 +2316,8 @@ public enum CompatibleMaterial {
|
||||
return MOOSHROOM_SPAWN_EGG;
|
||||
}
|
||||
|
||||
if (type == EntityType.PIG_ZOMBIE) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_16)
|
||||
&& type == EntityType.valueOf("PIG_ZOMBIE")) {
|
||||
return ZOMBIE_PIGMAN_SPAWN_EGG;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,18 @@ public class CompatibleParticleHandler {
|
||||
FALLING_NECTAR(ServerVersion.V1_15, "DRIP_WATER"),
|
||||
LANDING_HONEY(ServerVersion.V1_15, "DRIP_WATER"),
|
||||
/// End 1.15 ///
|
||||
// ToDo: Someone needs to make better compatible fall backs.
|
||||
SOUL_FIRE_FLAME(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
ASH(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
CRIMSON_SPORE(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
WARPED_SPORE(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
SOUL(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
DRIPPING_OBSIDIAN_TEAR(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
FALLING_OBSIDIAN_TEAR(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
LANDING_OBSIDIAN_TEAR(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
REVERSE_PORTAL(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
WHITE_ASH(ServerVersion.V1_16, "DRIP_WATER"),
|
||||
/// End 1.16 ///
|
||||
;
|
||||
|
||||
final boolean compatibilityMode;
|
||||
|
@ -24,6 +24,181 @@ public enum CompatibleSound {
|
||||
// 1.8 list:
|
||||
// https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/mapping-and-modding-tutorials/2213619-1-8-all-playsound-sound-arguments
|
||||
|
||||
/* 1.16 */
|
||||
// TODO: add similar sounds for older versions
|
||||
AMBIENT_BASALT_DELTAS_ADDITIONS(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_BASALT_DELTAS_LOOP(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_BASALT_DELTAS_MOOD(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_CRIMSON_FOREST_ADDITIONS(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_CRIMSON_FOREST_LOOP(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_CRIMSON_FOREST_MOOD(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_NETHER_WASTES_ADDITIONS(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_NETHER_WASTES_LOOP(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_NETHER_WASTES_MOOD(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_SOUL_SAND_VALLEY_ADDITIONS(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_SOUL_SAND_VALLEY_LOOP(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_SOUL_SAND_VALLEY_MOOD(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_WARPED_FOREST_ADDITIONS(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_WARPED_FOREST_LOOP(ServerVersion.V1_16, v(null, true)),
|
||||
AMBIENT_WARPED_FOREST_MOOD(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ANCIENT_DEBRIS_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ANCIENT_DEBRIS_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ANCIENT_DEBRIS_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ANCIENT_DEBRIS_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ANCIENT_DEBRIS_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BASALT_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BASALT_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BASALT_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BASALT_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BASALT_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BONE_BLOCK_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BONE_BLOCK_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BONE_BLOCK_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BONE_BLOCK_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_BONE_BLOCK_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_CHAIN_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_CHAIN_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_CHAIN_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_CHAIN_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_CHAIN_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_FUNGUS_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_FUNGUS_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_FUNGUS_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_FUNGUS_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_FUNGUS_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_GILDED_BLACKSTONE_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_GILDED_BLACKSTONE_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_GILDED_BLACKSTONE_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_GILDED_BLACKSTONE_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_GILDED_BLACKSTONE_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_LODESTONE_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_LODESTONE_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_LODESTONE_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_LODESTONE_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_LODESTONE_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERITE_BLOCK_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERITE_BLOCK_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERITE_BLOCK_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERITE_BLOCK_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERITE_BLOCK_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERRACK_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERRACK_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERRACK_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERRACK_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHERRACK_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_BRICKS_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_BRICKS_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_BRICKS_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_BRICKS_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_BRICKS_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_GOLD_ORE_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_GOLD_ORE_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_GOLD_ORE_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_GOLD_ORE_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_GOLD_ORE_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_ORE_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_ORE_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_ORE_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_ORE_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_ORE_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_SPROUTS_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_SPROUTS_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_SPROUTS_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_SPROUTS_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NETHER_SPROUTS_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NYLIUM_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NYLIUM_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NYLIUM_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NYLIUM_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_NYLIUM_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_RESPAWN_ANCHOR_AMBIENT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_RESPAWN_ANCHOR_CHARGE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_RESPAWN_ANCHOR_DEPLETE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_RESPAWN_ANCHOR_SET_SPAWN(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ROOTS_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ROOTS_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ROOTS_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ROOTS_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_ROOTS_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SHROOMLIGHT_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SHROOMLIGHT_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SHROOMLIGHT_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SHROOMLIGHT_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SHROOMLIGHT_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SMITHING_TABLE_USE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SAND_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SAND_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SAND_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SAND_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SAND_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SOIL_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SOIL_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SOIL_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SOIL_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_SOUL_SOIL_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_STEM_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_STEM_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_STEM_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_STEM_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_STEM_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_VINE_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WART_BLOCK_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WART_BLOCK_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WART_BLOCK_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WART_BLOCK_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WART_BLOCK_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WEEPING_VINES_BREAK(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WEEPING_VINES_FALL(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WEEPING_VINES_HIT(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WEEPING_VINES_PLACE(ServerVersion.V1_16, v(null, true)),
|
||||
BLOCK_WEEPING_VINES_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_DONKEY_EAT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_FOX_TELEPORT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_MULE_ANGRY(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_MULE_EAT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PARROT_IMITATE_HOGLIN(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PARROT_IMITATE_PIGLIN(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PARROT_IMITATE_ZOGLIN(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_ADMIRING_ITEM(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_AMBIENT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_ANGRY(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_CELEBRATE(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_DEATH(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_HURT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_JEALOUS(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_RETREAT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_PIGLIN_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_SNOW_GOLEM_SHEAR(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_AMBIENT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_DEATH(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_EAT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_HAPPY(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_HURT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_RETREAT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_SADDLE(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_STRIDER_STEP_LAVA(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOGLIN_AMBIENT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOGLIN_ANGRY(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOGLIN_ATTACK(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOGLIN_DEATH(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOGLIN_HURT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOGLIN_STEP(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_AMBIENT(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_ANGRY(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_DEATH(ServerVersion.V1_16, v(null, true)),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_HURT(ServerVersion.V1_16, v(null, true)),
|
||||
ITEM_ARMOR_EQUIP_NETHERITE(ServerVersion.V1_16, v(null, true)),
|
||||
ITEM_LODESTONE_COMPASS_LOCK(ServerVersion.V1_16, v(null, true)),
|
||||
MUSIC_DISC_PIGSTEP(ServerVersion.V1_16, v(null, true)),
|
||||
MUSIC_NETHER_BASALT_DELTAS(ServerVersion.V1_16, v(null, true)),
|
||||
MUSIC_NETHER_CRIMSON_FOREST(ServerVersion.V1_16, v(null, true)),
|
||||
MUSIC_NETHER_NETHER_WASTES(ServerVersion.V1_16, v(null, true)),
|
||||
MUSIC_NETHER_SOUL_SAND_VALLEY(ServerVersion.V1_16, v(null, true)),
|
||||
MUSIC_NETHER_WARPED_FOREST(ServerVersion.V1_16, v(null, true)),
|
||||
PARTICLE_SOUL_ESCAPE(ServerVersion.V1_16, v(null, true)),
|
||||
|
||||
/* 1.15 */
|
||||
// TODO: add similar sounds for older versions
|
||||
BLOCK_BEEHIVE_DRIP(ServerVersion.V1_15, v(null, true)),
|
||||
|
@ -12,6 +12,111 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public enum LegacyMaterialAnalouge {
|
||||
|
||||
/* 1.16 */
|
||||
// ToDo: Improve legal materials.
|
||||
ANCIENT_DEBRIES(ServerVersion.V1_15, "STONE"),
|
||||
BASALT(ServerVersion.V1_15, "STONE"),
|
||||
BLACKSTONE(ServerVersion.V1_15, "STONE"),
|
||||
BLACKSTONE_STAIRS(ServerVersion.V1_15, "STONE"),
|
||||
BLACKSTONE_WALL(ServerVersion.V1_15, "STONE"),
|
||||
BLASTSTONE_SLAB(ServerVersion.V1_15, "STONE"),
|
||||
CHAIN(ServerVersion.V1_15, "STONE"),
|
||||
CHISELED_NETHER_BRICKS(ServerVersion.V1_15, "STONE"),
|
||||
CHISELED_POLISHED_BLACKSTONE(ServerVersion.V1_15, "STONE"),
|
||||
CRACKED_NETHER_BRICKS(ServerVersion.V1_15, "STONE"),
|
||||
CRACKED_POLISHED_BLACKSTONE_BRICKS(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_BUTTON(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_DOOR(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_FENCE(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_FENCE_GATE(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_FUNGUS(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_HYPHAE(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_NYLIUM(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_PLANKS(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_PRESSURE_PLATE(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_ROOTS(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_SIGN(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_SLAB(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_STAIRS(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_STEM(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_TRAPDOOR(ServerVersion.V1_15, "STONE"),
|
||||
CRIMSON_WALL_SIGN(ServerVersion.V1_15, "STONE"),
|
||||
CRYING_OBSIDIAN(ServerVersion.V1_15, "STONE"),
|
||||
GILDED_BLACKSTONE(ServerVersion.V1_15, "STONE"),
|
||||
HOGLIN_SPAWN_EGG(ServerVersion.V1_15, "STONE"),
|
||||
LODESTONE(ServerVersion.V1_15, "STONE"),
|
||||
MUSIC_DISC_PIGSTEP(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_AXE(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_BLOCK(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_BOOTS(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_CHESTPLATE(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_HELMET(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_HOE(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_INGOT(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_LEGGINGS(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_PICKAXE(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_SCRAP(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_SHOVEL(ServerVersion.V1_15, "STONE"),
|
||||
NETHERITE_SWORD(ServerVersion.V1_15, "STONE"),
|
||||
NETHER_GOLD_ORE(ServerVersion.V1_15, "STONE"),
|
||||
NETHER_SPROUTS(ServerVersion.V1_15, "STONE"),
|
||||
PIGLIN_BANNER_PATTERN(ServerVersion.V1_15, "STONE"),
|
||||
PIGLIN_SPAWN_EGG(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BASALT(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_BRICKS(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_BRICK_SLAB(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_BRICK_STAIRS(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_BRICK_WALL(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_BUTTON(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_PRESSURE_PLATE(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_SLAB(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_STAIRS(ServerVersion.V1_15, "STONE"),
|
||||
POLISHED_BLACKSTONE_WALL(ServerVersion.V1_15, "STONE"),
|
||||
POTTED_CRIMSON_FUNGUS(ServerVersion.V1_15, "STONE"),
|
||||
POTTED_CRIMSON_ROOTS(ServerVersion.V1_15, "STONE"),
|
||||
POTTED_WARPED_FUNGUS(ServerVersion.V1_15, "STONE"),
|
||||
POTTED_WARPED_ROOTS(ServerVersion.V1_15, "STONE"),
|
||||
QUARTZ_BRICKS(ServerVersion.V1_15, "STONE"),
|
||||
RESPAWN_ANCHOR(ServerVersion.V1_15, "STONE"),
|
||||
SHROOMLIGHT(ServerVersion.V1_15, "STONE"),
|
||||
SOUL_CAMPFIRE(ServerVersion.V1_15, "STONE"),
|
||||
SOUL_FIRE(ServerVersion.V1_15, "STONE"),
|
||||
SOUL_LANTERN(ServerVersion.V1_15, "STONE"),
|
||||
SOUL_SOIL(ServerVersion.V1_15, "STONE"),
|
||||
SOUL_TORCH(ServerVersion.V1_15, "STONE"),
|
||||
SOUL_WALL_TORCH(ServerVersion.V1_15, "STONE"),
|
||||
STRIDER_SPAWN_EGG(ServerVersion.V1_15, "STONE"),
|
||||
STRIPPED_CRIMSON_HYPHAE(ServerVersion.V1_15, "STONE"),
|
||||
STRIPPED_CRIMSON_STEM(ServerVersion.V1_15, "STONE"),
|
||||
STRIPPED_WARPED_HYPHAE(ServerVersion.V1_15, "STONE"),
|
||||
STRIPPED_WARPED_STEM(ServerVersion.V1_15, "STONE"),
|
||||
TARGET(ServerVersion.V1_15, "STONE"),
|
||||
TWISTING_VINES(ServerVersion.V1_15, "STONE"),
|
||||
TWISTING_VINES_PLANT(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_BUTTON(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_DOOR(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_FENCE(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_FENCE_GATE(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_FUNGUS(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_FUNGUS_ON_A_STICK(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_HYPHAE(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_NYLIUM(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_PLANKS(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_PRESSURE_PLATE(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_ROOTS(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_SIGN(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_SLAB(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_STAIRS(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_STEM(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_TRAPDOOR(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_WALL_SIGN(ServerVersion.V1_15, "STONE"),
|
||||
WARPED_WART_BLOCK(ServerVersion.V1_15, "STONE"),
|
||||
WEEPING_VINES(ServerVersion.V1_15, "STONE"),
|
||||
WEEPING_VINES_PLANT(ServerVersion.V1_15, "STONE"),
|
||||
ZOGLIN_SPAWN_EGG(ServerVersion.V1_15, "STONE"),
|
||||
ZOMBIFIED_PIGLIN_SPAWN_EGG(ServerVersion.V1_15, "STONE"),
|
||||
|
||||
/* 1.15 */
|
||||
BEE_SPAWN_EGG(ServerVersion.V1_15, "PARROT_SPAWN_EGG", ServerVersion.V1_12, "MONSTER_EGG", (byte) 65),
|
||||
BEE_NEST(ServerVersion.V1_15, "BIRCH_LOG", "LOG", (byte) 2),
|
||||
|
@ -64,6 +64,10 @@ public class NmsManager {
|
||||
anvil = new com.songoda.core.nms.v1_15_R1.anvil.AnvilCore();
|
||||
nbt = new com.songoda.core.nms.v1_15_R1.nbt.NBTCoreImpl();
|
||||
break;
|
||||
case "v1_16_R1":
|
||||
anvil = new com.songoda.core.nms.v1_16_R1.anvil.AnvilCore();
|
||||
nbt = new com.songoda.core.nms.v1_16_R1.nbt.NBTCoreImpl();
|
||||
break;
|
||||
default:
|
||||
Logger.getLogger(NmsManager.class.getName()).log(Level.SEVERE, "Failed to load NMS for this server version: version {0} not found", serverPackageVersion);
|
||||
anvil = null;
|
||||
|
29
NMS/NMS-v1_16_R1/pom.xml
Normal file
29
NMS/NMS-v1_16_R1/pom.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>maven-version-number</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>SongodaCore-NMS-v1_16_R1</artifactId>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,23 @@
|
||||
package com.songoda.core.nms.v1_16_R1.anvil;
|
||||
|
||||
import com.songoda.core.nms.anvil.CustomAnvil;
|
||||
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class AnvilCore implements com.songoda.core.nms.anvil.AnvilCore {
|
||||
|
||||
@Override
|
||||
public CustomAnvil createAnvil(Player player) {
|
||||
EntityPlayer p = ((CraftPlayer) player).getHandle();
|
||||
return new AnvilView(p.nextContainerCounter(), p, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomAnvil createAnvil(Player player, InventoryHolder holder) {
|
||||
EntityPlayer p = ((CraftPlayer) player).getHandle();
|
||||
return new AnvilView(p.nextContainerCounter(), p, holder);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.songoda.core.nms.v1_16_R1.anvil;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_16_R1.IInventory;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventoryAnvil;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class AnvilInventoryCustom extends CraftInventoryAnvil {
|
||||
|
||||
final InventoryHolder holder;
|
||||
|
||||
public AnvilInventoryCustom(InventoryHolder holder, Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
|
||||
super(location, inventory, resultInventory, container);
|
||||
this.holder = holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryHolder getHolder() {
|
||||
return holder;
|
||||
}
|
||||
}
|
@ -0,0 +1,229 @@
|
||||
package com.songoda.core.nms.v1_16_R1.anvil;
|
||||
|
||||
import com.songoda.core.nms.anvil.CustomAnvil;
|
||||
import com.songoda.core.nms.anvil.methods.AnvilTextChange;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R1.ChatMessage;
|
||||
import net.minecraft.server.v1_16_R1.Container;
|
||||
import net.minecraft.server.v1_16_R1.ContainerAccess;
|
||||
import net.minecraft.server.v1_16_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_16_R1.Containers;
|
||||
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R1.IInventory;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutOpenWindow;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventoryView;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class AnvilView extends ContainerAnvil implements CustomAnvil {
|
||||
|
||||
private final EntityPlayer entity;
|
||||
private final Inventory inventory;
|
||||
private String customTitle = "Repairing";
|
||||
private int cost = -1;
|
||||
private boolean canUse = true;
|
||||
private AnvilTextChange textChange = null;
|
||||
|
||||
// used for setting custom inventory
|
||||
static Field mc_ContainerAnvil_repairInventory; // subcontainer with only the result
|
||||
static Field mc_ContainerAnvil_resultInventory; // full inventory
|
||||
static Field mc_ContainerAnvil_bukkitEntity;
|
||||
|
||||
static {
|
||||
try {
|
||||
mc_ContainerAnvil_repairInventory = ContainerAnvil.class.getDeclaredField("repairInventory");
|
||||
mc_ContainerAnvil_repairInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_resultInventory = ContainerAnvil.class.getDeclaredField("resultInventory");
|
||||
mc_ContainerAnvil_resultInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_bukkitEntity = ContainerAnvil.class.getDeclaredField("bukkitEntity");
|
||||
mc_ContainerAnvil_bukkitEntity.setAccessible(true);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
static Method mc_ContainerProperty_set;
|
||||
static Method mc_ContainerProperty_get;
|
||||
// 1.15 made this field public again, but now it's final. idk.
|
||||
static Field mc_Container_windowId;
|
||||
// 1.14 also introduced a title field, also private, which can only be set once and can't be checked
|
||||
static Field mc_Container_title;
|
||||
|
||||
static {
|
||||
try {
|
||||
mc_Container_title = Container.class.getDeclaredField("title");
|
||||
mc_Container_title.setAccessible(true);
|
||||
mc_Container_windowId = Container.class.getDeclaredField("windowId");
|
||||
mc_Container_windowId.setAccessible(true);
|
||||
|
||||
// remove the final modifier
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
modifiersField.setInt(mc_Container_windowId, mc_Container_windowId.getModifiers() & ~Modifier.FINAL);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public AnvilView(int id, EntityPlayer entity, InventoryHolder holder) {
|
||||
super(id, entity.inventory, ContainerAccess.at(entity.world, new BlockPosition(0, 0, 0)));
|
||||
this.setTitle(new ChatMessage(customTitle != null ? customTitle : ""));
|
||||
this.checkReachable = false;
|
||||
this.entity = entity;
|
||||
if(holder != null) {
|
||||
this.inventory = getBukkitView(entity, holder).getTopInventory();
|
||||
} else {
|
||||
this.inventory = getBukkitView().getTopInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public CraftInventoryView getBukkitView(EntityHuman player, InventoryHolder holder) {
|
||||
try {
|
||||
AnvilInventoryCustom craftInventory = new AnvilInventoryCustom(holder,
|
||||
new Location(entity.world.getWorld(), 0, 0, 0),
|
||||
(IInventory) mc_ContainerAnvil_repairInventory.get(this),
|
||||
(IInventory) mc_ContainerAnvil_resultInventory.get(this), this);
|
||||
CraftInventoryView view = new CraftInventoryView(player.getBukkitEntity(), craftInventory, this);
|
||||
mc_ContainerAnvil_bukkitEntity.set(this, view);
|
||||
return view;
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
return getBukkitView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(EntityHuman entityhuman) {
|
||||
return canUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e() {
|
||||
super.e();
|
||||
if (cost >= 0) {
|
||||
this.levelCost.set(cost);
|
||||
}
|
||||
textChange.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
e();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenameText() {
|
||||
return this.renameText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenameText(String text) {
|
||||
this.a(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnChange(AnvilTextChange handler) {
|
||||
textChange = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomTitle() {
|
||||
return customTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomTitle(String title) {
|
||||
this.customTitle = title;
|
||||
try {
|
||||
mc_Container_title.set(this, new ChatMessage(customTitle != null ? customTitle : ""));
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevelCost(int cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevelCost() {
|
||||
if (cost >= 0) {
|
||||
return cost;
|
||||
} else {
|
||||
return this.levelCost.get();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanUse(boolean bool) {
|
||||
this.canUse = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeftInput() {
|
||||
return inventory.getItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRightInput() {
|
||||
return inventory.getItem(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return inventory.getItem(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftInput(ItemStack item) {
|
||||
inventory.setItem(0, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightInput(ItemStack item) {
|
||||
inventory.setItem(1, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack item) {
|
||||
inventory.setItem(2, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
|
||||
// Counter stuff that the game uses to keep track of inventories
|
||||
int id = entity.nextContainerCounter();
|
||||
|
||||
// Send the packet
|
||||
entity.playerConnection.sendPacket(new PacketPlayOutOpenWindow(id, Containers.ANVIL, new ChatMessage(customTitle != null ? customTitle : "")));
|
||||
|
||||
// Set their active container to this anvil
|
||||
entity.activeContainer = this;
|
||||
|
||||
try {
|
||||
// Set their active container window id to that counter stuff
|
||||
mc_Container_windowId.set(this, id);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Create Error", ex);
|
||||
}
|
||||
|
||||
// Add the slot listener
|
||||
entity.activeContainer.addSlotListener(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.songoda.core.nms.v1_16_R1.nbt;
|
||||
|
||||
import com.songoda.core.nms.nbt.NBTCompound;
|
||||
import com.songoda.core.nms.nbt.NBTObject;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NBTCompoundImpl implements NBTCompound {
|
||||
|
||||
protected NBTTagCompound compound;
|
||||
|
||||
protected NBTCompoundImpl(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
public NBTCompoundImpl() {
|
||||
this.compound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, String s) {
|
||||
compound.setString(tag, s);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, boolean b) {
|
||||
compound.setBoolean(tag, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, int i) {
|
||||
compound.setInt(tag, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, double i) {
|
||||
compound.setDouble(tag, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, long l) {
|
||||
compound.setLong(tag, l);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, short s) {
|
||||
compound.setShort(tag, s);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, byte b) {
|
||||
compound.setByte(tag, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound remove(String tag) {
|
||||
compound.remove(tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String tag) {
|
||||
return compound.hasKey(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTObject getNBTObject(String tag) {
|
||||
return new NBTObjectImpl(compound, tag);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.songoda.core.nms.v1_16_R1.nbt;
|
||||
|
||||
import com.songoda.core.nms.nbt.NBTCompound;
|
||||
import com.songoda.core.nms.nbt.NBTCore;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class NBTCoreImpl implements NBTCore {
|
||||
|
||||
@Override
|
||||
public NBTItem of(ItemStack item) {
|
||||
return new NBTItemImpl(CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound newCompound() {
|
||||
return new NBTCompoundImpl();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.songoda.core.nms.v1_16_R1.nbt;
|
||||
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
|
||||
|
||||
private net.minecraft.server.v1_16_R1.ItemStack nmsItem;
|
||||
|
||||
public NBTItemImpl(net.minecraft.server.v1_16_R1.ItemStack nmsItem) {
|
||||
super(nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
|
||||
this.nmsItem = nmsItem;
|
||||
}
|
||||
|
||||
public ItemStack finish() {
|
||||
return CraftItemStack.asBukkitCopy(nmsItem);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.songoda.core.nms.v1_16_R1.nbt;
|
||||
|
||||
import com.songoda.core.nms.nbt.NBTObject;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
|
||||
public class NBTObjectImpl implements NBTObject {
|
||||
|
||||
private final NBTTagCompound compound;
|
||||
private final String tag;
|
||||
|
||||
public NBTObjectImpl(NBTTagCompound compound, String tag) {
|
||||
this.compound = compound;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
return compound.getString(tag);
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return compound.getBoolean(tag);
|
||||
}
|
||||
|
||||
public int asInt() {
|
||||
return compound.getInt(tag);
|
||||
}
|
||||
|
||||
public double asDouble() {
|
||||
return compound.getDouble(tag);
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
return compound.getLong(tag);
|
||||
}
|
||||
|
||||
public short asShort() {
|
||||
return compound.getShort(tag);
|
||||
}
|
||||
|
||||
public byte asByte() {
|
||||
return compound.getByte(tag);
|
||||
}
|
||||
|
||||
}
|
3
pom.xml
3
pom.xml
@ -21,6 +21,7 @@
|
||||
<module>NMS/NMS-v1_13_R2</module>
|
||||
<module>NMS/NMS-v1_14_R1</module>
|
||||
<module>NMS/NMS-v1_15_R1</module>
|
||||
<module>NMS/NMS-v1_16_R1</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
@ -62,7 +63,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
Loading…
Reference in New Issue
Block a user