-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Zerthick/API-7
Api 7
- Loading branch information
Showing
26 changed files
with
199 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 18 additions & 10 deletions
28
...n/java/io/github/zerthick/protectionperms/events/listeners/entity/HookEntityListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
package io.github.zerthick.protectionperms.events.listeners.entity; | ||
|
||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.entity.EntityType; | ||
import org.spongepowered.api.event.Listener; | ||
import org.spongepowered.api.event.action.FishingEvent; | ||
import org.spongepowered.api.event.filter.cause.First; | ||
import org.spongepowered.api.event.cause.EventContextKeys; | ||
import org.spongepowered.api.text.Text; | ||
import org.spongepowered.api.text.chat.ChatTypes; | ||
import org.spongepowered.api.text.format.TextColors; | ||
|
||
public class HookEntityListener { | ||
|
||
@Listener | ||
public void onEntityHook(FishingEvent.HookEntity event, @First Player player) { | ||
public void onEntityHook(FishingEvent.HookEntity event) { | ||
|
||
player.sendMessage(Text.of("Test")); | ||
event.getContext().get(EventContextKeys.OWNER).ifPresent(user -> | ||
|
||
user.getPlayer().ifPresent(player -> { | ||
|
||
EntityType entityType = event.getTargetEntity().getType(); | ||
String entityId = entityType.getId(); | ||
if (!player.hasPermission("protectionperms.entity.hook." + entityId)) { | ||
event.setCancelled(true); | ||
player.sendMessage(ChatTypes.ACTION_BAR, | ||
Text.of(TextColors.RED, "You don't have permission to hook " + entityType.getName() + "s!")); | ||
} | ||
|
||
}) | ||
|
||
); | ||
|
||
String entityId = event.getTargetEntity().getType().getId(); | ||
if (!player.hasPermission("protectionperms.entity.hook." + entityId)) { | ||
event.setCancelled(true); | ||
player.sendMessage(ChatTypes.ACTION_BAR, | ||
Text.of(TextColors.RED, "You don't have permission to hook " + entityId + "s!")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.