Remove the return;
Code:@Override public int process() { ticks++; if (ticks >= 500) this.stop(); return 1; }
|
Here's my DoubleExperience.Java
I really can't see why it's spamming this none stop, the code originally was lacking a 'return;' after the final string but that has apparently done nothing.. Any ideas?
Code:public class DoubleExperience extends Event { private int ticks = 0; @Override public boolean start() { World.sendGlobalMessage("<img=1><col=ff0000>[EVENT]: Double Experience is now active for 30 minutes."); return true; } @Override public boolean preStartupCheck() { return true; } @Override public int process() { ticks++; if (ticks >= 500) stop(); return 1; } @Override public void stop() { World.sendGlobalMessage("<img=1><col=ff0000>[EVENT]: Double Experience has now ended."); return; } }
Remove the return;
Code:@Override public int process() { ticks++; if (ticks >= 500) this.stop(); return 1; }
post the event class
I tried this but i was getting an error saying thatmust return a result?Code:public int process() {
Sorry is this what you're meaning? This is the EventManager.java
Code://Getters and setters /** * Gets the delay. * @return The delay. */ public int getEventDelay() { return delay; } /** * Adds delay the the event processing. * @param delay The event. */ public void addEventDelay(int delay) { this.delay += delay; } /** * Sets the delay. * @param delay The delay. */ public void setEventDelay(int delay) { this.delay = delay; } /** * Sets the current event and stops the previous one. * @param event {@link Event} The event. * @return */ public boolean setEvent(Event event) { forceStop(); if (!event.start()) return false; this.event = event; return true; } /** * Gets the {@link Event} event. * @return the event. */ public Event getEvent() { return event; } /** * Starts event boss timer. */ public void appendTimer() { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { switch (Utility.random(2)) { case 0: setEvent(new BossEvent()); eventAmount[1]++; System.out.println("Exectuing Event: " + "BossEvent: #" + eventAmount[0]); break; case 1: setEvent(new DoubleGold()); eventAmount[2]++; System.out.println("Exectuing Event: " + "DoubleGold: #" + eventAmount[1]); break; case 2: setEvent(new DoubleExperience()); eventAmount[3]++; System.out.println("Exectuing Event: " + "DoubleExperience: #" + eventAmount[2]); break; default: setEvent(new BossEvent()); eventAmount[1]++; System.out.println("Exectuing Event: " + "BossEvent: #" + eventAmount[0]); } } }, 120 * 60 * 1000, 120 * 60 * 1000); //Execute every 2 hours. } }
Might be because you need super.stop() i cant tell you for sure without looking at the event code, what base is it?
Here's my Event.class thought it's saying that there's no source file attached? And it's appearing in eclipse in a plain text style..
Code:// Compiled from Event.java (version 1.8 : 52.0, super bit) public abstract class com.mayhem.rs2.content.event.Event { // Method descriptor #6 ()V // Stack: 1, Locals: 1 public Event(); 0 aload_0 [this] 1 invokespecial java.lang.Object() [8] 4 return Line numbers: [pc: 0, line: 10] Local variable table: [pc: 0, pc: 5] local: this index: 0 type: com.mayhem.rs2.content.event.Event // Method descriptor #15 ()Z public abstract boolean start(); // Method descriptor #15 ()Z public abstract boolean preStartupCheck(); // Method descriptor #18 ()I public abstract int process(); // Method descriptor #6 ()V public abstract void stop(); // Method descriptor #21 (Lcom/mayhem/rs2/entity/World;I)V // Stack: 2, Locals: 3 protected final void setDelay(com.mayhem.rs2.entity.World world, int delay); 0 invokestatic com.mayhem.rs2.entity.World.getEventManager() : com.mayhem.rs2.content.event.EventManager [22] 3 iload_2 [delay] 4 invokevirtual com.mayhem.rs2.content.event.EventManager.setEventDelay(int) : void [28] 7 return Line numbers: [pc: 0, line: 26] [pc: 7, line: 27] Local variable table: [pc: 0, pc: 8] local: this index: 0 type: com.mayhem.rs2.content.event.Event [pc: 0, pc: 8] local: world index: 1 type: com.mayhem.rs2.entity.World [pc: 0, pc: 8] local: delay index: 2 type: int // Method descriptor #39 (Ljava/lang/String;)V // Stack: 3, Locals: 2 public void sendMessage(java.lang.String message); 0 new java.lang.StringBuilder [40] 3 dup 4 ldc <String "<img=1><col=ff0000>[EVENT]: "> [42] 6 invokespecial java.lang.StringBuilder(java.lang.String) [44] 9 aload_1 [message] 10 invokevirtual java.lang.StringBuilder.append(java.lang.String) : java.lang.StringBuilder [46] 13 ldc <String "</col>"> [50] 15 invokevirtual java.lang.StringBuilder.append(java.lang.String) : java.lang.StringBuilder [46] 18 invokevirtual java.lang.StringBuilder.toString() : java.lang.String [52] 21 invokestatic com.mayhem.rs2.entity.World.sendGlobalMessage(java.lang.String) : void [56] 24 return Line numbers: [pc: 0, line: 30] [pc: 24, line: 31] Local variable table: [pc: 0, pc: 25] local: this index: 0 type: com.mayhem.rs2.content.event.Event [pc: 0, pc: 25] local: message index: 1 type: java.lang.String }
I can't tell based off that but i'll take a guess. Even though you called the stop method, its still looping through process so there has to be a way to stop it. Try returning -1.
Also post your whole eventmanager class. I wanna see how the process method is called.Code:@Override public int process() { ticks++; if (ticks >= 500) { stop(); return -1; } return 1; }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |