Skip to content

Commit

Permalink
Bump to version 1.1.0, add unfinished PickupItem Listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthick committed Jan 2, 2018
1 parent a0a8d8c commit 5ae344f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ plugins {
}

group 'io.github.zerthick'
version '1.1.0'

repositories {
mavenCentral()
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public PluginContainer getInstance() {
@Listener
public void onServerInit(GameInitializationEvent event) {

DebugLogger.getInstance().setLogger(logger);

//Register Event Listeners
ListenerRegister.registerListeners(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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() + '!'));
}
});
}
}

0 comments on commit 5ae344f

Please sign in to comment.