Files
2009scape/Server/src/main/content/global/skill/construction/RemovalDialogue.java
T
Ceikry a100affda2 Repository reorganisation
Unified kotlin and java into just src/main
Unified the rs09 and core packages
Took all content out of the core package, and placed it into the new content package
Reorganised all source code relating to content to be easier to find and explore
2023-01-26 13:59:28 +00:00

102 lines
2.4 KiB
Java

package content.global.skill.construction;
import core.game.dialogue.DialogueInterpreter;
import core.game.dialogue.DialoguePlugin;
import core.game.node.entity.player.Player;
import core.plugin.Initializable;
/**
* Removal dialogue for room & decorations in construction
* @author Clayton Williams
* @author Emperor
* @date Jun-30-2015
*/
@Initializable
public final class RemovalDialogue extends DialoguePlugin {
/**
* The room position.
*/
private int[] pos;
/**
* The plane.
*/
private int plane;
/**
* The room to remove.
*/
private Room room;
/**
* Removal Dialogue
*/
public RemovalDialogue() {
super();
}
/**
* Removal Dialogue
* @param player
*/
public RemovalDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new RemovalDialogue(player);
}
@Override
public boolean open(Object... args) {
pos = (int[]) args[1];
plane = player.getLocation().getZ();
if (HouseManager.isInDungeon(player)) {
plane = 3;
}
room = player.getHouseManager().getRooms()[plane][pos[0]][pos[1]];
player.getDialogueInterpreter().sendOptions("Remove the " + (room != null ? room.getProperties().getName() : "room") + "?", "Yes", "No");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
if (stage == 0) {
if (buttonId == 1) {
if (plane == 0 && player.getHouseManager().hasRoomAt(1, pos[0], pos[1])) {
interpreter.sendPlainMessage(false, "You can't remove a room supporting another room.");
stage = 1;
return true;
}
if (room != null && room.getProperties().isLand()) {
Hotspot h = room.getHotspots()[0];
if (h != null && h.getDecorationIndex() == 0 && player.getHouseManager().getPortalAmount() <= 1) {
interpreter.sendPlainMessage(false, "You can't remove the garden with your portal in it.");
stage = 1;
return true;
}
}
player.getHouseManager().getRooms()[plane][pos[0]][pos[1]] = null;
for (int i = plane; i < 3; i++) {
Room r = player.getHouseManager().getRooms()[i][pos[0]][pos[1]];
if (r != null && r.getProperties().isRoof()) {
player.getHouseManager().getRooms()[i][pos[0]][pos[1]] = null;
}
}
player.getHouseManager().reload(player, true);
}
}
end();
return true;
}
@Override
public int[] getIds() {
return new int[]{ DialogueInterpreter.getDialogueKey("con:remove") };
}
}