Skip to content

Commit 3ea0a0a

Browse files
committed
* New legacy detection method in Labyrinth.java
* New temporary storage method in PersistentContainer * Changed all Region related listener information to Vent abstraction. * Added new PrintedPaginationBuilder for automatic FinishingCompliment implementation * Force creation of /Services/ parent folder on start if non existent. * Removed SkullItem.java Use CustomHead.java instead * Finished UniformedComponents.accept method
1 parent 6378fdf commit 3ea0a0a

Some content is hidden

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

41 files changed

+339
-720
lines changed

Labyrinth.iml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.16.3-R0.1-SNAPSHOT/spigot-api-1.16.3-R0.1-SNAPSHOT.jar!/" />
3434
</CLASSES>
3535
<JAVADOC />
36-
<SOURCES />
36+
<SOURCES>
37+
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.16.3-R0.1-SNAPSHOT/spigot-api-1.16.3-R0.1-SNAPSHOT-sources.jar!/" />
38+
</SOURCES>
3739
</library>
3840
</orderEntry>
3941
<orderEntry type="module-library">

labyrinth-afk/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>Labyrinth</artifactId>
77
<groupId>com.github.sanctum</groupId>
8-
<version>1.5.9</version>
8+
<version>1.6.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>com.github.sanctum</groupId>
2626
<artifactId>Labyrinth-plugin</artifactId>
27-
<version>1.5.9</version>
27+
<version>1.6.1</version>
2828
</dependency>
2929
</dependencies>
3030

labyrinth-gui/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<artifactId>Labyrinth</artifactId>
77
<groupId>com.github.sanctum</groupId>
8-
<version>1.5.9</version>
8+
<version>1.6.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>Labyrinth-GUI</artifactId>
13-
<version>1.5.9</version>
13+
<version>1.6.1</version>
1414

1515
<!--TODO: determine licensing (likely MIT)-->
1616
<licenses>
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.github.sanctum</groupId>
3232
<artifactId>Labyrinth-plugin</artifactId>
33-
<version>1.5.9</version>
33+
<version>1.6.1</version>
3434
</dependency>
3535
</dependencies>
3636
</project>

labyrinth-plugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<artifactId>Labyrinth</artifactId>
77
<groupId>com.github.sanctum</groupId>
8-
<version>1.5.9</version>
8+
<version>1.6.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>Labyrinth-plugin</artifactId>
13-
<version>1.5.9</version>
13+
<version>1.6.1</version>
1414

1515
<build>
1616
<plugins>

labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/Labyrinth.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import com.github.sanctum.labyrinth.formatting.component.WrappedComponent;
1414
import com.github.sanctum.labyrinth.library.CommandUtils;
1515
import com.github.sanctum.labyrinth.library.Cooldown;
16+
import com.github.sanctum.labyrinth.library.HUID;
1617
import com.github.sanctum.labyrinth.library.Item;
1718
import com.github.sanctum.labyrinth.library.NamespacedKey;
18-
import com.github.sanctum.labyrinth.library.SkullItem;
1919
import com.github.sanctum.labyrinth.library.StringUtils;
2020
import com.github.sanctum.labyrinth.task.Schedule;
2121
import java.io.IOException;
@@ -24,6 +24,7 @@
2424
import java.util.concurrent.ConcurrentLinkedQueue;
2525
import java.util.stream.Collectors;
2626
import org.bukkit.Bukkit;
27+
import org.bukkit.Sound;
2728
import org.bukkit.event.EventHandler;
2829
import org.bukkit.event.Listener;
2930
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@@ -119,9 +120,7 @@ public void onDisable() {
119120
} catch (InterruptedException ignored) {
120121
}
121122

122-
SkullItem.getLog().clear();
123-
124-
if (Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15") || Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
123+
if (!isLegacy()) {
125124
if (Item.getCache().size() > 0) {
126125
for (Item i : Item.getCache()) {
127126
Item.removeEntry(i);
@@ -135,14 +134,29 @@ public VentMap getEventMap() {
135134
return eventMap;
136135
}
137136

137+
/**
138+
* Get a queued list of running task id's
139+
*
140+
* @return A list of most running task id's
141+
*/
138142
public static ConcurrentLinkedQueue<Integer> getTasks() {
139143
return TASKS;
140144
}
141145

146+
/**
147+
* Get all pre-cached cooldowns.
148+
*
149+
* @return A list of all cached cooldowns.
150+
*/
142151
public static LinkedList<Cooldown> getCooldowns() {
143152
return COOLDOWNS;
144153
}
145154

155+
/**
156+
* Get all action wrapped text components.
157+
*
158+
* @return A list of all cached text components.
159+
*/
146160
public static LinkedList<WrappedComponent> getComponents() {
147161
return COMPONENTS;
148162
}
@@ -174,6 +188,15 @@ public static PersistentContainer getContainer(NamespacedKey key) {
174188
return component;
175189
}
176190

191+
/**
192+
* @return true if the given server version is legacy only or false if its pro-1.13
193+
*/
194+
public static boolean isLegacy() {
195+
return Bukkit.getVersion().contains("1.8") || Bukkit.getVersion().contains("1.9")
196+
|| Bukkit.getVersion().contains("1.10") || Bukkit.getVersion().contains("1.11")
197+
|| Bukkit.getVersion().contains("1.12") || Bukkit.getVersion().contains("1.13");
198+
}
199+
177200
/**
178201
* Auxiliary <strong>library</strong> instance.
179202
*/
@@ -182,7 +205,7 @@ public static Plugin getInstance() {
182205
}
183206

184207

185-
static class ComponentListener implements Listener {
208+
public static class ComponentListener implements Listener {
186209
@EventHandler
187210
public void onCommandNote(PlayerCommandPreprocessEvent e) {
188211
for (WrappedComponent component : COMPONENTS) {
@@ -193,6 +216,11 @@ public void onCommandNote(PlayerCommandPreprocessEvent e) {
193216
Schedule.sync(component::remove).waitReal(200);
194217
}
195218
e.setCancelled(true);
219+
} else {
220+
if (HUID.fromString(e.getMessage().replace("/", "")) != null) {
221+
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 1);
222+
e.setCancelled(true);
223+
}
196224
}
197225
}
198226
}

labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionFlag.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.github.sanctum.labyrinth.data;
22

3+
import com.github.sanctum.labyrinth.event.custom.Vent;
34
import com.github.sanctum.labyrinth.library.Cuboid;
4-
import com.github.sanctum.labyrinth.task.Schedule;
55
import org.bukkit.plugin.Plugin;
66

77
public class RegionFlag extends Cuboid.Flag {
88

99
public static class Builder {
1010

1111
private final Plugin plugin;
12-
private RegionService service;
12+
private Vent.Subscription<?> subscription;
1313
private String id;
1414
private String message;
1515

@@ -26,8 +26,13 @@ public Builder label(String id) {
2626
return this;
2727
}
2828

29+
@Deprecated
2930
public Builder envelope(RegionService service) {
30-
this.service = service;
31+
return this;
32+
}
33+
34+
public Builder envelope(Vent.Subscription<?> subscription) {
35+
this.subscription = subscription;
3136
return this;
3237
}
3338

@@ -37,7 +42,8 @@ public Builder receive(String message) {
3742
}
3843

3944
public Cuboid.Flag finish() {
40-
Schedule.sync(() -> RegionServicesManager.getInstance().load(service)).wait(1);
45+
//Schedule.sync(() -> RegionServicesManager.getInstance().load(service)).wait(1);
46+
Vent.subscribe(subscription);
4147
return new RegionFlag(this.plugin, this.id, this.message);
4248
}
4349

labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
import org.bukkit.event.Listener;
44

5+
@Deprecated
56
public interface RegionService extends Listener {
67
}

labyrinth-plugin/src/main/java/com/github/sanctum/labyrinth/data/RegionServicesManager.java

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import com.github.sanctum.labyrinth.library.Message;
1616
import com.github.sanctum.labyrinth.task.Schedule;
1717
import java.util.ArrayList;
18-
import java.util.Arrays;
1918
import java.util.LinkedList;
2019
import java.util.List;
2120
import java.util.Optional;
@@ -71,14 +70,21 @@ public boolean register(Cuboid.Flag flag) {
7170

7271
public boolean load(Cuboid.Flag flag) {
7372
Bukkit.getPluginManager().registerEvents(flag, Labyrinth.getInstance());
74-
return SERVICES.add(flag) && getFlagManager().getFlags().add(flag);
73+
return getFlagManager().getFlags().add(flag);
7574
}
7675

76+
public boolean load(Vent.Subscription<?> subscription) {
77+
Vent.subscribe(subscription);
78+
return true;
79+
}
80+
81+
@Deprecated
7782
public boolean load(RegionService service) {
7883
Bukkit.getPluginManager().registerEvents(service, Labyrinth.getInstance());
7984
return SERVICES.add(service);
8085
}
8186

87+
@Deprecated
8288
public boolean unload(RegionService service) {
8389
HandlerList.unregisterAll(service);
8490
return SERVICES.remove(service);
@@ -204,10 +210,7 @@ public static void start(Labyrinth instance) {
204210

205211
final Cuboid.Selection selection = Cuboid.Selection.source(p);
206212

207-
Schedule.sync(() -> {
208-
CuboidSelectionEvent event = new CuboidSelectionEvent(selection);
209-
instance.getServer().getPluginManager().callEvent(event);
210-
}).run();
213+
Schedule.sync(() -> new Vent.Call<>(new CuboidSelectionEvent(selection)).run()).run();
211214

212215
}
213216

@@ -217,8 +220,7 @@ public static void start(Labyrinth instance) {
217220

218221
Optional<Region> r = CompletableFuture.supplyAsync(() -> Region.match(e.getBlock().getLocation())).join();
219222
if (r.isPresent()) {
220-
RegionDestroyEvent event = new RegionDestroyEvent(e.getPlayer(), r.get(), e.getBlock());
221-
Bukkit.getPluginManager().callEvent(event);
223+
RegionDestroyEvent event = new Vent.Call<>(new RegionDestroyEvent(e.getPlayer(), r.get(), e.getBlock())).run();
222224
if (event.isCancelled()) {
223225
e.setCancelled(true);
224226
}
@@ -230,8 +232,7 @@ public static void start(Labyrinth instance) {
230232

231233
Optional<Region> r = CompletableFuture.supplyAsync(() -> Region.match(e.getBlock().getLocation())).join();
232234
if (r.isPresent()) {
233-
RegionBuildEvent event = new RegionBuildEvent(e.getPlayer(), r.get(), e.getBlock());
234-
Bukkit.getPluginManager().callEvent(event);
235+
RegionBuildEvent event = new Vent.Call<>(new RegionBuildEvent(e.getPlayer(), r.get(), e.getBlock())).run();
235236
if (event.isCancelled()) {
236237
e.setCancelled(true);
237238
}
@@ -261,8 +262,7 @@ public static void start(Labyrinth instance) {
261262
if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
262263
Optional<Region> r = CompletableFuture.supplyAsync(() -> Region.match(e.getBlock().get().getLocation())).join();
263264
if (r.isPresent()) {
264-
RegionInteractionEvent event = new RegionInteractionEvent(e.getPlayer(), r.get(), e.getBlock().get(), RegionInteractionEvent.ClickType.LEFT);
265-
Bukkit.getPluginManager().callEvent(event);
265+
RegionInteractionEvent event = new Vent.Call<>(new RegionInteractionEvent(e.getPlayer(), r.get(), e.getBlock().get(), RegionInteractionEvent.ClickType.LEFT)).run();
266266
if (event.isCancelled()) {
267267
e.setCancelled(true);
268268
}
@@ -274,7 +274,7 @@ public static void start(Labyrinth instance) {
274274
if (!e.getPlayer().hasPermission("labyrinth.selection"))
275275
return;
276276

277-
boolean isNew = Arrays.stream(Material.values()).anyMatch(m -> m.name().equals("WOODEN_AXE"));
277+
boolean isNew = Labyrinth.isLegacy();
278278

279279
Material mat = Items.getMaterial("WOODEN_AXE");
280280

@@ -290,16 +290,14 @@ public static void start(Labyrinth instance) {
290290

291291
selection.setPos1(e.getBlock().get().getLocation());
292292

293-
CuboidCreationEvent event = new CuboidCreationEvent(selection);
294-
Bukkit.getPluginManager().callEvent(event);
293+
new Vent.Call<>(new CuboidCreationEvent(selection)).run();
295294

296295
}
297296
}
298297
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
299298
Optional<Region> r = CompletableFuture.supplyAsync(() -> Region.match(e.getBlock().get().getLocation())).join();
300299
if (r.isPresent()) {
301-
RegionInteractionEvent event = new RegionInteractionEvent(e.getPlayer(), r.get(), e.getBlock().get(), RegionInteractionEvent.ClickType.RIGHT);
302-
Bukkit.getPluginManager().callEvent(event);
300+
RegionInteractionEvent event = new Vent.Call<>(new RegionInteractionEvent(e.getPlayer(), r.get(), e.getBlock().get(), RegionInteractionEvent.ClickType.RIGHT)).run();
303301
if (event.isCancelled()) {
304302
e.setCancelled(true);
305303
}
@@ -311,7 +309,7 @@ public static void start(Labyrinth instance) {
311309
if (!e.getPlayer().hasPermission("labyrinth.selection"))
312310
return;
313311

314-
boolean isNew = Arrays.stream(Material.values()).anyMatch(m -> m.name().equals("WOODEN_AXE"));
312+
boolean isNew = Labyrinth.isLegacy();
315313

316314
Material mat = Items.getMaterial("WOODEN_AXE");
317315

@@ -327,8 +325,7 @@ public static void start(Labyrinth instance) {
327325

328326
selection.setPos2(e.getBlock().get().getLocation());
329327

330-
CuboidCreationEvent event = new CuboidCreationEvent(selection);
331-
Bukkit.getPluginManager().callEvent(event);
328+
new Vent.Call<>(new CuboidCreationEvent(selection)).run();
332329
}
333330
}
334331

@@ -346,8 +343,7 @@ public static void start(Labyrinth instance) {
346343
if (r.getRegion().isPresent()) {
347344
Region region = r.getRegion().get();
348345

349-
RegionPVPEvent e = new RegionPVPEvent(p, target, region);
350-
Bukkit.getPluginManager().callEvent(e);
346+
RegionPVPEvent e = new Vent.Call<>(new RegionPVPEvent(p, target, region)).run();
351347

352348
if (e.isCancelled()) {
353349
event.setCancelled(true);
@@ -356,8 +352,6 @@ public static void start(Labyrinth instance) {
356352

357353
if (region instanceof Region.Spawn) {
358354

359-
Region.Spawn spawn = (Region.Spawn) region;
360-
361355
Region.Resident o = Region.Resident.get(p);
362356

363357
Region.Resident t = Region.Resident.get(target);
@@ -379,8 +373,7 @@ public static void start(Labyrinth instance) {
379373
if (r.getRegion().isPresent()) {
380374
Region region = r.getRegion().get();
381375

382-
RegionPVPEvent e = new RegionPVPEvent(p, target, region);
383-
Bukkit.getPluginManager().callEvent(e);
376+
RegionPVPEvent e = new Vent.Call<>(new RegionPVPEvent(p, target, region)).run();
384377

385378
if (e.isCancelled()) {
386379
event.setCancelled(true);

0 commit comments

Comments
 (0)