mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Merge branch 'feature/costumegate' into 'dev'
Added EffectGate interaction #901 See merge request morningstar/Arcturus-Community!336
This commit is contained in:
commit
5bff4ddbb9
@ -141,6 +141,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("puzzle_box", InteractionPuzzleBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("hopper", InteractionHopper.class));
|
||||
this.interactionsList.add(new ItemInteraction("costume_hopper", InteractionCostumeHopper.class));
|
||||
this.interactionsList.add(new ItemInteraction("effect_gate", InteractionEffectGate.class));
|
||||
this.interactionsList.add(new ItemInteraction("club_hopper", InteractionHabboClubHopper.class));
|
||||
this.interactionsList.add(new ItemInteraction("club_gate", InteractionHabboClubGate.class));
|
||||
this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionHabboClubTeleportTile.class));
|
||||
|
@ -0,0 +1,85 @@
|
||||
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.items.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.threading.runnables.CloseGate;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionEffectGate extends InteractionDefault implements ConditionalGate {
|
||||
|
||||
// List of Habboween costumes according to http://www.habboxwiki.com/Costumes
|
||||
private static final List<Integer> defaultAllowedEnables = new ArrayList<>(Arrays.asList(
|
||||
114, // Strong Arms
|
||||
115, // Ringmaster Costume
|
||||
116, // Fly Head
|
||||
117, // Executioner Hood
|
||||
118, // Evil Clown Paint
|
||||
135 // Marionette
|
||||
));
|
||||
|
||||
public InteractionEffectGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
public InteractionEffectGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
if (roomUnit == null || room == null)
|
||||
return false;
|
||||
|
||||
String customparams = this.getBaseItem().getCustomParams().trim();
|
||||
|
||||
if (!customparams.isEmpty()) {
|
||||
return Arrays.asList(customparams.split(";"))
|
||||
.contains(Integer.valueOf(roomUnit.getEffectId()).toString());
|
||||
}
|
||||
|
||||
return defaultAllowedEnables.contains(roomUnit.getEffectId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
if (this.canWalkOn(roomUnit, room, objects)) {
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
|
||||
Emulator.getThreading().run(new CloseGate(this, room), 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ 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.items.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
@ -13,7 +14,7 @@ import com.eu.habbo.threading.runnables.CloseGate;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionGuildGate extends InteractionGuildFurni {
|
||||
public class InteractionGuildGate extends InteractionGuildFurni implements ConditionalGate {
|
||||
public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
@ -61,4 +62,9 @@ public class InteractionGuildGate extends InteractionGuildFurni {
|
||||
this.setExtradata("0");
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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.items.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
@ -12,7 +13,7 @@ import com.eu.habbo.threading.runnables.CloseGate;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionHabboClubGate extends InteractionDefault {
|
||||
public class InteractionHabboClubGate extends InteractionDefault implements ConditionalGate {
|
||||
public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
@ -42,14 +43,6 @@ public class InteractionHabboClubGate extends InteractionDefault {
|
||||
if (this.canWalkOn(roomUnit, room, objects)) {
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
} else {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
|
||||
}
|
||||
|
||||
roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,4 +63,14 @@ public class InteractionHabboClubGate extends InteractionDefault {
|
||||
|
||||
Emulator.getThreading().run(new CloseGate(this, room), 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
if (roomUnit == null || room == null)
|
||||
return;
|
||||
|
||||
room.getHabbo(roomUnit).getClient().sendResponse(
|
||||
new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.interfaces;
|
||||
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
|
||||
public interface ConditionalGate {
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
|
||||
}
|
@ -3,16 +3,13 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionHabboClubGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||
import com.eu.habbo.habbohotel.users.DanceType;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
|
||||
@ -301,17 +298,16 @@ public class RoomUnit {
|
||||
if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) {
|
||||
if (item.canWalkOn(this, room, null)) {
|
||||
item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next});
|
||||
} else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) {
|
||||
} else if (item instanceof ConditionalGate) {
|
||||
this.setRotation(oldRotation);
|
||||
this.tilesWalked--;
|
||||
this.setGoalLocation(this.currentLocation);
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
room.sendComposer(new RoomUserStatusComposer(this).compose());
|
||||
|
||||
if (item instanceof InteractionHabboClubGate && habbo != null) {
|
||||
habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
|
||||
if (habbo != null) {
|
||||
((ConditionalGate) item).onRejected(this, this.getRoom(), new Object[]{});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -4,22 +4,22 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
|
||||
public class CloseGate implements Runnable {
|
||||
private final HabboItem guildGate;
|
||||
private final HabboItem gate;
|
||||
private final Room room;
|
||||
|
||||
public CloseGate(HabboItem guildGate, Room room) {
|
||||
this.guildGate = guildGate;
|
||||
public CloseGate(HabboItem gate, Room room) {
|
||||
this.gate = gate;
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.guildGate.getRoomId() == this.room.getId()) {
|
||||
if (this.gate.getRoomId() == this.room.getId()) {
|
||||
if (this.room.isLoaded()) {
|
||||
if (this.room.getHabbosAt(this.guildGate.getX(), this.guildGate.getY()).isEmpty()) {
|
||||
this.guildGate.setExtradata("0");
|
||||
this.room.updateItem(this.guildGate);
|
||||
this.guildGate.needsUpdate(true);
|
||||
if (this.room.getHabbosAt(this.gate.getX(), this.gate.getY()).isEmpty()) {
|
||||
this.gate.setExtradata("0");
|
||||
this.room.updateItem(this.gate);
|
||||
this.gate.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user