OpenJS-docs
Download plugin
  • Overview
    • Welcome
  • Getting Started
    • Installing the plugin
    • Configuration file
    • Commands
    • Creating scripts
  • OpenJS Components
    • Feature Flags
    • Managing scripts within scripts
    • Sharing variables between scripts
    • Custom Commands
    • Using PlaceHolderApi
    • Listening and cancelling events
    • Custom events
    • Loading and saving data
    • Logging in console
    • Scheduling
    • Java imports
  • Example Scripts
    • spawn hit stand command
    • Knockbackstick command
    • No hit-cooldown script
    • NoBlockPlacing script
    • Saving Player data script
    • running code asynchronously
    • WhileTrue do script
Powered by GitBook
On this page
  1. OpenJS Components

Java imports

//!import org.bukkit.Bukkit
//!import org.bukkit.event.player.PlayerJoinEvent
//!import java.util.logging.Logger

// Access the imported classes
var Bukkit = org.bukkit.Bukkit;
var PlayerJoinEvent = org.bukkit.event.player.PlayerJoinEvent;
var Logger = java.util.logging.Logger;

// Get a custom Logger
var logger = Logger.getLogger("OpenJSPluginLogger");

// Register the event listener
registerEvent(PlayerJoinEvent.class.getName(), {
    handleEvent: function(event) {
        var player = event.getPlayer();
        var message = "Welcome " + player.getName() + " to the server!";
        player.sendMessage(message);
        logger.info(message);
    }
});

This is not a complete documentation on java imports

PreviousSchedulingNextspawn hit stand command

Last updated 7 days ago