mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 08:20:51 +01:00
Fix wf_blob
This commit is contained in:
parent
34d8d0f8c5
commit
e993a0e95e
@ -1,4 +1,7 @@
|
|||||||
ALTER TABLE `users_pets`
|
ALTER TABLE `users_pets`
|
||||||
ADD COLUMN `saddle_item_id` int(11) NULL;
|
ADD COLUMN `saddle_item_id` int(11) NULL;
|
||||||
|
|
||||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!');
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!');
|
||||||
|
|
||||||
|
UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob';
|
||||||
|
UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2';
|
||||||
|
@ -132,8 +132,7 @@ public abstract class Game implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
|
||||||
item.setExtradata("0");
|
((WiredBlob) item).onGameStart(this.room);
|
||||||
this.room.updateItem(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +190,10 @@ public abstract class Game implements Runnable {
|
|||||||
((InteractionWiredHighscore) item).reloadData();
|
((InteractionWiredHighscore) item).reloadData();
|
||||||
this.room.updateItem(item);
|
this.room.updateItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
|
||||||
|
((WiredBlob) item).onGameEnd(this.room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void run();
|
public abstract void run();
|
||||||
|
@ -1,66 +1,120 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
|
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.games.Game;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameState;
|
||||||
|
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class WiredBlob extends InteractionDefault {
|
public class WiredBlob extends InteractionDefault {
|
||||||
|
enum WiredBlobState {
|
||||||
|
ACTIVE("0"),
|
||||||
|
USED("1");
|
||||||
|
|
||||||
|
private String state;
|
||||||
|
WiredBlobState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int POINTS_REWARD = 0;
|
||||||
|
private boolean RESETS_WITH_GAME = true;
|
||||||
|
|
||||||
public WiredBlob(ResultSet set, Item baseItem) throws SQLException {
|
public WiredBlob(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
|
|
||||||
|
this.parseCustomParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
|
||||||
|
this.parseCustomParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlace(Room room) {
|
||||||
|
super.onPlace(room);
|
||||||
|
|
||||||
|
this.setExtradata(WiredBlobState.USED.getState());
|
||||||
|
room.updateItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
|
|
||||||
if (this.getExtradata().equals("0")) {
|
if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return;
|
||||||
Habbo habbo = room.getHabbo(roomUnit);
|
|
||||||
|
|
||||||
if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) {
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
int points = Emulator.getConfig().getInt("hotel.item.wiredblob." + this.getBaseItem().getName());
|
|
||||||
|
|
||||||
if (points == 0) {
|
if (habbo != null) {
|
||||||
Emulator.getConfig().register("hotel.item.wiredblob." + this.getBaseItem().getName(), "3000");
|
GamePlayer player = habbo.getHabboInfo().getGamePlayer();
|
||||||
points = 1;
|
|
||||||
|
if (player != null) {
|
||||||
|
player.addScore(this.POINTS_REWARD);
|
||||||
|
|
||||||
|
BattleBanzaiGame battleBanzaiGame = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
|
||||||
|
|
||||||
|
if (battleBanzaiGame != null && battleBanzaiGame.getState() != GameState.IDLE) {
|
||||||
|
battleBanzaiGame.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean triggered = false;
|
this.setExtradata(WiredBlobState.USED.getState());
|
||||||
Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());
|
room.updateItem(this);
|
||||||
|
|
||||||
if (game != null) {
|
|
||||||
GameTeam team = game.getTeamForHabbo(habbo);
|
|
||||||
|
|
||||||
if (team != null) {
|
|
||||||
team.addTeamScore(points);
|
|
||||||
triggered = true;
|
|
||||||
} else {
|
|
||||||
GamePlayer player = habbo.getHabboInfo().getGamePlayer();
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.addScore(points);
|
|
||||||
triggered = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggered) {
|
|
||||||
this.setExtradata("1");
|
|
||||||
room.updateItem(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
|
if (!this.RESETS_WITH_GAME && objects != null && objects.length == 2 && objects[1].equals(WiredEffectType.TOGGLE_STATE) && room.getGames().stream().anyMatch(game -> game.getState().equals(GameState.RUNNING) || game.getState().equals(GameState.PAUSED))) {
|
||||||
|
this.setExtradata(this.getExtradata().equals(WiredBlobState.ACTIVE.getState()) ? WiredBlobState.USED.getState() : WiredBlobState.ACTIVE.getState());
|
||||||
|
room.updateItem(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGameStart(Room room) {
|
||||||
|
if (this.RESETS_WITH_GAME) {
|
||||||
|
this.setExtradata(WiredBlobState.ACTIVE.getState());
|
||||||
|
room.updateItem(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGameEnd(Room room) {
|
||||||
|
this.setExtradata(WiredBlobState.USED.getState());
|
||||||
|
room.updateItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseCustomParams() {
|
||||||
|
String[] params = this.getBaseItem().getCustomParams().split(",");
|
||||||
|
|
||||||
|
if (params.length != 2) {
|
||||||
|
Emulator.getLogging().logErrorLine("Wired blobs should have customparams with two parameters (points,resetsWithGame)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.POINTS_REWARD = Integer.parseInt(params[0]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Emulator.getLogging().logErrorLine("Wired blobs should have customparams with the first parameter being the amount of points (number)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RESETS_WITH_GAME = params[1].equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user