mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Reorganized a lot of code. Added tons of comments. Change how commands are added. Encapsulated commands into their own functions. Modified some commands. Recoded others. Added personalized /who that shows name colors.
This commit is contained in:
parent
3c316c1cca
commit
96ed2b100b
53
vminecraftAnnouncements.java
Normal file
53
vminecraftAnnouncements.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
//=====================================================================
|
||||||
|
//Class: vMinecraftAnnouncements
|
||||||
|
//Use: Encapsulates all announcements broadcast when commands are
|
||||||
|
// run
|
||||||
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vminecraftAnnouncements {
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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 if /kick, /ban, /ipban, and /time are run and
|
||||||
|
// displays a global message
|
||||||
|
//=====================================================================
|
||||||
|
public boolean onCommand(Player player, String[] split) {
|
||||||
|
if(!player.canUseCommand(split[0])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//Only run if the global message feature is enabled
|
||||||
|
if(vminecraftSettings.getInstance().globalmessages())
|
||||||
|
{
|
||||||
|
//Global messages that should only parse when a command can be successful
|
||||||
|
if(split[0].equalsIgnoreCase("/kick")) {
|
||||||
|
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
||||||
|
if (playerTarget != null && !playerTarget.hasControlOver(player)) {
|
||||||
|
vminecraftChat.gmsg(player.getColor()+player.getName()+Colors.Blue+" has kicked "+Colors.Red+playerTarget.getColor()+playerTarget.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(split[0].equalsIgnoreCase("/ban")) {
|
||||||
|
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
||||||
|
if (playerTarget != null && !playerTarget.hasControlOver(player)) {
|
||||||
|
vminecraftChat.gmsg(player.getColor()+player.getName()+Colors.Blue+" has banned "+Colors.Red+playerTarget.getColor()+playerTarget.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(split[0].equalsIgnoreCase("/ipban")) {
|
||||||
|
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
||||||
|
if (playerTarget != null && !playerTarget.hasControlOver(player)) {
|
||||||
|
vminecraftChat.gmsg(player.getColor()+player.getName()+Colors.Blue+" has IP banned "+Colors.Red+playerTarget.getColor()+playerTarget.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(split[0].equalsIgnoreCase("/time")) {
|
||||||
|
if (split.length <= 2) {
|
||||||
|
vminecraftChat.gmsg(Colors.Blue+"Time changes thanks to "+player.getColor()+player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
281
vminecraftChat.java
Normal file
281
vminecraftChat.java
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
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 vminecraftChat {
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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){
|
||||||
|
for (Player p : etc.getServer().getPlayerList()) {
|
||||||
|
if (p != null) {
|
||||||
|
p.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: nameColor
|
||||||
|
//Input: Player player: The player to get name as color
|
||||||
|
//Output: String: The name colored
|
||||||
|
//Use: Returns the colored name;
|
||||||
|
//=====================================================================
|
||||||
|
public static String nameColor(Player player){
|
||||||
|
return player.getColor() + player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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;
|
||||||
|
default:
|
||||||
|
color = Colors.White;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: lengthCheck
|
||||||
|
//Input: String str: The message to make sure isn't too long
|
||||||
|
//Output: boolean: If the message is too long
|
||||||
|
//Use: Check if a message is too long
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean lengthCheck(String str)
|
||||||
|
{
|
||||||
|
int length = 0;
|
||||||
|
for(int x = 0; x<str.length(); x++)
|
||||||
|
{
|
||||||
|
if("i;,.:|!".indexOf(str.charAt(x)) != -1)
|
||||||
|
{
|
||||||
|
length+=2;
|
||||||
|
}
|
||||||
|
else if("l'".indexOf(str.charAt(x)) != -1)
|
||||||
|
{
|
||||||
|
length+=3;
|
||||||
|
}
|
||||||
|
else if("tI[]".indexOf(str.charAt(x)) != -1)
|
||||||
|
{
|
||||||
|
length+=4;
|
||||||
|
}
|
||||||
|
else if("kf{}<>\"*()".indexOf(str.charAt(x)) != -1)
|
||||||
|
{
|
||||||
|
length+=5;
|
||||||
|
}
|
||||||
|
else if("hequcbrownxjmpsvazydgTHEQUCKBROWNFXJMPSVLAZYDG1234567890#\\/?$%-=_+&".indexOf(str.charAt(x)) != -1)
|
||||||
|
{
|
||||||
|
length+=6;
|
||||||
|
}
|
||||||
|
else if("@~".indexOf(str.charAt(x)) != -1)
|
||||||
|
{
|
||||||
|
length+=7;
|
||||||
|
}
|
||||||
|
else if(str.charAt(x)==' ')
|
||||||
|
{
|
||||||
|
length+=4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(length<=316)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} else { return false; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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 + "{" + player.getColor()
|
||||||
|
+ player.getName() + Colors.DarkPurple +"}" + Colors.White + " ";
|
||||||
|
|
||||||
|
//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
|
||||||
|
if (p.isAdmin() || (p.canUseCommand("/adminchat"))) {
|
||||||
|
|
||||||
|
//Send them the message
|
||||||
|
p.sendMessage(adminchat
|
||||||
|
+ message.substring(1, message.length()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//So you can read adminchat from the server console
|
||||||
|
log.log(Level.INFO, "@" + "<" + nameColor(player)
|
||||||
|
+ Colors.White +"> " + 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 = "<" + nameColor(player) + Colors.White +"> ";
|
||||||
|
if(vminecraftSettings.getInstance().greentext()) {
|
||||||
|
//Log the chat
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
|
//Output the message
|
||||||
|
gmsg(playerName + Colors.LightGreen + message);
|
||||||
|
}
|
||||||
|
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 = "<" + nameColor(player) + Colors.White +"> ";
|
||||||
|
if (vminecraftSettings.getInstance().FFF()) {
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
|
gmsg(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 = "<" + nameColor(player) + Colors.White +"> ";
|
||||||
|
if(vminecraftSettings.getInstance().quakeColors()&&message.length()>2 && vminecraftChat.lengthCheck(playerName + message)) {
|
||||||
|
|
||||||
|
//Loop through the string finding the color codes and inserting them
|
||||||
|
String temp = "";
|
||||||
|
for(int x = 0; x< message.length(); x++)
|
||||||
|
{
|
||||||
|
if(message.charAt(x)=='^' && x != message.length() - 1)
|
||||||
|
{
|
||||||
|
temp += vminecraftChat.colorChange(message.charAt(x+1));
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
temp+=message.charAt(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Log the chat
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
|
|
||||||
|
//Broadcast the message
|
||||||
|
gmsg(playerName + temp + " ");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
819
vminecraftCommands.java
Normal file
819
vminecraftCommands.java
Normal file
@ -0,0 +1,819 @@
|
|||||||
|
import java.awt.Color;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: vminecraftCommands
|
||||||
|
//Use: Encapsulates all commands added by this mod
|
||||||
|
//Author: nos, trapalice, cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vminecraftCommands{
|
||||||
|
//Log output
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
|
//The list of commands for vminecraft
|
||||||
|
public static commandList cl = new commandList();
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: loadCommands
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Imports all the commands into the command list
|
||||||
|
//=====================================================================
|
||||||
|
public static void loadCommands(){
|
||||||
|
//If we had commands we would add them here.
|
||||||
|
cl.register("/tp", "teleport");
|
||||||
|
cl.register("/masstp", "masstp", "Teleports those with lower permissions to you");
|
||||||
|
cl.register("/reload", "reload");
|
||||||
|
cl.register("/rules", "rules", "Displays the rules");
|
||||||
|
cl.register("/fabulous", "fabulous", "makes text SUUUPER");
|
||||||
|
cl.register("/whois", "whois", "/whois [user]");
|
||||||
|
cl.register("/say", "say");
|
||||||
|
cl.register("/slay", "slay", "Kill target player");
|
||||||
|
cl.register("/ezmodo", "invuln", "Toggle invulnerability");
|
||||||
|
cl.register("/ezlist", "ezlist", "List invulnerable players");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: teleport (/tp)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The arguments for the command. Should be a
|
||||||
|
// player name
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Teleports the user to another player
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean teleport(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//Get if the command is enabled
|
||||||
|
if(vminecraftSettings.getInstance().cmdTp())
|
||||||
|
{
|
||||||
|
//Make sure a player has been specified and return an error if not
|
||||||
|
if (args.length < 1) {
|
||||||
|
player.sendMessage(Colors.Rose + "Correct usage is: /tp [player]");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//Find the player by name
|
||||||
|
Player playerTarget = etc.getServer().matchPlayer(args[0]);
|
||||||
|
|
||||||
|
//If it's you, return witty message
|
||||||
|
if (player.getName().equalsIgnoreCase(args[0]))
|
||||||
|
player.sendMessage(Colors.Rose + "You're already here!");
|
||||||
|
|
||||||
|
//If the player is higher rank than you, inform the user
|
||||||
|
else if (!player.hasControlOver(playerTarget))
|
||||||
|
player.sendMessage(Colors.Red +
|
||||||
|
"That player has higher permissions than you.");
|
||||||
|
|
||||||
|
//If the player exists transport the user to the player
|
||||||
|
else if (playerTarget != null) {
|
||||||
|
log.log(Level.INFO, player.getName() + " teleported to " +
|
||||||
|
playerTarget.getName());
|
||||||
|
player.teleportTo(playerTarget);
|
||||||
|
|
||||||
|
//Otherwise inform the user that the player doesn't exist
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.Rose + "Can't find user "
|
||||||
|
+ args[0] + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: masstp (/masstp)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Should be empty or is ignored
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Teleports all players to the user
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean masstp(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the command is enabled
|
||||||
|
if(vminecraftSettings.getInstance().cmdMasstp()) {
|
||||||
|
//Go through all players and move them to the user
|
||||||
|
for (Player p : etc.getServer().getPlayerList()) {
|
||||||
|
if (!p.hasControlOver(player)) {
|
||||||
|
p.teleportTo(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Inform the user that the command has executed successfully
|
||||||
|
player.sendMessage(Colors.Blue+"Summoning successful.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: tphere (/tphere)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The arguments for the command. Should be a
|
||||||
|
// player name
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Teleports the user to another player
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean tphere(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//Check if the command is enabled.
|
||||||
|
if (vminecraftSettings.getInstance().cmdTphere()) {
|
||||||
|
//Make sure a player is specified
|
||||||
|
if (args.length < 1) {
|
||||||
|
player.sendMessage(Colors.Rose + "Correct usage is: /tphere [player]");
|
||||||
|
} else {
|
||||||
|
//Get the player by name
|
||||||
|
Player playerTarget = etc.getServer().matchPlayer(args[0]);
|
||||||
|
//If the player has a higher rank than the user, return error
|
||||||
|
if (!player.hasControlOver(playerTarget)) {
|
||||||
|
player.sendMessage(Colors.Red + "That player has higher permissions than you.");
|
||||||
|
//If the user teleports themselves, mock them
|
||||||
|
}else if (player.getName().equalsIgnoreCase(args[0])) {
|
||||||
|
player.sendMessage(Colors.Rose + "Wow look at that! You teleported yourself to yourself!");
|
||||||
|
//If the target exists, teleport them to the user
|
||||||
|
}else if (playerTarget != null) {
|
||||||
|
log.log(Level.INFO, player.getName() + " teleported " + player.getName() + " to their self.");
|
||||||
|
playerTarget.teleportTo(player);
|
||||||
|
//Otherwise inform the user that the target doens't exist.
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.Rose + "Can't find user " + args[0] + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: reload (/reload)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Ignored
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Reloads the settings for vminecraft
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean reload(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//Should only reload vminecraft settings if the player is able to use /reload
|
||||||
|
try {
|
||||||
|
vminecraftSettings.getInstance().loadSettings();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while loading settings", e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: rules (/rules)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Ignored
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Lists the rules
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean rules(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the rules exist
|
||||||
|
if(vminecraftSettings.getInstance().cmdRules()) {
|
||||||
|
//Display them
|
||||||
|
for (String str : vminecraftSettings.getInstance().getRules()) {
|
||||||
|
player.sendMessage(Colors.Blue+str);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: fabulous (/fabulous)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The message to apply the effect to
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Makes the text rainbow colored
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean fabulous(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the command is enabled
|
||||||
|
if(vminecraftSettings.getInstance().cmdFabulous()) {
|
||||||
|
//Make sure a message has been specified
|
||||||
|
if (args.length < 1) {return false;}
|
||||||
|
String str = "",
|
||||||
|
temp = "";
|
||||||
|
//Merge the message again
|
||||||
|
str = etc.combineSplit(0, args, " ");
|
||||||
|
String playerName = "<" + player.getName() + "> ";
|
||||||
|
String temp2 = playerName + str;
|
||||||
|
//The array of colors to use
|
||||||
|
String[] rainbow = new String[] {Colors.Red, Colors.Rose,
|
||||||
|
Colors.Yellow, Colors.Green, Colors.Blue,
|
||||||
|
Colors.LightPurple, Colors.Purple};
|
||||||
|
int counter=0;
|
||||||
|
//If the message isn't too long
|
||||||
|
if(vminecraftChat.lengthCheck(temp2))
|
||||||
|
{
|
||||||
|
//Output for server
|
||||||
|
log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\"");
|
||||||
|
|
||||||
|
//Loop through the message applying the colors
|
||||||
|
for(int x=0; x<str.length(); x++)
|
||||||
|
{
|
||||||
|
temp+=rainbow[counter]+str.charAt(x);
|
||||||
|
|
||||||
|
if(str.charAt(x)!=' ') counter++;
|
||||||
|
if(counter==7) counter = 0;
|
||||||
|
}
|
||||||
|
//Prepend the player name
|
||||||
|
String message = playerName + temp;
|
||||||
|
//Output the message
|
||||||
|
vminecraftChat.gmsg(message);
|
||||||
|
|
||||||
|
//Otherwise the message is too long, output error to user
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.Rose + "Message is too long");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: whois (/whois)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The player to find info on
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Displays information about the player specified
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean whois(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the command is enabled
|
||||||
|
if (vminecraftSettings.getInstance().cmdWhoIs()) {
|
||||||
|
//If a player is specified
|
||||||
|
if (args.length < 1) {
|
||||||
|
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
|
||||||
|
}
|
||||||
|
//Get the player by name
|
||||||
|
Player playerTarget = null;
|
||||||
|
for( Player p : etc.getServer().getPlayerList())
|
||||||
|
{
|
||||||
|
if (p.getName().equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
playerTarget = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//If the player exists
|
||||||
|
if (playerTarget != null){
|
||||||
|
|
||||||
|
//Displaying the information
|
||||||
|
player.sendMessage(Colors.Blue + "Whois results for " +
|
||||||
|
vminecraftChat.nameColor(playerTarget) + ".");
|
||||||
|
//Group
|
||||||
|
player.sendMessage(Colors.Blue + "Groups: " +
|
||||||
|
playerTarget.getGroups());
|
||||||
|
//Admin
|
||||||
|
player.sendMessage(Colors.Blue+"Admin: " +
|
||||||
|
String.valueOf(playerTarget.canIgnoreRestrictions()));
|
||||||
|
//IP
|
||||||
|
player.sendMessage(Colors.Blue+"IP: " + playerTarget.getIP());
|
||||||
|
//Restrictions
|
||||||
|
player.sendMessage(Colors.Blue+"Can ignore restrictions: " +
|
||||||
|
String.valueOf(playerTarget.canIgnoreRestrictions()));
|
||||||
|
|
||||||
|
//Give the user an error if the player doesn't exist
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.Rose+"Player not found.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: who (/who)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Ignored
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Displays the connected players
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean who(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the command is enabled
|
||||||
|
if (vminecraftSettings.getInstance().cmdWho()) {
|
||||||
|
//Loop through all players counting them and adding to the list
|
||||||
|
int count=0;
|
||||||
|
String tempList = "";
|
||||||
|
for( Player p : etc.getServer().getPlayerList())
|
||||||
|
{
|
||||||
|
if(count == 0)
|
||||||
|
tempList += vminecraftChat.nameColor(p);
|
||||||
|
else
|
||||||
|
tempList += ", " + vminecraftChat.nameColor(p);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
//Get the max players from the config
|
||||||
|
PropertiesFile server = new PropertiesFile("server.properties");
|
||||||
|
try {
|
||||||
|
server.load();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
int maxPlayers = server.getInt("max-players");
|
||||||
|
|
||||||
|
//Output the player list
|
||||||
|
vminecraftChat.gmsg( Color.red + "Players(" + count + "/" + maxPlayers +
|
||||||
|
"): " + tempList);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: say (/say)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The message to apply the effect to
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Announces the message to all players
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean say(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the command is enabled
|
||||||
|
if (vminecraftSettings.getInstance().cmdSay()) {
|
||||||
|
//Make sure a message is supplied or output an error
|
||||||
|
if (args.length < 1) {
|
||||||
|
player.sendMessage(Colors.Rose + "Usage is /say [message]");
|
||||||
|
}
|
||||||
|
//Display the message globally
|
||||||
|
vminecraftChat.gmsg(Colors.Yellow + etc.combineSplit(0, args, " "));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: slay (/slay)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The target for the command
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Kill the target player
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean slay(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//Check if the command is enabled
|
||||||
|
if(vminecraftSettings.getInstance().cmdEzModo()) {
|
||||||
|
//Get the player by name
|
||||||
|
Player playerTarget = etc.getServer().matchPlayer(args[0]);
|
||||||
|
//If the player isn't invulnerable kill them
|
||||||
|
if (!vminecraftSettings.getInstance().isEzModo(player.getName())) {
|
||||||
|
playerTarget.setHealth(0);
|
||||||
|
vminecraftChat.gmsg(player.getColor() + player.getName() + Colors.LightBlue + " has slain " + playerTarget.getColor() + playerTarget.getName());
|
||||||
|
//Otherwise output error to the user
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: invuln (/ezmodo)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: The target for the command
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: Kill the target player
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean invuln(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the command is enabled
|
||||||
|
if (vminecraftSettings.getInstance().cmdEzModo()) {
|
||||||
|
//If the player is already invulnerable, turn ezmodo off.
|
||||||
|
if (vminecraftSettings.getInstance().isEzModo(player.getName())) {
|
||||||
|
player.sendMessage(Colors.Red + "ezmodo = off");
|
||||||
|
vminecraftSettings.getInstance().removeEzModo(player.getName());
|
||||||
|
//Otherwise make them invulnerable
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Colors.LightBlue + "eh- maji? ezmodo!?");
|
||||||
|
player.sendMessage(Colors.Rose + "kimo-i");
|
||||||
|
player.sendMessage(Colors.LightBlue + "Easy Mode ga yurusareru no wa shougakusei made dayo ne");
|
||||||
|
player.sendMessage(Colors.Red + "**Laughter**");
|
||||||
|
vminecraftSettings.getInstance().addEzModo(player.getName());
|
||||||
|
player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: ezlist (/ezlist)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Ignored
|
||||||
|
//Output: boolean: If the user has access to the command
|
||||||
|
// and it is enabled
|
||||||
|
//Use: List all invulnerable players
|
||||||
|
//=====================================================================
|
||||||
|
public static boolean ezlist(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//If the feature is enabled list the players
|
||||||
|
if(vminecraftSettings.getInstance().cmdEzModo()) {
|
||||||
|
player.sendMessage("Ezmodo: " + vminecraftSettings.getInstance().ezModoList());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Disable using /modify to add commands (need to make a boolean settings for this)
|
||||||
|
|
||||||
|
//ezlist
|
||||||
|
//ezmodo
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
//Promote
|
||||||
|
if (vminecraftSettings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote")) {
|
||||||
|
if(split.length != 2)
|
||||||
|
{
|
||||||
|
player.sendMessage(Colors.Rose + "Usage is /promote [Player]");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Player playerTarget = null;
|
||||||
|
if(split.length==2){
|
||||||
|
for( Player p : etc.getServer().getPlayerList())
|
||||||
|
{
|
||||||
|
if (p.getName().equalsIgnoreCase(split[1]))
|
||||||
|
{
|
||||||
|
playerTarget = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( playerTarget!=null)
|
||||||
|
{
|
||||||
|
String playerTargetGroup[] = playerTarget.getGroups();
|
||||||
|
String playerGroup[] = player.getGroups();
|
||||||
|
player.sendMessage("Debug data:");
|
||||||
|
player.sendMessage("PlayerTarget: "+playerTargetGroup[0]);
|
||||||
|
player.sendMessage("Player: "+playerGroup[0]);
|
||||||
|
if(playerTargetGroup[0].equals("admins"))
|
||||||
|
{
|
||||||
|
player.sendMessage(Colors.Rose + "You can not promote " + split[1] + " any higher.");
|
||||||
|
}
|
||||||
|
if(playerTargetGroup[0].equals("mods") && (playerGroup[0].equals("owner")))
|
||||||
|
{
|
||||||
|
playerTarget.setGroups(ranks.Admins);
|
||||||
|
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
||||||
|
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin";
|
||||||
|
other.gmsg(message);
|
||||||
|
}
|
||||||
|
else if (playerTargetGroup[0].equals("trusted") && (playerGroup[0].equals("admins") || playerGroup[0].equals("owner")))
|
||||||
|
{
|
||||||
|
playerTarget.setGroups(ranks.Mods);
|
||||||
|
playerTargetGroup[0]="Mods";
|
||||||
|
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
||||||
|
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod";
|
||||||
|
other.gmsg(message);
|
||||||
|
}
|
||||||
|
else if (playerTargetGroup[0].equals("default") && (playerGroup[0].equals("mods") || playerGroup[0].equals("admins") || player.isInGroup("owner")))
|
||||||
|
{
|
||||||
|
playerTarget.setGroups(ranks.Trusted);
|
||||||
|
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
||||||
|
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted";
|
||||||
|
other.gmsg(message);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.sendMessage(Colors.Rose + "Player not found");
|
||||||
|
}
|
||||||
|
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Demote
|
||||||
|
if (vminecraftSettings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote"))
|
||||||
|
{
|
||||||
|
if(split.length != 2)
|
||||||
|
{
|
||||||
|
player.sendMessage(Colors.Rose + "Usage is /demote [Player]");
|
||||||
|
}
|
||||||
|
|
||||||
|
Player playerTarget = null;
|
||||||
|
|
||||||
|
for( Player p : etc.getServer().getPlayerList())
|
||||||
|
{
|
||||||
|
if (p.getName().equalsIgnoreCase(split[1]))
|
||||||
|
{
|
||||||
|
playerTarget = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( playerTarget!=null)
|
||||||
|
{
|
||||||
|
if(playerTarget.isInGroup("admins") && (player.isInGroup("superadmins")))
|
||||||
|
{
|
||||||
|
playerTarget.setGroups(ranks.Mods);
|
||||||
|
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
||||||
|
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod";
|
||||||
|
other.gmsg(message);
|
||||||
|
}
|
||||||
|
if(playerTarget.isInGroup("mods") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||||
|
{
|
||||||
|
playerTarget.setGroups(ranks.Trusted);
|
||||||
|
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
||||||
|
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted";
|
||||||
|
other.gmsg(message);
|
||||||
|
}
|
||||||
|
else if (playerTarget.isInGroup("trusted") && (player.isInGroup("mods") || player.isInGroup("superadmins") || player.isInGroup("admins")))
|
||||||
|
{
|
||||||
|
playerTarget.setGroups(ranks.Def);
|
||||||
|
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
||||||
|
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default";
|
||||||
|
other.gmsg(message);
|
||||||
|
}
|
||||||
|
else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||||
|
{
|
||||||
|
player.sendMessage(Colors.Rose + "You can not demote " + split[1] + " any lower.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.sendMessage(Colors.Rose + "Player not found");
|
||||||
|
}
|
||||||
|
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
||||||
|
return true;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: commandList
|
||||||
|
//Use: The list of commands that will be checked for
|
||||||
|
//Author: cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
class commandList {
|
||||||
|
command[] commands;
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: commandList
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Initialize the array of commands
|
||||||
|
//=====================================================================
|
||||||
|
public commandList(){
|
||||||
|
commands = new command[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: register
|
||||||
|
//Input: String name: The name of the command
|
||||||
|
// String func: The function to be called
|
||||||
|
//Output: boolean: Whether the command was input successfully or not
|
||||||
|
//Use: Registers a command to the command list for checking later
|
||||||
|
//=====================================================================
|
||||||
|
public boolean register(String name, String func){
|
||||||
|
|
||||||
|
//If the command list isn't empty
|
||||||
|
if(commands.length > 0)
|
||||||
|
{
|
||||||
|
//Check to make sure the command doesn't already exist
|
||||||
|
for(int i = 0; i < commands.length; i++)
|
||||||
|
if(commands[i].getName().equalsIgnoreCase(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//Create a new temp array
|
||||||
|
command[] temp = new command[commands.length + 1];
|
||||||
|
//Copy the old command list over
|
||||||
|
System.arraycopy(commands, 0, temp, 0, commands.length);
|
||||||
|
//Set commands to equal the new array
|
||||||
|
commands = temp;
|
||||||
|
} else {
|
||||||
|
commands = new command[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the new function to the list
|
||||||
|
commands[commands.length - 1] = new command(name, func);
|
||||||
|
|
||||||
|
//exit successfully
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: register
|
||||||
|
//Input: String name: The name of the command
|
||||||
|
// String func: The function to be called
|
||||||
|
// String info: The information for the command to put in help
|
||||||
|
//Output: boolean: Whether the command was input successfully or not
|
||||||
|
//Use: Registers a command to the command list for checking later
|
||||||
|
//=====================================================================
|
||||||
|
public boolean register(String name, String func, String info){
|
||||||
|
//Add to the /help list
|
||||||
|
etc.getInstance().addCommand(name, info);
|
||||||
|
|
||||||
|
//Finish registering
|
||||||
|
return register(name, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: register
|
||||||
|
//Input: String name: The name of the command
|
||||||
|
// String func: The function to be called
|
||||||
|
//Output: boolean: Whether the command was input successfully or not
|
||||||
|
//Use: Registers a command to the command list for checking later
|
||||||
|
//=====================================================================
|
||||||
|
public boolean registerAlias(String name, String com, String[] args){
|
||||||
|
|
||||||
|
//Check to make sure the alias doesn't already exist
|
||||||
|
for(int i = 0; i < commands.length; i++)
|
||||||
|
//The alias already exists
|
||||||
|
if(commands[i].getName().equalsIgnoreCase(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//If the command list isn't empty
|
||||||
|
if(commands.length > 0)
|
||||||
|
{
|
||||||
|
//Create a new temp array
|
||||||
|
command[] temp = new command[commands.length];
|
||||||
|
//Copy the old command list over
|
||||||
|
System.arraycopy(commands, 0, temp, 0, commands.length);
|
||||||
|
//Set commands to equal the new array
|
||||||
|
commands = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Add the new function to the list
|
||||||
|
commands[commands.length] = new commandRef(name, com, args);
|
||||||
|
|
||||||
|
//exit successfully
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: call
|
||||||
|
//Input: String name: The name of the command to be run
|
||||||
|
//Output: boolean: If the command was called successfully
|
||||||
|
//Use: Attempts to call a command
|
||||||
|
//=====================================================================
|
||||||
|
public boolean call(String name, Player player, String[] arg){
|
||||||
|
//Make sure the user has access to the command
|
||||||
|
if(!player.canUseCommand(name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//Search for the command
|
||||||
|
for(int i = 0; i < commands.length; i++)
|
||||||
|
{
|
||||||
|
//When found
|
||||||
|
if(commands[i].getName().equalsIgnoreCase(name))
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Call the command and return results
|
||||||
|
return commands[i].call(player, arg);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Something went wrong
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: command
|
||||||
|
//Use: The specific command
|
||||||
|
//Author: cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
private class command{
|
||||||
|
private String commandName;
|
||||||
|
private String function;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: command
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Initialize the command
|
||||||
|
//=====================================================================
|
||||||
|
public command(String name, String func){
|
||||||
|
commandName = name;
|
||||||
|
function = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getName
|
||||||
|
//Input: None
|
||||||
|
//Output: String: The command name
|
||||||
|
//Use: Returns the command name
|
||||||
|
//=====================================================================
|
||||||
|
public String getName(){
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: call
|
||||||
|
//Input: String[] arg: The arguments for the command
|
||||||
|
//Output: boolean: If the command was called successfully
|
||||||
|
//Use: Attempts to call the command
|
||||||
|
//=====================================================================
|
||||||
|
public boolean call(Player player, String[] arg)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Method m = vminecraftCommands.class.getMethod(function, Player.class, String[].class);
|
||||||
|
m.setAccessible(true);
|
||||||
|
return (Boolean) m.invoke(null, player, arg);
|
||||||
|
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Class: commandRef
|
||||||
|
//Use: A command referencing another command
|
||||||
|
//Author: cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
private class commandRef extends command{
|
||||||
|
private String commandName;
|
||||||
|
private String reference;
|
||||||
|
private String[] args;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: command
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Initialize the command
|
||||||
|
//=====================================================================
|
||||||
|
public commandRef(String name, String com, String[] arg){
|
||||||
|
super(name, "");
|
||||||
|
reference = com;
|
||||||
|
args = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: call
|
||||||
|
//Input: None
|
||||||
|
//Output: String: The command name
|
||||||
|
//Use: Returns the command name
|
||||||
|
//=====================================================================
|
||||||
|
public String getName(){
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: call
|
||||||
|
//Input: String[] arg: The arguments for the command
|
||||||
|
//Output: boolean: If the command was called successfully
|
||||||
|
//Use: Attempts to call the command
|
||||||
|
//=====================================================================
|
||||||
|
public boolean call(String[] arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
//Insert the arguments into the pre-set arguments
|
||||||
|
String[] temp = args;
|
||||||
|
int lastSet = -1;
|
||||||
|
for(int i = 0; i < temp.length; i++)
|
||||||
|
if(temp[i].startsWith("%"))
|
||||||
|
temp[i] = arg[lastSet = Integer.parseInt(temp[i].substring(1))];
|
||||||
|
|
||||||
|
//Append the rest of the arguments to the argument array
|
||||||
|
if(lastSet + 1 < arg.length)
|
||||||
|
{
|
||||||
|
String[] temp2 = new String[temp.length + arg.length - lastSet];
|
||||||
|
System.arraycopy(temp, 0, temp2, 0, temp.length);
|
||||||
|
System.arraycopy(arg, lastSet + 1, temp2,
|
||||||
|
temp.length, arg.length - lastSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Call the referenced command
|
||||||
|
//TODO STILL TO BE WRITTEN
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,456 +1,89 @@
|
|||||||
//Vminecraft plugin by nossr50 & TrapAlice
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
//=====================================================================
|
||||||
public class vminecraftListener extends PluginListener {
|
//Class: vminecraftListener
|
||||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
//Use: The listener to catch incoming chat and commands
|
||||||
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
private ArrayList<String> ezmodo = new ArrayList<String>(); //An array of players currently in ezmodo
|
//=====================================================================
|
||||||
|
public class vminecraftListener extends PluginListener {
|
||||||
public void enable() throws IOException {
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
settings.getInstance().loadSettings(); //Load the settings files
|
|
||||||
if (etc.getInstance().isHealthEnabled()){
|
//=====================================================================
|
||||||
etc.getInstance().addCommand("/ezmodo", "Toggle invulnerability");
|
//Function: disable
|
||||||
}
|
//Input: None
|
||||||
log.log(Level.INFO, "vminecraft enabled");
|
//Output: None
|
||||||
}
|
//Use: Disables vminecraft, but why would you want to do that? ;)
|
||||||
public void disable() {
|
//=====================================================================
|
||||||
log.log(Level.INFO, "vminecraft disabled");
|
public void disable() {
|
||||||
if (etc.getInstance().isHealthEnabled()) {
|
log.log(Level.INFO, "vminecraft disabled");
|
||||||
etc.getInstance().removeCommand("/ezmodo");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onHealthChange(Player player,int oldValue,int newValue){
|
|
||||||
if (player.getHealth() != 30 && ezmodo.contains(player.getName())) {
|
|
||||||
player.setHealth(30);
|
|
||||||
}
|
|
||||||
else if (settings.getInstance().globalmessages() && player.getHealth() < 1) {
|
|
||||||
other.gmsg(Colors.Gray + player.getName() + " is no more");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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){
|
public boolean onChat(Player player, String message){
|
||||||
String temp2 = "<" + player.getColor() + player.getName() + Colors.White +"> "; //Copies the formatting of id.java
|
|
||||||
String adminchat = Colors.DarkPurple + "{" + player.getColor() + player.getName() + Colors.DarkPurple +"}" + Colors.White + " "; //Special formatting for adminchat
|
|
||||||
String message2 = ""; //Used for greentext and FFF
|
|
||||||
String check = temp2+message; //Calculates how long your message will be including your name in the equation, this prevents minecraft clients from crashing when a color code is inserted after a linebreak
|
|
||||||
if (settings.getInstance().adminchat()&&message.startsWith("@") && (player.isAdmin() || player.canUseCommand("/adminchat"))) {
|
|
||||||
for (Player p : etc.getServer().getPlayerList()) {
|
|
||||||
String blaa = "";
|
|
||||||
if (p != null) {
|
|
||||||
if (p.isAdmin() || (p.canUseCommand("/adminchat"))) {
|
|
||||||
for ( int x = 1; x< message.length(); x++) {
|
|
||||||
blaa+=message.charAt(x);
|
|
||||||
}
|
|
||||||
if (p.isAdmin() || (p.canUseCommand("/adminchat"))){
|
|
||||||
if (p != null) {
|
|
||||||
p.sendMessage(adminchat+blaa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.log(Level.INFO, "@"+temp2+message); //So you can read adminchat from the server console
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
//Quote (Greentext)
|
||||||
//Greentext
|
if (message.startsWith(">"))
|
||||||
if (settings.getInstance().greentext()&&message.startsWith(">")) {
|
vminecraftChat.quote(player, message);
|
||||||
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
|
||||||
message = Colors.LightGreen + message;
|
//Rage (FFF)
|
||||||
message2 = temp2 + message;
|
else if (message.startsWith("FFF"))
|
||||||
other.gmsg(message2);
|
vminecraftChat.rage(player, message);
|
||||||
return true;
|
|
||||||
}
|
//Send through quakeColors otherwise
|
||||||
//FFF
|
else
|
||||||
if (settings.getInstance().FFF()&&message.startsWith("FFF")) {
|
vminecraftChat.quakeColors(player, message);
|
||||||
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
|
||||||
message = Colors.Red + message;
|
return false;
|
||||||
message2 = temp2 + message;
|
|
||||||
other.gmsg(message2);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//QuakeColors
|
|
||||||
if(settings.getInstance().quakeColors()&&message.length()>2 && other.lengthCheck(check)) {
|
|
||||||
String temp = "";
|
|
||||||
for(int x = 0; x< message.length(); x++)
|
|
||||||
{
|
|
||||||
if(message.charAt(x)=='^'&&x!=message.length()-1)
|
|
||||||
{
|
|
||||||
temp+=other.colorChange(message.charAt(x+1));
|
|
||||||
x+=1;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
temp+=message.charAt(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
|
||||||
message = temp2 + temp + " ";
|
|
||||||
for (Player p : etc.getServer().getPlayerList()) {
|
|
||||||
if (p != null) {
|
|
||||||
other.gmsg(message);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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) {
|
||||||
|
|
||||||
public boolean onCommand(Player player, String[] split) {
|
//Explot fix on /modify
|
||||||
if(!player.canUseCommand(split[0])) {
|
if(split[0].equals("/modify") && split[2].equals("commands")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(settings.getInstance().cmdMasstp() && split[0].equalsIgnoreCase("/masstp")) {
|
|
||||||
for (Player p : etc.getServer().getPlayerList()) {
|
|
||||||
if (!p.hasControlOver(player)) {
|
|
||||||
p.teleportTo(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
player.sendMessage(Colors.Blue+"Summoning successful.");
|
|
||||||
}
|
|
||||||
//Disable using /modify to add commands (need to make a boolean settings for this)
|
|
||||||
if(split[0].equals("/modify") && split[2].equals("commands")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//ezlist
|
|
||||||
if(settings.getInstance().cmdEzModo() && split[0].equals("/ezlist")) {
|
|
||||||
player.sendMessage("Ezmodo: " + ezmodo);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//slay
|
|
||||||
if(settings.getInstance().cmdEzModo() && split[0].equals("/slay")) {
|
|
||||||
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
|
||||||
if (!ezmodo.contains(playerTarget.getName())) {
|
|
||||||
playerTarget.setHealth(0);
|
|
||||||
other.gmsg(player.getColor() + player.getName() + Colors.LightBlue + " has slain " + playerTarget.getColor() + playerTarget.getName());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//ezmodo
|
|
||||||
if (settings.getInstance().cmdEzModo() && split[0].equals("/ezmodo")) {
|
|
||||||
if (ezmodo.contains(player.getName())) {
|
|
||||||
player.sendMessage(Colors.Red + "ezmodo = off");
|
|
||||||
ezmodo.remove(ezmodo.indexOf(player.getName()));
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
player.sendMessage(Colors.LightBlue + "eh- maji? ezmodo!?");
|
|
||||||
player.sendMessage(Colors.Rose + "kimo-i");
|
|
||||||
player.sendMessage(Colors.LightBlue + "Easy Mode ga yurusareru no wa shougakusei made dayo ne");
|
|
||||||
player.sendMessage(Colors.Red + "**Laughter**");
|
|
||||||
ezmodo.add(player.getName());
|
|
||||||
player.setHealth(30);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Replacement for /tp
|
|
||||||
if(settings.getInstance().cmdTp() && split[0].equalsIgnoreCase("/tp")) {
|
|
||||||
{
|
|
||||||
if (split.length < 2) {
|
|
||||||
player.sendMessage(Colors.Rose + "Correct usage is: /tp [player]");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
//Copy the arguments into their own array.
|
||||||
|
String[] args = new String[split.length - 1];
|
||||||
if (player.getName().equalsIgnoreCase(split[1])) {
|
System.arraycopy(split, 1, args, 0, args.length);
|
||||||
player.sendMessage(Colors.Rose + "You're already here!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.hasControlOver(playerTarget)) {
|
|
||||||
player.sendMessage(Colors.Red + "That player has higher permissions than you.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playerTarget != null) {
|
|
||||||
log.log(Level.INFO, player.getName() + " teleported to " + playerTarget.getName());
|
|
||||||
player.teleportTo(playerTarget);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
player.sendMessage(Colors.Rose + "Can't find user " + split[1] + ".");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Replacement for /tphere
|
|
||||||
if (settings.getInstance().cmdTphere() && (split[0].equalsIgnoreCase("/tphere") || split[0].equalsIgnoreCase("/s"))) {
|
|
||||||
if (split.length < 2) {
|
|
||||||
player.sendMessage(Colors.Rose + "Correct usage is: /tphere [player]");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
|
||||||
|
|
||||||
if (!player.hasControlOver(playerTarget)) {
|
|
||||||
player.sendMessage(Colors.Red + "That player has higher permissions than you.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (player.getName().equalsIgnoreCase(split[1])) {
|
|
||||||
player.sendMessage(Colors.Rose + "Wow look at that! You teleported yourself to yourself!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playerTarget != null) {
|
|
||||||
log.log(Level.INFO, player.getName() + " teleported " + player.getName() + " to their self.");
|
|
||||||
playerTarget.teleportTo(player);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(Colors.Rose + "Can't find user " + split[1] + ".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Global messages that should only parse when a command can be successful
|
|
||||||
if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/kick")) {
|
|
||||||
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
|
||||||
if (playerTarget != null && !playerTarget.hasControlOver(player)) {
|
|
||||||
other.gmsg(player.getColor()+player.getName()+Colors.Blue+" has kicked "+Colors.Red+playerTarget.getColor()+playerTarget.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/ban")) {
|
|
||||||
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
|
||||||
if (playerTarget != null && !playerTarget.hasControlOver(player)) {
|
|
||||||
other.gmsg(player.getColor()+player.getName()+Colors.Blue+" has banned "+Colors.Red+playerTarget.getColor()+playerTarget.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/ipban")) {
|
|
||||||
Player playerTarget = etc.getServer().matchPlayer(split[1]);
|
|
||||||
if (playerTarget != null && !playerTarget.hasControlOver(player)) {
|
|
||||||
other.gmsg(player.getColor()+player.getName()+Colors.Blue+" has IP banned "+Colors.Red+playerTarget.getColor()+playerTarget.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(settings.getInstance().globalmessages() && split[0].equalsIgnoreCase("/time")) {
|
|
||||||
if (split.length <= 2) {
|
|
||||||
other.gmsg(Colors.Blue+"Time changes thanks to "+player.getColor()+player.getName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Should only reload vminecraft settings if the player is able to use /reload
|
|
||||||
if(split[0].equalsIgnoreCase("/reload") && player.canUseCommand("/reload")) {
|
|
||||||
try {
|
|
||||||
settings.getInstance().loadSettings();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(vminecraftListener.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//Rules
|
|
||||||
if(settings.getInstance().cmdRules() && split[0].equalsIgnoreCase("/rules")) {
|
|
||||||
for (String str : settings.getInstance().getRules()) {
|
|
||||||
player.sendMessage(Colors.Blue+str);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//Fabulous
|
|
||||||
if(split[0].equalsIgnoreCase("/fabulous") && settings.getInstance().cmdFabulous()) {
|
|
||||||
if (split.length == 1) {return false;}
|
|
||||||
String temp = "";
|
|
||||||
String str = "";
|
|
||||||
str = etc.combineSplit(1, split, " ");
|
|
||||||
String temp2 = "<" + player.getName() + "> "+str;
|
|
||||||
String[] rainbow = new String[] {Colors.Red, Colors.Rose, Colors.Yellow, Colors.Green, Colors.Blue, Colors.LightPurple, Colors.Purple};
|
|
||||||
int counter=0;
|
|
||||||
if(other.lengthCheck(temp2))
|
|
||||||
{
|
|
||||||
log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\"");
|
|
||||||
for(int x=0; x<str.length(); x++)
|
|
||||||
{
|
|
||||||
temp+=rainbow[counter]+str.charAt(x);
|
|
||||||
counter++;
|
|
||||||
if(str.charAt(x)==' ') { counter--;}
|
|
||||||
if(counter==-1){counter = 6; }
|
|
||||||
if(counter==7){counter = 0; }
|
|
||||||
}
|
|
||||||
str = temp+" ";
|
|
||||||
String message = "<" + player.getColor() + player.getName() + Colors.White + "> " + str;
|
|
||||||
|
|
||||||
other.gmsg(message);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
player.sendMessage(Colors.Rose + "Message is too long");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
//Promote
|
|
||||||
if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote")) {
|
|
||||||
if(split.length != 2)
|
|
||||||
{
|
|
||||||
player.sendMessage(Colors.Rose + "Usage is /promote [Player]");
|
|
||||||
|
|
||||||
|
//Return the results of the command
|
||||||
|
return vminecraftCommands.cl.call(split[0], player, args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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){
|
||||||
|
if (player.getHealth() != vminecraftSettings.getInstance().ezModoHealth() && vminecraftSettings.getInstance().isEzModo(player.getName())) {
|
||||||
|
player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
|
||||||
|
|
||||||
Player playerTarget = null;
|
|
||||||
if(split.length==2){
|
|
||||||
for( Player p : etc.getServer().getPlayerList())
|
|
||||||
{
|
|
||||||
if (p.getName().equalsIgnoreCase(split[1]))
|
|
||||||
{
|
|
||||||
playerTarget = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( playerTarget!=null)
|
|
||||||
{
|
|
||||||
String playerTargetGroup[] = playerTarget.getGroups();
|
|
||||||
String playerGroup[] = player.getGroups();
|
|
||||||
player.sendMessage("Debug data:");
|
|
||||||
player.sendMessage("PlayerTarget: "+playerTargetGroup[0]);
|
|
||||||
player.sendMessage("Player: "+playerGroup[0]);
|
|
||||||
if(playerTargetGroup[0].equals("admins"))
|
|
||||||
{
|
|
||||||
player.sendMessage(Colors.Rose + "You can not promote " + split[1] + " any higher.");
|
|
||||||
}
|
|
||||||
if(playerTargetGroup[0].equals("mods") && (playerGroup[0].equals("owner")))
|
|
||||||
{
|
|
||||||
playerTarget.setGroups(ranks.Admins);
|
|
||||||
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
|
||||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin";
|
|
||||||
other.gmsg(message);
|
|
||||||
}
|
|
||||||
else if (playerTargetGroup[0].equals("trusted") && (playerGroup[0].equals("admins") || playerGroup[0].equals("owner")))
|
|
||||||
{
|
|
||||||
playerTarget.setGroups(ranks.Mods);
|
|
||||||
playerTargetGroup[0]="Mods";
|
|
||||||
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
|
||||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod";
|
|
||||||
other.gmsg(message);
|
|
||||||
}
|
|
||||||
else if (playerTargetGroup[0].equals("default") && (playerGroup[0].equals("mods") || playerGroup[0].equals("admins") || player.isInGroup("owner")))
|
|
||||||
{
|
|
||||||
playerTarget.setGroups(ranks.Trusted);
|
|
||||||
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
|
||||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted";
|
|
||||||
other.gmsg(message);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
player.sendMessage(Colors.Rose + "Player not found");
|
|
||||||
}
|
|
||||||
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Demote
|
|
||||||
if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote"))
|
|
||||||
{
|
|
||||||
if(split.length != 2)
|
|
||||||
{
|
|
||||||
player.sendMessage(Colors.Rose + "Usage is /demote [Player]");
|
|
||||||
}
|
|
||||||
|
|
||||||
Player playerTarget = null;
|
|
||||||
|
|
||||||
for( Player p : etc.getServer().getPlayerList())
|
|
||||||
{
|
|
||||||
if (p.getName().equalsIgnoreCase(split[1]))
|
|
||||||
{
|
|
||||||
playerTarget = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( playerTarget!=null)
|
|
||||||
{
|
|
||||||
if(playerTarget.isInGroup("admins") && (player.isInGroup("superadmins")))
|
|
||||||
{
|
|
||||||
playerTarget.setGroups(ranks.Mods);
|
|
||||||
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
|
||||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod";
|
|
||||||
other.gmsg(message);
|
|
||||||
}
|
|
||||||
if(playerTarget.isInGroup("mods") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
|
|
||||||
{
|
|
||||||
playerTarget.setGroups(ranks.Trusted);
|
|
||||||
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
|
||||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted";
|
|
||||||
other.gmsg(message);
|
|
||||||
}
|
|
||||||
else if (playerTarget.isInGroup("trusted") && (player.isInGroup("mods") || player.isInGroup("superadmins") || player.isInGroup("admins")))
|
|
||||||
{
|
|
||||||
playerTarget.setGroups(ranks.Def);
|
|
||||||
etc.getInstance().getDataSource().modifyPlayer(playerTarget);
|
|
||||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default";
|
|
||||||
other.gmsg(message);
|
|
||||||
}
|
|
||||||
else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins")))
|
|
||||||
{
|
|
||||||
player.sendMessage(Colors.Rose + "You can not demote " + split[1] + " any lower.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
player.sendMessage(Colors.Rose + "Player not found");
|
|
||||||
}
|
|
||||||
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//Whois will display info about a player
|
|
||||||
if (settings.getInstance().cmdWhoIs() && split[0].equalsIgnoreCase("/whois")) {
|
|
||||||
if (split.length < 2) {
|
|
||||||
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
|
|
||||||
}
|
}
|
||||||
String admin ="";
|
else if (vminecraftSettings.getInstance().globalmessages() && player.getHealth() < 1) {
|
||||||
String ignore ="";
|
vminecraftChat.gmsg(Colors.Gray + player.getName() + " is no more");
|
||||||
String IP = "";
|
|
||||||
Player playerTarget = null;
|
|
||||||
for( Player p : etc.getServer().getPlayerList())
|
|
||||||
{
|
|
||||||
if (p.getName().equalsIgnoreCase(split[1]))
|
|
||||||
{
|
|
||||||
playerTarget = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (playerTarget != null){
|
|
||||||
|
|
||||||
IP = playerTarget.getIP();
|
|
||||||
if (playerTarget.canIgnoreRestrictions()) {
|
|
||||||
ignore = "True";
|
|
||||||
} else {
|
|
||||||
ignore ="False";
|
|
||||||
}
|
|
||||||
if (playerTarget.canIgnoreRestrictions()) {
|
|
||||||
admin = "True";
|
|
||||||
} else {
|
|
||||||
admin = "False";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Displaying the information
|
|
||||||
player.sendMessage(Colors.Blue + "Whois results for "+split[1]+".");
|
|
||||||
//Group
|
|
||||||
for (String group : playerTarget.getGroups()) {
|
|
||||||
player.sendMessage(Colors.Blue + "Groups: "+group);
|
|
||||||
}
|
}
|
||||||
//Admin
|
return false;
|
||||||
player.sendMessage(Colors.Blue+"Admin: "+admin);
|
}
|
||||||
//IP
|
}
|
||||||
player.sendMessage(Colors.Blue+"IP: "+IP);
|
|
||||||
//Restrictions
|
|
||||||
player.sendMessage(Colors.Blue+"Can ignore restrictions: "+ignore);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
player.sendMessage(Colors.Rose+"Player not found.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//Say
|
|
||||||
if (settings.getInstance().cmdSay() && (split[0].equalsIgnoreCase("/say"))) {
|
|
||||||
String sayan;
|
|
||||||
sayan = etc.combineSplit(1, split, " ");
|
|
||||||
other.gmsg(Colors.Yellow+sayan);
|
|
||||||
}
|
|
||||||
//Should this be included?
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//Needs to be included
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +1,24 @@
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
//=====================================================================
|
||||||
* vminecraft Plugin
|
//Class: vMinecraftPlugin
|
||||||
* @author Robert, TrapAlice
|
//Use: Starts the plugin
|
||||||
*/
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
//This is how we setup the listener
|
//=====================================================================
|
||||||
public class vminecraftPlugin extends Plugin {
|
public class vminecraftPlugin extends Plugin {
|
||||||
static final vminecraftListener listener = new vminecraftListener();
|
static final vminecraftListener listener = new vminecraftListener();
|
||||||
public void enable() {
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
//If we had commands we would add them here.
|
|
||||||
etc.getInstance().addCommand("/masstp", "Teleports those with lower permissions to you");
|
public void enable() {
|
||||||
etc.getInstance().addCommand("/rules", "Displays the rules");
|
//Hopefully this will make the plugin load right away
|
||||||
etc.getInstance().addCommand("/fabulous", "makes text SUUUPER");
|
try {
|
||||||
etc.getInstance().addCommand("/whois", "/whois [user]");
|
vminecraftSettings.getInstance().loadSettings();
|
||||||
try {
|
} catch (IOException e) {
|
||||||
settings.getInstance().loadSettings(); //Hopefully this will make the plugin load right away
|
log.log(Level.SEVERE, "Exception while loading settings ", e);
|
||||||
} catch (IOException ex) {
|
}
|
||||||
Logger.getLogger(vminecraftPlugin.class.getName()).log(Level.SEVERE, null, ex);
|
vminecraftCommands.loadCommands();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
@ -32,7 +30,7 @@ public class vminecraftPlugin extends Plugin {
|
|||||||
etc.getLoader().addListener(PluginLoader.Hook.CHAT, listener, this, PluginListener.Priority.MEDIUM);
|
etc.getLoader().addListener(PluginLoader.Hook.CHAT, listener, this, PluginListener.Priority.MEDIUM);
|
||||||
etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.HIGH);
|
etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.HIGH);
|
||||||
if(etc.getInstance().isHealthEnabled()){
|
if(etc.getInstance().isHealthEnabled()){
|
||||||
etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM);
|
etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
190
vminecraftSettings.java
Normal file
190
vminecraftSettings.java
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
//=====================================================================
|
||||||
|
//Class: vminecraftSettings
|
||||||
|
//Use: Controls the settings for vminecraft
|
||||||
|
//Author: nossr50, TrapAlice, cerevisiae
|
||||||
|
//=====================================================================
|
||||||
|
public class vminecraftSettings {
|
||||||
|
//private final static Object syncLock = new Object();
|
||||||
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
private static volatile vminecraftSettings instance;
|
||||||
|
//Invulnerability List
|
||||||
|
|
||||||
|
|
||||||
|
//The feature settings
|
||||||
|
static boolean toggle = true,
|
||||||
|
adminChat = false,
|
||||||
|
greentext = false,
|
||||||
|
FFF = false,
|
||||||
|
quakeColors = false,
|
||||||
|
cmdFabulous = false,
|
||||||
|
cmdPromote = false,
|
||||||
|
cmdDemote = false,
|
||||||
|
cmdWhoIs = false,
|
||||||
|
cmdRules = false,
|
||||||
|
cmdMasstp = false,
|
||||||
|
cmdTp = false,
|
||||||
|
cmdTphere = false,
|
||||||
|
globalmessages = false,
|
||||||
|
cmdSay = false,
|
||||||
|
cmdWho = false,
|
||||||
|
cmdEzModo = false;
|
||||||
|
|
||||||
|
//An array of players currently in ezmodo
|
||||||
|
static ArrayList<String> ezModo = new ArrayList<String>();
|
||||||
|
//The max health for ezModo
|
||||||
|
static int ezHealth = 30;
|
||||||
|
|
||||||
|
private PropertiesFile properties;
|
||||||
|
String file = "vminecraft.properties";
|
||||||
|
public String rules[] = null;
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: loadSettings
|
||||||
|
//Input: None
|
||||||
|
//Output: None
|
||||||
|
//Use: Loads the settings from the properties
|
||||||
|
//=====================================================================
|
||||||
|
public void loadSettings() throws IOException
|
||||||
|
{
|
||||||
|
File theDir = new File("vminecraft.properties");
|
||||||
|
if(!theDir.exists()){
|
||||||
|
String location = "vminecraft.properties";
|
||||||
|
properties = new PropertiesFile("vminecraft.properties");
|
||||||
|
FileWriter writer = null;
|
||||||
|
try {
|
||||||
|
writer = new FileWriter(location);
|
||||||
|
writer.write("#This plugin is modular\r\n");
|
||||||
|
writer.write("#Turn any features you don't want to false and they won't be running\r\n");
|
||||||
|
writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n");
|
||||||
|
writer.write("greentext=true\r\n");
|
||||||
|
writer.write("quakeColors=true\r\n");
|
||||||
|
writer.write("cmdTphere=true\r\n");
|
||||||
|
writer.write("cmdFabulous=true\r\n");
|
||||||
|
writer.write("cmdWhoIs=true\r\n");
|
||||||
|
writer.write("cmdWho=true\r\n");
|
||||||
|
writer.write("cmdPromote=true\r\n");
|
||||||
|
writer.write("cmdDemote=true\r\n");
|
||||||
|
writer.write("cmdMasstp=true\r\n");
|
||||||
|
writer.write("cmdSay=true\r\n");
|
||||||
|
writer.write("cmdTp=true\r\n");
|
||||||
|
writer.write("cmdRules=true\r\n");
|
||||||
|
writer.write("globalmessages=true\r\n");
|
||||||
|
writer.write("FFF=true\r\n");
|
||||||
|
writer.write("adminchat=true\r\n");
|
||||||
|
writer.write("cmdEzModo=true\r\n");
|
||||||
|
writer.write("ezModo=\r\n");
|
||||||
|
writer.write("ezHealth=30\r\n");
|
||||||
|
writer.write("rules=Rules@#1: No griefing@#2: No griefing\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("vminecraft.properties");
|
||||||
|
properties.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
adminChat = properties.getBoolean("adminchat",true);
|
||||||
|
greentext = properties.getBoolean("greentext",true);
|
||||||
|
FFF = properties.getBoolean("FFF",true);
|
||||||
|
quakeColors = properties.getBoolean("quakeColors",true);
|
||||||
|
cmdFabulous = properties.getBoolean("cmdFabulous",true);
|
||||||
|
cmdPromote = properties.getBoolean("cmdPromote",true);
|
||||||
|
cmdDemote = properties.getBoolean("cmdDemote",true);
|
||||||
|
cmdWhoIs = properties.getBoolean("cmdWhoIs",true);
|
||||||
|
cmdWhoIs = properties.getBoolean("cmdWho",true);
|
||||||
|
cmdRules = properties.getBoolean("cmdRules",true);
|
||||||
|
cmdTp = properties.getBoolean("cmdTp",true);
|
||||||
|
cmdMasstp = properties.getBoolean("cmdMasstp",true);
|
||||||
|
cmdTphere = properties.getBoolean("cmdTphere",true);
|
||||||
|
globalmessages = properties.getBoolean("globalmessages",true);
|
||||||
|
cmdSay = properties.getBoolean("cmdSay",true);
|
||||||
|
cmdEzModo = properties.getBoolean("cmdEzModo",true);
|
||||||
|
rules = properties.getString("rules", "").split("@");
|
||||||
|
|
||||||
|
String[] tempEz = properties.getString("ezModo").split(",");
|
||||||
|
ezModo = new ArrayList<String>();
|
||||||
|
for(int i = 0; i < tempEz.length; i++)
|
||||||
|
ezModo.add(tempEz[i]);
|
||||||
|
|
||||||
|
ezHealth = properties.getInt("ezHealth");
|
||||||
|
|
||||||
|
log.log(Level.INFO, "vminecraft plugin successfully loaded");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//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 greentext() {return greentext;}
|
||||||
|
public boolean FFF() {return FFF;}
|
||||||
|
public boolean quakeColors() {return quakeColors;}
|
||||||
|
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 cmdEzModo() {return cmdEzModo;}
|
||||||
|
public boolean cmdWho() {return cmdWho;}
|
||||||
|
|
||||||
|
//EzModo functions
|
||||||
|
public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
|
||||||
|
public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
|
||||||
|
public void addEzModo(String playerName) {ezModo.add(playerName);}
|
||||||
|
public int ezModoHealth() {return ezHealth;}
|
||||||
|
public String ezModoList() {return ezModo.toString();}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getInstance
|
||||||
|
//Input: None
|
||||||
|
//Output: vminecraftSettings: The instance of the settings
|
||||||
|
//Use: Returns the instance of the settings
|
||||||
|
//=====================================================================
|
||||||
|
public static vminecraftSettings getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new vminecraftSettings();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: getRules
|
||||||
|
//Input: None
|
||||||
|
//Output: String[]: The list of rules
|
||||||
|
//Use: Gets the array containing the rules
|
||||||
|
//=====================================================================
|
||||||
|
public String[] getRules() {
|
||||||
|
return rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user