Skip to content

Commit

Permalink
Update to Sponge API 5.0.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthick committed Jul 9, 2016
1 parent d0d9daa commit 94080e4
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 16 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* along with ProtectionPerms. If not, see <http://www.gnu.org/licenses/>.
*/

group 'zerthick.github.io'
version '0.2.0'

apply plugin: 'java'
plugins {
id 'org.spongepowered.plugin' version '0.6'
id 'java'
}

sourceCompatibility = 1.8
group 'io.github.zerthick'

repositories {
mavenCentral()
Expand All @@ -33,5 +33,5 @@ repositories {
}

dependencies {
compile 'org.spongepowered:spongeapi:4.1.0-SNAPSHOT'
compile 'org.spongepowered:spongeapi:5.0.0-SNAPSHOT'
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;

@Plugin(id = "ProtectionPerms", name = "ProtectionPerms", version = "0.2.0")
@Plugin(id = "protectionperms",
name = "ProtectionPerms",
version = "0.3.0",
description = "A simple player protection and control plugin.")
public class ProtectionPermsMain {

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.github.zerthick.protectionperms.events.listeners.item.interactBlockEvent;

import org.spongepowered.api.data.type.HandTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
Expand All @@ -33,8 +34,22 @@
public class PrimaryBlockListener {

@Listener
public void onInteractBlockPrimary(InteractBlockEvent.Primary event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand();
public void onInteractBlockPrimaryMain(InteractBlockEvent.Primary.MainHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.MAIN_HAND);
if(itemStackOptional.isPresent()) {
String blockName = event.getTargetBlock().getState().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
if (!player.hasPermission("protectionPerms.item.use." + itemName + ".on." + blockName + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to primary use " + itemName + " on " + blockName + '!'));
}
}
}

@Listener
public void onInteractBlockPrimaryOff(InteractBlockEvent.Primary.OffHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.OFF_HAND);
if(itemStackOptional.isPresent()) {
String blockName = event.getTargetBlock().getState().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.github.zerthick.protectionperms.events.listeners.item.interactBlockEvent;

import org.spongepowered.api.data.type.HandTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
Expand All @@ -33,8 +34,22 @@
public class SecondaryBlockListener {

@Listener
public void onInteractBlockSecondary(InteractBlockEvent.Secondary event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand();
public void onInteractBlockSecondaryMain(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.MAIN_HAND);
if(itemStackOptional.isPresent()) {
String blockName = event.getTargetBlock().getState().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
if (!player.hasPermission("protectionPerms.item.use." + itemName + ".on." + blockName + ".secondary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to secondary use " + itemName + " on " + blockName + '!'));
}
}
}

@Listener
public void onInteractBlockSecondaryOff(InteractBlockEvent.Secondary.OffHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.OFF_HAND);
if(itemStackOptional.isPresent()) {
String blockName = event.getTargetBlock().getState().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.github.zerthick.protectionperms.events.listeners.item.interactEntityEvent;

import org.spongepowered.api.data.type.HandTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.InteractEntityEvent;
Expand All @@ -33,8 +34,22 @@
public class PrimaryEntityListener {

@Listener
public void onInteractEntityPrimary(InteractEntityEvent.Primary event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand();
public void onInteractEntityPrimaryMain(InteractEntityEvent.Primary.MainHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.MAIN_HAND);
if(itemStackOptional.isPresent()) {
String entityName = event.getTargetEntity().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
if (!player.hasPermission("protectionPerms.item.use." + itemName + ".on." + entityName + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to primary use " + itemName + " on " + entityName + '!'));
}
}
}

@Listener
public void onInteractEntityPrimaryOff(InteractEntityEvent.Primary.OffHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.OFF_HAND);
if(itemStackOptional.isPresent()) {
String entityName = event.getTargetEntity().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.github.zerthick.protectionperms.events.listeners.item.interactEntityEvent;

import org.spongepowered.api.data.type.HandTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.InteractEntityEvent;
Expand All @@ -33,8 +34,22 @@
public class SecondaryEntityListener {

@Listener
public void onInteractEntitySecondary(InteractEntityEvent.Secondary event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand();
public void onInteractEntitySecondaryMain(InteractEntityEvent.Secondary.MainHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.MAIN_HAND);
if(itemStackOptional.isPresent()) {
String entityName = event.getTargetEntity().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
if (!player.hasPermission("protectionPerms.item.use." + itemName + ".on." + entityName + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to secondary use " + itemName + " on " + entityName + '!'));
}
}
}

@Listener
public void onInteractEntitySecondaryOff(InteractEntityEvent.Secondary.OffHand event, @First Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(HandTypes.OFF_HAND);
if(itemStackOptional.isPresent()) {
String entityName = event.getTargetEntity().getType().getName();
String itemName = itemStackOptional.get().getItem().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class StartListener {

@Listener
public void onItemUse(UseItemStackEvent.Start event, @First Player player) {
String itemName = event.getItemStackInUse().getOriginal().getType().getName();
String itemName = event.getItemStackInUse().getType().getName();
if (!player.hasPermission("protectionPerms.item.use." + itemName)) {
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.RED, "You don't have permission to use " + itemName + '!'));
Expand Down

0 comments on commit 94080e4

Please sign in to comment.