mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
Changed everything to work with hey0's MCSM b104
This commit is contained in:
parent
94e2089e41
commit
5f6ecbce8c
@ -1,17 +0,0 @@
|
|||||||
//This doesn't do anything yet, eventually you will be able to toggle features by writing true or false in vminecraft-config.txt
|
|
||||||
//This is high up on my priority list
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
public class txtfiles {
|
|
||||||
static final Logger log = Logger.getLogger("Minecraft");
|
|
||||||
private final static Object syncLock = new Object();
|
|
||||||
static boolean toggle = true;
|
|
||||||
private PropertiesFile properties;
|
|
||||||
//Unfinished was interrupted in the middle of making this shit, where we can triggle toggles in a text file for commands
|
|
||||||
//example return true for greentext=true in vminecraft.properties file would disable that code
|
|
||||||
}
|
|
258
vminecraft.java
258
vminecraft.java
@ -2,7 +2,7 @@
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
public class vminecraft extends Plugin {
|
public class vminecraft extends Plugin {
|
||||||
|
//settings Settings;
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
//throw new UnsupportedOperationException("Not supported yet.");
|
//throw new UnsupportedOperationException("Not supported yet.");
|
||||||
@ -15,16 +15,25 @@ public class vminecraft extends Plugin {
|
|||||||
//I have to include this to compile, not sure why.
|
//I have to include this to compile, not sure why.
|
||||||
}
|
}
|
||||||
static final Logger log = Logger.getLogger("Minecraft");
|
static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLogin(Player player)
|
||||||
|
{
|
||||||
|
settings.getInstance().loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onChat(Player player, String message){
|
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 playerb = player.getName(); //Used to get names from players, can't remember why I can't just use 'player'
|
||||||
String temp2 = "<" + etc.getInstance().getUserColor(playerb) + player.getName() + Colors.White +"> "; //Inserts a name before the message
|
String temp2 = "<" + player.getColor() + player.getName() + Colors.White +"> "; //Inserts a name before the message
|
||||||
String adminchat = Colors.LightGreen + "{" + etc.getInstance().getUserColor(playerb) + player.getName() + Colors.LightGreen +"}" + Colors.White + " "; //Inserts names admin chat style before the message
|
String adminchat = Colors.LightGreen + "{" + player.getColor() + player.getName() + Colors.LightGreen +"}" + Colors.White + " "; //Inserts names admin chat style before the message
|
||||||
String message2 = ""; //Used for greentext and FFF
|
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
|
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 (message.startsWith("@") && (etc.getInstance().isUserInGroup(player, "mods") || etc.getInstance().isUserInGroup(player, "admins") || etc.getInstance().isUserInGroup(player, "superadmins"))) {
|
if (settings.getInstance().adminchat()&&message.startsWith("@") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins"))) {
|
||||||
for (Player p : etc.getServer().getPlayerList()) {
|
for (Player p : etc.getServer().getPlayerList()) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
if (etc.getInstance().isUserInGroup(p, "mods") || (etc.getInstance().isUserInGroup(p, "admins")) || (etc.getInstance().isUserInGroup(p, "superadmins"))) {
|
if (player.isInGroup("mods") || (player.isInGroup("admins")) || (player.isInGroup("superadmins"))) {
|
||||||
String blaa = "";
|
String blaa = "";
|
||||||
for ( int x = 1; x< message.length(); x++) {
|
for ( int x = 1; x< message.length(); x++) {
|
||||||
blaa+=message.charAt(x);
|
blaa+=message.charAt(x);
|
||||||
@ -37,23 +46,25 @@ public class vminecraft extends Plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//Greentext
|
//Greentext
|
||||||
if (message.startsWith(">")) {
|
if (settings.getInstance().greentext()&&message.startsWith(">")) {
|
||||||
|
id.a.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
message = Colors.LightGreen + message;
|
message = Colors.LightGreen + message;
|
||||||
message2 = temp2 + message;
|
message2 = temp2 + message;
|
||||||
other.gmsg(message2);
|
other.gmsg(message2);
|
||||||
id.a.log(Level.INFO, message2);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//FFF
|
//FFF
|
||||||
if (message.startsWith("FFF")) {
|
if (settings.getInstance().FFF()&&message.startsWith("FFF")) {
|
||||||
|
id.a.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
message = Colors.Red + message;
|
message = Colors.Red + message;
|
||||||
message2 = temp2 + message;
|
message2 = temp2 + message;
|
||||||
other.gmsg(message2);
|
other.gmsg(message2);
|
||||||
id.a.log(Level.INFO, message2);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//QuakeColors
|
//QuakeColors
|
||||||
if(message.length()>2 && lengthCheck(check)) {
|
if(settings.getInstance().quakeColors()&&message.length()>2 && lengthCheck(check)) {
|
||||||
String temp = "";
|
String temp = "";
|
||||||
for(int x = 0; x< message.length(); x++)
|
for(int x = 0; x< message.length(); x++)
|
||||||
{
|
{
|
||||||
@ -66,11 +77,12 @@ public class vminecraft extends Plugin {
|
|||||||
temp+=message.charAt(x);
|
temp+=message.charAt(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
message = temp2 + temp + " ";
|
message = temp2 + temp + " ";
|
||||||
for (Player p : etc.getServer().getPlayerList()) {
|
for (Player p : etc.getServer().getPlayerList()) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
other.gmsg(message);
|
other.gmsg(message);
|
||||||
log.log(Level.INFO, message);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,22 +90,23 @@ public class vminecraft extends Plugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean onCommand(Player player, String[] split) {
|
public boolean onCommand(Player player, String[] split) {
|
||||||
if (!etc.getInstance().canUseCommand(player.getName(), split[0])) {
|
if (player.canUseCommand(split[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Fabulous
|
//Fabulous
|
||||||
if (split[0].equalsIgnoreCase("/fabulous")) {
|
if (split[0].equalsIgnoreCase("/fabulous")&&settings.getInstance().cmdFabulous()) {
|
||||||
etc.getInstance().addCommand("/fabulous", "/fabulous <message>");
|
etc.getInstance().addCommand("/fabulous", "/fabulous <message>");
|
||||||
if (split.length == 1) {return false;}
|
if (split.length == 1) {return false;}
|
||||||
String temp = "";
|
String temp = "";
|
||||||
String str = "";
|
String str = "";
|
||||||
//str = paramString.substring(paramString.indexOf(" ")).trim();
|
//str = paramString.substring(paramString.indexOf(" ")).trim();
|
||||||
str = id.combineSplit(1, split, " ");
|
str = etc.combineSplit(1, split, " ");
|
||||||
String temp2 = "<" + player.getName() + "> "+str;
|
String temp2 = "<" + player.getName() + "> "+str;
|
||||||
String[] rainbow = new String[] {Colors.Red, Colors.Rose, Colors.Yellow, Colors.Green, Colors.Blue, Colors.LightPurple, Colors.Purple};
|
String[] rainbow = new String[] {Colors.Red, Colors.Rose, Colors.Yellow, Colors.Green, Colors.Blue, Colors.LightPurple, Colors.Purple};
|
||||||
int counter=0;
|
int counter=0;
|
||||||
if(lengthCheck(temp2))
|
if(lengthCheck(temp2))
|
||||||
{
|
{
|
||||||
|
id.a.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\"");
|
||||||
for(int x=0; x<str.length(); x++)
|
for(int x=0; x<str.length(); x++)
|
||||||
{
|
{
|
||||||
temp+=rainbow[counter]+str.charAt(x);
|
temp+=rainbow[counter]+str.charAt(x);
|
||||||
@ -103,113 +116,116 @@ public class vminecraft extends Plugin {
|
|||||||
if(counter==7){counter = 0; }
|
if(counter==7){counter = 0; }
|
||||||
}
|
}
|
||||||
str = temp+" ";
|
str = temp+" ";
|
||||||
String message = "<" + etc.getInstance().getUserColor(player.getName()) + player.getName() + Colors.White + "> " + str;
|
String message = "<" + player.getColor() + player.getName() + Colors.White + "> " + str;
|
||||||
id.a.log(Level.INFO, "[F]"+str);
|
|
||||||
other.gmsg(message);
|
other.gmsg(message);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Colors.Rose + "Message is too long");
|
player.sendMessage(Colors.Rose + "Message is too long");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Promote
|
//Promote
|
||||||
else if (split[0].equalsIgnoreCase("/promote")) {
|
else if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote"))
|
||||||
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
{
|
||||||
User user2 = etc.getInstance().getUser(split[1]);
|
if(split.length != 2)
|
||||||
if (split.length < 2) {
|
{
|
||||||
player.sendMessage(Colors.Rose + "Usage is /promote [player]");
|
player.sendMessage(Colors.Rose + "Usage is /promote [Player]");
|
||||||
}
|
}
|
||||||
if(user2 == null) { //Currently broken
|
|
||||||
player.sendMessage(Colors.Rose + "Player does not exist.");
|
Player playerTarget = null;
|
||||||
return false;
|
|
||||||
}
|
for( Player p : etc.getServer().getPlayerList())
|
||||||
//ea player = match(split[1]);
|
{
|
||||||
User user = etc.getInstance().getUser(split[1]);
|
if (p.getName().equalsIgnoreCase(split[1]))
|
||||||
boolean newUser = false;
|
{
|
||||||
if (user == null) {
|
playerTarget = p;
|
||||||
player.sendMessage(Colors.Rose + "Adding new user.");
|
}
|
||||||
newUser = true;
|
}
|
||||||
user = new User();
|
|
||||||
user.Name = split[1];
|
if( playerTarget!=null)
|
||||||
user.Administrator = false;
|
{
|
||||||
user.CanModifyWorld = true;
|
if(playerTarget.isInGroup("admins"))
|
||||||
user.IgnoreRestrictions = false;
|
{
|
||||||
user.Commands = new String[]{""};
|
player.sendMessage(Colors.Rose + "You can not promote " + split[1] + " any higher.");
|
||||||
user.Prefix = "";
|
}
|
||||||
log.log(Level.INFO, player + " added new user ("+user+")"); //Not sure about keeping this
|
if(playerTarget.isInGroup("mods") && (player.isInGroup("superadmins")))
|
||||||
return false;
|
{
|
||||||
}
|
playerTarget.setGroups(ranks.Admins);
|
||||||
if (etc.getInstance().isUserInGroup(split[1], "admins") && (etc.getInstance().isUserInGroup(player, "admins") || etc.getInstance().isUserInGroup(player, "superadmins"))) {
|
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||||
player.sendMessage(Colors.Rose + "You cannot promote " + split[1] + " any higher.");
|
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin";
|
||||||
} else if (etc.getInstance().isUserInGroup(split[1], "mods") && etc.getInstance().isUserInGroup(player, "superadmins")) {
|
other.gmsg(message);
|
||||||
user.Groups = ranks.Admins;
|
}
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
else if (playerTarget.isInGroup("trusted") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin";
|
{
|
||||||
other.gmsg(message);
|
playerTarget.setGroups(ranks.Mods);
|
||||||
} else if (etc.getInstance().isUserInGroup(split[1], "trusted") && etc.getInstance().isUserInGroup(player, "admins")) {
|
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||||
user.Groups = ranks.Mods;
|
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod";
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
other.gmsg(message);
|
||||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mods";
|
}
|
||||||
other.gmsg(message);
|
else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||||
} else if (etc.getInstance().isUserInGroup(split[1], "default") && etc.getInstance().isUserInGroup(player, "mods")) {
|
{
|
||||||
user.Groups = ranks.Trusted;
|
player.setGroups(ranks.Trusted);
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted";
|
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted";
|
||||||
other.gmsg(message);
|
other.gmsg(message);
|
||||||
} else player.sendMessage(Colors.Rose + "That didn't work");
|
}
|
||||||
if (newUser) {
|
}
|
||||||
etc.getInstance().getDataSource().addUser(user);
|
else{
|
||||||
} else {
|
player.sendMessage(Colors.Rose + "Player not found");
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
}
|
||||||
}
|
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
||||||
}
|
}
|
||||||
//Demote
|
//Demote
|
||||||
else if (split[0].equalsIgnoreCase("/demote")) {
|
else if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote"))
|
||||||
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
{
|
||||||
etc.getInstance().addCommand("/demote", "/demote [user]");
|
if(split.length != 2)
|
||||||
if (split.length < 2) {
|
{
|
||||||
player.sendMessage(Colors.Rose + "Usage is /demote [player]");
|
player.sendMessage(Colors.Rose + "Usage is /demote [Player]");
|
||||||
}
|
}
|
||||||
if(player == null) { //Currently broken
|
|
||||||
player.sendMessage(Colors.Rose + "Player does not exist.");
|
Player playerTarget = null;
|
||||||
return false;
|
|
||||||
}
|
for( Player p : etc.getServer().getPlayerList())
|
||||||
User user = etc.getInstance().getUser(split[1]);
|
{
|
||||||
boolean newUser = false;
|
if (p.getName().equalsIgnoreCase(split[1]))
|
||||||
if (user == null) {
|
{
|
||||||
player.sendMessage(Colors.Rose + "Adding new user.");
|
playerTarget = p;
|
||||||
newUser = true;
|
}
|
||||||
user = new User();
|
}
|
||||||
user.Name = split[1];
|
|
||||||
user.Administrator = false;
|
if( playerTarget!=null)
|
||||||
user.CanModifyWorld = true;
|
{
|
||||||
user.IgnoreRestrictions = false;
|
if(playerTarget.isInGroup("admins") && (player.isInGroup("superadmins")))
|
||||||
user.Commands = new String[]{""};
|
{
|
||||||
user.Prefix = "";
|
playerTarget.setGroups(ranks.Mods);
|
||||||
}
|
|
||||||
if (etc.getInstance().isUserInGroup(split[1], "admins")&& etc.getInstance().isUserInGroup(player, "superadmins")) {
|
|
||||||
user.Groups = ranks.Mods;
|
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
|
||||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod";
|
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod";
|
||||||
other.gmsg(message);
|
other.gmsg(message);
|
||||||
} else if (etc.getInstance().isUserInGroup(split[1], "mods")&& etc.getInstance().isUserInGroup(player, "admins")) {
|
}
|
||||||
user.Groups = ranks.Trusted;
|
if(playerTarget.isInGroup("mods") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
{
|
||||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted";
|
playerTarget.setGroups(ranks.Trusted);
|
||||||
other.gmsg(message);
|
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||||
} else if (etc.getInstance().isUserInGroup(split[1], "trusted")&& etc.getInstance().isUserInGroup(player, "mods")) {
|
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted";
|
||||||
user.Groups = ranks.Def;
|
other.gmsg(message);
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
}
|
||||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default";
|
else if (playerTarget.isInGroup("trusted") && (player.isInGroup("mods") || player.isInGroup("superadmins") || player.isInGroup("admins")))
|
||||||
other.gmsg(message);
|
{
|
||||||
} else if (etc.getInstance().isUserInGroup(split[1], "default")) {
|
playerTarget.setGroups(ranks.Def);
|
||||||
player.sendMessage(Colors.Rose + "You cannot demote " + split[1] + " any lower.");
|
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||||
} else player.sendMessage(Colors.Rose + "That didn't work");
|
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default";
|
||||||
if (newUser) {
|
other.gmsg(message);
|
||||||
etc.getInstance().getDataSource().addUser(user);
|
}
|
||||||
} else {
|
else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||||
etc.getInstance().getDataSource().modifyUser(user);
|
{
|
||||||
}
|
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]+" ");
|
||||||
|
}
|
||||||
//Whois will display info about a player
|
//Whois will display info about a player
|
||||||
} else if (split[0].equalsIgnoreCase("/whois")) {
|
else if (settings.getInstance().cmdWhoIs()&&split[0].equalsIgnoreCase("/whois")) {
|
||||||
String admin ="";
|
String admin ="";
|
||||||
String group ="";
|
String group ="";
|
||||||
String ignore ="";
|
String ignore ="";
|
||||||
@ -218,23 +234,23 @@ public class vminecraft extends Plugin {
|
|||||||
if (split.length < 2) {
|
if (split.length < 2) {
|
||||||
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
|
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
|
||||||
}
|
}
|
||||||
if (etc.getInstance().canIgnoreRestrictions(split[1])) {
|
if (player.canIgnoreRestrictions()) {
|
||||||
ignore = "True";
|
ignore = "True";
|
||||||
} else {
|
} else {
|
||||||
ignore ="False";
|
ignore ="False";
|
||||||
}
|
}
|
||||||
if (etc.getInstance().isAdmin(split[1])) {
|
if (player.canIgnoreRestrictions()) {
|
||||||
admin = "True";
|
admin = "True";
|
||||||
} else {
|
} else {
|
||||||
admin = "False";
|
admin = "False";
|
||||||
}
|
}
|
||||||
if (etc.getInstance().isUserInGroup(split[1], "superadmins")){
|
if (player.isInGroup("superadmins")){
|
||||||
group = "superadmins";
|
group = "superadmins";
|
||||||
}else if(etc.getInstance().isUserInGroup(split[1], "admins")){
|
}else if(player.isInGroup("admins")){
|
||||||
group = "admins";
|
group = "admins";
|
||||||
}else if(etc.getInstance().isUserInGroup(split[1], "mods")){
|
}else if(player.isInGroup("mods")){
|
||||||
group = "mods";
|
group = "mods";
|
||||||
}else if(etc.getInstance().isUserInGroup(split[1], "trusted")){
|
}else if(player.isInGroup("trusted")){
|
||||||
group = "trusted";
|
group = "trusted";
|
||||||
}else{
|
}else{
|
||||||
group = "Default";
|
group = "Default";
|
||||||
@ -245,6 +261,14 @@ public class vminecraft extends Plugin {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onKick(Player player, String reason)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Calculates how long the specified String is to prevent linebreaks when using scripts that insert color codes, designed to be used with playername included
|
//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)
|
private boolean lengthCheck(String str)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user