A few little fixes.

Make /cake give the cake achievement.
Fix /lockup.
Colorful MOTD, more MOTD options.
This commit is contained in:
Steven Lawson 2013-07-04 12:10:08 -04:00
parent 15fbd0e1f3
commit 0dca359e4c
6 changed files with 47 additions and 21 deletions

View File

@ -1,5 +1,5 @@
#Wed, 03 Jul 2013 16:10:19 -0400 #Wed, 03 Jul 2013 22:54:08 -0400
program.VERSION=2.20 program.VERSION=2.20
program.BUILDNUM=247 program.BUILDNUM=259
program.BUILDDATE=07/03/2013 04\:10 PM program.BUILDDATE=07/03/2013 10\:54 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Wed Jul 03 16:10:19 EDT 2013 #Wed Jul 03 22:54:08 EDT 2013
build.number=248 build.number=260

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random; import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Achievement;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -31,6 +32,10 @@ public class Command_cake extends TFM_Command
{ {
ItemStack heldItem = new ItemStack(Material.CAKE, 1); ItemStack heldItem = new ItemStack(Material.CAKE, 1);
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem); p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
p.awardAchievement(Achievement.MINE_WOOD);
p.awardAchievement(Achievement.BUILD_WORKBENCH);
p.awardAchievement(Achievement.BUILD_HOE);
p.awardAchievement(Achievement.BAKE_CAKE);
} }
TFM_Util.bcastMsg(output.toString()); TFM_Util.bcastMsg(output.toString());

View File

@ -1,9 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -115,19 +113,12 @@ public class Command_lockup extends TFM_Command
playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
{ {
private Random random = new Random();
@Override @Override
public void run() public void run()
{ {
if (p.isOnline()) if (p.isOnline())
{ {
p.openWorkbench(null, true); p.openInventory(p.getInventory());
Location l = p.getLocation().clone();
l.setPitch(random.nextFloat() * 360.0f);
l.setYaw(random.nextFloat() * 360.0f);
p.teleport(l);
} }
else else
{ {

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*; import me.StevenLawson.TotalFreedomMod.*;
import net.minecraft.server.v1_6_R1.MinecraftServer;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -756,19 +757,29 @@ public class TFM_PlayerListener implements Listener
TFM_ServerInterface.handlePlayerLogin(event); TFM_ServerInterface.handlePlayerLogin(event);
} }
@EventHandler() @EventHandler(priority = EventPriority.HIGHEST)
public void onServerPing(ServerListPingEvent event) public void onServerPing(ServerListPingEvent event)
{ {
// Colorize :) //event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY
+ "-" + TFM_Util.randomChatColor() + " Bukkit v" + String.valueOf(MinecraftServer.getServer().getVersion()));
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress())) if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
{ {
event.setMotd(ChatColor.RED + "You are banned!"); event.setMotd(ChatColor.RED + "You are banned.");
} }
if (TotalFreedomMod.adminOnlyMode) else if (TotalFreedomMod.adminOnlyMode)
{ {
event.setMotd(ChatColor.RED + "Server in AdminMode!"); event.setMotd(ChatColor.RED + "Server is closed.");
}
else if (Bukkit.hasWhitelist())
{
event.setMotd(ChatColor.RED + "Whitelist enabled.");
}
else if (Bukkit.getOnlinePlayers().length >= Bukkit.getMaxPlayers())
{
event.setMotd(ChatColor.RED + "Server is full.");
} }
} }
} }

View File

@ -1035,4 +1035,23 @@ public class TFM_Util
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null)); while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
return null; return null;
} }
public static final List<ChatColor> COLOR_POOL = Arrays.asList(
ChatColor.DARK_BLUE,
ChatColor.DARK_GREEN,
ChatColor.DARK_AQUA,
ChatColor.DARK_RED,
ChatColor.DARK_PURPLE,
ChatColor.GOLD,
ChatColor.BLUE,
ChatColor.GREEN,
ChatColor.AQUA,
ChatColor.RED,
ChatColor.LIGHT_PURPLE,
ChatColor.YELLOW);
private static final Random RANDOM = new Random();
public static ChatColor randomChatColor()
{
return COLOR_POOL.get(RANDOM.nextInt(COLOR_POOL.size()));
}
} }