Commit 30f94250 authored by Harmonic's avatar Harmonic
parents e40f772e d256e653
......@@ -14,6 +14,7 @@ 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.ServerMessage;
import com.eu.habbo.threading.runnables.games.GameTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -63,7 +64,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
String[] data = set.getString("extra_data").split("\t");
if (data.length >= 2) {
this.baseTime = Integer.valueOf(data[1]);
this.baseTime = Integer.parseInt(data[1]);
this.timeNow = this.baseTime;
}
......@@ -149,33 +150,6 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
if (this.needsUpdate() || this.needsDelete()) {
super.run();
}
if (this.getRoomId() == 0) {
this.threadActive = false;
return;
}
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null || !this.isRunning || this.isPaused) {
this.threadActive = false;
return;
}
this.timeNow--;
if (this.timeNow < 0) this.timeNow = 0;
if (this.timeNow > 0) {
this.threadActive = true;
Emulator.getThreading().run(this, 1000);
} else {
this.threadActive = false;
this.timeNow = 0;
this.endGame(room);
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
room.updateItem(this);
}
@Override
......@@ -248,7 +222,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
if (!this.threadActive) {
this.threadActive = true;
Emulator.getThreading().run(this, 1000);
Emulator.getThreading().run(new GameTimer(this), 1000);
}
} else if (client != null) {
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
......@@ -271,7 +245,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
if (!this.threadActive) {
this.threadActive = true;
Emulator.getThreading().run(this);
Emulator.getThreading().run(new GameTimer(this));
}
}
} else {
......@@ -285,7 +259,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
if (!this.threadActive) {
this.threadActive = true;
Emulator.getThreading().run(this, 1000);
Emulator.getThreading().run(new GameTimer(this), 1000);
}
}
......@@ -350,10 +324,30 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
}
public boolean isRunning() {
return isRunning;
return this.isRunning;
}
public void setRunning(boolean running) {
isRunning = running;
this.isRunning = running;
}
public void setThreadActive(boolean threadActive) {
this.threadActive = threadActive;
}
public boolean isPaused() {
return this.isPaused;
}
public void reduceTime() {
this.timeNow--;
}
public int getTimeNow() {
return this.timeNow;
}
public void setTimeNow(int timeNow) {
this.timeNow = timeNow;
}
}
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
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.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurni {
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
private THashSet<HabboItem> items = new THashSet<>();
public WiredConditionNotTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
......@@ -32,129 +21,19 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
if (roomUnit == null) return false;
if (roomUnit == null)
return false;
this.refresh();
if (this.items.isEmpty())
return true;
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
return this.items.stream().noneMatch(itemsAtUser::contains);
}
@Override
public String getWiredData() {
this.refresh();
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
));
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException {
this.items.clear();
String wiredData = set.getString("wired_data");
if (wiredData.startsWith("{")) {
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
for(int id : data.itemIds) {
HabboItem item = room.getHabboItem(id);
if (item != null) {
this.items.add(item);
}
}
} else {
String[] data = wiredData.split(";");
for (String s : data) {
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null) {
this.items.add(item);
}
}
}
}
@Override
public void onPickUp() {
this.items.clear();
return !triggerOnFurni(roomUnit, room);
}
@Override
public WiredConditionType getType() {
return type;
}
@Override
public void serializeWiredData(ServerMessage message, Room room) {
this.refresh();
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
message.appendInt(item.getId());
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(0);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(0);
message.appendInt(0);
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
packet.readString();
int count = packet.readInt();
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room != null) {
for (int i = 0; i < count; i++) {
HabboItem item = room.getHabboItem(packet.readInt());
if (item != null) {
this.items.add(item);
}
}
}
return true;
}
private void refresh() {
THashSet<HabboItem> items = new THashSet<>();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null) {
items.addAll(this.items);
} else {
for (HabboItem item : this.items) {
if (item.getRoomId() != room.getId())
items.add(item);
}
}
this.items.removeAll(items);
}
static class JsonData {
List<Integer> itemIds;
public JsonData(List<Integer> itemIds) {
this.itemIds = itemIds;
}
}
}
......@@ -22,7 +22,7 @@ import java.util.stream.Collectors;
public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI;
private THashSet<HabboItem> items = new THashSet<>();
protected THashSet<HabboItem> items = new THashSet<>();
public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
......@@ -42,10 +42,14 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
if (this.items.isEmpty())
return false;
return triggerOnFurni(roomUnit, room);
}
protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) {
/*
* 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles.
* 2. If a Habbo IS walking we have to check if the next tile in the walking path is one of the selected items
* */
* 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles.
* 2. If a Habbo IS walking we have to check if the next tile in the walking path is one of the selected items
* */
if (!roomUnit.isWalking()) {
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
return this.items.stream().anyMatch(itemsAtUser::contains);
......@@ -158,7 +162,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
return true;
}
private void refresh() {
protected void refresh() {
THashSet<HabboItem> items = new THashSet<>();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
......
......@@ -428,6 +428,16 @@ public class ModToolManager {
return bans;
}
//if machine id is empty, downgrade ban type to IP ban
if( (type == ModToolBanType.MACHINE || type == ModToolBanType.SUPER) && (offlineInfo == null || offlineInfo.getMachineID().isEmpty())) {
type = ModToolBanType.IP;
}
//if ip address is empty, downgrade ban type to account ban
if( (type == ModToolBanType.IP || type == ModToolBanType.SUPER) && (offlineInfo == null || offlineInfo.getIpLogin().isEmpty())) {
type = ModToolBanType.ACCOUNT;
}
ModToolBan ban = new ModToolBan(targetUserId, offlineInfo != null ? offlineInfo.getIpLogin() : "offline", offlineInfo != null ? offlineInfo.getMachineID() : "offline", moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic);
Emulator.getPluginManager().fireEvent(new SupportUserBannedEvent(moderator, target, ban));
Emulator.getThreading().run(ban);
......
......@@ -1514,6 +1514,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (unit.hasStatus(RoomUnitStatus.SIT)) {
unit.sitUpdate = true;
}
unit.setPreviousLocation(unit.getPreviousLocation());
unit.setPreviousLocationZ(unit.getPreviousLocation().getStackHeight());
unit.setCurrentLocation(this.getLayout().getTile(tile.x, tile.y));
unit.setZ(unit.getCurrentLocation().getStackHeight());
}
}
......
......@@ -336,7 +336,10 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler {
return;
}
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftGiver"));
if (this.client.getHabbo().getHabboInfo().getId() != userId) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftGiver"));
}
if (habbo != null) {
habbo.getClient().sendResponse(new AddHabboItemComposer(gift));
habbo.getClient().getHabbo().getInventory().getItemsComponent().addItem(gift);
......@@ -351,7 +354,9 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler {
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys));
}
AchievementManager.progressAchievement(userId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftReceiver"));
if (this.client.getHabbo().getHabboInfo().getId() != userId) {
AchievementManager.progressAchievement(userId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftReceiver"));
}
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
if (totalCredits > 0) {
......
......@@ -2,15 +2,17 @@ package com.eu.habbo.messages.incoming.rooms.items;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
public class MannequinSaveLookEvent extends MessageHandler {
@Override
public void handle() throws Exception {
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
Habbo habbo = this.client.getHabbo();
Room room = habbo.getHabboInfo().getCurrentRoom();
if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId())
if (room == null || !room.isOwner(habbo))
return;
HabboItem item = room.getHabboItem(this.packet.readInt());
......@@ -22,7 +24,7 @@ public class MannequinSaveLookEvent extends MessageHandler {
StringBuilder look = new StringBuilder();
for (String s : this.client.getHabbo().getHabboInfo().getLook().split("\\.")) {
for (String s : habbo.getHabboInfo().getLook().split("\\.")) {
if (!s.contains("hr") && !s.contains("hd") && !s.contains("he") && !s.contains("ea") && !s.contains("ha") && !s.contains("fa")) {
look.append(s).append(".");
}
......@@ -33,9 +35,9 @@ public class MannequinSaveLookEvent extends MessageHandler {
}
if (data.length == 3) {
item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + data[2]);
item.setExtradata(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + data[2]);
} else {
item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + this.client.getHabbo().getHabboInfo().getUsername() + "'s look.");
item.setExtradata(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + habbo.getHabboInfo().getUsername() + "'s look.");
}
item.needsUpdate(true);
......
......@@ -9,7 +9,7 @@ public class MannequinSaveNameEvent extends MessageHandler {
@Override
public void handle() throws Exception {
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId())
if (room == null || !room.isOwner(this.client.getHabbo()))
return;
HabboItem item = room.getHabboItem(this.packet.readInt());
......
package com.eu.habbo.threading.runnables.games;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
public class GameTimer implements Runnable {
private final InteractionGameTimer timer;
public GameTimer(InteractionGameTimer timer) {
this.timer = timer;
}
@Override
public void run() {
if (timer.getRoomId() == 0) {
timer.setRunning(false);
return;
}
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(timer.getRoomId());
if (room == null || !timer.isRunning() || timer.isPaused()) {
timer.setThreadActive(false);
return;
}
timer.reduceTime();
if (timer.getTimeNow() < 0) timer.setTimeNow(0);
if (timer.getTimeNow() > 0) {
timer.setThreadActive(true);
Emulator.getThreading().run(this, 1000);
} else {
timer.setThreadActive(false);
timer.setTimeNow(0);
timer.endGame(room);
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
room.updateItem(timer);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment