forked from 2009Scape/Server
Rebase with upstream
This commit is contained in:
commit
101b8314c9
2889 changed files with 481914 additions and 0 deletions
|
|
@ -0,0 +1,117 @@
|
|||
package plugin.skill.construction;
|
||||
|
||||
|
||||
import org.crandor.cache.def.impl.ItemDefinition;
|
||||
import org.crandor.game.component.Component;
|
||||
import org.crandor.game.component.ComponentDefinition;
|
||||
import org.crandor.game.component.ComponentPlugin;
|
||||
import org.crandor.game.content.skill.Skills;
|
||||
import org.crandor.game.content.skill.member.construction.*;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.object.GameObject;
|
||||
import org.crandor.plugin.InitializablePlugin;
|
||||
import org.crandor.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Handles the creating of a decoration object.
|
||||
* @author Emperor
|
||||
*
|
||||
*/
|
||||
@InitializablePlugin
|
||||
public final class ConstructionInterface extends ComponentPlugin {
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ComponentDefinition.put(396, this);
|
||||
ComponentDefinition.put(398, this);
|
||||
ComponentDefinition.put(402, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
|
||||
switch (component.getId()) {
|
||||
case 396:
|
||||
switch (button) {
|
||||
case 11:
|
||||
player.getInterfaceManager().close();
|
||||
Hotspot hotspot = player.getAttribute("con:hotspot");
|
||||
GameObject object = player.getAttribute("con:hsobject");
|
||||
if (hotspot == null || object == null) {
|
||||
System.err.println("Failed building decoration " + hotspot + " : " + object);
|
||||
break;
|
||||
}
|
||||
slot = ((slot % 2 != 0) ? 4 : 0) + (slot >> 1);
|
||||
if (slot >= hotspot.getHotspot().getDecorations().length) {
|
||||
System.err.println("Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length);
|
||||
break;
|
||||
}
|
||||
boolean debug = player.isStaff();
|
||||
Decoration deco = hotspot.getHotspot().getDecorations()[slot];
|
||||
if (!debug) {
|
||||
if (player.getSkills().getLevel(Skills.CONSTRUCTION) < deco.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need to have a Construction level of " + deco.getLevel() + " to build that.");
|
||||
return true;
|
||||
}
|
||||
if (!player.getInventory().containsItems(deco.getItems())) {
|
||||
player.getPacketDispatch().sendMessage("You don't have the right materials.");
|
||||
return true;
|
||||
}
|
||||
for (int tool : deco.getTools()) {
|
||||
if (tool == BuildingUtils.WATERING_CAN) {
|
||||
boolean hasWateringCan = false;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (player.getInventory().contains(tool - i, 1)) {
|
||||
hasWateringCan = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasWateringCan) {
|
||||
player.getPacketDispatch().sendMessage("You need a watering can to plant this.");
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!player.getInventory().contains(tool, 1)) {
|
||||
player.getPacketDispatch().sendMessage("You need a " + ItemDefinition.forId(tool).getName() + " to build this.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
BuildingUtils.buildDecoration(player, hotspot, deco, object);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 398:
|
||||
switch (button) {
|
||||
case 15:
|
||||
player.getHouseManager().toggleBuildingMode(player, true);
|
||||
return true;
|
||||
case 1:
|
||||
player.getHouseManager().toggleBuildingMode(player, false);
|
||||
return true;
|
||||
case 27:
|
||||
player.getHouseManager().expelGuests(player);
|
||||
return true;
|
||||
case 29:
|
||||
if (!player.getHouseManager().isInHouse(player)) {
|
||||
player.getPacketDispatch().sendMessage("You can't do this outside of your house.");
|
||||
return true;
|
||||
}
|
||||
HouseManager.leave(player);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 402:
|
||||
int index = button - 160;
|
||||
//System.err.println("BuildRoom Interface Index: " + index);
|
||||
if (index > -1 && index < RoomProperties.values().length) {
|
||||
player.getDialogueInterpreter().open("con:room", RoomProperties.values()[index]);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue