Clean up code, replace switch and try-with-resource where possible.

This commit is contained in:
Đạt Nhân Trương
2022-08-07 21:51:10 +07:00
parent f983b4dccf
commit 0ef3e69638
22 changed files with 609 additions and 589 deletions

View File

@@ -104,16 +104,20 @@ public class CashShop {
if (ItemConstants.EXPIRING_ITEMS) {
if (period == 1) {
if (itemId == ItemId.EXP_COUPON_2X_4H || itemId == ItemId.DROP_COUPON_2X_4H) { // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
switch (itemId) {
case ItemId.DROP_COUPON_2X_4H, ItemId.EXP_COUPON_2X_4H: // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(4));
/*
} else if(itemId == 5211047 || itemId == 5360014) { // 3 Hour 2X coupons, unused as of now
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(3));
*/
} else if (itemId == ItemId.EXP_COUPON_3X_2H) { // 2 Hour 3X coupons.
break;
case ItemId.EXP_COUPON_3X_2H:
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(2));
} else {
break;
default:
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(1));
break;
}
} else {
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(period));
@@ -264,12 +268,16 @@ public class CashShop {
this.characterId = characterId;
if (!YamlConfig.config.server.USE_JOINT_CASHSHOP_INVENTORY) {
if (jobType == 0) {
switch (jobType) {
case 0:
factory = ItemFactory.CASH_EXPLORER;
} else if (jobType == 1) {
break;
case 1:
factory = ItemFactory.CASH_CYGNUS;
} else if (jobType == 2) {
break;
case 2:
factory = ItemFactory.CASH_ARAN;
break;
}
} else {
factory = ItemFactory.CASH_OVERALL;