mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 15:36:27 +01:00
Add Usage Policy and Remote Switch
This commit is contained in:
parent
0a6355996a
commit
c48f20c73f
@ -168,6 +168,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("youtube", InteractionYoutubeTV.class));
|
||||
this.interactionsList.add(new ItemInteraction("jukebox", InteractionJukeBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("switch", InteractionSwitch.class));
|
||||
this.interactionsList.add(new ItemInteraction("switch_remote_control", InteractionSwitchRemoteControl.class));
|
||||
this.interactionsList.add(new ItemInteraction("fx_box", InteractionFXBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("blackhole", InteractionBlackHole.class));
|
||||
this.interactionsList.add(new ItemInteraction("effect_toggle", InteractionEffectToggle.class));
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionSwitchRemoteControl extends InteractionDefault {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionSwitchRemoteControl.class);
|
||||
|
||||
public InteractionSwitchRemoteControl(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionSwitchRemoteControl(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isUsable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (room != null) {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (this.getExtradata().isEmpty())
|
||||
this.setExtradata("0");
|
||||
|
||||
if (this.getBaseItem().getStateCount() > 0) {
|
||||
int currentState = 0;
|
||||
|
||||
try {
|
||||
currentState = Integer.parseInt(this.getExtradata());
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.error("Incorrect extradata ({}) for item ID ({}) of type ({})", this.getExtradata(), this.getId(), this.getBaseItem().getName());
|
||||
}
|
||||
|
||||
this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount());
|
||||
this.needsUpdate(true);
|
||||
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.eu.habbo.messages.outgoing.rooms.items;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionGift;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
@ -23,7 +22,7 @@ public class AddFloorItemComposer extends MessageComposer {
|
||||
this.response.appendInt(this.item instanceof InteractionGift ? ((((InteractionGift) this.item).getColorId() * 1000) + ((InteractionGift) this.item).getRibbonId()) : (this.item instanceof InteractionMusicDisc ? ((InteractionMusicDisc) this.item).getSongId() : 1));
|
||||
this.item.serializeExtradata(this.response);
|
||||
this.response.appendInt(-1);
|
||||
this.response.appendInt(this.item.isUsable());
|
||||
this.response.appendInt(this.item instanceof InteractionTeleport || this.item instanceof InteractionSwitch || this.item instanceof InteractionSwitchRemoteControl || this.item instanceof InteractionVendingMachine || this.item instanceof InteractionInformationTerminal || this.item instanceof InteractionPostIt|| this.item instanceof InteractionPuzzleBox ? 2 : this.item.isUsable() ? 1 : 0);
|
||||
this.response.appendInt(this.item.getUserId());
|
||||
this.response.appendString(this.itemOwnerName);
|
||||
return this.response;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.eu.habbo.messages.outgoing.rooms.items;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionGift;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
@ -45,7 +44,7 @@ public class RoomFloorItemsComposer extends MessageComposer {
|
||||
this.response.appendInt(item instanceof InteractionGift ? ((((InteractionGift) item).getColorId() * 1000) + ((InteractionGift) item).getRibbonId()) : (item instanceof InteractionMusicDisc ? ((InteractionMusicDisc) item).getSongId() : 1));
|
||||
item.serializeExtradata(this.response);
|
||||
this.response.appendInt(-1);
|
||||
this.response.appendInt(item.isUsable() ? 1 : 0);
|
||||
this.response.appendInt(item instanceof InteractionTeleport || item instanceof InteractionSwitch || item instanceof InteractionSwitchRemoteControl || item instanceof InteractionVendingMachine || item instanceof InteractionInformationTerminal || item instanceof InteractionPostIt || item instanceof InteractionPuzzleBox ? 2 : item.isUsable() ? 1 : 0);
|
||||
this.response.appendInt(item.getUserId());
|
||||
}
|
||||
return this.response;
|
||||
|
Loading…
Reference in New Issue
Block a user