mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
Delete EventTrait
This commit is contained in:
parent
52547c5bd6
commit
0b6c7b0b0e
@ -1,31 +1,30 @@
|
|||||||
package net.minestom.server.event;
|
package net.minestom.server.event;
|
||||||
|
|
||||||
import net.minestom.server.event.handler.EventHandler;
|
import net.minestom.server.event.handler.EventHandler;
|
||||||
import net.minestom.server.event.trait.EventTrait;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class EventNode<T extends EventTrait> {
|
public class EventNode<T extends Event> {
|
||||||
|
|
||||||
private EventNode() {
|
private EventNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EventNode<?> create() {
|
public static EventNode<Event> create() {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends EventTrait, E> EventNode<T> conditional(Class<T> eventType,
|
|
||||||
Class<E> handlerType,
|
|
||||||
Predicate<E> predicate) {
|
|
||||||
return new EventNode<>();
|
return new EventNode<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends EventTrait> EventNode<T> conditional(Class<T> eventType) {
|
public static <T extends Event, E> EventNode<T> conditional(Class<T> eventType,
|
||||||
|
Class<E> handlerType,
|
||||||
|
Predicate<E> predicate) {
|
||||||
return new EventNode<>();
|
return new EventNode<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends EventTrait> EventNode<T> unique(Class<T> eventType, EventHandler handler) {
|
public static <T extends Event> EventNode<T> conditional(Class<T> eventType) {
|
||||||
|
return new EventNode<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Event> EventNode<T> unique(Class<T> eventType, EventHandler handler) {
|
||||||
return new EventNode<>();
|
return new EventNode<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package net.minestom.server.event.trait;
|
package net.minestom.server.event.trait;
|
||||||
|
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
|
import net.minestom.server.event.Event;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface EntityEvent extends EventTrait {
|
public interface EntityEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the entity of this event.
|
* Gets the entity of this event.
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
package net.minestom.server.event.trait;
|
|
||||||
|
|
||||||
import net.minestom.server.event.Event;
|
|
||||||
|
|
||||||
public interface EventTrait extends Event {
|
|
||||||
}
|
|
@ -1,8 +1,9 @@
|
|||||||
package net.minestom.server.event.trait;
|
package net.minestom.server.event.trait;
|
||||||
|
|
||||||
|
import net.minestom.server.event.Event;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface ItemEvent extends EventTrait {
|
public interface ItemEvent extends Event {
|
||||||
@NotNull ItemStack getItemStack();
|
@NotNull ItemStack getItemStack();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package net.minestom.server.event.trait;
|
package net.minestom.server.event.trait;
|
||||||
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.event.Event;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface PlayerEvent extends EventTrait {
|
public interface PlayerEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player.
|
* Gets the player.
|
||||||
|
@ -142,6 +142,10 @@ public class PlayerInit {
|
|||||||
.handler(playerTickEvent -> System.out.println("Player tick!"))
|
.handler(playerTickEvent -> System.out.println("Player tick!"))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
var empty = EventNode.create();
|
||||||
|
empty.addListener(PlayerMoveEvent.class, (event) -> {
|
||||||
|
});
|
||||||
|
|
||||||
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
||||||
globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> {
|
globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> {
|
||||||
final Entity source = event.getEntity();
|
final Entity source = event.getEntity();
|
||||||
|
Loading…
Reference in New Issue
Block a user