tripps41 Posted June 21, 2014 Share Posted June 21, 2014 (edited) Hey guys tripps here and i am posting my plugin for minecraft . I have no idea how to post this so i will just paste the coding and a link to the page. Download Main Class: package net.jc.minecraft; import java.io.IOException; import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; public final class PcBroadcast extends JavaPlugin { PcTask task; public static boolean enabled = true; public class PcTask extends BukkitRunnable { public void run() { if (PcBroadcast.enabled) { int I = new Random().nextInt(PcBroadcast.this.getConfig().getStringList("Messages").size()); String PCM = ChatColor.translateAlternateColorCodes('&', (String)PcBroadcast.this.getConfig().getStringList("Messages").get(I)); String prefix = ChatColor.translateAlternateColorCodes('&', PcBroadcast.this.getConfig().getString("Prefix")); Bukkit.broadcastMessage(prefix + PCM); } } } public void onEnable() { task = new PcTask(); getLogger().info("PCB Is Enabled!"); this.getConfig().options().copyDefaults(true); saveDefaultConfig(); task.runTaskTimer(this, 10L, getConfig().getLong("Time") * 20L); try { MetricsLite metrics = new MetricsLite(this); metrics.start(); } catch (IOException e) { // Failed to submit the stats :-( } } public void onDisable() { getLogger().info("PCB Is Disabled!"); Bukkit.getScheduler().cancelTasks(this); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("pcb")) { if (args.length == 0) { if (sender.hasPermission("pcb")) { sender.sendMessage(ChatColor.GOLD + "/pcb toggle - This command will toggle broadcasting messages!"); sender.sendMessage(ChatColor.GOLD + "/pcb reload - This command will reload the configuration of PCM!"); sender.sendMessage(ChatColor.GOLD + "/pcb credits - This will display the people who developed PCM!"); } else { sender.sendMessage(ChatColor.RED + "NICE TRY!"); } } else if (args.length == 1) { if (args[0].equalsIgnoreCase("toggle")) { if (sender.hasPermission("pcb.toggle")) { enabled = !enabled; sender.sendMessage(ChatColor.GREEN + "PCB BROADCAST IS NOW SET TO" + ChatColor.RED + enabled); } else { sender.sendMessage(ChatColor.RED + "NICE TRY!"); } } else if (args[0].equalsIgnoreCase("reload")) { if (sender.hasPermission("pcb.reload")) { this.reloadConfig(); sender.sendMessage(ChatColor.AQUA + "PCB" + ChatColor.GREEN + " Has Been Reloaded From Disk Space!"); } else { sender.sendMessage(ChatColor.RED + "NICE TRY!"); } } else if (args[0].equalsIgnoreCase("credits")) { if (sender.hasPermission("pcb.credits")){ sender.sendMessage(ChatColor.GREEN + "PCB was made by Polarcraft"); sender.sendMessage(ChatColor.AQUA + "Aka tripps41"); } } } else if (args.length >= 2) { sender.sendMessage("TOO MANY ARGUMENTS."); } } return false; } } Edited June 21, 2014 by tripps41 1 Quote Link to comment Share on other sites More sharing options...
UnPrePared_ Posted June 24, 2014 Share Posted June 24, 2014 There is something a long time ago made ? Why do you think people/server owners need this ? Quote Link to comment Share on other sites More sharing options...
tripps41 Posted June 24, 2014 Author Share Posted June 24, 2014 Because people still use this plugin. And it was made by me so i decided to post it to hg. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.