mirror of
https://github.com/Stefan-5422/School-Programming-Projekt-022022.git
synced 2026-09-04 00:46:01 +02:00
Minor updates
xD
This commit is contained in:
@@ -49,6 +49,6 @@ public class ItemBehaviour extends Component {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
parent.removeListener(dataKey + "Changed", this, this::itemChanged);
|
||||
parent.removeListener(dataKey + "Changed", this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class OfferBehaviour extends Component {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.parent.removeListener("itemAccepted", this, this::itemAccepted);
|
||||
this.parent.removeListener("placed", this,this::placed);
|
||||
this.parent.removeListener("itemAccepted", this);
|
||||
this.parent.removeListener("placed", this);
|
||||
|
||||
receiver = null;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public class RecieveBehaviour extends Component {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.parent.removeListener("offerItem", this, this::receive);
|
||||
this.parent.removeListener("placed", this, this::placed);
|
||||
this.parent.removeListener("offerItem", this);
|
||||
this.parent.removeListener("placed", this);
|
||||
|
||||
offerer = null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.yes.yes.behaviours;
|
||||
|
||||
import com.yes.yes.utils.BlockContainer;
|
||||
import com.yes.yes.utils.Component;
|
||||
import com.yes.yes.utils.Coordinate;
|
||||
import com.yes.yes.utils.Entity;
|
||||
|
||||
public class TestBehaviour extends Component {
|
||||
@@ -41,6 +40,6 @@ public class TestBehaviour extends Component {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
parent.removeListener("placed", this, this::onNeighborPlaced);
|
||||
parent.removeListener("placed", this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public abstract class Entity extends javafx.scene.Group {
|
||||
handler.addListener(eventName, object, function);
|
||||
}
|
||||
|
||||
public final <T> void removeListener(String eventName, Object object, Consumer<T> function) {
|
||||
handler.removeListener(eventName, object, function);
|
||||
public final <T> void removeListener(String eventName, Object object) {
|
||||
handler.removeListener(eventName, object);
|
||||
}
|
||||
|
||||
public final void trigger(String eventName, Object parameter) {
|
||||
|
||||
@@ -15,12 +15,12 @@ public class EventHandler {
|
||||
events.get(eventName).put(object, (e) -> function.accept((T) e));
|
||||
}
|
||||
|
||||
public <T> void removeListener(String eventName, Object object, Consumer<T> function) throws IllegalArgumentException {
|
||||
public <T> void removeListener(String eventName, Object object) throws IllegalArgumentException {
|
||||
//NOTE: This needs to be called otherwise memory leak
|
||||
if (!events.containsKey(eventName)) {
|
||||
throw new IllegalArgumentException("Event " + eventName + " does not exist!");
|
||||
}
|
||||
//noinspection SuspiciousMethodCalls
|
||||
|
||||
events.get(eventName).remove(object);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public class GlobalEventHandler {
|
||||
}
|
||||
|
||||
public static <T> void removeListener(String eventName, Object object, Consumer<T> function) {
|
||||
handler.removeListener(eventName, object, function);
|
||||
handler.removeListener(eventName, object);
|
||||
}
|
||||
|
||||
public static void trigger(String eventName, Object parameter) {
|
||||
|
||||
Reference in New Issue
Block a user