RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ShootingStar.java
1package com.osroyale.content.shootingstar;
2
3import com.osroyale.content.skill.impl.mining.PickaxeData;
4import com.osroyale.game.task.Task;
5import com.osroyale.game.world.World;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.entity.skill.Skill;
8import com.osroyale.game.world.items.Item;
9import com.osroyale.game.world.object.GameObject;
10import org.apache.logging.log4j.LogManager;
11import org.apache.logging.log4j.Logger;
12
46
47public class ShootingStar {
48
49 private static final Logger logger = LogManager.getLogger(ShootingStar.class);
50
54 public static boolean starHasBeenFound = false;
55
60
64 public static int starTick = 30;
65
70 public static void mine(Player player, GameObject o) {
71 if(!starHasBeenFound) {
72 starHasBeenFound = true;
73 player.dialogueFactory.sendStatement("Congratulations! You were the first person to find this star!").execute();
74 player.skills.addExperience(14, 10000);
75 return;
76 }
77
78 PickaxeData pickaxe = PickaxeData.getBestPickaxe(player).orElse(null);
79
80 if(pickaxe == null) {
81 player.message("You don't have a pickaxe.");
82 return;
83 }
84
85 if (!player.skills.get(Skill.MINING).reqLevel(pickaxe.level)) {
86 player.message("You need a level of " + pickaxe.level + " to use this pickaxe!");
87 return;
88 }
89
90 if(!player.skills.get(Skill.MINING).reqLevel(shootingStarData.getMiningLevel())) {
91 player.dialogueFactory.sendStatement("You need a Mining level of " + shootingStarData.getMiningLevel() + " to mine here.").execute();
92 return;
93 }
94
95 if(!player.inventory.hasCapacityFor(new Item(25527))) {
96 player.message("Not enough space in your inventory.");
97 return;
98 }
99
100 player.message("You swing your pick at the rock.");
101
102 player.animate(pickaxe.animation);
103
104 player.action.execute(new ShootingStarAction(player, pickaxe, o));
105 player.skills.get(Skill.MINING).setDoingSkill(true);
106 }
107
112 public static void prospect(Player player) {
113 if(!starHasBeenFound) {
114 starHasBeenFound = true;
115 player.dialogueFactory.sendStatement("Congratulations! You were the first person to find this star!", "You have been granted 10,000 mining xp!").execute();
116 player.skills.addExperience(14, 10000);
117 return;
118 }
119
120 player.dialogueFactory.sendStatement("This is a size-"+(shootingStarData.starLevel + 1)+" star. A Mining level of at least "+shootingStarData.getMiningLevel()+" is required to", "mine this layer. It has been mined "+shootingStarData.getPercentage()+"% of the way to the next layer.").execute();
121 }
122
126 public static void init() {
127 logger.info("Loaded Shooting Stars event.");
128 World.schedule(new Task(1) {
129 @Override
130 protected void execute() {
131 starTick--;
132 if(starTick <= 0) {
133 if(shootingStarData != null) {
134 shootingStarData.destruct();
135 starHasBeenFound = false;
136 }
137
139 World.sendMessage("@red@A shooting star has just crashed " + shootingStarData.getHint() +" " + shootingStarData.getLocationName() + "!");
140 // DiscordPlugin.sendSimpleMessage("A shooting star has just crashed " + shootingStarData.getHint() +" " + shootingStarData.getLocationName() + "!");
141 //4 Hours in ticks
142 starTick = 24_000;
143 }
144 }
145
146 @Override
147 protected void onCancel(boolean logout) {
148 }
149 });
150 }
151}
final DialogueFactory sendStatement(String... lines)
static void mine(Player player, GameObject o)
static void sendMessage(String... messages)
Definition World.java:433
static void schedule(Task task)
Definition World.java:284
void addExperience(int id, double experience)
static Optional< PickaxeData > getBestPickaxe(Player player)