Misc Changes (#633)

* Fix Weight Calculation For Add/Remove Item In ItemAssistant

* Re-Add Simple Stuck Command That Logs To Discord To Prevent Abuse

* Update Discord Log Chanel Var

* Fix int/interface Command

* Add World ID Check To DiscordBot Link Command

* Fix Java Warnings in DiscordBot Link Command
This commit is contained in:
Josh Shippam
2023-03-20 23:35:25 +00:00
committed by GitHub
parent d155a57380
commit e293bde96f
6 changed files with 24 additions and 15 deletions
@@ -515,7 +515,7 @@ public class ItemAssistant {
player.flushOutStream();
}
i = 30;
Weight.calcWeight(player, item, "additem");
Weight.updateWeight(player);
return true;
}
}
@@ -533,7 +533,7 @@ public class ItemAssistant {
}
resetItems(3214);
i = 30;
Weight.calcWeight(player, item, "additem");
Weight.updateWeight(player);
return true;
}
}
@@ -2338,7 +2338,7 @@ public class ItemAssistant {
}
}
resetItems(3214);
Weight.calcWeight(player, id, "deleteitem");
Weight.updateWeight(player);
}
public void deleteItem(int id, int slot, int amount) {
@@ -2353,7 +2353,7 @@ public class ItemAssistant {
player.playerItems[slot] = 0;
}
resetItems(3214);
Weight.calcWeight(player, id, "deleteitem");
Weight.updateWeight(player);
}
}
@@ -13,11 +13,11 @@ public class Weight {
* @param c
* @param item
* @param action
* - deleteitem, additem, equip, unequip.
* - deleteItem, addItem.
*/
public static void calcWeight(Player c, int item, String action) {
double weight = ItemDefinitions.getWeight(item);
if (action.equalsIgnoreCase("deleteitem")) {
if (action.equalsIgnoreCase("deleteItem")) {
if (weight > 99.20) {
c.weight -= weight / 100;
if (c.weight < 0) {
@@ -31,7 +31,7 @@ public class Weight {
c.weight = 0.0;
}
c.getPacketSender().writeWeight((int) c.weight);
} else if (action.equalsIgnoreCase("additem")) {
} else if (action.equalsIgnoreCase("addItem")) {
if (weight > 99.20) {
c.weight += weight / 100;
c.getPacketSender().writeWeight((int) c.weight);
@@ -56,7 +56,7 @@ public class Weight {
calcWeight(player, playerItem, "addItem");
}
}
// Equiped items
// Equipped items
for (int element : player.playerEquipment) {
if (element > -1) {// equipment
if (element == 88) {
@@ -1,7 +1,6 @@
package com.rs2.game.shops;
import com.rs2.Constants;
import com.rs2.game.items.Weight;
import org.apollo.cache.def.ItemDefinition;
import com.rs2.game.bots.BotHandler;
@@ -451,7 +450,6 @@ public class ShopAssistant {
// Add item to the shop
addShopItem(unNotedItemID, amount);
player.getItemAssistant().resetItems(3823);
Weight.updateWeight(player);
resetShop(player.shopId);
updatePlayerShop();
return true;
@@ -613,7 +611,6 @@ public class ShopAssistant {
GameLogger.writeLog(player.playerName, "shopbuying", player.playerName + " bought " + amount + " " + itemName + " for " + totalValue + " " + currencyName + " from store " + shopID + ".");
}
player.getItemAssistant().resetItems(3823);
Weight.updateWeight(player);
resetShop(player.shopId);
updatePlayerShop();
return true; //return TRUE / FALSE Update = shop&Inventory / Doesnt Update
@@ -21,6 +21,7 @@ public class JavaCord {
public static String commandPrefix = "::w" + Constants.WORLD;
public static String token;
public static DiscordApi api = null;
public static String logChannelId = "1083146780507656294";
public static void init() throws IOException {
if (token != null && !token.equals("")) { //If the token was loaded by loadSettings:
@@ -1,7 +1,7 @@
package com.rs2.integrations.discord.commands;
import com.rs2.Constants;
import org.javacord.api.entity.message.Message;
import org.javacord.api.entity.user.User;
import org.javacord.api.event.message.MessageCreateEvent;
import org.javacord.api.listener.message.MessageCreateListener;
@@ -10,8 +10,12 @@ public class Link implements MessageCreateListener {
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().equalsIgnoreCase("::link")) {
if (Constants.WORLD == 1) {
if (message.getAuthor().asUser().isPresent()) {
event.getChannel().sendMessage(message.getAuthor().asUser().get().getMentionTag() + ", Please check your DM's to continue.");
message.getAuthor().asUser().get().sendMessage("Please copy/paste the following in-game to link your Discord account: \n ```::link " + message.getAuthor().asUser().get().getIdAsString() + "```");
}
}
}
}
}
@@ -11,6 +11,7 @@ import com.rs2.game.bots.BotHandler;
import com.rs2.game.npcs.NpcHandler;
import com.rs2.game.players.*;
import com.rs2.game.players.antimacro.AntiSpam;
import com.rs2.integrations.discord.JavaCord;
import com.rs2.net.Packet;
import com.rs2.net.packets.PacketType;
import com.rs2.util.Misc;
@@ -45,6 +46,12 @@ public class Commands implements PacketType {
public static void playerCommands(Player player, String playerCommand, String[] arguments) {
switch (playerCommand.toLowerCase()) {
case "stuck":
if(JavaCord.token != null) {
if (JavaCord.api.getTextChannelById(JavaCord.logChannelId).isPresent())
JavaCord.api.getTextChannelById(JavaCord.logChannelId).get().sendMessage(player.playerName + " used ::stuck at X/Y: " + player.absX + "/" + player.absY);
}
player.getPlayerAssistant().spellTeleport(Constants.RESPAWN_X, Constants.RESPAWN_Y, 0);
case "link":
player.setDiscordCode(arguments[0]);
player.getPacketSender().sendMessage("Your Account has now been linked with Discord User ID:");
@@ -619,7 +626,7 @@ public class Commands implements PacketType {
int interface2 = Integer.parseInt(arguments[1]);
player.getPacketSender().sendFrame248(interface1, interface2);
return;
} else if (arguments.length == 2) {
} else if (arguments.length == 3) {
int interface1 = Integer.parseInt(arguments[0]);
int interface2 = Integer.parseInt(arguments[1]);
int interface3 = Integer.parseInt(arguments[2]);