mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
add notify + reject now throws
This commit is contained in:
parent
22350de481
commit
f51be46f8b
4 changed files with 62 additions and 71 deletions
|
|
@ -1,79 +1,71 @@
|
|||
package core.game.node.entity.skill.cooking;
|
||||
package core.game.node.entity.skill.cooking
|
||||
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import org.rs09.consts.Items;
|
||||
import core.game.node.`object`.GameObject
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Items.BREAD_DOUGH_2307
|
||||
import org.rs09.consts.Items.RAW_BEEF_2132
|
||||
import org.rs09.consts.Items.SEAWEED_401
|
||||
import org.rs09.consts.Items.UNCOOKED_CAKE_1889
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
//author: Ceik
|
||||
@Initializable
|
||||
public class CookingRewrite extends UseWithHandler {
|
||||
// fires/ranges
|
||||
public static final int[] OBJECTS = new int[] { 24313,21302, 13528, 13529, 13533, 13531, 13536, 13539, 13542, 2728, 2729, 2730, 2731, 2732, 2859, 3038, 3039, 3769, 3775, 4265, 4266, 5249, 5499, 5631, 5632, 5981, 9682, 10433, 11404, 11405, 11406, 12102, 12796, 13337, 13881, 14169, 14919, 15156, 20000, 20001, 21620, 21792, 22713, 22714, 23046, 24283, 24284, 25155, 25156, 25465, 25730, 27297, 29139, 30017, 32099, 33500, 34495, 34546, 36973, 37597, 37629, 37726, 114, 4172, 5275, 8750, 16893, 22154, 34410, 34565, 114, 9085, 9086, 9087, 12269, 15398, 25440, 25441, 2724, 2725, 2726, 4618, 4650, 5165, 6093, 6094, 6095, 6096, 8712, 9439, 9440, 9441, 10824, 17640, 17641, 17642, 17643, 18039, 21795, 24285, 24329, 27251, 33498, 35449, 36815, 36816, 37426, 40110 };
|
||||
class CookingRewrite : InteractionListener() {
|
||||
|
||||
// raw foods
|
||||
public CookingRewrite() {
|
||||
super(2140, 1861, 3228, 7521, 3151, 325, 319, 347, 355, 333, 339, 351, 329, 3381, 361, 10136, 5003, 379, 365, 373, 2149, 7946, 385, 397, 391, 3369, 3371, 3373, 1893, 1895, 1897, 1899, 1901, 1963, 2102, 2120, 2108, 5972, 5504, 1982, 1965, 1957, 5988, 1781, 6701, 6703, 6705, 7056, 7058, 7060, 1933, 1783, 1927, 1929, 6032, 6034, 2011, 227, 1921, 1937, 7934, 7086, 4239, 7068, 7086, 2003, 7078, 7072, 4239, 7062, 7064, 7084, 1871, 7082, 2309, 1891, 1967, 1971, 2142, 9436, 2142, 2142, 2325, 2333, 2327, 2331, 7170, 2323, 2335, 7178, 7180, 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 315, 9988, 2878, 7568, 9980, 7223, 5982, 598, 4293, 10816, 2138, 2134, 3142, 2136, 1859, 3226, 7518, 3150, 327, 321, 345, 353, 335, 341, 349, 331, 3379, 359, 10138, 5001, 377, 363, 371, 2148, 7944, 383, 395, 389, 3363, 3365, 3367, 5986, 401, 1942, 4237, 2001, 7076, 1871, 7080, 2307, 1889, 2132, 2132, 2132, 2132, 2321, 2319, 7168, 2317, 7176, 7186, 7196, 7206, 7216, 2287, 317, 9986, 2876, 7566, 9984, 7224, Items.RAW_OOMLIE_2337, Items.WRAPPED_OOMLIE_2341, Items.COOKED_OOMLIE_WRAP_2343);
|
||||
val RAW_FOODS: IntArray
|
||||
|
||||
init {
|
||||
val list = CookableItems.values().map { it.raw }.toMutableList()
|
||||
list.add(Items.COOKED_MEAT_2142)
|
||||
RAW_FOODS = list.toIntArray()
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
new FoodCookingDialogue().init();
|
||||
for (int object : OBJECTS) {
|
||||
addHandler(object, OBJECT_TYPE, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
override fun defineListeners() {
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
int item = event.getUsedItem().getId();
|
||||
Player player = event.getPlayer();
|
||||
GameObject object = (GameObject) event.getUsedWith();
|
||||
boolean range = object.getName().toLowerCase().contains("range");
|
||||
onUseWith(OBJECT,RAW_FOODS, *COOKING_OBJs){player, used, with ->
|
||||
val item = used.asItem()
|
||||
val obj = with.asObject()
|
||||
val range = obj.name.toLowerCase().contains("range")
|
||||
when (item.id) {
|
||||
RAW_BEEF_2132 -> if (range) {
|
||||
player.dialogueInterpreter.open(FoodCookingDialogue.DialogueID, item, 9436, true, obj)
|
||||
return@onUseWith true
|
||||
}
|
||||
SEAWEED_401 -> if (range) {
|
||||
player.dialogueInterpreter.open(FoodCookingDialogue.DialogueID, item, 1781, false, obj)
|
||||
return@onUseWith true
|
||||
}
|
||||
BREAD_DOUGH_2307, UNCOOKED_CAKE_1889 -> if (!range) {
|
||||
player.packetDispatch.sendMessage("You need to cook this on a range.")
|
||||
return@onUseWith false
|
||||
}
|
||||
}
|
||||
|
||||
//range checks when necessary
|
||||
switch(item){
|
||||
case Items.RAW_BEEF_2132: //sinew
|
||||
if(range) {
|
||||
player.getDialogueInterpreter().open(FoodCookingDialogue.DialogueID, item, 9436, true, object);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case Items.SEAWEED_401: //soda ash
|
||||
if(range) {
|
||||
player.getDialogueInterpreter().open(FoodCookingDialogue.DialogueID, item, 1781, false, object);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case Items.BREAD_DOUGH_2307:
|
||||
case Items.UNCOOKED_CAKE_1889: //cake, bread
|
||||
if(!range){
|
||||
player.getPacketDispatch().sendMessage("You need to cook this on a range.");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
//cook a standard item
|
||||
player.dialogueInterpreter.open(FoodCookingDialogue.DialogueID, item.id, obj)
|
||||
return@onUseWith true
|
||||
}
|
||||
|
||||
//cook a standard item
|
||||
player.getDialogueInterpreter().open(FoodCookingDialogue.DialogueID,item,event.getUsedWith());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void cook(Player player, GameObject object, int initial, int product, int amount){
|
||||
Item food = new Item(initial);
|
||||
if(food.getName().toLowerCase().contains("pizza")){
|
||||
player.getPulseManager().run(new PizzaCookingPulse(player,object,initial,product,amount));
|
||||
} else if (food.getName().toLowerCase().contains("pie")){
|
||||
player.getPulseManager().run(new PieCookingPulse(player,object,initial,product,amount));
|
||||
} else if(CookableItems.intentionalBurn(initial)) {
|
||||
player.getPulseManager().run(new IntentionalBurnPulse(player, object, initial, product, amount));
|
||||
} else {
|
||||
player.getPulseManager().run(new StandardCookingPulse(player, object, initial, product, amount));
|
||||
companion object {
|
||||
val COOKING_OBJs = intArrayOf(24313,21302, 13528, 13529, 13533, 13531, 13536, 13539, 13542, 2728, 2729, 2730, 2731, 2732, 2859, 3038, 3039, 3769, 3775, 4265, 4266, 5249, 5499, 5631, 5632, 5981, 9682, 10433, 11404, 11405, 11406, 12102, 12796, 13337, 13881, 14169, 14919, 15156, 20000, 20001, 21620, 21792, 22713, 22714, 23046, 24283, 24284, 25155, 25156, 25465, 25730, 27297, 29139, 30017, 32099, 33500, 34495, 34546, 36973, 37597, 37629, 37726, 114, 4172, 5275, 8750, 16893, 22154, 34410, 34565, 114, 9085, 9086, 9087, 12269, 15398, 25440, 25441, 2724, 2725, 2726, 4618, 4650, 5165, 6093, 6094, 6095, 6096, 8712, 9439, 9440, 9441, 10824, 17640, 17641, 17642, 17643, 18039, 21795, 24285, 24329, 27251, 33498, 35449, 36815, 36816, 37426, 40110)
|
||||
|
||||
@JvmStatic
|
||||
fun cook(player: Player, `object`: GameObject?, initial: Int, product: Int, amount: Int) {
|
||||
val food = Item(initial)
|
||||
if (food.name.toLowerCase().contains("pizza")) {
|
||||
player.pulseManager.run(PizzaCookingPulse(player, `object`, initial, product, amount))
|
||||
} else if (food.name.toLowerCase().contains("pie")) {
|
||||
player.pulseManager.run(PieCookingPulse(player, `object`, initial, product, amount))
|
||||
} else if (CookableItems.intentionalBurn(initial)) {
|
||||
player.pulseManager.run(IntentionalBurnPulse(player, `object`, initial, product, amount))
|
||||
} else {
|
||||
player.pulseManager.run(StandardCookingPulse(player, `object`, initial, product, amount))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,11 +38,11 @@ abstract class CommandSet(val defaultPrivilege: Command.Privilege) : Plugin<Any?
|
|||
}
|
||||
|
||||
/**
|
||||
* Glorified player.sendMessage with green text coloring and an arrow. Use this when you need to
|
||||
* Glorified player.sendMessage with black text coloring and an arrow. Use this when you need to
|
||||
* notify/inform a player of some information from within the command without ending execution.
|
||||
*/
|
||||
fun notify(player: Player, message: String){
|
||||
player.sendMessage(colorize("%G-->$message"))
|
||||
player.sendMessage(colorize("-->$message"))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
|||
val l = player.location
|
||||
val r = player.viewport.region
|
||||
var obj: GameObject? = null
|
||||
player.packetDispatch.sendMessage("Absolute: " + l + ", regional: [" + l.localX + ", " + l.localY + "], chunk: [" + l.chunkOffsetX + ", " + l.chunkOffsetY + "], flag: [" + RegionManager.isTeleportPermitted(l) + ", " + RegionManager.getClippingFlag(l) + ", " + RegionManager.isLandscape(l) + "].")
|
||||
player.packetDispatch.sendMessage("Region: [id=" + l.regionId + ", active=" + r.isActive + ", instanced=" + (r is DynamicRegion) + "], obj=" + RegionManager.getObject(l) + ".")
|
||||
player.packetDispatch.sendMessage("Object: " + RegionManager.getObject(l).also{obj = it} + ".")
|
||||
player.packetDispatch.sendMessage("Object Varp: " + obj?.definition?.configFile?.configId + " offset: " + obj?.definition?.configFile?.bitShift + " size: " + (obj?.definition?.configFile?.bitShift?.minus(obj?.definition?.configFile?.bitShift!!)))
|
||||
notify(player,"Absolute: " + l + ", regional: [" + l.localX + ", " + l.localY + "], chunk: [" + l.chunkOffsetX + ", " + l.chunkOffsetY + "], flag: [" + RegionManager.isTeleportPermitted(l) + ", " + RegionManager.getClippingFlag(l) + ", " + RegionManager.isLandscape(l) + "].")
|
||||
notify(player,"Region: [id=" + l.regionId + ", active=" + r.isActive + ", instanced=" + (r is DynamicRegion) + "], obj=" + RegionManager.getObject(l) + ".")
|
||||
notify(player,"Object: " + RegionManager.getObject(l).also{obj = it} + ".")
|
||||
notify(player,"Object Varp: " + obj?.definition?.configFile?.configId + " offset: " + obj?.definition?.configFile?.bitShift + " size: " + (obj?.definition?.configFile?.bitShift?.minus(obj?.definition?.configFile?.bitShift!!)))
|
||||
SystemLogger.logInfo("Viewport: " + l.getSceneX(player.playerFlags.lastSceneGraph) + "," + l.getSceneY(player.playerFlags.lastSceneGraph))
|
||||
val loc = "Location.create(" + l.x + ", " + l.y + ", " + l.z + ")"
|
||||
SystemLogger.logInfo(loc + "; " + player.playerFlags.lastSceneGraph + ", " + l.localX + ", " + l.localY)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import core.plugin.Initializable
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.system.command.Command
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.tools.getAmount
|
||||
|
||||
@Initializable
|
||||
class SystemCommandSet : CommandSet(Command.Privilege.ADMIN) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue