Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Main class:
- package com.xpietqr_.pack;
- import java.util.logging.Logger;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- import com.xpietqr_.pack.commands.Goodbye;
- import com.xpietqr_.pack.commands.Hello;
- public class PlayerMessagePlugin extends JavaPlugin {
- public void onEnalble() {
- PluginDescriptionFile pdffile = getDescription();
- Logger logger = getLogger();
- getCommand("hello").setExecutor(new Hello());
- getCommand("goodbye").setExecutor(new Goodbye());
- logger.info(pdffile.getName() + " Has been Enabled! (V." + pdffile.getVersion() + ")");
- }
- public void onDisable() {
- PluginDescriptionFile pdffile = getDescription();
- Logger logger = getLogger();
- logger.info(pdffile.getName() + " Has been disabled! (V." + pdffile.getVersion() + ")");
- }
- }
- goodbye class:
- package com.xpietqr_.pack.commands;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class Goodbye implements CommandExecutor {
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
- String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage("You MUST be a player to use this command!");
- return false;
- }
- Player player = (Player) sender;
- Location l = new Location(player.getWorld(), 0, 64, 0);
- player.sendMessage(ChatColor.RED + "Goodbye");
- player.teleport(l);
- return true;
- }
- }
- Hello class
- package com.xpietqr_.pack.commands;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class Hello implements CommandExecutor {
- public boolean onCommand(CommandSender sender, Command command,
- String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage("You MUST be a player to use this command!");
- return false;
- }
- Player player = (Player) sender;
- player.sendMessage(ChatColor.RED + "Hello " + player.getName());
- return true;
- }
- }
- plugin.yml
- main: com.xpietqr_.pack.PlayerMessagePlugin
- version: 1.0
- name: PlayerMessagePlugin
- commands:
- hello:
- description: Sends a player a message! :)
- goodbye:
- description: Teleports the player to the goodbye!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement