This commit is contained in:
Alejandro 2019-12-27 14:39:10 +02:00
commit 3f845f38cc
12 changed files with 187 additions and 25 deletions

View File

@ -1 +1,2 @@
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500');
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500');
UPDATE items_base SET interaction_type = 'vote_counter' WHERE item_name = 'vote_count_add';

View File

@ -37,7 +37,7 @@ public final class Emulator {
public final static int BUILD = 0;
public final static String PREVIEW = "RC-2";
public final static String PREVIEW = "RC-3";
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
private static final String logo =
@ -49,7 +49,7 @@ public final class Emulator {
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
" /____/ \n" +
" 'RC Stands for Race Car.' \n" ;
" 'The boiz are back in town.' \n" ;
public static String build = "";
public static boolean isReady = false;
public static boolean isShuttingDown = false;
@ -136,7 +136,7 @@ public final class Emulator {
Emulator.getThreading().run(() -> {
Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-1 Build. If you find any bugs please place them on our git repository.");
Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-3 Build. If you find any bugs please place them on our git repository.");
Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: ");
Emulator.getLogging().logStart("https://discord.gg/syuqgN");
Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!");

View File

@ -147,8 +147,8 @@ public class CleanerThread implements Runnable {
statement.execute("DELETE users_favorite_rooms FROM users_favorite_rooms LEFT JOIN rooms ON room_id = rooms.id WHERE rooms.id IS NULL");
}
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp < ? AND activation_timestamp != 0")) {
statement.setInt(1, Emulator.getIntUnixTimestamp() - 86400);
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp + duration < ? AND activation_timestamp > 0 AND duration > 0")) {
statement.setInt(1, Emulator.getIntUnixTimestamp());
statement.execute();
}

View File

@ -355,6 +355,8 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("snowstorm_tree", null));
this.interactionsList.add(new ItemInteraction("snowstorm_machine", null));
this.interactionsList.add(new ItemInteraction("snowstorm_pile", null));
this.interactionsList.add(new ItemInteraction("vote_counter", InteractionVoteCounter.class));
}

View File

@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
@ -15,41 +17,54 @@ import java.sql.SQLException;
public class InteractionFXBox extends InteractionDefault {
public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
this.setExtradata("0");
// this.setExtradata("0");
}
public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0");
// this.setExtradata("0");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
if (client != null && room.hasRights(client.getHabbo())) {
if (client != null && this.getUserId() == client.getHabbo().getHabboInfo().getId()) {
if(this.getExtradata().equals("1"))
return;
int effectId = -1;
if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) {
if (this.getBaseItem().getEffectM() > 0) {
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
effectId = this.getBaseItem().getEffectM();
}
}
if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) {
if (this.getBaseItem().getEffectF() > 0) {
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
effectId = this.getBaseItem().getEffectF();
}
}
if(effectId < 0)
return;
if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId))
return;
EffectsComponent.HabboEffect effect = client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0);
client.sendResponse(new UserEffectsListComposer(client.getHabbo()));
client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
this.setExtradata("1");
room.updateItemState(this);
room.removeHabboItem(this);
HabboItem item = this;
Emulator.getThreading().run(new Runnable() {
@Override
public void run() {
new QueryDeleteHabboItem(item.getId()).run();
room.sendComposer(new RemoveFloorItemComposer(item).compose());
}
Emulator.getThreading().run(() -> {
new QueryDeleteHabboItem(item.getId()).run();
room.sendComposer(new RemoveFloorItemComposer(item).compose());
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
}, 500);
}
}

View File

@ -21,7 +21,7 @@ public class InteractionTeleport extends HabboItem {
private int targetId;
private int targetRoomId;
private int roomUnitID = -1;
private boolean walkable = false;
private boolean walkable;
public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@ -82,6 +82,7 @@ public class InteractionTeleport extends HabboItem {
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
startTeleport(room, habbo);
walkable = true;
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
// set state 1 and walk on item
this.roomUnitID = unit.getId();
@ -93,11 +94,11 @@ public class InteractionTeleport extends HabboItem {
List<Runnable> onFail = new ArrayList<Runnable>();
onSuccess.add(() -> {
walkable = this.getBaseItem().allowWalk();
room.updateTile(currentLocation);
tryTeleport(client, room);
unit.removeOverrideTile(currentLocation);
unit.setCanLeaveRoomByDoor(true);
walkable = this.getBaseItem().allowWalk();
});
onFail.add(() -> {
@ -208,8 +209,10 @@ public class InteractionTeleport extends HabboItem {
}
public void startTeleport(Room room, Habbo habbo, int delay) {
if (habbo.getRoomUnit().isTeleporting)
if (habbo.getRoomUnit().isTeleporting) {
walkable = this.getBaseItem().allowWalk();
return;
}
this.roomUnitID = -1;
habbo.getRoomUnit().isTeleporting = true;

View File

@ -0,0 +1,106 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
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.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class InteractionVoteCounter extends HabboItem {
private boolean frozen;
private int votes;
private List<Integer> votedUsers;
public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
if(!this.getExtradata().contains(",")) {
this.setExtradata("1,0"); // frozen,votes
}
String[] bits = this.getExtradata().split(",");
frozen = bits[0].equals("1");
votes = Integer.parseInt(bits[1]);
votedUsers = new ArrayList<>();
}
public InteractionVoteCounter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
if(!extradata.contains(",")) {
extradata = "1,0";
}
String[] bits = extradata.split(",");
frozen = bits[0].equals("1");
votes = Integer.parseInt(bits[1]);
votedUsers = new ArrayList<>();
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0) + 3);
serverMessage.appendString(this.frozen ? "0" : "1");
serverMessage.appendInt(this.votes);
super.serializeExtradata(serverMessage);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
@Override
public boolean isWalkable() {
return false;
}
private void updateExtradata() {
this.setExtradata((this.frozen ? "1" : "0") + "," + this.votes);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
return;
this.frozen = !this.frozen;
if(!frozen) {
this.votes = 0;
this.votedUsers.clear();
}
updateExtradata();
this.needsUpdate(true);
room.updateItem(this);
}
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
public void vote(Room room, int UserId, int vote) {
if(frozen)
return;
if(votedUsers.contains(UserId))
return;
votedUsers.add(UserId);
votes += vote;
updateExtradata();
this.needsUpdate(true);
room.updateItem(this);
}
}

View File

@ -198,7 +198,11 @@ public enum RoomUnitEffect {
WATERINGCAN(192),
TRAMPOLINEJUMP(193),
TREADMILL(194),
CROSSTRAINER(195);
CROSSTRAINER(195),
STARWARS(196),
FLYINGCARPET(197),
YELLOWDUCK(198),
FLYNGTURTLE(199);
private int id;

View File

@ -34,6 +34,10 @@ public class EffectsComponent {
}
public HabboEffect createEffect(int effectId) {
return createEffect(effectId, 86400);
}
public HabboEffect createEffect(int effectId, int duration) {
HabboEffect effect;
synchronized (this.effects) {
if (this.effects.containsKey(effectId)) {
@ -44,6 +48,7 @@ public class EffectsComponent {
}
} else {
effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId());
effect.duration = duration;
effect.insert();
}
@ -159,6 +164,9 @@ public class EffectsComponent {
}
public boolean isRemaining() {
if(this.duration <= 0)
return true;
if (this.total > 0) {
if (this.activationTimestamp >= 0) {
if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) {
@ -172,6 +180,9 @@ public class EffectsComponent {
}
public int remainingTime() {
if(this.duration <= 0) //permanant
return Integer.MAX_VALUE;
return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration;
}

View File

@ -17,6 +17,8 @@ public class InviteFriendsEvent extends MessageHandler {
String message = this.packet.readString();
message = Emulator.getGameEnvironment().getWordFilter().filter(message, this.client.getHabbo());
for (int i : userIds) {
if (i == 0)
continue;

View File

@ -1,8 +1,10 @@
package com.eu.habbo.messages.incoming.rooms.users;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionVoteCounter;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.events.users.UserSignEvent;
@ -20,6 +22,16 @@ public class RoomUserSignEvent extends MessageHandler {
if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) {
this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + "");
this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo());
if(signId <= 10) {
int userId = this.client.getHabbo().getHabboInfo().getId();
for (HabboItem item : room.getFloorItems()) {
if (item instanceof InteractionVoteCounter) {
((InteractionVoteCounter)item).vote(room, userId, signId);
}
}
}
}
}
}

View File

@ -27,10 +27,16 @@ public class UserEffectsListComposer extends MessageComposer {
this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> {
UserEffectsListComposer.this.response.appendInt(effect.effect);
UserEffectsListComposer.this.response.appendInt(0);
UserEffectsListComposer.this.response.appendInt(effect.duration);
UserEffectsListComposer.this.response.appendInt(effect.total);
UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1);
UserEffectsListComposer.this.response.appendBoolean(effect.isActivated());
UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : 1);
UserEffectsListComposer.this.response.appendInt(effect.total - (effect.isActivated() ? 1 : 0));
if(!effect.isActivated()) {
UserEffectsListComposer.this.response.appendInt(0);
}
else {
UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? (Emulator.getIntUnixTimestamp() - effect.activationTimestamp) + effect.duration : -1);
}
UserEffectsListComposer.this.response.appendBoolean(effect.duration <= 0); //effect.isActivated());
return true;
});
}