Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
chsami committed Nov 30, 2024
2 parents cdd51e3 + e535464 commit 86fdb54
Show file tree
Hide file tree
Showing 24 changed files with 623 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,22 @@ default boolean logoutAfterBreak() {
return true;
}

@ConfigItem(
keyName = "useRandomWorld",
name = "Use RandomWorld",
description = "Change to a random world once break is finished",
position = 5
)
default boolean useRandomWorld() {
return false;
}

@ConfigItem(
keyName = "UsePlaySchedule",
name = "Use Play Schedule",
description = "Enable or disable the use of a play schedule",
position = 5,
section = "UsePlaySchedule"
position = 0,
section = usePlaySchedule
)
default boolean usePlaySchedule() {
return false;
Expand All @@ -82,8 +92,8 @@ default boolean usePlaySchedule() {
keyName = "PlaySchedule",
name = "Play Schedule",
description = "Select the play schedule",
position = 6,
section = "UsePlaySchedule"
position = 1,
section = usePlaySchedule
)
default PlaySchedule playSchedule() {
return PlaySchedule.MEDIUM_DAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ public boolean run(BreakHandlerConfig config) {
if (breakIn <= 0)
breakIn = Random.random(config.timeUntilBreakStart() * 60, config.timeUntilBreakEnd() * 60);

new Login();
if (config.useRandomWorld()) {
new Login(Login.getRandomWorld(Login.activeProfile.isMember()));
} else {
new Login();
}
totalBreaks++;
ClientUI.getFrame().setTitle(title);
if (Rs2AntibanSettings.takeMicroBreaks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.GameState;
import net.runelite.api.WorldType;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
Expand Down Expand Up @@ -121,6 +122,8 @@ public void fetchStars() {

ZonedDateTime now = ZonedDateTime.now(utcZoneId);

boolean inSeasonalWorld = Microbot.getClient().getWorldType().contains(WorldType.SEASONAL);

// Format starData into Star Model
for (Star star : starData) {
// Filter out stars that ended longer than three mintues ago to avoid adding really old stars
Expand All @@ -142,6 +145,13 @@ public void fetchStars() {

if (star.isGameModeWorld()) continue;

// Seasonal world filtering
if (inSeasonalWorld && !star.isInSeasonalWorld()) {
continue; // Skip non-seasonal worlds if the player is in a seasonal world
} else if (!inSeasonalWorld && star.isInSeasonalWorld()) {
continue; // Skip seasonal worlds if the player is not in a seasonal world
}

addToList(star);
}
filterPanelList(hideWildernessLocations || hideMembersWorlds || hideF2PWorlds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public boolean isMemberWorld() {
public boolean isF2PWorld() {
return !this.isGameModeWorld() && !this.getWorldObject().getTypes().contains(WorldType.MEMBERS);
}

public boolean isInSeasonalWorld() {
return this.getWorldObject().getTypes().contains(WorldType.SEASONAL);
}

@Override
public boolean equals(Object obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.nateplugins.skilling.natefishing.enums.Fish;
import net.runelite.client.plugins.microbot.util.bank.Rs2Bank;
import net.runelite.client.plugins.microbot.util.bank.enums.BankLocation;
import net.runelite.client.plugins.microbot.util.walker.Rs2Walker;
Expand Down Expand Up @@ -33,7 +34,13 @@ public class ShortestPathPanel extends PluginPanel {
private JComboBox<Hops> hopsComboBox;
private JComboBox<Trees> treesComboBox;
private JComboBox<CompostBins> compostBinsComboBox;
private JComboBox<HuntingAreas> hunterCreatureComboBox;
private JComboBox<HuntingAreas> huntingAreasComboBox;
private JComboBox<Birds> birdsComboBox;
private JComboBox<Chinchompas> chinchompasComboBox;
private JComboBox<Insects> insectsComboBox;
private JComboBox<Kebbits> kebbitsJComboBox;
private JComboBox<Salamanders> salamandersComboBox;
private JComboBox<SpecialHuntingAreas> specialHuntingAreasJComboBox;

@Inject
private ShortestPathPanel(ShortestPathPlugin plugin) {
Expand Down Expand Up @@ -268,25 +275,64 @@ private JPanel createHunterCreaturePanel() {
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBorder(createCenteredTitledBorder("Travel to Hunter Creature", "/net/runelite/client/plugins/microbot/shortestpath/Hunter_icon.png"));

hunterCreatureComboBox = new JComboBox<>(HuntingAreas.values());
hunterCreatureComboBox.setRenderer(new ComboBoxListRenderer());
hunterCreatureComboBox.setAlignmentX(Component.CENTER_ALIGNMENT);
hunterCreatureComboBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, hunterCreatureComboBox.getPreferredSize().height));
((JLabel) hunterCreatureComboBox.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
huntingAreasComboBox = new JComboBox<>(HuntingAreas.values());
huntingAreasComboBox.setRenderer(new ComboBoxListRenderer());
huntingAreasComboBox.setAlignmentX(Component.CENTER_ALIGNMENT);
huntingAreasComboBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, huntingAreasComboBox.getPreferredSize().height));
((JLabel) huntingAreasComboBox.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);

birdsComboBox = new JComboBox<>(Birds.values());
chinchompasComboBox = new JComboBox<>(Chinchompas.values());
insectsComboBox = new JComboBox<>(Insects.values());
kebbitsJComboBox = new JComboBox<>(Kebbits.values());
salamandersComboBox = new JComboBox<>(Salamanders.values());
specialHuntingAreasJComboBox = new JComboBox<>(SpecialHuntingAreas.values());

JComboBox<?>[] subComboBoxes = {birdsComboBox, chinchompasComboBox, insectsComboBox, kebbitsJComboBox, salamandersComboBox, specialHuntingAreasJComboBox};

for (JComboBox<?> comboBox : subComboBoxes) {
comboBox.setRenderer(new ComboBoxListRenderer());
comboBox.setAlignmentX(Component.CENTER_ALIGNMENT);
comboBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, comboBox.getPreferredSize().height));
((JLabel)comboBox.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
comboBox.setVisible(false);
}

huntingAreasComboBox.addActionListener(e -> {
HuntingAreas selectedHuntingArea = (HuntingAreas) huntingAreasComboBox.getSelectedItem();
birdsComboBox.setVisible(selectedHuntingArea == HuntingAreas.BIRDS);
chinchompasComboBox.setVisible(selectedHuntingArea == HuntingAreas.CHINCHOMPAS);
insectsComboBox.setVisible(selectedHuntingArea == HuntingAreas.INSECTS);
kebbitsJComboBox.setVisible(selectedHuntingArea == HuntingAreas.KEBBITS);
salamandersComboBox.setVisible(selectedHuntingArea == HuntingAreas.SALAMANDERS);
specialHuntingAreasJComboBox.setVisible(selectedHuntingArea == HuntingAreas.SPECIAL);
});

JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
JButton startButton = new JButton("Start");
JButton stopButton = new JButton("Stop");

startButton.addActionListener(e -> startWalking(getSelectedHunterCreature().getWorldPoint()));
startButton.addActionListener(e -> startWalking(getSelectedHuntingArea()));
stopButton.addActionListener(e -> stopWalking());

buttonPanel.add(startButton);
buttonPanel.add(stopButton);

panel.add(hunterCreatureComboBox);
JPanel hunterGuildPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
JButton hunterGuildButton = new JButton(" Hunter Guild ");

hunterGuildButton.addActionListener(e -> startWalking(new WorldPoint(1558, 3046, 0)));

hunterGuildPanel.add(hunterGuildButton);

panel.add(huntingAreasComboBox);
for (JComboBox<?> comboBox : subComboBoxes) {
panel.add(comboBox);
}
panel.add(Box.createRigidArea(new Dimension(0, 5)));
panel.add(buttonPanel);
panel.add(Box.createRigidArea(new Dimension(0, 2)));
panel.add(hunterGuildPanel);

return panel;
}
Expand Down Expand Up @@ -336,30 +382,28 @@ public WorldPoint getSelectedFarmingLocation() {
}
}

public String getSelectedFarmingLocationName() {
Farming selectedFarming = getSelectedFarmingCategory();
switch (selectedFarming) {
case ALLOTMENTS:
return ((Allotments) allotmentsComboBox.getSelectedItem()).name();
case BUSHES:
return ((Bushes) bushesComboBox.getSelectedItem()).name();
case FRUIT_TREES:
return ((FruitTrees) fruitTreesComboBox.getSelectedItem()).name();
case HERBS:
return ((Herbs) herbsComboBox.getSelectedItem()).name();
case HOPS:
return ((Hops) hopsComboBox.getSelectedItem()).name();
case TREES:
return ((Trees) treesComboBox.getSelectedItem()).name();
case COMPOST_BINS:
return ((CompostBins) compostBinsComboBox.getSelectedItem()).name();
default:
return "Unknown";
}
public HuntingAreas getSelectedHunterArea() {
return (HuntingAreas) huntingAreasComboBox.getSelectedItem();
}

public HuntingAreas getSelectedHunterCreature() {
return (HuntingAreas) hunterCreatureComboBox.getSelectedItem();
public WorldPoint getSelectedHuntingArea() {
HuntingAreas selectedHunting = getSelectedHunterArea();
switch (selectedHunting) {
case BIRDS:
return ((Birds) birdsComboBox.getSelectedItem()).getWorldPoint();
case INSECTS:
return ((Insects) insectsComboBox.getSelectedItem()).getWorldPoint();
case KEBBITS:
return ((Kebbits) kebbitsJComboBox.getSelectedItem()).getWorldPoint();
case CHINCHOMPAS:
return ((Chinchompas) chinchompasComboBox.getSelectedItem()).getWorldPoint();
case SALAMANDERS:
return ((Salamanders) salamandersComboBox.getSelectedItem()).getWorldPoint();
case SPECIAL:
return ((SpecialHuntingAreas) specialHuntingAreasJComboBox.getSelectedItem()).getWorldPoint();
default:
return null;
}
}

private void startWalking(WorldPoint point) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,14 @@ private boolean useTransport(Transport transport) {
if (!isFeatureEnabled(transport.getType())) return false;
// If you don't meet level requirements
if (!hasRequiredLevels(transport)) return false;
// If you don't have the required Items & Amount for transport (used for charters & minecarts)
if (transport.getAmtItemRequired() > 0 && !Rs2Inventory.hasItemAmount(transport.getItemRequired(), transport.getAmtItemRequired())) return false;
// Check Teleport Item Settings
if (transport.getType() == TELEPORTATION_ITEM) return isTeleportationItemUsable(transport);
// If the transport has quest requirements & the quest haven't been completed
if (transport.isQuestLocked() && !completedQuests(transport)) return false;
// If the transport has varbit requirements & the varbits do not match
if (!varbitChecks(transport)) return false;
// If you don't have the required Items & Amount for transport (used for charters & minecarts)
if (transport.getAmtItemRequired() > 0 && !Rs2Inventory.hasItemAmount(transport.getItemRequired(), transport.getAmtItemRequired())) return false;
// Check Teleport Item Settings
if (transport.getType() == TELEPORTATION_ITEM) return isTeleportationItemUsable(transport);

return true;
}
Expand Down Expand Up @@ -471,18 +471,19 @@ private boolean hasRequiredItems(Transport transport) {
if (Rs2Walker.disableTeleports) return false;

// Handle teleportation items
if (TransportType.TELEPORTATION_ITEM.equals(transport.getType()))
return transport.getItemIdRequirements()
.stream()
.flatMap(Collection::stream)
.anyMatch(itemId -> Rs2Equipment.isWearing(itemId) || Rs2Inventory.hasItem(itemId));
if (TransportType.TELEPORTATION_ITEM.equals(transport.getType())) {
// Special case for Chronicle teleport
if (requiresChronicle(transport)) return hasChronicleCharges();

return transport.getItemIdRequirements()
.stream()
.flatMap(Collection::stream)
.anyMatch(itemId -> Rs2Equipment.isWearing(itemId) || Rs2Inventory.hasItem(itemId));
}

// Handle teleportation spells
if (TransportType.TELEPORTATION_SPELL.equals(transport.getType())) return Rs2Magic.quickCanCast(transport.getDisplayInfo());

// Special case for Chronicle teleport
if (requiresChronicle(transport)) return hasChronicleCharges();

// Check membership restrictions
if (!client.getWorldType().contains(WorldType.MEMBERS)) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public boolean hasRequirements() {
case CORSAIR_COVE:
// Requires The Corsair Curse
return Rs2Player.getQuestState(Quest.THE_CORSAIR_CURSE) == QuestState.FINISHED;
case SOPHANEM:
return Rs2Player.getQuestState(Quest.CONTACT) == QuestState.FINISHED;
default:
return true;
}
Expand Down
Loading

0 comments on commit 86fdb54

Please sign in to comment.