API

Ghost Player API

Implementing Ghost Player in your code

Example :

(This example is obsolete because Ghost Player now set the default tranformation but you can take a look to see how to use the API).

package com.skyost.ghostserver;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import com.skyost.gp.GhostFactory;
import com.skyost.gp.GhostPlayerPlugin;


public class GhostServer extends JavaPlugin implements Listener {
	
	public static GhostFactory ghostFactory;
	
	@SuppressWarnings("static-access")
	public void onEnable() {
		this.ghostFactory = new GhostFactory((Plugin) this);
		this.getServer().getPluginManager().registerEvents(this, this);
	}
	
	public boolean loadGhostFactory() {
		if(this.getServer().getPluginManager().getPlugin("Ghost Player") != null) {
			ghostFactory = GhostPlayerPlugin.ghostFactory;
			System.out.println("[GhostServer] Ghost Player has been loaded with success !");
			return true;
		}
		else {
			return false;
		}
	}
	
	public void onDisable() {
		getServer().getPluginManager().disablePlugin(this);
	}
	
	@EventHandler
	public void onPlayerRespawn(PlayerRespawnEvent event) {
		if(ghostFactory.isGhost(event.getPlayer()) == false) {
			ghostFactory.setGhost(event.getPlayer(), true);
		}
    	}
	
	@EventHandler
	public void onPlayerQuit(PlayerQuitEvent event) {
		if(ghostFactory.isGhost(event.getPlayer()) == true) {
			ghostFactory.setGhost(event.getPlayer(), false);
		}
	}
    
	@EventHandler
	public void onPlayerDeath(PlayerDeathEvent event) {
		if(ghostFactory.isGhost(event.getEntity()) == false) {
			ghostFactory.setGhost(event.getEntity(), true);
		}
	}
    
	@EventHandler
	public void onPlayerJoin(PlayerJoinEvent event) {
		if(ghostFactory.isGhost(event.getPlayer()) == false) {
			ghostFactory.setGhost(event.getPlayer(), true);
		}
		event.getPlayer().sendMessage(ChatColor.GREEN + "Welcome to" + " " + getServer().getName() + ", the ghost world...!");
		event.setJoinMessage(ChatColor.GREEN + event.getPlayer().getName() + " " + "has joined the ghost world...");
	}
}

In this example, we are making players ghost all the time !

JavaDoc

You can find the JavaDoc here.


Comments

Posts Quoted:
Reply
Clear All Quotes