diff --git a/build.gradle b/build.gradle index 00c718c..291600a 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ plugins { } group 'io.github.zerthick' +version '1.1.0' repositories { mavenCentral() @@ -33,13 +34,13 @@ repositories { } } -spongestart { +spongestart{ eula true - minecraft '1.11.2' + minecraft '1.12.2' type 'stable' } dependencies { - compile 'org.spongepowered:spongeapi:6.0.0' + compile 'org.spongepowered:spongeapi:7.0.0' } diff --git a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java index 3697e64..c14609d 100644 --- a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java +++ b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java @@ -56,6 +56,8 @@ public PluginContainer getInstance() { @Listener public void onServerInit(GameInitializationEvent event) { + DebugLogger.getInstance().setLogger(logger); + //Register Event Listeners ListenerRegister.registerListeners(this); } diff --git a/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/ItemListenerManager.java b/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/ItemListenerManager.java index 4e9f060..a45f6d0 100644 --- a/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/ItemListenerManager.java +++ b/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/ItemListenerManager.java @@ -20,6 +20,10 @@ package io.github.zerthick.protectionperms.events.listeners.item; import io.github.zerthick.protectionperms.events.listeners.ListenerManager; +import io.github.zerthick.protectionperms.events.listeners.item.interactBlockEvent.PrimaryBlockListener; +import io.github.zerthick.protectionperms.events.listeners.item.interactBlockEvent.SecondaryBlockListener; +import io.github.zerthick.protectionperms.events.listeners.item.interactEntityEvent.PrimaryEntityListener; +import io.github.zerthick.protectionperms.events.listeners.item.interactEntityEvent.SecondaryEntityListener; import java.util.LinkedList; import java.util.List; @@ -30,19 +34,20 @@ public class ItemListenerManager implements ListenerManager{ public ItemListenerManager() { listeners = new LinkedList<>(); - //listeners.add(new PrimaryBlockListener()); - //listeners.add(new SecondaryBlockListener()); - //listeners.add(new PrimaryEntityListener()); - //listeners.add(new SecondaryEntityListener()); - //listeners.add(new UseItemListener()); - //listeners.add(new DropItemDispenseListener()); - //listeners.add(new DropItemDeathListener()); - //listeners.add(new CraftItemListener()); + listeners.add(new PrimaryBlockListener()); + listeners.add(new SecondaryBlockListener()); + listeners.add(new PrimaryEntityListener()); + listeners.add(new SecondaryEntityListener()); + listeners.add(new UseItemListener()); + listeners.add(new DropItemDispenseListener()); + listeners.add(new DropItemDeathListener()); + listeners.add(new CraftItemListener()); //*listeners.add(new EnchantItemListener()); - //listeners.add(new SmeltItemListener()); + listeners.add(new SmeltItemListener()); //*listeners.add(new ForgeItemListener()); //*listeners.add(new BrewItemListener()); listeners.add(new EquipItemListener()); + //listeners.add(new PickupItemListener()); } @Override diff --git a/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/PickupItemListener.java b/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/PickupItemListener.java new file mode 100644 index 0000000..8cf2c2a --- /dev/null +++ b/src/main/java/io/github/zerthick/protectionperms/events/listeners/item/PickupItemListener.java @@ -0,0 +1,30 @@ +package io.github.zerthick.protectionperms.events.listeners.item; + +import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.event.Listener; +import org.spongepowered.api.event.filter.cause.Root; +import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; +import org.spongepowered.api.item.ItemType; +import org.spongepowered.api.item.inventory.ItemStackSnapshot; +import org.spongepowered.api.text.Text; +import org.spongepowered.api.text.chat.ChatTypes; +import org.spongepowered.api.text.format.TextColors; + +public class PickupItemListener { + + @Listener + public void onItemDrop(ChangeInventoryEvent.Pickup event, @Root Player player) { + + event.getTransactions().forEach(slotTransaction -> { + ItemStackSnapshot stackSnapshot = slotTransaction.getFinal(); + + ItemType itemType = stackSnapshot.getType(); + String itemId = itemType.getId(); + + if (!player.hasPermission("protectionperms.item.pickup." + itemId)) { + event.setCancelled(true); + player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to pick up " + itemType.getName() + '!')); + } + }); + } +}