Merge remote-tracking branch 'upstream/master'

This commit is contained in:
skelsoft
2021-06-29 09:40:50 +10:00
12 changed files with 69 additions and 118 deletions
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.cache.def.impl.CS2Mapping;
import core.cache.def.impl.ItemDefinition;
import core.game.component.Component;
@@ -19,6 +20,7 @@ import core.net.packet.context.ContainerContext;
import core.net.packet.out.ContainerPacket;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
import rs09.game.ge.GrandExchangeOffer;
import rs09.game.ge.PlayerGrandExchange;
import rs09.game.interaction.npc.BogrogPouchSwapper;
@@ -333,17 +335,13 @@ public class GrandExchangeInterface extends ComponentPlugin {
setOfferAmount(player, offer, amount + 1000);
return true;
case 170: // value x
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
if (player.getInterfaceManager().getChatbox().getId() == 389) {
player.getPlayerGrandExchange().openSearch();
}
setOfferAmount(player, offer, (int) value);
return true;
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
if (player.getInterfaceManager().getChatbox().getId() == 389) {
player.getPlayerGrandExchange().openSearch();
}
setOfferAmount(player, offer, (int) value);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return false;
case 180:
if (offer != null) {
@@ -370,17 +368,13 @@ public class GrandExchangeInterface extends ComponentPlugin {
player.getPacketDispatch().sendMessage("Please select an offer first.");
return true;
}
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
if (player.getInterfaceManager().getChatbox().getId() == 389) {
player.getPlayerGrandExchange().openSearch();
}
setOfferValue(player, offer, (int) value);
return true;
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
if (player.getInterfaceManager().getChatbox().getId() == 389) {
player.getPlayerGrandExchange().openSearch();
}
setOfferValue(player, offer, (int) value);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return false;
case 195:
player.getInterfaceManager().close();
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.cache.def.impl.ItemDefinition;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
@@ -13,6 +14,7 @@ import core.game.node.item.Item;
import core.plugin.Plugin;
import core.plugin.Initializable;
import core.tools.StringUtils;
import kotlin.Unit;
/**
* Represents the interface plugin used for jewellery crafting.
@@ -178,14 +180,10 @@ public final class JewelleryInterface extends ComponentPlugin {
break;
case 199:
final JewelleryItem d = data;
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
JewelleryCrafting.make(player, d, (int) getValue());
return true;
}
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
JewelleryCrafting.make(player, d, (int) value);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
return true;
}
if(!player.getSlayer().getLearned()[1] && data.equals(JewelleryItem.SLAYER_RING)){
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -10,6 +11,7 @@ import core.game.node.entity.player.link.RunScript;
import core.game.node.item.Item;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
/**
* Represents the leather crafting interface.
@@ -43,14 +45,10 @@ public final class LeatherCraftInterface extends ComponentPlugin {
amount = player.getInventory().getAmount(new Item(LeatherCrafting.LEATHER));
break;
case 199:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
player.getPulseManager().run(new SoftCraftPulse(player, new Item(LeatherCrafting.LEATHER), soft, (int) getValue()));
return true;
}
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
ContentAPI.submitIndividualPulse(player, new SoftCraftPulse(player, new Item(LeatherCrafting.LEATHER), soft, (int) value));
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
return true;
}
player.getPulseManager().run(new SoftCraftPulse(player, null, soft, amount));
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -9,6 +10,7 @@ import core.game.node.entity.player.link.diary.DiaryType;
import core.game.node.item.Item;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
/**
* Represents the component handler for the interface 403.
@@ -64,14 +66,10 @@ public class SawmillPlankInterface extends ComponentPlugin {
}
if (amount == 69) {
final Plank plankk = plank;
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
create(player, plankk, (int) super.getValue());
return true;
}
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
create(player, plankk, (int) value);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
return true;
}
if (plank != null) {
@@ -11,6 +11,8 @@ import core.game.node.item.Item;
import core.net.packet.in.ExaminePacket;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
/**
* Represents the plugin used to handle the shopping interface.
@@ -113,20 +115,17 @@ public final class ShoppingPlugin extends ComponentPlugin {
* @return the script.
* @param slot the slot.
*/
private RunScript getRunScript(final ShopViewer viewer, final int slot, final int componentId) {
return new RunScript() {
@Override
public boolean handle() {
switch (componentId){
private Function1 getRunScript(final ShopViewer viewer, final int slot, final int componentId) {
return (value) -> {
switch (componentId){
case 620:
viewer.getShop().buy(viewer.getPlayer(), slot, (int) getValue(), viewer.getTabIndex());
viewer.getShop().buy(viewer.getPlayer(), slot, (int) value, viewer.getTabIndex());
break;
case 621:
viewer.getShop().sell(viewer.getPlayer(), slot, (int) getValue(), viewer.getTabIndex());
viewer.getShop().sell(viewer.getPlayer(), slot, (int) value, viewer.getTabIndex());
break;
}
return true;
}
return Unit.INSTANCE;
};
}
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -53,20 +54,6 @@ public final class SkillTabInterface extends ComponentPlugin {
p.sendMessage("You must be inside Edgeville bank to set levels.");
return false;
}
p.getDialogueInterpreter().sendInput(true, "Enter the target level: ");
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
final int target_level = Integer.parseInt((String) getValue());
if (target_level > 99 || target_level == -1) {
player.getPacketDispatch().sendMessage("Invalid target level.");
return true;
}
p.getSkills().setStaticLevel(config.getSkillId(), target_level);
p.getSkills().setLevel(config.getSkillId(), target_level);
return true;
}
});
}
return true;
}
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -9,6 +10,7 @@ import core.game.node.entity.skill.smithing.smelting.SmeltingPulse;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.RunScript;
import core.plugin.Plugin;
import kotlin.Unit;
/**
* @author 'Vexia
@@ -29,16 +31,11 @@ public class SmeltingInterface extends ComponentPlugin {
return true;
}
if (barType.getAmount() == -1) {
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
player.getPulseManager().run(new SmeltingPulse(player, null, barType.getBar(), ammount));
return false;
}
});
player.getInterfaceManager().closeChatbox();
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
ContentAPI.submitIndividualPulse(player, new SmeltingPulse(player, null, barType.getBar(), (int) value));
return Unit.INSTANCE;
});
} else {
player.getPulseManager().run(new SmeltingPulse(player, null, barType.getBar(), barType.getAmount()));
}
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -12,6 +13,7 @@ import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.RunScript;
import core.game.node.item.Item;
import core.plugin.Plugin;
import kotlin.Unit;
/**
* @author 'Vexia
@@ -36,15 +38,10 @@ public class SmithingInterface extends ComponentPlugin {
p.getGameAttributes().setAttribute("smith-bar", bar);
p.getGameAttributes().setAttribute("smith-item", item);
if (amount == -1) {
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
final int ammount = (int) value;
p.getPulseManager().run(new SmithingPulse(p, new Item((int) p.getGameAttributes().getAttribute("smith-item"), ammount), (Bars) p.getGameAttributes().getAttribute("smith-bar"), ammount));
return false;
}
ContentAPI.sendInputDialogue(p, true, "Enter the amount:", (value) -> {
p.getPulseManager().run(new SmithingPulse(p, new Item((int) p.getGameAttributes().getAttribute("smith-item"), (int) value), (Bars) p.getGameAttributes().getAttribute("smith-bar"), (int) value));
return Unit.INSTANCE;
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
return true;
}
p.getPulseManager().run(new SmithingPulse(p, new Item(item, amount), Bars.forId(item), amount));
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.cache.def.impl.ItemDefinition;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
@@ -11,6 +12,7 @@ import core.game.node.entity.player.link.RunScript;
import core.game.node.item.Item;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
@Initializable
public class SpinningInterface extends ComponentPlugin {
@@ -43,15 +45,10 @@ public class SpinningInterface extends ComponentPlugin {
amt = p.getInventory().getAmount(new Item(spin.getNeed()));
break;
case 199:
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
p.getPulseManager().run(new SpinningPulse(p, new Item(spin.getNeed(), 1), ammount, spin));
return true;
}
ContentAPI.sendInputDialogue(p, true, "Enter the amount:", (value) -> {
ContentAPI.submitIndividualPulse(p, new SpinningPulse(p, new Item(spin.getNeed(), 1), (int) value, spin));
return Unit.INSTANCE;
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
break;
}
if (opcode == 199) {
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -9,6 +10,7 @@ import core.game.node.entity.player.link.RunScript;
import core.game.node.item.Item;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
/**
* @author Vexia
@@ -73,15 +75,10 @@ public class TanningInterface extends ComponentPlugin {
case 124:
amount = 10;
case 199:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int amt = (int) getValue();
TanningProduct.tan(player, amt, deff);
return true;
}
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
TanningProduct.tan(player, (int) value, deff);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter amount:");
break;
case 234:
amount = player.getInventory().getAmount(new Item(def.getItem(), 1));
@@ -1,5 +1,6 @@
package core.game.interaction.inter;
import api.ContentAPI;
import core.game.component.Component;
import core.game.component.ComponentDefinition;
import core.game.component.ComponentPlugin;
@@ -8,6 +9,7 @@ import core.game.node.entity.player.link.RunScript;
import core.game.node.entity.player.link.request.trade.TradeModule;
import core.plugin.Initializable;
import core.plugin.Plugin;
import kotlin.Unit;
/**
* Represents the interface plugin used to handle all trade related functions.
@@ -66,14 +68,10 @@ public final class TradeInterfacePlugin extends ComponentPlugin {
module.getContainer().withdraw(slot, module.getContainer().getAmount(module.getContainer().get(slot)));
break;
case 234:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
module.getContainer().withdraw(slot, (int) getValue());
return true;
}
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
module.getContainer().withdraw(slot, (int) value);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
break;
case 9:// examine.
if (TradeModule.getExtension(button == 32 ? module.getTarget() : player) == null) {
@@ -98,14 +96,10 @@ public final class TradeInterfacePlugin extends ComponentPlugin {
module.getContainer().offer(slot, player.getInventory().getAmount(player.getInventory().get(slot)));
break;
case 234:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
module.getContainer().offer(slot, (int) getValue());
return true;
}
ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> {
module.getContainer().offer(slot, (int) value);
return Unit.INSTANCE;
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount:");
break;
case 9:
player.getPacketDispatch().sendMessage(player.getInventory().get(slot).getDefinition().getExamine());
@@ -446,16 +446,11 @@ public final class BankingPlugin extends OptionHandler {
p.getBank().addItem(slot, p.getBank().getLastAmountX());
break;
case 234:
p.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int amount = (int) value;
p.getBank().addItem(slot, amount);
p.getBank().updateLastAmountX(amount);
return false;
}
ContentAPI.sendInputDialogue(p, true, "Enter the amount:", (value) -> {
p.getBank().addItem(slot, (int) value);
p.getBank().updateLastAmountX((int) value);
return Unit.INSTANCE;
});
p.getDialogueInterpreter().sendInput(false, "Enter the amount.");
break;
case 168:
p.getBank().addItem(slot, p.getInventory().getAmount(item));