Skip to content

Commit

Permalink
Provide additional extension hook point
Browse files Browse the repository at this point in the history
Introduce PacketJumper docs directly in CH docs.
  • Loading branch information
LadyCailin authored Mar 21, 2024
1 parent 1a81140 commit 42e7776
Show file tree
Hide file tree
Showing 12 changed files with 459 additions and 265 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@
<connection>scm:git:git://github.com/sk89q/commandhelper.git</connection>
<url>https://github.com/sk89q/commandhelper</url>
<developerConnection>scm:git:[email protected]:sk89q/commandhelper.git</developerConnection>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class CommandHelperPlugin extends JavaPlugin {
private boolean firstLoad = true;
private long interpreterUnlockedUntil = 0;
private Thread loadingThread;

/**
* Listener for the plugin system.
*/
Expand Down Expand Up @@ -301,6 +302,8 @@ public void run() {
};
loadingThread.start();

ExtensionManager.OnLoad();

myServer = BukkitMCServer.Get();

// Build dynamic enums
Expand Down Expand Up @@ -419,7 +422,6 @@ public void onDisable() {
}

ExtensionManager.Cleanup();

ac = null;
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/laytonsmith/core/constructs/Construct.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ public Target getTarget() {
}

public Construct(String value, ConstructType ctype, int lineNum, File file, int column) {
this.value = value;
Static.AssertNonNull(value, "The string value may not be null.");
this.ctype = ctype;
this.target = new Target(lineNum, file, column);
this(value, ctype, new Target(lineNum, file, column));
}

public Construct(String value, ConstructType ctype, Target t) {
Expand Down Expand Up @@ -218,6 +215,8 @@ private static Object json_encode0(Mixed c, Target t) throws MarshalException {
}
return map;
}
} else if(c.isInstanceOf(CClassType.TYPE)) {
return c.val();
} else {
throw new MarshalException("The type of " + c.getClass().getSimpleName() + " is not currently supported", c);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public File getConfigDir() {
}

// Lifetime functions

/**
* Called the very first time the extension is loaded, before user code is executed.
*/
@Override
public void onLoad() {
}

/**
* Called when server is loading, or during a /reloadaliases call.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/laytonsmith/core/extensions/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public interface Extension {
Version getVersion();

// Lifetime functions
/**
* Called the very first time the extension is loaded, before user code is executed.
*/
void onLoad();

/**
* Called when server is loading, or during a /reloadaliases call.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,24 @@ public static void Cleanup() {
}
}

/**
* This should be run once, on server first startup.
*/
public static void OnLoad() {
for(ExtensionTracker trk : EXTENSIONS.values()) {
for(Extension ext : trk.getExtensions()) {
try {
ext.onLoad();
} catch (Throwable e) {
Logger log = Static.getLogger();
log.log(Level.SEVERE, ext.getClass().getName()
+ "'s onStartup caused an exception:");
log.log(Level.SEVERE, StackTraceUtils.GetStacktrace(e));
}
}
}
}

/**
* This should be run each time the "startup" of the runtime occurs or extensions are reloaded.
*/
Expand Down
77 changes: 0 additions & 77 deletions src/main/java/com/laytonsmith/core/packetjumper/PacketInfo.java

This file was deleted.

This file was deleted.

155 changes: 0 additions & 155 deletions src/main/java/com/laytonsmith/core/packetjumper/PacketJumper.java

This file was deleted.

Loading

0 comments on commit 42e7776

Please sign in to comment.