This commit is contained in:
Alejandro 2019-06-05 00:47:27 +03:00
commit b2d18e7486
12 changed files with 175 additions and 279 deletions

View File

@ -15,4 +15,11 @@ ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFT
ALTER TABLE `support_tickets`
ADD COLUMN `group_id` int(11) NOT NULL AFTER `category`,
ADD COLUMN `thread_id` int(11) NOT NULL AFTER `group_id`,
ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`;
ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`;
ALTER TABLE `pet_actions`
ADD COLUMN `can_swim` enum('1','0') NULL DEFAULT '0' AFTER `random_actions`;
UPDATE `pet_actions` SET `can_swim` = '1' WHERE `pet_type` = 9 OR `pet_type` = 14 OR `pet_type` = 23 OR `pet_type` = 24 OR `pet_type` = 25 OR `pet_type` = 28 OR `pet_type` = 29 OR `pet_type` = 30 OR `pet_type` = 32;
UPDATE `items_base` SET `customparams` = '30,60,120,180,300,600', `interaction_type` = 'game_timer', `interaction_modes_count` = 1 WHERE `item_name` IN ('fball_counter','bb_counter','es_counter');

View File

@ -129,8 +129,6 @@ public abstract class Game implements Runnable {
Emulator.getPluginManager().fireEvent(gameStartedEvent);
}
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, this.room, new Object[]{this});
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
item.setExtradata("0");
this.room.updateItem(item);

View File

@ -2,19 +2,12 @@ package com.eu.habbo.habbohotel.games;
public enum GameTeamColors {
RED(0),
NONE(0),
GREEN(1),
BLUE(2),
YELLOW(3),
NONE(4),
RED(1),
GREEN(2),
BLUE(3),
YELLOW(4),
ONE(5),
TWO(6),
@ -41,6 +34,6 @@ public enum GameTeamColors {
}
}
return RED;
return NONE;
}
}

View File

@ -143,11 +143,10 @@ public class BattleBanzaiGame extends Game {
if (total >= this.tileCount && this.tileCount != 0) {
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
if (timer.isRunning())
timer.setRunning(false);
if (timer.isRunning()) {
timer.endGame(room);
}
}
InteractionGameTimer.endGames(room, true);
}
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);

View File

@ -211,4 +211,8 @@ public class Item {
public double[] getMultiHeights() {
return this.multiHeights;
}
public String getCustomParams() {
return customParams;
}
}

View File

@ -25,7 +25,6 @@ import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.Int
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.freeze.InteractionFreezeTimer;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGateBlue;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGateGreen;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGateRed;
@ -168,11 +167,11 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class));
this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class));
this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class));
this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class));
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class));
this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class));
@ -292,9 +291,6 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("wf_highscore", InteractionWiredHighscore.class));
//battlebanzai_pyramid
//battlebanzai_puck extends pushable
this.interactionsList.add(new ItemInteraction("battlebanzai_timer", InteractionBattleBanzaiTimer.class));
this.interactionsList.add(new ItemInteraction("battlebanzai_tile", InteractionBattleBanzaiTile.class));
this.interactionsList.add(new ItemInteraction("battlebanzai_random_teleport", InteractionBattleBanzaiTeleporter.class));
this.interactionsList.add(new ItemInteraction("battlebanzai_sphere", InteractionBattleBanzaiSphere.class));
@ -316,7 +312,6 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("freeze_block", InteractionFreezeBlock.class));
this.interactionsList.add(new ItemInteraction("freeze_tile", InteractionFreezeTile.class));
this.interactionsList.add(new ItemInteraction("freeze_exit", InteractionFreezeExitTile.class));
this.interactionsList.add(new ItemInteraction("freeze_timer", InteractionFreezeTimer.class));
this.interactionsList.add(new ItemInteraction("freeze_gate_blue", InteractionFreezeGateBlue.class));

View File

@ -17,80 +17,120 @@ import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public abstract class InteractionGameTimer extends HabboItem implements Runnable {
public class InteractionGameTimer extends HabboItem implements Runnable {
private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 };
private int baseTime = 0;
private int timeNow = 0;
private boolean isRunning = false;
private boolean isPaused = false;
private boolean threadActive = false;
public enum InteractionGameTimerAction {
START_STOP(1),
INCREASE_TIME(2);
private int action;
InteractionGameTimerAction(int action) {
this.action = action;
}
public int getAction() {
return action;
}
public static InteractionGameTimerAction getByAction(int action) {
if (action == 1) return START_STOP;
if (action == 2) return INCREASE_TIME;
return START_STOP;
}
}
public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
String[] data = set.getString("extra_data").split("\t");
parseCustomParams(baseItem);
if (data.length >= 2) {
this.baseTime = Integer.valueOf(data[1]);
this.timeNow = this.baseTime;
try {
String[] data = set.getString("extra_data").split("\t");
if (data.length >= 2) {
this.baseTime = Integer.valueOf(data[1]);
this.timeNow = this.baseTime;
}
if (data.length >= 1) {
this.setExtradata(data[0] + "\t0");
}
}
if (data.length >= 1) {
this.setExtradata(data[0]);
catch (Exception e) {
this.baseTime = TIMER_INTERVAL_STEPS[0];
this.timeNow = this.baseTime;
}
}
public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
parseCustomParams(item);
}
public static void endGamesIfLastTimer(Room room) {
boolean gamesActive = false;
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
if (timer.isRunning())
gamesActive = true;
public void parseCustomParams(Item baseItem) {
try {
String[] intervalSteps = baseItem.getCustomParams().split(",");
int[] finalSteps = new int[intervalSteps.length];
for (int i = 0; i < intervalSteps.length; i++) {
finalSteps[i] = Integer.parseInt(intervalSteps[i]);
}
TIMER_INTERVAL_STEPS = finalSteps;
}
if (!gamesActive) {
endGames(room);
catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
}
public static void endGames(Room room) {
endGames(room, false);
}
public void endGame(Room room) {
this.isRunning = false;
this.isPaused = false;
public static void endGames(Room room, boolean overrideTriggerWired) {
boolean triggerWired = false;
//end existing games
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = InteractionGameTimer.getOrCreateGame(room, gameClass);
if (!game.state.equals(GameState.IDLE)) {
triggerWired = true;
for (Game game : room.getGames()) {
if (!game.getState().equals(GameState.IDLE)) {
game.onEnd();
game.stop();
}
}
}
if (triggerWired) {
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
private void createNewGame(Room room) {
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game existingGame = room.getGame(gameClass);
if (existingGame != null) {
existingGame.initialise();
} else {
try {
Game game = gameClass.getDeclaredConstructor(Room.class).newInstance(room);
room.addGame(game);
game.initialise();
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
}
}
}
public static Game getOrCreateGame(Room room, Class<? extends Game> gameClass) {
Game game = (gameClass.cast(room.getGame(gameClass)));
if (game == null) {
try {
game = gameClass.getDeclaredConstructor(Room.class).newInstance(room);
room.addGame(game);
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
private void pause(Room room) {
for (Game game : room.getGames()) {
game.pause();
}
}
return game;
private void unpause(Room room) {
for (Game game : room.getGames()) {
game.unpause();
}
}
@Override
@ -117,27 +157,31 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
this.timeNow--;
room.updateItem(this);
} else {
this.isRunning = false;
this.isPaused = false;
this.threadActive = false;
endGamesIfLastTimer(room);
this.endGame(room);
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
}
@Override
public void onPickUp(Room room) {
this.setExtradata("0");
this.endGame(room);
this.setExtradata(this.baseTime + "\t" + this.baseTime);
this.needsUpdate(true);
}
@Override
public void onPlace(Room room) {
if (this.baseTime == 0) {
this.baseTime = 30;
this.timeNow = this.baseTime;
if (this.baseTime < this.TIMER_INTERVAL_STEPS[0]) {
this.baseTime = this.TIMER_INTERVAL_STEPS[0];
}
this.timeNow = this.baseTime;
this.setExtradata(this.timeNow + "\t" + this.baseTime);
room.updateItem(this);
this.needsUpdate(true);
super.onPlace(room);
}
@ -163,126 +207,84 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
if (this.getExtradata().isEmpty()) {
this.setExtradata("0");
this.setExtradata("0\t" + this.TIMER_INTERVAL_STEPS[0]);
}
// if wired triggered it
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning) {
endGamesIfLastTimer(room);
if (objects.length >= 2 && objects[1] instanceof WiredEffectType) {
if(!(!this.isRunning || this.isPaused))
return;
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass);
if (!game.isRunning) {
game.initialise();
}
boolean wasPaused = this.isPaused;
this.endGame(room);
if(wasPaused) {
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
timeNow = this.baseTime;
this.createNewGame(room);
this.timeNow = this.baseTime;
this.isRunning = true;
this.isPaused = false;
room.updateItem(this);
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{});
if (!this.threadActive) {
this.threadActive = true;
Emulator.getThreading().run(this);
Emulator.getThreading().run(this, 1000);
}
} else if (client != null) {
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
return;
int state = 1;
InteractionGameTimerAction state = InteractionGameTimerAction.START_STOP;
if (objects.length >= 1 && objects[0] instanceof Integer) {
state = (Integer) objects[0];
state = InteractionGameTimerAction.getByAction((int) objects[0]);
}
switch (state) {
case 1:
if (this.isRunning) {
case START_STOP:
if (this.isRunning) { // a game has been started
this.isPaused = !this.isPaused;
boolean allPaused = this.isPaused;
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
if (!timer.isPaused)
allPaused = false;
}
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass);
if (allPaused) {
game.pause();
} else {
game.unpause();
}
}
if (!this.isPaused) {
this.isRunning = true;
timeNow = this.baseTime;
room.updateItem(this);
if (this.isPaused) {
this.pause(room);
} else {
this.unpause(room);
if (!this.threadActive) {
this.threadActive = true;
Emulator.getThreading().run(this);
}
}
}
if (!this.isRunning) {
endGamesIfLastTimer(room);
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
Game game = getOrCreateGame(room, gameClass);
game.initialise();
}
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{});
} else {
this.isPaused = false;
this.isRunning = true;
timeNow = this.baseTime;
this.timeNow = this.baseTime;
room.updateItem(this);
this.createNewGame(room);
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{this});
if (!this.threadActive) {
this.threadActive = true;
Emulator.getThreading().run(this);
Emulator.getThreading().run(this, 1000);
}
}
break;
case 2:
case INCREASE_TIME:
if (!this.isRunning) {
this.increaseTimer(room);
return;
} else if (this.isPaused) {
this.endGame(room);
this.increaseTimer(room);
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
if (this.isPaused) {
this.isPaused = false;
this.isRunning = false;
timeNow = this.baseTime;
room.updateItem(this);
endGamesIfLastTimer(room);
}
break;
case 3:
this.isPaused = false;
this.isRunning = false;
timeNow = this.baseTime;
room.updateItem(this);
boolean gamesActive = false;
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
if (timer.isRunning())
gamesActive = true;
}
if (!gamesActive) {
endGames(room);
}
break;
}
}
@ -299,33 +301,24 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
if (this.isRunning)
return;
this.needsUpdate(true);
int baseTime = -1;
switch (this.baseTime) {
case 0:
this.baseTime = 30;
break;
case 30:
this.baseTime = 60;
break;
case 60:
this.baseTime = 120;
break;
case 120:
this.baseTime = 180;
break;
case 180:
this.baseTime = 300;
break;
case 300:
this.baseTime = 600;
break;
//case 600: this.baseTime = 0; break;
if (this.timeNow != this.baseTime) {
baseTime = this.baseTime;
} else {
for (int step : this.TIMER_INTERVAL_STEPS) {
if (this.timeNow < step) {
baseTime = step;
break;
}
}
default:
this.baseTime = 30;
if (baseTime == -1) baseTime = this.TIMER_INTERVAL_STEPS[0];
}
this.baseTime = baseTime;
this.setExtradata(this.timeNow + "\t" + this.baseTime);
this.timeNow = this.baseTime;
room.updateItem(this);
this.needsUpdate(true);
@ -333,11 +326,9 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
@Override
public String getDatabaseExtraData() {
return this.getExtradata() + "\t" + this.baseTime;
return this.getExtradata();
}
public abstract Class<? extends Game> getGameType();
@Override
public boolean allowWiredResetState() {
return true;
@ -350,12 +341,4 @@ public abstract class InteractionGameTimer extends HabboItem implements Runnable
public void setRunning(boolean running) {
isRunning = running;
}
public int getTimeNow() {
return timeNow;
}
public void setTimeNow(int timeNow) {
this.timeNow = timeNow;
}
}

View File

@ -1,41 +0,0 @@
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai;
import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionBattleBanzaiTimer extends InteractionGameTimer {
public InteractionBattleBanzaiTimer(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
public InteractionBattleBanzaiTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public Class<? extends Game> getGameType() {
return BattleBanzaiGame.class;
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
@Override
public boolean isWalkable() {
return false;
}
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
}

View File

@ -1,48 +0,0 @@
package com.eu.habbo.habbohotel.items.interactions.games.freeze;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionFreezeTimer extends InteractionGameTimer {
public InteractionFreezeTimer(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
public InteractionFreezeTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
@Override
public boolean isWalkable() {
return false;
}
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
}
@Override
public Class<? extends Game> getGameType() {
return FreezeGame.class;
}
}

View File

@ -31,6 +31,7 @@ public class PetData implements Comparable<PetData> {
public String[] actionsTired;
public String[] actionsRandom;
public THashMap<PetVocalsType, THashSet<PetVocal>> petVocals;
public boolean canSwim;
private int type;
private String name;
private List<PetCommand> petCommands;
@ -51,6 +52,7 @@ public class PetData implements Comparable<PetData> {
this.actionsHappy = set.getString("happy_actions").split(";");
this.actionsTired = set.getString("tired_actions").split(";");
this.actionsRandom = set.getString("random_actions").split(";");
this.canSwim = set.getString("can_swim").equalsIgnoreCase("1");
this.reset();
}

View File

@ -2147,6 +2147,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return null;
}
public ConcurrentSet<Game> getGames() {
return this.games;
}
public int getUserCount() {
return this.currentHabbos.size();
}
@ -4588,19 +4592,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<RoomUnit> units = new THashSet<>();
for (Habbo habbo : this.currentHabbos.values()) {
if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom().getId() == this.getId()) {
if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().getId() == this.getId()) {
units.add(habbo.getRoomUnit());
}
}
for (Pet pet : this.currentPets.valueCollection()) {
if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom().getId() == this.getId()) {
if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom() != null && pet.getRoomUnit().getRoom().getId() == this.getId()) {
units.add(pet.getRoomUnit());
}
}
for (Bot bot : this.currentBots.valueCollection()) {
if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom().getId() == this.getId()) {
if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom() != null && bot.getRoomUnit().getRoom().getId() == this.getId()) {
units.add(bot.getRoomUnit());
}
}

View File

@ -333,7 +333,7 @@ public class RoomUnit {
this.resetIdleTimer();
if (habbo != null) {
HabboItem topItem = this.room.getTopItemAt(next.x, next.y);
HabboItem topItem = room.getTopItemAt(next.x, next.y);
boolean isAtDoor = next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY();
boolean publicRoomKicks = !room.isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick");