/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chaoswg;
import net.risingworld.api.Plugin;
import net.risingworld.api.Server;
import net.risingworld.api.World;
import net.risingworld.api.events.EventMethod;
import net.risingworld.api.events.Listener;
import net.risingworld.api.events.Threading;
import net.risingworld.api.events.player.PlayerRespawnEvent;
import net.risingworld.api.events.player.PlayerSpawnEvent;
import net.risingworld.api.gui.Font;
import net.risingworld.api.gui.GuiLabel;
import net.risingworld.api.gui.PivotPosition;
import net.risingworld.api.objects.Player;
/**
*
* @author noci
*/
public class Beispielplugin extends Plugin implements Listener{
Server server;
World world;
@Override
public void onEnable() {
System.out.print("### ENABLE\n");
//Get server and world objects
server = getServer();
world = getWorld();
//Show server name
System.out.println("Server name: " + server.getName());
//Show world name and seed
System.out.println("World name: " + world.getName() + " seed: " + world.getSeed());
}
@Override
public void onDisable() {
System.out.print("### DISABLE\n");
}
//@EventMethod(Threading.Sync)
//public void onPlayerSpawn(PlayerSpawnEvent event){
@net.risingworld.api.events.EventMethod
public void onPlayerSpawn(net.risingworld.api.events.player.PlayerSpawnEvent event) {
System.out.print("### Player Spawn\n");
//Label with relative coordinates. Coordinates start from the bottom
//left corner, i.e. the relative coordinates x=0.9 and y=0.1 are close
//to the right corner of the screen.
GuiLabel label = new GuiLabel(0.9f, 0.1f, true);
//Set the text of this label
label.setText("Hello World!" + server.getName());
//Change the pivot of this label to "bottom right"
label.setPivot(PivotPosition.BottomRight);
//We want a bold mono font
label.setFont(Font.DefaultMono_Bold);
//Change the font size (default is 12, we want to make it
//a little bit bigger
label.setFontSize(20);
Player p = event.getPlayer();
p.addGuiElement(label);
}
}