123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- //This is where the bulk of the plugin is
- import java.util.Locale;
- import java.util.logging.Logger;
- import java.util.logging.Level;
- public class vminecraft extends Plugin {
- //settings Settings;
- @Override
- public void disable() {
- //throw new UnsupportedOperationException("Not supported yet.");
- //I have to include this to compile, not sure why.
- }
- @Override
- public void enable() {
- //throw new UnsupportedOperationException("Not supported yet.");
- //I have to include this to compile, not sure why.
- }
- static final Logger log = Logger.getLogger("Minecraft");
- @Override
- public void onLogin(Player player)
- {
- settings.getInstance().loadSettings();
- }
- public boolean onChat(Player player, String message){
- //Settings.loadSettings();
- settings.getInstance().loadSettings();
- String playerb = player.getName(); //Used to get names from players, can't remember why I can't just use 'player'
- String temp2 = "<" + player.getColor() + player.getName() + Colors.White +"> "; //Inserts a name before the message
- String adminchat = Colors.DarkPurple + "{" + player.getColor() + player.getName() + Colors.DarkPurple +"}" + Colors.White + " "; //Inserts names admin chat style before the message
- 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.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins"))) {
- for (Player p : etc.getServer().getPlayerList()) {
- String blaa = "";
- if (p != null) {
- if (player.isInGroup("mods") || (player.isInGroup("admins")) || (player.isInGroup("superadmins"))) {
- for ( int x = 1; x< message.length(); x++) {
- blaa+=message.charAt(x);
- }
- if (p.isInGroup("superadmins") || p.isInGroup("mods") || p.isInGroup("admins")){
- if (p != null) {
- p.sendMessage(adminchat+blaa);
- }
- }
- //where logs used to be
- }
- }
- }
- log.log(Level.INFO, "@"+adminchat+message);
- return true;
- }
- //Greentext
- if (settings.getInstance().greentext()&&message.startsWith(">")) {
- id.a.log(Level.INFO, "<"+player.getName()+"> "+message);
- message = Colors.LightGreen + message;
- message2 = temp2 + message;
- other.gmsg(message2);
- return true;
- }
- //FFF
- if (settings.getInstance().FFF()&&message.startsWith("FFF")) {
- id.a.log(Level.INFO, "<"+player.getName()+"> "+message);
- message = Colors.Red + message;
- message2 = temp2 + message;
- other.gmsg(message2);
- return true;
- }
- //QuakeColors
- if(settings.getInstance().quakeColors()&&message.length()>2 && lengthCheck(check)) {
- String temp = "";
- for(int x = 0; x< message.length(); x++)
- {
- if(message.charAt(x)=='^'&&x!=message.length()-1)
- {
- temp+=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;
- }
- public boolean onCommand(Player player, String[] split) {
- if(!player.canUseCommand(split[0])) {
- return false;
- }
- //Replace id's /tp with my own so you can't tele to higher ranked players
- if(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]);
- if (player.getName().equalsIgnoreCase(split[1])) {
- 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;
- }
- }
- }
- //Same thing as my changes to /tp
- if ((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] + ".");
- }
- }
- //Temporary fix, this will still go off if you enter anything for split[1] I need to make it so split[1] is the same name as a real player
- if(split[0].equalsIgnoreCase("/kick")) {
- if (split[1] != null){
- other.gmsg(player.getColor()+player.getName()+Colors.Blue+" used kick.");
- other.gmsg(Colors.Red+split[1]+" was the target.");
- }
- }
- if(split[0].equalsIgnoreCase("/ban")) {
- if (split[1] != null){
- other.gmsg(player.getColor()+player.getName()+Colors.Blue+" used ban.");
- other.gmsg(Colors.Red+split[1]+" was the target.");
- }
- }
- if(split[0].equalsIgnoreCase("/ipban")) {
- if (split[1] != null){
- other.gmsg(player.getColor()+player.getName()+Colors.Blue+" used IP ban.");
- other.gmsg(Colors.Red+split[1]+" was the target.");
- }
- }
- if(split[0].equalsIgnoreCase("/time")) {
- if (split.length <= 2) {
- other.gmsg(Colors.Blue+"Time changes thanks to "+player.getColor()+player.getName());
- return false;
- }
- }
- //Rules
- if(split[0].equalsIgnoreCase("/rules")) {
- etc.getInstance().addCommand("/rules", "Displays the rules");
- player.sendMessage(Colors.Blue + "Rules");
- player.sendMessage(Colors.Blue+"#1:No griefing");
- player.sendMessage(Colors.Blue+"#2:Don't spam night/day changes");
- player.sendMessage(Colors.Blue+"#3:Don't beg for items that you could easily gather");
- player.sendMessage(Colors.Blue+"#4:Don't steal from another players chest");
- player.sendMessage(Colors.Blue+"#5:The admins word is final");
- return true;
- }
- //Fabulous
- if(split[0].equalsIgnoreCase("/fabulous") && settings.getInstance().cmdFabulous()) {
- if (split.length == 1) {return false;}
- String temp = "";
- String str = "";
- //str = paramString.substring(paramString.indexOf(" ")).trim();
- 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(lengthCheck(temp2))
- {
- id.a.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);
- } 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]");
- }
- 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.sendMessage(Colors.Rose + "You can not promote " + split[1] + " any higher.");
- }
- if(playerTarget.isInGroup("mods") && (player.isInGroup("superadmins")))
- {
- 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 (playerTarget.isInGroup("trusted") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
- {
- playerTarget.setGroups(ranks.Mods);
- etc.getInstance().getDataSource().modifyPlayer(playerTarget);
- String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod";
- other.gmsg(message);
- }
- else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins")))
- {
- 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]");
- //This part of the code might not be working right now
- }
- String admin ="";
- String group ="";
- String ignore ="";
- String IP = "";
- Player playerTarget = null;
- for( Player p : etc.getServer().getPlayerList())
- {
- if (p.getName().equalsIgnoreCase(split[1]))
- {
- playerTarget = p;
- }
- }
- if (playerTarget != null){
- etc.getInstance().addCommand("/whois", "/whois [user]");
- IP = playerTarget.getIP();
- if (playerTarget.canIgnoreRestrictions()) {
- ignore = "True";
- } else {
- ignore ="False";
- }
- if (playerTarget.canIgnoreRestrictions()) {
- admin = "True";
- } else {
- admin = "False";
- }
- if (playerTarget.isInGroup("superadmins")){
- group = "superadmins";
- }else if(playerTarget.isInGroup("admins")){
- group = "admins";
- }else if(player.isInGroup("mods")){
- group = "mods";
- }else if(player.isInGroup("trusted")){
- group = "trusted";
- }else{
- group = "Default";
- }
- //Main
- player.sendMessage(Colors.Blue + "Whois results for "+split[1]+".");
- //Info for group
- player.sendMessage(Colors.Blue + "Group: "+group);
- //info for admin
- player.sendMessage(Colors.Blue+"Admin: "+admin);
- //Info for IP
- player.sendMessage(Colors.Blue+"IP: "+IP);
- //Info on restrictions
- player.sendMessage(Colors.Blue+"Can ignore restrictions: "+ignore);
- return true;
- } else {
- player.sendMessage(Colors.Rose+"Player not found.");
- }
- } if (split[0].equalsIgnoreCase("/say")) {
- String sayan;
- sayan = etc.combineSplit(1, split, " ");
- other.gmsg(Colors.Yellow+sayan);
- //Should make a global message to all players
- }
- else {
- return false;
- }
- return true;
- }
- public void onKick(Player player, String reason)
- {
- //other.gmsg(Colors.Red+player.getColor()+player.getName()+Colors.Red+" was kicked.");
- }
- public void onIpBan(Player player, String reason)
- {
- //other.gmsg(Colors.Red+player.getColor()+player.getName()+Colors.Red+" was IP banned.");
- }
- public void onBan(Player player, String reason)
- {
- //other.gmsg(Colors.Red+player.getColor()+player.getName()+Colors.Red+" was banned.");
- }
- //Calculates how long the specified String is to prevent linebreaks when using scripts that insert color codes, designed to be used with playername included
- private 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; }
- }
- //QuakeColors Part 2
- private 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;
- }
- }
|