generated from runelite/example-plugin
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add swarmer feature * clean up swarmer feature * clean up curlies * fix indentation issues * fix curlies again * more code formatting * disable when outside toa areas * track spawn wave by tick * use animation change events * remove unused injected fields * un-static state fields * remove unused cardinality after tick-based tracking * un-star import * constant room end message * use groupingBy and jawt outline in overlay * panel changes * only rebuild panel models * load recent raids on startup * separate panel from overlay, merge * reset on room wipe * split out data class from writer * use injected gson * construct leak data in-run * remove unused swarmnpc fields * build panel on edt * simplify some data manager stuff * move io to its own thread * load raid list after save * prevent early wave number increment * sort leaks table --------- Co-authored-by: Rhea <[email protected]>
- Loading branch information
1 parent
092ad26
commit be0f17f
Showing
11 changed files
with
832 additions
and
9 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 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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/duckblade/osrs/toa/features/boss/kephri/swarmer/SwarmNpc.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,11 @@ | ||
package com.duckblade.osrs.toa.features.boss.kephri.swarmer; | ||
|
||
import lombok.Data; | ||
import net.runelite.api.NPC; | ||
|
||
@Data | ||
public class SwarmNpc | ||
{ | ||
private final NPC npc; | ||
private final int waveSpawned; | ||
} |
133 changes: 133 additions & 0 deletions
133
src/main/java/com/duckblade/osrs/toa/features/boss/kephri/swarmer/SwarmerDataManager.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,133 @@ | ||
package com.duckblade.osrs.toa.features.boss.kephri.swarmer; | ||
|
||
import com.duckblade.osrs.toa.TombsOfAmascutPlugin; | ||
import com.duckblade.osrs.toa.module.PluginLifecycleComponent; | ||
import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.lang.reflect.Type; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardOpenOption; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Singleton | ||
@RequiredArgsConstructor(onConstructor_ = @Inject) | ||
public class SwarmerDataManager implements PluginLifecycleComponent | ||
{ | ||
|
||
private static final int MAX_RECENT_RAIDS = 10; | ||
public static final Path SWARMS_DIRECTORY = new File(TombsOfAmascutPlugin.TOA_FOLDER, "kephri-swarms").toPath(); | ||
|
||
private final Gson gson; | ||
|
||
private ExecutorService executor; | ||
|
||
@Override | ||
public void startUp() | ||
{ | ||
executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("ToA-SwarmerDataManager-%d").build()); | ||
} | ||
|
||
@Override | ||
public void shutDown() | ||
{ | ||
executor.shutdown(); | ||
} | ||
|
||
public CompletableFuture<List<String>> getRaidList() | ||
{ | ||
return CompletableFuture.supplyAsync(() -> | ||
{ | ||
try | ||
{ | ||
if (!Files.exists(SWARMS_DIRECTORY)) | ||
{ | ||
return Collections.emptyList(); | ||
} | ||
|
||
try (Stream<Path> files = Files.list(SWARMS_DIRECTORY)) | ||
{ | ||
return files.filter(f -> f.getFileName().toString().endsWith(".json")) | ||
.sorted(Comparator.reverseOrder()) | ||
.limit(MAX_RECENT_RAIDS) | ||
.map(f -> f.getFileName().toString().replace(".json", "")) | ||
.map(s -> s.replace('_', ':')) | ||
.collect(Collectors.toList()); | ||
} | ||
} | ||
catch (Exception ignored) | ||
{ | ||
} | ||
|
||
return Collections.emptyList(); | ||
}, executor); | ||
} | ||
|
||
public CompletableFuture<List<SwarmerRoomData>> getRaidData(String raidUnsafe) | ||
{ | ||
return CompletableFuture.supplyAsync(() -> | ||
{ | ||
String raid = raidUnsafe.replace(':', '_'); | ||
|
||
if (!Files.exists(SWARMS_DIRECTORY)) | ||
{ | ||
return Collections.emptyList(); | ||
} | ||
if (!Files.exists(SWARMS_DIRECTORY.resolve(raid + ".json"))) | ||
{ | ||
return Collections.emptyList(); | ||
} | ||
|
||
try (FileReader reader = new FileReader(SWARMS_DIRECTORY.resolve(raid + ".json").toFile())) | ||
{ | ||
Type listType = new TypeToken<List<SwarmerRoomData>>() | ||
{ | ||
}.getType(); | ||
return gson.fromJson(reader, listType); | ||
} | ||
catch (Exception ignored) | ||
{ | ||
return Collections.emptyList(); | ||
} | ||
}, executor); | ||
} | ||
|
||
public CompletableFuture<Void> saveRaidData(List<SwarmerRoomData> raidDataList) | ||
{ | ||
return CompletableFuture.runAsync(() -> | ||
{ | ||
String raidName = new SimpleDateFormat("yyyy-MM-dd HH_mm_ss").format(new Date()); | ||
try | ||
{ | ||
if (!Files.exists(SWARMS_DIRECTORY)) | ||
{ | ||
Files.createDirectories(SWARMS_DIRECTORY); | ||
} | ||
Files.writeString( | ||
SWARMS_DIRECTORY.resolve(raidName + ".json"), | ||
gson.toJson(raidDataList), | ||
StandardOpenOption.CREATE, | ||
StandardOpenOption.TRUNCATE_EXISTING | ||
); | ||
} | ||
catch (Exception ignored) | ||
{ | ||
} | ||
}); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/duckblade/osrs/toa/features/boss/kephri/swarmer/SwarmerFonts.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,30 @@ | ||
package com.duckblade.osrs.toa.features.boss.kephri.swarmer; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum SwarmerFonts | ||
{ | ||
REGULAR("RS Regular"), | ||
ARIAL("Arial"), | ||
CAMBRIA("Cambria"), | ||
ROCKWELL("Rockwell"), | ||
SEGOE_UI("Segoe Ui"), | ||
TIMES_NEW_ROMAN("Times New Roman"), | ||
VERDANA("Verdana"), | ||
DIALOG("DIALOG"), | ||
RUNESCAPE("RuneScape"); | ||
|
||
private final String name; | ||
|
||
public String toString() | ||
{ | ||
return this.name; | ||
} | ||
|
||
SwarmerFonts(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
} |
Oops, something went wrong.