Refactored bot wired.

This commit is contained in:
necmi 2020-07-10 21:18:45 -04:00 committed by Harmonic
parent a7e70d2061
commit 4c27917273
7 changed files with 72 additions and 74 deletions

View File

@ -68,12 +68,13 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
List<Bot> bots = room.getBots(this.botName);
if (bots.size() > 1) {
if (bots.size() != 1) {
return false;
}
for (Bot bot : bots) {
Bot bot = bots.get(0);
bot.setFigure(this.botLook);
}
return true;
}

View File

@ -86,15 +86,14 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null) {
List<Bot> bots = room.getBots(this.botName);
if (bots.size() > 1) {
return false;
}
for (Bot bot : bots) {
if (this.mode == 1)
if (habbo != null && bots.size() == 1) {
Bot bot = bots.get(0);
if (this.mode == 1) {
bot.startFollowingHabbo(habbo);
else
} else {
bot.stopFollowingHabbo();
}

View File

@ -88,13 +88,11 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null) {
List<Bot> bots = room.getBots(this.botName);
if (bots.size() > 1) {
return false;
}
for (Bot bot : bots) {
if (habbo != null && bots.size() == 1) {
Bot bot = bots.get(0);
List<Runnable> tasks = new ArrayList<>();
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
@ -105,7 +103,6 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
failedReach.add(() -> tasks.forEach(Runnable::run));
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
}
return true;
}

View File

@ -83,16 +83,21 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
.replace(Emulator.getTexts().getValue("wired.variable.pixels"), habbo.getHabboInfo().getPixels() + "")
.replace(Emulator.getTexts().getValue("wired.variable.points"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "");
}
List<Bot> bots = room.getBots(this.botName);
if (bots.size() > 1) {
if (bots.size() != 1) {
return false;
}
for (Bot bot : bots) {
if (this.mode == 1)
Bot bot = bots.get(0);
if (this.mode == 1) {
bot.shout(message);
else
} else {
bot.talk(message);
}
return true;
}

View File

@ -103,19 +103,22 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
.replace(Emulator.getTexts().getValue("wired.variable.points"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "");
List<Bot> bots = room.getBots(this.botName);
if (bots.size() > 1) {
if (bots.size() != 1) {
return false;
}
for (Bot bot : bots) {
Bot bot = bots.get(0);
if (this.mode == 1) {
bot.whisper(m, habbo);
} else {
bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
}
}
return true;
}
return false;
}

View File

@ -139,15 +139,15 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
List<Bot> bots = room.getBots(this.botName);
if (bots.isEmpty())
return false;
if (bots.size() > 1) {
if (bots.size() != 1) {
return false;
}
for (Bot bot : bots) {
Bot bot = bots.get(0);
int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
int j = 1;
for (HabboItem item : this.items) {
if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
if (i == j) {
@ -158,7 +158,6 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
}
}
}
}
return true;
}

View File

@ -88,14 +88,13 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
if (this.items.isEmpty())
return false;
List<Bot> bots = room.getBots(this.botName);
if (bots.isEmpty())
if (this.items.isEmpty() || bots.size() != 1) {
return false;
}
Bot bot = bots.get(0);
THashSet<HabboItem> items = new THashSet<>();
for (HabboItem item : this.items) {
@ -108,10 +107,6 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
}
if (this.items.size() > 0) {
if (bots.size() > 1) {
return false;
}
for (Bot bot : bots) {
int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
int j = 1;
for (HabboItem item : this.items) {
@ -125,7 +120,6 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
}
}
}
}
return true;
}