Merge branch 'master' of github.com:nossr50/vminecraft-plugin

This commit is contained in:
nossr50 2010-12-09 18:51:59 -08:00
commit f719efd2ae
3 changed files with 618 additions and 448 deletions

View File

@ -19,11 +19,13 @@ public class vMinecraftChat {
//=====================================================================
public static void gmsg(Player sender, String msg){
for (Player receiver : etc.getServer().getPlayerList()) {
if (receiver != null) {
if(vMinecraftUsers.players.findProfile(receiver) == null)
if (receiver == null) {return;}
if(vMinecraftUsers.getProfile(receiver) == null)
return;
//Check if the person has the sender ignored
if(!vMinecraftUsers.players.findProfile(receiver).isIgnored(sender))
if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
{
String[] message = applyColors(wordWrap(msg));
for(String out : message)
@ -31,7 +33,6 @@ public class vMinecraftChat {
}
}
}
}
//=====================================================================
//Function: sendMessage
@ -41,17 +42,17 @@ public class vMinecraftChat {
//=====================================================================
public static void sendMessage(Player sender, Player receiver, String msg){
//Check if the receiver has the sender ignored
if(vMinecraftUsers.players.findProfile(receiver) == null)
if(vMinecraftUsers.getProfile(receiver) == null)
return;
if(!vMinecraftUsers.players.findProfile(receiver).isIgnored(sender))
if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
{
String[] message = applyColors(wordWrap(msg));
for(String out : message)
receiver.sendMessage(out);
//Tell them if they are
} else
sendMessage(sender, sender, Colors.Rose + receiver.getName() + " has you " +
"on their ignore list.");
sendMessage(sender, sender, Colors.Rose + receiver.getName()
+ " has you on their ignore list.");
}
//=====================================================================
@ -211,18 +212,24 @@ public class vMinecraftChat {
//=====================================================================
public static String getName(Player player){
//Get the prefix
String playerPrefix = player.getPrefix();
//Add the nickname or the name if there is none
String output = vMinecraftUsers.getProfile(player).getNick();
//Add the name
String output = player.getName();
if(output.isEmpty())
output = player.getName();
//Add the color if there is one
if(player.getColor() != null && player.getColor() != "")
output = player.getColor().substring(0,2) + output;
//Add the prefix if there is one
if(playerPrefix != null && !playerPrefix.isEmpty())
output = applyColors(playerPrefix.substring(1)) + output;
//Add the tag if there is one
output = vMinecraftUsers.getProfile(player).getTag() + output;
//Add the suffix if there is one
output += vMinecraftUsers.getProfile(player).getSuffix();
/*if(playerPrefix != null && !playerPrefix.isEmpty())
output = applyColors(playerPrefix.substring(1)) + output;*/
//Return the name
return output;

View File

@ -30,36 +30,46 @@ public class vMinecraftCommands{
public static void loadCommands(){
//If we had commands we would add them here.
//register
//register: Registers a function for use with a command
//String: The command that will be used
//String: The name of the function that will be called when
// the command is used
//String(Optional): The help menu description
cl.register("/tp", "teleport");
//Administrative
cl.register("/prefix", "prefix");
cl.register("/vminecraft", "vminecrafthelp");
cl.register("/colors", "colors");
cl.register("/masstp", "masstp", "Teleports those with lower permissions to you");
cl.register("/reload", "reload");
cl.register("/rules", "rules", "Displays the rules");
cl.register("/fabulous", "fabulous", "makes text SUUUPER");
cl.register("/whois", "whois", "/whois [user]");
cl.register("/who", "who");
cl.register("/say", "say");
cl.register("/slay", "slay", "Kill target player");
cl.register("/a", "adminChatToggle", "Toggle admin chat for every message");
cl.register("/modify", "modify");
cl.register("/rules", "rules", "Displays the rules");
cl.register("/who", "who");
//Movement
cl.register("/tp", "teleport");
cl.register("/tphere", "tphere");
cl.register("/masstp", "masstp", "Teleports those with lower permissions to you");
//Health
cl.register("/ezmodo", "invuln", "Toggle invulnerability");
cl.register("/ezlist", "ezlist", "List invulnerable players");
cl.register("/heal", "heal", "heal yourself or other players");
cl.register("/suicide", "suicide", "Kill yourself... you loser");
cl.register("/a", "adminChatToggle", "Toggle admin chat for every message");
cl.register("/modify", "modifySplit");
cl.register("/slay", "slay", "Kill target player");
//Social
cl.register("/colors", "colors");
cl.register("/me", "me");
cl.register("/fabulous", "fabulous", "makes text SUUUPER");
cl.register("/msg", "message", "Send a message to a player /msg [Player] [Message]");
cl.register("/reply", "reply", "Reply to a player /reply [Message], Alias: /r");
cl.register("/ignore", "addIgnored", "Adds a user to your ignore list");
cl.register("/unignore", "removeIgnored", "Removes a user from your ignore list");
cl.register("/ignorelist", "ignoreList", "Lists the players you have ignored");
//registerAlias
//registerAlias: Runs the second command when the first command is called
//String: The command that this will be called by
//String: The message that will be called when the first is entered
// Can be modified with %# to have it insert a player
@ -78,7 +88,7 @@ public class vMinecraftCommands{
cl.registerAlias("/kill", "/suicide");
cl.registerAlias("/ci", "/clearinventory");
//registerMessage
//registerMessage: Displays a message whenever a command is used
//String: The command it will run on
//String: What will be displayed
// %p is the player calling the command
@ -102,28 +112,65 @@ public class vMinecraftCommands{
// and provides some useful tips.
//=====================================================================
public static int vminecrafthelp(Player player, String[] args){
vMinecraftChat.sendMessage(player, player, Colors.Yellow + "Chat Settings");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Admin Chat: " + vMinecraftSettings.getInstance().adminchat());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "FFF turns red: " + vMinecraftSettings.getInstance().FFF());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Greentext After >: " + vMinecraftSettings.getInstance().greentext());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Quake Color Script: " + vMinecraftSettings.getInstance().quakeColors());
vMinecraftChat.sendMessage(player, player, Colors.Yellow + "Enabled Commands are TRUE, disabled are FALSE");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /ezmodo: " + vMinecraftSettings.getInstance().cmdEzModo());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /fabulous: " + vMinecraftSettings.getInstance().cmdFabulous());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /rules: " + vMinecraftSettings.getInstance().cmdRules());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /heal: " + vMinecraftSettings.getInstance().cmdHeal());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /masstp: " + vMinecraftSettings.getInstance().cmdMasstp());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /say: " + vMinecraftSettings.getInstance().cmdSay());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /suicide: " + vMinecraftSettings.getInstance().cmdSuicide());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /whois: " + vMinecraftSettings.getInstance().cmdWhoIs());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /tp won't work on higher ranked players: " + vMinecraftSettings.getInstance().cmdTp());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /tphere won't work on higher ranked players: " + vMinecraftSettings.getInstance().cmdTphere());
vMinecraftChat.sendMessage(player, player, Colors.Yellow + "Other Settings");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /who: " + vMinecraftSettings.getInstance().cmdWho());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "COLORED PLAYER LIST IS DEPENDENT ON /who BEING TRUE!");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Global Messages: " + vMinecraftSettings.getInstance().globalmessages());
vMinecraftChat.sendMessage(player, player, Colors.Yellow
+ "Chat Settings");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Admin Chat: " + vMinecraftSettings.getInstance()
.adminchat());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "FFF turns red: " + vMinecraftSettings.getInstance()
.FFF());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Greentext After >: " + vMinecraftSettings.getInstance()
.greentext());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Quake Color Script: " + vMinecraftSettings.getInstance()
.quakeColors());
vMinecraftChat.sendMessage(player, player, Colors.Yellow
+ "Enabled Commands are TRUE, disabled are FALSE");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /ezmodo: " + vMinecraftSettings.getInstance()
.cmdEzModo());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /fabulous: " + vMinecraftSettings.getInstance()
.cmdFabulous());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /rules: " + vMinecraftSettings.getInstance()
.cmdRules());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /heal: " + vMinecraftSettings.getInstance()
.cmdHeal());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /masstp: " + vMinecraftSettings.getInstance()
.cmdMasstp());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /say: " + vMinecraftSettings.getInstance()
.cmdSay());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /suicide: " + vMinecraftSettings.getInstance()
.cmdSuicide());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /whois: " + vMinecraftSettings.getInstance()
.cmdWhoIs());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /tp won't work on higher ranked players: "
+ vMinecraftSettings.getInstance().cmdTp());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /tphere won't work on higher ranked players: "
+ vMinecraftSettings.getInstance().cmdTphere());
vMinecraftChat.sendMessage(player, player, Colors.Yellow
+ "Other Settings");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Command /who: " + vMinecraftSettings.getInstance()
.cmdWho());
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "COLORED PLAYER LIST IS DEPENDENT ON /who BEING TRUE!");
vMinecraftChat.sendMessage(player, player, Colors.DarkPurple
+ "Global Messages: " + vMinecraftSettings.getInstance()
.globalmessages());
return EXIT_SUCCESS;
}
//=====================================================================
//Function: prefix (/prefix)
//Input: Player player: The player using the command
@ -187,7 +234,7 @@ public class vMinecraftCommands{
public static int me(Player player, String[] args)
{
String str = etc.combineSplit(0, args, " ");
if (args.length < 1) {return EXIT_FAIL;}
if (args.length < 1) return EXIT_FAIL;
vMinecraftChat.emote(player, str);
return EXIT_SUCCESS;
}
@ -202,10 +249,23 @@ public class vMinecraftCommands{
//=====================================================================
public static int message(Player player, String[] args)
{
//Make sure a player is specified
if (args.length > 1) {
String msg = etc.combineSplit(1, args, " ");
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "Usage is /msg [player] [message]");
return EXIT_SUCCESS;
}
//Make sure the player exists
Player toPlayer = etc.getServer().matchPlayer(args[0]);
if (toPlayer != null && args.length > 0) {
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "No player by the name of " + args[0] + " could be found.");
return EXIT_SUCCESS;
}
String msg = etc.combineSplit(1, args, " ");
//Send the message to the targeted player and the sender
vMinecraftChat.sendMessage(player, toPlayer,
Colors.LightGreen + "[From:" + vMinecraftChat.getName(player)
@ -214,20 +274,12 @@ public class vMinecraftCommands{
Colors.LightGreen + "[To:" + vMinecraftChat.getName(toPlayer)
+ Colors.LightGreen + "] " + msg);
//Set the last massager for each player
vMinecraftUsers.players.findProfile(player).setMessage(toPlayer);
vMinecraftUsers.players.findProfile(toPlayer).setMessage(player);
vMinecraftUsers.getProfile(player).setMessage(toPlayer);
vMinecraftUsers.getProfile(toPlayer).setMessage(player);
//Display the message to the log
log.log(Level.INFO, player.getName() + " whispered to " + toPlayer.getName()
+ ": " + msg);
} else {
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "No player by the name of " + args[0] + " could be found.");
}
} else {
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "Usage is /msg [player] [message]");
}
return EXIT_SUCCESS;
}
@ -241,10 +293,27 @@ public class vMinecraftCommands{
public static int reply(Player player, String[] args)
{
//If the profile exists for the player
if(vMinecraftUsers.players.findProfile(player) != null )
{
Player toPlayer = vMinecraftUsers.players.findProfile(player).getMessage();
if (toPlayer != null && args.length > 0) {
if(vMinecraftUsers.getProfile(player) == null ) {
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "The person you last message has logged off");
return EXIT_SUCCESS;
}
//Make sure a message is specified
if (args.length < 1) {
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "Usage is /reply [Message]");
return EXIT_SUCCESS;
}
//Make sure the player they're talking to is online
Player toPlayer = vMinecraftUsers.getProfile(player).getMessage();
if (toPlayer == null) {
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "The person you last message has logged off");
return EXIT_SUCCESS;
}
String msg = etc.combineSplit(0, args, " ");
//Send the message to the targeted player and the sender
@ -256,17 +325,12 @@ public class vMinecraftCommands{
+ Colors.LightGreen + "] " + msg);
//Set the last messager for each player
vMinecraftUsers.players.findProfile(player).setMessage(toPlayer);
vMinecraftUsers.players.findProfile(toPlayer).setMessage(player);
vMinecraftUsers.getProfile(player).setMessage(toPlayer);
vMinecraftUsers.getProfile(toPlayer).setMessage(player);
//Display the message to the log
log.log(Level.INFO, player.getName() + " whispered to " + toPlayer.getName()
+ ": " + msg);
} else {
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "The person you last message has logged off");
}
}
return EXIT_SUCCESS;
}
@ -280,35 +344,39 @@ public class vMinecraftCommands{
public static int addIgnored(Player player, String[] args)
{
//Make sure the player gave you a user to ignore
if(args.length > 0)
if(args.length < 1)
{
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "Usage: /ignore [Player]");
return EXIT_SUCCESS;
}
//Find the player and make sure they exist
Player ignore = etc.getServer().matchPlayer(args[0]);
if(ignore != null)
if(ignore == null)
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The person you tried to ignore is not logged in.");
return EXIT_SUCCESS;
}
//Don't let the player ignore themselves
if(!ignore.getName().equalsIgnoreCase(player.getName()))
{
//Attempt to ignore the player and report accordingly
if(vMinecraftUsers.players.findProfile(player).addIgnore(ignore))
vMinecraftChat.sendMessage(player, player,
Colors.Rose + ignore.getName()+ " has been successfuly " +
"ignored.");
else
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "You are already ignoring " + ignore.getName());
} else
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "You cannot ignore yourself");
return EXIT_SUCCESS;
}
else
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "The person you tried to ignore is not logged in.");
}
//Attempt to ignore the player and report accordingly
if(vMinecraftUsers.getProfile(player).addIgnore(ignore))
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ ignore.getName() + " has been successfuly ignored.");
else
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "Usage: /ignore [Player]");
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "You are already ignoring " + ignore.getName());
return EXIT_SUCCESS;
}
@ -322,28 +390,67 @@ public class vMinecraftCommands{
public static int removeIgnored(Player player, String[] args)
{
//Make sure the player gave you a user to ignore
if(args.length > 0)
if(args.length < 1)
{
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "Usage: /unignore [Player]");
return EXIT_SUCCESS;
}
//Find the player and make sure they exist
Player ignore = etc.getServer().matchPlayer(args[0]);
if(ignore != null)
if(ignore == null)
{
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "The person you tried to unignore is not logged in.");
return EXIT_SUCCESS;
}
//Attempt to ignore the player and report accordingly
if(vMinecraftUsers.players.findProfile(player).removeIgnore(ignore))
if(vMinecraftUsers.getProfile(player).removeIgnore(ignore))
vMinecraftChat.sendMessage(player, player,
Colors.Rose + ignore.getName()+ " has been successfuly " +
"unignored.");
else
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "You are not currently ignoring " + ignore.getName());
return EXIT_SUCCESS;
}
else
//=====================================================================
//Function: ignoreList (/ignorelist)
//Input: Player player: The player using the command
// String[] args: Ignored
//Output: int: Exit Code
//Use: Lists the player you have ignored
//=====================================================================
public static int ignoreList(Player player, String[] args)
{
//Get the ignore list
String[] list = vMinecraftUsers.getProfile(player).listIgnore();
//Find the last page number
int lastPage = (int)list.length / 5;
if((int)list.length % 5 > 0)
lastPage++;
//Find the page number the player wants displayed
int page = 0;
if(args.length > 0 && Integer.valueOf(args[0]) > 0
&& Integer.valueOf(args[0]) <= lastPage)
page = Integer.valueOf(args[0]) - 1;
//Display the header
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "The person you tried to unignore is not logged in.");
}
else
Colors.Rose + "Ignore List [" + page + "/"
+ lastPage + "]");
//Display up to 5 people
for(int i = 0; i < 5 && i + (page * 5) < list.length; i++)
vMinecraftChat.sendMessage(player, player,
Colors.Rose + "Usage: /unignore [Player]");
Colors.Rose + list[i+ (page * 5)]);
return EXIT_SUCCESS;
}
@ -358,11 +465,10 @@ public class vMinecraftCommands{
public static int adminChatToggle(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/a")) {
return EXIT_FAIL;
}
if(vMinecraftSettings.getInstance().adminChatToggle())
{
if(!player.canUseCommand("/a")) return EXIT_FAIL;
if(!vMinecraftSettings.getInstance().adminChatToggle()) return EXIT_FAIL;
//If the player is already toggled for admin chat, remove them
if (vMinecraftSettings.getInstance().isAdminToggled(player.getName())) {
player.sendMessage(Colors.Red + "Admin Chat Toggle = off");
@ -374,8 +480,6 @@ public class vMinecraftCommands{
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: heal (/heal)
//Input: Player player: The player using the command
@ -387,32 +491,33 @@ public class vMinecraftCommands{
public static int heal(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/heal")) {
return EXIT_FAIL;
}
if(vMinecraftSettings.getInstance().cmdHeal())
{
if(!player.canUseCommand("/heal")) return EXIT_FAIL;
if(!vMinecraftSettings.getInstance().cmdHeal()) return EXIT_FAIL;
//If a target wasn't specified, heal the user.
if (args.length < 1){
player.setHealth(20);
player.sendMessage("Your health is restored");
//If a target was specified, try to find them and then heal them
//Otherwise report the error
} else if (args.length > 0){
Player playerTarget = etc.getServer().matchPlayer(args[0]);
if (playerTarget != null){
playerTarget.setHealth(20);
player.sendMessage(Colors.Blue + "You have healed " + vMinecraftChat.getName(playerTarget));
playerTarget.sendMessage(Colors.Blue + "You have been healed by " + vMinecraftChat.getName(player));
}
else if (playerTarget == null){
player.sendMessage(Colors.Rose + "Couldn't find that player");
}
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
//If a target was specified, try to find them and then heal them
//Otherwise report the error
Player playerTarget = etc.getServer().matchPlayer(args[0]);
if (playerTarget == null){
player.sendMessage(Colors.Rose
+ "Couldn't find that player");
return EXIT_SUCCESS;
}
playerTarget.setHealth(20);
player.sendMessage(Colors.Blue + "You have healed "
+ vMinecraftChat.getName(playerTarget));
playerTarget.sendMessage(Colors.Blue
+ "You have been healed by "
+ vMinecraftChat.getName(player));
return EXIT_SUCCESS;
}
//=====================================================================
@ -425,17 +530,14 @@ public class vMinecraftCommands{
public static int suicide(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/suicide")) {
return EXIT_FAIL;
}
if(vMinecraftSettings.getInstance().cmdSuicide())
{
if(!player.canUseCommand("/suicide")) return EXIT_FAIL;
if(vMinecraftSettings.getInstance().cmdSuicide()) return EXIT_FAIL;
//Set your health to 0. Not much to it.
player.setHealth(0);
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: teleport (/tp)
@ -448,16 +550,15 @@ public class vMinecraftCommands{
public static int teleport(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/tp")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/tp")) return EXIT_FAIL;
//Get if the command is enabled
if(vMinecraftSettings.getInstance().cmdTp())
{
if(!vMinecraftSettings.getInstance().cmdTp())return EXIT_FAIL;
//Make sure a player has been specified and return an error if not
if (args.length < 1) {
player.sendMessage(Colors.Rose + "Correct usage is: /tp [player]");
} else {
return EXIT_SUCCESS;
}
//Find the player by name
Player playerTarget = etc.getServer().matchPlayer(args[0]);
@ -481,13 +582,9 @@ public class vMinecraftCommands{
playerTarget.getName());
player.teleportTo(playerTarget);
//Otherwise inform the user that the player doesn't exist
}
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: masstp (/masstp)
@ -499,11 +596,11 @@ public class vMinecraftCommands{
public static int masstp(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/masstp")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/masstp")) return EXIT_FAIL;
//If the command is enabled
if(vMinecraftSettings.getInstance().cmdMasstp()) {
if(!vMinecraftSettings.getInstance().cmdMasstp())return EXIT_FAIL;
//Go through all players and move them to the user
for (Player p : etc.getServer().getPlayerList()) {
if (!p.hasControlOver(player)) {
@ -515,8 +612,6 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: tphere (/tphere)
@ -529,37 +624,41 @@ public class vMinecraftCommands{
public static int tphere(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/tphere")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/tphere")) return EXIT_FAIL;
//Check if the command is enabled.
if (vMinecraftSettings.getInstance().cmdTphere()) {
if (!vMinecraftSettings.getInstance().cmdTphere())return EXIT_FAIL;
//Make sure a player is specified
if (args.length < 1) {
player.sendMessage(Colors.Rose + "Correct usage is: /tphere [player]");
} else {
player.sendMessage(Colors.Rose + "Correct usage" +
" is: /tphere [player]");
return EXIT_SUCCESS;
}
//Get the player by name
Player playerTarget = etc.getServer().matchPlayer(args[0]);
//If the target doesn't exist
if(playerTarget == null)
player.sendMessage(Colors.Rose + "Can't find user " + args[0] + ".");
player.sendMessage(Colors.Rose + "Can't find user "
+ args[0] + ".");
//If the player has a higher rank than the user, return error
else if (!player.hasControlOver(playerTarget))
player.sendMessage(Colors.Red + "That player has higher permissions than you.");
player.sendMessage(Colors.Red + "That player has higher" +
" permissions than you.");
//If the user teleports themselves, mock them
else if (player.getName().equalsIgnoreCase(args[0]))
player.sendMessage(Colors.Rose + "Wow look at that! You teleported yourself to yourself!");
player.sendMessage(Colors.Rose + "Wow look at that! You" +
" teleported yourself to yourself!");
//If the target exists, teleport them to the user
else {
log.log(Level.INFO, player.getName() + " teleported " + player.getName() + " to their self.");
log.log(Level.INFO, player.getName() + " teleported "
+ player.getName() + " to their self.");
playerTarget.teleportTo(player);
}
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: reload (/reload)
@ -571,11 +670,10 @@ public class vMinecraftCommands{
public static int reload(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/reload")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/reload")) return EXIT_FAIL;
vMinecraftSettings.getInstance().loadSettings();
return EXIT_FAIL;
return EXIT_SUCCESS;
}
//=====================================================================
@ -588,8 +686,11 @@ public class vMinecraftCommands{
public static int rules(Player player, String[] args)
{
//If the rules exist
if(vMinecraftSettings.getInstance().cmdRules()
&& vMinecraftSettings.getInstance().getRules().length > 0) {
if(!vMinecraftSettings.getInstance().cmdRules()
&& vMinecraftSettings.getInstance().getRules().length > 0
&& !vMinecraftSettings.getInstance().getRules()[0].isEmpty()) {
return EXIT_FAIL;
}
//Apply QuakeCode Colors to the rules
String[] rules = vMinecraftChat.applyColors(
@ -599,12 +700,11 @@ public class vMinecraftCommands{
if(!str.isEmpty())
player.sendMessage(Colors.Blue + str);
else
player.sendMessage(Colors.Blue + "!!!The Rules Have Not Been Set!!!");
player.sendMessage(Colors.Blue
+ "!!!The Rules Have Not Been Set!!!");
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: fabulous (/fabulous)
@ -616,17 +716,20 @@ public class vMinecraftCommands{
public static int fabulous(Player player, String[] args)
{
//If the command is enabled
if(vMinecraftSettings.getInstance().cmdFabulous()) {
if(!vMinecraftSettings.getInstance().cmdFabulous()) return EXIT_FAIL;
//Make sure a message has been specified
if (args.length < 1) {
player.sendMessage(Colors.Rose + "Usage /fabulous [Message]");
return EXIT_SUCCESS;
}
//Format the name
String playerName = Colors.White + "<"
+ vMinecraftChat.getName(player) + Colors.White +"> ";
//Make sure a message has been specified
if (args.length < 1) {return EXIT_FAIL;}
String str = " ";
//Merge the message again
str = etc.combineSplit(0, args, " ");
String str = etc.combineSplit(0, args, " ");
//Output for server
log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\"");
@ -636,8 +739,6 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: whois (/whois)
@ -649,20 +750,26 @@ public class vMinecraftCommands{
public static int whois(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/whois")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/whois")) return EXIT_FAIL;
//If the command is enabled
if (vMinecraftSettings.getInstance().cmdWhoIs()) {
if (!vMinecraftSettings.getInstance().cmdWhoIs()) return EXIT_FAIL;
//If a player is specified
if (args.length < 1)
{
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
else {
return EXIT_SUCCESS;
}
//Get the player by name
Player playerTarget = etc.getServer().matchPlayer(args[0]);
//If the player exists
if (playerTarget != null){
if (playerTarget == null){
player.sendMessage(Colors.Rose+"Player not found.");
return EXIT_SUCCESS;
}
//Displaying the information
player.sendMessage(Colors.Blue + "Whois results for " +
@ -670,6 +777,10 @@ public class vMinecraftCommands{
//Group
for(String group: playerTarget.getGroups())
player.sendMessage(Colors.Blue + "Groups: " + group);
//Only let admins see this info
if(player.isAdmin())
{
//Admin
player.sendMessage(Colors.Blue+"Admin: " +
String.valueOf(playerTarget.isAdmin()));
@ -678,13 +789,6 @@ public class vMinecraftCommands{
//Restrictions
player.sendMessage(Colors.Blue+"Can ignore restrictions: " +
String.valueOf(playerTarget.canIgnoreRestrictions()));
//Give the user an error if the player doesn't exist
} else {
player.sendMessage(Colors.Rose+"Player not found.");
}
}
return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
}
@ -699,7 +803,8 @@ public class vMinecraftCommands{
public static int who(Player player, String[] args)
{
//If the command is enabled
if (vMinecraftSettings.getInstance().cmdWho()) {
if (!vMinecraftSettings.getInstance().cmdWho()) return EXIT_FAIL;
//Loop through all players counting them and adding to the list
int count=0;
String tempList = "";
@ -728,8 +833,6 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: say (/say)
@ -741,21 +844,21 @@ public class vMinecraftCommands{
public static int say(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/say")) {
return EXIT_FAIL;
}
//If the command is enabled
if (vMinecraftSettings.getInstance().cmdSay()) {
if(!player.canUseCommand("/say")) return EXIT_FAIL;
//Check if the command is enabled
if (!vMinecraftSettings.getInstance().cmdSay()) return EXIT_FAIL;
//Make sure a message is supplied or output an error
if (args.length < 1) {
player.sendMessage(Colors.Rose + "Usage is /say [message]");
}
//Display the message globally
vMinecraftChat.gmsg(player, Colors.Yellow + etc.combineSplit(0, args, " "));
vMinecraftChat.gmsg(player, Colors.Yellow
+ etc.combineSplit(0, args, " "));
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: slay (/slay)
@ -767,30 +870,36 @@ public class vMinecraftCommands{
public static int slay(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/slay")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/slay")) return EXIT_FAIL;
//Check if the command is enabled
if(vMinecraftSettings.getInstance().cmdEzModo()) {
if(!vMinecraftSettings.getInstance().cmdEzModo()) return EXIT_FAIL;
//Get the player by name
Player playerTarget = etc.getServer().matchPlayer(args[0]);
//If the player doesn't exist don't run
if(playerTarget == null)
return EXIT_FAIL;
{
player.sendMessage(Colors.Rose + "Usage is /slay [Player]");
return EXIT_SUCCESS;
}
//If the player isn't invulnerable kill them
if (!vMinecraftSettings.getInstance().isEzModo(playerTarget.getName())) {
if (vMinecraftSettings.getInstance()
.isEzModo(playerTarget.getName())) {
player.sendMessage(Colors.Rose + "That player is currently in" +
" ezmodo! Hahahaha");
}
playerTarget.setHealth(0);
vMinecraftChat.gmsg(player, vMinecraftChat.getName(player)
+ Colors.LightBlue + " has slain "
+ vMinecraftChat.getName(playerTarget));
//Otherwise output error to the user
} else {
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: invuln (/ezmodo)
@ -802,27 +911,27 @@ public class vMinecraftCommands{
public static int invuln(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/ezmodo")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/ezmodo")) return EXIT_FAIL;
//If the command is enabled
if (vMinecraftSettings.getInstance().cmdEzModo()) {
if (!vMinecraftSettings.getInstance().cmdEzModo()) return EXIT_FAIL;
//If the player is already invulnerable, turn ezmodo off.
if (vMinecraftSettings.getInstance().isEzModo(player.getName())) {
player.sendMessage(Colors.Red + "ezmodo = off");
vMinecraftSettings.getInstance().removeEzModo(player.getName());
//Otherwise make them invulnerable
} else {
player.sendMessage(Colors.LightBlue + "eh- maji? ezmodo!?");
player.sendMessage(Colors.Rose + "kimo-i");
player.sendMessage(Colors.LightBlue + "Easy Mode ga yurusareru no wa shougakusei made dayo ne");
player.sendMessage(Colors.LightBlue + "Easy Mode ga yurusareru" +
" no wa shougakusei made dayo ne");
player.sendMessage(Colors.Red + "**Laughter**");
vMinecraftSettings.getInstance().addEzModo(player.getName());
}
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: ezlist (/ezlist)
@ -834,31 +943,27 @@ public class vMinecraftCommands{
public static int ezlist(Player player, String[] args)
{
//Make sure the user has access to the command
if(!player.canUseCommand("/ezmodo")) {
return EXIT_FAIL;
}
if(!player.canUseCommand("/ezmodo")) return EXIT_FAIL;
//If the feature is enabled list the players
if(vMinecraftSettings.getInstance().cmdEzModo()) {
if(!vMinecraftSettings.getInstance().cmdEzModo()) return EXIT_FAIL;
player.sendMessage("Ezmodo: " + vMinecraftSettings.getInstance().ezModoList());
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//=====================================================================
//Function: modifySplit (/modify)
//Function: modify (/modify)
//Input: Player player: The player using the command
// String[] args: Player, Command, Arguments
//Output: int: Exit Code
//Use: List all invulnerable players
//=====================================================================
public static int modifySplit(Player player, String[] args)
public static int modify(Player player, String[] args)
{
//Exploit fix for people giving themselves commands
if(args[2].equals("commands")){
return EXIT_FAIL;
}
return EXIT_CONTINUE;
if(player.canUseCommand("/prefix"))
vMinecraftChat.sendMessage(player, player, "/prefix [Color]" +
" (Tag) - Set your prefix and tag.");
return EXIT_SUCCESS;
}
//=====================================================================
@ -1188,8 +1293,7 @@ class commandList {
int call(Player player, String[] arg)
{
//Make sure the player can use the command first
if(!player.canUseCommand(super.commandName))
return EXIT_FAIL;
if(!player.canUseCommand(super.commandName)) return EXIT_FAIL;
//Make sure the command is long enough to fire
if(minArgs < arg.length)

View File

@ -65,10 +65,26 @@ public class vMinecraftUsers {
return false;
}
//=====================================================================
//Function: addUser
//Input: Player player: The player to create a profile for
//Output: none
//Use: Creates the player profile
//=====================================================================
public static void addUser(Player player){
players.addPlayer(player);
}
//=====================================================================
//Function: getProfile
//Input: Player player: The player to find the profile for
//Output: PlayerList.PlayerProfile: The profile
//Use: Gets the player profile
//=====================================================================
public static PlayerList.PlayerProfile getProfile(Player player){
return players.findProfile(player);
}
public static vMinecraftUsers getInstance() {
if (instance == null) {
instance = new vMinecraftUsers();
@ -319,6 +335,17 @@ class PlayerList
return false;
}
//=====================================================================
//Function: removeIgnore
//Input: Player name: The player to unignore
//Output: boolean: If the player was successfully unignored
//Use: Stops ignoring a player.
//=====================================================================
public String[] listIgnore()
{
return ignoreList.toArray(new String[ignoreList.size()]);
}
//=====================================================================
//Function: addAlias
//Input: String command: The command to try to call
@ -370,6 +397,38 @@ class PlayerList
//=====================================================================
public String getTag() { return tag; }
//=====================================================================
//Function: setNick
//Input: String newTag: The nickname to set for the player
//Output: None
//Use: Sets a player nickname
//=====================================================================
public void setNick(String newNick){ nickName = newNick; }
//=====================================================================
//Function: getNick
//Input: None
//Output: String: The player nickname
//Use: Gets a player nickname
//=====================================================================
public String getNick() { return nickName; }
//=====================================================================
//Function: setSuffix
//Input: String newTag: The suffix to set for the player
//Output: None
//Use: Sets a player suffix
//=====================================================================
public void setSuffix(String newSuffix){ suffix = newSuffix; }
//=====================================================================
//Function: getSuffix
//Input: None
//Output: String: The player suffix
//Use: Gets a player suffix
//=====================================================================
public String getSuffix() { return suffix; }
//=====================================================================
//Function: setMessage
//Input: String newName: The name of the player they last messaged