mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Misc Updates
This commit is contained in:
parent
35e4550f81
commit
db8ac45ad5
@ -131,7 +131,7 @@ public class vminecraftChat {
|
|||||||
public static String getName(Player player){
|
public static String getName(Player player){
|
||||||
|
|
||||||
//Get the prefix
|
//Get the prefix
|
||||||
String[] playerPrefix = new String[]{player.getPrefix()};
|
String playerPrefix = player.getPrefix();
|
||||||
|
|
||||||
//Add the name
|
//Add the name
|
||||||
String output = player.getName();
|
String output = player.getName();
|
||||||
@ -140,8 +140,8 @@ public class vminecraftChat {
|
|||||||
if(player.getColor() != null && player.getColor() != "")
|
if(player.getColor() != null && player.getColor() != "")
|
||||||
output = player.getColor().substring(0,2) + output;
|
output = player.getColor().substring(0,2) + output;
|
||||||
//Add the prefix if there is one
|
//Add the prefix if there is one
|
||||||
if(playerPrefix[0] != null && playerPrefix[0] != "")
|
if(playerPrefix != null && playerPrefix != "")
|
||||||
output = applyColors(playerPrefix)[0].substring(3) + output;
|
output = applyColors(playerPrefix).substring(3) + output;
|
||||||
|
|
||||||
//Return the name
|
//Return the name
|
||||||
return output;
|
return output;
|
||||||
@ -365,46 +365,111 @@ public class vminecraftChat {
|
|||||||
//Output: String[]: The lines, but colorful
|
//Output: String[]: The lines, but colorful
|
||||||
//Use: Colors each line
|
//Use: Colors each line
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
private static String[] applyColors(String[] message)
|
public static String[] applyColors(String[] message)
|
||||||
{
|
{
|
||||||
|
if(message != null && message[0] != null && !message[0].equals("")){
|
||||||
|
//The color to start the line with
|
||||||
|
String recentColor = Colors.White;
|
||||||
|
|
||||||
//The color to start the line with
|
//Go through each line
|
||||||
String recentColor = Colors.White;
|
int counter = 0;
|
||||||
|
for(String msg: message)
|
||||||
//Go through each line
|
|
||||||
int counter = 0;
|
|
||||||
for(String msg: message)
|
|
||||||
{
|
|
||||||
//Start the line with the most recent color
|
|
||||||
String temp = recentColor;
|
|
||||||
|
|
||||||
//Loop through looking for a color code
|
|
||||||
for(int x = 0; x< msg.length(); x++)
|
|
||||||
{
|
{
|
||||||
//If the char is a ^
|
//Start the line with the most recent color
|
||||||
if(msg.charAt(x)=='^' && x != msg.length() - 1)
|
String temp = recentColor;
|
||||||
|
|
||||||
|
//Loop through looking for a color code
|
||||||
|
for(int x = 0; x< msg.length(); x++)
|
||||||
{
|
{
|
||||||
//If the following character is a color code
|
//If the char is a ^ or §
|
||||||
if(vminecraftChat.colorChange(msg.charAt(x+1)) != null)
|
if(msg.charAt(x) == '^' || msg.charAt(x) == '§')
|
||||||
{
|
{
|
||||||
//Set the most recent color to the new color
|
if(x != msg.length() - 1)
|
||||||
recentColor = vminecraftChat.colorChange(msg.charAt(x+1));
|
{
|
||||||
//Add the color
|
//If the following character is a color code
|
||||||
temp += recentColor;
|
if(vminecraftChat.colorChange(msg.charAt(x+1)) != null)
|
||||||
//Skip these chars
|
{
|
||||||
x++;
|
//Set the most recent color to the new color
|
||||||
//Otherwise ignore it.
|
recentColor = vminecraftChat.colorChange(msg.charAt(x+1));
|
||||||
|
//Add the color
|
||||||
|
temp += recentColor;
|
||||||
|
//Skip these chars
|
||||||
|
x++;
|
||||||
|
//Otherwise ignore it.
|
||||||
|
} else {
|
||||||
|
temp += msg.charAt(x);
|
||||||
|
}
|
||||||
|
//Insert the character
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
temp += msg.charAt(x);
|
temp += msg.charAt(x);
|
||||||
}
|
}
|
||||||
//Insert the character
|
|
||||||
} else {
|
|
||||||
temp += msg.charAt(x);
|
|
||||||
}
|
}
|
||||||
|
//Replace the message with the colorful message
|
||||||
|
message[counter] = temp;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: applyColors
|
||||||
|
//Input: String message: The line to be colored
|
||||||
|
//Output: String: The line, but colorful
|
||||||
|
//Use: Colors a line
|
||||||
|
//=====================================================================
|
||||||
|
public static String applyColors(String message)
|
||||||
|
{
|
||||||
|
return applyColors(message, Colors.White);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: applyColors
|
||||||
|
//Input: String message: The line to be colored
|
||||||
|
// String color: The color to start the line with
|
||||||
|
//Output: String: The line, but colorful
|
||||||
|
//Use: Colors a line
|
||||||
|
//=====================================================================
|
||||||
|
public static String applyColors(String message, String color)
|
||||||
|
{
|
||||||
|
if(message != null && !message.equals(""))
|
||||||
|
{
|
||||||
|
//The color to start the line with
|
||||||
|
if(color == null)
|
||||||
|
color = Colors.White;
|
||||||
|
|
||||||
|
//Start the line with the most recent color
|
||||||
|
String temp = color;
|
||||||
|
|
||||||
|
//Loop through looking for a color code
|
||||||
|
for(int x = 0; x< message.length(); x++)
|
||||||
|
{
|
||||||
|
//If the char is a ^ or §
|
||||||
|
if(message.charAt(x) == '^' || message.charAt(x) == '§')
|
||||||
|
{
|
||||||
|
if(x != message.length() - 1)
|
||||||
|
{
|
||||||
|
//If the following character is a color code
|
||||||
|
if(vminecraftChat.colorChange(message.charAt(x+1)) != null)
|
||||||
|
{
|
||||||
|
//Set the most recent color to the new color
|
||||||
|
color = vminecraftChat.colorChange(message.charAt(x+1));
|
||||||
|
//Add the color
|
||||||
|
temp += color;
|
||||||
|
//Skip these chars
|
||||||
|
x++;
|
||||||
|
//Otherwise ignore it.
|
||||||
|
} else {
|
||||||
|
temp += message.charAt(x);
|
||||||
|
}
|
||||||
|
//Insert the character
|
||||||
|
} else {
|
||||||
|
temp += message.charAt(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Replace the message with the colorful message
|
|
||||||
message[counter] = temp;
|
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -237,11 +237,17 @@ public class vminecraftCommands{
|
|||||||
{
|
{
|
||||||
//If the rules exist
|
//If the rules exist
|
||||||
if(vminecraftSettings.getInstance().cmdRules()
|
if(vminecraftSettings.getInstance().cmdRules()
|
||||||
&& vminecraftSettings.getInstance().getRules().length != 0) {
|
&& vminecraftSettings.getInstance().getRules().length > 0) {
|
||||||
|
|
||||||
|
//Apply QuakeCode Colors to the rules
|
||||||
|
String[] rules = vminecraftChat.applyColors(
|
||||||
|
vminecraftSettings.getInstance().getRules());
|
||||||
//Display them
|
//Display them
|
||||||
for (String str : vminecraftSettings.getInstance().getRules()) {
|
for (String str : rules ) {
|
||||||
if(str.isEmpty())
|
if(!str.isEmpty())
|
||||||
player.sendMessage(Colors.Blue+str);
|
player.sendMessage(Colors.Blue + str);
|
||||||
|
else
|
||||||
|
player.sendMessage(Colors.Blue + "!!!The Rules Have Not Been Set!!!");
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,8 @@ public class vminecraftSettings {
|
|||||||
cmdTp = properties.getBoolean("cmdTp",true);
|
cmdTp = properties.getBoolean("cmdTp",true);
|
||||||
cmdMasstp = properties.getBoolean("cmdMasstp",true);
|
cmdMasstp = properties.getBoolean("cmdMasstp",true);
|
||||||
cmdTphere = properties.getBoolean("cmdTphere",true);
|
cmdTphere = properties.getBoolean("cmdTphere",true);
|
||||||
cmdSuicide = properties.getBoolean("cmdSuicide", true);
|
cmdSuicide = properties.getBoolean("cmdSuicide", true);
|
||||||
cmdHeal = properties.getBoolean("cmdHeal",true);
|
cmdHeal = properties.getBoolean("cmdHeal",true);
|
||||||
globalmessages = properties.getBoolean("globalmessages",true);
|
globalmessages = properties.getBoolean("globalmessages",true);
|
||||||
cmdSay = properties.getBoolean("cmdSay",true);
|
cmdSay = properties.getBoolean("cmdSay",true);
|
||||||
cmdEzModo = properties.getBoolean("cmdEzModo",true);
|
cmdEzModo = properties.getBoolean("cmdEzModo",true);
|
||||||
@ -171,7 +171,6 @@ public class vminecraftSettings {
|
|||||||
public boolean cmdRules() {return cmdRules;}
|
public boolean cmdRules() {return cmdRules;}
|
||||||
public boolean globalmessages() {return globalmessages;}
|
public boolean globalmessages() {return globalmessages;}
|
||||||
public boolean cmdMasstp() {return cmdMasstp;}
|
public boolean cmdMasstp() {return cmdMasstp;}
|
||||||
public boolean cmdEzModo() {return cmdEzModo;}
|
|
||||||
public boolean cmdWho() {return cmdWho;}
|
public boolean cmdWho() {return cmdWho;}
|
||||||
public boolean stopFire() {return stopFire;}
|
public boolean stopFire() {return stopFire;}
|
||||||
public boolean stopTnt() {return stopTnt;}
|
public boolean stopTnt() {return stopTnt;}
|
||||||
@ -179,18 +178,20 @@ public class vminecraftSettings {
|
|||||||
public boolean cmdHeal() {return cmdHeal;}
|
public boolean cmdHeal() {return cmdHeal;}
|
||||||
|
|
||||||
//EzModo methods
|
//EzModo methods
|
||||||
|
public boolean cmdEzModo() {return cmdEzModo;}
|
||||||
public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
|
public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
|
||||||
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
|
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
|
||||||
public void addEzModo(String playerName) {ezModo.add(playerName);}
|
public void addEzModo(String playerName) {ezModo.add(playerName);}
|
||||||
public int ezModoHealth() {return ezHealth;}
|
public int ezModoHealth() {return ezHealth;}
|
||||||
public String ezModoList() {return ezModo.toString();}
|
public String ezModoList() {return ezModo.toString();}
|
||||||
//Random death message method
|
|
||||||
public static String randomDeathMsg() {
|
//Random death message method
|
||||||
if (deathMessages == null) {
|
public static String randomDeathMsg() {
|
||||||
return "died";
|
if (deathMessages == null) {
|
||||||
}
|
return "died";
|
||||||
return deathMessages[ (int) (Math.random() * deathMessages.length)];
|
}
|
||||||
}
|
return deathMessages[ (int) (Math.random() * deathMessages.length)];
|
||||||
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: getInstance
|
//Function: getInstance
|
||||||
|
Loading…
Reference in New Issue
Block a user