Skip to content

Commit c41c256

Browse files
Commented new changes
1 parent af21eab commit c41c256

File tree

12 files changed

+89
-2
lines changed

12 files changed

+89
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.illusion.skyblockcore.common.event;
22

3+
/**
4+
* This class is a basic tag class for skyblock events. It is expected that all skyblock events extend this class.
5+
*/
36
public abstract class SkyblockEvent {
47

58
}

SkyblockCore-Common/src/main/java/me/illusion/skyblockcore/common/event/impl/SkyblockPlatformEnabledEvent.java

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import me.illusion.skyblockcore.common.event.SkyblockEvent;
44
import me.illusion.skyblockcore.common.platform.SkyblockPlatform;
55

6+
/**
7+
* This event is called when the SkyblockPlatform is enabled.
8+
*/
69
public class SkyblockPlatformEnabledEvent extends SkyblockEvent {
710

811
private final SkyblockPlatform platform;
@@ -11,6 +14,11 @@ public SkyblockPlatformEnabledEvent(SkyblockPlatform plugin) {
1114
this.platform = plugin;
1215
}
1316

17+
/**
18+
* Gets the SkyblockPlatform that was enabled.
19+
*
20+
* @return The SkyblockPlatform that was enabled.
21+
*/
1422
public SkyblockPlatform getPlatform() {
1523
return platform;
1624
}

SkyblockCore-Common/src/main/java/me/illusion/skyblockcore/common/event/listener/SkyblockEventListener.java

+10
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22

33
import me.illusion.skyblockcore.common.event.SkyblockEvent;
44

5+
/**
6+
* This interface is responsible for listening to skyblock events.
7+
*
8+
* @param <T> The event type.
9+
*/
510
public interface SkyblockEventListener<T extends SkyblockEvent> {
611

12+
/**
13+
* This method is called when a skyblock event is called.
14+
*
15+
* @param event The event that was called.
16+
*/
717
void onEvent(T event);
818

919
}

SkyblockCore-Common/src/main/java/me/illusion/skyblockcore/common/event/manager/SkyblockEventManager.java

+16
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
import me.illusion.skyblockcore.common.event.SkyblockEvent;
44
import me.illusion.skyblockcore.common.event.listener.SkyblockEventListener;
55

6+
/**
7+
* This interface is responsible for managing skyblock events and their listeners.
8+
*/
69
public interface SkyblockEventManager {
710

11+
/**
12+
* Subscribes a listener to a specific event class.
13+
*
14+
* @param eventClass The event class to subscribe to.
15+
* @param listener The listener to subscribe.
16+
* @param <T> The event type.
17+
*/
818
<T extends SkyblockEvent> void subscribe(Class<T> eventClass, SkyblockEventListener<T> listener);
919

20+
/**
21+
* Unsubscribes a listener from a specific event class.
22+
*
23+
* @param event The event class to unsubscribe from.
24+
* @param <T> The event type.
25+
*/
1026
<T extends SkyblockEvent> void callEvent(T event);
1127

1228
}

SkyblockCore-Common/src/main/java/me/illusion/skyblockcore/common/event/manager/SkyblockEventManagerImpl.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
import me.illusion.skyblockcore.common.event.SkyblockEvent;
66
import me.illusion.skyblockcore.common.event.listener.SkyblockEventListener;
77

8+
/**
9+
* This class is a basic implementation of the SkyblockEventManager interface.
10+
*/
811
public class SkyblockEventManagerImpl implements SkyblockEventManager {
912

10-
private final Set<SkyblockEventHandler<?>> handlers = ConcurrentHashMap.newKeySet();
13+
private final Set<SkyblockEventHandler<?>> handlers = ConcurrentHashMap.newKeySet(); // This could be better
1114

1215
@Override
1316
public <T extends SkyblockEvent> void subscribe(Class<T> eventClass, SkyblockEventListener<T> listener) {
@@ -23,11 +26,16 @@ public <T extends SkyblockEvent> void callEvent(T event) {
2326
continue;
2427
}
2528

26-
SkyblockEventHandler<T> castedHandler = (SkyblockEventHandler<T>) handler;
29+
SkyblockEventHandler<T> castedHandler = (SkyblockEventHandler<T>) handler; // icky
2730
castedHandler.accept(event);
2831
}
2932
}
3033

34+
/**
35+
* This is an internal class that represents a subscribed event handler.
36+
*
37+
* @param <T>
38+
*/
3139
private static class SkyblockEventHandler<T extends SkyblockEvent> {
3240

3341
private final Class<T> eventClass;

SkyblockCore-Server/src/main/java/me/illusion/skyblockcore/server/event/island/SkyblockIslandEvent.java

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import me.illusion.skyblockcore.common.event.SkyblockEvent;
44
import me.illusion.skyblockcore.server.island.SkyblockIsland;
55

6+
/**
7+
* This class is a basic tag class for skyblock island events. It is expected that all skyblock island events extend this class.
8+
*/
69
public abstract class SkyblockIslandEvent extends SkyblockEvent {
710

811
private final SkyblockIsland island;
@@ -11,6 +14,11 @@ public SkyblockIslandEvent(SkyblockIsland island) {
1114
this.island = island;
1215
}
1316

17+
/**
18+
* Gets the SkyblockIsland that was involved in this event.
19+
*
20+
* @return The SkyblockIsland that was involved in this event.
21+
*/
1422
public SkyblockIsland getIsland() {
1523
return island;
1624
}

SkyblockCore-Server/src/main/java/me/illusion/skyblockcore/server/event/island/SkyblockIslandLoadEvent.java

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import me.illusion.skyblockcore.server.island.SkyblockIsland;
44

5+
/**
6+
* This event is called when a SkyblockIsland is loaded.
7+
*/
58
public class SkyblockIslandLoadEvent extends SkyblockIslandEvent {
69

710
public SkyblockIslandLoadEvent(SkyblockIsland island) {

SkyblockCore-Server/src/main/java/me/illusion/skyblockcore/server/event/island/SkyblockIslandUnloadEvent.java

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import me.illusion.skyblockcore.server.island.SkyblockIsland;
44

5+
/**
6+
* This event is called when a SkyblockIsland is unloaded.
7+
*/
58
public class SkyblockIslandUnloadEvent extends SkyblockIslandEvent {
69

710
public SkyblockIslandUnloadEvent(SkyblockIsland island) {

SkyblockCore-Server/src/main/java/me/illusion/skyblockcore/server/island/AbstractIslandManager.java

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import me.illusion.skyblockcore.common.platform.SkyblockPlatform;
1111
import me.illusion.skyblockcore.common.profile.SkyblockProfileCache;
1212

13+
/**
14+
* Abstract implementation of the SkyblockIslandManager
15+
*/
1316
public abstract class AbstractIslandManager implements SkyblockIslandManager {
1417

1518
protected final Map<UUID, SkyblockIsland> loadedIslands = new ConcurrentHashMap<>();

SkyblockCore-Server/src/main/java/me/illusion/skyblockcore/server/util/SkyblockLocation.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.illusion.skyblockcore.server.util;
22

3+
/**
4+
* Represents a multi-platform location. It is expected that each platform makes an adapter for this class.
5+
*/
36
public class SkyblockLocation {
47

58
private final String world;

SkyblockCore-Spigot/src/main/java/me/illusion/skyblockcore/spigot/SkyblockSpigotPlugin.java

+11
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,17 @@ private void finishLoading() {
101101

102102
}
103103

104+
/**
105+
* Registers the default skyblock networks
106+
*/
104107
private void registerNetworks() {
105108
networkRegistry.register(new ComplexSkyblockNetwork(this));
106109
networkRegistry.register(new SimpleSkyblockNetwork(this));
107110
}
108111

112+
/**
113+
* Initializes the cosmos setup
114+
*/
109115
private void initCosmos() {
110116
if (cosmosSetup != null) {
111117
throw new IllegalStateException("Cosmos setup already initialized!");
@@ -118,6 +124,11 @@ private void initCosmos() {
118124
cosmosSetup = cosmosSetupFile.getSetup();
119125
}
120126

127+
/**
128+
* Sets the profile cache
129+
*
130+
* @param profileCache The profile cache
131+
*/
121132
public void setProfileCache(SkyblockProfileCache profileCache) {
122133
this.profileCache = profileCache;
123134
}

SkyblockCore-Spigot/src/main/java/me/illusion/skyblockcore/spigot/network/SkyblockNetworkRegistryImpl.java

+11
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
import me.illusion.skyblockcore.server.network.AbstractSkyblockNetworkRegistry;
55
import me.illusion.skyblockcore.spigot.SkyblockSpigotPlugin;
66
import me.illusion.skyblockcore.spigot.utilities.config.BukkitConfigurationAdapter;
7+
import org.bukkit.Bukkit;
78

89
public class SkyblockNetworkRegistryImpl extends AbstractSkyblockNetworkRegistry {
910

11+
private final SkyblockSpigotPlugin plugin;
12+
1013
public SkyblockNetworkRegistryImpl(SkyblockSpigotPlugin plugin) {
1114
super(plugin, BukkitConfigurationAdapter.adapt(new YMLBase(plugin, "network-settings.yml").getConfiguration()));
15+
this.plugin = plugin;
16+
}
17+
18+
@Override
19+
protected void failToEnable(String name) {
20+
super.failToEnable(name);
21+
22+
Bukkit.getPluginManager().disablePlugin(plugin);
1223
}
1324
}

0 commit comments

Comments
 (0)