Cleaned up and standardized output messages.

Code tidy.
This commit is contained in:
Steven Lawson 2011-09-25 00:32:00 -04:00
parent 11c10cd83d
commit 4007a8c37a
3 changed files with 135 additions and 101 deletions

View File

@ -1,9 +1,9 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=TotalFreedomMod
application.vendor=Michael
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@ -24,14 +24,13 @@ debug.test.classpath=\
dist.dir=dist
dist.jar=${dist.dir}/TotalFreedomMod.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\repositories\\Bukkit\\target\\bukkit-0.0.1-SNAPSHOT.jar
file.reference.Essentials.jar=C:\\repositories\\Essentials\\BuildAll\\dist\\lib\\Essentials.jar
file.reference.bukkit-0.0.1-SNAPSHOT.jar-2=C:\\github\\Bukkit\\target\\bukkit-0.0.1-SNAPSHOT.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.Essentials.jar}
${file.reference.bukkit-0.0.1-SNAPSHOT.jar-2}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

View File

@ -21,16 +21,15 @@ public class TotalFreedomMod extends JavaPlugin
private final TotalFreedomModEntityListener entityListener = new TotalFreedomModEntityListener(this);
private final TotalFreedomModBlockListener blockListener = new TotalFreedomModBlockListener(this);
//private final TotalFreedomModPlayerListener playerListener = new TotalFreedomModPlayerListener(this);
private static final Logger log = Logger.getLogger("Minecraft");
protected static Configuration CONFIG;
private List<String> superadmins = new ArrayList<String>();
public Boolean allowExplosions = false;
public Boolean allowLavaDamage = false;
public Boolean allowFire = false;
public final static String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public final static String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public final static String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public void onEnable()
{
@ -39,7 +38,10 @@ public class TotalFreedomMod extends JavaPlugin
if (CONFIG.getString("superadmins", null) == null) //Generate config file:
{
log.log(Level.INFO, "[Total Freedom Mod] - Generating default config file (plugins/TotalFreedomMod/config.yml)...");
CONFIG.setProperty("superadmins", new String[] {"Madgeek1450", "markbyron"});
CONFIG.setProperty("superadmins", new String[]
{
"Madgeek1450", "markbyron"
});
CONFIG.setProperty("allow_explosions", false);
CONFIG.setProperty("allow_lava_damage", false);
CONFIG.setProperty("allow_fire", false);
@ -90,8 +92,9 @@ public class TotalFreedomMod extends JavaPlugin
{
if (isUserSuperadmin(sender.getName()))
{
tfBroadcastMessage(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY);
sender.setOp(true);
sender.sendMessage(ChatColor.YELLOW + "You are now op!");
sender.sendMessage(YOU_ARE_OP);
}
else
{
@ -114,8 +117,14 @@ public class TotalFreedomMod extends JavaPlugin
boolean first = true;
for (Player p : Bukkit.getOnlinePlayers())
{
if (first) first = false;
else onlineUsers.append(", ");
if (first)
{
first = false;
}
else
{
onlineUsers.append(", ");
}
if (sender.getName().equalsIgnoreCase("remotebukkit"))
{
@ -123,8 +132,14 @@ public class TotalFreedomMod extends JavaPlugin
}
else
{
if (p.isOp()) onlineUsers.append("[OP]").append(p.getName());
else onlineUsers.append(p.getName());
if (p.isOp())
{
onlineUsers.append("[OP]").append(p.getName());
}
else
{
onlineUsers.append(p.getName());
}
}
}
}
@ -138,11 +153,23 @@ public class TotalFreedomMod extends JavaPlugin
boolean first = true;
for (Player p : Bukkit.getOnlinePlayers())
{
if (first) first = false;
else onlineUsers.append(", ");
if (first)
{
first = false;
}
else
{
onlineUsers.append(", ");
}
if (p.isOp()) onlineUsers.append(ChatColor.RED).append(p.getName());
else onlineUsers.append(p.getName());
if (p.isOp())
{
onlineUsers.append(ChatColor.RED).append(p.getName());
}
else
{
onlineUsers.append(p.getName());
}
onlineUsers.append(ChatColor.WHITE);
}
@ -157,15 +184,16 @@ public class TotalFreedomMod extends JavaPlugin
{
if (isUserSuperadmin(sender.getName()) || player == null)
{
tfBroadcastMessage(String.format("(%s: De-opping everyone)", sender.getName()), ChatColor.GRAY);
for (Player p : Bukkit.getOnlinePlayers())
{
if (!isUserSuperadmin(p.getName()) && !p.getName().equals(sender.getName()))
{
p.setOp(false);
p.sendMessage(YOU_ARE_NOT_OP);
}
}
tfBroadcastMessage(ChatColor.YELLOW + sender.getName() + " de-op'd everyone on the server.");
}
else
{
@ -178,6 +206,8 @@ public class TotalFreedomMod extends JavaPlugin
{
if (isUserSuperadmin(sender.getName()) || player == null)
{
tfBroadcastMessage(String.format("(%s: Opping everyone)", sender.getName()), ChatColor.GRAY);
boolean doSetGamemode = false;
GameMode targetGamemode = GameMode.CREATIVE;
if (args.length != 0)
@ -197,10 +227,13 @@ public class TotalFreedomMod extends JavaPlugin
for (Player p : Bukkit.getOnlinePlayers())
{
p.setOp(true);
if (doSetGamemode) p.setGameMode(targetGamemode);
}
p.sendMessage(YOU_ARE_OP);
tfBroadcastMessage(ChatColor.YELLOW + sender.getName() + " op'd everyone on the server.");
if (doSetGamemode)
{
p.setGameMode(targetGamemode);
}
}
}
else
{
@ -223,10 +256,9 @@ public class TotalFreedomMod extends JavaPlugin
{
matched_player = true;
tfBroadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY);
p.setOp(true);
tfBroadcastMessage("Oping " + p.getName());
p.sendMessage(ChatColor.YELLOW + "You are now op!");
p.sendMessage(YOU_ARE_OP);
}
if (!matched_player)
{
@ -254,10 +286,9 @@ public class TotalFreedomMod extends JavaPlugin
{
matched_player = true;
tfBroadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY);
p.setOp(false);
tfBroadcastMessage("De-opping " + p.getName());
p.sendMessage(ChatColor.YELLOW + "You have been de-op'd.");
p.sendMessage(YOU_ARE_NOT_OP);
}
if (!matched_player)
{
@ -395,7 +426,7 @@ public class TotalFreedomMod extends JavaPlugin
if (player == null || sender.isOp())
{
String message = implodeStringList(" ", Arrays.asList(args));
tfBroadcastMessage(ChatColor.LIGHT_PURPLE + "[Server:" + sender.getName() + "] " + message);
tfBroadcastMessage(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE);
}
else
{
@ -431,7 +462,7 @@ public class TotalFreedomMod extends JavaPlugin
String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
tfBroadcastMessage(String.format("%sBanning: %s, IP: %s.", ChatColor.RED, p.getName(), user_ip));
tfBroadcastMessage(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
Bukkit.banIP(user_ip);
Bukkit.getOfflinePlayer(p.getName()).setBanned(true);
@ -448,6 +479,8 @@ public class TotalFreedomMod extends JavaPlugin
{
if (player == null || isUserSuperadmin(sender.getName()))
{
tfBroadcastMessage("Server is going offline.", ChatColor.GRAY);
for (Player p : Bukkit.getOnlinePlayers())
{
p.kickPlayer("Server is going offline, come back in a few minutes.");
@ -474,12 +507,12 @@ public class TotalFreedomMod extends JavaPlugin
if (args[0].equalsIgnoreCase("on"))
{
this.allowExplosions = true;
sender.sendMessage("Explosives are now enabled. Don't blow your fingers off!");
sender.sendMessage("Explosives are now enabled.");
}
else
{
this.allowExplosions = false;
sender.sendMessage("Explosives are now disabled. Funtime is over...");
sender.sendMessage("Explosives are now disabled.");
}
}
else
@ -547,11 +580,13 @@ public class TotalFreedomMod extends JavaPlugin
return false;
}
public static void tfBroadcastMessage(String message)
public static void tfBroadcastMessage(String message, ChatColor color)
{
log.info(message);
for (Player p : Bukkit.getOnlinePlayers())
{
p.sendMessage(message);
p.sendMessage(color + message);
}
}

View File

@ -1,6 +1,6 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 1.1.2
version: 1.2.0
description: Plugin for the Total Freedom server
author: StevenLawson / Madgeek1450
commands: