From d83385a24c00797afdcb7e0a97c6f3dcd1616dd9 Mon Sep 17 00:00:00 2001 From: BlackBeltPanda Date: Wed, 12 Aug 2020 10:28:30 -0400 Subject: [PATCH] 5.2.1 Version Bump - Add basic DuctPlaceEvent and DuctBreakEvent --- pom.xml | 2 +- .../transportpipes/api/DuctBreakEvent.java | 29 +++++++++++++++++++ .../transportpipes/api/DuctPlaceEvent.java | 29 +++++++++++++++++++ .../transportpipes/listener/DuctListener.java | 8 +++++ src/main/resources/plugin.yml | 2 +- 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/robotricker/transportpipes/api/DuctBreakEvent.java create mode 100644 src/main/java/de/robotricker/transportpipes/api/DuctPlaceEvent.java diff --git a/pom.xml b/pom.xml index 519b1bd9..324d5f4b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.robotricker transportpipes - 5.2.0-SNAPSHOT + 5.2.1-SNAPSHOT jar TransportPipes diff --git a/src/main/java/de/robotricker/transportpipes/api/DuctBreakEvent.java b/src/main/java/de/robotricker/transportpipes/api/DuctBreakEvent.java new file mode 100644 index 00000000..66326593 --- /dev/null +++ b/src/main/java/de/robotricker/transportpipes/api/DuctBreakEvent.java @@ -0,0 +1,29 @@ +package de.robotricker.transportpipes.api; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class DuctBreakEvent extends Event { + + Player player; + private static final HandlerList handlers = new HandlerList(); + + public DuctBreakEvent(Player player) { + super(); + this.player = player; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + public Player getPlayer() { + return player; + } +} \ No newline at end of file diff --git a/src/main/java/de/robotricker/transportpipes/api/DuctPlaceEvent.java b/src/main/java/de/robotricker/transportpipes/api/DuctPlaceEvent.java new file mode 100644 index 00000000..ba4ea470 --- /dev/null +++ b/src/main/java/de/robotricker/transportpipes/api/DuctPlaceEvent.java @@ -0,0 +1,29 @@ +package de.robotricker.transportpipes.api; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class DuctPlaceEvent extends Event { + + Player player; + private static final HandlerList handlers = new HandlerList(); + + public DuctPlaceEvent(Player player) { + super(); + this.player = player; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + public Player getPlayer() { + return player; + } +} \ No newline at end of file diff --git a/src/main/java/de/robotricker/transportpipes/listener/DuctListener.java b/src/main/java/de/robotricker/transportpipes/listener/DuctListener.java index 3cbc536b..06de2543 100644 --- a/src/main/java/de/robotricker/transportpipes/listener/DuctListener.java +++ b/src/main/java/de/robotricker/transportpipes/listener/DuctListener.java @@ -34,6 +34,8 @@ import de.robotricker.transportpipes.PlayerSettingsService; import de.robotricker.transportpipes.ThreadService; import de.robotricker.transportpipes.TransportPipes; +import de.robotricker.transportpipes.api.DuctBreakEvent; +import de.robotricker.transportpipes.api.DuctPlaceEvent; import de.robotricker.transportpipes.config.GeneralConf; import de.robotricker.transportpipes.config.LangConf; import de.robotricker.transportpipes.duct.Duct; @@ -279,6 +281,9 @@ else if (placeBlock == null || (clickedDuct != null && !manualPlaceable)) { globalDuctManager.updateNeighborDuctsInRenderSystems(duct, true); decreaseHandItem(interaction.p, interaction.hand); + + DuctPlaceEvent event = new DuctPlaceEvent(interaction.p); + Bukkit.getPluginManager().callEvent(event); } else { LangConf.Key.PROTECTED_BLOCK.sendMessage(interaction.p); } @@ -321,6 +326,9 @@ else if (placeBlock == null || (clickedDuct != null && !manualPlaceable)) { globalDuctManager.updateNeighborDuctsConnections(clickedDuct); globalDuctManager.updateNeighborDuctsInRenderSystems(clickedDuct, true); globalDuctManager.playDuctDestroyActions(clickedDuct, interaction.p); + + DuctBreakEvent event = new DuctBreakEvent(interaction.p); + Bukkit.getPluginManager().callEvent(event); } interaction.cancel = true; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0ea171de..1810125d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ version: ${project.versionCode} authors: [RoboTricker, BlackBeltPanda] main: ${project.groupId}.${project.artifactId}.${project.name} depend: [ProtocolLib] -api-version: 1.15 +api-version: 1.16 permissions: transportpipes.*: children: