Adjusted based on feedback
This commit is contained in:
@@ -50,14 +50,9 @@ public class StorageProcessor {
|
|||||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||||
Character chr = c.getPlayer();
|
Character chr = c.getPlayer();
|
||||||
Storage storage = chr.getStorage();
|
Storage storage = chr.getStorage();
|
||||||
byte mode = p.readByte();
|
String gmBlockedStorageMessage = "You cannot use the storage as a GM of this level.";
|
||||||
|
|
||||||
if (chr.isGM() && chr.gmLevel() < YamlConfig.config.server.MINIMUM_GM_LEVEL_TO_USE_STORAGE) {
|
byte mode = p.readByte();
|
||||||
chr.dropMessage(1, "You cannot use the storage as a GM of this level.");
|
|
||||||
log.info(String.format("GM %s blocked from placing items in storage", chr.getName()));
|
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chr.getLevel() < 15) {
|
if (chr.getLevel() < 15) {
|
||||||
chr.dropMessage(1, "You may only use the storage once you have reached level 15.");
|
chr.dropMessage(1, "You may only use the storage once you have reached level 15.");
|
||||||
@@ -68,7 +63,7 @@ public class StorageProcessor {
|
|||||||
if (c.tryacquireClient()) {
|
if (c.tryacquireClient()) {
|
||||||
try {
|
try {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 4: { // take out
|
case 4: { // Take out
|
||||||
byte type = p.readByte();
|
byte type = p.readByte();
|
||||||
byte slot = p.readByte();
|
byte slot = p.readByte();
|
||||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||||
@@ -77,8 +72,17 @@ public class StorageProcessor {
|
|||||||
c.disconnect(true, false);
|
c.disconnect(true, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
slot = storage.getSlot(InventoryType.getByType(type), slot);
|
slot = storage.getSlot(InventoryType.getByType(type), slot);
|
||||||
Item item = storage.getItem(slot);
|
Item item = storage.getItem(slot);
|
||||||
|
|
||||||
|
if (hasGMRestrictions(chr)) {
|
||||||
|
chr.dropMessage(1, gmBlockedStorageMessage);
|
||||||
|
log.info(String.format("GM %s blocked from using storage", chr.getName()));
|
||||||
|
chr.sendPacket(PacketCreator.enableActions());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (ii.isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
if (ii.isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0C));
|
c.sendPacket(PacketCreator.getStorageError((byte) 0x0C));
|
||||||
@@ -114,7 +118,7 @@ public class StorageProcessor {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5: { // store
|
case 5: { // Store
|
||||||
short slot = p.readShort();
|
short slot = p.readShort();
|
||||||
int itemId = p.readInt();
|
int itemId = p.readInt();
|
||||||
short quantity = p.readShort();
|
short quantity = p.readShort();
|
||||||
@@ -127,6 +131,14 @@ public class StorageProcessor {
|
|||||||
c.disconnect(true, false);
|
c.disconnect(true, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasGMRestrictions(chr)) {
|
||||||
|
chr.dropMessage(1, gmBlockedStorageMessage);
|
||||||
|
log.info(String.format("GM %s blocked from using storage", chr.getName()));
|
||||||
|
chr.sendPacket(PacketCreator.enableActions());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (quantity < 1) {
|
if (quantity < 1) {
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
@@ -180,16 +192,24 @@ public class StorageProcessor {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6: // arrange items
|
case 6: // Arrange items
|
||||||
if (YamlConfig.config.server.USE_STORAGE_ITEM_SORT) {
|
if (YamlConfig.config.server.USE_STORAGE_ITEM_SORT) {
|
||||||
storage.arrangeItems(c);
|
storage.arrangeItems(c);
|
||||||
}
|
}
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
break;
|
break;
|
||||||
case 7: { // meso
|
case 7: { // Mesos
|
||||||
int meso = p.readInt();
|
int meso = p.readInt();
|
||||||
int storageMesos = storage.getMeso();
|
int storageMesos = storage.getMeso();
|
||||||
int playerMesos = chr.getMeso();
|
int playerMesos = chr.getMeso();
|
||||||
|
|
||||||
|
if (hasGMRestrictions(chr)) {
|
||||||
|
chr.dropMessage(1, gmBlockedStorageMessage);
|
||||||
|
log.info(String.format("GM %s blocked from using storage", chr.getName()));
|
||||||
|
chr.sendPacket(PacketCreator.enableActions());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||||
meso = Integer.MIN_VALUE + storageMesos;
|
meso = Integer.MIN_VALUE + storageMesos;
|
||||||
@@ -215,7 +235,7 @@ public class StorageProcessor {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 8: // close... unless the player decides to enter cash shop!
|
case 8: // Close (unless the player decides to enter cash shop)
|
||||||
storage.close();
|
storage.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -224,4 +244,8 @@ public class StorageProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasGMRestrictions(Character character) {
|
||||||
|
return character.isGM() && character.gmLevel() < YamlConfig.config.server.MINIMUM_GM_LEVEL_TO_USE_STORAGE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user