mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-07 08:39:07 +00:00
Fixed the delay on banking a non stackable item (#341)
Brought back old code as what I previously did affected the time it takes to bank items.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -8,62 +8,62 @@ import com.rebotted.game.players.Player;
|
|||||||
*/
|
*/
|
||||||
public class Weight extends ItemDefinitions {
|
public class Weight extends ItemDefinitions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the weight when doing actions
|
* Calculates the weight when doing actions
|
||||||
*
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param item
|
* @param item
|
||||||
* @param action
|
* @param action
|
||||||
* - deleteitem, additem, equip, unequip.
|
* - deleteitem, additem, equip, unequip.
|
||||||
*/
|
*/
|
||||||
private static void calcWeight(Player c, int item, String action) {
|
public static void calcWeight(Player c, int item, String action) {
|
||||||
if (action.equalsIgnoreCase("deleteitem")) {
|
if (action.equalsIgnoreCase("deleteitem")) {
|
||||||
if (getWeight(item) > 99.20) {
|
if (getWeight(item) > 99.20) {
|
||||||
c.weight -= getWeight(item) / 100;
|
c.weight -= getWeight(item) / 100;
|
||||||
if (c.weight < 0) {
|
if (c.weight < 0) {
|
||||||
c.weight = 0.0;
|
c.weight = 0.0;
|
||||||
}
|
}
|
||||||
c.getPacketSender().writeWeight((int) c.weight);
|
c.getPacketSender().writeWeight((int) c.weight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
c.weight -= getWeight(item) / 10;
|
c.weight -= getWeight(item) / 10;
|
||||||
if (c.weight < 0) {
|
if (c.weight < 0) {
|
||||||
c.weight = 0.0;
|
c.weight = 0.0;
|
||||||
}
|
}
|
||||||
c.getPacketSender().writeWeight((int) c.weight);
|
c.getPacketSender().writeWeight((int) c.weight);
|
||||||
} else if (action.equalsIgnoreCase("additem")) {
|
} else if (action.equalsIgnoreCase("additem")) {
|
||||||
if (getWeight(item) > 99.20) {
|
if (getWeight(item) > 99.20) {
|
||||||
c.weight += getWeight(item) / 100;
|
c.weight += getWeight(item) / 100;
|
||||||
c.getPacketSender().writeWeight((int) c.weight);
|
c.getPacketSender().writeWeight((int) c.weight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
c.weight += getWeight(item) / 10;
|
c.weight += getWeight(item) / 10;
|
||||||
c.getPacketSender().writeWeight((int) c.weight);
|
c.getPacketSender().writeWeight((int) c.weight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the weight for inventory and equipment.
|
* Updates the weight for inventory and equipment.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void updateWeight(Player player) {
|
public static void updateWeight(Player player) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.weight = 0;
|
player.weight = 0;
|
||||||
// Inventory items
|
// Inventory items
|
||||||
for (int playerItem : player.playerItems) {
|
for (int playerItem : player.playerItems) {
|
||||||
if (playerItem > -1) {// inventory
|
if (playerItem > -1) {// inventory
|
||||||
calcWeight(player, playerItem, "addItem");
|
calcWeight(player, playerItem, "addItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Equiped items
|
// Equiped items
|
||||||
for (int element : player.playerEquipment) {
|
for (int element : player.playerEquipment) {
|
||||||
if (element > -1) {// equipment
|
if (element > -1) {// equipment
|
||||||
if (element == 88) player.weight -= 4.5;
|
if (element == 88) player.weight -= 4.5;
|
||||||
else calcWeight(player, element, "addItem");
|
else calcWeight(player, element, "addItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.getPacketSender().writeWeight((int) player.weight);
|
}
|
||||||
}
|
player.getPacketSender().writeWeight((int) player.weight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user