mirror of
https://github.com/Stefan-5422/School-Programming-Projekt-022022.git
synced 2026-09-04 00:46:01 +02:00
Fix method signature of removeListener method
This commit is contained in:
@@ -53,7 +53,7 @@ public abstract class Entity extends javafx.scene.Group {
|
||||
handler.addListener(eventName, function);
|
||||
}
|
||||
|
||||
public final void removeListener(String eventName, Function<Object, Void> function) {
|
||||
public final <T> void removeListener(String eventName, Consumer<T> function) {
|
||||
handler.removeListener(eventName, function);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class EventHandler {
|
||||
events.get(eventName).add((e) -> function.accept((T) e));
|
||||
}
|
||||
|
||||
public void removeListener(String eventName, Function<Object, Void> function) throws IllegalArgumentException {
|
||||
public <T> void removeListener(String eventName, Consumer<T> function) throws IllegalArgumentException {
|
||||
//NOTE: This needs to be called otherwise memory leak
|
||||
if (!events.containsKey(eventName)) {
|
||||
throw new IllegalArgumentException("Event " + eventName + " does not exist!");
|
||||
|
||||
@@ -13,7 +13,7 @@ public class GlobalEventHandler {
|
||||
handler.addListener(eventName, function);
|
||||
}
|
||||
|
||||
public static void removeListener(String eventName, Function<Object, Void> function) {
|
||||
public static <T> void removeListener(String eventName, Consumer<T> function) {
|
||||
handler.removeListener(eventName, function);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ public class Chunk extends GridPane {
|
||||
}
|
||||
|
||||
public void removeEntity(Coordinate pos) {
|
||||
this.getChildren().remove(data[pos.x + pos.y * CHUNK_SIZE]);
|
||||
Entity entity = getEntity(pos);
|
||||
this.getChildren().remove(entity);
|
||||
data[pos.x + pos.y * CHUNK_SIZE] = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user