Merge branch 'development'

This commit is contained in:
Christian Koop 2024-10-02 15:57:32 +02:00
commit 7dbe315edb
No known key found for this signature in database
GPG Key ID: 6A4A09E8ED946113
7 changed files with 37 additions and 39 deletions

View File

@ -7,7 +7,7 @@
<parent>
<groupId>com.craftaro</groupId>
<artifactId>UltimateStacker-Parent</artifactId>
<version>3.1.10</version>
<version>3.3.0</version>
</parent>
<artifactId>UltimateStacker-API</artifactId>
<version>1.0.0-SNAPSHOT</version>
@ -42,7 +42,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<version>3.7.0</version>
<executions>
<execution>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>com.craftaro</groupId>
<artifactId>UltimateStacker-Parent</artifactId>
<version>3.1.10</version>
<version>3.3.0</version>
</parent>
<artifactId>UltimateStacker-Plugin</artifactId>
@ -16,7 +16,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.0</version>
<executions>
<execution>
@ -55,10 +55,10 @@
<excludeDefaults>false</excludeDefaults>
<includes>
<include>**/nms/v*/**</include>
<include>**/third_party/net/kyori/**</include>
</includes>
<excludes>
<exclude>**/third_party/org/apache/**</exclude>
<exclude>**/third_party/net/kyori/**</exclude>
<exclude>**/third_party/com/zaxxer/**</exclude>
<exclude>**/third_party/org/jooq/**</exclude>
<exclude>**/third_party/org/mariadb/**</exclude>
@ -101,7 +101,7 @@
<repository>
<id>songoda-public</id>
<url>https://repo.craftaro.com/repository/public/</url>
<url>https://repo.songoda.com/repository/public/</url>
</repository>
<repository>

View File

@ -2,8 +2,9 @@ package com.craftaro.ultimatestacker.listeners;
import com.craftaro.core.compatibility.CompatibleHand;
import com.craftaro.core.hooks.ProtectionManager;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBT;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.iface.ReadableNBT;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.craftaro.ultimatestacker.UltimateStacker;
import com.craftaro.ultimatestacker.api.UltimateStackerApi;
import com.craftaro.ultimatestacker.api.events.spawner.SpawnerBreakEvent;
@ -69,7 +70,7 @@ public class BlockListeners implements Listener {
if (Settings.STACK_BLOCKS.getBoolean()
&& Settings.STACKABLE_BLOCKS.getStringList().contains(block.getType().name()) //Is block stackable
&& !block.getType().equals(XMaterial.SPAWNER.parseMaterial()) //Don't stack spawners here
) {
) {
Optional<XMaterial> xBlockType = XMaterial.matchXMaterial(block.getType().name());
if (!xBlockType.isPresent()) return;
@ -84,9 +85,9 @@ public class BlockListeners implements Listener {
if (isStacked) {
event.setCancelled(true);
//Add to stack
if (clickAction == Action.RIGHT_CLICK_BLOCK && !player.hasPermission("ultimatestacker.block.nostack")) {
if (clickAction == Action.RIGHT_CLICK_BLOCK && !player.hasPermission("ultimatestacker.block.nostack")) {
if (inHand.getType().equals(Material.AIR)) return;
if(!blockType.equals(XMaterial.matchXMaterial(inHand))) return;
if (!blockType.equals(XMaterial.matchXMaterial(inHand))) return;
//Add all held items to stack
if (Settings.ALWAYS_ADD_ALL.getBoolean() || isSneaking) {
stack.add(inHandAmount);
@ -108,8 +109,8 @@ public class BlockListeners implements Listener {
//Remove all items from stack
int amountToRemove = Math.min(Settings.MAX_REMOVEABLE.getInt(), stack.getAmount());
ItemStack removed = stack.getMaterial().parseItem();
removed.setAmount(amountToRemove);
stack.take(amountToRemove);
removed.setAmount(amountToRemove - 1);
stack.take(amountToRemove - 1);
if (Settings.ADD_TO_INVENTORY.getBoolean()) {
player.getInventory().addItem(removed);
} else {
@ -124,7 +125,7 @@ public class BlockListeners implements Listener {
player.getWorld().dropItemNaturally(block.getLocation(), stack.getMaterial().parseItem());
}
}
if (stack.getAmount() == 1) {
if (stack.getAmount() <= 1) {
//Remove stack
stack.destroy();
return;
@ -138,7 +139,7 @@ public class BlockListeners implements Listener {
if (isSneaking || player.hasPermission("ultimatestacker.block.nostack")) return;
//Check if player clicked the same type as the clicked block
if (inHand.getType().equals(Material.AIR)) return;
if(!blockType.equals(XMaterial.matchXMaterial(inHand))) return;
if (!blockType.equals(XMaterial.matchXMaterial(inHand))) return;
if (clickAction != Action.RIGHT_CLICK_BLOCK) return;
//Create new stack
event.setCancelled(true);
@ -201,7 +202,7 @@ public class BlockListeners implements Listener {
//remove fullstacks-1 and add back overflow as a new item stack
if (player.getGameMode() != GameMode.CREATIVE) {
if (overflow > 0) {
hand.takeItem(player, fullStacks+1);
hand.takeItem(player, fullStacks + 1);
ItemStack overflowItem = Methods.getSpawnerItem(blockType, overflow);
if (player.getInventory().firstEmpty() == -1) {
block.getWorld().dropItemNaturally(block.getLocation().add(.5, 0, .5), overflowItem);
@ -345,9 +346,10 @@ public class BlockListeners implements Listener {
}
private int getSpawnerAmount(ItemStack item) {
NBTItem nbtItem = new NBTItem(item);
if (nbtItem.hasKey("spawner_stack_size"))
ReadableNBT nbtItem = NBT.readNbt(item);
if (nbtItem.hasTag("spawner_stack_size")) {
return nbtItem.getInteger("spawner_stack_size");
}
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return 1;
if (item.getItemMeta().getDisplayName().contains(":")) {

View File

@ -2,10 +2,8 @@ package com.craftaro.ultimatestacker.listeners;
import com.craftaro.core.compatibility.CompatibleHand;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.nms.Nms;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTCompound;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTEntity;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBT;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.iface.ReadableNBT;
import com.craftaro.core.utils.EntityUtils;
import com.craftaro.ultimatestacker.UltimateStacker;
import com.craftaro.ultimatestacker.api.UltimateStackerApi;
@ -108,7 +106,7 @@ public class SpawnerListeners implements Listener {
if (!Settings.EGGS_CONVERT_SPAWNERS.getBoolean()
|| (event.getItem().hasItemMeta() && event.getItem().getItemMeta().hasDisplayName()
&& !new NBTItem(event.getItem()).hasKey("UC"))) {
&& !NBT.readNbt(event.getItem()).hasTag("UC"))) {
return;
}
@ -126,8 +124,7 @@ public class SpawnerListeners implements Listener {
.replace("MOOSHROOM", "MUSHROOM_COW")
.replace("ZOMBIE_PIGMAN", "PIG_ZOMBIE"));
else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
Nms.getImplementations().getNbt().of(event.getItem()).toString();
NBTCompound entityTag = new NBTItem(event.getItem()).getCompound("EntityTag");
ReadableNBT entityTag = NBT.readNbt(event.getItem()).getCompound("EntityTag");
if (entityTag != null) {
entityType = EntityType.fromName(entityTag.getString("id"));
} else {

View File

@ -148,6 +148,10 @@ public class StackingTask extends BukkitRunnable {
if (!configurationSection.getBoolean("Mobs." + entity.getType().name() + ".Enabled"))
return true;
//Check nametag or custom entity
if ((!stackManager.isStackedEntity(entity) && entity.getCustomName() != null) || plugin.getCustomEntityManager().getCustomEntity(entity) != null)
return true;
// Allow spawn if stack reasons are set and match, or if from a spawner
final String spawnReason = entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").isEmpty()
? entity.getMetadata("US_REASON").get(0).asString() : null;
@ -186,12 +190,6 @@ public class StackingTask extends BukkitRunnable {
return;
}
// If this entity is named or a custom entity skip it.
if (!isStack && (baseEntity.getCustomName() != null && plugin.getCustomEntityManager().getCustomEntity(baseEntity) != null)) {
processed.add(baseEntity.getUniqueId());
return;
}
// Get similar entities around our entity and make sure those entities are both compatible and stackable.
List<LivingEntity> stackableFriends = getSimilarEntitiesAroundEntity(baseEntity, location);

View File

@ -1,8 +1,8 @@
package com.craftaro.ultimatestacker.utils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBT;
import com.craftaro.core.utils.TextUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.ultimatestacker.UltimateStacker;
import com.craftaro.ultimatestacker.api.UltimateStackerApi;
import com.craftaro.ultimatestacker.api.stack.item.StackedItem;
@ -104,9 +104,10 @@ public class Methods {
((BlockStateMeta) meta).setBlockState(cs);
item.setItemMeta(meta);
NBTItem nbtItem = new NBTItem(item);
nbtItem.setInteger("spawner_stack_size", amount);
return nbtItem.getItem();
NBT.modify(item, readableItemNBT -> {
readableItemNBT.setInteger("spawner_stack_size", amount);
});
return item;
}
public static boolean isInt(String number) {

View File

@ -7,7 +7,7 @@
<groupId>com.craftaro</groupId>
<artifactId>UltimateStacker-Parent</artifactId>
<packaging>pom</packaging>
<version>3.1.10</version>
<version>3.3.0</version>
<modules>
<module>UltimateStacker-API</module>
@ -19,7 +19,7 @@
<url>https://craftaro.com/marketplace/product/16</url>
<properties>
<craftaro.coreVersion>3.0.6-SNAPSHOT</craftaro.coreVersion>
<craftaro.coreVersion>3.5.0-SNAPSHOT</craftaro.coreVersion>
<maven.compiler.release>8</maven.compiler.release>
<maven.compiler.target>1.8</maven.compiler.target>
@ -42,8 +42,8 @@
<repositories>
<repository>
<id>craftaro-minecraft-plugins</id>
<url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
<id>songoda-minecraft-plugins</id>
<url>https://repo.songoda.com/repository/minecraft-plugins/</url>
</repository>
<repository>