mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Fixed thread flood in Vending Machines
This commit is contained in:
parent
a14ff42fe6
commit
15e24f3114
@ -6,8 +6,6 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
@ -17,6 +15,7 @@ import com.eu.habbo.util.pathfinding.Rotation;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
public class InteractionVendingMachine extends InteractionDefault {
|
||||
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||
@ -33,12 +32,18 @@ public class InteractionVendingMachine extends InteractionDefault {
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (client != null) {
|
||||
if (client == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomTile tile = this.getRequiredTile(client.getHabbo(), room);
|
||||
|
||||
if (tile != null) {
|
||||
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
|
||||
if (tile != null &&
|
||||
tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||
if (!this.getExtradata().equals("0") || this.getExtradata().length() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
|
||||
room.updateHabbo(client.getHabbo());
|
||||
this.rotateToMachine(client.getHabbo().getRoomUnit());
|
||||
@ -51,16 +56,7 @@ public class InteractionVendingMachine extends InteractionDefault {
|
||||
this.setExtradata("1");
|
||||
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
this.giveVendingMachineItem(client.getHabbo(), room);
|
||||
|
||||
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||
}, 500);
|
||||
}
|
||||
this.runGiveItemThread(client, room);
|
||||
} else {
|
||||
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
|
||||
for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
|
||||
@ -84,15 +80,21 @@ public class InteractionVendingMachine extends InteractionDefault {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
|
||||
Emulator.getThreading().run(() -> client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
|
||||
if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
|
||||
this.rotateToMachine(client.getHabbo().getRoomUnit());
|
||||
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||
}
|
||||
|
||||
this.runGiveItemThread(client, room);
|
||||
}, 300)), 250);
|
||||
}, null));
|
||||
}
|
||||
}
|
||||
|
||||
private void runGiveItemThread(GameClient client, Room room) {
|
||||
try {
|
||||
Emulator.getThreading().run(() -> {
|
||||
ScheduledFuture thread = Emulator.getThreading().run(() -> {
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
this.giveVendingMachineItem(client.getHabbo(), room);
|
||||
|
||||
@ -100,16 +102,15 @@ public class InteractionVendingMachine extends InteractionDefault {
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||
}, 500).get();
|
||||
}, 500);
|
||||
|
||||
if (thread.isDone()) {
|
||||
thread.get();
|
||||
}
|
||||
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 300));
|
||||
}, 250);
|
||||
}, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user