Run Java plugins without compiling them

Overview

Run Java plugins without compiling them!

Usage

Under plugins/SkriptJava, you can put your .java files to run when the server is up and loaded. This plugin will compile them at runtime and execute them.

Execution

Each script has to have a load() and unload() function, as well as a constructor that takes in the Plugin parameter. There is a demo script loaded for you to see when the plugin loads for the first time.

Listeners

You can call Bukkit functions and classes like normal. You can also implement Listener if you want to handle events. It's the same as you would do for a plugin.

Commands

You can also make command scripts by implementing CommandExecutor and having a getCommand() function that returns the command name.

Example

HelloWorld.java

{ for (Player player : Bukkit.getOnlinePlayers()) { player.sendMessage("You can even run scheduled scripts!"); } }, 0L, 20L); } /** * Every script can also have an unload method. This will be called when unloading the script, * and its better memory management. It is not necessary but it is recommended. */ public void unload() { uuids.clear(); } /** * You can handle events here by using normal @EventHandler annotations. */ @EventHandler public void onJoin(PlayerJoinEvent e) { uuids.add(e.getPlayer().getUniqueId()); broadcast(e.getPlayer().getUniqueId(), e.getPlayer().getName()); } @EventHandler public void onLeave(PlayerQuitEvent e) { uuids.remove(e.getPlayer().getUniqueId()); broadcast(e.getPlayer().getUniqueId(), e.getPlayer().getName()); } private void broadcast(UUID uuid, String name) { for (Player player : Bukkit.getOnlinePlayers()) { player.sendMessage(name + " (" + uuid + ") has joined the server!"); } } /** * Handle commands using Bukkit CommandExecutor interface. */ @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { commandSender.sendMessage("This is a Demo Java Skript command!"); return false; } /** * Running /demo will execute the onCommand method. */ public String getCommand() { return "demo"; } }">
package skriptjava;

/**
 * You can use Bukkit imports here. It would still work.
 */
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;

import java.util.HashSet;
import java.util.UUID;

/**
 * A basic Java class, with a Bukkit Listener implemented to handle events.
 */
public class HelloWorld implements Listener, CommandExecutor {

    private HashSet<UUID> uuids;
    private final Plugin skriptJava;
    public HelloWorld(Plugin plugin) {
        this.skriptJava = plugin;
        uuids = new HashSet<>();
    }

    /**
     * Every script must start with a load method. This will be called when a script is loaded.
     */
    public void load() {
        System.out.println("Hello World! This is a Demo Java Skript");
        skriptJava.getServer().getScheduler().runTaskTimer(skriptJava, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                player.sendMessage("You can even run scheduled scripts!");
            }
        }, 0L, 20L);
    }

    /**
     * Every script can also have an unload method. This will be called when unloading the script,
     * and its better memory management. It is not necessary but it is recommended.
     */
    public void unload() {
        uuids.clear();
    }

    /**
     * You can handle events here by using normal @EventHandler annotations.
     */
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        uuids.add(e.getPlayer().getUniqueId());
        broadcast(e.getPlayer().getUniqueId(), e.getPlayer().getName());
    }

    @EventHandler
    public void onLeave(PlayerQuitEvent e) {
        uuids.remove(e.getPlayer().getUniqueId());
        broadcast(e.getPlayer().getUniqueId(), e.getPlayer().getName());
    }

    private void broadcast(UUID uuid, String name) {
        for (Player player : Bukkit.getOnlinePlayers()) {
            player.sendMessage(name + " (" + uuid + ") has joined the server!");
        }
    }

    /**
     * Handle commands using Bukkit CommandExecutor interface.
     */
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        commandSender.sendMessage("This is a Demo Java Skript command!");
        return false;
    }

    /**
     * Running /demo will execute the onCommand method.
     */
    public String getCommand() {
        return "demo";
    }
}

In-game Commands

  • /skriptjava reload [script] - Hot-reloads a script. Case-sensitive. (Permission: skriptjava.reload)
  • /skriptjava reloadall - Hot-reloads all active scripts. (Permission: skriptjava.reloadall)
  • /skriptjava load [script] - Loads a new script. Case-sensitive. (Permission: skriptjava.load)
  • /skriptjava unload [script] - Unloads an active script. Case-sensitive. (Permission: skriptjava.unload)
  • /skriptjava list - Lists all active scripts. (Permission: skriptjava.list)
You might also like...

Spigot Premium Plugins Updater

SPPU Spigot Premium Plugins Updater Installation Minimum Java 8 required Download the SPPU.jar and put it into your servers root directory Download th

Aug 1, 2022

A MOTD plugin for Velocity that caches network packets. This helps it be the fastest one of the MOTD plugins.

FastMOTD A MOTD plugin for Velocity that catches network packets. This helps it be the fastest one of the MOTD plugins. Test server: ely.su Features F

Dec 24, 2022

The goal of the project is to create a web application using Java EE and database (PostgreSQL) without connecting a modern technology stack like spring boot and hibernate

The goal of the project is to create a web application using Java EE and database (PostgreSQL) without connecting a modern technology stack like spring boot and hibernate

About The Project SignIn page SignUp page Profile page The goal of the project is to create a web application using Java EE and database (PostgreSQL)

Mar 23, 2022

tuya-spring-boot-starter helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilities. You can put all the focus on business logic without taking care of server-side programming nor relational databases.

English | 中文版 tuya-spring-boot-starter helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilit

Dec 26, 2022

Get device location by telephony (SIM card) or settings without using GPS tracker.

Get device location by telephony (SIM card) or settings without using GPS tracker.

react-native-device-country Get device location by telephony (SIM card) or settings without using GPS tracker Installation yarn add react-native-devic

Nov 29, 2022

Maintainable software without effort.

modern-clean-architecture Create services with a clean architecture with significantly less effort necessary than usual. The main idea of Clean Archit

Dec 14, 2022

A simple app to use Xposed without root, unlock the bootloader or modify system image, etc.

A simple app to use Xposed without root, unlock the bootloader or modify system image, etc.

中文文档 Introduction VirtualXposed is a simple App based on VirtualApp and epic that allows you to use an Xposed Module without needing to root, unlock t

Jan 8, 2023

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

Dec 30, 2022

InstaKill is a shitty addon for the Meteor Client created without knowledge of the code

InstaKill About InstaKill is a shitty addon for the Meteor Client created without knowledge of the code. The only thing this addon adds is InstaKill e

Jun 15, 2022
Releases(release)
Owner
Rance Andres
I mostly do Java projects but time to time I store some C++ as well. I study Game Development in Singapore.
Rance Andres
A demo of Rongcloud uniapp sdk integration for compiling debug-apk in Android Studio

Rongcloud-uniapp-sdk-demo A demo of Rongcloud uniapp sdk integration for compiling debug-apk in Android Studio 这是一个为了给uniapp在Android平台打出debug-apk的demo

Zongkui Guo 1 Oct 13, 2021
A Java agent that disables platform features you don't use, before an attacker uses them against you.

aegis4j Avoid the NEXT Log4Shell vulnerability! The Java platform has accrued a number of features over the years. Some of these features are no longe

Daniel Gredler 14 Jan 11, 2022
Allows acquiring of vanilla/mod assets at runtime instead of including them in builds potentially violating licenses

AssetMover Allows acquiring of vanilla/mod assets at runtime instead of including them in builds potentially violating licenses. Features: Downloading

Cleanroom 5 Nov 26, 2022
Flutter plugin to listen to all incoming notifications (posted or removed) with the possibility to reply to them

notification_listener_service A flutter plugin for interacting with Notification Service in Android. NotificationListenerService is a service that rec

Iheb Briki 10 Dec 15, 2022
A script that downloads wallpapers from the subreddit r/wallpapers and then sets them on your Windows machine.

Wallpaper Downloader ?? This script takes the most voted wallpaper in the subreddit r/wallpapers in 24 hours, downloads the .json of that page, parses

404a10 1 May 15, 2022
A manager tool to categorize game assets such as images and sounds/music. The tool enables you to tag these files, so that finding them by tags allows fast searches.

BtAssetManager This application allows you to easily categorize large amounts of image and sound files. You can apply tags to each individual file to

null 21 Sep 15, 2022
BurritoSpigot is a fork of TacoSpigot 1.8.9 that offers several enhancements to performance as well as bug fixes. while offer extra APIs and support for plugins

?? BurritoSpigot ?? BurritoSpigot is a fork of TacoSpigot 1.8.8 that offers several enhancements to performance as well as bug fixes. while offer extr

Cobble Sword Services 44 Dec 20, 2022
This is a module for Waterfall/Bungeecord! That means instead of putting it in the plugins/ folder

CMD: Plugins This is a module for Waterfall/Bungeecord! That means instead of putting it in the plugins/ folder, you put it in the modules/ folder! In

CyberedCake 0 Jun 8, 2022
A supercharged gradle template for developing Minecraft plugins with multi platform support.

Minecraft Multi-Platform Template You can use this template to develop your own high quality Minecraft plugins for multiple platforms using Gradle wit

sVoxelDev 3 Nov 23, 2022