Merge branch 'development'

This commit is contained in:
Brianna 2021-06-12 20:16:12 -05:00
commit 251b284d17
121 changed files with 3113 additions and 379 deletions

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../</relativePath>
</parent>

View File

@ -0,0 +1,75 @@
package com.songoda.core.compatibility;
public enum ClassMapping {
BIOME_BASE("world.level.biome", "BiomeBase"),
BIOME_STORAGE("world.level.chunk", "BiomeStorage"),
BLOCK("level.block", "BlockPosition"),
BLOCK_BASE("world.level.block.state", "BlockBase"),
BLOCK_BUTTON_ABSTRACT("world.level.block", "BlockButtonAbstract"),
BLOCK_PRESSURE_PLATE_ABSTRACT("world.level.block", "BlockPressurePlateAbstract"),
BLOCK_LEVER("world.level.block", "BlockLever"),
BLOCKS("world.level.block", "Blocks"),
BLOCK_POSITION("core", "BlockPosition"),
CHAT_MESSAGE_TYPE("network.chat", "ChatMessageType"),
CHUNK("world.level.chunk", "Chunk"),
ENTITY("world.entity", "Entity"),
ENTITY_INSENTIENT("world.entity", "EntityInsentient"),
ENTITY_PLAYER("server.level", "EntityPlayer"),
I_BLOCK_DATA("world.level.block.state", "IBlockData"),
I_CHAT_BASE_COMPONENT("network.chat", "IChatBaseComponent"),
I_REGISTRY("core", "IRegistry"),
ITEM("world.item", "Item"),
ITEM_STACK("world.item", "ItemStack"),
LEVEL_ENTITY_GETTER("level.entity", "LevelEntityGetter"),
MINECRAFT_SERVER("server", "MinecraftServer"),
NBT_TAG_COMPOUND("nbt", "NBTTagCompound"),
NBT_TAG_LIST("nbt", "NBTTagList"),
NBT_BASE("nbt", "NBTBase"),
PERSISTENT_ENTITY_SECTION_MANAGER("world.level.entity", "PersistentEntitySectionManager"),
PACKET("network.protocol", "Packet"),
PACKET_PLAY_OUT_CHAT("network.protocol.game", "PacketPlayOutChat"),
PACKET_PLAY_OUT_WORLD_BORDER("PacketPlayOutWorldBorder"), // Removed in 1.17
PLAYER_CONNECTION("server.network", "PlayerConnection"),
WORLD("world.level", "World"),
WORLD_BORDER("world.level.border", "WorldBorder"),
WORLD_SERVER("server.level", "WorldServer"),
CRAFT_BLOCK("block", "CraftBlock"),
CRAFT_BLOCK_DATA("block.data", "CraftBlockData"),
CRAFT_CHUNK("craftChunk"),
CRAFT_ENTITY("entity", "CraftEntity"),
CRAFT_PLAYER("entity", "CraftPlayer"),
CRAFT_WORLD("CraftWorld");
private final String packageName;
private final String className;
ClassMapping(String packageName) {
this(null, packageName);
}
ClassMapping(String packageName, String className) {
this.packageName = packageName;
this.className = className;
}
public Class<?> getClazz() {
return getClazz(null);
}
public Class<?> getClazz(String sub) {
try {
String name = sub == null ? className : className + "$" + sub;
if (className.startsWith("Craft"))
return Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString()
+ (packageName == null ? "" : "." + packageName) + "." + name);
return Class.forName("net.minecraft." + (
ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17) && packageName != null
? packageName : "server." + ServerVersion.getServerVersionString()) + "." + name);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -98,6 +98,8 @@ public class ClientVersion {
case 753:
case 754:
return ServerVersion.V1_16;
case 755:
return ServerVersion.V1_17;
}
return version > 498 ? ServerVersion.getServerVersion() : ServerVersion.UNKNOWN;
}

View File

@ -25,6 +25,10 @@ import java.util.Set;
*/
public enum CompatibleBiome {
/* 1.17 */
DRIPSTONE_CAVES(ServerVersion.V1_17),
LUSH_CAVES(ServerVersion.V1_17),
/* 1.16 */
SOUL_SAND_VALLEY(ServerVersion.V1_16),
CRIMSON_FOREST(ServerVersion.V1_16),
@ -127,12 +131,12 @@ public enum CompatibleBiome {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_15)) {
try {
Class<?> classBiomeBase = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".BiomeBase"),
classCraftChunk = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".CraftChunk"),
classCraftBlock = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".block.CraftBlock"),
classChunk = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".Chunk"),
classBiomeStorage = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".BiomeStorage"),
classIRegistry = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".IRegistry");
Class<?> classBiomeBase = ClassMapping.BIOME_BASE.getClazz(),
classCraftChunk = ClassMapping.CRAFT_CHUNK.getClazz(),
classCraftBlock = ClassMapping.CRAFT_BLOCK.getClazz(),
classChunk = ClassMapping.CHUNK.getClazz(),
classBiomeStorage = ClassMapping.BIOME_STORAGE.getClazz(),
classIRegistry = ClassMapping.I_REGISTRY.getClazz();
methodBiomeToBiomeBase = isAbove1_16_R1 ? classCraftBlock.getMethod("biomeToBiomeBase", classIRegistry, Biome.class)
: classCraftBlock.getMethod("biomeToBiomeBase", Biome.class);
@ -149,7 +153,7 @@ public enum CompatibleBiome {
fieldStorageRegistry = classBiomeStorage.getDeclaredField("g");
}
fieldStorageRegistry.setAccessible(true);
} catch (NoSuchMethodException | NoSuchFieldException | ClassNotFoundException e) {
} catch (NoSuchMethodException | NoSuchFieldException e) {
e.printStackTrace();
}
}

View File

@ -1,9 +1,6 @@
package com.songoda.core.compatibility;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerItemBreakEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
@ -99,56 +96,4 @@ public enum CompatibleHand {
else
player.getInventory().setItemInOffHand(item);
}
private static Class<?> cb_CraftPlayer;
private static Method getHandle, playBreak, asNMSCopy;
/**
* Damage the selected item
*
* @param player the player who's item you want to damage
* @param damage the amount of damage to apply to the item
*/
public void damageItem(Player player, short damage) {
if (player.getGameMode() == GameMode.CREATIVE) return;
if (cb_CraftPlayer == null) {
try {
cb_CraftPlayer = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".entity.CraftPlayer");
Class<?> mc_EntityLiving = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".EntityLiving");
Class<?> cb_ItemStack = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".inventory.CraftItemStack");
Class<?> mc_ItemStack = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".ItemStack");
getHandle = cb_CraftPlayer.getMethod("getHandle");
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
playBreak = mc_EntityLiving.getDeclaredMethod("a", mc_ItemStack, int.class); //Consistent from 1.16-1.13
else
playBreak = mc_EntityLiving.getDeclaredMethod("b", mc_ItemStack); //Consistent from 1.12-1.8
playBreak.setAccessible(true);
asNMSCopy = cb_ItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
}
}
ItemStack item = getItem(player);
short newDurability = (short) (item.getDurability() + damage);
if (newDurability >= item.getType().getMaxDurability()) {
PlayerItemBreakEvent breakEvent = new PlayerItemBreakEvent(player, item);
Bukkit.getServer().getPluginManager().callEvent(breakEvent);
try {
if (playBreak.getParameterCount() == 2)
playBreak.invoke(getHandle.invoke(cb_CraftPlayer.cast(player)), asNMSCopy.invoke(null, item), 1);
else
playBreak.invoke(getHandle.invoke(cb_CraftPlayer.cast(player)), asNMSCopy.invoke(item));
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
setItem(player, null);
return;
}
item.setDurability(newDurability);
}
}

View File

@ -33,9 +33,160 @@ public enum CompatibleMaterial {
JUNGLE_DOOR_ITEM(429),
ACACIA_DOOR_ITEM(430),
DARK_OAK_DOOR_ITEM(431),
*/
/* 1.17 */
AMETHYST_BLOCK(),
AMETHYST_CLUSTER(),
AMETHYST_SHARD(),
AXOLOTL_BUCKET(),
AXOLOTL_SPAWN_EGG(),
AZALEA(),
AZALEA_LEAVES(),
BIG_DRIPLEAF(),
BIG_DRIPLEAF_STEM(),
BLACK_CANDLE(),
BLACK_CANDLE_CAKE(),
BLUE_CANDLE(),
BLUE_CANDLE_CAKE(),
BROWN_CANDLE(),
BROWN_CANDLE_CAKE(),
BUDDING_AMETHYST(),
BUNDLE(),
CALCITE(),
CANDLE(),
CANDLE_CAKE(),
CAVE_VINES(),
CAVE_VINES_PLANT(),
CHISELED_DEEPSLATE(),
COBBLED_DEEPSLATE(),
COBBLED_DEEPSLATE_SLAB(),
COBBLED_DEEPSLATE_STAIRS(),
COBBLED_DEEPSLATE_WALL(),
COPPER_BLOCK(),
COPPER_INGOT(),
COPPER_ORE(),
CRACKED_DEEPSLATE_BRICKS(),
CRACKED_DEEPSLATE_TILES(),
CUT_COPPER(),
CUT_COPPER_SLAB(),
CUT_COPPER_STAIRS(),
CYAN_CANDLE(),
CYAN_CANDLE_CAKE(),
DEEPSLATE(),
DEEPSLATE_BRICKS(),
DEEPSLATE_BRICK_SLAB(),
DEEPSLATE_BRICK_STAIRS(),
DEEPSLATE_BRICK_WALL(),
DEEPSLATE_COAL_ORE(),
DEEPSLATE_COPPER_ORE(),
DEEPSLATE_DIAMOND_ORE(),
DEEPSLATE_EMERALD_ORE(),
DEEPSLATE_GOLD_ORE(),
DEEPSLATE_IRON_ORE(),
DEEPSLATE_LAPIS_ORE(),
DEEPSLATE_REDSTONE_ORE(),
DEEPSLATE_TILES(),
DEEPSLATE_TILE_SLAB(),
DEEPSLATE_TILE_STAIRS(),
DEEPSLATE_TILE_WALL(),
DRIPSTONE_BLOCK(),
EXPOSED_COPPER(),
EXPOSED_CUT_COPPER(),
EXPOSED_CUT_COPPER_SLAB(),
EXPOSED_CUT_COPPER_STAIRS(),
FLOWERING_AZALEA(),
FLOWERING_AZALEA_LEAVES(),
GLOW_BERRIES(),
GLOW_INK_SAC(),
GLOW_ITEM_FRAME(),
GLOW_LICHEN(),
GLOW_SQUID_SPAWN_EGG(),
GOAT_SPAWN_EGG(),
GRAY_CANDLE(),
GRAY_CANDLE_CAKE(),
GREEN_CANDLE(),
GREEN_CANDLE_CAKE(),
HANGING_ROOTS(),
INFESTED_DEEPSLATE(),
LARGE_AMETHYST_BUD(),
LAVA_CAULDRON(),
LIGHT(),
LIGHTNING_ROD(),
LIGHT_BLUE_CANDLE(),
LIGHT_BLUE_CANDLE_CAKE(),
LIGHT_GRAY_CANDLE(),
LIGHT_GRAY_CANDLE_CAKE(),
LIME_CANDLE(),
LIME_CANDLE_CAKE(),
MAGENTA_CANDLE(),
MAGENTA_CANDLE_CAKE(),
MEDIUM_AMETHYST_BUD(),
MOSS_BLOCK(),
MOSS_CARPET(),
ORANGE_CANDLE(),
ORANGE_CANDLE_CAKE(),
OXIDIZED_COPPER(),
OXIDIZED_CUT_COPPER(),
OXIDIZED_CUT_COPPER_SLAB(),
OXIDIZED_CUT_COPPER_STAIRS(),
PINK_CANDLE(),
PINK_CANDLE_CAKE(),
POINTED_DRIPSTONE(),
POLISHED_DEEPSLATE(),
POLISHED_DEEPSLATE_SLAB(),
POLISHED_DEEPSLATE_STAIRS(),
POLISHED_DEEPSLATE_WALL(),
POTTED_AZALEA_BUSH(),
POTTED_FLOWERING_AZALEA_BUSH(),
POWDER_SNOW(),
POWDER_SNOW_BUCKET(),
POWDER_SNOW_CAULDRON(),
PURPLE_CANDLE(),
PURPLE_CANDLE_CAKE(),
RAW_COPPER(),
RAW_COPPER_BLOCK(),
RAW_GOLD(),
RAW_GOLD_BLOCK(),
RAW_IRON(),
RAW_IRON_BLOCK(),
RED_CANDLE(),
RED_CANDLE_CAKE(),
ROOTED_DIRT(),
SCULK_SENSOR(),
SMALL_AMETHYST_BUD(),
SMALL_DRIPLEAF(),
SMOOTH_BASALT(),
SPORE_BLOSSOM(),
SPYGLASS(),
TINTED_GLASS(),
TUFF(),
WATER_CAULDRON(),
WAXED_COPPER_BLOCK(),
WAXED_CUT_COPPER(),
WAXED_CUT_COPPER_SLAB(),
WAXED_CUT_COPPER_STAIRS(),
WAXED_EXPOSED_COPPER(),
WAXED_EXPOSED_CUT_COPPER(),
WAXED_EXPOSED_CUT_COPPER_SLAB(),
WAXED_EXPOSED_CUT_COPPER_STAIRS(),
WAXED_OXIDIZED_COPPER(),
WAXED_OXIDIZED_CUT_COPPER(),
WAXED_OXIDIZED_CUT_COPPER_SLAB(),
WAXED_OXIDIZED_CUT_COPPER_STAIRS(),
WAXED_WEATHERED_COPPER(),
WAXED_WEATHERED_CUT_COPPER(),
WAXED_WEATHERED_CUT_COPPER_SLAB(),
WAXED_WEATHERED_CUT_COPPER_STAIRS(),
WEATHERED_COPPER(),
WEATHERED_CUT_COPPER(),
WEATHERED_CUT_COPPER_SLAB(),
WEATHERED_CUT_COPPER_STAIRS(),
WHITE_CANDLE(),
WHITE_CANDLE_CAKE(),
YELLOW_CANDLE(),
YELLOW_CANDLE_CAKE(),
/* 1.16 */
ANCIENT_DEBRIS(),
BASALT(),
@ -527,7 +678,7 @@ public enum CompatibleMaterial {
GRANITE_WALL,
GRASS("LONG_GRASS", (byte) 1),
GRASS_BLOCK("GRASS"),
GRASS_PATH,
GRASS_PATH("GRASS_PATH"),
GRAVEL,
GRAY_BANNER("BANNER", (byte) 8),
GRAY_BED("BED", (byte) 7),
@ -1940,21 +2091,31 @@ public enum CompatibleMaterial {
case KELP:
return DRIED_KELP;
case IRON_ORE:
case DEEPSLATE_IRON_ORE:
return IRON_INGOT;
case GOLD_ORE:
case DEEPSLATE_GOLD_ORE:
return GOLD_INGOT;
case DIAMOND_ORE:
case DEEPSLATE_DIAMOND_ORE:
return DIAMOND;
case LAPIS_ORE:
case DEEPSLATE_LAPIS_ORE:
return LAPIS_LAZULI;
case REDSTONE_ORE:
case DEEPSLATE_REDSTONE_ORE:
return REDSTONE;
case COAL_ORE:
case DEEPSLATE_COAL_ORE:
return COAL;
case EMERALD_ORE:
case DEEPSLATE_EMERALD_ORE:
return EMERALD;
case NETHER_QUARTZ_ORE:
return QUARTZ;
case COPPER_ORE:
case DEEPSLATE_COPPER_ORE:
return COPPER_INGOT;
case SAND:
case RED_SAND:
return GLASS;

View File

@ -15,7 +15,7 @@ import java.util.stream.Stream;
public class CompatibleParticleHandler {
public static enum ParticleType {
EXPLOSION_NORMAL(),
EXPLOSION_NORMAL,
EXPLOSION_LARGE,
EXPLOSION_HUGE,
FIREWORKS_SPARK,
@ -100,6 +100,25 @@ public class CompatibleParticleHandler {
REVERSE_PORTAL(ServerVersion.V1_16, "DRIP_WATER"),
WHITE_ASH(ServerVersion.V1_16, "DRIP_WATER"),
/// End 1.16 ///
// ToDo: Someone needs to make better compatible fall backs.
LIGHT(ServerVersion.V1_17, "DRIP_WATER"),
DUST_COLOR_TRANSITION(ServerVersion.V1_17, "DRIP_WATER"),
VIBRATION(ServerVersion.V1_17, "DRIP_WATER"),
FALLING_SPORE_BLOSSOM(ServerVersion.V1_17, "DRIP_WATER"),
SPORE_BLOSSOM_AIR(ServerVersion.V1_17, "DRIP_WATER"),
SMALL_FLAME(ServerVersion.V1_17, "DRIP_WATER"),
SNOWFLAKE(ServerVersion.V1_17, "DRIP_WATER"),
DRIPPING_DRIPSTONE_LAVA(ServerVersion.V1_17, "DRIP_WATER"),
FALLING_DRIPSTONE_LAVA(ServerVersion.V1_17, "DRIP_WATER"),
DRIPPING_DRIPSTONE_WATER(ServerVersion.V1_17, "DRIP_WATER"),
FALLING_DRIPSTONE_WATER(ServerVersion.V1_17, "DRIP_WATER"),
GLOW_SQUID_INK(ServerVersion.V1_17, "DRIP_WATER"),
GLOW(ServerVersion.V1_17, "DRIP_WATER"),
WAX_ON(ServerVersion.V1_17, "DRIP_WATER"),
WAX_OFF(ServerVersion.V1_17, "DRIP_WATER"),
ELECTRIC_SPARK(ServerVersion.V1_17, "DRIP_WATER"),
SCRAPE(ServerVersion.V1_17, "DRIP_WATER"),
/// End 1.17 ///
;
final boolean compatibilityMode;

View File

@ -24,6 +24,215 @@ 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.17 */
// TODO: add similar sounds for older versions
BLOCK_AMETHYST_BLOCK_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_BLOCK_CHIME(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_BLOCK_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_BLOCK_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_BLOCK_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_BLOCK_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_CLUSTER_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_CLUSTER_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_CLUSTER_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_CLUSTER_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_AMETHYST_CLUSTER_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_LEAVES_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_LEAVES_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_LEAVES_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_LEAVES_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_LEAVES_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_AZALEA_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_TILT_DOWN(ServerVersion.V1_17, v(null, true)),
BLOCK_BIG_DRIPLEAF_TILT_UP(ServerVersion.V1_17, v(null, true)),
BLOCK_CAKE_ADD_CANDLE(ServerVersion.V1_17, v(null, true)),
BLOCK_CALCITE_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_CALCITE_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_CALCITE_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_CALCITE_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_CALCITE_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_AMBIENT(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_EXTINGUISH(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_CANDLE_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_CAVE_VINES_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_CAVE_VINES_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_CAVE_VINES_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_CAVE_VINES_PICK_BERRIES(ServerVersion.V1_17, v(null, true)),
BLOCK_CAVE_VINES_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_CAVE_VINES_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_COPPER_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_COPPER_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_COPPER_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_COPPER_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_COPPER_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_BRICKS_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_BRICKS_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_BRICKS_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_BRICKS_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_BRICKS_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_TILES_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_TILES_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_TILES_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_TILES_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_DEEPSLATE_TILES_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_DRIPSTONE_BLOCK_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_DRIPSTONE_BLOCK_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_DRIPSTONE_BLOCK_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_DRIPSTONE_BLOCK_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_DRIPSTONE_BLOCK_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_FLOWERING_AZALEA_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_FLOWERING_AZALEA_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_FLOWERING_AZALEA_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_FLOWERING_AZALEA_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_FLOWERING_AZALEA_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_HANGING_ROOTS_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_HANGING_ROOTS_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_HANGING_ROOTS_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_HANGING_ROOTS_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_HANGING_ROOTS_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_LARGE_AMETHYST_BUD_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_LARGE_AMETHYST_BUD_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_MEDIUM_AMETHYST_BUD_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_MEDIUM_AMETHYST_BUD_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_CARPET_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_CARPET_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_CARPET_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_CARPET_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_CARPET_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_MOSS_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_DRIP_LAVA(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_DRIP_LAVA_INTO_CAULDRON(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_DRIP_WATER(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_DRIP_WATER_INTO_CAULDRON(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_LAND(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_POINTED_DRIPSTONE_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_POLISHED_DEEPSLATE_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_POLISHED_DEEPSLATE_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_POLISHED_DEEPSLATE_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_POLISHED_DEEPSLATE_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_POLISHED_DEEPSLATE_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_POWDER_SNOW_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_POWDER_SNOW_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_POWDER_SNOW_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_POWDER_SNOW_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_POWDER_SNOW_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_ROOTED_DIRT_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_ROOTED_DIRT_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_ROOTED_DIRT_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_ROOTED_DIRT_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_ROOTED_DIRT_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_CLICKING(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_CLICKING_STOP(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_SCULK_SENSOR_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_AMETHYST_BUD_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_AMETHYST_BUD_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_DRIPLEAF_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_DRIPLEAF_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_DRIPLEAF_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_DRIPLEAF_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_SMALL_DRIPLEAF_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_SPORE_BLOSSOM_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_SPORE_BLOSSOM_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_SPORE_BLOSSOM_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_SPORE_BLOSSOM_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_SPORE_BLOSSOM_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES(ServerVersion.V1_17, v("ITEM_SWEET_BERRIES_PICK_FROM_BUSH")),
BLOCK_TUFF_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_TUFF_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_TUFF_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_TUFF_PLACE(ServerVersion.V1_17, v(null, true)),
BLOCK_TUFF_STEP(ServerVersion.V1_17, v(null, true)),
BLOCK_VINE_BREAK(ServerVersion.V1_17, v(null, true)),
BLOCK_VINE_FALL(ServerVersion.V1_17, v(null, true)),
BLOCK_VINE_HIT(ServerVersion.V1_17, v(null, true)),
BLOCK_VINE_PLACE(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_ATTACK(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_DEATH(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_HURT(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_IDLE_AIR(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_IDLE_WATER(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_SPLASH(ServerVersion.V1_17, v(null, true)),
ENTITY_AXOLOTL_SWIM(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_ITEM_FRAME_ADD_ITEM(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_ITEM_FRAME_BREAK(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_ITEM_FRAME_PLACE(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_ITEM_FRAME_REMOVE_ITEM(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_ITEM_FRAME_ROTATE_ITEM(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_SQUID_AMBIENT(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_SQUID_DEATH(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_SQUID_HURT(ServerVersion.V1_17, v(null, true)),
ENTITY_GLOW_SQUID_SQUIRT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_AMBIENT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_DEATH(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_EAT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_HURT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_LONG_JUMP(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_MILK(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_PREPARE_RAM(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_RAM_IMPACT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_AMBIENT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_DEATH(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_EAT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_HURT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_LONG_JUMP(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_MILK(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_PREPARE_RAM(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_SCREAMING_RAM_IMPACT(ServerVersion.V1_17, v(null, true)),
ENTITY_GOAT_STEP(ServerVersion.V1_17, v(null, true)),
ENTITY_MINECART_INSIDE_UNDERWATER(ServerVersion.V1_17, v(null, true)),
ENTITY_PARROT_IMITATE_PIGLIN_BRUTE(ServerVersion.V1_17, v(null, true)),
ENTITY_PIGLIN_BRUTE_AMBIENT(ServerVersion.V1_17, v(null, true)),
ENTITY_PIGLIN_BRUTE_ANGRY(ServerVersion.V1_17, v(null, true)),
ENTITY_PIGLIN_BRUTE_CONVERTED_TO_ZOMBIFIED(ServerVersion.V1_17, v(null, true)),
ENTITY_PIGLIN_BRUTE_DEATH(ServerVersion.V1_17, v(null, true)),
ENTITY_PIGLIN_BRUTE_HURT(ServerVersion.V1_17, v(null, true)),
ENTITY_PIGLIN_BRUTE_STEP(ServerVersion.V1_17, v(null, true)),
ENTITY_PLAYER_HURT_FREEZE(ServerVersion.V1_17, v(null, true)),
ENTITY_SKELETON_CONVERTED_TO_STRAY(ServerVersion.V1_17, v(null, true)),
ITEM_AXE_SCRAPE(ServerVersion.V1_17, v(null, true)),
ITEM_AXE_WAX_OFF(ServerVersion.V1_17, v(null, true)),
ITEM_BONE_MEAL_USE(ServerVersion.V1_17, v(null, true)),
ITEM_BUCKET_EMPTY_AXOLOTL(ServerVersion.V1_17, v(null, true)),
ITEM_BUCKET_EMPTY_POWDER_SNOW(ServerVersion.V1_17, v(null, true)),
ITEM_BUCKET_FILL_AXOLOTL(ServerVersion.V1_17, v(null, true)),
ITEM_BUCKET_FILL_POWDER_SNOW(ServerVersion.V1_17, v(null, true)),
ITEM_GLOW_INK_SAC_USE(ServerVersion.V1_17, v(null, true)),
ITEM_HONEYCOMB_WAX_ON(ServerVersion.V1_17, v(null, true)),
ITEM_INK_SAC_USE(ServerVersion.V1_17, v(null, true)),
ITEM_SPYGLASS_STOP_USING(ServerVersion.V1_17, v(null, true)),
ITEM_SPYGLASS_USE(ServerVersion.V1_17, v(null, true)),
ITEM_DYE_USE(ServerVersion.V1_17, v(null, true)),
/* 1.16 */
// TODO: add similar sounds for older versions
AMBIENT_BASALT_DELTAS_ADDITIONS(ServerVersion.V1_16, v(null, true)),
@ -972,7 +1181,6 @@ public enum CompatibleSound {
ITEM_SHIELD_BLOCK,
ITEM_SHIELD_BREAK,
ITEM_SHOVEL_FLATTEN,
ITEM_SWEET_BERRIES_PICK_FROM_BUSH,
ITEM_TOTEM_USE,
ITEM_TRIDENT_HIT,
ITEM_TRIDENT_HIT_GROUND,

View File

@ -45,7 +45,6 @@ public class EntityNamespace {
put("witherboss", "wither");
put("mushroomcow", "mooshroom");
put("snowman", "snow_golem");
put("snowman", "snow_golem");
put("ozelot", "ocelot");
put("villagergolem", "iron_golem");
put("villager_golem", "iron_golem");

View File

@ -14,110 +14,263 @@ import java.util.Map;
*/
public enum LegacyMaterialAnalouge {
/* 1.17 */
// ToDo: Improve legal materials.
AMETHYST_BLOCK(ServerVersion.V1_17, "STONE"),
AMETHYST_CLUSTER(ServerVersion.V1_17, "STONE"),
AMETHYST_SHARD(ServerVersion.V1_17, "STONE"),
AXOLOTL_BUCKET(ServerVersion.V1_17, "STONE"),
AXOLOTL_SPAWN_EGG(ServerVersion.V1_17, "STONE"),
AZALEA(ServerVersion.V1_17, "STONE"),
AZALEA_LEAVES(ServerVersion.V1_17, "STONE"),
BIG_DRIPLEAF(ServerVersion.V1_17, "STONE"),
BIG_DRIPLEAF_STEM(ServerVersion.V1_17, "STONE"),
BLACK_CANDLE(ServerVersion.V1_17, "STONE"),
BLACK_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
BLUE_CANDLE(ServerVersion.V1_17, "STONE"),
BLUE_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
BROWN_CANDLE(ServerVersion.V1_17, "STONE"),
BROWN_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
BUDDING_AMETHYST(ServerVersion.V1_17, "STONE"),
BUNDLE(ServerVersion.V1_17, "STONE"),
CALCITE(ServerVersion.V1_17, "STONE"),
CANDLE(ServerVersion.V1_17, "STONE"),
CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
CAVE_VINES(ServerVersion.V1_17, "STONE"),
CAVE_VINES_PLANT(ServerVersion.V1_17, "STONE"),
CHISELED_DEEPSLATE(ServerVersion.V1_17, "STONE"),
COBBLED_DEEPSLATE(ServerVersion.V1_17, "STONE"),
COBBLED_DEEPSLATE_SLAB(ServerVersion.V1_17, "STONE"),
COBBLED_DEEPSLATE_STAIRS(ServerVersion.V1_17, "STONE"),
COBBLED_DEEPSLATE_WALL(ServerVersion.V1_17, "STONE"),
COPPER_BLOCK(ServerVersion.V1_17, "STONE"),
COPPER_INGOT(ServerVersion.V1_17, "STONE"),
COPPER_ORE(ServerVersion.V1_17, "STONE"),
CRACKED_DEEPSLATE_BRICKS(ServerVersion.V1_17, "STONE"),
CRACKED_DEEPSLATE_TILES(ServerVersion.V1_17, "STONE"),
CUT_COPPER(ServerVersion.V1_17, "STONE"),
CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
CYAN_CANDLE(ServerVersion.V1_17, "STONE"),
CYAN_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
DEEPSLATE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_BRICKS(ServerVersion.V1_17, "STONE"),
DEEPSLATE_BRICK_SLAB(ServerVersion.V1_17, "STONE"),
DEEPSLATE_BRICK_STAIRS(ServerVersion.V1_17, "STONE"),
DEEPSLATE_BRICK_WALL(ServerVersion.V1_17, "STONE"),
DEEPSLATE_COAL_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_COPPER_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_DIAMOND_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_EMERALD_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_GOLD_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_IRON_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_LAPIS_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_REDSTONE_ORE(ServerVersion.V1_17, "STONE"),
DEEPSLATE_TILES(ServerVersion.V1_17, "STONE"),
DEEPSLATE_TILE_SLAB(ServerVersion.V1_17, "STONE"),
DEEPSLATE_TILE_STAIRS(ServerVersion.V1_17, "STONE"),
DEEPSLATE_TILE_WALL(ServerVersion.V1_17, "STONE"),
DRIPSTONE_BLOCK(ServerVersion.V1_17, "STONE"),
EXPOSED_COPPER(ServerVersion.V1_17, "STONE"),
EXPOSED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
EXPOSED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
EXPOSED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
FLOWERING_AZALEA(ServerVersion.V1_17, "STONE"),
FLOWERING_AZALEA_LEAVES(ServerVersion.V1_17, "STONE"),
GLOW_BERRIES(ServerVersion.V1_17, "STONE"),
GLOW_INK_SAC(ServerVersion.V1_17, "STONE"),
GLOW_ITEM_FRAME(ServerVersion.V1_17, "STONE"),
GLOW_LICHEN(ServerVersion.V1_17, "STONE"),
GLOW_SQUID_SPAWN_EGG(ServerVersion.V1_17, "STONE"),
GOAT_SPAWN_EGG(ServerVersion.V1_17, "STONE"),
GRAY_CANDLE(ServerVersion.V1_17, "STONE"),
GRAY_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
GREEN_CANDLE(ServerVersion.V1_17, "STONE"),
GREEN_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
HANGING_ROOTS(ServerVersion.V1_17, "STONE"),
INFESTED_DEEPSLATE(ServerVersion.V1_17, "STONE"),
LARGE_AMETHYST_BUD(ServerVersion.V1_17, "STONE"),
LAVA_CAULDRON(ServerVersion.V1_17, "STONE"),
LIGHT(ServerVersion.V1_17, "STONE"),
LIGHTNING_ROD(ServerVersion.V1_17, "STONE"),
LIGHT_BLUE_CANDLE(ServerVersion.V1_17, "STONE"),
LIGHT_BLUE_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
LIGHT_GRAY_CANDLE(ServerVersion.V1_17, "STONE"),
LIGHT_GRAY_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
LIME_CANDLE(ServerVersion.V1_17, "STONE"),
LIME_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
MAGENTA_CANDLE(ServerVersion.V1_17, "STONE"),
MAGENTA_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
MEDIUM_AMETHYST_BUD(ServerVersion.V1_17, "STONE"),
MOSS_BLOCK(ServerVersion.V1_17, "STONE"),
MOSS_CARPET(ServerVersion.V1_17, "STONE"),
ORANGE_CANDLE(ServerVersion.V1_17, "STONE"),
ORANGE_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
OXIDIZED_COPPER(ServerVersion.V1_17, "STONE"),
OXIDIZED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
OXIDIZED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
OXIDIZED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
PINK_CANDLE(ServerVersion.V1_17, "STONE"),
PINK_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
POINTED_DRIPSTONE(ServerVersion.V1_17, "STONE"),
POLISHED_DEEPSLATE(ServerVersion.V1_17, "STONE"),
POLISHED_DEEPSLATE_SLAB(ServerVersion.V1_17, "STONE"),
POLISHED_DEEPSLATE_STAIRS(ServerVersion.V1_17, "STONE"),
POLISHED_DEEPSLATE_WALL(ServerVersion.V1_17, "STONE"),
POTTED_AZALEA_BUSH(ServerVersion.V1_17, "STONE"),
POTTED_FLOWERING_AZALEA_BUSH(ServerVersion.V1_17, "STONE"),
POWDER_SNOW(ServerVersion.V1_17, "STONE"),
POWDER_SNOW_BUCKET(ServerVersion.V1_17, "STONE"),
POWDER_SNOW_CAULDRON(ServerVersion.V1_17, "STONE"),
PURPLE_CANDLE(ServerVersion.V1_17, "STONE"),
PURPLE_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
RAW_COPPER(ServerVersion.V1_17, "STONE"),
RAW_COPPER_BLOCK(ServerVersion.V1_17, "STONE"),
RAW_GOLD(ServerVersion.V1_17, "STONE"),
RAW_GOLD_BLOCK(ServerVersion.V1_17, "STONE"),
RAW_IRON(ServerVersion.V1_17, "STONE"),
RAW_IRON_BLOCK(ServerVersion.V1_17, "STONE"),
RED_CANDLE(ServerVersion.V1_17, "STONE"),
RED_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
ROOTED_DIRT(ServerVersion.V1_17, "STONE"),
SCULK_SENSOR(ServerVersion.V1_17, "STONE"),
SMALL_AMETHYST_BUD(ServerVersion.V1_17, "STONE"),
SMALL_DRIPLEAF(ServerVersion.V1_17, "STONE"),
SMOOTH_BASALT(ServerVersion.V1_17, "STONE"),
SPORE_BLOSSOM(ServerVersion.V1_17, "STONE"),
SPYGLASS(ServerVersion.V1_17, "STONE"),
TINTED_GLASS(ServerVersion.V1_17, "STONE"),
TUFF(ServerVersion.V1_17, "STONE"),
WATER_CAULDRON(ServerVersion.V1_17, "STONE"),
WAXED_COPPER_BLOCK(ServerVersion.V1_17, "STONE"),
WAXED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
WAXED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
WAXED_EXPOSED_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_EXPOSED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_EXPOSED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
WAXED_EXPOSED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
WAXED_OXIDIZED_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_OXIDIZED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_OXIDIZED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
WAXED_OXIDIZED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
WAXED_WEATHERED_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_WEATHERED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
WAXED_WEATHERED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
WAXED_WEATHERED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
WEATHERED_COPPER(ServerVersion.V1_17, "STONE"),
WEATHERED_CUT_COPPER(ServerVersion.V1_17, "STONE"),
WEATHERED_CUT_COPPER_SLAB(ServerVersion.V1_17, "STONE"),
WEATHERED_CUT_COPPER_STAIRS(ServerVersion.V1_17, "STONE"),
WHITE_CANDLE(ServerVersion.V1_17, "STONE"),
WHITE_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
YELLOW_CANDLE(ServerVersion.V1_17, "STONE"),
YELLOW_CANDLE_CAKE(ServerVersion.V1_17, "STONE"),
/* 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"),
ANCIENT_DEBRIES(ServerVersion.V1_16, "STONE"),
BASALT(ServerVersion.V1_16, "STONE"),
BLACKSTONE(ServerVersion.V1_16, "STONE"),
BLACKSTONE_STAIRS(ServerVersion.V1_16, "STONE"),
BLACKSTONE_WALL(ServerVersion.V1_16, "STONE"),
BLASTSTONE_SLAB(ServerVersion.V1_16, "STONE"),
CHAIN(ServerVersion.V1_16, "STONE"),
CHISELED_NETHER_BRICKS(ServerVersion.V1_16, "STONE"),
CHISELED_POLISHED_BLACKSTONE(ServerVersion.V1_16, "STONE"),
CRACKED_NETHER_BRICKS(ServerVersion.V1_16, "STONE"),
CRACKED_POLISHED_BLACKSTONE_BRICKS(ServerVersion.V1_16, "STONE"),
CRIMSON_BUTTON(ServerVersion.V1_16, "STONE"),
CRIMSON_DOOR(ServerVersion.V1_16, "STONE"),
CRIMSON_FENCE(ServerVersion.V1_16, "STONE"),
CRIMSON_FENCE_GATE(ServerVersion.V1_16, "STONE"),
CRIMSON_FUNGUS(ServerVersion.V1_16, "STONE"),
CRIMSON_HYPHAE(ServerVersion.V1_16, "STONE"),
CRIMSON_NYLIUM(ServerVersion.V1_16, "STONE"),
CRIMSON_PLANKS(ServerVersion.V1_16, "STONE"),
CRIMSON_PRESSURE_PLATE(ServerVersion.V1_16, "STONE"),
CRIMSON_ROOTS(ServerVersion.V1_16, "STONE"),
CRIMSON_SIGN(ServerVersion.V1_16, "STONE"),
CRIMSON_SLAB(ServerVersion.V1_16, "STONE"),
CRIMSON_STAIRS(ServerVersion.V1_16, "STONE"),
CRIMSON_STEM(ServerVersion.V1_16, "STONE"),
CRIMSON_TRAPDOOR(ServerVersion.V1_16, "STONE"),
CRIMSON_WALL_SIGN(ServerVersion.V1_16, "STONE"),
CRYING_OBSIDIAN(ServerVersion.V1_16, "STONE"),
GILDED_BLACKSTONE(ServerVersion.V1_16, "STONE"),
HOGLIN_SPAWN_EGG(ServerVersion.V1_16, "STONE"),
LODESTONE(ServerVersion.V1_16, "STONE"),
MUSIC_DISC_PIGSTEP(ServerVersion.V1_16, "STONE"),
NETHERITE_AXE(ServerVersion.V1_16, "STONE"),
NETHERITE_BLOCK(ServerVersion.V1_16, "STONE"),
NETHERITE_BOOTS(ServerVersion.V1_16, "STONE"),
NETHERITE_CHESTPLATE(ServerVersion.V1_16, "STONE"),
NETHERITE_HELMET(ServerVersion.V1_16, "STONE"),
NETHERITE_HOE(ServerVersion.V1_16, "STONE"),
NETHERITE_INGOT(ServerVersion.V1_16, "STONE"),
NETHERITE_LEGGINGS(ServerVersion.V1_16, "STONE"),
NETHERITE_PICKAXE(ServerVersion.V1_16, "STONE"),
NETHERITE_SCRAP(ServerVersion.V1_16, "STONE"),
NETHERITE_SHOVEL(ServerVersion.V1_16, "STONE"),
NETHERITE_SWORD(ServerVersion.V1_16, "STONE"),
NETHER_GOLD_ORE(ServerVersion.V1_16, "STONE"),
NETHER_SPROUTS(ServerVersion.V1_16, "STONE"),
PIGLIN_BANNER_PATTERN(ServerVersion.V1_16, "STONE"),
PIGLIN_SPAWN_EGG(ServerVersion.V1_16, "STONE"),
POLISHED_BASALT(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_BRICKS(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_BRICK_SLAB(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_BRICK_STAIRS(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_BRICK_WALL(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_BUTTON(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_PRESSURE_PLATE(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_SLAB(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_STAIRS(ServerVersion.V1_16, "STONE"),
POLISHED_BLACKSTONE_WALL(ServerVersion.V1_16, "STONE"),
POTTED_CRIMSON_FUNGUS(ServerVersion.V1_16, "STONE"),
POTTED_CRIMSON_ROOTS(ServerVersion.V1_16, "STONE"),
POTTED_WARPED_FUNGUS(ServerVersion.V1_16, "STONE"),
POTTED_WARPED_ROOTS(ServerVersion.V1_16, "STONE"),
QUARTZ_BRICKS(ServerVersion.V1_16, "STONE"),
RESPAWN_ANCHOR(ServerVersion.V1_16, "STONE"),
SHROOMLIGHT(ServerVersion.V1_16, "STONE"),
SOUL_CAMPFIRE(ServerVersion.V1_16, "STONE"),
SOUL_FIRE(ServerVersion.V1_16, "STONE"),
SOUL_LANTERN(ServerVersion.V1_16, "STONE"),
SOUL_SOIL(ServerVersion.V1_16, "STONE"),
SOUL_TORCH(ServerVersion.V1_16, "STONE"),
SOUL_WALL_TORCH(ServerVersion.V1_16, "STONE"),
STRIDER_SPAWN_EGG(ServerVersion.V1_16, "STONE"),
STRIPPED_CRIMSON_HYPHAE(ServerVersion.V1_16, "STONE"),
STRIPPED_CRIMSON_STEM(ServerVersion.V1_16, "STONE"),
STRIPPED_WARPED_HYPHAE(ServerVersion.V1_16, "STONE"),
STRIPPED_WARPED_STEM(ServerVersion.V1_16, "STONE"),
TARGET(ServerVersion.V1_16, "STONE"),
TWISTING_VINES(ServerVersion.V1_16, "STONE"),
TWISTING_VINES_PLANT(ServerVersion.V1_16, "STONE"),
WARPED_BUTTON(ServerVersion.V1_16, "STONE"),
WARPED_DOOR(ServerVersion.V1_16, "STONE"),
WARPED_FENCE(ServerVersion.V1_16, "STONE"),
WARPED_FENCE_GATE(ServerVersion.V1_16, "STONE"),
WARPED_FUNGUS(ServerVersion.V1_16, "STONE"),
WARPED_FUNGUS_ON_A_STICK(ServerVersion.V1_16, "STONE"),
WARPED_HYPHAE(ServerVersion.V1_16, "STONE"),
WARPED_NYLIUM(ServerVersion.V1_16, "STONE"),
WARPED_PLANKS(ServerVersion.V1_16, "STONE"),
WARPED_PRESSURE_PLATE(ServerVersion.V1_16, "STONE"),
WARPED_ROOTS(ServerVersion.V1_16, "STONE"),
WARPED_SIGN(ServerVersion.V1_16, "STONE"),
WARPED_SLAB(ServerVersion.V1_16, "STONE"),
WARPED_STAIRS(ServerVersion.V1_16, "STONE"),
WARPED_STEM(ServerVersion.V1_16, "STONE"),
WARPED_TRAPDOOR(ServerVersion.V1_16, "STONE"),
WARPED_WALL_SIGN(ServerVersion.V1_16, "STONE"),
WARPED_WART_BLOCK(ServerVersion.V1_16, "STONE"),
WEEPING_VINES(ServerVersion.V1_16, "STONE"),
WEEPING_VINES_PLANT(ServerVersion.V1_16, "STONE"),
ZOGLIN_SPAWN_EGG(ServerVersion.V1_16, "STONE"),
ZOMBIFIED_PIGLIN_SPAWN_EGG(ServerVersion.V1_16, "STONE"),
/* 1.15 */
BEE_SPAWN_EGG(ServerVersion.V1_15, "PARROT_SPAWN_EGG", ServerVersion.V1_12, "MONSTER_EGG", (byte) 65),

View File

@ -5,7 +5,7 @@ import org.bukkit.Bukkit;
public enum ServerVersion {
UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20;
UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20, V1_21;
private final static String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName();
private final static String serverPackageVersion = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../</relativePath>
</parent>
@ -40,23 +40,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<doclint>none</doclint>
<source>1.8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@ -119,7 +102,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.5</version>
<version>1.17</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -243,6 +226,13 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>SongodaCore-NMS-v1_17_R1</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End NMS -->
<!-- Start Plugin Hooks -->
<dependency>
@ -380,7 +370,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.25</version>
<version>1.26</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -51,12 +51,12 @@ public class SongodaCore {
* Whenever we make a major change to the core GUI, updater,
* or other function used by the core, increment this number
*/
private final static int coreRevision = 8;
private final static int coreRevision = 9;
/**
* This has been added as of Rev 6
*/
private final static String coreVersion = "2.4.57";
private final static String coreVersion = "2.5";
/**
* This is specific to the website api
@ -120,6 +120,7 @@ public class SongodaCore {
// register ourselves as the SongodaCore service!
INSTANCE = new SongodaCore(plugin);
INSTANCE.init();
INSTANCE.register(plugin, pluginID, icon, coreVersion);
Bukkit.getServicesManager().register(SongodaCore.class, INSTANCE, plugin, ServicePriority.Normal);
// we need (JavaPlugin plugin, int pluginID, String icon) for our object
if (!otherPlugins.isEmpty()) {
@ -149,6 +150,7 @@ public class SongodaCore {
INSTANCE.init();
Bukkit.getServicesManager().register(SongodaCore.class, INSTANCE, plugin, ServicePriority.Normal);
}
INSTANCE.register(plugin, pluginID, icon, coreVersion);
}
SongodaCore() {
@ -197,14 +199,13 @@ public class SongodaCore {
private ArrayList<BukkitTask> tasks = new ArrayList();
private PluginInfo register(JavaPlugin plugin, int pluginID, String icon, String libraryVersion) {
private void register(JavaPlugin plugin, int pluginID, String icon, String libraryVersion) {
System.out.println(getPrefix() + "Hooked " + plugin.getName() + ".");
PluginInfo info = new PluginInfo(plugin, pluginID, icon, libraryVersion);
// don't forget to check for language pack updates ;)
info.addModule(new LocaleModule());
registeredPlugins.add(info);
tasks.add(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> update(info), 60L));
return info;
}
private void update(PluginInfo plugin) {

View File

@ -4,7 +4,9 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.compatibility.ClassMapping;
import com.songoda.core.utils.TextUtils;
import net.minecraft.network.chat.IChatBaseComponent;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,7 +26,7 @@ import java.util.regex.Pattern;
public class ChatMessage {
private static final Gson gson = new GsonBuilder().create();
private List<JsonObject> textList = new ArrayList<>();
private final List<JsonObject> textList = new ArrayList<>();
public void clear() {
textList.clear();
@ -234,21 +236,21 @@ public class ChatMessage {
Class<?> cb_craftPlayerClazz, mc_entityPlayerClazz, mc_playerConnectionClazz, mc_PacketInterface,
mc_IChatBaseComponent, mc_IChatBaseComponent_ChatSerializer, mc_PacketPlayOutChat;
cb_craftPlayerClazz = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftPlayer");
cb_craftPlayerClazz = ClassMapping.CRAFT_PLAYER.getClazz();
cb_craftPlayer_getHandle = cb_craftPlayerClazz.getDeclaredMethod("getHandle");
mc_entityPlayerClazz = Class.forName("net.minecraft.server." + version + ".EntityPlayer");
mc_entityPlayer_playerConnection = mc_entityPlayerClazz.getDeclaredField("playerConnection");
mc_playerConnectionClazz = Class.forName("net.minecraft.server." + version + ".PlayerConnection");
mc_PacketInterface = Class.forName("net.minecraft.server." + version + ".Packet");
mc_entityPlayerClazz = ClassMapping.ENTITY_PLAYER.getClazz();
mc_entityPlayer_playerConnection = mc_entityPlayerClazz.getDeclaredField(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17) ? "b" : "playerConnection");
mc_playerConnectionClazz = ClassMapping.PLAYER_CONNECTION.getClazz();
mc_PacketInterface = ClassMapping.PACKET.getClazz();
mc_playerConnection_sendPacket = mc_playerConnectionClazz.getDeclaredMethod("sendPacket", mc_PacketInterface);
mc_IChatBaseComponent = Class.forName("net.minecraft.server." + version + ".IChatBaseComponent");
mc_IChatBaseComponent_ChatSerializer = Class.forName("net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer");
mc_IChatBaseComponent = ClassMapping.I_CHAT_BASE_COMPONENT.getClazz();
mc_IChatBaseComponent_ChatSerializer = ClassMapping.I_CHAT_BASE_COMPONENT.getClazz("ChatSerializer");
mc_IChatBaseComponent_ChatSerializer_a = mc_IChatBaseComponent_ChatSerializer.getMethod("a", String.class);
mc_PacketPlayOutChat = Class.forName("net.minecraft.server." + version + ".PacketPlayOutChat");
mc_PacketPlayOutChat = ClassMapping.PACKET_PLAY_OUT_CHAT.getClazz();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
mc_ChatMessageType = Class.forName("net.minecraft.server." + version + ".ChatMessageType");
mc_chatMessageType_Chat = mc_ChatMessageType.getField("CHAT");
mc_ChatMessageType = ClassMapping.CHAT_MESSAGE_TYPE.getClazz();
mc_chatMessageType_Chat = mc_ChatMessageType.getField(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17) ? "a" : "CHAT");
mc_PacketPlayOutChat_new = mc_PacketPlayOutChat.getConstructor(mc_IChatBaseComponent, mc_ChatMessageType, UUID.class);
} else {
mc_PacketPlayOutChat_new = mc_PacketPlayOutChat.getConstructor(mc_IChatBaseComponent);

View File

@ -10,9 +10,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@ -304,11 +306,12 @@ public class CommandManager implements CommandExecutor, TabCompleter {
public static void registerCommandDynamically(Plugin plugin, String command, CommandExecutor executor, TabCompleter tabManager) {
try {
// Retrieve the SimpleCommandMap from the server
Class<?> classCraftServer = Bukkit.getServer().getClass();
Field fieldCommandMap = classCraftServer.getDeclaredField("commandMap");
fieldCommandMap.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) fieldCommandMap.get(Bukkit.getServer());
Class<?> clazzCraftServer = Bukkit.getServer().getClass();
Object craftServer = clazzCraftServer.cast(Bukkit.getServer());
SimpleCommandMap commandMap = (SimpleCommandMap) craftServer.getClass()
.getDeclaredMethod("getCommandMap").invoke(craftServer);
// Construct a new Command object
Constructor<PluginCommand> constructorPluginCommand = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
@ -340,4 +343,12 @@ public class CommandManager implements CommandExecutor, TabCompleter {
e.printStackTrace();
}
}
/*
private class DCommand extends PluginCommand {
protected DCommand(@NotNull String name, @NotNull Plugin owner) {
super(name, owner);
}
} */
}

View File

@ -4,7 +4,7 @@ import com.songoda.core.SongodaCore;
import com.songoda.core.commands.AbstractCommand;
import com.songoda.core.compatibility.ServerProject;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.NMSUtils;
import com.songoda.core.compatibility.ClassMapping;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -24,7 +24,7 @@ public class SongodaCoreDiagCommand extends AbstractCommand {
super(false, "diag");
try {
serverInstance = NMSUtils.getNMSClass("MinecraftServer").getMethod("getServer").invoke(null);
serverInstance = ClassMapping.MINECRAFT_SERVER.getClazz().getMethod("getServer").invoke(null);
tpsField = serverInstance.getClass().getField("recentTps");
} catch (NoSuchFieldException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException e) {

View File

@ -164,14 +164,14 @@ public class WorldGuardFlagHandler {
private static Object getPrivateField(Class<?> c, Object handle, String fieldName) throws Exception {
Field field = c.getDeclaredField(fieldName);
field.setAccessible(true);
field.setAccessible(true); // This should be okay since it only runs on older versions.
return field.get(handle);
}
private static void setStaticField(Field field, Object value) throws Exception {
field.setAccessible(true);
field.setAccessible(true); // This should be okay since it only runs on older versions.
Field modifier = Field.class.getDeclaredField("modifiers");
modifier.setAccessible(true);
modifier.setAccessible(true); // This should be okay since it only runs on older versions.
modifier.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, value);
}

View File

@ -93,6 +93,11 @@ public class NmsManager {
nbt = new com.songoda.core.nms.v1_16_R3.nbt.NBTCoreImpl();
world = new com.songoda.core.nms.v1_16_R3.world.WorldCoreImpl();
break;
case "v1_17_R1":
anvil = new com.songoda.core.nms.v1_17_R1.anvil.AnvilCore();
nbt = new com.songoda.core.nms.v1_17_R1.nbt.NBTCoreImpl();
world = new com.songoda.core.nms.v1_17_R1.world.WorldCoreImpl();
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;

View File

@ -1,5 +1,6 @@
package com.songoda.core.utils;
import com.songoda.core.compatibility.ClassMapping;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
import org.bukkit.Bukkit;
@ -309,7 +310,7 @@ public class BlockUtils {
}
private static Class<?> clazzCraftWorld, clazzCraftBlock, clazzBlockPosition;
private static Method getHandle, updateAdjacentComparators, getNMSBlock;
private static Method getHandle, updateAdjacentComparators, craftBlock_getNMS, nmsBlockData_getBlock;
/**
* Manually trigger the updateAdjacentComparators method for containers
@ -321,18 +322,18 @@ public class BlockUtils {
try {
// Cache reflection.
if (clazzCraftWorld == null) {
String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName();
String ver = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);
clazzCraftWorld = Class.forName("org.bukkit.craftbukkit." + ver + ".CraftWorld");
clazzCraftBlock = Class.forName("org.bukkit.craftbukkit." + ver + ".block.CraftBlock");
clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
Class<?> clazzWorld = Class.forName("net.minecraft.server." + ver + ".World");
Class<?> clazzBlock = Class.forName("net.minecraft.server." + ver + ".Block");
clazzCraftWorld = ClassMapping.CRAFT_WORLD.getClazz();
clazzCraftBlock = ClassMapping.CRAFT_BLOCK.getClazz();
clazzBlockPosition = ClassMapping.BLOCK_POSITION.getClazz();
Class<?> clazzWorld = ClassMapping.WORLD.getClazz();
Class<?> clazzBlock = ClassMapping.BLOCK.getClazz();
getHandle = clazzCraftWorld.getMethod("getHandle");
updateAdjacentComparators = clazzWorld.getMethod("updateAdjacentComparators", clazzBlockPosition, clazzBlock);
getNMSBlock = clazzCraftBlock.getDeclaredMethod("getNMSBlock");
getNMSBlock.setAccessible(true);
craftBlock_getNMS = clazzCraftBlock.getDeclaredMethod("getNMS");
Class<?> clazzBlockData = ClassMapping.BLOCK_BASE.getClazz("BlockData");
nmsBlockData_getBlock = clazzBlockData.getDeclaredMethod("getBlock");
}
// invoke and cast objects.
@ -344,7 +345,7 @@ public class BlockUtils {
updateAdjacentComparators
.invoke(world, clazzBlockPosition.getConstructor(double.class, double.class, double.class)
.newInstance(location.getX(), location.getY(), location.getZ()),
getNMSBlock.invoke(craftBlock));
nmsBlockData_getBlock.invoke(craftBlock_getNMS.invoke(craftBlock)));
} catch (ReflectiveOperationException e) {
e.printStackTrace();
@ -372,14 +373,13 @@ public class BlockUtils {
try {
// Cache reflection
if (clazzIBlockData == null) {
String ver = Bukkit.getServer().getClass().getPackage().getName().substring(23);
clazzIBlockData = Class.forName("net.minecraft.server." + ver + ".IBlockData");
clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
clazzCraftWorld = Class.forName("org.bukkit.craftbukkit." + ver + ".CraftWorld");
clazzBlocks = Class.forName("net.minecraft.server." + ver + ".Blocks");
Class<?> clazzBlock = Class.forName("net.minecraft.server." + ver + ".Block");
Class<?> clazzWorld = Class.forName("net.minecraft.server." + ver + ".World");
Class<?> clazzChunk = Class.forName("net.minecraft.server." + ver + ".Chunk");
clazzIBlockData = ClassMapping.I_BLOCK_DATA.getClazz();
clazzBlockPosition = ClassMapping.BLOCK_POSITION.getClazz();
clazzCraftWorld = ClassMapping.CRAFT_WORLD.getClazz();
clazzBlocks = ClassMapping.BLOCKS.getClazz();
Class<?> clazzBlock = ClassMapping.BLOCK.getClazz();
Class<?> clazzWorld = ClassMapping.WORLD.getClazz();
Class<?> clazzChunk = ClassMapping.CHUNK.getClazz();
getHandle = clazzCraftWorld.getMethod("getHandle");
getChunkAt = clazzWorld.getMethod("getChunkAt", int.class, int.class);

View File

@ -1,5 +1,6 @@
package com.songoda.core.utils;
import com.songoda.core.compatibility.ClassMapping;
import com.songoda.core.compatibility.ServerVersion;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
@ -74,34 +75,37 @@ public class BlockUtilsModern {
}
}
private static Class<?> clazzCraftWorld, clazzCraftBlock,
clazzLeverBlock, clazzButtonBlock, clazzPressurePlateBlock;
private static Method craftWorld_getHandle, craftBlock_getNMSBlock, craftBlock_getPostition, craftBlockData_getState,
nmsLever_updateNeighbours, nmsButton_updateNeighbours, nmsPlate_updateNeighbours;
private static Class<?> clazzCraftWorld;
private static Class<?> clazzCraftBlock;
private static Class<?> clazzLeverBlock;
private static Class<?> clazzButtonBlock;
private static Class<?> clazzPressurePlateBlock;
private static Method craftWorld_getHandle, craftBlock_getNMS, craftBlock_getPostition, craftBlockData_getState,
nmsLever_updateNeighbours, nmsButton_updateNeighbours, nmsPlate_updateNeighbours, nmsBlockData_getBlock;
static {
try {
// Cache reflection.
String ver = Bukkit.getServer().getClass().getPackage().getName().substring(23);
clazzCraftWorld = Class.forName("org.bukkit.craftbukkit." + ver + ".CraftWorld");
clazzCraftBlock = Class.forName("org.bukkit.craftbukkit." + ver + ".block.CraftBlock");
//clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
clazzCraftWorld = ClassMapping.CRAFT_WORLD.getClazz();
clazzCraftBlock = ClassMapping.CRAFT_BLOCK.getClazz();
craftWorld_getHandle = clazzCraftWorld.getMethod("getHandle");
craftBlock_getNMSBlock = clazzCraftBlock.getDeclaredMethod("getNMSBlock");
craftBlock_getNMSBlock.setAccessible(true);
craftBlock_getPostition = clazzCraftBlock.getDeclaredMethod("getPosition");
Class<?> clazzCraftBlockData = Class.forName("org.bukkit.craftbukkit." + ver + ".block.data.CraftBlockData");
craftBlock_getNMS = clazzCraftBlock.getDeclaredMethod("getNMS");
Class<?> clazzBlockData = ClassMapping.BLOCK_BASE.getClazz("BlockData");
nmsBlockData_getBlock = clazzBlockData.getDeclaredMethod("getBlock");
Class<?> clazzCraftBlockData = ClassMapping.CRAFT_BLOCK_DATA.getClazz();
craftBlockData_getState = clazzCraftBlockData.getDeclaredMethod("getState");
Class<?> clazzWorld = Class.forName("net.minecraft.server." + ver + ".World");
Class<?> clazzBlockState = Class.forName("net.minecraft.server." + ver + ".IBlockData");
Class<?> clazzBlockPos = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
clazzLeverBlock = Class.forName("net.minecraft.server." + ver + ".BlockLever");
clazzButtonBlock = Class.forName("net.minecraft.server." + ver + ".BlockButtonAbstract");
clazzPressurePlateBlock = Class.forName("net.minecraft.server." + ver + ".BlockPressurePlateAbstract");
Class<?> clazzWorld = ClassMapping.WORLD.getClazz();
Class<?> clazzBlockState = ClassMapping.I_BLOCK_DATA.getClazz();
Class<?> clazzBlockPos = ClassMapping.BLOCK_POSITION.getClazz();
clazzLeverBlock = ClassMapping.BLOCK_LEVER.getClazz();
clazzButtonBlock = ClassMapping.BLOCK_BUTTON_ABSTRACT.getClazz();
clazzPressurePlateBlock = ClassMapping.BLOCK_PRESSURE_PLATE_ABSTRACT.getClazz();
// nmsLever_updateNeighbours, nmsButton_updateNeighbours, nmsPlate_updateNeighbours
nmsLever_updateNeighbours = clazzLeverBlock.getDeclaredMethod(ServerVersion.isServerVersionAbove(ServerVersion.V1_13)
@ -131,7 +135,7 @@ public class BlockUtilsModern {
Object cworld = clazzCraftWorld.cast(block.getWorld());
Object mworld = craftWorld_getHandle.invoke(cworld);
Object cblock = clazzCraftBlock.cast(block);
Object mblock = craftBlock_getNMSBlock.invoke(cblock);
Object mblock = nmsBlockData_getBlock.invoke(craftBlock_getNMS.invoke(cblock));
Object mpos = craftBlock_getPostition.invoke(cblock);
//System.out.println(mblock.getClass());

View File

@ -1,8 +1,7 @@
package com.songoda.core.utils;
import com.songoda.core.compatibility.CompatibleMaterial;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import com.songoda.core.compatibility.ClassMapping;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -24,12 +23,11 @@ public class EntityUtils {
static {
try {
String ver = Bukkit.getServer().getClass().getPackage().getName().substring(23);
clazzEntityInsentient = Class.forName("net.minecraft.server." + ver + ".EntityInsentient");
clazzEntity = Class.forName("net.minecraft.server." + ver + ".Entity");
clazzCraftEntity = Class.forName("org.bukkit.craftbukkit." + ver + ".entity.CraftEntity");
clazzEntityInsentient = ClassMapping.ENTITY_INSENTIENT.getClazz();
clazzEntity = ClassMapping.ENTITY.getClazz();
clazzCraftEntity = ClassMapping.CRAFT_ENTITY.getClazz();
methodGetHandle = clazzCraftEntity.getDeclaredMethod("getHandle");
} catch (ClassNotFoundException | NoSuchMethodException e) {
} catch (NoSuchMethodException e) {
e.printStackTrace();
}

View File

@ -7,9 +7,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.songoda.core.compatibility.CompatibleHand;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.nms.NmsManager;
import com.songoda.core.compatibility.ClassMapping;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -120,43 +119,6 @@ public class ItemUtils {
return clone;
}
public static ItemStack addDamage(ItemStack item, int damage) {
return addDamage(null, item, damage);
}
public static ItemStack addDamage(Player player, ItemStack item, int damage) {
if (item == null)
return null;
int maxDurability = item.getType().getMaxDurability();
int durability;
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11)
? NmsManager.getNbt().of(item).has("Unbreakable")
: item.getItemMeta().isUnbreakable()) {
return item;
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
// ItemStack.setDurability(short) still works in 1.13-1.14, but use these methods now
ItemMeta meta = item.getItemMeta();
if (meta instanceof Damageable) {
Damageable damageable = ((Damageable) meta);
damageable.setDamage(((Damageable) meta).getDamage() + damage);
item.setItemMeta(meta);
durability = damageable.getDamage();
} else {
return item;
}
} else {
item.setDurability((short) Math.max(0, item.getDurability() + damage));
durability = item.getDurability();
}
if (durability >= maxDurability && player != null) {
player.getInventory().removeItem(item);
CompatibleSound.ENTITY_ITEM_BREAK.play(player);
}
return item;
}
public static boolean hasEnoughDurability(ItemStack tool, int requiredAmount) {
if (tool.getType().getMaxDurability() <= 1)
return true;
@ -173,10 +135,10 @@ public class ItemUtils {
}
static Class cb_ItemStack = NMSUtils.getCraftClass("inventory.CraftItemStack");
static Class mc_ItemStack = NMSUtils.getNMSClass("ItemStack");
static Class mc_NBTTagCompound = NMSUtils.getNMSClass("NBTTagCompound");
static Class mc_NBTTagList = NMSUtils.getNMSClass("NBTTagList");
static Class mc_NBTBase = NMSUtils.getNMSClass("NBTBase");
static Class mc_ItemStack = ClassMapping.ITEM_STACK.getClazz();
static Class mc_NBTTagCompound = ClassMapping.NBT_TAG_COMPOUND.getClazz();
static Class mc_NBTTagList = ClassMapping.NBT_TAG_LIST.getClazz();
static Class mc_NBTBase = ClassMapping.NBT_BASE.getClazz();
static Method mc_ItemStack_getTag;
static Method mc_ItemStack_setTag;
static Method mc_NBTTagCompound_set;
@ -292,7 +254,7 @@ public class ItemUtils {
return item;
}
private static Class mc_Item = NMSUtils.getNMSClass("Item");
private static Class<?> mc_Item = ClassMapping.ITEM.getClazz();
private static Method mc_Item_getItem;
private static Field mc_Item_maxStackSize;
@ -348,15 +310,22 @@ public class ItemUtils {
}
public static ItemStack getCustomHead(String texture) {
ItemStack skullItem = CompatibleMaterial.PLAYER_HEAD.getItem();
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
return skullItem;
return getCustomHead(null, texture);
}
public static ItemStack getCustomHead(String signature, String texture) {
ItemStack skullItem = CompatibleMaterial.PLAYER_HEAD.getItem();
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_8))
return skullItem;
SkullMeta sm = (SkullMeta) skullItem.getItemMeta();
GameProfile gm;
if (texture.endsWith("=")) {
gm = new GameProfile(UUID.nameUUIDFromBytes(texture.getBytes()), "CustomHead");
if (signature == null)
gm.getProperties().put("textures", new Property("texture", texture.replaceAll("=", "")));
else
gm.getProperties().put("textures", new Property("textures", texture, signature));
} else {
gm = new GameProfile(UUID.nameUUIDFromBytes(texture.getBytes()), "CustomHead");
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"http://textures.minecraft.net/texture/%s\"}}}", texture).getBytes());

View File

@ -1,6 +1,7 @@
package com.songoda.core.utils;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.compatibility.ClassMapping;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
@ -8,17 +9,6 @@ import java.lang.reflect.Method;
public class NMSUtils {
public static Class<?> getNMSClass(String className) {
try {
String fullName = "net.minecraft.server." + ServerVersion.getServerVersionString() + "." + className;
Class<?> clazz = Class.forName(fullName);
return clazz;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static Class<?> getCraftClass(String className) {
try {
String fullName = "org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + "." + className;
@ -65,14 +55,7 @@ public class NMSUtils {
public static void setField(Object object, String fieldName, Object fieldValue, boolean declared) {
try {
Field field;
if (declared) {
field = object.getClass().getDeclaredField(fieldName);
} else {
field = object.getClass().getField(fieldName);
}
Field field = declared ? object.getClass().getDeclaredField(fieldName) : object.getClass().getField(fieldName);
field.setAccessible(true);
field.set(object, fieldValue);
} catch (Exception e) {
@ -84,7 +67,7 @@ public class NMSUtils {
try {
Object handle = player.getClass().getMethod("getHandle").invoke(player);
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
playerConnection.getClass().getMethod("sendPacket", ClassMapping.PACKET.getClazz()).invoke(playerConnection, packet);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -0,0 +1,75 @@
package com.songoda.core.world;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.nms.NmsManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerItemBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
public class SItemStack {
protected final com.songoda.core.nms.world.SItemStack sItem;
protected final ItemStack item;
public SItemStack(ItemStack item) {
this.item = item;
this.sItem = NmsManager.getWorld().getItemStack(item);
}
/**
* Damage the selected item
*
* @param player the player who's item you want to damage
* @param damage the amount of damage to apply to the item
*/
public ItemStack addDamage(Player player, int damage) {
if (item == null)
return null;
int maxDurability = item.getType().getMaxDurability();
int durability;
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11)
? NmsManager.getNbt().of(item).has("Unbreakable")
: item.getItemMeta().isUnbreakable()) {
return item;
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
// ItemStack.setDurability(short) still works in 1.13-1.14, but use these methods now
ItemMeta meta = item.getItemMeta();
if (meta instanceof Damageable) {
Damageable damageable = ((Damageable) meta);
damageable.setDamage(((Damageable) meta).getDamage() + damage);
item.setItemMeta(meta);
durability = damageable.getDamage();
} else {
return item;
}
} else {
item.setDurability((short) Math.max(0, item.getDurability() + damage));
durability = item.getDurability();
}
if (durability >= maxDurability && player != null)
destroy(player);
return item;
}
public void destroy(Player player) {
destroy(player, 1);
}
public void destroy(Player player, int amount) {
PlayerItemBreakEvent breakEvent = new PlayerItemBreakEvent(player, item);
Bukkit.getServer().getPluginManager().callEvent(breakEvent);
sItem.breakItem(player, amount);
CompatibleSound.ENTITY_ITEM_BREAK.play(player);
}
public ItemStack getItem() {
return item;
}
}

View File

@ -17,12 +17,12 @@ import java.util.concurrent.ThreadLocalRandom;
public class SSpawner {
private static final WorldCore worldCore = NmsManager.getWorld();
protected final com.songoda.core.nms.world.SSpawner sSpawner;
protected final Location location;
public SSpawner(Location location) {
this.location = location;
this.sSpawner = NmsManager.getWorld().getSpawner(location);
}
public SSpawner(CreatureSpawner spawner) {
@ -60,7 +60,7 @@ public class SSpawner {
int amountSpawned = 0;
while (spawnCountUsed-- > 0) {
EntityType type = types[ThreadLocalRandom.current().nextInt(types.length)];
LivingEntity entity = worldCore.getSpawner(location).spawnEntity(type, particle, spawned, canSpawnOn);
LivingEntity entity = sSpawner.spawnEntity(type, particle, spawned, canSpawnOn);
if (entity != null) {
// If this entity is indeed stackable then spawn a single stack with the desired stack size.
if (useStackPlugin && amountToSpawn >= EntityStackerManager.getMinStackSize(type)) {
@ -73,4 +73,8 @@ public class SSpawner {
}
return amountSpawned;
}
public Location getLocation() {
return location;
}
}

View File

@ -0,0 +1,39 @@
package com.songoda.core.world;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.nms.NmsManager;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import java.util.List;
public class SWorld {
protected final com.songoda.core.nms.world.SWorld sWorld;
protected final World world;
public SWorld(World world) {
this.world = world;
this.sWorld = NmsManager.getWorld().getWorld(world);
}
public Entity[] getEntitiesFromChunk(int x, int z) {
Location location = new Location(null, 0.0D, 0.0D, 0.0D);
return getLivingEntities().stream().filter((entity) -> {
entity.getLocation(location);
return location.getBlockX() >> 4 == x && location.getBlockZ() >> 4 == z;
}).toArray(Entity[]::new);
}
public List<LivingEntity> getLivingEntities() {
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_17))
return world.getLivingEntities();
return sWorld.getLivingEntities();
}
public World getWorld() {
return world;
}
}

View File

@ -0,0 +1,90 @@
package com.songoda.core.world;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.compatibility.ClassMapping;
import com.songoda.core.utils.NMSUtils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class SWorldBorder {
private static Class<?> packetPlayOutWorldBorderEnumClass;
private static Class<?> worldBorderClass;
private static Class<?> craftWorldClass;
private static Constructor<?> packetPlayOutWorldBorderConstructor;
static {
try {
Class<?> packetPlayOutWorldBorder = ClassMapping.PACKET_PLAY_OUT_WORLD_BORDER.getClazz();
if(packetPlayOutWorldBorder != null) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11))
packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[0];
else
packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[1];
worldBorderClass = ClassMapping.WORLD_BORDER.getClazz();
craftWorldClass = NMSUtils.getCraftClass("CraftWorld");
packetPlayOutWorldBorderConstructor = packetPlayOutWorldBorder.getConstructor(worldBorderClass,
packetPlayOutWorldBorderEnumClass);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void send(Player player, Color color, double size, Location centerLocation) {
try {
if (centerLocation == null || centerLocation.getWorld() == null)
return;
Object worldBorder = worldBorderClass.getConstructor().newInstance();
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
Object craftWorld = craftWorldClass.cast(centerLocation.getWorld());
Method getHandleMethod = craftWorld.getClass().getMethod("getHandle");
Object worldServer = getHandleMethod.invoke(craftWorld);
NMSUtils.setField(worldBorder, "world", worldServer, false);
}
Method setCenter = worldBorder.getClass().getMethod("setCenter", double.class, double.class);
setCenter.invoke(worldBorder, centerLocation.getX(), centerLocation.getZ());
Method setSize = worldBorder.getClass().getMethod("setSize", double.class);
setSize.invoke(worldBorder, size);
Method setWarningTime = worldBorder.getClass().getMethod("setWarningTime", int.class);
setWarningTime.invoke(worldBorder, 0);
Method setWarningDistance = worldBorder.getClass().getMethod("setWarningDistance", int.class);
setWarningDistance.invoke(worldBorder, 0);
Method transitionSizeBetween = worldBorder.getClass().getMethod("transitionSizeBetween", double.class,
double.class, long.class);
if (color == Color.Green) {
transitionSizeBetween.invoke(worldBorder, size - 0.1D, size, 20000000L);
} else if (color == Color.Red) {
transitionSizeBetween.invoke(worldBorder, size, size - 1.0D, 20000000L);
}
@SuppressWarnings({"unchecked", "rawtypes"})
Object packet = packetPlayOutWorldBorderConstructor.newInstance(worldBorder,
Enum.valueOf((Class<Enum>) packetPlayOutWorldBorderEnumClass, "INITIALIZE"));
NMSUtils.sendPacket(player, packet);
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
e.printStackTrace();
}
}
public enum Color {
Blue, Green, Red
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>
@ -13,6 +13,12 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>

View File

@ -0,0 +1,13 @@
package com.songoda.core.nms.world;
import org.bukkit.entity.Player;
import java.util.Random;
public interface SItemStack {
Random random = new Random();
void breakItem(Player player, int amount);
}

View File

@ -0,0 +1,10 @@
package com.songoda.core.nms.world;
import org.bukkit.entity.LivingEntity;
import java.util.List;
public interface SWorld {
List<LivingEntity> getLivingEntities();
}

View File

@ -1,11 +1,17 @@
package com.songoda.core.nms.world;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public interface WorldCore {
SSpawner getSpawner(CreatureSpawner spawner);
SSpawner getSpawner(Location location);
SItemStack getItemStack(ItemStack item);
SWorld getWorld(World world);
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_10_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.EnumParticle;
import net.minecraft.server.v1_10_R1.Item;
import net.minecraft.server.v1_10_R1.Vec3D;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < 5; ++i) {
Vec3D vec3d = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double) entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(EnumParticle.ITEM_CRACK, vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z, new int[]{Item.getId(CraftItemStack.asNMSCopy(item).getItem())});
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_10_R1.world.spawner;
package com.songoda.core.nms.v1_10_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_10_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_10_R1.world;
import com.songoda.core.nms.v1_10_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_11_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.EnumParticle;
import net.minecraft.server.v1_11_R1.Item;
import net.minecraft.server.v1_11_R1.Vec3D;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < 5; ++i) {
Vec3D vec3d = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double) entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(EnumParticle.ITEM_CRACK, vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z, new int[]{Item.getId(CraftItemStack.asNMSCopy(item).getItem())});
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_11_R1.world.spawner;
package com.songoda.core.nms.v1_11_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_11_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_11_R1.world;
import com.songoda.core.nms.v1_11_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_12_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumParticle;
import net.minecraft.server.v1_12_R1.Item;
import net.minecraft.server.v1_12_R1.Vec3D;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < 5; ++i) {
Vec3D vec3d = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double) entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(EnumParticle.ITEM_CRACK, vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z, new int[]{Item.getId(CraftItemStack.asNMSCopy(item).getItem())});
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_12_R1.world.spawner;
package com.songoda.core.nms.v1_12_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_12_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_12_R1.world;
import com.songoda.core.nms.v1_12_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_13_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_13_R1.EntityPlayer;
import net.minecraft.server.v1_13_R1.ParticleParamItem;
import net.minecraft.server.v1_13_R1.Particles;
import net.minecraft.server.v1_13_R1.Vec3D;
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double)entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(new ParticleParamItem(Particles.C, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_13_R1.world.spawner;
package com.songoda.core.nms.v1_13_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_13_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_13_R1.world;
import com.songoda.core.nms.v1_13_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_13_R2.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_13_R2.EntityPlayer;
import net.minecraft.server.v1_13_R2.ParticleParamItem;
import net.minecraft.server.v1_13_R2.Particles;
import net.minecraft.server.v1_13_R2.Vec3D;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double)entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(new ParticleParamItem(Particles.C, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_13_R2.world.spawner;
package com.songoda.core.nms.v1_13_R2.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_13_R2.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_13_R2.world;
import com.songoda.core.nms.v1_13_R2.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_14_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_14_R1.EntityPlayer;
import net.minecraft.server.v1_14_R1.ParticleParamItem;
import net.minecraft.server.v1_14_R1.Particles;
import net.minecraft.server.v1_14_R1.Vec3D;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double)entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(new ParticleParamItem(Particles.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_14_R1.world.spawner;
package com.songoda.core.nms.v1_14_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_14_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_14_R1.world;
import com.songoda.core.nms.v1_14_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_15_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_15_R1.EntityPlayer;
import net.minecraft.server.v1_15_R1.ParticleParamItem;
import net.minecraft.server.v1_15_R1.Particles;
import net.minecraft.server.v1_15_R1.Vec3D;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX(), entityPlayer.getHeadY(), entityPlayer.locZ());
entityPlayer.world.addParticle(new ParticleParamItem(Particles.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_15_R1.world.spawner;
package com.songoda.core.nms.v1_15_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_15_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_15_R1.world;
import com.songoda.core.nms.v1_15_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_16_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_16_R1.EntityPlayer;
import net.minecraft.server.v1_16_R1.ParticleParamItem;
import net.minecraft.server.v1_16_R1.Particles;
import net.minecraft.server.v1_16_R1.Vec3D;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX(), entityPlayer.getHeadY(), entityPlayer.locZ());
entityPlayer.world.addParticle(new ParticleParamItem(Particles.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_16_R1.world.spawner;
package com.songoda.core.nms.v1_16_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_16_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_16_R1.world;
import com.songoda.core.nms.v1_16_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_16_R2.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_16_R2.EntityPlayer;
import net.minecraft.server.v1_16_R2.ParticleParamItem;
import net.minecraft.server.v1_16_R2.Particles;
import net.minecraft.server.v1_16_R2.Vec3D;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX(), entityPlayer.getHeadY(), entityPlayer.locZ());
entityPlayer.world.addParticle(new ParticleParamItem(Particles.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_16_R2.world.spawner;
package com.songoda.core.nms.v1_16_R2.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_16_R2.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_16_R2.world;
import com.songoda.core.nms.v1_16_R2.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_16_R3.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_16_R3.EntityPlayer;
import net.minecraft.server.v1_16_R3.ParticleParamItem;
import net.minecraft.server.v1_16_R3.Particles;
import net.minecraft.server.v1_16_R3.Vec3D;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) this.random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX(), entityPlayer.getHeadY(), entityPlayer.locZ());
entityPlayer.world.addParticle(new ParticleParamItem(Particles.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_16_R3.world.spawner;
package com.songoda.core.nms.v1_16_R3.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_16_R3.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_16_R3.world;
import com.songoda.core.nms.v1_16_R3.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

36
NMS/NMS-v1_17_R1/pom.xml Normal file
View File

@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>SongodaCore-NMS-v1_17_R1</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-NMS-API</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>SongodaCore-Compatibility</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,23 @@
package com.songoda.core.nms.v1_17_R1.anvil;
import com.songoda.core.nms.anvil.CustomAnvil;
import net.minecraft.server.level.EntityPlayer;
import org.bukkit.craftbukkit.v1_17_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);
}
}

View File

@ -0,0 +1,22 @@
package com.songoda.core.nms.v1_17_R1.anvil;
import net.minecraft.world.IInventory;
import net.minecraft.world.inventory.ContainerAnvil;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_17_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;
}
}

View File

@ -0,0 +1,209 @@
package com.songoda.core.nms.v1_17_R1.anvil;
import com.songoda.core.nms.anvil.CustomAnvil;
import com.songoda.core.nms.anvil.methods.AnvilTextChange;
import jdk.internal.misc.Unsafe;
import net.minecraft.core.BlockPosition;
import net.minecraft.network.chat.ChatMessage;
import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.world.IInventory;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.inventory.Container;
import net.minecraft.world.inventory.ContainerAccess;
import net.minecraft.world.inventory.ContainerAnvil;
import net.minecraft.world.inventory.ContainerAnvilAbstract;
import net.minecraft.world.inventory.Containers;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Field;
import java.util.logging.Level;
import java.util.logging.Logger;
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 = ContainerAnvilAbstract.class.getDeclaredField("p");
mc_ContainerAnvil_repairInventory.setAccessible(true);
mc_ContainerAnvil_resultInventory = ContainerAnvilAbstract.class.getDeclaredField("o");
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);
}
}
// 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);
} catch (Exception ex) {
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
}
}
public AnvilView(int id, EntityPlayer entity, InventoryHolder holder) {
super(entity.nextContainerCounter(), entity.getInventory(), ContainerAccess.at(entity.getWorld(), 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.getWorld().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.setLevelCost(cost);
}
textChange.onChange();
}
@Override
public void update() {
e();
}
@Override
public String getRenameText() {
return this.v;
}
@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.getLevelCost();
}
}
@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() {
// Send the packet
entity.b.sendPacket(new PacketPlayOutOpenWindow(j, Containers.h, new ChatMessage(customTitle != null ? customTitle : "")));
// Set their active container to this anvil
entity.bV = this;
// Add the slot listener
entity.initMenu(entity.bV);
//entity.bV.addSlotListener(entity.cX);
}
}

View File

@ -0,0 +1,209 @@
package com.songoda.core.nms.v1_17_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTObject;
import net.minecraft.nbt.NBTCompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.Set;
import java.util.UUID;
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 set(String tag, int[] i) {
compound.setIntArray(tag, i);
return this;
}
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public NBTCompound set(String tag, UUID u) {
compound.a(tag, u);
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);
}
@Override
public String getString(String tag) {
return getNBTObject(tag).asString();
}
@Override
public boolean getBoolean(String tag) {
return getNBTObject(tag).asBoolean();
}
@Override
public int getInt(String tag) {
return getNBTObject(tag).asInt();
}
@Override
public double getDouble(String tag) {
return getNBTObject(tag).asDouble();
}
@Override
public long getLong(String tag) {
return getNBTObject(tag).asLong();
}
@Override
public short getShort(String tag) {
return getNBTObject(tag).asShort();
}
@Override
public byte getByte(String tag) {
return getNBTObject(tag).asByte();
}
@Override
public int[] getIntArray(String tag) {
return getNBTObject(tag).asIntArray();
}
@Override
public byte[] getByteArray(String tag) {
return getNBTObject(tag).asByteArray();
}
@Override
public NBTCompound getCompound(String tag) {
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override
public Set<String> getKeys() {
return compound.getKeys();
}
@Override
public Set<String> getKeys(String tag) {
return compound.getCompound(tag).getKeys();
}
@Override
public byte[] serialize(String... exclusions) {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream dataOutput = new ObjectOutputStream(outputStream)) {
addExtras();
NBTTagCompound compound = this.compound.clone();
for (String exclusion : exclusions)
compound.remove(exclusion);
NBTCompressedStreamTools.a(compound, (OutputStream) dataOutput);
return outputStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void deSerialize(byte[] serialized) {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(serialized);
ObjectInputStream dataInput = new ObjectInputStream(inputStream)) {
compound = NBTCompressedStreamTools.a((InputStream) dataInput);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void addExtras() {
// None
}
@Override
public String toString() {
return compound.toString();
}
}

View File

@ -0,0 +1,37 @@
package com.songoda.core.nms.v1_17_R1.nbt;
import com.songoda.core.nms.nbt.NBTCore;
import com.songoda.core.nms.nbt.NBTEntity;
import com.songoda.core.nms.nbt.NBTItem;
import net.minecraft.nbt.NBTTagCompound;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
public class NBTCoreImpl implements NBTCore {
@Override
public NBTItem of(ItemStack item) {
return new NBTItemImpl(CraftItemStack.asNMSCopy(item));
}
@Override
public NBTItem newItem() {
return new NBTItemImpl(null);
}
@Override
public NBTEntity of(Entity entity) {
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
NBTTagCompound nbt = new NBTTagCompound();
nmsEntity.save(nbt);
return new NBTEntityImpl(nbt, nmsEntity);
}
@Override
public NBTEntity newEntity() {
return new NBTEntityImpl(new NBTTagCompound(), null);
}
}

View File

@ -0,0 +1,62 @@
package com.songoda.core.nms.v1_17_R1.nbt;
import com.songoda.core.nms.nbt.NBTEntity;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.EnumMobSpawn;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import java.util.Optional;
public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
private Entity nmsEntity;
public NBTEntityImpl(NBTTagCompound entityNBT, Entity nmsEntity) {
super(entityNBT);
this.nmsEntity = nmsEntity;
}
@Override
public org.bukkit.entity.Entity spawn(Location location) {
String entityType = getNBTObject("entity_type").asString();
Optional<EntityTypes<?>> optionalEntity = EntityTypes.a(entityType);
if (optionalEntity.isPresent()) {
Entity spawned = optionalEntity.get().spawnCreature(
((CraftWorld) location.getWorld()).getHandle(),
compound,
null,
null,
new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()),
EnumMobSpawn.n,
true,
false
);
if (spawned != null) {
spawned.load(compound);
org.bukkit.entity.Entity entity = spawned.getBukkitEntity();
entity.teleport(location);
nmsEntity = spawned;
return entity;
}
}
return null;
}
@Override
public org.bukkit.entity.Entity reSpawn(Location location) {
nmsEntity.die();
return spawn(location);
}
@Override
public void addExtras() {
compound.setString("entity_type", IRegistry.Y.getKey(nmsEntity.getEntityType()).toString());
}
}

View File

@ -0,0 +1,28 @@
package com.songoda.core.nms.v1_17_R1.nbt;
import com.songoda.core.nms.nbt.NBTItem;
import net.minecraft.nbt.NBTTagCompound;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private final net.minecraft.world.item.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.world.item.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
this.nmsItem = nmsItem;
}
public ItemStack finish() {
if (nmsItem == null) {
return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.a(compound));
} else {
return CraftItemStack.asBukkitCopy(nmsItem);
}
}
@Override
public void addExtras() {
}
}

View File

@ -0,0 +1,73 @@
package com.songoda.core.nms.v1_17_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTObject;
import net.minecraft.nbt.NBTTagCompound;
import java.util.Set;
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;
}
@Override
public String asString() {
return compound.getString(tag);
}
@Override
public boolean asBoolean() {
return compound.getBoolean(tag);
}
@Override
public int asInt() {
return compound.getInt(tag);
}
@Override
public double asDouble() {
return compound.getDouble(tag);
}
@Override
public long asLong() {
return compound.getLong(tag);
}
@Override
public short asShort() {
return compound.getShort(tag);
}
@Override
public byte asByte() {
return compound.getByte(tag);
}
@Override
public int[] asIntArray() {
return compound.getIntArray(tag);
}
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override
public NBTCompound asCompound() {
return new NBTCompoundImpl(compound.getCompound(tag));
}
@Override
public Set<String> getKeys() {
return compound.getKeys();
}
}

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_17_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.core.particles.ParticleParamItem;
import net.minecraft.core.particles.Particles;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
Vec3D vec3d = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.getXRot() * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.getYRot() * 0.017453292F);
double d0 = (double) (-random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.getXRot() * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.getYRot() * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX(), entityPlayer.getHeadY(), entityPlayer.locZ());
entityPlayer.t.addParticle(new ParticleParamItem(Particles.K, CraftItemStack.asNMSCopy(item)), vec3d1.b, vec3d1.c, vec3d1.d, vec3d.b, vec3d.c + 0.05D, vec3d.d);
}
}
}

View File

@ -0,0 +1,132 @@
package com.songoda.core.nms.v1_17_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SpawnedEntity;
import net.minecraft.core.BlockPosition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.DifficultyDamageScaler;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityInsentient;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.EnumMobSpawn;
import net.minecraft.world.level.MobSpawnerData;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.CreatureSpawnEvent;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
public class SSpawnerImpl implements SSpawner {
private final Location spawnerLocation;
public SSpawnerImpl(Location location) {
this.spawnerLocation = location;
}
@Override
public LivingEntity spawnEntity(EntityType type, Location spawnerLocation) {
return spawnEntity(type, "EXPLOSION_NORMAL", null, null);
}
@Override
public LivingEntity spawnEntity(EntityType type, String particleType, SpawnedEntity spawned,
Set<CompatibleMaterial> canSpawnOn) {
MobSpawnerData data = new MobSpawnerData();
NBTTagCompound compound = data.getEntity();
String name = type.name().toLowerCase().replace("snowman", "snow_golem")
.replace("mushroom_cow", "mooshroom");
compound.setString("id", "minecraft:" + name);
short spawnRange = 4;
for (int i = 0; i < 50; i++) {
WorldServer world = ((CraftWorld) spawnerLocation.getWorld()).getHandle();
Random random = world.getRandom();
double x = spawnerLocation.getX() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
double y = spawnerLocation.getY() + random.nextInt(3) - 1;
double z = spawnerLocation.getZ() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
Optional<Entity> optionalEntity = EntityTypes.a(compound, world);
if (!optionalEntity.isPresent()) continue;
Entity entity = optionalEntity.get();
entity.setPosition(x, y, z);
BlockPosition position = entity.getChunkCoordinates();
DifficultyDamageScaler damageScaler = world.getDamageScaler(position);
if (!(entity instanceof EntityInsentient))
continue;
EntityInsentient entityInsentient = (EntityInsentient) entity;
Location spot = new Location(spawnerLocation.getWorld(), x, y, z);
if (!canSpawn(world, entityInsentient, spot, canSpawnOn))
continue;
entityInsentient.prepare(world, damageScaler, EnumMobSpawn.c,
null, null);
LivingEntity craftEntity = (LivingEntity) entity.getBukkitEntity();
if (spawned != null)
if (!spawned.onSpawn(craftEntity))
return null;
if (particleType != null) {
float xx = (float) (0 + (Math.random() * 1));
float yy = (float) (0 + (Math.random() * 2));
float zz = (float) (0 + (Math.random() * 1));
CompatibleParticleHandler.spawnParticles(CompatibleParticleHandler.ParticleType.getParticle(particleType),
spot, 5, xx, yy, zz, 0);
}
world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER);
spot.setYaw(random.nextFloat() * 360.0F);
craftEntity.teleport(spot);
return craftEntity;
}
return null;
}
private boolean canSpawn(WorldServer world, EntityInsentient entityInsentient, Location location,
Set<CompatibleMaterial> canSpawnOn) {
if (!world.getCubes(entityInsentient, entityInsentient.getBoundingBox()))
return false;
CompatibleMaterial spawnedIn = CompatibleMaterial.getMaterial(location.getBlock());
CompatibleMaterial spawnedOn = CompatibleMaterial.getMaterial(location.getBlock().getRelative(BlockFace.DOWN));
if (spawnedIn == null || spawnedOn == null)
return false;
if (!spawnedIn.isAir()
&& spawnedIn != CompatibleMaterial.WATER
&& !spawnedIn.name().contains("PRESSURE")
&& !spawnedIn.name().contains("SLAB")) {
return false;
}
for (CompatibleMaterial material : canSpawnOn) {
if (material == null) continue;
if (spawnedOn.equals(material) || material.isAir())
return true;
}
return false;
}
}

View File

@ -0,0 +1,56 @@
package com.songoda.core.nms.v1_17_R1.world;
import com.songoda.core.nms.world.SWorld;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.entity.LevelEntityGetter;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.entity.LivingEntity;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
private final World world;
private static Field fieldG;
static {
try {
fieldG = WorldServer.class.getDeclaredField("G");
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
fieldG.setAccessible(true);
}
public SWorldImpl(World world) {
this.world = world;
}
@Override
public List<LivingEntity> getLivingEntities() {
List<LivingEntity> list = new ArrayList();
try {
WorldServer worldServer = ((CraftWorld) world).getHandle();
LevelEntityGetter<net.minecraft.world.entity.Entity> entities =
((PersistentEntitySectionManager<Entity>) fieldG.get(worldServer)).d();
entities.a().forEach((mcEnt) -> {
org.bukkit.entity.Entity bukkitEntity = mcEnt.getBukkitEntity();
if (bukkitEntity instanceof LivingEntity && bukkitEntity.isValid()) {
list.add((LivingEntity) bukkitEntity);
}
});
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return list;
}
}

View File

@ -0,0 +1,33 @@
package com.songoda.core.nms.v1_17_R1.world;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@Override
public SSpawner getSpawner(CreatureSpawner spawner) {
return new SSpawnerImpl(spawner.getLocation());
}
@Override
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl(world);
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -0,0 +1,36 @@
package com.songoda.core.nms.v1_8_R1.world;
import com.songoda.core.nms.world.SItemStack;
import net.minecraft.server.v1_8_R1.EntityPlayer;
import net.minecraft.server.v1_8_R1.EnumParticle;
import net.minecraft.server.v1_8_R1.Item;
import net.minecraft.server.v1_8_R1.Vec3D;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SItemStackImpl implements SItemStack {
private final ItemStack item;
public SItemStackImpl(ItemStack item) {
this.item = item;
}
@Override
public void breakItem(Player player, int amount) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < 5; ++i) {
Vec3D vec3d = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.a(-entityPlayer.pitch * 0.017453292F);
vec3d = vec3d.b(-entityPlayer.yaw * 0.017453292F);
double d0 = (double) (-random.nextFloat()) * 0.6D - 0.3D;
Vec3D vec3d1 = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.a(-entityPlayer.pitch * 0.017453292F);
vec3d1 = vec3d1.b(-entityPlayer.yaw * 0.017453292F);
vec3d1 = vec3d1.add(entityPlayer.locX, entityPlayer.locY + (double) entityPlayer.getHeadHeight(), entityPlayer.locZ);
entityPlayer.world.addParticle(EnumParticle.ITEM_CRACK, vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c, new int[]{Item.getId(CraftItemStack.asNMSCopy(item).getItem())});
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.core.nms.v1_8_R1.world.spawner;
package com.songoda.core.nms.v1_8_R1.world;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;

View File

@ -0,0 +1,18 @@
package com.songoda.core.nms.v1_8_R1.world;
import com.songoda.core.nms.world.SWorld;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
public class SWorldImpl implements SWorld {
public SWorldImpl() {
}
@Override
public List<LivingEntity> getLivingEntities() {
return new ArrayList<>();
}
}

View File

@ -1,10 +1,13 @@
package com.songoda.core.nms.v1_8_R1.world;
import com.songoda.core.nms.v1_8_R1.world.spawner.SSpawnerImpl;
import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.inventory.ItemStack;
public class WorldCoreImpl implements WorldCore {
@ -17,4 +20,14 @@ public class WorldCoreImpl implements WorldCore {
public SSpawner getSpawner(Location location) {
return new SSpawnerImpl(location);
}
@Override
public SItemStack getItemStack(ItemStack item) {
return new SItemStackImpl(item);
}
@Override
public SWorld getWorld(World world) {
return new SWorldImpl();
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.57</version>
<version>2.5</version>
<relativePath>../../</relativePath>
</parent>

Some files were not shown because too many files have changed in this diff Show More