Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAIN:
- package me.Askingg.Reflex;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitRunnable;
- import net.md_5.bungee.api.ChatColor;
- public class Main extends JavaPlugin {
- public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
- public void onEnable() {
- getServer().getConsoleSender().sendMessage(prefix + "Plugin successfully enabled.");
- getServer().getPluginManager().registerEvents(new Monsters(), this);
- Commands commands = new Commands();
- getCommand(commands.cmd1).setExecutor(commands);
- getCommand(commands.cmd2).setExecutor(commands);
- getCommand(commands.cmd3).setExecutor(commands);
- getCommand(commands.cmd4).setExecutor(commands);
- runnable();
- registerConfig();
- saveDefaultConfig();
- }
- public void onDisable() {
- getServer().getConsoleSender().sendMessage(prefix + "Plugin Successfully Disabled");
- }
- public void runnable() {
- new BukkitRunnable() {
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- for (LivingEntity e : getServer().getWorld("world").getLivingEntities()) {
- e.setCustomName(e.getType() + "" + ChatColor.DARK_GRAY + " (" + ChatColor.RED + e.getHealth()
- + ChatColor.DARK_GRAY + " / " + ChatColor.RED + e.getMaxHealth() + ChatColor.DARK_GRAY
- + ")");
- e.setCustomNameVisible(true);
- }
- }
- }.runTaskTimerAsynchronously((Plugin) this, 0, 10);
- }
- private void registerConfig() {
- getConfig().options().copyDefaults(true);
- saveConfig();
- }
- }
- COMMANDS:
- package me.Askingg.Reflex;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import net.md_5.bungee.api.ChatColor;
- public class Commands implements CommandExecutor {
- public String cmd1 = "giveitem";
- public String cmd2 = "prefix";
- public String cmd3 = "discord";
- public String cmd4 = "config";
- public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (sender instanceof Player) {
- if (cmd.getName().equalsIgnoreCase(cmd1)) {
- if (args.length != 0) {
- Material item = Material.getMaterial(args[0].toUpperCase());
- if (item != null) {
- Inventory inv = ((Player) sender).getInventory();
- inv.addItem(new ItemStack(item, 1));
- sender.sendMessage(ChatColor.AQUA + "You were given one " + ChatColor.DARK_AQUA + args[0]);
- return true;
- } else {
- sender.sendMessage(ChatColor.RED + args[0] + ChatColor.WHITE + " is not a valid item.");
- return true;
- }
- } else {
- sender.sendMessage(ChatColor.RED + "Not enough arguements.");
- return true;
- }
- }
- if (cmd.getName().equalsIgnoreCase(cmd2)) {
- sender.sendMessage(prefix + "Prefix test command");
- return true;
- }
- if (cmd.getName().equalsIgnoreCase(cmd3)) {
- sender.sendMessage(ChatColor.WHITE + "Join the discord at " + ChatColor.RED + "discord.gg/AW8U7pF"
- + ChatColor.WHITE + " !");
- return true;
- }
- if (cmd.getName().equalsIgnoreCase(cmd4)) {
- sender.sendMessage(ChatColor.RED + "Hi");
- }
- } else {
- sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
- return true;
- }
- return false;
- }
- }
- COMMANDS:
- package me.Askingg.Reflex;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import net.md_5.bungee.api.ChatColor;
- public class Commands implements CommandExecutor {
- public String cmd1 = "giveitem";
- public String cmd2 = "prefix";
- public String cmd3 = "discord";
- public String cmd4 = "config";
- public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (sender instanceof Player) {
- if (cmd.getName().equalsIgnoreCase(cmd1)) {
- if (args.length != 0) {
- Material item = Material.getMaterial(args[0].toUpperCase());
- if (item != null) {
- Inventory inv = ((Player) sender).getInventory();
- inv.addItem(new ItemStack(item, 1));
- sender.sendMessage(ChatColor.AQUA + "You were given one " + ChatColor.DARK_AQUA + args[0]);
- return true;
- } else {
- sender.sendMessage(ChatColor.RED + args[0] + ChatColor.WHITE + " is not a valid item.");
- return true;
- }
- } else {
- sender.sendMessage(ChatColor.RED + "Not enough arguements.");
- return true;
- }
- }
- if (cmd.getName().equalsIgnoreCase(cmd2)) {
- sender.sendMessage(prefix + "Prefix test command");
- return true;
- }
- if (cmd.getName().equalsIgnoreCase(cmd3)) {
- sender.sendMessage(ChatColor.WHITE + "Join the discord at " + ChatColor.RED + "discord.gg/AW8U7pF"
- + ChatColor.WHITE + " !");
- return true;
- }
- if (cmd.getName().equalsIgnoreCase(cmd4)) {
- sender.sendMessage(ChatColor.RED + "Hi");
- }
- } else {
- sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
- return true;
- }
- return false;
- }
- }
- PLUGIN.YML:
- name: Reflex
- author: Askingg
- version: "1.0"
- main: me.Askingg.Reflex.Main
- description: Custom plugin for Reflex SMP
- commands:
- giveitem:
- usage: /<command>
- description: Get any minecraft item.
- prefix:
- usage: /<command>
- description: String test command.
- discord:
- usage: /<command>
- description: View the discord invitation link.
- config:
- usage: /<command>
- description: Test configureable command.
- CONFIG.YML:
- # Change the custom message, this is my first configureable message.
- Custom Message: '&fConfigurable custom message of &cReflex&f. Hello %p!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement