Skip to content

Commit d0281eb

Browse files
feat(): added stash, and fixed slight visual bug with bows
1 parent 503cbee commit d0281eb

9 files changed

Lines changed: 1021 additions & 3 deletions

File tree

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/SkyBlockGenericLoader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import net.swofty.type.skyblockgeneric.user.SkyBlockIsland;
7575
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
7676
import net.swofty.type.skyblockgeneric.user.SkyBlockScoreboard;
77+
import net.swofty.type.skyblockgeneric.user.StashReminder;
7778
import net.swofty.type.generic.user.categories.CustomGroups;
7879
import net.swofty.type.skyblockgeneric.user.fairysouls.FairySoul;
7980
import net.swofty.type.skyblockgeneric.user.fairysouls.FairySoulZone;
@@ -309,6 +310,7 @@ public void initialize(MinecraftServer server) {
309310
* Start repeaters
310311
*/
311312
SkyBlockScoreboard.start();
313+
StashReminder.start(MinecraftServer.getSchedulerManager());
312314
PlayerHolograms.updateAll(MinecraftServer.getSchedulerManager());
313315

314316
/**
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package net.swofty.type.skyblockgeneric.commands;
2+
3+
import net.minestom.server.command.builder.arguments.ArgumentWord;
4+
import net.swofty.commons.item.ItemType;
5+
import net.swofty.type.generic.command.CommandParameters;
6+
import net.swofty.type.generic.command.HypixelCommand;
7+
import net.swofty.type.generic.user.categories.Rank;
8+
import net.swofty.type.skyblockgeneric.data.datapoints.DatapointStash;
9+
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
10+
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
11+
12+
import java.util.ArrayList;
13+
import java.util.List;
14+
15+
@CommandParameters(aliases = "pickupstash",
16+
description = "Pickup items from your stash",
17+
usage = "/pickupstash [item|material]",
18+
permission = Rank.DEFAULT,
19+
allowsConsole = false)
20+
public class PickupStashCommand extends HypixelCommand {
21+
@Override
22+
public void registerUsage(MinestomCommand command) {
23+
ArgumentWord typeArg = new ArgumentWord("type").from("item", "material");
24+
25+
// No args - pick up from both stashes
26+
command.addSyntax((sender, context) -> {
27+
if (!permissionCheck(sender)) return;
28+
29+
SkyBlockPlayer player = (SkyBlockPlayer) sender;
30+
pickupFromItemStash(player);
31+
pickupFromMaterialStash(player);
32+
});
33+
34+
// With type argument
35+
command.addSyntax((sender, context) -> {
36+
if (!permissionCheck(sender)) return;
37+
38+
SkyBlockPlayer player = (SkyBlockPlayer) sender;
39+
String type = context.get(typeArg);
40+
41+
if (type.equalsIgnoreCase("material")) {
42+
pickupFromMaterialStash(player);
43+
} else {
44+
pickupFromItemStash(player);
45+
}
46+
}, typeArg);
47+
}
48+
49+
private void pickupFromItemStash(SkyBlockPlayer player) {
50+
DatapointStash.PlayerStash stash = player.getStash();
51+
52+
if (stash.getItemStashCount() == 0) {
53+
player.sendMessage("§cYour item stash is already empty!");
54+
return;
55+
}
56+
57+
int pickedUp = 0;
58+
while (player.hasEmptySlots(1) && stash.getItemStashCount() > 0) {
59+
SkyBlockItem removed = stash.removeFromItemStash(0);
60+
if (removed != null) {
61+
player.addAndUpdateItem(removed);
62+
player.sendMessage("§aFrom stash: §f" + removed.getDisplayName());
63+
pickedUp++;
64+
}
65+
}
66+
67+
if (pickedUp == 0) {
68+
player.sendMessage("§cCouldn't unstash your item stash! Your inventory is full!");
69+
} else if (stash.getItemStashCount() == 0) {
70+
player.sendMessage("§aYou picked up all items from your item stash!");
71+
} else {
72+
player.sendMessage("§eYou still have §c" + stash.getItemStashCount() + " §eitems in there!");
73+
}
74+
}
75+
76+
private void pickupFromMaterialStash(SkyBlockPlayer player) {
77+
DatapointStash.PlayerStash stash = player.getStash();
78+
79+
if (stash.getMaterialStashCount() == 0) {
80+
player.sendMessage("§cYour material stash is already empty!");
81+
return;
82+
}
83+
84+
int pickedUp = 0;
85+
List<ItemType> types = new ArrayList<>(stash.getMaterialStash().keySet());
86+
87+
for (ItemType type : types) {
88+
int amount = stash.getMaterialStash().getOrDefault(type, 0);
89+
int maxStackSize = type.material.maxStackSize();
90+
91+
while (amount > 0 && player.hasEmptySlots(1)) {
92+
int toPickup = Math.min(amount, maxStackSize);
93+
int removed = stash.removeFromMaterialStash(type, toPickup);
94+
if (removed > 0) {
95+
SkyBlockItem newItem = new SkyBlockItem(type);
96+
newItem.setAmount(removed);
97+
player.addAndUpdateItem(newItem);
98+
player.sendMessage("§aFrom stash: §f" + type.getDisplayName() + " §7x" + removed);
99+
pickedUp += removed;
100+
amount -= removed;
101+
} else {
102+
break;
103+
}
104+
}
105+
106+
if (!player.hasEmptySlots(1)) break;
107+
}
108+
109+
if (pickedUp == 0) {
110+
player.sendMessage("§cCouldn't unstash your material stash! Your inventory is full!");
111+
} else if (stash.getMaterialStashCount() == 0) {
112+
player.sendMessage("§aYou picked up all items from your material stash!");
113+
} else {
114+
player.sendMessage("§eYou still have §c" + stash.getMaterialStashCount() +
115+
" §ematerials totalling §c" + stash.getMaterialTypeCount() +
116+
" §etypes of materials in there!");
117+
}
118+
}
119+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package net.swofty.type.skyblockgeneric.commands;
2+
3+
import net.minestom.server.command.builder.arguments.ArgumentWord;
4+
import net.swofty.type.generic.command.CommandParameters;
5+
import net.swofty.type.generic.command.HypixelCommand;
6+
import net.swofty.type.generic.user.categories.Rank;
7+
import net.swofty.type.skyblockgeneric.gui.inventories.stash.GUIStashItem;
8+
import net.swofty.type.skyblockgeneric.gui.inventories.stash.GUIStashMaterial;
9+
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
10+
11+
@CommandParameters(aliases = "viewstash",
12+
description = "View your stash",
13+
usage = "/viewstash [item|material]",
14+
permission = Rank.DEFAULT,
15+
allowsConsole = false)
16+
public class ViewStashCommand extends HypixelCommand {
17+
@Override
18+
public void registerUsage(MinestomCommand command) {
19+
ArgumentWord typeArg = new ArgumentWord("type").from("item", "material");
20+
21+
// No args - open item stash by default
22+
command.addSyntax((sender, context) -> {
23+
if (!permissionCheck(sender)) return;
24+
25+
SkyBlockPlayer player = (SkyBlockPlayer) sender;
26+
new GUIStashItem().open(player);
27+
});
28+
29+
// With type argument
30+
command.addSyntax((sender, context) -> {
31+
if (!permissionCheck(sender)) return;
32+
33+
SkyBlockPlayer player = (SkyBlockPlayer) sender;
34+
String type = context.get(typeArg);
35+
36+
if (type.equalsIgnoreCase("material")) {
37+
new GUIStashMaterial().open(player);
38+
} else {
39+
new GUIStashItem().open(player);
40+
}
41+
}, typeArg);
42+
}
43+
}

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/data/SkyBlockDataHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,10 @@ DatapointStringList.class, new DatapointStringList("used_scrolls")),
425425
DatapointLong.class, new DatapointLong("booster_cookie_expiration_date", 1L)),
426426

427427
KAT("kat", false, false, false,
428-
DatapointKat.class, new DatapointKat("kat"));
428+
DatapointKat.class, new DatapointKat("kat")),
429+
430+
STASH("stash", false, false, false,
431+
DatapointStash.class, new DatapointStash("stash"));
429432

430433
@Getter private final String key;
431434
@Getter private final Boolean isProfilePersistent;

0 commit comments

Comments
 (0)