test
This commit is contained in:
parent
87570b4061
commit
6d6c3279c5
|
@ -16,7 +16,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Example extends JavaPlugin implements Listener, CommandExecutor {
|
public class Example extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
private Plugin main;
|
private Plugin main;
|
||||||
|
|
||||||
|
@ -29,55 +29,13 @@ public class Example extends JavaPlugin implements Listener, CommandExecutor {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.main = this;
|
this.main = this;
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new Example(), this);
|
Bukkit.getServer().getPluginManager().registerEvents(new Example(), this);
|
||||||
this.getCommand("test").setExecutor(new Example());
|
this.getCommand("test").setExecutor(new TestCommand());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
|
|
||||||
if (event.getPlayer() == null) return;
|
|
||||||
KingdomPlayer player = UltimateKingdom.Players().getPlayer(event.getPlayer());
|
|
||||||
|
|
||||||
if (player.getKingdom() == null) {
|
|
||||||
System.out.println("Player has no kingdom");
|
|
||||||
}else {
|
|
||||||
|
|
||||||
System.out.println("Player has kingdom " + player.getKingdom().getName());
|
|
||||||
|
|
||||||
//checking for a kingdom
|
|
||||||
if (UltimateKingdom.Kingdoms().getKingdom("MyKingdom") != null) {
|
|
||||||
|
|
||||||
// get the kingdom
|
|
||||||
Kingdom kingdom = UltimateKingdom.Kingdoms().getKingdom("MyKingdom");
|
|
||||||
|
|
||||||
// set user in kingdom
|
|
||||||
player.setKingdom(kingdom);
|
|
||||||
System.out.println("Player is now member of kingdom " + kingdom.getName());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// teleport player in a few seconds to spawn
|
|
||||||
if (player.getKingdom() != null ) {
|
|
||||||
UltimateKingdom.getKingdomServer().TeleportManager().TelePortPlayer(player.getPlayer(), player.getKingdom().getSpawn(),
|
|
||||||
"Kingdom Spawn");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
|
||||||
|
|
||||||
if (!cmd.getName().equalsIgnoreCase("test")) return true;
|
|
||||||
KingdomPlayer kdp = UltimateKingdom.Players().getPlayer((Player ) sender);
|
|
||||||
sender.sendMessage(kdp.getKingdom().getName());
|
|
||||||
|
|
||||||
// if (sender instanceof Player) {
|
|
||||||
// Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Here we need to give items to our player
|
|
||||||
// }
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
26
src/main/java/me/map/example/TestCommand.java
Normal file
26
src/main/java/me/map/example/TestCommand.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package me.map.example;
|
||||||
|
|
||||||
|
import me.map.ultimatekingdom.api.UltimateKingdom;
|
||||||
|
import me.map.ultimatekingdom.api.objects.KingdomPlayer;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class TestCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
|
||||||
|
|
||||||
|
if (!cmd.getName().equalsIgnoreCase("test")) return true;
|
||||||
|
KingdomPlayer kdp = UltimateKingdom.Players().getPlayer((Player) sender);
|
||||||
|
sender.sendMessage(kdp.getKingdom().getName());
|
||||||
|
|
||||||
|
// if (sender instanceof Player) {
|
||||||
|
// Player player = (Player) sender;
|
||||||
|
|
||||||
|
// Here we need to give items to our player
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user