Skip to content

Commit b0ab674

Browse files
authored
Merge pull request #22 from Streamline-Essentials/dev
Dev
2 parents 423a77c + 7353f67 commit b0ab674

File tree

15 files changed

+134
-24
lines changed

15 files changed

+134
-24
lines changed

build.gradle

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,33 @@ dependencies {
5757
shadow(SHADOW)
5858

5959
// TheBase
60-
implementation("com.github.server-utilities:TheBase:${rootProject.properties['base-version']}").exclude(group: 'com.zaxxer', module: 'HikariCP')
61-
shadow("com.github.server-utilities:TheBase:${rootProject.properties['base-version']}").exclude(group: 'com.zaxxer', module: 'HikariCP')
60+
implementation('com.github.simplix-softworks:simplixstorage:3.2.7')
61+
shadow('com.github.simplix-softworks:simplixstorage:3.2.7')
62+
63+
implementation('mysql:mysql-connector-java:8.0.33')
64+
shadow('mysql:mysql-connector-java:8.0.33')
65+
66+
implementation('org.xerial:sqlite-jdbc:3.46.1.0')
67+
.exclude(group: 'org.slf4j', module: 'slf4j-api')
68+
shadow('org.xerial:sqlite-jdbc:3.46.1.0')
69+
.exclude(group: 'org.slf4j', module: 'slf4j-api')
70+
71+
implementation('com.zaxxer:HikariCP:5.1.0')
72+
.exclude(group: 'org.slf4j', module: 'slf4j-api')
73+
.exclude(group: 'org.apache.logging.log4j', module: 'log4j-api')
74+
.exclude(group: 'org.apache.logging.log4j', module: 'log4j-core')
75+
.exclude(group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl')
76+
shadow('com.zaxxer:HikariCP:5.1.0')
77+
.exclude(group: 'org.slf4j', module: 'slf4j-api')
78+
.exclude(group: 'org.apache.logging.log4j', module: 'log4j-api')
79+
.exclude(group: 'org.apache.logging.log4j', module: 'log4j-core')
80+
.exclude(group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl')
81+
82+
implementation('net.objecthunter:exp4j:0.4.8')
83+
shadow('net.objecthunter:exp4j:0.4.8')
84+
85+
implementation('com.google.re2j:re2j:1.7')
86+
shadow('com.google.re2j:re2j:1.7')
6287

6388
// OblivateInvs
6489
implementation("com.github.hamza-cskn.obliviate-invs:core:4.1.12").exclude(group: 'com.google.code.gson', module: 'gson')
@@ -101,6 +126,8 @@ shadowJar {
101126
relocate('com.github.Anon8281.universalScheduler', 'host.plas.bou.libs.universalScheduler')
102127
relocate('com.github.benmanes.caffeine', 'host.plas.bou.libs.caffeine')
103128
relocate('com.google.gson', 'host.plas.bou.libs.gson')
129+
130+
relocate('de.leonhard', 'tv.quaint.thebase.lib.leonhard')
104131
}
105132

106133
artifacts {

dependencies.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
ext {
22
IMPL = [
3+
'com.github.Server-Utilities:TheBase:6e4c8814',
34
'com.github.streamline-essentials:UniversalScheduler:main-SNAPSHOT',
45
'com.github.ben-manes.caffeine:caffeine:3.1.8',
56
'com.google.code.gson:gson:2.11.0',
67
]
78
SHADOW = [
9+
'com.github.Server-Utilities:TheBase:6e4c8814',
810
'com.github.streamline-essentials:UniversalScheduler:main-SNAPSHOT',
911
'com.github.ben-manes.caffeine:caffeine:3.1.8',
1012
'com.google.code.gson:gson:2.11.0',

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = BukkitOfUtils
22
group = com.github.streamline-essentials
3-
version = 1.9.0
3+
version = 1.10.0
44

5-
base-version = c8388399
5+
base-version = 6e4c8814
66

77
plugin.main = host.plas.bou.BukkitOfUtils

src/main/java/host/plas/bou/BetterPlugin.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.bukkit.Bukkit;
1313
import org.bukkit.event.HandlerList;
1414
import org.bukkit.event.Listener;
15+
import org.bukkit.plugin.Plugin;
1516
import org.bukkit.plugin.java.JavaPlugin;
1617
import tv.quaint.async.SyncInstance;
1718
import tv.quaint.async.ThreadHolder;
@@ -25,7 +26,7 @@
2526
import java.util.function.Consumer;
2627

2728
@Getter @Setter
28-
public class BetterPlugin extends JavaPlugin implements IModifierEventable, Identified, WithSync, BaseEventListener {
29+
public class BetterPlugin extends JavaPlugin implements IModifierEventable, Identified, WithSync, BaseEventListener, ListenerConglomerate {
2930
@Getter
3031
private final ModifierType modifierType;
3132

@@ -66,6 +67,8 @@ public void onLoad() {
6667

6768
@Override
6869
public void onEnable() {
70+
registerSelfListener();
71+
6972
onBaseEnabling();
7073

7174
if (! (this instanceof BukkitOfUtils)) {
@@ -80,6 +83,18 @@ public void onDisable() {
8083
onBaseDisable();
8184

8285
PluginDisableEvent event = new PluginDisableEvent(this).fire();
86+
87+
unregisterSelfListener();
88+
}
89+
90+
public void registerSelfListener() {
91+
registerListener((Listener) this);
92+
registerListener((BaseEventListener) this);
93+
}
94+
95+
public void unregisterSelfListener() {
96+
unregisterListener((Listener) this);
97+
unregisterListener((BaseEventListener) this);
8398
}
8499

85100
public void registerListenerConglomerate(ListenerConglomerate listener) {
@@ -113,7 +128,7 @@ public void unregisterListener(Listener listener) {
113128
}
114129

115130
public void unregisterAllBukkitListeners() {
116-
HandlerList.unregisterAll(this);
131+
HandlerList.unregisterAll((Plugin) this);
117132
}
118133

119134
public void unregisterAllListeners() {

src/main/java/host/plas/bou/events/MainListener.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import host.plas.bou.BukkitOfUtils;
55
import host.plas.bou.compat.papi.PAPICompat;
66
import host.plas.bou.events.self.plugin.PluginDisableEvent;
7+
import host.plas.bou.gui.ScreenManager;
8+
import host.plas.bou.gui.screens.events.BlockRedrawEvent;
79
import host.plas.bou.utils.DatabaseUtils;
810
import org.bukkit.Bukkit;
911
import org.bukkit.event.Listener;
@@ -30,4 +32,9 @@ public void onPluginDisable(PluginDisableEvent event) {
3032
BukkitOfUtils.getInstance().logWarning("Failed to fully disable a Better Plugin!", t);
3133
}
3234
}
35+
36+
@BaseProcessor
37+
public void onRedrawEvent(BlockRedrawEvent event) {
38+
event.getScreenBlock().onRedraw(event);
39+
}
3340
}

src/main/java/host/plas/bou/firestring/FireString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import lombok.Setter;
55
import tv.quaint.objects.Identifiable;
66
import tv.quaint.objects.SingleSet;
7-
import tv.quaint.thebase.lib.re2j.Matcher;
87
import tv.quaint.utils.MatcherUtils;
8+
import com.google.re2j.Matcher;
99

1010
import java.util.List;
1111

src/main/java/host/plas/bou/gui/ScreenManager.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.Optional;
1111
import java.util.concurrent.ConcurrentSkipListSet;
1212
import java.util.concurrent.atomic.AtomicReference;
13+
import java.util.function.Predicate;
1314

1415
public class ScreenManager {
1516
@Getter @Setter
@@ -77,4 +78,43 @@ public static ConcurrentSkipListSet<ScreenInstance> getPlayersOf(ScreenBlock blo
7778

7879
return players;
7980
}
81+
82+
@Getter @Setter
83+
private static ConcurrentSkipListSet<ScreenBlock> loadedBlocks = new ConcurrentSkipListSet<>();
84+
85+
public static void addBlock(ScreenBlock block) {
86+
loadedBlocks.add(block);
87+
}
88+
89+
public static void removeBlock(Predicate<ScreenBlock> predicate) {
90+
loadedBlocks.removeIf(predicate);
91+
}
92+
93+
public static Optional<ScreenBlock> getScreenBlock(ScreenInstance instance) {
94+
AtomicReference<Optional<ScreenBlock>> block = new AtomicReference<>(Optional.empty());
95+
96+
loadedBlocks.forEach(b -> {
97+
if (block.get().isPresent()) return;
98+
99+
if (instance.getScreenBlock().isPresent() && instance.getScreenBlock().get().equals(b)) {
100+
block.set(Optional.of(b));
101+
}
102+
});
103+
104+
return block.get();
105+
}
106+
107+
public static Optional<ScreenBlock> getScreenBlockOf(Player player) {
108+
AtomicReference<Optional<ScreenBlock>> block = new AtomicReference<>(Optional.empty());
109+
110+
getScreen(player).ifPresent(screen -> {
111+
block.set(getScreenBlock(screen));
112+
});
113+
114+
return block.get();
115+
}
116+
117+
public static boolean hasBlock(ScreenBlock block) {
118+
return loadedBlocks.contains(block);
119+
}
80120
}

src/main/java/host/plas/bou/gui/screens/ScreenInstance.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,20 @@ public void close() {
139139
}
140140

141141
public void redraw() {
142+
redraw(true);
143+
}
144+
145+
public void redraw(boolean reshow) {
142146
build(inventorySheet);
147+
148+
if (reshow) {
149+
reshow();
150+
}
151+
}
152+
153+
public void reshow() {
154+
close();
155+
open();
143156
}
144157

145158
public ConcurrentSkipListMap<String, HumanEntity> getViewers() {

src/main/java/host/plas/bou/gui/screens/blocks/ScreenBlock.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ public void onRedraw() {
5252
public void onOpen(BlockOpenEvent event) {
5353
Player player = event.getPlayer();
5454

55-
if (ScreenManager.hasScreen(player)) {
55+
if (ScreenManager.hasScreen(player) && ! event.isOverride()) {
5656
ScreenManager.getScreen(player).ifPresent(ScreenInstance::open);
57-
} else {
58-
buildScreen(event).open();
57+
return;
5958
}
59+
60+
buildScreen(event).open();
6061
}
6162

6263
public void onClose(BlockCloseEvent event) {
@@ -86,9 +87,10 @@ public ScreenInstance buildScreen(BlockOpenEvent event) {
8687
public void onRedraw(BlockRedrawEvent event) {
8788
ScreenBlock block = event.getScreenBlock();
8889

89-
ScreenManager.getPlayersOf(block).forEach(s -> {
90-
s.close();
91-
s.open();
92-
});
90+
ScreenManager.getPlayersOf(block).forEach(ScreenInstance::redraw);
91+
}
92+
93+
public void redraw() {
94+
BlockRedrawEvent event = new BlockRedrawEvent(this).fire();
9395
}
9496
}

src/main/java/host/plas/bou/gui/screens/events/BlockOpenEvent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
@Getter @Setter
99
public class BlockOpenEvent extends ScreenBlockEvent {
1010
private Player player;
11+
private boolean override;
1112

1213
public BlockOpenEvent(Player player, ScreenBlock screenBlock) {
1314
super(screenBlock);
1415

1516
this.player = player;
17+
this.override = true;
1618
}
1719
}

0 commit comments

Comments
 (0)