mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
Wired fixes.
Closes #772 #786 #804 #816 #802 #791 #727 #726 #721 #705 (pets) #701 #707 #710 #607 #604 #411
This commit is contained in:
parent
134dc737e0
commit
1d5391ff1c
@ -173,11 +173,11 @@ public class Bot implements Runnable {
|
||||
int timeOut = Emulator.getRandom().nextInt(20) * 2;
|
||||
this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp());
|
||||
}
|
||||
} else {
|
||||
}/* else {
|
||||
for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
|
||||
@ -188,12 +188,16 @@ public class Bot implements Runnable {
|
||||
this.lastChatIndex = 0;
|
||||
}
|
||||
|
||||
this.talk(this.chatLines.get(this.lastChatIndex)
|
||||
String message = this.chatLines.get(this.lastChatIndex)
|
||||
.replace("%owner%", this.room.getOwnerName())
|
||||
.replace("%item_count%", this.room.itemCount() + "")
|
||||
.replace("%name%", this.name)
|
||||
.replace("%roomname%", this.room.getName())
|
||||
.replace("%user_count%", this.room.getUserCount() + ""));
|
||||
.replace("%user_count%", this.room.getUserCount() + "");
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) {
|
||||
this.talk(message);
|
||||
}
|
||||
|
||||
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
|
||||
}
|
||||
@ -247,7 +251,12 @@ public class Bot implements Runnable {
|
||||
room.giveEffect(this.roomUnit, this.effect, -1);
|
||||
}
|
||||
|
||||
this.talk(PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]);
|
||||
if(PLACEMENT_MESSAGES.length > 0) {
|
||||
String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)];
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) {
|
||||
this.talk(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPickUp(Habbo habbo, Room room) {
|
||||
|
@ -3,6 +3,8 @@ package com.eu.habbo.habbohotel.bots;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.plugin.events.bots.BotServerItemEvent;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
|
||||
@ -78,7 +80,14 @@ public class ButlerBot extends Bot {
|
||||
tasks.add(new RoomUnitGiveHanditem(serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0));
|
||||
|
||||
tasks.add(() -> b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername())));
|
||||
tasks.add(() -> {
|
||||
if(this.getRoom() != null) {
|
||||
String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername());
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) {
|
||||
b.talk(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<Runnable> failedReached = new ArrayList();
|
||||
failedReached.add(() -> {
|
||||
@ -98,7 +107,13 @@ public class ButlerBot extends Bot {
|
||||
}
|
||||
} else {
|
||||
this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId);
|
||||
this.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", s).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||
|
||||
if(this.getRoom() != null) {
|
||||
String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", s).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername());
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) {
|
||||
this.talk(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -95,8 +95,10 @@ public abstract class Game implements Runnable {
|
||||
if (team != null && team.isMember(habbo)) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
team.removeMember(habbo.getHabboInfo().getGamePlayer());
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
habbo.getHabboInfo().getGamePlayer().reset();
|
||||
}
|
||||
}
|
||||
|
||||
habbo.getHabboInfo().setCurrentGame(null);
|
||||
habbo.getHabboInfo().setGamePlayer(null);
|
||||
|
@ -13,6 +13,7 @@ public class GamePlayer {
|
||||
|
||||
|
||||
private int score;
|
||||
private int wiredScore;
|
||||
|
||||
|
||||
public GamePlayer(Habbo habbo, GameTeamColors teamColor) {
|
||||
@ -23,15 +24,23 @@ public class GamePlayer {
|
||||
|
||||
public void reset() {
|
||||
this.score = 0;
|
||||
this.wiredScore = 0;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addScore(int amount) {
|
||||
addScore(amount, false);
|
||||
}
|
||||
|
||||
public synchronized void addScore(int amount, boolean isWired) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
|
||||
this.score += amount;
|
||||
|
||||
if (this.score < 0) this.score = 0;
|
||||
|
||||
if(isWired && this.score > 0) {
|
||||
this.wiredScore += amount;
|
||||
}
|
||||
|
||||
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
|
||||
}
|
||||
}
|
||||
@ -49,4 +58,8 @@ public class GamePlayer {
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
public int getScoreAchievementValue() {
|
||||
return this.score - this.wiredScore;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class BattleBanzaiGame extends Game {
|
||||
for (GameTeam team : this.teams.values()) {
|
||||
if (!singleTeamGame) {
|
||||
for (GamePlayer player : team.getMembers()) {
|
||||
if (player.getScore() > 0) {
|
||||
if (player.getScoreAchievementValue() > 0) {
|
||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ public class BattleBanzaiGame extends Game {
|
||||
if (winningTeam != null) {
|
||||
if (!singleTeamGame) {
|
||||
for (GamePlayer player : winningTeam.getMembers()) {
|
||||
if (player.getScore() > 0) {
|
||||
if (player.getScoreAchievementValue() > 0) {
|
||||
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
||||
}
|
||||
|
@ -287,9 +287,9 @@ public class FreezeGame extends Game {
|
||||
players.addAll(team.getMembers());
|
||||
|
||||
for (GamePlayer p : players) {
|
||||
if (p.getScore() > 0) {
|
||||
if (p.getScoreAchievementValue() > 0) {
|
||||
if (team.equals(winningTeam)) {
|
||||
AchievementManager.progressAchievement(p.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FreezeWinner"), p.getScore());
|
||||
AchievementManager.progressAchievement(p.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FreezeWinner"), p.getScoreAchievementValue());
|
||||
this.room.sendComposer(new RoomUserActionComposer(p.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -99,7 +100,7 @@ public class InteractionPressurePlate extends HabboItem {
|
||||
}
|
||||
|
||||
this.setExtradata(occupied ? "1" : "0");
|
||||
room.updateItem(this);
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -57,7 +58,7 @@ public abstract class InteractionWiredEffect extends InteractionWired {
|
||||
|
||||
}
|
||||
|
||||
public abstract boolean saveData(ClientMessage packet, GameClient gameClient);
|
||||
public abstract boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException;
|
||||
|
||||
public int getDelay() {
|
||||
return this.delay;
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
@ -35,39 +36,23 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
this.refresh();
|
||||
|
||||
boolean foundSomething = false;
|
||||
for (HabboItem item : this.items) {
|
||||
boolean found = false;
|
||||
|
||||
THashSet<HabboItem> stackedItems = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
|
||||
if (stackedItems == null)
|
||||
continue;
|
||||
|
||||
if (stackedItems.isEmpty() && this.all)
|
||||
return false;
|
||||
|
||||
for (HabboItem i : stackedItems) {
|
||||
if (i == item)
|
||||
continue;
|
||||
|
||||
if (i.getZ() >= item.getZ()) {
|
||||
found = true;
|
||||
foundSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.all) {
|
||||
if (!found)
|
||||
return false;
|
||||
} else {
|
||||
if (found)
|
||||
if(this.items.isEmpty())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return this.items.isEmpty() || foundSomething;
|
||||
|
||||
if(this.all) {
|
||||
return this.items.stream().allMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,43 +51,16 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
THashMap<HabboItem, THashSet<RoomTile>> tiles = new THashMap<>();
|
||||
for (HabboItem item : this.items) {
|
||||
tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
}
|
||||
|
||||
Collection<Habbo> habbos = room.getHabbos();
|
||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||
|
||||
for (Map.Entry<HabboItem, THashSet<RoomTile>> set : tiles.entrySet()) {
|
||||
boolean found = false;
|
||||
for (Habbo habbo : habbos) {
|
||||
if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
for (Bot bot : bots) {
|
||||
if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
for (Pet pet : pets) {
|
||||
if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.items.stream().allMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,22 +37,20 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
this.refresh();
|
||||
|
||||
if(items.isEmpty())
|
||||
return false;
|
||||
|
||||
if (stuff != null) {
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem) {
|
||||
HabboItem item = (HabboItem) stuff[0];
|
||||
|
||||
for (HabboItem i : this.items) {
|
||||
if (i.getBaseItem().getId() == item.getBaseItem().getId())
|
||||
return true;
|
||||
HabboItem triggeringItem = (HabboItem)stuff[0];
|
||||
return this.items.stream().anyMatch(item -> item == triggeringItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
@ -39,19 +40,20 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
THashSet<HabboItem> things = room.getItemsAt(item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item));
|
||||
things.removeAll(this.items);
|
||||
if (!things.isEmpty()) {
|
||||
if (this.all)
|
||||
return false;
|
||||
else
|
||||
continue;
|
||||
if(this.all) {
|
||||
return this.items.stream().allMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
return true;
|
||||
else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,7 +81,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
@ -169,6 +171,8 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public WiredConditionOperator operator() {
|
||||
return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
||||
// NICE TRY BUT THAT'S NOT HOW IT WORKS. NOTHING IN HABBO IS AN "OR" CONDITION - EVERY CONDITION MUST BE SUCCESS FOR THE STACK TO EXECUTE, BUT LET'S LEAVE IT IMPLEMENTED FOR PLUGINS TO USE.
|
||||
//return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
}
|
||||
|
@ -51,43 +51,16 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
THashMap<HabboItem, THashSet<RoomTile>> tiles = new THashMap<>();
|
||||
for (HabboItem item : this.items) {
|
||||
tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
}
|
||||
|
||||
Collection<Habbo> habbos = room.getHabbos();
|
||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||
|
||||
for (Map.Entry<HabboItem, THashSet<RoomTile>> set : tiles.entrySet()) {
|
||||
if (!habbos.isEmpty()) {
|
||||
for (Habbo habbo : habbos) {
|
||||
if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bots.isEmpty()) {
|
||||
for (Bot bot : bots) {
|
||||
if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pets.isEmpty()) {
|
||||
for (Pet pet : pets) {
|
||||
if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.items.stream().noneMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,15 +32,14 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
this.refresh();
|
||||
|
||||
if(items.isEmpty())
|
||||
return true;
|
||||
|
||||
if (stuff != null) {
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem) {
|
||||
HabboItem item = (HabboItem) stuff[0];
|
||||
|
||||
for (HabboItem i : this.items) {
|
||||
if (i.getBaseItem().getId() == item.getBaseItem().getId())
|
||||
return false;
|
||||
}
|
||||
HabboItem triggeringItem = (HabboItem)stuff[0];
|
||||
return this.items.stream().noneMatch(item -> item == triggeringItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,10 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
return !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor);
|
||||
}
|
||||
return true; // user is not part of any team
|
||||
return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); // user is not part of any team
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,12 +37,8 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
|
||||
return this.items.stream().noneMatch(itemsAtUser::contains);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
@ -37,14 +38,10 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
|
||||
return this.items.stream().anyMatch(itemsAtUser::contains);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,6 +146,6 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public WiredConditionOperator operator() {
|
||||
return WiredConditionOperator.OR;
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
@ -9,10 +10,12 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_CLOTHES;
|
||||
@ -44,18 +47,27 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
String dataString = packet.readString();
|
||||
packet.readInt();
|
||||
int delay = packet.readInt();
|
||||
|
||||
String[] data = packet.readString().split(((char) 9) + "");
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
String splitBy = "\t";
|
||||
if(!dataString.contains(splitBy))
|
||||
throw new WiredSaveException("Malformed data string");
|
||||
|
||||
String[] data = dataString.split(Pattern.quote(splitBy));
|
||||
|
||||
if (data.length != 2)
|
||||
throw new WiredSaveException("Malformed data string. Invalid data length");
|
||||
|
||||
this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.botLook = data[1];
|
||||
}
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -69,12 +81,10 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bots.size() == 1) {
|
||||
Bot bot = bots.get(0);
|
||||
bot.setFigure(this.botLook);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
@ -11,6 +12,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -67,13 +69,25 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
int mode = packet.readInt();
|
||||
|
||||
this.mode = packet.readInt();
|
||||
this.botName = packet.readString().replace("\t", "");
|
||||
if(mode != 0 && mode != 1)
|
||||
throw new WiredSaveException("Mode is invalid");
|
||||
|
||||
String botName = packet.readString().replace("\t", "");
|
||||
botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.botName = botName;
|
||||
this.mode = mode;
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,17 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -70,13 +74,25 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.itemId = packet.readInt();
|
||||
this.botName = packet.readString();
|
||||
int itemId = packet.readInt();
|
||||
|
||||
if(itemId < 0)
|
||||
itemId = 0;
|
||||
|
||||
String botName = packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.itemId = itemId;
|
||||
this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,15 +110,22 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
List<Runnable> tasks = new ArrayList<>();
|
||||
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(roomUnit, room, this.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
||||
tasks.add(() -> {
|
||||
if(roomUnit.getRoom() != null && roomUnit.getRoom().getId() == room.getId() && roomUnit.getCurrentLocation().distance(bot.getRoomUnit().getCurrentLocation()) < 2) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{});
|
||||
}
|
||||
});
|
||||
|
||||
RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomUnit.getX(), roomUnit.getY(), true);
|
||||
|
||||
if(tile != null) {
|
||||
bot.getRoomUnit().setGoalLocation(tile);
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
|
||||
|
||||
List<Runnable> failedReach = new ArrayList<>();
|
||||
failedReach.add(() -> tasks.forEach(Runnable::run));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(bot.getRoomUnit(), tile, room, tasks, tasks));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -9,12 +9,16 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_TALK;
|
||||
@ -48,22 +52,35 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.mode = packet.readInt();
|
||||
int mode = packet.readInt();
|
||||
|
||||
String[] data = packet.readString().split(((char) 9) + "");
|
||||
if(mode != 0 && mode != 1)
|
||||
throw new WiredSaveException("Mode is invalid");
|
||||
|
||||
if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
String dataString = packet.readString();
|
||||
|
||||
if (data[1].length() > 64) return false;
|
||||
this.message = data[1];
|
||||
}
|
||||
String splitBy = "\t";
|
||||
if(!dataString.contains(splitBy))
|
||||
throw new WiredSaveException("Malformed data string");
|
||||
|
||||
String[] data = dataString.split(Pattern.quote(splitBy));
|
||||
|
||||
if (data.length != 2)
|
||||
throw new WiredSaveException("Malformed data string. Invalid data length");
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.setDelay(delay);
|
||||
this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.mode = mode;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -88,17 +105,17 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bots.size() == 1) {
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) {
|
||||
if (this.mode == 1) {
|
||||
bot.shout(message);
|
||||
} else {
|
||||
bot.talk(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -10,14 +10,18 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_TALK_TO_AVATAR;
|
||||
@ -69,21 +73,34 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.mode = packet.readInt();
|
||||
String[] data = packet.readString().split("" + ((char) 9));
|
||||
int mode = packet.readInt();
|
||||
|
||||
if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
if(mode != 0 && mode != 1)
|
||||
throw new WiredSaveException("Mode is invalid");
|
||||
|
||||
if (data[1].length() > 64) return false;
|
||||
this.message = data[1];
|
||||
}
|
||||
String dataString = packet.readString();
|
||||
String splitBy = "\t";
|
||||
if(!dataString.contains(splitBy))
|
||||
throw new WiredSaveException("Malformed data string");
|
||||
|
||||
String[] data = dataString.split(Pattern.quote(splitBy));
|
||||
|
||||
if (data.length != 2)
|
||||
throw new WiredSaveException("Malformed data string. Invalid data length");
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.mode = mode;
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -112,11 +129,13 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ m })) {
|
||||
if (this.mode == 1) {
|
||||
bot.whisper(m, habbo);
|
||||
} else {
|
||||
bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitTeleport;
|
||||
import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer;
|
||||
@ -21,6 +22,7 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -77,6 +79,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||
}
|
||||
|
||||
@ -110,20 +113,36 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
this.botName = packet.readString();
|
||||
String botName = packet.readString();
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -12,26 +12,28 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_MOVE;
|
||||
|
||||
private THashSet<HabboItem> items;
|
||||
private List<HabboItem> items;
|
||||
private String botName = "";
|
||||
|
||||
public WiredEffectBotWalkToFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.items = new THashSet<>();
|
||||
this.items = new ArrayList<>();
|
||||
}
|
||||
|
||||
public WiredEffectBotWalkToFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
this.items = new THashSet<>();
|
||||
this.items = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,20 +66,36 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
this.botName = packet.readString();
|
||||
String botName = packet.readString();
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -92,33 +110,18 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (this.items.isEmpty() || bots.size() != 1) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Bot bot = bots.get(0);
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : items) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
|
||||
|
||||
// wtf was that
|
||||
if (this.items.size() > 0) {
|
||||
int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
|
||||
int j = 1;
|
||||
for (HabboItem item : this.items) {
|
||||
HabboItem item = this.items.get(Emulator.getRandom().nextInt(this.items.size()));
|
||||
|
||||
if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
|
||||
if (i == j) {
|
||||
bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
break;
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +145,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
this.items = new ArrayList<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredData.length > 1) {
|
||||
|
@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
@ -57,25 +57,29 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
if (this.items.isEmpty()) return false;
|
||||
|
||||
for (Map.Entry<HabboItem, RoomUserRotation> entry : this.items.entrySet()) {
|
||||
RoomUserRotation currentRotation = entry.getValue();
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
|
||||
|
||||
int count = 1;
|
||||
while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED) && count < 8) {
|
||||
while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID) && count < 8) {
|
||||
entry.setValue(this.nextRotation(entry.getValue()));
|
||||
targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<HabboItem, RoomUserRotation> entry : this.items.entrySet()) {
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
|
||||
|
||||
if (targetTile != null && targetTile.state != RoomTileState.INVALID) {
|
||||
boolean hasRoomUnits = false;
|
||||
for (RoomUnit _roomUnit : room.getHabbosAndBotsAt(targetTile)) {
|
||||
for (RoomUnit _roomUnit : room.getRoomUnitsAt(targetTile)) {
|
||||
hasRoomUnits = true;
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{entry.getKey()}));
|
||||
}
|
||||
|
||||
if (!hasRoomUnits) {
|
||||
if (!hasRoomUnits && targetTile.getAllowStack() && targetTile.state != RoomTileState.INVALID) {
|
||||
THashSet<RoomTile> refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getKey().getBaseItem().getWidth(), entry.getKey().getBaseItem().getLength(), entry.getKey().getRotation());
|
||||
room.sendComposer(new FloorItemOnRollerComposer(entry.getKey(), null, targetTile, targetTile.getStackHeight() - entry.getKey().getZ(), room).compose());
|
||||
room.getLayout().getTilesAt(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getKey().getBaseItem().getWidth(), entry.getKey().getBaseItem().getLength(), entry.getKey().getRotation());
|
||||
@ -89,7 +93,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.getDelay() + this.startRotation.getValue() + "\t" + this.rotateAction + "\t" + this.items.size());
|
||||
StringBuilder data = new StringBuilder(this.getDelay() + "\t" + this.startRotation.getValue() + "\t" + this.rotateAction + "\t" + this.items.size());
|
||||
|
||||
for (Map.Entry<HabboItem, RoomUserRotation> entry : this.items.entrySet()) {
|
||||
data.append("\t").append(entry.getKey().getId()).append(":").append(entry.getValue().getValue());
|
||||
@ -102,17 +106,15 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
|
||||
if (data.length >= 1) {
|
||||
if (data.length >= 4) {
|
||||
this.setDelay(Integer.parseInt(data[0]));
|
||||
}
|
||||
if (data.length >= 3) {
|
||||
this.startRotation = RoomUserRotation.fromValue(Integer.parseInt(data[0]));
|
||||
this.rotateAction = Integer.parseInt(data[1]);
|
||||
this.startRotation = RoomUserRotation.fromValue(Integer.parseInt(data[1]));
|
||||
this.rotateAction = Integer.parseInt(data[2]);
|
||||
|
||||
int itemCount = Integer.parseInt(data[2]);
|
||||
int itemCount = Integer.parseInt(data[3]);
|
||||
|
||||
if (itemCount > 0) {
|
||||
for (int i = 3; i < data.length; i++) {
|
||||
for (int i = 4; i < data.length; i++) {
|
||||
String[] subData = data[i].split(":");
|
||||
|
||||
if (subData.length == 2) {
|
||||
@ -161,25 +163,53 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
this.startRotation = RoomUserRotation.fromValue(packet.readInt());
|
||||
this.rotateAction = packet.readInt();
|
||||
int startRotationInt = packet.readInt();
|
||||
|
||||
if(startRotationInt < 0 || startRotationInt > 7 || (startRotationInt % 2) != 0) {
|
||||
throw new WiredSaveException("Direction is invalid");
|
||||
}
|
||||
|
||||
RoomUserRotation startRotation = RoomUserRotation.fromValue(startRotationInt);
|
||||
|
||||
int rotateAction = packet.readInt();
|
||||
|
||||
if(rotateAction < 0 || rotateAction > 6) {
|
||||
throw new WiredSaveException("Blocked action is invalid");
|
||||
}
|
||||
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
THashMap<HabboItem, RoomUserRotation> newItems = new THashMap<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.put(it, startRotation);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.putAll(newItems);
|
||||
this.startRotation = startRotation;
|
||||
this.rotateAction = rotateAction;
|
||||
this.setDelay(delay);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
HabboItem item = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(packet.readInt());
|
||||
|
||||
if (item != null) {
|
||||
this.items.put(item, this.startRotation);
|
||||
}
|
||||
}
|
||||
this.setDelay(packet.readInt());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
@ -11,6 +12,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.iterator.TObjectIntIterator;
|
||||
import gnu.trove.map.TObjectIntMap;
|
||||
import gnu.trove.map.hash.TObjectIntHashMap;
|
||||
@ -61,7 +63,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
if (iterator.value() < this.count) {
|
||||
iterator.setValue(iterator.value() + 1);
|
||||
|
||||
habbo.getHabboInfo().getGamePlayer().addScore(this.score);
|
||||
habbo.getHabboInfo().getGamePlayer().addScore(this.score, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -74,7 +76,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
this.data.put(new AbstractMap.SimpleEntry<>(game.getStartTime(), habbo.getHabboInfo().getId()), 1);
|
||||
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
habbo.getHabboInfo().getGamePlayer().addScore(this.score);
|
||||
habbo.getHabboInfo().getGamePlayer().addScore(this.score, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -147,14 +149,30 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.score = packet.readInt();
|
||||
this.count = packet.readInt();
|
||||
int score = packet.readInt();
|
||||
|
||||
if(score < 1 || score > 100)
|
||||
throw new WiredSaveException("Score is invalid");
|
||||
|
||||
int timesPerGame = packet.readInt();
|
||||
|
||||
if(timesPerGame < 1 || timesPerGame > 10)
|
||||
throw new WiredSaveException("Times per game is invalid");
|
||||
|
||||
packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.score = score;
|
||||
this.count = timesPerGame;
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||
@ -12,6 +13,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.map.hash.TIntIntHashMap;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -115,15 +117,37 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.points = packet.readInt();
|
||||
this.count = packet.readInt();
|
||||
this.teamColor = GameTeamColors.values()[packet.readInt()];
|
||||
int points = packet.readInt();
|
||||
|
||||
if(points < 1 || points > 100)
|
||||
throw new WiredSaveException("Points is invalid");
|
||||
|
||||
int timesPerGame = packet.readInt();
|
||||
|
||||
if(timesPerGame < 1 || timesPerGame > 10)
|
||||
throw new WiredSaveException("Times per game is invalid");
|
||||
|
||||
int team = packet.readInt();
|
||||
|
||||
if(team < 1 || team > 4)
|
||||
throw new WiredSaveException("Team is invalid");
|
||||
|
||||
packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.points = points;
|
||||
this.count = timesPerGame;
|
||||
this.teamColor = GameTeamColors.values()[team];
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
@ -12,6 +14,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -37,16 +40,19 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() == null) {
|
||||
WiredGame game = (WiredGame) room.getGame(WiredGame.class);
|
||||
WiredGame game = (WiredGame) room.getGameOrCreate(WiredGame.class);
|
||||
|
||||
if (game == null) {
|
||||
game = new WiredGame(room);
|
||||
room.addGame(game);
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getCurrentGame() != null && (habbo.getHabboInfo().getCurrentGame() != WiredGame.class || (habbo.getHabboInfo().getCurrentGame() == WiredGame.class && habbo.getHabboInfo().getGamePlayer().getTeamColor() != this.teamColor))) {
|
||||
// remove from current game
|
||||
Game currentGame = room.getGame(habbo.getHabboInfo().getCurrentGame());
|
||||
currentGame.removeHabbo(habbo);
|
||||
}
|
||||
|
||||
return game.addHabbo(habbo, this.teamColor);
|
||||
if(habbo.getHabboInfo().getGamePlayer() == null) {
|
||||
game.addHabbo(habbo, this.teamColor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -116,12 +122,22 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
int team = packet.readInt();
|
||||
|
||||
if(team < 1 || team > 4)
|
||||
throw new WiredSaveException("Team is invalid");
|
||||
|
||||
packet.readInt();
|
||||
this.teamColor = GameTeamColors.values()[packet.readInt()];
|
||||
int unknownInt = packet.readInt();
|
||||
packet.readString();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.teamColor = GameTeamColors.values()[packet.readInt()];
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitKick;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@ -135,11 +136,17 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
this.message = packet.readString();
|
||||
String message = packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||
@ -12,6 +13,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -39,7 +41,7 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());
|
||||
|
||||
if (game == null) {
|
||||
game = room.getGame(WiredGame.class);
|
||||
game = room.getGameOrCreate(WiredGame.class);
|
||||
}
|
||||
|
||||
if (game != null) {
|
||||
@ -105,11 +107,16 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.setDelay(delay);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
@ -22,6 +23,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class);
|
||||
@ -57,6 +61,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) {
|
||||
if (!setting.state.equals(" ")) {
|
||||
item.setExtradata(setting.state);
|
||||
room.updateItemState(item);
|
||||
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
}
|
||||
}
|
||||
@ -180,17 +185,17 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
|
||||
int itemCount = Integer.valueOf(data[0]);
|
||||
int itemCount = Integer.parseInt(data[0]);
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
String[] items = data[1].split(Pattern.quote(";"));
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
try {
|
||||
|
||||
String[] stuff = items[i].split("-");
|
||||
String[] stuff = items[i].split(Pattern.quote("-"));
|
||||
|
||||
if (stuff.length >= 5) {
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4])));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -201,7 +206,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
this.state = data[2].equals("1");
|
||||
this.direction = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
this.setDelay(Integer.valueOf(data[5]));
|
||||
this.setDelay(Integer.parseInt(data[5]));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -243,33 +248,48 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.state = packet.readInt() == 1;
|
||||
this.direction = packet.readInt() == 1;
|
||||
this.position = packet.readInt() == 1;
|
||||
boolean setState = packet.readInt() == 1;
|
||||
boolean setDirection = packet.readInt() == 1;
|
||||
boolean setPosition = packet.readInt() == 1;
|
||||
|
||||
packet.readString();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room == null)
|
||||
return true;
|
||||
throw new WiredSaveException("Trying to save wired in unloaded room");
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
this.settings.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem item = room.getHabboItem(itemId);
|
||||
|
||||
if (item != null)
|
||||
this.settings.add(new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtradata() : " ", item.getRotation(), item.getX(), item.getY()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
List<WiredMatchFurniSetting> newSettings = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newSettings.add(new WiredMatchFurniSetting(it.getId(), this.checkForWiredResetPermission && it.allowWiredResetState() ? it.getExtradata() : " ", it.getRotation(), it.getX(), it.getY()));
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.state = setState;
|
||||
this.direction = setDirection;
|
||||
this.position = setPosition;
|
||||
this.settings.clear();
|
||||
this.settings.addAll(newSettings);
|
||||
this.setDelay(packet.readInt());
|
||||
|
||||
return true;
|
||||
|
@ -12,11 +12,15 @@ import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.FLEE;
|
||||
@ -44,45 +48,35 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
RoomTile t = room.getLayout().getTile(item.getX(), item.getY());
|
||||
double shortest = 1000.0D;
|
||||
|
||||
Habbo target = null;
|
||||
|
||||
for (Habbo habbo : room.getHabbos()) {
|
||||
if (habbo.getRoomUnit().getCurrentLocation().distance(t) <= shortest) {
|
||||
shortest = habbo.getRoomUnit().getCurrentLocation().distance(t);
|
||||
target = habbo;
|
||||
}
|
||||
}
|
||||
RoomUnit target = room.getRoomUnits().stream().min(Comparator.comparingDouble(a -> a.getCurrentLocation().distance(t))).orElse(null);
|
||||
|
||||
if (target != null) {
|
||||
if (RoomLayout.tilesAdjecent(target.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY())) && (target.getRoomUnit().getX() == item.getX() || target.getRoomUnit().getY() == item.getY())) {
|
||||
final Habbo finalTarget = target;
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, finalTarget.getRoomUnit(), room, new Object[]{item}), 500);
|
||||
|
||||
if (target.getCurrentLocation().distance(t) <= 1) {
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, target, room, new Object[]{item}), 500);
|
||||
continue;
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
if (target.getRoomUnit().getX() == item.getX()) {
|
||||
if (item.getY() < target.getRoomUnit().getY())
|
||||
if (target.getX() == item.getX()) {
|
||||
if (item.getY() < target.getY())
|
||||
y--;
|
||||
else
|
||||
y++;
|
||||
} else if (target.getRoomUnit().getY() == item.getY()) {
|
||||
if (item.getX() < target.getRoomUnit().getX())
|
||||
} else if (target.getY() == item.getY()) {
|
||||
if (item.getX() < target.getX())
|
||||
x--;
|
||||
else
|
||||
x++;
|
||||
} else if (target.getRoomUnit().getX() - item.getX() > target.getRoomUnit().getY() - item.getY()) {
|
||||
if (target.getRoomUnit().getX() - item.getX() > 0)
|
||||
} else if (target.getX() - item.getX() > target.getY() - item.getY()) {
|
||||
if (target.getX() - item.getX() > 0)
|
||||
x--;
|
||||
else
|
||||
x++;
|
||||
} else {
|
||||
if (target.getRoomUnit().getY() - item.getY() > 0)
|
||||
if (target.getY() - item.getY() > 0)
|
||||
y--;
|
||||
else
|
||||
y++;
|
||||
@ -182,20 +176,35 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import com.eu.habbo.threading.runnables.WiredCollissionRunnable;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
@ -19,6 +20,7 @@ import gnu.trove.set.hash.THashSet;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -128,7 +130,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
if (startTile != null && layout.tileExists(startTile.x, startTile.y)) {
|
||||
THashSet<RoomUnit> roomUnitsAtTile = room.getHabbosAndBotsAt(startTile.x, startTile.y);
|
||||
Collection<RoomUnit> roomUnitsAtTile = room.getRoomUnitsAt(startTile);
|
||||
if (roomUnitsAtTile.size() > 0) {
|
||||
target = roomUnitsAtTile.iterator().next();
|
||||
if (i == 0) { // i = 0 means right next to it
|
||||
@ -300,20 +302,36 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -86,9 +86,10 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
|
||||
if (newTile != null) {
|
||||
boolean hasRoomUnits = false;
|
||||
for (RoomUnit _roomUnit : room.getHabbosAndBotsAt(newTile)) {
|
||||
for (RoomUnit _roomUnit : room.getRoomUnitsAt(newTile)) {
|
||||
hasRoomUnits = true;
|
||||
WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{item});
|
||||
// this wired isn't meant to do a collision
|
||||
//WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{item});
|
||||
}
|
||||
|
||||
if (!hasRoomUnits && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) {
|
||||
|
@ -14,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitTeleport;
|
||||
import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer;
|
||||
@ -78,6 +79,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||
}
|
||||
|
||||
@ -127,20 +129,36 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3,12 +3,20 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionCrackable;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiPuck;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.*;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
@ -17,6 +25,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
@ -34,6 +43,46 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
|
||||
private final THashSet<HabboItem> items;
|
||||
|
||||
private static final List<Class<? extends HabboItem>> FORBIDDEN_TYPES = new ArrayList<Class<? extends HabboItem>>() {
|
||||
{
|
||||
this.add(InteractionWired.class);
|
||||
this.add(InteractionTeleport.class);
|
||||
this.add(InteractionPushable.class);
|
||||
this.add(InteractionTagPole.class);
|
||||
this.add(InteractionTagField.class);
|
||||
this.add(InteractionCrackable.class);
|
||||
this.add(InteractionGameScoreboard.class);
|
||||
this.add(InteractionGameGate.class);
|
||||
this.add(InteractionFreezeTile.class);
|
||||
this.add(InteractionFreezeBlock.class);
|
||||
this.add(InteractionFreezeExitTile.class);
|
||||
this.add(InteractionBattleBanzaiTeleporter.class);
|
||||
this.add(InteractionBattleBanzaiTile.class);
|
||||
this.add(InteractionMonsterPlantSeed.class);
|
||||
this.add(InteractionPetBreedingNest.class);
|
||||
this.add(InteractionPetDrink.class);
|
||||
this.add(InteractionPetFood.class);
|
||||
this.add(InteractionPetToy.class);
|
||||
this.add(InteractionBadgeDisplay.class);
|
||||
this.add(InteractionClothing.class);
|
||||
this.add(InteractionVendingMachine.class);
|
||||
this.add(InteractionGift.class);
|
||||
this.add(InteractionPressurePlate.class);
|
||||
this.add(InteractionMannequin.class);
|
||||
this.add(InteractionGymEquipment.class);
|
||||
this.add(InteractionHopper.class);
|
||||
this.add(InteractionObstacle.class);
|
||||
this.add(InteractionOneWayGate.class);
|
||||
this.add(InteractionPuzzleBox.class);
|
||||
this.add(InteractionRoller.class);
|
||||
this.add(InteractionSwitch.class);
|
||||
this.add(InteractionTent.class);
|
||||
this.add(InteractionTrap.class);
|
||||
this.add(InteractionTrophy.class);
|
||||
this.add(InteractionWater.class);
|
||||
}
|
||||
};
|
||||
|
||||
public WiredEffectToggleFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.items = new THashSet<>();
|
||||
@ -92,25 +141,36 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
|
||||
this.items.add(item);
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -123,7 +183,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
|
||||
THashSet<HabboItem> itemsToRemove = new THashSet<>();
|
||||
for (HabboItem item : this.items) {
|
||||
if (item == null || item.getRoomId() == 0 || item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile) {
|
||||
if (item == null || item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) {
|
||||
itemsToRemove.add(item);
|
||||
continue;
|
||||
}
|
||||
|
@ -3,11 +3,18 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionCrackable;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.*;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
@ -15,6 +22,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
@ -32,6 +40,46 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||
|
||||
private final THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
private static final List<Class<? extends HabboItem>> FORBIDDEN_TYPES = new ArrayList<Class<? extends HabboItem>>() {
|
||||
{
|
||||
this.add(InteractionWired.class);
|
||||
this.add(InteractionTeleport.class);
|
||||
this.add(InteractionPushable.class);
|
||||
this.add(InteractionTagPole.class);
|
||||
this.add(InteractionTagField.class);
|
||||
this.add(InteractionCrackable.class);
|
||||
this.add(InteractionGameScoreboard.class);
|
||||
this.add(InteractionGameGate.class);
|
||||
this.add(InteractionFreezeTile.class);
|
||||
this.add(InteractionFreezeBlock.class);
|
||||
this.add(InteractionFreezeExitTile.class);
|
||||
this.add(InteractionBattleBanzaiTeleporter.class);
|
||||
this.add(InteractionBattleBanzaiTile.class);
|
||||
this.add(InteractionMonsterPlantSeed.class);
|
||||
this.add(InteractionPetBreedingNest.class);
|
||||
this.add(InteractionPetDrink.class);
|
||||
this.add(InteractionPetFood.class);
|
||||
this.add(InteractionPetToy.class);
|
||||
this.add(InteractionBadgeDisplay.class);
|
||||
this.add(InteractionClothing.class);
|
||||
this.add(InteractionVendingMachine.class);
|
||||
this.add(InteractionGift.class);
|
||||
this.add(InteractionPressurePlate.class);
|
||||
this.add(InteractionMannequin.class);
|
||||
this.add(InteractionGymEquipment.class);
|
||||
this.add(InteractionHopper.class);
|
||||
this.add(InteractionObstacle.class);
|
||||
this.add(InteractionOneWayGate.class);
|
||||
this.add(InteractionPuzzleBox.class);
|
||||
this.add(InteractionRoller.class);
|
||||
this.add(InteractionSwitch.class);
|
||||
this.add(InteractionTent.class);
|
||||
this.add(InteractionTrap.class);
|
||||
this.add(InteractionTrophy.class);
|
||||
this.add(InteractionWater.class);
|
||||
}
|
||||
};
|
||||
|
||||
public WiredEffectToggleRandom(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
@ -88,24 +136,36 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
this.items.clear();
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
int count = packet.readInt();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
|
||||
this.items.add(item);
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -115,7 +175,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||
THashSet<HabboItem> items = this.items;
|
||||
|
||||
for (HabboItem item : items) {
|
||||
if (item.getRoomId() == 0) {
|
||||
if (item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) {
|
||||
this.items.remove(item);
|
||||
continue;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@ -83,20 +84,36 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
this.items.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5,14 +5,18 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
@ -68,15 +72,25 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.message = Emulator.getGameEnvironment().getWordFilter().filter(packet.readString(), null);
|
||||
if (this.message.length() > 100) {
|
||||
this.message = "";
|
||||
String message = packet.readString();
|
||||
|
||||
if(gameClient.getHabbo() == null || !gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) {
|
||||
message = Emulator.getGameEnvironment().getWordFilter().filter(message, null);
|
||||
message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
}
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.message = message;
|
||||
this.setDelay(delay);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -87,7 +101,9 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED)));
|
||||
String msg = this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "");
|
||||
habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED)));
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg }));
|
||||
|
||||
if (habbo.getRoomUnit().isIdle()) {
|
||||
habbo.getRoomUnit().getRoom().unIdle(habbo);
|
||||
|
@ -68,7 +68,7 @@ public class WiredBlob extends InteractionDefault {
|
||||
GamePlayer player = habbo.getHabboInfo().getGamePlayer();
|
||||
|
||||
if (player != null) {
|
||||
player.addScore(this.POINTS_REWARD);
|
||||
player.addScore(this.POINTS_REWARD, true);
|
||||
|
||||
BattleBanzaiGame battleBanzaiGame = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
|
||||
|
||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
||||
public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class);
|
||||
|
||||
public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_STF;
|
||||
public final static WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI;
|
||||
|
||||
private THashSet<HabboItem> items;
|
||||
private String botName = "";
|
||||
@ -73,7 +73,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
message.appendString(this.botName);
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
message.appendInt(WiredTriggerType.BOT_REACHED_STF.code);
|
||||
|
||||
if (!this.isTriggeredByRoomUnit()) {
|
||||
List<Integer> invalidTriggers = new ArrayList<>();
|
||||
@ -114,17 +114,11 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
for (Bot bot : bots) {
|
||||
if (bot.getRoomUnit().equals(roomUnit)) {
|
||||
for (Object o : stuff) {
|
||||
if (this.items.contains(o))
|
||||
return true;
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem) {
|
||||
return this.items.contains(stuff[0]) && room.getBots(this.botName).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -57,16 +57,7 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
if (stuff.length == 0)
|
||||
return false;
|
||||
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
for (Bot bot : bots) {
|
||||
if (bot.getRoomUnit().equals(stuff[0]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return room.getBots(this.botName).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,14 +28,11 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
if (this.key.length() > 0) {
|
||||
if (stuff[0] instanceof String) {
|
||||
if (((String) stuff[0]).toLowerCase().contains(this.key.toLowerCase())) {
|
||||
return !this.ownerOnly || room.getOwnerId() == habbo.getHabboInfo().getId();
|
||||
}
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
return !this.ownerOnly || (habbo != null && room.getOwnerId() == habbo.getHabboInfo().getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -1458,7 +1459,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (itemsOnRoller.isEmpty()) {
|
||||
HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y);
|
||||
|
||||
if (item != null && itemsNewTile.contains(item)) {
|
||||
if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) {
|
||||
Emulator.getThreading().run(() -> {
|
||||
if (unit.getGoal() == rollerTile) {
|
||||
try {
|
||||
@ -2170,6 +2171,20 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Game getGameOrCreate(Class<? extends Game> gameType) {
|
||||
Game game = this.getGame(gameType);
|
||||
if(game == null) {
|
||||
try {
|
||||
game = gameType.getDeclaredConstructor(Room.class).newInstance(this);
|
||||
this.addGame(game);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting game " + gameType.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
public ConcurrentSet<Game> getGames() {
|
||||
return this.games;
|
||||
}
|
||||
@ -4678,4 +4693,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
return units;
|
||||
}
|
||||
|
||||
public Collection<RoomUnit> getRoomUnitsAt(RoomTile tile) {
|
||||
THashSet<RoomUnit> roomUnits = getRoomUnits();
|
||||
return roomUnits.stream().filter(unit -> unit.getCurrentLocation() == tile).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
@ -37,6 +37,7 @@ public class RoomUnit {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnit.class);
|
||||
|
||||
public boolean isWiredTeleporting = false;
|
||||
public boolean isLeavingTeleporter = false;
|
||||
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
||||
private final THashMap<String, Object> cacheable;
|
||||
public boolean canRotate = true;
|
||||
|
@ -126,7 +126,6 @@ public class WiredHandler {
|
||||
public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff) {
|
||||
long millis = System.currentTimeMillis();
|
||||
if (Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) {
|
||||
trigger.setCooldown(millis);
|
||||
trigger.activateBox(room);
|
||||
|
||||
THashSet<InteractionWiredCondition> conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY());
|
||||
@ -152,6 +151,7 @@ public class WiredHandler {
|
||||
}
|
||||
}
|
||||
|
||||
trigger.setCooldown(millis);
|
||||
|
||||
boolean hasExtraRandom = room.getRoomSpecialTypes().hasExtraType(trigger.getX(), trigger.getY(), WiredExtraRandom.class);
|
||||
boolean hasExtraUnseen = room.getRoomSpecialTypes().hasExtraType(trigger.getX(), trigger.getY(), WiredExtraUnseen.class);
|
||||
|
@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorMessagesComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer;
|
||||
import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer;
|
||||
|
||||
public class WiredEffectSaveDataEvent extends MessageHandler {
|
||||
@ -18,13 +20,19 @@ public class WiredEffectSaveDataEvent extends MessageHandler {
|
||||
if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermission(Permission.ACC_MOVEROTATE)) {
|
||||
InteractionWiredEffect effect = room.getRoomSpecialTypes().getEffect(itemId);
|
||||
|
||||
if (effect != null) {
|
||||
try {
|
||||
if (effect == null)
|
||||
throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId));
|
||||
|
||||
if (effect.saveData(this.packet, this.client)) {
|
||||
this.client.sendResponse(new WiredSavedComposer());
|
||||
effect.needsUpdate(true);
|
||||
Emulator.getThreading().run(effect);
|
||||
}
|
||||
}
|
||||
catch (WiredSaveException e) {
|
||||
this.client.sendResponse(new UpdateFailedComposer(e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.eu.habbo.messages.incoming.wired;
|
||||
|
||||
public class WiredSaveException extends Exception {
|
||||
|
||||
private final String message;
|
||||
|
||||
public WiredSaveException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -23,6 +24,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
|
||||
private final Room room;
|
||||
private int x;
|
||||
private int y;
|
||||
private HabboItem oldTopItem;
|
||||
|
||||
public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) {
|
||||
this.roomUnit = roomUnit;
|
||||
@ -32,6 +34,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
|
||||
this.newLocation = newLocation;
|
||||
this.newZ = newZ;
|
||||
this.room = room;
|
||||
oldTopItem = this.room.getTopItemAt(oldLocation.x, oldLocation.y);
|
||||
}
|
||||
|
||||
public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) {
|
||||
@ -42,6 +45,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
|
||||
this.newLocation = newLocation;
|
||||
this.newZ = this.newLocation.getStackHeight();
|
||||
this.room = room;
|
||||
this.oldTopItem = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +68,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
|
||||
if (this.roller != null && room.getLayout() != null) {
|
||||
RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY());
|
||||
HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y);
|
||||
if (topItem != null) {
|
||||
if (topItem != null && (topItem == roller || oldTopItem != topItem)) {
|
||||
try {
|
||||
topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this});
|
||||
} catch (Exception e) {
|
||||
|
@ -5,16 +5,20 @@ import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
|
||||
public class BotFollowHabbo implements Runnable {
|
||||
private final Bot bot;
|
||||
private final Habbo habbo;
|
||||
private final Room room;
|
||||
private boolean hasReached;
|
||||
|
||||
public BotFollowHabbo(Bot bot, Habbo habbo, Room room) {
|
||||
this.bot = bot;
|
||||
this.habbo = habbo;
|
||||
this.room = room;
|
||||
this.hasReached = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,6 +34,16 @@ public class BotFollowHabbo implements Runnable {
|
||||
if (target.x < 0 || target.y < 0)
|
||||
target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), this.habbo.getRoomUnit().getBodyRotation().getValue());
|
||||
|
||||
if(this.habbo.getRoomUnit().getCurrentLocation().distance(this.bot.getRoomUnit().getCurrentLocation()) < 2) {
|
||||
if(!hasReached) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{});
|
||||
hasReached = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hasReached = false;
|
||||
}
|
||||
|
||||
if (target.x >= 0 && target.y >= 0) {
|
||||
this.bot.getRoomUnit().setGoalLocation(target);
|
||||
this.bot.getRoomUnit().setCanWalk(true);
|
||||
|
@ -30,12 +30,11 @@ public class RoomUnitTeleport implements Runnable {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.newEffect = newEffect;
|
||||
roomUnit.isWiredTeleporting = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null)
|
||||
if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null || roomUnit.isLeavingTeleporter)
|
||||
return;
|
||||
|
||||
RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y);
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -47,7 +48,7 @@ public class RoomUnitWalkToLocation implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.walker.getGoal().equals(this.goalTile)) {
|
||||
if (!this.walker.getGoal().equals(this.goalTile) || (this.walker.getPath().size() == 0 && !this.walker.hasStatus(RoomUnitStatus.MOVE))) {
|
||||
onFail();
|
||||
return;
|
||||
}
|
||||
|
@ -3,11 +3,10 @@ package com.eu.habbo.threading.runnables.teleport;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.threading.runnables.HabboItemNewState;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
|
||||
@ -29,6 +28,7 @@ class TeleportActionFive implements Runnable {
|
||||
public void run() {
|
||||
RoomUnit unit = this.client.getHabbo().getRoomUnit();
|
||||
|
||||
unit.isLeavingTeleporter = false;
|
||||
unit.isTeleporting = false;
|
||||
unit.setCanWalk(true);
|
||||
|
||||
@ -46,11 +46,16 @@ class TeleportActionFive implements Runnable {
|
||||
List<Runnable> onSuccess = new ArrayList<Runnable>();
|
||||
onSuccess.add(() -> {
|
||||
unit.setCanLeaveRoomByDoor(true);
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
unit.isLeavingTeleporter = false;
|
||||
}, 300);
|
||||
});
|
||||
|
||||
unit.setCanLeaveRoomByDoor(false);
|
||||
unit.setGoalLocation(tile);
|
||||
unit.statusUpdate(true);
|
||||
unit.isLeavingTeleporter = true;
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess));
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,10 @@ class TeleportActionFour implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.client.getHabbo().getRoomUnit() != null) {
|
||||
this.client.getHabbo().getRoomUnit().isLeavingTeleporter = true;
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 500);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user