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
|
||||
}
|
222
vminecraft.java
222
vminecraft.java
@ -2,7 +2,7 @@
|
||||
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.");
|
||||
@ -15,16 +15,25 @@ public class vminecraft extends Plugin {
|
||||
//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 = "<" + etc.getInstance().getUserColor(playerb) + 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 temp2 = "<" + player.getColor() + player.getName() + Colors.White +"> "; //Inserts a name 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 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()) {
|
||||
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 = "";
|
||||
for ( int x = 1; x< message.length(); x++) {
|
||||
blaa+=message.charAt(x);
|
||||
@ -37,23 +46,25 @@ public class vminecraft extends Plugin {
|
||||
return true;
|
||||
}
|
||||
//Greentext
|
||||
if (message.startsWith(">")) {
|
||||
if (settings.getInstance().greentext()&&message.startsWith(">")) {
|
||||
id.a.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||
message = Colors.LightGreen + message;
|
||||
message2 = temp2 + message;
|
||||
other.gmsg(message2);
|
||||
id.a.log(Level.INFO, message2);
|
||||
|
||||
return true;
|
||||
}
|
||||
//FFF
|
||||
if (message.startsWith("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);
|
||||
id.a.log(Level.INFO, message2);
|
||||
|
||||
return true;
|
||||
}
|
||||
//QuakeColors
|
||||
if(message.length()>2 && lengthCheck(check)) {
|
||||
if(settings.getInstance().quakeColors()&&message.length()>2 && lengthCheck(check)) {
|
||||
String temp = "";
|
||||
for(int x = 0; x< message.length(); x++)
|
||||
{
|
||||
@ -66,11 +77,12 @@ public class vminecraft extends Plugin {
|
||||
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);
|
||||
log.log(Level.INFO, message);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -78,22 +90,23 @@ public class vminecraft extends Plugin {
|
||||
return false;
|
||||
}
|
||||
public boolean onCommand(Player player, String[] split) {
|
||||
if (!etc.getInstance().canUseCommand(player.getName(), split[0])) {
|
||||
if (player.canUseCommand(split[0])) {
|
||||
return false;
|
||||
}
|
||||
//Fabulous
|
||||
if (split[0].equalsIgnoreCase("/fabulous")) {
|
||||
if (split[0].equalsIgnoreCase("/fabulous")&&settings.getInstance().cmdFabulous()) {
|
||||
etc.getInstance().addCommand("/fabulous", "/fabulous <message>");
|
||||
if (split.length == 1) {return false;}
|
||||
String temp = "";
|
||||
String str = "";
|
||||
//str = paramString.substring(paramString.indexOf(" ")).trim();
|
||||
str = id.combineSplit(1, split, " ");
|
||||
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);
|
||||
@ -103,113 +116,116 @@ public class vminecraft extends Plugin {
|
||||
if(counter==7){counter = 0; }
|
||||
}
|
||||
str = temp+" ";
|
||||
String message = "<" + etc.getInstance().getUserColor(player.getName()) + player.getName() + Colors.White + "> " + str;
|
||||
id.a.log(Level.INFO, "[F]"+str);
|
||||
String message = "<" + player.getColor() + player.getName() + Colors.White + "> " + str;
|
||||
|
||||
other.gmsg(message);
|
||||
} else {
|
||||
player.sendMessage(Colors.Rose + "Message is too long");
|
||||
}
|
||||
}
|
||||
//Promote
|
||||
else if (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) {
|
||||
player.sendMessage(Colors.Rose + "Usage is /promote [player]");
|
||||
else if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote"))
|
||||
{
|
||||
if(split.length != 2)
|
||||
{
|
||||
player.sendMessage(Colors.Rose + "Usage is /promote [Player]");
|
||||
}
|
||||
if(user2 == null) { //Currently broken
|
||||
player.sendMessage(Colors.Rose + "Player does not exist.");
|
||||
return false;
|
||||
|
||||
Player playerTarget = null;
|
||||
|
||||
for( Player p : etc.getServer().getPlayerList())
|
||||
{
|
||||
if (p.getName().equalsIgnoreCase(split[1]))
|
||||
{
|
||||
playerTarget = p;
|
||||
}
|
||||
//ea player = match(split[1]);
|
||||
User user = etc.getInstance().getUser(split[1]);
|
||||
boolean newUser = false;
|
||||
if (user == null) {
|
||||
player.sendMessage(Colors.Rose + "Adding new user.");
|
||||
newUser = true;
|
||||
user = new User();
|
||||
user.Name = split[1];
|
||||
user.Administrator = false;
|
||||
user.CanModifyWorld = true;
|
||||
user.IgnoreRestrictions = false;
|
||||
user.Commands = new String[]{""};
|
||||
user.Prefix = "";
|
||||
log.log(Level.INFO, player + " added new user ("+user+")"); //Not sure about keeping this
|
||||
return false;
|
||||
}
|
||||
if (etc.getInstance().isUserInGroup(split[1], "admins") && (etc.getInstance().isUserInGroup(player, "admins") || etc.getInstance().isUserInGroup(player, "superadmins"))) {
|
||||
player.sendMessage(Colors.Rose + "You cannot promote " + split[1] + " any higher.");
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "mods") && etc.getInstance().isUserInGroup(player, "superadmins")) {
|
||||
user.Groups = ranks.Admins;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
|
||||
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(player);
|
||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin";
|
||||
other.gmsg(message);
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "trusted") && etc.getInstance().isUserInGroup(player, "admins")) {
|
||||
user.Groups = ranks.Mods;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mods";
|
||||
}
|
||||
else if (playerTarget.isInGroup("trusted") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||
{
|
||||
playerTarget.setGroups(ranks.Mods);
|
||||
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod";
|
||||
other.gmsg(message);
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "default") && etc.getInstance().isUserInGroup(player, "mods")) {
|
||||
user.Groups = ranks.Trusted;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
}
|
||||
else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||
{
|
||||
player.setGroups(ranks.Trusted);
|
||||
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||
String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted";
|
||||
other.gmsg(message);
|
||||
} else player.sendMessage(Colors.Rose + "That didn't work");
|
||||
if (newUser) {
|
||||
etc.getInstance().getDataSource().addUser(user);
|
||||
} else {
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
}
|
||||
}
|
||||
//Demote
|
||||
else if (split[0].equalsIgnoreCase("/demote")) {
|
||||
else{
|
||||
player.sendMessage(Colors.Rose + "Player not found");
|
||||
}
|
||||
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
||||
etc.getInstance().addCommand("/demote", "/demote [user]");
|
||||
if (split.length < 2) {
|
||||
player.sendMessage(Colors.Rose + "Usage is /demote [player]");
|
||||
}
|
||||
//Demote
|
||||
else if (settings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote"))
|
||||
{
|
||||
if(split.length != 2)
|
||||
{
|
||||
player.sendMessage(Colors.Rose + "Usage is /demote [Player]");
|
||||
}
|
||||
if(player == null) { //Currently broken
|
||||
player.sendMessage(Colors.Rose + "Player does not exist.");
|
||||
return false;
|
||||
|
||||
Player playerTarget = null;
|
||||
|
||||
for( Player p : etc.getServer().getPlayerList())
|
||||
{
|
||||
if (p.getName().equalsIgnoreCase(split[1]))
|
||||
{
|
||||
playerTarget = p;
|
||||
}
|
||||
User user = etc.getInstance().getUser(split[1]);
|
||||
boolean newUser = false;
|
||||
if (user == null) {
|
||||
player.sendMessage(Colors.Rose + "Adding new user.");
|
||||
newUser = true;
|
||||
user = new User();
|
||||
user.Name = split[1];
|
||||
user.Administrator = false;
|
||||
user.CanModifyWorld = true;
|
||||
user.IgnoreRestrictions = false;
|
||||
user.Commands = new String[]{""};
|
||||
user.Prefix = "";
|
||||
}
|
||||
if (etc.getInstance().isUserInGroup(split[1], "admins")&& etc.getInstance().isUserInGroup(player, "superadmins")) {
|
||||
user.Groups = ranks.Mods;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
|
||||
if( playerTarget!=null)
|
||||
{
|
||||
if(playerTarget.isInGroup("admins") && (player.isInGroup("superadmins")))
|
||||
{
|
||||
playerTarget.setGroups(ranks.Mods);
|
||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod";
|
||||
other.gmsg(message);
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "mods")&& etc.getInstance().isUserInGroup(player, "admins")) {
|
||||
user.Groups = ranks.Trusted;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
}
|
||||
if(playerTarget.isInGroup("mods") && (player.isInGroup("admins") || player.isInGroup("superadmins")))
|
||||
{
|
||||
playerTarget.setGroups(ranks.Trusted);
|
||||
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted";
|
||||
other.gmsg(message);
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "trusted")&& etc.getInstance().isUserInGroup(player, "mods")) {
|
||||
user.Groups = ranks.Def;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
}
|
||||
else if (playerTarget.isInGroup("trusted") && (player.isInGroup("mods") || player.isInGroup("superadmins") || player.isInGroup("admins")))
|
||||
{
|
||||
playerTarget.setGroups(ranks.Def);
|
||||
etc.getInstance().getDataSource().modifyPlayer(player);
|
||||
String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default";
|
||||
other.gmsg(message);
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "default")) {
|
||||
player.sendMessage(Colors.Rose + "You cannot demote " + split[1] + " any lower.");
|
||||
} else player.sendMessage(Colors.Rose + "That didn't work");
|
||||
if (newUser) {
|
||||
etc.getInstance().getDataSource().addUser(user);
|
||||
} else {
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
}
|
||||
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]+" ");
|
||||
}
|
||||
//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 group ="";
|
||||
String ignore ="";
|
||||
@ -218,23 +234,23 @@ public class vminecraft extends Plugin {
|
||||
if (split.length < 2) {
|
||||
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
|
||||
}
|
||||
if (etc.getInstance().canIgnoreRestrictions(split[1])) {
|
||||
if (player.canIgnoreRestrictions()) {
|
||||
ignore = "True";
|
||||
} else {
|
||||
ignore ="False";
|
||||
}
|
||||
if (etc.getInstance().isAdmin(split[1])) {
|
||||
if (player.canIgnoreRestrictions()) {
|
||||
admin = "True";
|
||||
} else {
|
||||
admin = "False";
|
||||
}
|
||||
if (etc.getInstance().isUserInGroup(split[1], "superadmins")){
|
||||
if (player.isInGroup("superadmins")){
|
||||
group = "superadmins";
|
||||
}else if(etc.getInstance().isUserInGroup(split[1], "admins")){
|
||||
}else if(player.isInGroup("admins")){
|
||||
group = "admins";
|
||||
}else if(etc.getInstance().isUserInGroup(split[1], "mods")){
|
||||
}else if(player.isInGroup("mods")){
|
||||
group = "mods";
|
||||
}else if(etc.getInstance().isUserInGroup(split[1], "trusted")){
|
||||
}else if(player.isInGroup("trusted")){
|
||||
group = "trusted";
|
||||
}else{
|
||||
group = "Default";
|
||||
@ -245,6 +261,14 @@ public class vminecraft extends Plugin {
|
||||
}
|
||||
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
|
||||
private boolean lengthCheck(String str)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user