mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Merge branch 'master' of github.com:nossr50/vminecraft-plugin
This commit is contained in:
commit
15b92cde5c
@ -67,8 +67,16 @@ public class vminecraftChat {
|
|||||||
return tempout;
|
return tempout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: msgLength
|
||||||
|
//Input: String str: The string to find the length of
|
||||||
|
//Output: int: The length on the screen of a string
|
||||||
|
//Use: Finds the length on the screen of a string. Ignores colors.
|
||||||
|
//=====================================================================
|
||||||
private static int msgLength(String str){
|
private static int msgLength(String str){
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
//Loop through all the characters, skipping any color characters
|
||||||
|
//and their following color codes
|
||||||
for(int x = 0; x<str.length(); x++)
|
for(int x = 0; x<str.length(); x++)
|
||||||
{
|
{
|
||||||
if(str.charAt(x) == '§')
|
if(str.charAt(x) == '§')
|
||||||
@ -90,8 +98,13 @@ public class vminecraftChat {
|
|||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: rainbow
|
||||||
|
//Input: String msg: The string to colorify
|
||||||
|
//Output: String: The rainbowed result
|
||||||
|
//Use: Rainbowifies a string;
|
||||||
|
//=====================================================================
|
||||||
public static String rainbow(String msg){
|
public static String rainbow(String msg){
|
||||||
String temp = "";
|
String temp = "";
|
||||||
//The array of colors to use
|
//The array of colors to use
|
||||||
@ -110,12 +123,12 @@ public class vminecraftChat {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: nameColor
|
//Function: getName
|
||||||
//Input: Player player: The player to get name as color
|
//Input: Player player: The player to get name as color
|
||||||
//Output: String: The name colored
|
//Output: String: The name colored
|
||||||
//Use: Returns the colored name;
|
//Use: Returns the colored name;
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static String nameColor(Player player){
|
public static String getName(Player player){
|
||||||
|
|
||||||
//Get the prefix
|
//Get the prefix
|
||||||
String[] playerPrefix = new String[]{player.getPrefix()};
|
String[] playerPrefix = new String[]{player.getPrefix()};
|
||||||
@ -231,7 +244,7 @@ public class vminecraftChat {
|
|||||||
if(player.isAdmin() || player.canUseCommand("/adminchat"))
|
if(player.isAdmin() || player.canUseCommand("/adminchat"))
|
||||||
{
|
{
|
||||||
//Special formatting for adminchat {Username}
|
//Special formatting for adminchat {Username}
|
||||||
String adminchat = Colors.DarkPurple + "{" + nameColor(player)
|
String adminchat = Colors.DarkPurple + "{" + getName(player)
|
||||||
+ Colors.DarkPurple +"}" + Colors.White + " ";
|
+ Colors.DarkPurple +"}" + Colors.White + " ";
|
||||||
|
|
||||||
String[] msg = wordWrap(adminchat + message.substring(1, message.length()));
|
String[] msg = wordWrap(adminchat + message.substring(1, message.length()));
|
||||||
@ -253,7 +266,7 @@ public class vminecraftChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//So you can read adminchat from the server console
|
//So you can read adminchat from the server console
|
||||||
log.log(Level.INFO, "@" + "<" + nameColor(player)
|
log.log(Level.INFO, "@" + "<" + getName(player)
|
||||||
+ Colors.White +"> " + message);
|
+ Colors.White +"> " + message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -270,7 +283,7 @@ public class vminecraftChat {
|
|||||||
public static boolean quote(Player player, String message)
|
public static boolean quote(Player player, String message)
|
||||||
{
|
{
|
||||||
//Format the name
|
//Format the name
|
||||||
String playerName = Colors.White + "<" + nameColor(player)
|
String playerName = Colors.White + "<" + getName(player)
|
||||||
+ Colors.White + "> ";
|
+ Colors.White + "> ";
|
||||||
if(vminecraftSettings.getInstance().greentext()) {
|
if(vminecraftSettings.getInstance().greentext()) {
|
||||||
//Log the chat
|
//Log the chat
|
||||||
@ -298,7 +311,7 @@ public class vminecraftChat {
|
|||||||
{
|
{
|
||||||
//Format the name
|
//Format the name
|
||||||
String playerName = Colors.White + "<"
|
String playerName = Colors.White + "<"
|
||||||
+ nameColor(player) + Colors.White +"> ";
|
+ getName(player) + Colors.White +"> ";
|
||||||
if (vminecraftSettings.getInstance().FFF()) {
|
if (vminecraftSettings.getInstance().FFF()) {
|
||||||
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
|
|
||||||
@ -324,7 +337,7 @@ public class vminecraftChat {
|
|||||||
{
|
{
|
||||||
//Format the name
|
//Format the name
|
||||||
String playerName = Colors.White + "<"
|
String playerName = Colors.White + "<"
|
||||||
+ nameColor(player) + Colors.White +"> ";
|
+ getName(player) + Colors.White +"> ";
|
||||||
if(vminecraftSettings.getInstance().quakeColors()) {
|
if(vminecraftSettings.getInstance().quakeColors()) {
|
||||||
|
|
||||||
//Log the chat
|
//Log the chat
|
||||||
|
@ -48,44 +48,60 @@ public class vminecraftCommands{
|
|||||||
cl.registerAlias("/wrists", "/suicide");
|
cl.registerAlias("/wrists", "/suicide");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Heal
|
//=====================================================================
|
||||||
|
//Function: heal (/heal)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The arguments for the command. Should be a
|
||||||
|
// player name or blank
|
||||||
|
//Output: int: Exit Code
|
||||||
|
//Use: Heals yourself or a specified player.
|
||||||
|
//=====================================================================
|
||||||
public static int heal(Player player, String[] args)
|
public static int heal(Player player, String[] args)
|
||||||
{
|
{
|
||||||
if(vminecraftSettings.getInstance().cmdHeal())
|
if(vminecraftSettings.getInstance().cmdHeal())
|
||||||
{
|
{
|
||||||
if (args[1] == null){
|
//If a target wasn't specified, heal the user.
|
||||||
if (player.getHealth() < 20){
|
if (args == null){
|
||||||
vminecraftChat.gmsg("Your health is restored");
|
if (player.getHealth() < 20){
|
||||||
return EXIT_SUCCESS;
|
vminecraftChat.gmsg("Your health is restored");
|
||||||
}
|
}
|
||||||
else if (args[1] != null){
|
//If a target was specified, try to find them and then heal them
|
||||||
Player playerTarget = etc.getServer().matchPlayer(args[1]);
|
//Otherwise report the error
|
||||||
if (playerTarget != null){
|
} else if (args != null){
|
||||||
playerTarget.setHealth(20);
|
Player playerTarget = etc.getServer().matchPlayer(args[0]);
|
||||||
vminecraftChat.gmsg(Colors.Blue + "You have healed " + playerTarget.getColor() + playerTarget.getName());
|
|
||||||
vminecraftChat.gmsg(Colors.Blue + "You have been healed by " + player.getColor() + player.getName());
|
if (playerTarget != null){
|
||||||
return EXIT_SUCCESS;
|
playerTarget.setHealth(20);
|
||||||
}
|
player.sendMessage(Colors.Blue + "You have healed " + vminecraftChat.getName(playerTarget));
|
||||||
else if (playerTarget == null){
|
playerTarget.sendMessage(Colors.Blue + "You have been healed by " + vminecraftChat.getName(player));
|
||||||
vminecraftChat.gmsg(Colors.Rose + "Couldn't find that player");
|
}
|
||||||
return EXIT_FAIL;
|
else if (playerTarget == null){
|
||||||
}
|
vminecraftChat.gmsg(Colors.Rose + "Couldn't find that player");
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return EXIT_FAIL;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
//Suicide
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: suicide (/suicide, /wrists)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Ignored
|
||||||
|
//Output: int: Exit Code
|
||||||
|
//Use: Kills yourself
|
||||||
|
//=====================================================================
|
||||||
public static int suicide(Player player, String[] args)
|
public static int suicide(Player player, String[] args)
|
||||||
{
|
{
|
||||||
if(vminecraftSettings.getInstance().cmdSuicide())
|
if(vminecraftSettings.getInstance().cmdSuicide())
|
||||||
{
|
{
|
||||||
|
//Set your health to 0. Not much to it.
|
||||||
player.setHealth(0);
|
player.setHealth(0);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return EXIT_FAIL;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: teleport (/tp)
|
//Function: teleport (/tp)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
@ -247,7 +263,7 @@ public class vminecraftCommands{
|
|||||||
|
|
||||||
//Format the name
|
//Format the name
|
||||||
String playerName = Colors.White + "<"
|
String playerName = Colors.White + "<"
|
||||||
+ vminecraftChat.nameColor(player) + Colors.White +"> ";
|
+ vminecraftChat.getName(player) + Colors.White +"> ";
|
||||||
//Make sure a message has been specified
|
//Make sure a message has been specified
|
||||||
if (args.length < 1) {return EXIT_FAIL;}
|
if (args.length < 1) {return EXIT_FAIL;}
|
||||||
String str = " ";
|
String str = " ";
|
||||||
@ -306,7 +322,7 @@ public class vminecraftCommands{
|
|||||||
|
|
||||||
//Displaying the information
|
//Displaying the information
|
||||||
player.sendMessage(Colors.Blue + "Whois results for " +
|
player.sendMessage(Colors.Blue + "Whois results for " +
|
||||||
vminecraftChat.nameColor(playerTarget));
|
vminecraftChat.getName(playerTarget));
|
||||||
//Group
|
//Group
|
||||||
for(String group: playerTarget.getGroups())
|
for(String group: playerTarget.getGroups())
|
||||||
player.sendMessage(Colors.Blue + "Groups: " + group);
|
player.sendMessage(Colors.Blue + "Groups: " + group);
|
||||||
@ -347,9 +363,9 @@ public class vminecraftCommands{
|
|||||||
{
|
{
|
||||||
if(p != null){
|
if(p != null){
|
||||||
if(count == 0)
|
if(count == 0)
|
||||||
tempList += vminecraftChat.nameColor(p);
|
tempList += vminecraftChat.getName(p);
|
||||||
else
|
else
|
||||||
tempList += Colors.White + ", " + vminecraftChat.nameColor(p);
|
tempList += Colors.White + ", " + vminecraftChat.getName(p);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,9 +429,9 @@ public class vminecraftCommands{
|
|||||||
//If the player isn't invulnerable kill them
|
//If the player isn't invulnerable kill them
|
||||||
if (!vminecraftSettings.getInstance().isEzModo(playerTarget.getName())) {
|
if (!vminecraftSettings.getInstance().isEzModo(playerTarget.getName())) {
|
||||||
playerTarget.setHealth(0);
|
playerTarget.setHealth(0);
|
||||||
vminecraftChat.gmsg(vminecraftChat.nameColor(player)
|
vminecraftChat.gmsg(vminecraftChat.getName(player)
|
||||||
+ Colors.LightBlue + " has slain "
|
+ Colors.LightBlue + " has slain "
|
||||||
+ vminecraftChat.nameColor(playerTarget));
|
+ vminecraftChat.getName(playerTarget));
|
||||||
//Otherwise output error to the user
|
//Otherwise output error to the user
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
|
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
|
||||||
|
Loading…
Reference in New Issue
Block a user