mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 08:36:45 +01:00
Changed file names to be shorter
This commit is contained in:
parent
0d32acfe0b
commit
82e32d7395
685
vChat.java
Normal file
685
vChat.java
Normal file
@ -0,0 +1,685 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: vMinecraftChat
|
||||||
|
//Use: Encapsulates all chat commands added by this mod
|
||||||
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vChat {
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
protected static final int lineLength = 312;
|
||||||
|
//The array of colors to use
|
||||||
|
protected static final String[] rainbow = new String[] {
|
||||||
|
Colors.Red,
|
||||||
|
Colors.Rose,
|
||||||
|
Colors.Gold,
|
||||||
|
Colors.Yellow,
|
||||||
|
Colors.LightGreen,
|
||||||
|
Colors.Green,
|
||||||
|
Colors.LightBlue,
|
||||||
|
Colors.Blue,
|
||||||
|
Colors.Navy,
|
||||||
|
Colors.DarkPurple,
|
||||||
|
Colors.Purple,
|
||||||
|
Colors.LightPurple};
|
||||||
|
protected static final String[] xmas = new String[] {
|
||||||
|
Colors.Red,
|
||||||
|
Colors.Red,
|
||||||
|
Colors.White,
|
||||||
|
Colors.White,
|
||||||
|
Colors.Green,
|
||||||
|
Colors.Green,
|
||||||
|
};
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: gmsg
|
||||||
|
//Input: Player sender: The player sending the message
|
||||||
|
// String msg: The message to be broadcast to all players
|
||||||
|
//Output: None
|
||||||
|
//Use: Outputs a message to everybody
|
||||||
|
//=====================================================================
|
||||||
|
public static void gmsg(Player sender, String msg){
|
||||||
|
if(sender != null && sender.isMuted())
|
||||||
|
sender.sendMessage(Colors.Red + "You have been muted.");
|
||||||
|
|
||||||
|
for (Player receiver : etc.getServer().getPlayerList()) {
|
||||||
|
|
||||||
|
if (receiver == null) return;
|
||||||
|
|
||||||
|
if(vUsers.getProfile(receiver) == null) return;
|
||||||
|
|
||||||
|
//Check if the person has the sender ignored
|
||||||
|
if(sender != null)
|
||||||
|
if(vUsers.getProfile(receiver).isIgnored(sender))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String[] message = applyColors(wordWrap(msg));
|
||||||
|
for(String out : message)
|
||||||
|
receiver.sendMessage(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: gmsg
|
||||||
|
//Input: String msg: The message to be broadcast to all players
|
||||||
|
//Output: None
|
||||||
|
//Use: Outputs a message to everybody
|
||||||
|
//=====================================================================
|
||||||
|
public static void gmsg(String msg){gmsg(null, msg);}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: sendMessage
|
||||||
|
//Input: Player sender: The player sending the message
|
||||||
|
// Player receiver: The player receiving the message
|
||||||
|
// String msg: The message to be broadcast to all players
|
||||||
|
//Output: None
|
||||||
|
//Use: Outputs a message to everybody
|
||||||
|
//=====================================================================
|
||||||
|
public static void sendMessage(Player sender, Player receiver, String msg){
|
||||||
|
if(sender != null && sender.isMuted())
|
||||||
|
sender.sendMessage(Colors.Red + "You have been muted.");
|
||||||
|
|
||||||
|
//Check if the receiver has the sender ignored
|
||||||
|
if(vUsers.getProfile(receiver) == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(sender != null)
|
||||||
|
if(vUsers.getProfile(receiver).isIgnored(sender))
|
||||||
|
{
|
||||||
|
sendMessage(sender, sender, Colors.Rose + receiver.getName()
|
||||||
|
+ " has you on their ignore list.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] message = applyColors(wordWrap(msg));
|
||||||
|
for(String out : message)
|
||||||
|
receiver.sendMessage(out);
|
||||||
|
//Tell them if they are
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: sendMessage
|
||||||
|
//Input: Player receiver: The player receiving the message
|
||||||
|
// String msg: The message to be broadcast to all players
|
||||||
|
//Output: None
|
||||||
|
//Use: Outputs a message to everybody
|
||||||
|
//=====================================================================
|
||||||
|
public static void sendMessage(Player receiver, String msg)
|
||||||
|
{
|
||||||
|
sendMessage(null, receiver, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: wordWrap
|
||||||
|
//Input: String msg: The message to be wrapped
|
||||||
|
//Output: String[]: The array of substrings
|
||||||
|
//Use: Cuts the message apart into whole words short enough to fit
|
||||||
|
// on one line
|
||||||
|
//=====================================================================
|
||||||
|
public static String[] wordWrap(String msg){
|
||||||
|
//Split each word apart
|
||||||
|
ArrayList<String> split = new ArrayList<String>();
|
||||||
|
for(String in : msg.split(" "))
|
||||||
|
split.add(in);
|
||||||
|
|
||||||
|
//Create an arraylist for the output
|
||||||
|
ArrayList<String> out = new ArrayList<String>();
|
||||||
|
//While i is less than the length of the array of words
|
||||||
|
while(!split.isEmpty()){
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
//Create an arraylist to hold individual words
|
||||||
|
ArrayList<String> words = new ArrayList<String>();
|
||||||
|
|
||||||
|
//Loop through the words finding their length and increasing
|
||||||
|
//j, the end point for the sub string
|
||||||
|
while(!split.isEmpty() && split.get(0) != null && len <= lineLength)
|
||||||
|
{
|
||||||
|
int wordLength = msgLength(split.get(0)) + 4;
|
||||||
|
|
||||||
|
//If a word is too long for a line
|
||||||
|
if(wordLength > lineLength)
|
||||||
|
{
|
||||||
|
String[] tempArray = wordCut(len, split.remove(0));
|
||||||
|
words.add(tempArray[0]);
|
||||||
|
split.add(tempArray[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the word is not too long to fit
|
||||||
|
len += wordLength;
|
||||||
|
if( len < lineLength)
|
||||||
|
words.add(split.remove(0));
|
||||||
|
}
|
||||||
|
//Merge them and add them to the output array.
|
||||||
|
out.add( etc.combineSplit(0,
|
||||||
|
words.toArray(new String[words.size()]), " ") + " " );
|
||||||
|
}
|
||||||
|
//Convert to an array and return
|
||||||
|
return out.toArray(new String[out.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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.
|
||||||
|
//=====================================================================
|
||||||
|
public static int msgLength(String str){
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if(str.charAt(x) == '^' || str.charAt(x) == Colors.White.charAt(0))
|
||||||
|
{
|
||||||
|
if(colorChange(str.charAt(x + 1)) != null)
|
||||||
|
{
|
||||||
|
x++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int len = charLength(str.charAt(x));
|
||||||
|
length += len;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: wordCut
|
||||||
|
//Input: String str: The string to find the length of
|
||||||
|
//Output: String[]: The cut up word
|
||||||
|
//Use: Cuts apart a word that is too long to fit on one line
|
||||||
|
//=====================================================================
|
||||||
|
private static String[] wordCut(int lengthBefore, String str){
|
||||||
|
int length = lengthBefore;
|
||||||
|
//Loop through all the characters, skipping any color characters
|
||||||
|
//and their following color codes
|
||||||
|
String[] output = new String[2];
|
||||||
|
int x = 0;
|
||||||
|
while(length < lineLength && x < str.length())
|
||||||
|
{
|
||||||
|
int len = charLength(str.charAt(x));
|
||||||
|
if( len > 0)
|
||||||
|
length += len;
|
||||||
|
else
|
||||||
|
x++;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
if(x > str.length())
|
||||||
|
x = str.length();
|
||||||
|
//Add the substring to the output after cutting it
|
||||||
|
output[0] = str.substring(0, x);
|
||||||
|
//Add the last of the string to the output.
|
||||||
|
output[1] = str.substring(x);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: charLength
|
||||||
|
//Input: char x: The character to find the length of.
|
||||||
|
//Output: int: The length of the character
|
||||||
|
//Use: Finds the visual length of the character on the screen.
|
||||||
|
//=====================================================================
|
||||||
|
private static int charLength(char x)
|
||||||
|
{
|
||||||
|
if("i.:,;|!".indexOf(x) != -1)
|
||||||
|
return 2;
|
||||||
|
else if("l'".indexOf(x) != -1)
|
||||||
|
return 3;
|
||||||
|
else if("tI[]".indexOf(x) != -1)
|
||||||
|
return 4;
|
||||||
|
else if("fk{}<>\"*()".indexOf(x) != -1)
|
||||||
|
return 5;
|
||||||
|
else if("abcdeghjmnopqrsuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890\\/#?$%-=_+&^".indexOf(x) != -1)
|
||||||
|
return 6;
|
||||||
|
else if("@~".indexOf(x) != -1)
|
||||||
|
return 7;
|
||||||
|
else if(x==' ')
|
||||||
|
return 4;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: rainbow
|
||||||
|
//Input: String msg: The string to colorify
|
||||||
|
//Output: String: The rainbowed result
|
||||||
|
//Use: Rainbowifies a string;
|
||||||
|
//=====================================================================
|
||||||
|
public static String rainbow(String msg){
|
||||||
|
String temp = "";
|
||||||
|
int counter=0;
|
||||||
|
//Loop through the message applying the colors
|
||||||
|
for(int x=0; x<msg.length(); x++)
|
||||||
|
{
|
||||||
|
temp += rainbow[counter]+msg.charAt(x);
|
||||||
|
|
||||||
|
if(msg.charAt(x)!=' ') counter++;
|
||||||
|
if(counter==rainbow.length) counter = 0;
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
//=====================================================================
|
||||||
|
//Function: xmas
|
||||||
|
//Input: String msg: The string to colorify
|
||||||
|
//Output: String: The xmas colored result
|
||||||
|
//Use: Makes a string more festive
|
||||||
|
//=====================================================================
|
||||||
|
public static String xmas(String msg){
|
||||||
|
String temp = "";
|
||||||
|
int counter=0;
|
||||||
|
//Loop through the message applying the colors
|
||||||
|
for(int x=0; x<msg.length(); x++)
|
||||||
|
{
|
||||||
|
temp += xmas[counter]+msg.charAt(x);
|
||||||
|
|
||||||
|
if(msg.charAt(x)!=' ') counter++;
|
||||||
|
if(counter==xmas.length) counter = 0;
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getName
|
||||||
|
//Input: Player player: The player to get name as color
|
||||||
|
//Output: String: The name colored
|
||||||
|
//Use: Returns the colored name;
|
||||||
|
//=====================================================================
|
||||||
|
public static String getName(Player player){
|
||||||
|
|
||||||
|
//Add the nickname or the name if there is none
|
||||||
|
String output = vUsers.getProfile(player).getNick();
|
||||||
|
|
||||||
|
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 tag if there is one
|
||||||
|
output = vUsers.getProfile(player).getTag() + output;
|
||||||
|
|
||||||
|
//Add the suffix if there is one
|
||||||
|
output += vUsers.getProfile(player).getSuffix();
|
||||||
|
|
||||||
|
output = Colors.White + output;
|
||||||
|
|
||||||
|
/*if(playerPrefix != null && !playerPrefix.isEmpty())
|
||||||
|
output = applyColors(playerPrefix.substring(1)) + output;*/
|
||||||
|
|
||||||
|
//Return the name
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: colorChange
|
||||||
|
//Input: char colour: The color code to find the color for
|
||||||
|
//Output: String: The color that the code identified
|
||||||
|
//Use: Finds a color giving a color code
|
||||||
|
//=====================================================================
|
||||||
|
public static String colorChange(char colour)
|
||||||
|
{
|
||||||
|
String color = "";
|
||||||
|
switch(colour)
|
||||||
|
{
|
||||||
|
case '0':
|
||||||
|
color = Colors.Black;
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
color = Colors.Navy;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
color = Colors.Green;
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
color = Colors.Blue;
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
color = Colors.Red;
|
||||||
|
break;
|
||||||
|
case '5':
|
||||||
|
color = Colors.Purple;
|
||||||
|
break;
|
||||||
|
case '6':
|
||||||
|
color = Colors.Gold;
|
||||||
|
break;
|
||||||
|
case '7':
|
||||||
|
color = Colors.LightGray;
|
||||||
|
break;
|
||||||
|
case '8':
|
||||||
|
color = Colors.Gray;
|
||||||
|
break;
|
||||||
|
case '9':
|
||||||
|
color = Colors.DarkPurple;
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
color = Colors.LightGreen;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
color = Colors.LightBlue;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
color = Colors.Rose;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
color = Colors.LightPurple;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
color = Colors.Yellow;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
color = Colors.White;
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
color = Colors.LightGreen;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
color = Colors.LightBlue;
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
color = Colors.Rose;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
color = Colors.LightPurple;
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
color = Colors.Yellow;
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
color = Colors.White;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
color = "^r";
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
color = "^r";
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
color = "^x";
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
color = "^x";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: adminChat
|
||||||
|
//Input: Player player: The player talking
|
||||||
|
// String message: The message to apply the effect to
|
||||||
|
//Output: boolean: If this feature is enabled
|
||||||
|
//Use: Sends messages only to admins
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean adminChat(Player player, String message){
|
||||||
|
|
||||||
|
//Check if the player can use this feature
|
||||||
|
if(player.isAdmin() || player.canUseCommand("/adminchat"))
|
||||||
|
{
|
||||||
|
//Special formatting for adminchat {Username}
|
||||||
|
String adminchat = Colors.DarkPurple + "{" + getName(player)
|
||||||
|
+ Colors.DarkPurple +"} ";
|
||||||
|
|
||||||
|
//Cut off the @ prefix
|
||||||
|
if(message.startsWith("@"))
|
||||||
|
message = message.substring(1, message.length());
|
||||||
|
|
||||||
|
//Get the player from the playerlist to send the message to.
|
||||||
|
for (Player p: etc.getServer().getPlayerList()) {
|
||||||
|
|
||||||
|
//If p is not null
|
||||||
|
if (p != null) {
|
||||||
|
|
||||||
|
//And if p is an admin or has access to adminchat send message
|
||||||
|
if (p.isAdmin() || (p.canUseCommand("/adminchat"))) {
|
||||||
|
sendMessage(player, p, adminchat + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//So you can read adminchat from the server console
|
||||||
|
log.log(Level.INFO, "@" + "<" + player.getName() + "> " + message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public static boolean partyChat(Player player, String message){
|
||||||
|
if(vUsers.getProfile(player).inParty()){
|
||||||
|
String partychat = Colors.Green + "(" + getName(player) + Colors.Green + ") ";
|
||||||
|
for (Player p: etc.getServer().getPlayerList()){
|
||||||
|
if (p != null){
|
||||||
|
if (vUsers.getProfile(p).inParty() && (vUsers.getProfile(p).getParty().equals(vUsers.getProfile(player).getParty()))){
|
||||||
|
sendMessage(player, p, partychat + Colors.Green + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: quote
|
||||||
|
//Input: Player player: The player talking
|
||||||
|
// String message: The message to apply the effect to
|
||||||
|
//Output: boolean: If this feature is enabled
|
||||||
|
//Use: Displays a message as a quote
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean quote(Player player, String message)
|
||||||
|
{
|
||||||
|
//Format the name
|
||||||
|
String playerName = Colors.White + "<" + getName(player)
|
||||||
|
+ Colors.White + "> ";
|
||||||
|
if(vConfig.getInstance().greentext()) {
|
||||||
|
//Log the chat
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> " + message);
|
||||||
|
|
||||||
|
//Output the message
|
||||||
|
gmsg(player, playerName + Colors.LightGreen + message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: rage
|
||||||
|
//Input: Player player: The player talking
|
||||||
|
// String message: The message to apply the effect to
|
||||||
|
//Output: boolean: If this feature is enabled
|
||||||
|
//Use: Displays a message in red
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean rage(Player player, String message)
|
||||||
|
{
|
||||||
|
//Format the name
|
||||||
|
String playerName = Colors.White + "<"
|
||||||
|
+ getName(player) + Colors.White +"> ";
|
||||||
|
if (vConfig.getInstance().FFF()) {
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
|
|
||||||
|
//Output the message
|
||||||
|
gmsg(player, playerName + Colors.Red + message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: quakeColors
|
||||||
|
//Input: Player player: The player talking
|
||||||
|
// String message: The message to apply the effect to
|
||||||
|
//Output: boolean: If this feature is enabled
|
||||||
|
//Use: Displays a message in red
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean quakeColors(Player player, String message)
|
||||||
|
{
|
||||||
|
//Format the name
|
||||||
|
String playerName = Colors.White + "<"
|
||||||
|
+ getName(player) + Colors.White +"> ";
|
||||||
|
if(vConfig.getInstance().quakeColors()) {
|
||||||
|
|
||||||
|
String color = vUsers.getProfile(player).getColor();
|
||||||
|
//Log the chat
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> " + message);
|
||||||
|
|
||||||
|
//Output the message
|
||||||
|
gmsg(player, playerName + color + message);
|
||||||
|
|
||||||
|
//Loop through the string finding the color codes and inserting them
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: emote
|
||||||
|
//Input: Player player: The player talking
|
||||||
|
// String message: The message to apply the effect to
|
||||||
|
//Output: boolean: If this feature is enabled
|
||||||
|
//Use: /me but with our custom colors applied
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean emote(Player player, String message)
|
||||||
|
{
|
||||||
|
gmsg(player, "* " + getName(player) + " " + Colors.White + message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: applyColors
|
||||||
|
//Input: String[] message: The lines to be colored
|
||||||
|
//Output: String[]: The lines, but colorful
|
||||||
|
//Use: Colors each line
|
||||||
|
//=====================================================================
|
||||||
|
public static String[] applyColors(String[] message)
|
||||||
|
{
|
||||||
|
if(message != null && message[0] != null && !message[0].isEmpty()){
|
||||||
|
//The color to start the line with
|
||||||
|
String recentColor = Colors.White;
|
||||||
|
|
||||||
|
//Go through each line
|
||||||
|
int counter = 0;
|
||||||
|
int i = 0;
|
||||||
|
boolean taste = false;
|
||||||
|
boolean xmasparty = false;
|
||||||
|
|
||||||
|
for(String msg: message)
|
||||||
|
{
|
||||||
|
//Start the line with the most recent color
|
||||||
|
String temp = "";
|
||||||
|
if(!recentColor.equals("^r") && recentColor != null)
|
||||||
|
temp += recentColor;
|
||||||
|
|
||||||
|
//Loop through looking for a color code
|
||||||
|
for(int x = 0; x< msg.length(); x++)
|
||||||
|
{
|
||||||
|
//If the char is a ^ or <EFBFBD>
|
||||||
|
if(taste || msg.charAt(x) == '^'
|
||||||
|
|| msg.charAt(x) == Colors.Red.charAt(0))
|
||||||
|
{
|
||||||
|
if(x != msg.length() - 1)
|
||||||
|
{
|
||||||
|
//If the following character is a color code
|
||||||
|
if(vChat.colorChange(msg.charAt(x+1)) != null)
|
||||||
|
{
|
||||||
|
//Set the most recent color to the new color
|
||||||
|
recentColor = vChat.colorChange(msg.charAt(x+1));
|
||||||
|
|
||||||
|
//If the color specified is rainbow
|
||||||
|
if(taste || recentColor.equals("^r"))
|
||||||
|
{
|
||||||
|
//Skip the quake code for rainbow
|
||||||
|
if(recentColor.equals("^r"))
|
||||||
|
{
|
||||||
|
x += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Taste keeps it going with rainbow if there
|
||||||
|
//are more lines
|
||||||
|
taste = true;
|
||||||
|
//Loop through the message applying the colors
|
||||||
|
while(x < msg.length() && msg.charAt(x) != '^'
|
||||||
|
&& msg.charAt(x) != Colors.Red.charAt(0))
|
||||||
|
{
|
||||||
|
temp += rainbow[i] + msg.charAt(x);
|
||||||
|
|
||||||
|
if(msg.charAt(x) != ' ') i++;
|
||||||
|
if(i == rainbow.length) i = 0;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If it reached another color instead of the end
|
||||||
|
if(x < msg.length() && msg.charAt(x) == '^'
|
||||||
|
|| x < msg.length()
|
||||||
|
&& msg.charAt(x) == Colors.Red.charAt(0) )
|
||||||
|
{
|
||||||
|
taste = false;
|
||||||
|
i = 0;
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(xmasparty || recentColor.equals("^x"))
|
||||||
|
{
|
||||||
|
//Skip the quake code for xmas
|
||||||
|
if(recentColor.equals("^x"))
|
||||||
|
{
|
||||||
|
x += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Taste keeps it going with xmas if there
|
||||||
|
//are more lines
|
||||||
|
xmasparty = true;
|
||||||
|
//Loop through the message applying the colors
|
||||||
|
while(x < msg.length() && msg.charAt(x) != '^'
|
||||||
|
&& msg.charAt(x) != Colors.Red.charAt(0))
|
||||||
|
{
|
||||||
|
temp += xmas[i] + msg.charAt(x);
|
||||||
|
|
||||||
|
if(msg.charAt(x) != ' ') i++;
|
||||||
|
if(i == xmas.length) i = 0;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If it reached another color instead of the end
|
||||||
|
if(x < msg.length() && msg.charAt(x) == '^'
|
||||||
|
|| x < msg.length()
|
||||||
|
&& msg.charAt(x) == Colors.Red.charAt(0) )
|
||||||
|
{
|
||||||
|
xmasparty = false;
|
||||||
|
i = 0;
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
//Add the color
|
||||||
|
temp += recentColor;
|
||||||
|
//Skip these chars
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Otherwise ignore it.
|
||||||
|
} else {
|
||||||
|
temp += msg.charAt(x);
|
||||||
|
}
|
||||||
|
//Insert the character
|
||||||
|
} else {
|
||||||
|
temp += msg.charAt(x);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
temp += msg.charAt(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Replace the message with the colorful message
|
||||||
|
message[counter] = temp;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
300
vConfig.java
Normal file
300
vConfig.java
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
//=====================================================================
|
||||||
|
//Class: vminecraftSettings
|
||||||
|
//Use: Controls the settings for vminecraft
|
||||||
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vConfig {
|
||||||
|
//private final static Object syncLock = new Object();
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
private static volatile vConfig instance;
|
||||||
|
static int range;
|
||||||
|
|
||||||
|
|
||||||
|
//The feature settings
|
||||||
|
static boolean toggle = true,
|
||||||
|
adminChat = false,
|
||||||
|
greentext = false,
|
||||||
|
FFF = false,
|
||||||
|
quakeColors = false,
|
||||||
|
prefix = false,
|
||||||
|
suffix = false,
|
||||||
|
ignore = false,
|
||||||
|
colors = false,
|
||||||
|
nick = false,
|
||||||
|
playerspawn = false,
|
||||||
|
freeze = false,
|
||||||
|
lavaspread = false,
|
||||||
|
colorsrequirepermission = false,
|
||||||
|
cmdFabulous = false,
|
||||||
|
cmdPromote = false,
|
||||||
|
cmdDemote = false,
|
||||||
|
cmdWhoIs = false,
|
||||||
|
cmdRules = false,
|
||||||
|
cmdMasstp = false,
|
||||||
|
cmdTp = false,
|
||||||
|
cmdTphere = false,
|
||||||
|
globalmessages = false,
|
||||||
|
cmdSay = false,
|
||||||
|
cmdWho = false,
|
||||||
|
stopFire = false,
|
||||||
|
cmdHeal = false,
|
||||||
|
cmdSuicide = false,
|
||||||
|
cmdAdminToggle = false,
|
||||||
|
cmdEzModo = false;
|
||||||
|
//An array of players currently in ezmodo
|
||||||
|
static ArrayList<String> ezModo = new ArrayList<String>();
|
||||||
|
//An array of players currently frozen
|
||||||
|
static ArrayList<String> frozenplayers = new ArrayList<String>();
|
||||||
|
//An array of players currently toggled for admin chat
|
||||||
|
static ArrayList<String> adminChatList = new ArrayList<String>();
|
||||||
|
//An array of blocks that won't catch on fire
|
||||||
|
static public ArrayList<Integer> fireblockan;
|
||||||
|
|
||||||
|
|
||||||
|
private PropertiesFile properties;
|
||||||
|
String file = "vminecraft.properties";
|
||||||
|
public String rules[] = new String[0];
|
||||||
|
public static String deathMessages[] = new String[0];
|
||||||
|
public static String ranks[] = new String[0];
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: loadSettings
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Loads the settings from the properties
|
||||||
|
//=====================================================================
|
||||||
|
public void loadSettings()
|
||||||
|
{
|
||||||
|
File theDir = new File("vminecraft.properties");
|
||||||
|
if(!theDir.exists()){
|
||||||
|
String location = "vminecraft.properties";
|
||||||
|
properties = new PropertiesFile("vminecraft.properties");
|
||||||
|
FileWriter writer = null;
|
||||||
|
try {
|
||||||
|
writer = new FileWriter(location);
|
||||||
|
writer.write("#This plugin is modular\r\n");
|
||||||
|
writer.write("#Turn any features you don't want to false and they won't be running\r\n");
|
||||||
|
writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n");
|
||||||
|
writer.write("#Chat Options\r\n");
|
||||||
|
writer.write("#Allows the use of color codes following ^ symbol\r\n");
|
||||||
|
writer.write("ColoredChat=true\r\n");
|
||||||
|
writer.write("#Require per player permission for quakecolors\r\n");
|
||||||
|
writer.write("colorsrequirepermissions=false\r\n");
|
||||||
|
writer.write("#use /coloruse to give players permission if this is enabled\r\n");
|
||||||
|
writer.write("#Text following a > will be colored green to mimic quoting of popular internet message boards\r\n");
|
||||||
|
writer.write("QuotesAreGreen=true\r\n");
|
||||||
|
writer.write("#Turns any chat message starting with FFF automagically blood red\r\n");
|
||||||
|
writer.write("FFF=true\r\n");
|
||||||
|
writer.write("\r\n");
|
||||||
|
writer.write("#Admin Settings\r\n");
|
||||||
|
writer.write("#Enables or disables players spawning to their home location\r\n");
|
||||||
|
writer.write("playerspawn=true\r\n");
|
||||||
|
writer.write("#Enables or disables the admin only chat\r\n");
|
||||||
|
writer.write("adminchat=true\r\n");
|
||||||
|
writer.write("#Lets non admins use admin chat if they have the /adminchat command permission\r\n");
|
||||||
|
writer.write("/adminchat=true\r\n");
|
||||||
|
writer.write("#Enables overriding of regular /tp and /tphere to make it so you can only teleport to players with lower permissions, and only bring players of lower permissions to you\r\n");
|
||||||
|
writer.write("/tp=true\r\n");
|
||||||
|
writer.write("/tphere=true\r\n");
|
||||||
|
writer.write("#Mass Tp uses the same concept, anyone with this command only brings those with lower permissions to themselves\r\n");
|
||||||
|
writer.write("/masstp=true\r\n");
|
||||||
|
writer.write("\r\n");
|
||||||
|
writer.write("#Server Settings\r\n");
|
||||||
|
writer.write("#Enables or Disables the following commands, give groups/users permissions to use these commands for them to work\r\n");
|
||||||
|
writer.write("/fabulous=true\r\n");
|
||||||
|
writer.write("/prefix=true\r\n");
|
||||||
|
writer.write("/freeze=true\r\n");
|
||||||
|
writer.write("/suffix=true\r\n");
|
||||||
|
writer.write("/ignore=true\r\n");
|
||||||
|
writer.write("/colors=true\r\n");
|
||||||
|
writer.write("/whois=true\r\n");
|
||||||
|
writer.write("/nick=true\r\n");
|
||||||
|
writer.write("/who=true\r\n");
|
||||||
|
writer.write("/promote=true\r\n");
|
||||||
|
writer.write("/demote=true\r\n");
|
||||||
|
writer.write("/say=true\r\n");
|
||||||
|
writer.write("/rules=true\r\n");
|
||||||
|
writer.write("/suicide=true\r\n");
|
||||||
|
writer.write("/ezmodo=true\r\n");
|
||||||
|
writer.write("#Global Messages\r\n");
|
||||||
|
writer.write("#Enable or Disable sending announcements about sensitive commands to the entire server\r\n");
|
||||||
|
writer.write("globalmessages=true\r\n");
|
||||||
|
writer.write("#Adding player names to this list will have them start off in ezmodo\r\n");
|
||||||
|
writer.write("ezModo=\r\n");
|
||||||
|
writer.write("#Stop fire from spreading\r\n");
|
||||||
|
writer.write("stopFire=false\r\n");
|
||||||
|
writer.write("#Stop lava from spreading fire");
|
||||||
|
writer.write("lavaspread=false");
|
||||||
|
writer.write("#Blocks disabled from fire");
|
||||||
|
writer.write("fireblocks=");
|
||||||
|
writer.write("\r\n");
|
||||||
|
writer.write("#Organize your player ranks from lowest to highest.\r\n");
|
||||||
|
writer.write("ranks=\r\n");
|
||||||
|
writer.write("#Write the rules to be shown when /rules is used here, it works just like the MOTD does\r\n");
|
||||||
|
writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
|
||||||
|
writer.write("#The Random Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n");
|
||||||
|
writer.write("deathMessages=is no more,died horribly,went peacefully\r\n");
|
||||||
|
writer.write("hiddendistance=1024");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (writer != null) {
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
properties = new PropertiesFile("vminecraft.properties");
|
||||||
|
try {
|
||||||
|
properties.load();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while loading vminecraft.properties", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
adminChat = properties.getBoolean("adminchat",true);
|
||||||
|
playerspawn = properties.getBoolean("playerspawn",true);
|
||||||
|
greentext = properties.getBoolean("QuotesAreGreen",true);
|
||||||
|
FFF = properties.getBoolean("FFF",true);
|
||||||
|
quakeColors = properties.getBoolean("ColoredChat",true);
|
||||||
|
colorsrequirepermission = properties.getBoolean("colorsrequirepermission",true);
|
||||||
|
prefix = properties.getBoolean("prefix",true);
|
||||||
|
suffix = properties.getBoolean("suffix",true);
|
||||||
|
ignore = properties.getBoolean("ignore",true);
|
||||||
|
colors = properties.getBoolean("colors",true);
|
||||||
|
nick = properties.getBoolean("nick",true);
|
||||||
|
freeze = properties.getBoolean("/freeze",true);
|
||||||
|
cmdFabulous = properties.getBoolean("/fabulous",true);
|
||||||
|
cmdPromote = properties.getBoolean("/promote",true);
|
||||||
|
cmdDemote = properties.getBoolean("/demote",true);
|
||||||
|
cmdWhoIs = properties.getBoolean("/whois",true);
|
||||||
|
cmdWho = properties.getBoolean("/who",true);
|
||||||
|
cmdRules = properties.getBoolean("/rules",true);
|
||||||
|
cmdTp = properties.getBoolean("/tp",true);
|
||||||
|
cmdMasstp = properties.getBoolean("/masstp",true);
|
||||||
|
cmdTphere = properties.getBoolean("/tphere",true);
|
||||||
|
cmdSuicide = properties.getBoolean("/suicide", true);
|
||||||
|
cmdHeal = properties.getBoolean("/heal",true);
|
||||||
|
cmdAdminToggle = properties.getBoolean("/adminchat", true);
|
||||||
|
globalmessages = properties.getBoolean("globalmessages",true);
|
||||||
|
cmdSay = properties.getBoolean("/say",true);
|
||||||
|
cmdEzModo = properties.getBoolean("/ezmodo",true);
|
||||||
|
stopFire = properties.getBoolean("stopFire",true);
|
||||||
|
lavaspread = properties.getBoolean("lavaspread",true);
|
||||||
|
rules = properties.getString("rules", "").split("@");
|
||||||
|
deathMessages = properties.getString("deathmessages", "").split(",");
|
||||||
|
String[] tempEz = properties.getString("ezModo").split(",");
|
||||||
|
String[] fireblocks = properties.getString("fireblocks").split(",");
|
||||||
|
fireblockan = new ArrayList<Integer>();
|
||||||
|
for(String str : fireblocks)
|
||||||
|
{
|
||||||
|
if(!str.isEmpty())
|
||||||
|
fireblockan.add(Integer.parseInt(str));
|
||||||
|
}
|
||||||
|
ezModo = new ArrayList<String>();
|
||||||
|
ezModo.addAll(Arrays.asList(tempEz));
|
||||||
|
ranks = properties.getString("ranks").split(",");
|
||||||
|
range = properties.getInt("hiddendistance",1024);
|
||||||
|
log.log(Level.INFO, "vminecraft plugin successfully loaded");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE {0}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: adminchat, greentext, FFF, quakeColors, cmdFabulous,
|
||||||
|
// cmdPromote, cmdDemote, cmdWhoIs, cmdTp, cmdTphere, cmdSay
|
||||||
|
// cmdRules, globalmessages, cmdMasstp, cmdEzModo
|
||||||
|
//Input: None
|
||||||
|
//Output: Boolan: If the feature is enabled
|
||||||
|
//Use: Returns if the feature is enabled
|
||||||
|
//=====================================================================
|
||||||
|
public boolean adminchat() {return adminChat;}
|
||||||
|
public boolean adminChatToggle() {return cmdAdminToggle;}
|
||||||
|
public boolean greentext() {return greentext;}
|
||||||
|
public boolean FFF() {return FFF;}
|
||||||
|
public boolean quakeColors() {return quakeColors;}
|
||||||
|
public boolean prefix() {return prefix;}
|
||||||
|
public boolean suffix() {return suffix;}
|
||||||
|
public boolean ignore() {return ignore;}
|
||||||
|
public boolean colors() {return colors;}
|
||||||
|
public boolean nick() {return nick;}
|
||||||
|
public boolean playerspawn() {return playerspawn;}
|
||||||
|
public boolean colorsreq() {return colorsrequirepermission;}
|
||||||
|
public boolean freeze() {return freeze;}
|
||||||
|
public boolean cmdFabulous() {return cmdFabulous;}
|
||||||
|
public boolean cmdPromote() {return cmdPromote;}
|
||||||
|
public boolean cmdDemote() {return cmdDemote;}
|
||||||
|
public boolean cmdWhoIs() {return cmdWhoIs;}
|
||||||
|
public boolean cmdTp() {return cmdTp;}
|
||||||
|
public boolean cmdTphere() {return cmdTphere;}
|
||||||
|
public boolean cmdSay() {return cmdSay;}
|
||||||
|
public boolean cmdRules() {return cmdRules;}
|
||||||
|
public boolean globalmessages() {return globalmessages;}
|
||||||
|
public boolean cmdMasstp() {return cmdMasstp;}
|
||||||
|
public boolean cmdWho() {return cmdWho;}
|
||||||
|
public boolean stopFire() {return stopFire;}
|
||||||
|
public boolean lavaSpread() {return lavaspread;}
|
||||||
|
public boolean cmdSuicide() {return cmdSuicide;}
|
||||||
|
public boolean cmdHeal() {return cmdHeal;}
|
||||||
|
public ArrayList<Integer> getFireBlockIds() {return fireblockan;}
|
||||||
|
public String[] getRanks() {return ranks;}
|
||||||
|
|
||||||
|
//EzModo methods
|
||||||
|
public boolean cmdEzModo() {return cmdEzModo;}
|
||||||
|
public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
|
||||||
|
public boolean isFrozen(String playerName) {return frozenplayers.contains(playerName);}
|
||||||
|
public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
|
||||||
|
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
|
||||||
|
public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
|
||||||
|
public void addEzModo(String playerName) {ezModo.add(playerName);}
|
||||||
|
public void addAdminToggled(String playerName) {adminChatList.add(playerName);}
|
||||||
|
public void addFrozen(String playerName) {frozenplayers.add(playerName);}
|
||||||
|
public void removeFrozen (String playerName) {frozenplayers.remove(frozenplayers.indexOf(playerName));}
|
||||||
|
public String ezModoList() {return ezModo.toString();}
|
||||||
|
|
||||||
|
//Random death message method
|
||||||
|
public static String randomDeathMsg() {
|
||||||
|
if (deathMessages == null) {
|
||||||
|
return "died";
|
||||||
|
}
|
||||||
|
return deathMessages[ (int) (Math.random() * deathMessages.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getInstance
|
||||||
|
//Input: None
|
||||||
|
//Output: vminecraftSettings: The instance of the settings
|
||||||
|
//Use: Returns the instance of the settings
|
||||||
|
//=====================================================================
|
||||||
|
public static vConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new vConfig();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getRules
|
||||||
|
//Input: None
|
||||||
|
//Output: String[]: The list of rules
|
||||||
|
//Use: Gets the array containing the rules
|
||||||
|
//=====================================================================
|
||||||
|
public String[] getRules() {
|
||||||
|
return rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
187
vListener.java
Normal file
187
vListener.java
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
//=====================================================================
|
||||||
|
//Class: vMinecraftListener
|
||||||
|
//Use: The listener to catch incoming chat and commands
|
||||||
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vListener extends PluginListener {
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: disable
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Disables vMinecraft, but why would you want to do that? ;)
|
||||||
|
//=====================================================================
|
||||||
|
public void disable() {
|
||||||
|
log.log(Level.INFO, "vMinecraft disabled");
|
||||||
|
}
|
||||||
|
public void onPlayerMove(Player player, Location from, Location to) {
|
||||||
|
if(vConfig.getInstance().isFrozen(player.getName())){
|
||||||
|
player.teleportTo(from);
|
||||||
|
}
|
||||||
|
vCom.updateInvisibleForAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: onChat
|
||||||
|
//Input: Player player: The player calling the command
|
||||||
|
// String message: The message to color
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Checks for quote, rage, and colors
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
public boolean onChat(Player player, String message){
|
||||||
|
|
||||||
|
//Quote (Greentext)
|
||||||
|
if (message.startsWith("@") ||
|
||||||
|
vConfig.getInstance().isAdminToggled(player.getName()))
|
||||||
|
return vChat.adminChat(player, message);
|
||||||
|
|
||||||
|
else if (message.startsWith(">"))
|
||||||
|
return vChat.quote(player, message);
|
||||||
|
|
||||||
|
//Rage (FFF)
|
||||||
|
else if (message.startsWith("FFF"))
|
||||||
|
return vChat.rage(player, message);
|
||||||
|
|
||||||
|
//Send through quakeColors otherwise
|
||||||
|
else
|
||||||
|
return vChat.quakeColors(player, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: onCommand
|
||||||
|
//Input: Player player: The player calling the command
|
||||||
|
// String[] split: The arguments
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Checks for exploits and runs the commands
|
||||||
|
//=====================================================================
|
||||||
|
public boolean onCommand(Player player, String[] split) {
|
||||||
|
|
||||||
|
//Copy the arguments into their own array.
|
||||||
|
String[] args = new String[split.length - 1];
|
||||||
|
System.arraycopy(split, 1, args, 0, args.length);
|
||||||
|
|
||||||
|
//Return the results of the command
|
||||||
|
int exitCode = vCom.cl.call(split[0], player, args);
|
||||||
|
if(exitCode == 0)
|
||||||
|
return false;
|
||||||
|
else if(exitCode == 1)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: onHealthChange
|
||||||
|
//Input: Player player: The player calling the command
|
||||||
|
// int oldValue: The old health value;
|
||||||
|
// int newValue: The new health value
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Checks for exploits and runs the commands
|
||||||
|
//=====================================================================
|
||||||
|
public boolean onHealthChange(Player player,int oldValue,int newValue){
|
||||||
|
|
||||||
|
//Sets a player as dead
|
||||||
|
if (player.getHealth() < 1){
|
||||||
|
vUsers.getProfile(player).isDead(true);
|
||||||
|
}
|
||||||
|
if (player.getHealth() > 1 && vUsers.getProfile(player).isDead()){
|
||||||
|
if(vConfig.getInstance().playerspawn())
|
||||||
|
{
|
||||||
|
Warp home = null;
|
||||||
|
if (etc.getDataSource().getHome(player.getName()) != null){
|
||||||
|
home = etc.getDataSource().getHome(player.getName());
|
||||||
|
player.teleportTo(home.Location);
|
||||||
|
player.sendMessage(Colors.DarkPurple + "Return here with /myspawn");
|
||||||
|
player.sendMessage(Colors.DarkPurple + "The penalty for returning is the loss of inventory");
|
||||||
|
}
|
||||||
|
if(player.canUseCommand("/sethome"))
|
||||||
|
player.sendMessage(Colors.DarkPurple + "Set your own spawn with /sethome");
|
||||||
|
}
|
||||||
|
vUsers.getProfile(player).isDead(false);
|
||||||
|
if(!vUsers.getProfile(player).isSilent())
|
||||||
|
vChat.gmsg(Colors.Gray + player.getName() + " " + vConfig.randomDeathMsg());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onLogin(Player player){
|
||||||
|
vChat.sendMessage(player, player, Colors.Rose + "There are currently " + etc.getServer().getPlayerList().size() + " players online.");
|
||||||
|
vUsers.addUser(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisconnect(Player player){
|
||||||
|
vUsers.removeUser(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onIgnite(Block block, Player player) {
|
||||||
|
|
||||||
|
if(vConfig.getInstance().stopFire()){
|
||||||
|
//There are 3 ways fire can spread
|
||||||
|
//1 = lava, 2 = lighter, 3 = spread (other fire blocks)
|
||||||
|
//Stop lava from spreading
|
||||||
|
if(block.getStatus() == 1 && vConfig.getInstance().lavaSpread()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//Stop fire from spreading fire
|
||||||
|
if (block.getStatus() == 3 && vConfig.getInstance().stopFire()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//Checking to see if any of the blocks fire is trying to spread to is on the "fireblockan" list
|
||||||
|
if (block.getStatus() == 3){
|
||||||
|
int x,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
g;
|
||||||
|
x = block.getX();
|
||||||
|
y = block.getY();
|
||||||
|
z = block.getZ();
|
||||||
|
//Finding out the blockid of the current blocks fire is trying to spread to
|
||||||
|
int blockid = etc.getServer().getBlockIdAt(x, y, z);
|
||||||
|
//Check to see the blockid doesn't match anything on the list
|
||||||
|
for(x = 0; x >= vConfig.fireblockan.size(); x++){
|
||||||
|
if (vConfig.fireblockan.get(x) == blockid){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//Stop players without permission from being able to set fires
|
||||||
|
if(block.getStatus() == 2 && !player.canUseCommand("/flint")){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
|
||||||
|
//Invincibility for EzModo players
|
||||||
|
if(defender.isPlayer()){
|
||||||
|
Player dplayer = defender.getPlayer();
|
||||||
|
if(vConfig.getInstance().isEzModo(dplayer.getName())){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(attacker != null && attacker.isPlayer()){
|
||||||
|
Player aplayer = attacker.getPlayer();
|
||||||
|
if(vUsers.getProfile(dplayer).inParty()){
|
||||||
|
if(vmc.inSameParty(aplayer, dplayer)){
|
||||||
|
return true;
|
||||||
|
} else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -6,13 +6,13 @@ import java.util.logging.Logger;
|
|||||||
//Author: nossr50, TrapAlice, cerevisiae
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public class vMinecraft extends Plugin {
|
public class vMinecraft extends Plugin {
|
||||||
static final vMinecraftListener listener = new vMinecraftListener();
|
static final vListener listener = new vListener();
|
||||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
public void enable() {
|
public void enable() {
|
||||||
vMinecraftSettings.getInstance().loadSettings();
|
vConfig.getInstance().loadSettings();
|
||||||
vMinecraftUsers.getInstance().loadUsers();
|
vUsers.getInstance().loadUsers();
|
||||||
vMinecraftCommands.loadCommands();
|
vCom.loadCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
|
633
vUsers.java
Normal file
633
vUsers.java
Normal file
@ -0,0 +1,633 @@
|
|||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: PlayerList
|
||||||
|
//Use: Encapsulates the player list
|
||||||
|
//Author: cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vUsers {
|
||||||
|
private static volatile vUsers instance;
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
private PropertiesFile properties;
|
||||||
|
String location = "vminecraft.users";
|
||||||
|
|
||||||
|
public static PlayerList players = new PlayerList();
|
||||||
|
|
||||||
|
|
||||||
|
public void loadUsers(){
|
||||||
|
File theDir = new File(location);
|
||||||
|
if(!theDir.exists()){
|
||||||
|
properties = new PropertiesFile(location);
|
||||||
|
FileWriter writer = null;
|
||||||
|
try {
|
||||||
|
writer = new FileWriter(location);
|
||||||
|
writer.write("#Storage place for user information\r\n");
|
||||||
|
writer.write("#username:nickname:suffix:tag:ignore,list,names:alias,commands,here\r\n");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (writer != null) {
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
properties = new PropertiesFile(location);
|
||||||
|
try {
|
||||||
|
properties.load();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while loading " + location, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: addUser
|
||||||
|
//Input: Player player: The player to create a profile for
|
||||||
|
//Output: none
|
||||||
|
//Use: Loads the profile for the specified player
|
||||||
|
//=====================================================================
|
||||||
|
public static void addUser(Player player){
|
||||||
|
players.addPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: removeUser
|
||||||
|
//Input: Player player: The player to stop following
|
||||||
|
//Output: none
|
||||||
|
//Use: Creates the player profile
|
||||||
|
//=====================================================================
|
||||||
|
public static void removeUser(Player player){
|
||||||
|
players.removePlayer(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 vUsers getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new vUsers();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
public static void getRow(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class PlayerList
|
||||||
|
{
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
ArrayList<PlayerProfile> players;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: PlayerList
|
||||||
|
//Input: Player player: The player to create a profile object for
|
||||||
|
//Output: none
|
||||||
|
//Use: Initializes the ArrayList
|
||||||
|
//=====================================================================
|
||||||
|
public PlayerList() { players = new ArrayList<PlayerProfile>(); }
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: addPlayer
|
||||||
|
//Input: Player player: The player to add
|
||||||
|
//Output: None
|
||||||
|
//Use: Add a profile of the specified player
|
||||||
|
//=====================================================================
|
||||||
|
public void addPlayer(Player player)
|
||||||
|
{
|
||||||
|
players.add(new PlayerProfile(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: removePlayer
|
||||||
|
//Input: Player player: The player to remove
|
||||||
|
//Output: None
|
||||||
|
//Use: Remove the profile of the specified player
|
||||||
|
//=====================================================================
|
||||||
|
public void removePlayer(Player player)
|
||||||
|
{
|
||||||
|
players.remove(findProfile(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: findProfile
|
||||||
|
//Input: Player player: The player to find's profile
|
||||||
|
//Output: PlayerProfile: The profile of the specified player
|
||||||
|
//Use: Get the profile for the specified player
|
||||||
|
//=====================================================================
|
||||||
|
public PlayerProfile findProfile(Player player)
|
||||||
|
{
|
||||||
|
for(PlayerProfile ply : players)
|
||||||
|
{
|
||||||
|
if(ply.isPlayer(player))
|
||||||
|
return ply;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: PlayerProfile
|
||||||
|
//Use: Encapsulates all commands for player options
|
||||||
|
//Author: cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
class PlayerProfile
|
||||||
|
{
|
||||||
|
protected final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
private String playerName,
|
||||||
|
lastMessage,
|
||||||
|
nickName,
|
||||||
|
tag,
|
||||||
|
suffix,
|
||||||
|
party,
|
||||||
|
tpxyz;
|
||||||
|
|
||||||
|
private boolean dead,
|
||||||
|
silent;
|
||||||
|
|
||||||
|
char defaultColor;
|
||||||
|
|
||||||
|
String location = "vminecraft.users";
|
||||||
|
|
||||||
|
private ArrayList<String> ignoreList;
|
||||||
|
private commandList aliasList;
|
||||||
|
|
||||||
|
static final int EXIT_FAIL = 0,
|
||||||
|
EXIT_SUCCESS = 1,
|
||||||
|
EXIT_CONTINUE = 2;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: PlayerProfile
|
||||||
|
//Input: Player player: The player to create a profile object for
|
||||||
|
//Output: none
|
||||||
|
//Use: Loads settings for the player or creates them if they don't
|
||||||
|
// exist.
|
||||||
|
//=====================================================================
|
||||||
|
public PlayerProfile(Player player)
|
||||||
|
{
|
||||||
|
//Declare things
|
||||||
|
playerName = player.getName();
|
||||||
|
tag = new String();
|
||||||
|
nickName = new String();
|
||||||
|
suffix = new String();
|
||||||
|
tpxyz = new String();
|
||||||
|
party = new String();
|
||||||
|
party = null;
|
||||||
|
defaultColor = 'f';
|
||||||
|
ignoreList = new ArrayList<String>();
|
||||||
|
aliasList = new commandList();
|
||||||
|
dead = false;
|
||||||
|
|
||||||
|
//Try to load the player and if they aren't found, append them
|
||||||
|
if(!load())
|
||||||
|
addPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean load()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Open the user file
|
||||||
|
FileReader file = new FileReader(location);
|
||||||
|
BufferedReader in = new BufferedReader(file);
|
||||||
|
String line = "";
|
||||||
|
while((line = in.readLine()) != null)
|
||||||
|
{
|
||||||
|
//Find if the line contains the player we want.
|
||||||
|
String[] character = line.split(":");
|
||||||
|
if(!character[0].equals(playerName)){continue;}
|
||||||
|
|
||||||
|
//Get the tag
|
||||||
|
if(character.length > 1)
|
||||||
|
tag = character[1];
|
||||||
|
//Get the nickname
|
||||||
|
if(character.length > 2)
|
||||||
|
nickName = character[2];
|
||||||
|
//Get the suffix
|
||||||
|
if(character.length > 3)
|
||||||
|
suffix = character[3];
|
||||||
|
//Get the color
|
||||||
|
if(character.length > 4)
|
||||||
|
defaultColor = character[4].charAt(0);
|
||||||
|
//Ignore previously ignored players
|
||||||
|
if(character.length > 5)
|
||||||
|
{
|
||||||
|
String[] ignores = character[5].split(",");
|
||||||
|
if(ignores.length > 0)
|
||||||
|
{
|
||||||
|
for(String ignore : ignores)
|
||||||
|
ignoreList.add(ignore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Register the aliases
|
||||||
|
if(character.length > 6)
|
||||||
|
{
|
||||||
|
String[] allAliases = character[6].split(",");
|
||||||
|
if(allAliases.length > 0)
|
||||||
|
{
|
||||||
|
for(String singleAlias : allAliases)
|
||||||
|
{
|
||||||
|
String[] parts = singleAlias.split("@");
|
||||||
|
if(parts.length > 1)
|
||||||
|
{
|
||||||
|
aliasList.registerAlias(parts[0], parts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//XYZ TP Back value
|
||||||
|
//Not sure if declaring a double this way will work or not
|
||||||
|
if(character.length > 7)
|
||||||
|
{
|
||||||
|
tpxyz = character[7];
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while reading "
|
||||||
|
+ location + " (Are you sure you formatted it correctly?)", e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Function: save
|
||||||
|
// Input: none
|
||||||
|
// Output: None
|
||||||
|
// Use: Writes current values of PlayerProfile to disk
|
||||||
|
// Call this function to save current values
|
||||||
|
//=====================================================================
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Open the file
|
||||||
|
FileReader file = new FileReader(location);
|
||||||
|
BufferedReader in = new BufferedReader(file);
|
||||||
|
StringBuilder writer = new StringBuilder();
|
||||||
|
String line = "";
|
||||||
|
|
||||||
|
//While not at the end of the file
|
||||||
|
while((line = in.readLine()) != null)
|
||||||
|
{
|
||||||
|
//Read the line in and copy it to the output it's not the player
|
||||||
|
//we want to edit
|
||||||
|
if(!line.split(":")[0].equalsIgnoreCase(playerName))
|
||||||
|
{
|
||||||
|
writer.append(line).append("\r\n");
|
||||||
|
|
||||||
|
//Otherwise write the new player information
|
||||||
|
} else {
|
||||||
|
writer.append(playerName + ":");
|
||||||
|
writer.append(tag + ":");
|
||||||
|
writer.append(nickName + ":");
|
||||||
|
writer.append(suffix + ":");
|
||||||
|
writer.append(defaultColor + ":");
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(String ignore : ignoreList)
|
||||||
|
{
|
||||||
|
writer.append(ignore);
|
||||||
|
if(i < ignoreList.size() - 1)
|
||||||
|
writer.append(",");
|
||||||
|
}
|
||||||
|
writer.append(":");
|
||||||
|
writer.append(aliasList.toString());
|
||||||
|
writer.append(tpxyz.toString());
|
||||||
|
writer.append("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
|
||||||
|
//Write the new file
|
||||||
|
FileWriter out = new FileWriter(location);
|
||||||
|
out.write(writer.toString());
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Open the file to write the player
|
||||||
|
FileWriter file = new FileWriter(location, true);
|
||||||
|
BufferedWriter out = new BufferedWriter(file);
|
||||||
|
|
||||||
|
//Add the player to the end
|
||||||
|
out.append(playerName + ":");
|
||||||
|
out.append(tag + ":");
|
||||||
|
out.append(nickName + ":");
|
||||||
|
out.append(suffix + ":");
|
||||||
|
out.append(defaultColor + ":");
|
||||||
|
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(String ignore : ignoreList)
|
||||||
|
{
|
||||||
|
out.append(ignore);
|
||||||
|
if(i < ignoreList.size() - 1)
|
||||||
|
out.append(",");
|
||||||
|
}
|
||||||
|
out.append(":");
|
||||||
|
out.append(tpxyz + ":");
|
||||||
|
|
||||||
|
out.append(aliasList.toString());
|
||||||
|
out.newLine();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: isPlayer
|
||||||
|
//Input: None
|
||||||
|
//Output: Player: The player this profile belongs to
|
||||||
|
//Use: Finds if this profile belongs to a specified player
|
||||||
|
//=====================================================================
|
||||||
|
public boolean isPlayer(Player player)
|
||||||
|
{
|
||||||
|
return player.getName().equals(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: isIgnored
|
||||||
|
//Input: Player player: Checks if a player is ignored
|
||||||
|
//Output: boolean: If they're ignored
|
||||||
|
//Use: Finds if the specified player is in the ignore list
|
||||||
|
//=====================================================================
|
||||||
|
public boolean isIgnored(Player player){
|
||||||
|
return ignoreList.contains(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: addIgnore
|
||||||
|
//Input: Player name: The player to ignore
|
||||||
|
//Output: boolean: If the player was successfully ignored
|
||||||
|
//Use: Ignores a player.
|
||||||
|
//=====================================================================
|
||||||
|
public boolean addIgnore(Player name)
|
||||||
|
{
|
||||||
|
if(!ignoreList.contains(name))
|
||||||
|
{
|
||||||
|
ignoreList.add(name.getName());
|
||||||
|
save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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 boolean removeIgnore(Player name)
|
||||||
|
{
|
||||||
|
if(ignoreList.contains(name.getName()))
|
||||||
|
{
|
||||||
|
ignoreList.remove(name.getName());
|
||||||
|
save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
// String[] args: The arguments for the command
|
||||||
|
//Output: None
|
||||||
|
//Use: Adds a command
|
||||||
|
//=====================================================================
|
||||||
|
public void addAlias(String name, String callCommand)
|
||||||
|
{
|
||||||
|
aliasList.registerAlias(name, callCommand);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: callAlias
|
||||||
|
//Input: String command: The command to try to call
|
||||||
|
// Player player: Checks if a player is ignored
|
||||||
|
// String[] args: The arguments for the command
|
||||||
|
//Output: int: Exit code
|
||||||
|
//Use: Attempts to call a command
|
||||||
|
//=====================================================================
|
||||||
|
public int callAlias(String command, Player player, String[] args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Attemt to call the function
|
||||||
|
return aliasList.call(command, player, args);
|
||||||
|
}
|
||||||
|
catch (Throwable e)
|
||||||
|
{
|
||||||
|
//The function wasn't found, returns fail
|
||||||
|
return EXIT_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: setTag
|
||||||
|
//Input: String newTag: The tag to set for the player
|
||||||
|
//Output: None
|
||||||
|
//Use: Sets a player tag
|
||||||
|
//=====================================================================
|
||||||
|
public void setTag(String newTag)
|
||||||
|
{
|
||||||
|
tag = newTag;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
//=====================================================================
|
||||||
|
//Function: setTpback
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Sets a player's tpback xyz coordinates
|
||||||
|
//=====================================================================
|
||||||
|
public void setTpback(String newtpback)
|
||||||
|
{
|
||||||
|
tpxyz = newtpback;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getTpxyz
|
||||||
|
//Input: None
|
||||||
|
//Output: Double: The player's tpback x coords
|
||||||
|
//Use: Gets the x value of tpback
|
||||||
|
//=====================================================================
|
||||||
|
public String getTpxyz()
|
||||||
|
{
|
||||||
|
return tpxyz;
|
||||||
|
}
|
||||||
|
//Function: getTag
|
||||||
|
//Input: None
|
||||||
|
//Output: String: The player tag
|
||||||
|
//Use: Gets a player tag
|
||||||
|
//=====================================================================
|
||||||
|
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;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSilent(){
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
public void disableSilent(){
|
||||||
|
silent = false;
|
||||||
|
}
|
||||||
|
public boolean isSilent(){
|
||||||
|
return silent;
|
||||||
|
}
|
||||||
|
//Store the player's party
|
||||||
|
public void setParty(String newParty)
|
||||||
|
{
|
||||||
|
party = newParty;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
//Retrieve the player's party
|
||||||
|
public String getParty() {return party;}
|
||||||
|
//Remove party
|
||||||
|
public void removeParty() {
|
||||||
|
party = null;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
//Retrieve whether or not the player is in a party
|
||||||
|
public boolean inParty() {
|
||||||
|
if(party != null){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getSuffix
|
||||||
|
//Input: None
|
||||||
|
//Output: String: The player suffix
|
||||||
|
//Use: Gets a player suffix
|
||||||
|
//=====================================================================
|
||||||
|
public String getSuffix() { return suffix; }
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: setColor
|
||||||
|
//Input: String newTag: The color to set for the player
|
||||||
|
//Output: None
|
||||||
|
//Use: Sets a player color
|
||||||
|
//=====================================================================
|
||||||
|
public void setColor(String newColor)
|
||||||
|
{
|
||||||
|
defaultColor = newColor.charAt(0);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getColor
|
||||||
|
//Input: None
|
||||||
|
//Output: String: The player color
|
||||||
|
//Use: Gets a player color
|
||||||
|
//=====================================================================
|
||||||
|
public String getColor() {return vChat.colorChange(defaultColor);}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: setMessage
|
||||||
|
//Input: String newName: The name of the player they last messaged
|
||||||
|
// or recieved a message from.
|
||||||
|
//Output: None
|
||||||
|
//Use: Sets a player tag
|
||||||
|
//=====================================================================
|
||||||
|
public void setMessage(Player newName){ lastMessage = newName.getName(); }
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getMessage
|
||||||
|
//Input: None
|
||||||
|
//Output: String: The player name
|
||||||
|
//Use: Gets the name of the player they last messaged or recieved
|
||||||
|
// a message from.
|
||||||
|
//=====================================================================
|
||||||
|
public Player getMessage()
|
||||||
|
{
|
||||||
|
if(lastMessage != null)
|
||||||
|
return etc.getServer().matchPlayer(lastMessage);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: isDead
|
||||||
|
//Input: None
|
||||||
|
//Output: boolean: If the player is dead or not
|
||||||
|
//Use: Gets the player is dead or not.
|
||||||
|
//=====================================================================
|
||||||
|
public boolean isDead() {return dead;}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: isDead
|
||||||
|
//Input: boolean isded: if the player is dead or not.
|
||||||
|
//Output: None
|
||||||
|
//Use: Sets if the player is dead or not
|
||||||
|
//=====================================================================
|
||||||
|
public void isDead(boolean isded){dead = isded;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
38
vmc.java
Normal file
38
vmc.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
public class vmc {
|
||||||
|
|
||||||
|
//Check if two players are in the same party
|
||||||
|
public static boolean inSameParty(Player playera, Player playerb){
|
||||||
|
if(vUsers.getProfile(playera).getParty().equals(vUsers.getProfile(playerb).getParty())){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Get the distance between two players
|
||||||
|
public static double getDistance(Player player1, Player player2)
|
||||||
|
{
|
||||||
|
return Math.sqrt(Math.pow(player1.getX() - player2.getX(), 2) + Math.pow(player1.getY() - player2.getY(), 2)
|
||||||
|
+ Math.pow(player1.getZ() - player2.getZ(), 2));
|
||||||
|
}
|
||||||
|
//Send the "invisibility" toggle to players near the hidden player
|
||||||
|
public static void sendInvisible(Player player){
|
||||||
|
for (Player p : etc.getServer().getPlayerList())
|
||||||
|
{
|
||||||
|
if (vmc.getDistance(player, p) <= vConfig.range && p.getUser() != player.getUser())
|
||||||
|
{
|
||||||
|
p.getUser().a.b(new dv(player.getUser().g));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Send "visibility" toggle to invisible players turning them back to normal
|
||||||
|
public static void sendNotInvisible(Player player){
|
||||||
|
for (Player p : etc.getServer().getPlayerList())
|
||||||
|
{
|
||||||
|
if (vmc.getDistance(player, p) < vConfig.range && p.getUser() != player.getUser())
|
||||||
|
{
|
||||||
|
p.getUser().a.b(new d(player.getUser()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user