Removes debug printouts.
Fixes issue where add/removeListener functions could fail on null input.
@@ -543,13 +543,9 @@ public class Screen {
}
for (final EventListener listener : temp.getEventListeners()) {
- if (listener == null) {
- System.out.println("Found null event listener on component: " + temp);
- } else {
removeListener(listener);
}
}
- }
// Reset all of the tiles where the component used to be.
final int startX = component.getTiles().getXPosition();
@@ -593,6 +589,10 @@ public class Screen {
* If an event listener isn't supported by this function.
*/
public void addListener(final EventListener ... eventListeners) {
+ if (eventListeners == null) {
+ return;
+ }
+
for (final EventListener listener : eventListeners) {
if (listener == null) {
continue;
@@ -614,19 +614,16 @@ public class Screen {
// Add the listener to the canvas:
if (listener instanceof KeyListener) {
canvas.addKeyListener((KeyListener) listener);
- System.out.println("Added KeyListener (Screen): " + listener.hashCode());
continue;
}
if (listener instanceof MouseListener) {
canvas.addMouseListener((MouseListener) listener);
- System.out.println("Added MouseListener (Screen): " + listener.hashCode());
continue;
}
if (listener instanceof MouseMotionListener) {
canvas.addMouseMotionListener((MouseMotionListener) listener);
- System.out.println("Added MouseMotionListener (Screen): " + listener.hashCode());
continue;
}
@@ -644,6 +641,10 @@ public class Screen {
* If an event listener isn't supported by this function.
*/
public void removeListener(final EventListener ... eventListeners) {
+ if (eventListeners == null) {
+ return;
+ }
+
for (final EventListener listener : eventListeners) {
if (listener == null) {
continue;
@@ -651,19 +652,16 @@ public class Screen {
if (listener instanceof KeyListener) {
canvas.removeKeyListener((KeyListener) listener);
- System.out.println("Removed KeyListener (Screen): " + listener.hashCode());
continue;
}
if (listener instanceof MouseListener) {
canvas.removeMouseListener((MouseListener) listener);
- System.out.println("Removed MouseListener (Screen): " + listener.hashCode());
continue;
}
if (listener instanceof MouseMotionListener) {
canvas.removeMouseMotionListener((MouseMotionListener) listener);
- System.out.println("Removed MouseMotionListener (Screen): " + listener.hashCode());
continue;
}
