generated from runelite/example-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Minigame storage - Giants' Foundry
- Loading branch information
Showing
7 changed files
with
60 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
src/main/java/dev/thource/runelite/dudewheresmystuff/minigames/GiantsFoundry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package dev.thource.runelite.dudewheresmystuff.minigames; | ||
|
||
import dev.thource.runelite.dudewheresmystuff.DudeWheresMyStuffPlugin; | ||
import dev.thource.runelite.dudewheresmystuff.ItemStack; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import lombok.Getter; | ||
import net.runelite.api.ItemID; | ||
import net.runelite.api.widgets.Widget; | ||
import org.apache.commons.lang3.math.NumberUtils; | ||
|
||
/** GiantsFoundry is responsible for tracking the player's Giants' Foundry points. */ | ||
@Getter | ||
public class GiantsFoundry extends MinigamesStorage { | ||
|
||
private static final Pattern HAND_IN_PATTERN = Pattern.compile("at quality: (\\d+)"); | ||
|
||
private final ItemStack points = | ||
new ItemStack(ItemID.COLOSSAL_BLADE, "Points", 0, 0, 0, true); | ||
private boolean didJustHandIn = false; | ||
|
||
GiantsFoundry(DudeWheresMyStuffPlugin plugin) { | ||
super(MinigamesStorageType.GIANTS_FOUNDRY, plugin); | ||
|
||
items.add(points); | ||
} | ||
|
||
@Override | ||
public boolean onGameTick() { | ||
Widget shopWidget = plugin.getClient().getWidget(753, 13); | ||
if (shopWidget != null) { | ||
points.setQuantity(Integer.parseInt(shopWidget.getText())); | ||
lastUpdated = System.currentTimeMillis(); | ||
return true; | ||
} | ||
|
||
Widget chatWidget = plugin.getClient().getWidget(229, 1); | ||
if (chatWidget != null) { | ||
if (!didJustHandIn) { | ||
Matcher matcher = HAND_IN_PATTERN.matcher(chatWidget.getText()); | ||
if (matcher.find()) { | ||
points.setQuantity(points.getQuantity() + NumberUtils.toInt(matcher.group(1))); | ||
lastUpdated = System.currentTimeMillis(); | ||
didJustHandIn = true; | ||
return true; | ||
} | ||
} | ||
} else { | ||
didJustHandIn = false; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters