Merge branch 'nossr50'

Conflicts:
	mcMMO/com/gmail/nossr50/mcPermissions.java
This commit is contained in:
Ben Diskmaster L 2011-07-18 00:41:04 -05:00
commit 9ad06ca4b6
35 changed files with 209 additions and 7833 deletions

28
TODO
View File

@ -1,28 +0,0 @@
Bukkit TODO
-Create Groups Plugin for the Groups system
-Split vMinecraft hMod into smaller plugins for bukkit
-vAdmin for the new admin mod and admin features
-vGuilds for the guild and party system (noss)
-vGroups for the groups system (Cere)
-Finish up the hMod planned features
-Include updatr support with the new plugins
-Port as many of vMinecrafts features as possible
vChat TODO
High Priority
-Rewrite wordWrap() (cere?)
-Rainbow (Possibly xmas as well) crashing clients when entering the second line. My guess is it is a color code being inserted at the end.
Medium Priority
-Ignore
-Default Chat Color
-Settings file
-Chat channels
-Nicknames
-Suffix
-Prefix
Low Priority
-Fix bug where xmas/rainbow don't continue on the second line
-Fix bug where ^x & ^r are inserted to the end of the message when using xmas/rainbow

View File

@ -1,71 +0,0 @@
vMinecraft v1 Todo:
+ Add permission toggle for using colors
+ Guilds
+ Party Leaders
+ Ability to ban the use of certain colors as default chat/prefix color/suffix color
+ More complex fire antigrief
+ matchPlayer taking into account nicknames and prefixes and suffixes
+ Add [] around player tags
+ Modify setNick to not allow players to copy other's
+ Fix ^^ in chat causing error message
nicknames and account names. Also disallow Notch as a nick :P
+ Make death messages accurately report damage type
+ Aliasing Commands (Global Aliases and Personal Aliases) <Cere>
+ Write a way to add and remove commands from players and groups
vMinecraft v2 Updates!
+Add in a sort of rap sheet file for storing and retrieving
information on bans and kicks.
+ More Complex Antigriefs <Nos> Working on this... that is in the future!
+ Different types of /slay
* /slay fire to burn them to death
* /slay drown to drown them
* /slay boil to burn them with lava
+ Time manipulation
* Have time changes not be instant but move the sky faster
to get to the time entered
* Loop through specific times of the day and then rewind
ex: Sunrise to sunset, mid-morning to noon
+ Track Chest Inventory
+ Probations.
* When a player connects it will automatically kick them and inform them
how much longer they are probated for.
DONE
+ Brackets with group prefix colors in chat
+ Party system
+ Party Chat
+ Fix death messages
+ Added /freeze command to stop players from moving
+ Quick recode of /me to use the new getName function
+ Promote and Demote (ASAP) <Cere> DIBS
+ Simple Fire Antigrief
+ /prefix
+ /a to toggle admin chat
+ Code was organized
+ Aliasing was added
+ Playerlist is now colorful and awesome
+ Random death messages
+ Suicide command
+ Heal Command
+ Colored Prefixes
+ Color Codes only removed when actual colors are specified
* Allows use of ^ for emotes and whatever else they
might be needed for.
+ Multi Line color fix
* Now we can have color on multiple lines without
crashing the client
* Also does not cut words in half
+ vminecraft Help
* Specialized help message for vminecraft
? /vhelp?
+ Recode Messaging
* Reply Feature
* Personal Muting
+ Allow players to nickname themselves or others
+ Allow players to set suffixes
+ ^r for rainbow color code
+ Finish work on the flat file system
+ Disabled /modify
Notes: Let's try to to finish as much of this list as possible tomorrow and push for a b8 release soon :P

View File

@ -1,690 +0,0 @@
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((x+1 <= str.length()) && (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 && !"".equals(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(vConfig.getInstance().partyChat()){
//Cut off the ! prefix
if(message.startsWith("!"))
message = message.substring(1, message.length());
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 = vmc.getInstance().getGroupPrefix(player) + "<" + getName(player)
+ vmc.getInstance().getGroupPrefix(player) + "> ";
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 = vmc.getInstance().getGroupPrefix(player) + "<"
+ getName(player) + vmc.getInstance().getGroupPrefix(player) +"> ";
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 = vmc.getInstance().getGroupPrefix(player) + "<"
+ getName(player) + vmc.getInstance().getGroupPrefix(player) +"> ";
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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,315 +0,0 @@
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,
groupcoloredbrackets = false,
partyChat = 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 player currently toggled for party chat
static ArrayList<String> partyChatList = 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.append("#This plugin is modular\r\n");
writer.append("#Turn any features you don't want to false and they won't be running\r\n");
writer.append("#If you edit this file and save it, then use /reload it will reload the settings\r\n");
writer.append("#Chat Options\r\n");
writer.append("#Group prefix colors apply to player brackets\r\n");
writer.append("groupcoloredbrackets=true\r\n");
writer.append("#Allows the use of color codes following ^ symbol\r\n");
writer.append("ColoredChat=true\r\n");
writer.append("#Require per player permission for quakecolors\r\n");
writer.append("colorsrequirepermissions=false\r\n");
writer.append("#use /coloruse to give players permission if this is enabled\r\n");
writer.append("#Text following a > will be colored green to mimic quoting of popular internet message boards\r\n");
writer.append("QuotesAreGreen=true\r\n");
writer.append("#Turns any chat message starting with FFF automagically blood red\r\n");
writer.append("FFF=true\r\n");
writer.append("\r\n");
writer.append("#Admin Settings\r\n");
writer.append("#Enables or disables players spawning to their home location\r\n");
writer.append("playerspawn=true\r\n");
writer.append("#Enables or disables the admin only chat\r\n");
writer.append("adminchat=true\r\n");
writer.append("#Lets non admins use admin chat if they have the /adminchat command permission\r\n");
writer.append("/adminchat=true\r\n");
writer.append("#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.append("/tp=true\r\n");
writer.append("/tphere=true\r\n");
writer.append("#Mass Tp uses the same concept, anyone with this command only brings those with lower permissions to themselves\r\n");
writer.append("/masstp=true\r\n");
writer.append("\r\n");
writer.append("#Server Settings\r\n");
writer.append("#Enables or Disables the following commands, give groups/users permissions to use these commands for them to work\r\n");
writer.append("/fabulous=true\r\n");
writer.append("/prefix=true\r\n");
writer.append("/freeze=true\r\n");
writer.append("/suffix=true\r\n");
writer.append("/ignore=true\r\n");
writer.append("/colors=true\r\n");
writer.append("/whois=true\r\n");
writer.append("/nick=true\r\n");
writer.append("/who=true\r\n");
writer.append("/promote=true\r\n");
writer.append("/demote=true\r\n");
writer.append("/say=true\r\n");
writer.append("/rules=true\r\n");
writer.append("/suicide=true\r\n");
writer.append("/ezmodo=true\r\n");
writer.append("#Global Messages\r\n");
writer.append("#Enable or Disable sending announcements about sensitive commands to the entire server\r\n");
writer.append("globalmessages=true\r\n");
writer.append("#Adding player names to this list will have them start off in ezmodo\r\n");
writer.append("ezModo=\r\n");
writer.append("#Stop fire from spreading\r\n");
writer.append("stopFire=false\r\n");
writer.append("#Stop lava from spreading fire");
writer.append("lavaspread=false");
writer.append("#Blocks disabled from fire");
writer.append("fireblocks=");
writer.append("\r\n");
writer.append("#Organize your player ranks from lowest to highest.\r\n");
writer.append("ranks=\r\n");
writer.append("#Write the rules to be shown when /rules is used here, it works just like the MOTD does\r\n");
writer.append("rules=Rules@#1: No griefing@#2: No griefing\r\n");
writer.append("#The Random Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n");
writer.append("deathMessages=is no more,died horribly,went peacefully\r\n");
writer.append("#Enable whether or not players can toggle party chat");
writer.append("partychat=true");
writer.append("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 {
groupcoloredbrackets = properties.getBoolean("groupcoloredbrackets",true);
adminChat = properties.getBoolean("adminchat",true);
partyChat = properties.getBoolean("partychat",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 groupcoloredbrackets(){return groupcoloredbrackets;}
public boolean partyChat() {return partyChat;}
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 boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);}
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));}
public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
public void addEzModo(String playerName) {ezModo.add(playerName);}
public void addPartyToggled(String playerName) {partyChatList.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;
}
}

View File

@ -1,212 +0,0 @@
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");
//On console stuff
public boolean onConsoleCommand(String[] split) {
String server = Colors.LightGreen + "[Server]" + Colors.DarkPurple;
if(split[0].equalsIgnoreCase("say"))
{
if(split.length > 1){
String args = " " + etc.combineSplit(1, split, " ");
vChat.gmsg(server + " " + args);
log.log(Level.INFO, "[Server] " + args);
return true;
}
return false;
}
if(split[0].equalsIgnoreCase("stop")){
vChat.gmsg(server + " shutting down the server");
log.log(Level.INFO, "[Server] " + "shutting down the server");
}
return false;
}
//=====================================================================
//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){
if (message.startsWith("@") ||
vConfig.getInstance().isAdminToggled(player.getName()))
return vChat.adminChat(player, message);
//PartyChat
if((message.startsWith("!")) ||
vConfig.getInstance().isPartyToggled(player.getName()))
return vChat.partyChat(player, message);
//Quote (Greentext)
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;
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
//This also checks if the defender is a player
if(defender.isPlayer()){
Player dplayer = defender.getPlayer();
if(vConfig.getInstance().isEzModo(dplayer.getName())){
return true;
}
//So far we've checked if the defender is a player, next we check if the attacker is one
if(attacker != null && attacker.isPlayer()){
//If the attacker is not null and is a player we assign the attacker to a new player variable
Player aplayer = attacker.getPlayer();
//Then we preceed to check if they are in the same party, the code for this is stored elsewhere
if(vUsers.getProfile(dplayer).inParty()){
//If they are in the same party we tell onDamage to return true stopping the damage code from executing
if(aplayer != null && vmc.inSameParty(aplayer, dplayer)){
return true;
//if they aren't we tell it to return false, making the damage happen
} else{
return false;
}
}
else {
return false;
}
}
}
return false;
}
}

View File

@ -1,37 +0,0 @@
import java.util.logging.Logger;
//=====================================================================
//Class: vMinecraftPlugin
//Use: Starts the plugin
//Author: nossr50, TrapAlice, cerevisiae
//=====================================================================
public class vMinecraft extends Plugin {
static final vListener listener = new vListener();
protected static final Logger log = Logger.getLogger("Minecraft");
public void enable() {
vConfig.getInstance().loadSettings();
vUsers.getInstance().loadUsers();
vCom.loadCommands();
vUpdatr.getInstance().createUpdatrFile();
}
public void disable() {
//And remove the commands here.
}
public void initialize() {
//Here we add the hook we're going to use. In this case it's the arm swing event.
etc.getLoader().addListener(PluginLoader.Hook.SERVERCOMMAND, listener, this, PluginListener.Priority.CRITICAL);
etc.getLoader().addListener(PluginLoader.Hook.CHAT, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.LOGIN, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.HIGH);
etc.getLoader().addListener(PluginLoader.Hook.IGNITE, listener, this, PluginListener.Priority.HIGH);
etc.getLoader().addListener(PluginLoader.Hook.DAMAGE, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.EXPLODE, listener, this, PluginListener.Priority.HIGH);
etc.getLoader().addListener(PluginLoader.Hook.LIQUID_DESTROY, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.PLAYER_MOVE, listener, this, PluginListener.Priority.MEDIUM);
}
}

View File

@ -1,48 +0,0 @@
//Thanks to Yogoda for the code!
import java.io.*;
import java.util.logging.*;
public class vUpdatr {
static final String pluginName = "vMinecraft";
static final String version = "0.1";
static final String updatrUrl = "http://dl.dropbox.com/u/18212134/vMinecraft.updatr";
static final String updatrFileUrl = "http://dl.dropbox.com/u/18212134/vMinecraft.jar";
static final String updatrNotes = "Added Updatr support!";
private static volatile vUpdatr instance;
public static Logger logger = Logger.getLogger("Minecraft");
public void createUpdatrFile(){
try {
File updatrDir = new File("Updatr");
//create Updatr directory if it does not exsits already
if(updatrDir.exists()){
File updatrFile = new File("Updatr" + File.separator + pluginName + ".updatr");
//Updatr file does not exist, create it
if(!updatrFile.exists()){
updatrFile.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(updatrFile));
writer.write("name = " + pluginName); writer.newLine();
writer.write("version = " + version); writer.newLine();
writer.write("url = " + updatrUrl); writer.newLine();
writer.write("file = " + updatrFileUrl); writer.newLine();
writer.write("notes = " + updatrNotes); writer.newLine();
writer.close();
}
}
} catch (IOException e) {
vUpdatr.logger.log(Level.SEVERE, null, e);
}
}
public static vUpdatr getInstance(){
if (instance == null){
instance = new vUpdatr();
}
return instance;
}
}

View File

@ -1,633 +0,0 @@
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;}
}
}

View File

@ -1,115 +0,0 @@
import java.io.*;
import java.lang.String;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class vmc {
private static volatile vmc instance;
protected static final Logger log = Logger.getLogger("Minecraft");
private PropertiesFile properties;
String location = "groups.txt";
//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 (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 (getDistance(player, p) < vConfig.range && p.getUser() != player.getUser())
{
p.getUser().a.b(new d(player.getUser()));
}
}
}
public String[] getPartyMembers(Player player){
int x = 0;
String partyarray[] = null;
ArrayList<String> partymembers = new ArrayList<String>();
for(Player p : etc.getServer().getPlayerList()){
if(vmc.inSameParty(player, p) && p != null){
partymembers.add(p.getName());
x++;
}
}
partymembers.toArray(partyarray);
return partyarray;
}
public static void informPartyMembers(Player player){
int x = 0;
for(Player p : etc.getServer().getPlayerList()){
if(vmc.inSameParty(player, p) && !p.getName().equals(player.getName())){
p.sendMessage(vUsers.getProfile(player).getTag() + player.getName() + Colors.Green + " has joined your party");
x++;
}
}
}
public static void informPartyMembersQuit(Player player){
int x = 0;
for(Player p : etc.getServer().getPlayerList()){
if(vmc.inSameParty(player, p) && !p.getName().equals(player.getName())){
p.sendMessage(vUsers.getProfile(player).getTag() + player.getName() + Colors.Green + " has left your party");
x++;
}
}
}
public String getGroupPrefix(Player player){
String groups[] = player.getGroups();
String groupline[] = null;
String prefix = Colors.White;
int x = 0;
if(groups.length == 0 || groups == null)
return prefix;
if(vConfig.getInstance().groupcoloredbrackets()){
//Read the file
properties = new PropertiesFile(location);
try {
properties.load();
} catch (IOException e) {
log.log(Level.SEVERE, "Exception while loading " + location, e);
}
//Grab the line with the same group as the player
for(String herp : groups){
if(herp != null)
x++;
}
if(x > 0)
groupline = properties.getString(groups[0]).split(":");
//Check if the prefix is null or not
if(!groupline[0].isEmpty() && groupline != null)
{
//vChat.colorChange(groupline[0].charAt(0));
prefix = groupline[0];
prefix = vChat.colorChange(prefix.charAt(0));
}
}
return prefix;
}
public static vmc getInstance() {
if (instance == null) {
instance = new vmc();
}
return instance;
}
}

View File

@ -10,12 +10,9 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.*; import com.gmail.nossr50.skills.*;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
import com.nijiko.permissions.PermissionHandler;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
@ -49,13 +46,13 @@ public class mcMMO extends JavaPlugin
* Donate via paypal to nossr50@gmail.com (A million thanks to anyone that does!) * Donate via paypal to nossr50@gmail.com (A million thanks to anyone that does!)
*/ */
public static String maindirectory = "plugins/mcMMO/"; public static String maindirectory = "plugins + File.separator + mcMMO";
File file = new File(maindirectory + File.separator + "config.yml"); File file = new File(maindirectory + File.separator + "config.yml");
public static final Logger log = Logger.getLogger("Minecraft"); public static final Logger log = Logger.getLogger("Minecraft");
private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcPlayerListener playerListener = new mcPlayerListener(this);
private final mcBlockListener blockListener = new mcBlockListener(this); private final mcBlockListener blockListener = new mcBlockListener(this);
private final mcEntityListener entityListener = new mcEntityListener(this); private final mcEntityListener entityListener = new mcEntityListener(this);
public static PermissionHandler permissionHandler; public static mcPermissions permissionHandler = new mcPermissions();
private Permissions permissions; private Permissions permissions;
private Timer mcMMO_Timer = new Timer(true); //BLEED AND REGENERATION private Timer mcMMO_Timer = new Timer(true); //BLEED AND REGENERATION
@ -71,9 +68,9 @@ public class mcMMO extends JavaPlugin
public void onEnable() public void onEnable()
{ {
//new File(maindirectory).mkdir(); new File(maindirectory).mkdir();
setupPermissions(); mcPermissions.initialize(getServer());
config.configCheck(); config.configCheck();
if(!LoadProperties.useMySQL) if(!LoadProperties.useMySQL)
@ -121,25 +118,6 @@ public class mcMMO extends JavaPlugin
//mcMMO_SpellTimer.schedule(new mcTimerSpells(this), (long)0, (long)(100)); //mcMMO_SpellTimer.schedule(new mcTimerSpells(this), (long)0, (long)(100));
} }
private void setupPermissions()
{
if (permissionHandler != null)
{
return;
}
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
if (permissionsPlugin == null)
{
//log.log(Level.INFO, "[mcMMO] Permission system not detected, defaulting to OP");
return;
}
permissionHandler = ((Permissions) permissionsPlugin).getHandler();
//log.log(Level.INFO, "[mcMMO] Found and will use plugin "+((Permissions)permissionsPlugin).getDescription().getFullName());
}
public boolean inSameParty(Player playera, Player playerb){ public boolean inSameParty(Player playera, Player playerb){
if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()){ if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()){
if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())){ if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())){

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50; package com.gmail.nossr50;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Server; import org.bukkit.Server;
@ -15,39 +14,39 @@ import com.nijikokun.bukkit.Permissions.Permissions;
public class mcPermissions public class mcPermissions
{ {
private enum PermissionType {
PEX, PERMISSIONS, BUKKIT
}
private static PermissionType permissionType;
private static Object PHandle;
public static boolean permissionsEnabled = false;
private static volatile mcPermissions instance; private static volatile mcPermissions instance;
private enum PermissionType {
PEX, PERMISSIONS, BUKKIT
}
private static PermissionType permissionType;
private static Object PHandle;
public static boolean permissionsEnabled = false;
public static void initialize(Server server) public static void initialize(Server server)
{ {
Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx");
Plugin test = server.getPluginManager().getPlugin("Permissions");
Logger log = Logger.getLogger("Minecraft"); Logger log = Logger.getLogger("Minecraft");
if (PEXtest != null) {
PHandle = (PermissionManager) PermissionsEx.getPermissionManager(); if(permissionsEnabled && permissionType != PermissionType.PERMISSIONS) return;
permissionType = PermissionType.PEX;
permissionsEnabled = true; Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx");
log.log(Level.INFO, "[mcMMO] PermissionsEx enabled."); Plugin test = server.getPluginManager().getPlugin("Permissions");
} else if (test != null) { if(PEXtest != null) {
PHandle = (PermissionHandler) ((Permissions) test).getHandler(); PHandle = (PermissionManager) PermissionsEx.getPermissionManager();
permissionType = PermissionType.PERMISSIONS; permissionType = PermissionType.PEX;
permissionsEnabled = true; permissionsEnabled = true;
log.log(Level.INFO, "[mcMMO] Permissions "+test.getDescription().getVersion()+" enabled."); log.info("[mcMMO] PermissionsEx found, using PermissionsEx.");
} else } else if(test != null) {
{ PHandle = (PermissionHandler) ((Permissions) test).getHandler();
log.log(Level.SEVERE, "[mcMMO] Permissions isn't loaded, there are no restrictions."); permissionType = PermissionType.PERMISSIONS;
/* permissionsEnabled = true;
permissionType = PermissionType.BUKKIT; log.info("[mcMMO] Permissions version "+test.getDescription().getVersion()+" found, using Permissions.");
permissionsEnabled = true; } else {
log.info("[mcMMO] Using Bukkit Permissions.") permissionType = PermissionType.BUKKIT;
*/ permissionsEnabled = true;
} log.info("[mcMMO] Using Bukkit Permissions.");
}
} }
public static boolean getEnabled() public static boolean getEnabled()
@ -55,19 +54,20 @@ public class mcPermissions
return permissionsEnabled; return permissionsEnabled;
} }
private static boolean permission(Player player, String string) private static boolean permission(Player player, String permission)
{ {
switch (permissionType) { if(!permissionsEnabled) return player.isOp();
case PEX: switch(permissionType) {
return ((PermissionManager) PHandle).has(player, string); case PEX:
case PERMISSIONS: return ((PermissionManager) PHandle).has(player, permission);
return ((PermissionHandler) PHandle).has(player, string); case PERMISSIONS:
case BUKKIT: return ((PermissionHandler) PHandle).has(player, permission);
//return player.hasPermission(string); case BUKKIT:
default: return player.hasPermission(permission);
return true; default:
} return true;
} }
}
public boolean admin(Player player){ public boolean admin(Player player){
if (permissionsEnabled) { if (permissionsEnabled) {
return permission(player, "mcmmo.admin"); return permission(player, "mcmmo.admin");

View File

@ -64,3 +64,166 @@ commands:
description: Toggle Admin chat or send admin chat messages description: Toggle Admin chat or send admin chat messages
sorcery: sorcery:
description: Detailed skill info description: Detailed skill info
permissions:
mcmmo.*:
description: Implies all mcmmo permissions.
children:
mcmmo.admin: true
mcmmo.tools.*: true
mcmmo.ability.*: true
mcmmo.item.*: true
mcmmo.tools.*: true
mcmmo.regeneration: true
mcmmo.motd: true
mcmmo.commands.*: true
mcmmo.chat.*: true
mcmmo.skills.*: true
mcmmo.admin:
default: op
mcmmo.tools.*:
description: Implies all mcmmo.tools permissions.
children:
mcmmo.tools.mcrefresh: true
mcmmo.tools.mmoedit: true
mcmmo.tools.mcgod: true
mcmmo.tools.mcrefresh:
default: op
mcmmo.tools.mmoedit:
default: op
mcmmo.tools.mcgod:
default: op
mcmmo.ability.*:
description: Implies all mcmmo.ability permissions.
children:
mcmmo.ability.herbalism: true
mcmmo.ability.excavation: true
mcmmo.ability.unarmed: true
mcmmo.ability.mining: true
mcmmo.ability.axes: true
mcmmo.ability.swords: true
mcmmo.ability.woodcutting: true
mcmmo.ability.herbalism:
default: true
mcmmo.ability.excavation:
default: true
mcmmo.ability.unarmed:
default: true
mcmmo.ability.mining:
default: true
mcmmo.ability.axes:
default: true
mcmmo.ability.swords:
default: true
mcmmo.ability.woodcutting:
default: true
mcmmo.item.*:
description: Implies all mcmmo.item permissions.
children:
mcmmo.item.chimaerawing: true
mcmmo.item.chimaerawing:
default: true
mcmmo.regeneration:
default: true
mcmmo.motd:
default: true
mcmmo.commands.*:
description: Implies all mcmmo.commands permissions.
children:
mcmmo.commands.ability: true
mcmmo.commands.myspawn: true
mcmmo.commands.setmyspawn: true
mcmmo.commands.ptp: true
mcmmo.commands.whois: true
mcmmo.commands.party: true
mcmmo.commands.ability:
default: true
mcmmo.commands.myspawn:
default: true
mcmmo.commands.setmyspawn:
default: true
mcmmo.commands.ptp:
default: true
mcmmo.commands.whois:
default: true
mcmmo.commands.party:
default: true
mcmmo.chat.*:
description: Implies all mcmmo.chat permissions. (Warning, contains adminchat)
children:
mcmmo.chat.adminchat: true
mcmmo.chat.partychat: true
mcmmo.chat.adminchat:
default: op
mcmmo.chat.partychat:
default: true
mcmmo.skills.*:
description: Implies all mcmmo.skills permissions.
children:
mcmmo.skills.sorcery.*: true
mcmmo.skills.curative.*: true
mcmmo.skills.taming: true
mcmmo.skills.mining: true
mcmmo.skills.woodcutting: true
mcmmo.skills.repair: true
mcmmo.skills.unarmed: true
mcmmo.skills.archery: true
mcmmo.skills.herbalism: true
mcmmo.skills.excavation: true
mcmmo.skills.swords: true
mcmmo.skills.axes: true
mcmmo.skills.acrobatics: true
mcmmo.skills.sorcery.*:
description: Implies all mcmmo.skills.sorcery permissions.
children:
mcmmo.skills.sorcery: true
mcmmo.skills.sorcery.water: true
mcmmo.skills.sorcery.water.thunder: true
mcmmo.skills.curative.*:
description: Implies all mcmmo.skills.curative permissions.
children:
mcmmo.skills.curative: true
mcmmo.skills.curative.heal.other: true
mcmmo.skills.curative.heal.self: true
mcmmo.skills.sorcery:
default: true
mcmmo.skills.sorcery.water:
default: true
mcmmo.skills.sorcery.water.thunder:
default: true
mcmmo.skills.curative:
default: true
mcmmo.skills.curative.heal.other:
default: true
mcmmo.skills.curative.heal.self:
default: true
mcmmo.skills.taming:
default: true
mcmmo.skills.mining:
default: true
mcmmo.skills.woodcutting:
default: true
mcmmo.skills.repair:
default: true
mcmmo.skills.unarmed:
default: true
mcmmo.skills.archery:
default: true
mcmmo.skills.herbalism:
default: true
mcmmo.skills.excavation:
default: true
mcmmo.skills.swords:
default: true
mcmmo.skills.axes:
default: true
mcmmo.skills.acrobatics:
default: true

View File

@ -1,42 +0,0 @@
package com.bukkit.nossr50.vChat;
import java.io.File;
import java.util.HashMap;
import org.bukkit.entity.Player;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
/**
* vChat for Bukkit
*
* @author nossr50
* @author cerevisae
*/
public class vChat extends JavaPlugin {
private final vPlayerListener playerListener = new vPlayerListener(this);
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
public vChat(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
super(pluginLoader, instance, desc, folder, plugin, cLoader);
}
public void onEnable() {
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
//Load the users file
vUsers.getInstance().loadUsers();
}
public void onDisable() {
System.out.println("vChat Disabled!");
}
}

View File

@ -1,537 +0,0 @@
package com.bukkit.nossr50.vChat;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handle events for all Player related events
* @author nossr50
*/
public class vPlayerListener extends PlayerListener {
private final vChat plugin;
protected static final Logger log = Logger.getLogger("Minecraft");
//The length of a text box line in pixels
protected static final int lineLength = 312;
//Characters we will split the line at
protected static final String lineSplit = "/- ";
public vPlayerListener(vChat instance) {
plugin = instance;
}
public void onPlayerJoin(PlayerEvent event) {
Player player = event.getPlayer();
vUsers.addUser(player);
}
//Special Color Codes
protected static final String[] rainbow = new String[] {
ChatColor.DARK_RED.toString(),
ChatColor.RED.toString(),
ChatColor.GOLD.toString(),
ChatColor.YELLOW.toString(),
ChatColor.GREEN.toString(),
ChatColor.DARK_GREEN.toString(),
ChatColor.BLUE.toString(),
ChatColor.DARK_BLUE.toString(),
ChatColor.AQUA.toString(),
ChatColor.DARK_AQUA.toString(),
ChatColor.DARK_PURPLE.toString(),
ChatColor.LIGHT_PURPLE.toString()
};
protected static final String[] xmas = new String[] {
ChatColor.DARK_RED.toString(),
ChatColor.DARK_RED.toString(),
ChatColor.WHITE.toString(),
ChatColor.WHITE.toString(),
ChatColor.DARK_GREEN.toString(),
ChatColor.DARK_GREEN.toString(),
};
public void onPlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
String split[] = event.getMessage().split(" ");
event.setCancelled(true);
Player[] players = plugin.getServer().getOnlinePlayers();
//Quotes
if(split[0].startsWith(">"))
quote(player, message, players);
else{
quakeColors(player, message, players);
}
}
//=====================================================================
//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 void quakeColors(Player player, String message, Player[] players)
{
//Format the name
String playerName = "<"
+ player.getName() + "> ";
//String color = vUsers.getProfile(player).getColor();
//Log the chat
log.log(Level.INFO, "<"+player.getName()+"> " + message);
//Output the message
gmsg(player, playerName + message, players);
//Loop through the string finding the color codes and inserting them
}
//=====================================================================
//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, Player[] players){
/* Disabled for now
if(sender != null && sender.isMuted())
sender.sendMessage(ChatColor.DARK_RED + "You have been muted.");
*/
for (Player receiver : players) {
if (receiver == null) return;
//if(vUsers.getProfile(receiver) == null) return;
//Check if the person has the sender ignored
/* Disabled for now
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, null);}
public static void gmsg(Player player, String msg){gmsg(player, msg, null);}
//=====================================================================
//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(combineSplit(words.toArray(new String[words.size()]), " ") + " " );
}
//Convert to an array and return
return out.toArray(new String[out.size()]);
}
//CombineSplit
public static String combineSplit(String[] array, String merge) {
String out = "";
for(String word : array)
out += word + merge;
return out;
}
//=====================================================================
//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((x+1 <= str.length()) && (str.charAt(x) == '^' || str.charAt(x) == ChatColor.WHITE.toString().charAt(0)))
{
if(colorChange(str.charAt(x + 1)) != null)
{
x++;
continue;
}
}
int len = charLength(str.charAt(x));
length += len;
}
return length;
}
//=====================================================================
//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 = ChatColor.BLACK.toString();
break;
case '1':
color = ChatColor.DARK_BLUE.toString();
break;
case '2':
color = ChatColor.DARK_GREEN.toString();
break;
case '3':
color = ChatColor.DARK_AQUA.toString();
break;
case '4':
color = ChatColor.DARK_RED.toString();
break;
case '5':
color = ChatColor.DARK_PURPLE.toString();
break;
case '6':
color = ChatColor.GOLD.toString();
break;
case '7':
color = ChatColor.GRAY.toString();
break;
case '8':
color = ChatColor.DARK_GRAY.toString();
break;
case '9':
color = ChatColor.BLUE.toString();
break;
case 'a':
color = ChatColor.GREEN.toString();
break;
case 'b':
color = ChatColor.AQUA.toString();
break;
case 'c':
color = ChatColor.RED.toString();
break;
case 'd':
color = ChatColor.LIGHT_PURPLE.toString();
break;
case 'e':
color = ChatColor.YELLOW.toString();
break;
case 'f':
color = ChatColor.WHITE.toString();
break;
case 'A':
color = ChatColor.GREEN.toString();
break;
case 'B':
color = ChatColor.AQUA.toString();
break;
case 'C':
color = ChatColor.RED.toString();
break;
case 'D':
color = ChatColor.LIGHT_PURPLE.toString();
break;
case 'E':
color = ChatColor.YELLOW.toString();
break;
case 'F':
color = ChatColor.WHITE.toString();
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;
}
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;
}
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: 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 void quote(Player player, String message, Player[] players)
{
//Format the name
String playerName = ChatColor.WHITE + "<" + player.getName() + "> ";
//Log the chat
log.log(Level.INFO, "<"+player.getName()+"> " + message);
//Output the message
gmsg(player, playerName + ChatColor.GREEN + message, players);
}
//=====================================================================
//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 = ChatColor.WHITE.toString();
//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.equals("^x") && 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
if(taste || msg.charAt(x) == '^'
|| msg.charAt(x) == ChatColor.DARK_RED.toString().charAt(0))
{
if(x != msg.length() - 1)
{
//If the following character is a color code
if(colorChange(msg.charAt(x+1)) != null)
{
//Set the most recent color to the new color
recentColor = 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) != ChatColor.DARK_RED.toString().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) == '^'
/* Not sure what this check is for
* || x < msg.length() && msg.charAt(x) == ChatColor.DARK_RED.toString().charAt(0)*/)
{
taste = false;
i = 0;
x--;
}
}
if(xmasparty || recentColor.equals("^x"))
{
//Skip the quake code for xmas
if(recentColor.equals("^x"))
{
x += 2;
}
//xmasparty 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) != ChatColor.DARK_RED.toString().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) == ChatColor.DARK_RED.toString().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;
}
}

View File

@ -1,552 +0,0 @@
package com.bukkit.nossr50.vChat;
import java.io.*;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.entity.*;
public class vUsers {
private static volatile vUsers instance;
protected static final Logger log = Logger.getLogger("Minecraft");
String location = "vChat.users";
public static PlayerList players = new PlayerList();
private Properties properties = new Properties();
//To load
public void load() throws IOException {
properties.load(new FileInputStream(location));
}
//To save
public void save() {
try {
properties.store(new FileOutputStream(location), null);
}catch(IOException ex) {
}
}
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 {
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;
private boolean dead,
silent;
char defaultColor;
String location = "vChat.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();
party = new String();
party = null;
defaultColor = 'f';
ignoreList = new ArrayList<String>();
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);
}
}
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("\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.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: 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: 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 vPlayerListener.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)
//We need the bukkit equivalent of this
//return 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;}
}
}

View File

@ -1,37 +0,0 @@
package com.gmail.nossr50.vChat;
import java.io.File;
import java.util.HashMap;
import org.bukkit.entity.Player;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
/**
* vChat for Bukkit
*
* @author nossr50
* @author cerevisae
*/
public class vChat extends JavaPlugin {
private final vPlayerListener playerListener = new vPlayerListener(this);
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
public void onEnable() {
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
//Load the users file
vUsers.getInstance().loadUsers();
}
public void onDisable() {
System.out.println("vChat Disabled!");
}
}

View File

@ -1,707 +0,0 @@
package com.gmail.nossr50.vChat;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.gmail.nossr50.mcConfig;
import com.gmail.nossr50.mcMMO;
/**
* Handle events for all Player related events
* @author nossr50
*/
public class vPlayerListener extends PlayerListener {
private final vChat plugin;
protected static final Logger log = Logger.getLogger("Minecraft");
//The length of a text box line in pixels
protected static final int lineLength = 312;
//Characters we will split the line at
protected static final String lineSplit = "/- ";
public vPlayerListener(vChat instance) {
plugin = instance;
}
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
vUsers.addUser(player);
player.sendMessage(ChatColor.YELLOW+"This server is running vChat");
player.sendMessage(ChatColor.YELLOW+"Type /color or /prefix to do some thangs");
player.sendMessage(ChatColor.DARK_AQUA+"Currently running in Linux");
player.sendMessage(ChatColor.DARK_AQUA+"Steam community: vminecraft");
}
public Boolean isPlayer(String playername){
for(Player derp : plugin.getServer().getOnlinePlayers()){
if(derp.getName().toLowerCase().equals(playername.toLowerCase())){
return true;
}
}
return false;
}
//Special Color Codes
protected static final String[] rainbow = new String[] {
ChatColor.DARK_RED.toString(),
ChatColor.RED.toString(),
ChatColor.GOLD.toString(),
ChatColor.YELLOW.toString(),
ChatColor.GREEN.toString(),
ChatColor.DARK_GREEN.toString(),
ChatColor.BLUE.toString(),
ChatColor.DARK_BLUE.toString(),
ChatColor.AQUA.toString(),
ChatColor.DARK_AQUA.toString(),
ChatColor.DARK_PURPLE.toString(),
ChatColor.LIGHT_PURPLE.toString()
};
protected static final String[] xmas = new String[] {
ChatColor.DARK_RED.toString(),
ChatColor.DARK_RED.toString(),
ChatColor.WHITE.toString(),
ChatColor.WHITE.toString(),
ChatColor.DARK_GREEN.toString(),
ChatColor.DARK_GREEN.toString(),
};
public void onPlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
String split[] = event.getMessage().split(" ");
Player[] players = plugin.getServer().getOnlinePlayers();
Plugin tester = plugin.getServer().getPluginManager().getPlugin("mcMMO");
if (tester == null) {
} else {
try {
mcMMO plugin = (mcMMO)tester;
if (plugin.isPartyChatToggled(player) || plugin.isAdminChatToggled(player)) {
return;
} else {
if(split[0].startsWith(">"))
quote(player, message, players);
else{
quakeColors(player, message, players);
}
}
} catch (ClassCastException ex) {
player.sendMessage("There's a plugin disguised as mcMMO! It's not the one I was expecting!");
}
}
event.setCancelled(true);
}
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
String split[] = event.getMessage().split(" ");
/*
* COLORS
*/
if(split[0].equalsIgnoreCase("/color")){
event.setCancelled(true);
if(split.length > 1)
{
vUsers.getProfile(player).setColor(split[1]);
player.sendMessage(ChatColor.RED
+ "Default chat color set.");
} else {
player.sendMessage(ChatColor.RED + "You use these color codes like in quake or MW2.");
player.sendMessage(ChatColor.RED + "^4 would make text " + ChatColor.DARK_RED
+ "red" + ChatColor.RED + ", ^a would make it " + ChatColor.GREEN
+ "light green" + ChatColor.RED + ".");
player.sendMessage(
ChatColor.BLACK + "0"
+ ChatColor.DARK_BLUE + "1"
+ ChatColor.DARK_GREEN + "2"
+ ChatColor.DARK_AQUA + "3"
+ ChatColor.DARK_RED + "4"
+ ChatColor.DARK_PURPLE + "5"
+ ChatColor.GOLD + "6"
+ ChatColor.GRAY + "7"
+ ChatColor.DARK_GRAY + "8"
+ ChatColor.BLUE + "9"
+ ChatColor.GREEN + "A"
+ ChatColor.AQUA + "B"
+ ChatColor.RED + "C"
+ ChatColor.LIGHT_PURPLE + "D"
+ ChatColor.YELLOW + "E"
+ ChatColor.WHITE + "F");
//+ "^r" + "[R]ainbow")
}
event.setCancelled(true);
}
/*
* PREFIX
*/
if(split[0].equalsIgnoreCase("/prefix")){
event.setCancelled(true);
if(split.length < 3 && player.isOp()){
player.sendMessage( ChatColor.RED + "Usage is /prefix [Player] [Color Code] <Tag>");
player.sendMessage(ChatColor.RED + "Example: /prefix " + player.getName() + " e ^0[^a<3^0]");
player.sendMessage( ChatColor.RED + "This would produce a name like... " + ChatColor.BLACK + "[" + ChatColor.GREEN + "<3" +ChatColor.BLACK + "]" + ChatColor.YELLOW + player.getName());
return;
}
if(player.isOp()){
//Check if the player exists
Player other = plugin.getServer().getPlayer(split[1]);
if(other == null)
{
player.sendMessage( ChatColor.RED
+ "The player you specified could not be found");
return;
}
if(split.length >= 3 && split[2] != null)
{
vUsers.getProfile(other).setPrefix(split[2]);
player.sendMessage(ChatColor.RED + "Name color changed");
}
if(split.length >= 4 && msgLength(split[3]) > 60)
{
player.sendMessage( ChatColor.RED
+ "The prefix you entered was too long.");
return;
}
if(split.length >= 4 && split[3] != null)
{
vUsers.players.findProfile(other).setTag(split[3]);
player.sendMessage(ChatColor.GREEN + "Prefix changed");
log.log(Level.INFO, player + " changed their prefix to " + split[3]);
}
return;
}
if(split.length < 2){
player.sendMessage( ChatColor.RED + "Usage is /prefix [Color Code] <Tag>");
player.sendMessage(ChatColor.RED + "Example: /prefix " + player.getName() + " e ^0[^a<3^0]");
player.sendMessage( ChatColor.RED + "This would produce a name like... " + ChatColor.BLACK + "[" + ChatColor.GREEN + "<3" + ChatColor.BLACK + "]" + ChatColor.YELLOW + player.getName());
return;
}
//Name color
if(split.length >= 2 && split[1] != null){
vUsers.getProfile(player).setPrefix(split[1]);
player.sendMessage(ChatColor.RED + "Name color changed");
}
//Prefix
if(split.length >= 3 && split[2] != null){
//Check if the prefix is too long
if(msgLength(split[1]) > 60)
{
player.sendMessage( ChatColor.RED
+ "The prefix you entered was too long.");
return;
}
vUsers.players.findProfile(player).setTag(split[2]);
player.sendMessage(ChatColor.GREEN + "Prefix changed");
}
}
/*
* SUFFIX
*/
if(split[0].equalsIgnoreCase("/suffix")){
event.setCancelled(true);
}
if(split[0].equalsIgnoreCase("/rprefix")){
if(!player.isOp()){
player.sendMessage("Op Only");
}
if(split.length < 2){
player.sendMessage("Usage is /rprefix <name>");
return;
}
if(isPlayer(split[1])){
Player target = plugin.getServer().getPlayer(split[1]);
vUsers.getProfile(target).setPrefix("");
vUsers.getProfile(target).setTag("");
}
}
}
//=====================================================================
//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 void quakeColors(Player player, String message, Player[] players)
{
//Format the name
String playerName = "<"
//Insert their tag
+ vUsers.getProfile(player).getTag()
//Color their name
+ colorChange(vUsers.getProfile(player).getPrefix().charAt(0))
//Insert their name
+ player.getName() +ChatColor.WHITE+ "> ";
String color = vUsers.getProfile(player).getColor();
//Log the chat
log.log(Level.INFO, "<"+player.getName()+"> " + message);
//Output the message
gmsg(player, playerName + color + message, players);
//Loop through the string finding the color codes and inserting them
}
//=====================================================================
//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, Player[] players){
/* Disabled for now
if(sender != null && sender.isMuted())
sender.sendMessage(ChatColor.DARK_RED + "You have been muted.");
*/
for (Player receiver : players) {
if (receiver == null) return;
//if(vUsers.getProfile(receiver) == null) return;
//Check if the person has the sender ignored
/* Disabled for now
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, null);}
public static void gmsg(Player player, String msg){gmsg(player, msg, null);}
//=====================================================================
//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(combineSplit(words.toArray(new String[words.size()]), " ") + " " );
}
//Convert to an array and return
return out.toArray(new String[out.size()]);
}
//CombineSplit
public static String combineSplit(String[] array, String merge) {
String out = "";
for(String word : array)
out += word + merge;
return out;
}
//=====================================================================
//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((x+1 <= str.length()) && (str.charAt(x) == '^' || str.charAt(x) == ChatColor.WHITE.toString().charAt(0)))
{
if(colorChange(str.charAt(x + 1)) != null)
{
x++;
continue;
}
}
int len = charLength(str.charAt(x));
length += len;
}
return length;
}
//=====================================================================
//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 = ChatColor.BLACK.toString();
break;
case '1':
color = ChatColor.DARK_BLUE.toString();
break;
case '2':
color = ChatColor.DARK_GREEN.toString();
break;
case '3':
color = ChatColor.DARK_AQUA.toString();
break;
case '4':
color = ChatColor.DARK_RED.toString();
break;
case '5':
color = ChatColor.DARK_PURPLE.toString();
break;
case '6':
color = ChatColor.GOLD.toString();
break;
case '7':
color = ChatColor.GRAY.toString();
break;
case '8':
color = ChatColor.DARK_GRAY.toString();
break;
case '9':
color = ChatColor.BLUE.toString();
break;
case 'a':
color = ChatColor.GREEN.toString();
break;
case 'b':
color = ChatColor.AQUA.toString();
break;
case 'c':
color = ChatColor.RED.toString();
break;
case 'd':
color = ChatColor.LIGHT_PURPLE.toString();
break;
case 'e':
color = ChatColor.YELLOW.toString();
break;
case 'f':
color = ChatColor.WHITE.toString();
break;
case 'A':
color = ChatColor.GREEN.toString();
break;
case 'B':
color = ChatColor.AQUA.toString();
break;
case 'C':
color = ChatColor.RED.toString();
break;
case 'D':
color = ChatColor.LIGHT_PURPLE.toString();
break;
case 'E':
color = ChatColor.YELLOW.toString();
break;
case 'F':
color = ChatColor.WHITE.toString();
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;
}
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;
}
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: 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 void quote(Player player, String message, Player[] players)
{
//Format the name
//Format the name
String playerName = "<"+
//Insert their tag
vUsers.getProfile(player).getTag()
//Color their name
+ colorChange(vUsers.getProfile(player).getPrefix().charAt(0))
//Insert their name
+ player.getName() +ChatColor.WHITE+ "> ";
//Log the chat
log.log(Level.INFO, "<"+player.getName()+"> " + message);
//Output the message
gmsg(player, playerName + ChatColor.GREEN + message, players);
}
//=====================================================================
//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 = ChatColor.WHITE.toString();
//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.equals("^x") && 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
if(taste || msg.charAt(x) == '^'
|| msg.charAt(x) == ChatColor.DARK_RED.toString().charAt(0))
{
if(x != msg.length() - 1)
{
//If the following character is a color code
if(colorChange(msg.charAt(x+1)) != null)
{
//Set the most recent color to the new color
recentColor = 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) != ChatColor.DARK_RED.toString().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) == '^')
{
taste = false;
i = 0;
x--;
}
*/
}
if(xmasparty || recentColor.equals("^x"))
{
/*
//Skip the quake code for xmas
if(recentColor.equals("^x"))
{
x += 2;
}
//xmasparty 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) != ChatColor.DARK_RED.toString().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) == ChatColor.DARK_RED.toString().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;
}
}

View File

@ -1,570 +0,0 @@
package com.gmail.nossr50.vChat;
import java.io.*;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.entity.*;
public class vUsers {
private static volatile vUsers instance;
protected static final Logger log = Logger.getLogger("Minecraft");
String location = "vChat.users";
public static PlayerList players = new PlayerList();
private Properties properties = new Properties();
//To load
public void load() throws IOException {
properties.load(new FileInputStream(location));
}
//To save
public void save() {
try {
properties.store(new FileOutputStream(location), null);
}catch(IOException ex) {
}
}
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 {
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,
prefix,
party;
private boolean dead,
silent;
char defaultColor;
String location = "vChat.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();
prefix = new String();
party = new String();
party = null;
defaultColor = 'f';
ignoreList = new ArrayList<String>();
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);
}
}
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 + ":");
writer.append(prefix + ":");
int i = 0;
for(String ignore : ignoreList)
{
writer.append(ignore);
if(i < ignoreList.size() - 1)
writer.append(",");
}
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("" + ":");
out.append(nickName + ":");
out.append(suffix + ":");
out.append("f" + ":");
out.append("f" + ":");
int i = 0;
for(String ignore : ignoreList)
{
out.append(ignore);
if(i < ignoreList.size() - 1)
out.append(",");
}
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: 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: 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; }
public void setPrefix(String newPrefix)
{
prefix = newPrefix;
save();
}
public String getPrefix() {
if(prefix != null && !prefix.equals("") && !prefix.equals("null")){
return prefix;
} else {
return "f";
}
}
//=====================================================================
//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 vPlayerListener.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)
//We need the bukkit equivalent of this
//return 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;}
}
}

View File

@ -1,3 +0,0 @@
name: vChat
main: com.gmail.nossr50.vChat.vChat
version: 1.0

View File

@ -1,22 +0,0 @@
package com.bukkit.nossr50.vPlayersOnline;
import org.bukkit.Material;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
/**
* vPlayersOnline block listener
* @author nossr50
*/
public class vBlockListener extends BlockListener {
private final vPlayersOnline plugin;
public vBlockListener(final vPlayersOnline plugin) {
this.plugin = plugin;
}
//put all Block related code here
}

View File

@ -1,62 +0,0 @@
package com.bukkit.nossr50.vPlayersOnline;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.ChatColor;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handle events for all Player related events
* @author nossr50
*/
public class vPlayerListener extends PlayerListener {
private final vPlayersOnline plugin;
protected static final Logger log = Logger.getLogger("Minecraft");
public vPlayerListener(vPlayersOnline instance) {
plugin = instance;
}
//Function to count the players
public int playerCount(){
Player players[] = plugin.getServer().getOnlinePlayers();
int x = 0;
for(Player hurrdurr: players){
x++;
}
return x;
}
//Message to be sent when a player joins
public void onPlayerJoin(PlayerEvent event) {
Player player = event.getPlayer();
//English Version
player.sendMessage(ChatColor.GREEN + "There are " + playerCount() + " players online.");
}
//Message to be sent when a player uses /list
public void onPlayerCommand(PlayerChatEvent event) {
String[] split = event.getMessage().split(" ");
Player player = event.getPlayer();
if(split[0].equalsIgnoreCase("/list") || split[0].equalsIgnoreCase("/who")){
event.setCancelled(true);
String tempList = "";
int x = 0;
for(Player p : plugin.getServer().getOnlinePlayers())
{
if(p != null && x+1 == playerCount()){
tempList+= p.getName();
x++;
}
if(p != null && x < playerCount()){
tempList+= p.getName() +", ";
x++;
}
}
//Output the player list
player.sendMessage(ChatColor.RED + "Player List ("+ChatColor.WHITE + tempList +ChatColor.RED+")");
player.sendMessage(ChatColor.RED + "Total Players: " + ChatColor.GREEN + playerCount());
}
}
}

View File

@ -1,44 +0,0 @@
package com.bukkit.nossr50.vPlayersOnline;
import java.io.File;
import java.util.HashMap;
import org.bukkit.event.player.*;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.entity.Player;
/**
* vPlayersOnline for Bukkit
*
* @author nossr50
*/
public class vPlayersOnline extends JavaPlugin {
private final vPlayerListener playerListener = new vPlayerListener(this);
private final vBlockListener blockListener = new vBlockListener(this);
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
private final String name = "vPlayersOnline";
public vPlayersOnline(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
super(pluginLoader, instance, desc, folder, plugin, cLoader);
}
public void onEnable() {
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
//Displays a message when plugin is loaded
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
}
public void onDisable() {
System.out.println("vPlayersOnline disabled.");
}
}

View File

@ -1,78 +0,0 @@
package com.gmail.nossr50.vPlayersOnline;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
/**
*
* @author Mark Tolley
*/
class Config
{
public static String name;
private static final String CONFIG_FILE = "plugins/vPlayersOnline/vplayersonline.properties";
public static Properties loadConfig() {
Properties config = defaultConfig();
try {
config.load(new FileReader(CONFIG_FILE));
}
catch (FileNotFoundException e) {
System.out.println(name + ": Creating configuration file...");
config = defaultConfig();
writeConfig();
}
catch (IOException e) {
System.out.println(name + "s: An error occured reading configuration, using defaults.");
config = defaultConfig();
}
return config;
}
private static void writeConfig() {
File f = new File(CONFIG_FILE);
if (f.getParentFile().mkdirs()) {
try {
FileWriter fw = new FileWriter(f);
fw.write("# vPlayersOnline configuration file\r\n");
fw.write("# \r\n");
fw.write("# Color codes:\r\n");
fw.write("# &0 black\r\n");
fw.write("# &1 dark blue &9 blue\r\n");
fw.write("# &2 dark green &a green\r\n");
fw.write("# &3 dark aqua &b aqua\r\n");
fw.write("# &4 dark red &c red\r\n");
fw.write("# &5 dark pink &d pink\r\n");
fw.write("# &6 dark yellow &e yellow\r\n");
fw.write("# &7 light grey &f white\r\n");
fw.write("# &8 dark grey\r\n");
fw.write("\r\n");
fw.write("PlayersOnline = &aThere are %d players online\r\n");
fw.write("PlayerList = &cPlayer List &f(%s)\r\n");
fw.write("TotalPlayers = &cTotal Players: &a%d\r\n");
fw.write("#1POnline = &aThere is 1 player online.\r\n");
fw.write("1POnline = &cNo one else is online.\r\n");
fw.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
private static Properties defaultConfig() {
Properties config = new Properties();
config.setProperty("PlayersOnline", "&aThere are %d players online");
config.setProperty("PlayerList", "&cPlayer List &f(%s)");
config.setProperty("TotalPlayers", "&cTotal Players: &a%d");
config.setProperty("1POnline", "&cNo one else is online.");
return config;
}
}

View File

@ -1,103 +0,0 @@
package com.gmail.nossr50.vPlayersOnline;
import java.util.Properties;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.ChatColor;
/**
* Handle events for all Player related events
* @author nossr50
*/
public class vPlayerListener extends PlayerListener {
private final vPlayersOnline plugin;
private final String PlayersOnline;
private final String PlayerList;
private final String TotalPlayers;
private final String _1POnline;
public vPlayerListener(vPlayersOnline instance, Properties config) {
plugin = instance;
PlayersOnline = parseColors(config.getProperty("PlayersOnline"));
PlayerList = parseColors(config.getProperty("PlayerList"));
TotalPlayers = parseColors(config.getProperty("TotalPlayers"));
_1POnline = parseColors(config.getProperty("1POnline"));
}
//Function to count the players
private int playerCount(){
Player players[] = plugin.getServer().getOnlinePlayers();
return players.length;
}
private static String parseColors(String str) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); ++i) {
char c = str.charAt(i);
if (c == '&') {
char next = str.charAt(i+1);
if (next == '&') {
// literal &
++i;
} else {
try {
int color = Integer.parseInt(String.valueOf(next), 16);
sb.append(ChatColor.getByCode(color));
++i;
continue;
} catch (NumberFormatException e) {}
}
}
sb.append(c);
}
return sb.toString();
}
//Message to be sent when a player joins
@Override
public void onPlayerJoin(PlayerEvent event) {
Player player = event.getPlayer();
int count = playerCount();
if (count == 1) {
player.sendMessage(_1POnline);
} else {
player.sendMessage(String.format(PlayersOnline, count));
}
}
//Message to be sent when a player uses /list
@Override
public void onPlayerCommandPreprocess(PlayerChatEvent event) {
String[] split = event.getMessage().split(" ");
Player player = event.getPlayer();
if(split[0].equalsIgnoreCase("/list") || split[0].equalsIgnoreCase("/who")){
event.setCancelled(true);
int count = playerCount();
String tempList = "";
int x = 0;
for(Player p : plugin.getServer().getOnlinePlayers())
{
if(p != null && x+1 >= count){
tempList+= p.getName();
x++;
}
if(p != null && x < count){
tempList+= p.getName() +", ";
x++;
}
}
//Output the player list
player.sendMessage(String.format(PlayerList, tempList));
player.sendMessage(String.format(TotalPlayers, count));
}
}
}

View File

@ -1,48 +0,0 @@
package com.gmail.nossr50.vPlayersOnline;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
/**
* vPlayersOnline for Bukkit
*
* @author nossr50
*/
public class vPlayersOnline extends JavaPlugin {
private PluginDescriptionFile pdfFile;
private vPlayerListener playerListener;
public void onLoad() {
}
public void onEnable() {
pdfFile = this.getDescription();
Config.name = pdfFile.getName();
Properties config = Config.loadConfig();
playerListener = new vPlayerListener(this, config);
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Normal, this);
//Displays a message when plugin is loaded
System.out.println(Config.name + " version " + pdfFile.getVersion() + " is enabled!");
}
public void onDisable() {
System.out.println(Config.name + " disabled.");
}
}

View File

@ -1,3 +0,0 @@
name: vPlayersOnline
main: com.gmail.nossr50.vPlayersOnline.vPlayersOnline
version: 1.5

View File

@ -1,28 +0,0 @@
package com.bukkit.nossr50.vStopFire;
import org.bukkit.Material;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.block.Block;
/**
* vStopFire block listener
* @author nossr50
*/
public class vBlockListener extends BlockListener {
private final vStopFire plugin;
public vBlockListener(final vStopFire plugin) {
this.plugin = plugin;
}
//This should stop fire from spreading but still allow players to light stuff up with flint and steel
public void onBlockIgnite(BlockIgniteEvent event) {
String cause = event.getCause().toString();
if(cause.equals("SPREAD"))
event.setCancelled(true);
if(!cause.equals("FLINT_AND_STEEL"))
event.setCancelled(true);
}
}

View File

@ -1,24 +0,0 @@
package com.bukkit.nossr50.vStopFire;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
/**
* Handle events for all Player related events
* @author nossr50
*/
public class vPlayerListener extends PlayerListener {
private final vStopFire plugin;
public vPlayerListener(vStopFire instance) {
plugin = instance;
}
//Insert Player related code here
}

View File

@ -1,29 +0,0 @@
package com.bukkit.nossr50.vStopFire;
import java.io.File;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
/**
* vStopFire for Bukkit
*
* @author nossr50
*/
public class vStopFire extends JavaPlugin {
private final vPlayerListener playerListener = new vPlayerListener(this);
private final vBlockListener blockListener = new vBlockListener(this);
private final String name = "vStopFire";
public void onEnable() {
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.Normal, this);
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
}
public void onDisable() {
System.out.println("vStopFire disabled!");
}
}

View File

@ -1,3 +0,0 @@
name: vStopFire
main: com.bukkit.nossr50.vStopFire.vStopFire
version: 1.1

View File

@ -1,11 +0,0 @@
package com.gmail.nossr50.woolplus;
import org.bukkit.Material;
import org.bukkit.event.block.BlockListener;
public class wBlockListener extends BlockListener {
private final woolplus plugin;
public wBlockListener(final woolplus plugin) {
this.plugin = plugin;
}
}

View File

@ -1,306 +0,0 @@
package com.gmail.nossr50.woolplus;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerItemEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
public class wPlayerListener extends PlayerListener {
private final woolplus plugin;
public wPlayerListener(woolplus instance) {
plugin = instance;
}
public void onPlayerItem(PlayerItemEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getPlayer().getItemInHand();
Block block = event.getBlockClicked();
if(block != null && item != null && isDye(item) && isWool(block)){
dyeWool(block, item, player);
}
}
public boolean isDye(ItemStack item){
int type = item.getTypeId();
if(type == 351 || type == 352){
return true;
} else {
return false;
}
}
public boolean isWool(Block block){
int type = block.getTypeId();
if(type == 35){
return true;
} else {
return false;
}
}
public boolean isBoneMeal(ItemStack item){
int type = item.getTypeId();
short durability = item.getDurability();
if(type == 351 && durability == 15){
return true;
} else {
return false;
}
}
public void consumeDye(short type, Player player){
ItemStack[] inventory = player.getInventory().getContents();
for (ItemStack x : inventory){
if(x.getTypeId() == 351 && x.getDurability() == type){
if(x.getAmount() == 1){
x.setAmount(0);
x.setTypeId(0);
}
if(x.getAmount() > 1)
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
}
player.updateInventory();
}
public boolean isLightColoredWool(byte wool){
if(wool == 4 || wool == 5 || wool == 6 || wool == 9 || wool == 2 || wool == 3){
return true;
} else {
return false;
}
}
public void dyeWool(Block block, ItemStack item, Player player){
MaterialData mdye = item.getData();
byte dye = mdye.getData();
byte wool = block.getData();
short durability = item.getDurability();
/*
* WOOL LIGHTENING
*/
//Black dyes everything you know!
if(durability == 0 && wool != 15){
block.setData((byte) 15);
consumeDye(item.getDurability(), player);
return;
}
//BLACK -> GRAY
if(wool == 15 && isBoneMeal(item)){
block.setData((byte) 7);
consumeDye(item.getDurability(), player);
return;
}
//GRAY -> LGRAY
if(wool == 7 && isBoneMeal(item)){
block.setData((byte) 8);
consumeDye(item.getDurability(), player);
return;
}
//BROWN -> GRAY
if(wool == 12 && isBoneMeal(item)){
block.setData((byte) 7);
consumeDye(item.getDurability(), player);
return;
}
//LGRAY -> WHITE
if(wool == 8 && isBoneMeal(item)){
block.setData((byte) 0);
consumeDye(item.getDurability(), player);
return;
}
//RED (14) -> PINK (6)
if(wool == 14 && isBoneMeal(item)){
block.setData((byte) 6);
consumeDye(item.getDurability(), player);
return;
}
//GREEN13 -> LIME5
if(wool == 13 && isBoneMeal(item)){
block.setData((byte) 5);
consumeDye(item.getDurability(), player);
return;
}
//BLUE11 -> CYAN9
if(wool == 11 && isBoneMeal(item)){
block.setData((byte) 9);
consumeDye(item.getDurability(), player);
return;
}
//CYAN9 -> LIGHT BLUE3
if(wool == 9 && isBoneMeal(item)){
block.setData((byte) 3);
consumeDye(item.getDurability(), player);
return;
}
//PURPLE10 -> MAGENTA2
if(wool == 10 && isBoneMeal(item)){
block.setData((byte) 2);
consumeDye(item.getDurability(), player);
return;
}
/*
* WOOL COMBINATIONS
*/
//Red + Yellow = Orange
//If wool is red, dye is yellow
if(wool == 14 && durability == 11){
block.setData((byte) 1);
consumeDye(item.getDurability(), player);
return;
}
//If wool is yellow, dye is red
if(wool == 4 && durability == 1){
block.setData((byte) 1);
consumeDye(item.getDurability(), player);
return;
}
//Lapis + Green = Cyan
//if wool is Lapis/Blue, dye is green
if(wool == 11 && durability == 2){
block.setData((byte) 9);
consumeDye(item.getDurability(), player);
return;
}
//if wool is Green, dye is lapis
if(wool == 13 && durability == 4){
block.setData((byte) 9);
consumeDye(item.getDurability(), player);
return;
}
//Red + Lapis = Purple
//if wool is Red, dye is Lapis
if(wool == 14 && durability == 4){
block.setData((byte) 10);
consumeDye(item.getDurability(), player);
return;
}
//if wool is Lapis/Blue, dye is red
if(wool == 11 && durability == 1){
block.setData((byte) 10);
consumeDye(item.getDurability(), player);
return;
}
//Purple + Pink = Magenta
//if wool is Purple, dye is pink
if(wool == 10 && durability == 9){
block.setData((byte) 2);
consumeDye(item.getDurability(), player);
return;
}
//if wool is pink, dye is purple
if(wool == 6 && durability == 5){
block.setData((byte) 2);
consumeDye(item.getDurability(), player);
return;
}
/*
* REGULAR DYE SECTION
*/
if(wool == 0){
//orange
if(durability == 14){
block.setData((byte) 1);
consumeDye(item.getDurability(), player);
return;
}
//magenta
if (durability == 13){
block.setData((byte) 2);
consumeDye(item.getDurability(), player);
return;
}
//light blue
if(durability == 12){
block.setData((byte) 3);
consumeDye(item.getDurability(), player);
return;
}
//yellow
if(durability == 11){
block.setData((byte) 4);
consumeDye(item.getDurability(), player);
return;
}
//lime
if(durability == 10){
block.setData((byte) 5);
consumeDye(item.getDurability(), player);
return;
}
//pink
if(durability == 9){
block.setData((byte) 6);
consumeDye(item.getDurability(), player);
return;
}
//gray
if(durability == 8){
block.setData((byte) 7);
consumeDye(item.getDurability(), player);
return;
}
//light gray
if(durability == 7){
block.setData((byte) 8);
consumeDye(item.getDurability(), player);
return;
}
//cyan
if(durability == 6){
block.setData((byte) 9);
consumeDye(item.getDurability(), player);
return;
}
//purple
if(durability == 5){
block.setData((byte) 10);
consumeDye(item.getDurability(), player);
return;
}
//lapis or blue
if(durability == 4){
block.setData((byte) 11);
consumeDye(item.getDurability(), player);
return;
}
//coco or brown
if(durability == 3){
block.setData((byte) 12);
consumeDye(item.getDurability(), player);
return;
}
//green
if(durability == 2){
block.setData((byte) 13);
consumeDye(item.getDurability(), player);
return;
}
//red
if(durability == 1){
block.setData((byte) 14);
consumeDye(item.getDurability(), player);
return;
}
}
/*
* BROWN CONVERSION
*/
if(!isBoneMeal(item) && durability != 0 && wool != 12){
block.setData((byte) 12);
consumeDye(item.getDurability(), player);
return;
}
if(isBoneMeal(item) && wool != 0 && !isLightColoredWool(wool)){
block.setData((byte) 7);
consumeDye(item.getDurability(), player);
return;
}
if(isBoneMeal(item) && wool != 0 && isLightColoredWool(wool)){
block.setData((byte) 0);
consumeDye(item.getDurability(), player);
return;
}
}
}

View File

@ -1,29 +0,0 @@
package com.gmail.nossr50.woolplus;
import java.io.File;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Wool Plus for Bukkit
*
* @author nossr50
*/
public class woolplus extends JavaPlugin {
private final wPlayerListener playerListener = new wPlayerListener(this);
private final wBlockListener blockListener = new wBlockListener(this);
private final String name = "Wool Plus";
public void onEnable() {
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal, this);
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
}
public void onDisable() {
System.out.println("Wool Plus disabled!");
}
}

View File

@ -1,3 +0,0 @@
name: woolplus
main: com.gmail.nossr50.woolplus.woolplus
version: 1.2