mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-13 05:44:19 +01:00
Update SongodaCore methods
This commit is contained in:
parent
3230710f76
commit
a22746b9d5
@ -2,7 +2,9 @@ package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.craftaro.core.compatibility.CompatibleHand;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.nms.NmsManager;
|
||||
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.utils.EntityUtils;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
@ -124,13 +126,16 @@ public class SpawnerListeners implements Listener {
|
||||
.replace("MOOSHROOM", "MUSHROOM_COW")
|
||||
.replace("ZOMBIE_PIGMAN", "PIG_ZOMBIE"));
|
||||
else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
String str = NmsManager.getNbt().of(event.getItem()).toString();
|
||||
if (str.contains("minecraft:"))
|
||||
entityType = EntityType.fromName(str.substring(str.indexOf("minecraft:") + 10, str.indexOf("\"}")));
|
||||
else
|
||||
entityType = EntityType.fromName(str.substring(str.indexOf("EntityTag:{id:") + 15, str.indexOf("\"}")));
|
||||
} else
|
||||
Nms.getImplementations().getNbt().of(event.getItem()).toString();
|
||||
NBTCompound entityTag = new NBTItem(event.getItem()).getCompound("EntityTag");
|
||||
if (entityTag != null) {
|
||||
entityType = EntityType.fromName(entityTag.getString("id"));
|
||||
} else {
|
||||
entityType = EntityType.fromName(event.getItem().getItemMeta().getDisplayName().replace(" Spawn Egg", ""));
|
||||
}
|
||||
} else {
|
||||
entityType = ((SpawnEgg) event.getItem().getData()).getSpawnedType();
|
||||
}
|
||||
|
||||
if (!player.hasPermission("ultimatestacker.egg." + entityType.name())) {
|
||||
event.setCancelled(true);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.craftaro.ultimatestacker.listeners.item;
|
||||
|
||||
import com.craftaro.core.nms.NmsManager;
|
||||
import com.craftaro.core.nms.Nms;
|
||||
import com.craftaro.core.nms.world.WorldCore;
|
||||
import com.craftaro.core.world.SWorld;
|
||||
import com.craftaro.third_party.org.apache.commons.lang3.StringUtils;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerApi;
|
||||
@ -8,6 +10,7 @@ import com.craftaro.ultimatestacker.api.stack.item.StackedItem;
|
||||
import com.craftaro.ultimatestacker.api.stack.item.StackedItemManager;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -52,7 +55,7 @@ public class ItemListeners implements Listener {
|
||||
Methods.updateInventory(event.getItem(), event.getInventory());
|
||||
if (event.getInventory().getHolder() instanceof BlockState) {
|
||||
Block invHolder = ((BlockState) event.getInventory().getHolder()).getBlock();
|
||||
NmsManager.getWorld().updateAdjacentComparators(invHolder);
|
||||
Nms.getImplementations().getWorld().updateAdjacentComparators(invHolder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,13 +67,15 @@ public class ItemListeners implements Listener {
|
||||
if (disabledWorlds.stream().anyMatch(worldStr -> event.getEntity().getWorld().getName().equalsIgnoreCase(worldStr)))
|
||||
return;
|
||||
|
||||
if (UltimateStackerApi.getStackedItemManager().isStackedItem(event.getEntity())) return;
|
||||
|
||||
ItemStack itemStack = event.getEntity().getItemStack();
|
||||
|
||||
if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() &&
|
||||
StringUtils.substring(itemStack.getItemMeta().getDisplayName(), 0, 3).equals("***")) {
|
||||
return; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/
|
||||
}
|
||||
|
||||
|
||||
UltimateStackerApi.getStackedItemManager().createStack(event.getEntity(), itemStack.getAmount());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user