Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

Pcbroadcast [Minecraft Plugin]


tripps41
 Share

Recommended Posts

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 by tripps41
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share