Skip to content

Commit 4e5f7c4

Browse files
committed
Replace scenes with tags, simplify API, rewrite internals
1 parent 96c13f1 commit 4e5f7c4

66 files changed

Lines changed: 1269 additions & 1260 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build-logic/src/main/kotlin/bundlescenes.base.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ plugins {
33
}
44

55
repositories {
6-
maven("https://repo.bundlegroup.gg/repository/maven-public/") {
7-
name = "bundlegroup"
8-
credentials(PasswordCredentials::class)
9-
}
6+
mavenCentral()
7+
maven("https://repo.papermc.io/repository/maven-public/")
108
maven("https://maven.enginehub.org/repo/")
119
}
1210

bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/BundleScenes.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
package gg.bundlegroup.bundlescenes.api;
22

3-
import gg.bundlegroup.bundlescenes.api.controller.Controller;
4-
import gg.bundlegroup.bundlescenes.api.scene.ChunkSceneProvider;
5-
import gg.bundlegroup.bundlescenes.api.scene.Scene;
6-
import net.kyori.adventure.key.Key;
7-
import org.bukkit.Chunk;
8-
import org.bukkit.Location;
9-
import org.bukkit.World;
3+
import org.bukkit.entity.Entity;
104
import org.bukkit.plugin.Plugin;
11-
import org.jspecify.annotations.NullMarked;
125

13-
import java.util.Collection;
6+
import java.util.HashSet;
147
import java.util.Objects;
8+
import java.util.Set;
159

16-
@NullMarked
1710
public interface BundleScenes {
18-
Controller createController(Plugin plugin, Key key);
11+
Controller createController(Plugin plugin);
1912

20-
Scene scene(Key key);
13+
Element createElement(Plugin plugin, Viewable viewable);
2114

22-
Collection<Scene> scenes();
15+
Set<String> getTags();
2316

24-
default ChunkSceneProvider chunk(Location location) {
25-
return chunk(location.getChunk());
26-
}
17+
Set<String> getEntityTags(Entity entity);
18+
19+
void setEntityTags(Entity entity, Set<String> tags);
2720

28-
default ChunkSceneProvider chunk(Chunk chunk) {
29-
return chunk(chunk.getWorld(), chunk.getX(), chunk.getZ());
21+
default boolean addEntityTag(Entity entity, String tag) {
22+
Set<String> tags = new HashSet<>(getEntityTags(entity));
23+
boolean added = tags.add(tag);
24+
if (added) {
25+
setEntityTags(entity, tags);
26+
}
27+
return added;
3028
}
3129

32-
ChunkSceneProvider chunk(World world, int x, int z);
30+
default boolean removeEntityTag(Entity entity, String tag) {
31+
Set<String> tags = new HashSet<>(getEntityTags(entity));
32+
boolean removed = tags.remove(tag);
33+
if (removed) {
34+
setEntityTags(entity, tags);
35+
}
36+
return removed;
37+
}
3338

3439
static BundleScenes get() {
3540
return Objects.requireNonNull(BundleScenesProvider.instance);

bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/BundleScenesProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package gg.bundlegroup.bundlescenes.api;
22

3-
import org.jspecify.annotations.NullMarked;
3+
import org.jetbrains.annotations.ApiStatus;
44
import org.jspecify.annotations.Nullable;
55

6-
@NullMarked
6+
@ApiStatus.Internal
77
public final class BundleScenesProvider {
88
public BundleScenesProvider() {
99
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package gg.bundlegroup.bundlescenes.api;
2+
3+
import org.bukkit.entity.Player;
4+
import org.jetbrains.annotations.ApiStatus;
5+
6+
import java.io.Closeable;
7+
8+
/**
9+
* Used to control which tags are visible.
10+
*/
11+
@ApiStatus.NonExtendable
12+
public interface Controller extends Closeable {
13+
/**
14+
* Start showing elements with the specified tag to the player.
15+
*
16+
* @param player the player
17+
* @param tag the tag to show
18+
*/
19+
void showTag(Player player, String tag);
20+
21+
/**
22+
* Stop showing elements with the specified tag to the player.
23+
*
24+
* @param player the player
25+
* @param tag the tag to hide
26+
*/
27+
void hideTag(Player player, String tag);
28+
29+
/**
30+
* Returns whether this controller is showing the tag to the player.
31+
*
32+
* @param player the player
33+
* @param tag the tag
34+
* @return true if this controller is showing the tag to the player
35+
*/
36+
boolean isShowingTag(Player player, String tag);
37+
38+
/**
39+
* Closes this controller.
40+
*/
41+
@Override
42+
void close();
43+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package gg.bundlegroup.bundlescenes.api;
2+
3+
import java.util.Set;
4+
5+
public interface Element {
6+
Set<String> getTags();
7+
8+
void addTag(String tag);
9+
10+
void removeTag(String tag);
11+
12+
void remove();
13+
}

bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/viewable/Viewable.java renamed to bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/Viewable.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
package gg.bundlegroup.bundlescenes.api.viewable;
1+
package gg.bundlegroup.bundlescenes.api;
22

33
import org.bukkit.entity.Player;
4-
import org.jspecify.annotations.NullMarked;
54

65
import java.util.Collection;
76

8-
@NullMarked
97
public interface Viewable {
108
void addViewer(Player player);
119

bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/controller/Controller.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@NullMarked
2+
package gg.bundlegroup.bundlescenes.api;
3+
4+
import org.jspecify.annotations.NullMarked;

bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/scene/ChunkSceneProvider.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

bundlescenes-api/src/main/java/gg/bundlegroup/bundlescenes/api/scene/Scene.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)