forked from Upstream/mmocore
Added 'place-block' and 'break-block' triggers
This commit is contained in:
parent
6e7d6d0b3a
commit
a4477415ed
@ -0,0 +1,23 @@
|
|||||||
|
package net.Indyuce.mmocore.api.player.profess.event.trigger;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
||||||
|
|
||||||
|
public class BlockBrokenTrigger implements EventTriggerHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handles(String event) {
|
||||||
|
return event.startsWith("break-block");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void a(BlockBreakEvent event) {
|
||||||
|
PlayerData player = PlayerData.get(event.getPlayer());
|
||||||
|
if (player.getProfess().hasEventTriggers("break-block"))
|
||||||
|
player.getProfess().getEventTriggers("break-block").getTriggers().forEach(trigger -> trigger.apply(player));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package net.Indyuce.mmocore.api.player.profess.event.trigger;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
||||||
|
|
||||||
|
public class BlockPlacedTrigger implements EventTriggerHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handles(String event) {
|
||||||
|
return event.startsWith("place-block");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void a(BlockPlaceEvent event) {
|
||||||
|
PlayerData player = PlayerData.get(event.getPlayer());
|
||||||
|
if (player.getProfess().hasEventTriggers("place-block"))
|
||||||
|
player.getProfess().getEventTriggers("place-block").getTriggers().forEach(trigger -> trigger.apply(player));
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,8 @@ import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
|||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass.ClassOption;
|
import net.Indyuce.mmocore.api.player.profess.PlayerClass.ClassOption;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.AttackEventTrigger;
|
import net.Indyuce.mmocore.api.player.profess.event.trigger.AttackEventTrigger;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.event.trigger.BlockBrokenTrigger;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.event.trigger.BlockPlacedTrigger;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.ClassChosenEventTrigger;
|
import net.Indyuce.mmocore.api.player.profess.event.trigger.ClassChosenEventTrigger;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.LevelUpEventTrigger;
|
import net.Indyuce.mmocore.api.player.profess.event.trigger.LevelUpEventTrigger;
|
||||||
|
|
||||||
@ -41,6 +43,8 @@ public class ClassManager extends MMOManager {
|
|||||||
registerEvent(new LevelUpEventTrigger());
|
registerEvent(new LevelUpEventTrigger());
|
||||||
registerEvent(new AttackEventTrigger());
|
registerEvent(new AttackEventTrigger());
|
||||||
registerEvent(new ClassChosenEventTrigger());
|
registerEvent(new ClassChosenEventTrigger());
|
||||||
|
registerEvent(new BlockBrokenTrigger());
|
||||||
|
registerEvent(new BlockPlacedTrigger());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvent(EventTriggerHandler handler) {
|
public void registerEvent(EventTriggerHandler handler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user