mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
More plugin system work
This commit is contained in:
parent
a6577064b0
commit
8dfbcb9423
8 changed files with 91 additions and 9 deletions
|
|
@ -21,7 +21,46 @@ test {
|
|||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
task buildPlugins {
|
||||
dependsOn(classes)
|
||||
task initializeNewPlugin {
|
||||
doLast {
|
||||
def pluginFile = new File("src/main/java/MyPlugin")
|
||||
pluginFile.mkdirs()
|
||||
|
||||
def props = new File(rootProject.project("plugin-playground").projectDir.absolutePath + File.separator + "src/main/java/MyPlugin/plugin.properties").text = """
|
||||
AUTHOR='Me'
|
||||
DESCRIPTION='Make sure to rename both the MyPlugin folder and the package statement in plugin.java!
|
||||
VERSION=-1.1
|
||||
"""
|
||||
def java = new File(rootProject.project("plugin-playground").projectDir.absolutePath + File.separator + "src/main/java/MyPlugin/plugin.java").text = """
|
||||
package MyPlugin;
|
||||
|
||||
import plugin.Plugin;
|
||||
|
||||
public class plugin extends Plugin {
|
||||
@Override
|
||||
public void Init() {
|
||||
//Init() is called when the plugin is loaded
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Update() {
|
||||
//Update() is called once per tick (600ms)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Draw(long deltaTime) {
|
||||
//Draw() is called once per frame, with deltaTime being the time since last frame.
|
||||
}
|
||||
|
||||
//Check the source of plugin.Plugin for more methods you can override! Happy hacking! <3
|
||||
//There are also many methods to aid in plugin development in plugin.api.API
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
task buildPlugins(type: Copy, dependsOn: classes) {
|
||||
def pluginsPath = rootProject.project("client").projectDir.absolutePath + File.separator + "plugins"
|
||||
from "build/classes/java/main"
|
||||
into pluginsPath
|
||||
}
|
||||
|
|
@ -1,15 +1,19 @@
|
|||
package OverheadDebugPlugin;
|
||||
|
||||
import plugin.Plugin;
|
||||
import plugin.api.API;
|
||||
import plugin.api.FontColor;
|
||||
import plugin.api.FontType;
|
||||
import plugin.api.TextModifier;
|
||||
import plugin.api.*;
|
||||
import rt4.*;
|
||||
|
||||
/**
|
||||
* @author ceikry
|
||||
*/
|
||||
public class plugin extends Plugin {
|
||||
private boolean isEnabled = false;
|
||||
|
||||
@Override
|
||||
public void PlayerOverheadDraw(Player player, int screenX, int screenY) {
|
||||
if (!isEnabled) return;
|
||||
|
||||
API.DrawText(
|
||||
FontType.SMALL,
|
||||
FontColor.YELLOW,
|
||||
|
|
@ -22,6 +26,8 @@ public class plugin extends Plugin {
|
|||
|
||||
@Override
|
||||
public void NPCOverheadDraw(Npc npc, int screenX, int screenY) {
|
||||
if (!isEnabled) return;
|
||||
|
||||
String npcSb =
|
||||
(npc.type.name.strEquals(JagString.parse("null"))
|
||||
? npc.type.getMultiNpc() != null
|
||||
|
|
@ -44,4 +50,13 @@ public class plugin extends Plugin {
|
|||
screenY
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ProcessCommand(String commandStr, String[] args) {
|
||||
if (!API.PlayerHasPrivilege(Privileges.JMOD)) return;
|
||||
|
||||
if (commandStr.equalsIgnoreCase("::npcdebug")) {
|
||||
isEnabled = !isEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
AUTHOR="Ceikry"
|
||||
DESCRIPTION="Renders helpful debug text over the heads of players and NPCs."
|
||||
VERSION=1.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue