mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Merge branch 'master' of git@github.com:nossr50/vminecraft-plugin.git
Conflicts: README vminecraft.java
This commit is contained in:
commit
fd3df0696e
7
TODO
Normal file
7
TODO
Normal file
@ -0,0 +1,7 @@
|
||||
TODO:
|
||||
Improve logging
|
||||
Fix existing bugs in /promote and /demote
|
||||
Add toggles to all features
|
||||
Add more info if I can think of anything useful to /whois and format it more nicely with linebreaks and stuff
|
||||
Maybe include a "last online" feature for /whois
|
||||
Look into block protection
|
11
other.java
11
other.java
@ -1,11 +0,0 @@
|
||||
public class other {
|
||||
public static other gmsg;
|
||||
public static other gmsg(String msg){
|
||||
for (Player p : etc.getServer().getPlayerList()) {
|
||||
if (p != null) {
|
||||
p.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
return gmsg;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/* Class of all ranks so I don't need to type them in */
|
||||
|
||||
public class ranks {
|
||||
public static final String[] Def = {"default"};
|
||||
public static final String[] Trusted = {"trusted"};
|
||||
public static final String[] Mods = {"mods"};
|
||||
public static final String[] Admins = {"admins"};
|
||||
public static final String[] SuperAdmins = {"superadmins"};
|
||||
}
|
127
settings.java
Normal file
127
settings.java
Normal file
@ -0,0 +1,127 @@
|
||||
//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.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
public class settings {
|
||||
private final static Object syncLock = new Object();
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static volatile settings instance;
|
||||
static boolean toggle = true;
|
||||
private boolean adminChat = false;
|
||||
private boolean greentext = false;
|
||||
private boolean FFF = false;
|
||||
private boolean quakeColors = false;
|
||||
private boolean cmdFabulous = false;
|
||||
private boolean cmdPromote = false;
|
||||
private boolean cmdDemote = false;
|
||||
private boolean cmdWhoIs = false;
|
||||
private PropertiesFile properties;
|
||||
String file = "vminecraft.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
|
||||
|
||||
|
||||
public void loadSettings()
|
||||
{
|
||||
try{
|
||||
|
||||
Scanner scanner = new Scanner(new File(file));
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
if( line.startsWith("#") || line.equals(""))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String[] split = line.split("=");
|
||||
if(split[0].equalsIgnoreCase("adminchat"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
adminChat = true;
|
||||
}
|
||||
else adminChat = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("Greentext"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
greentext = true;
|
||||
}
|
||||
else greentext = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("FFF"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
FFF = true;
|
||||
}
|
||||
else FFF = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("QuakeColors"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
quakeColors = true;
|
||||
}
|
||||
else quakeColors = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("cmdFabulous"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
cmdFabulous = true;
|
||||
}
|
||||
else cmdFabulous = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("cmdPromote"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
cmdPromote = true;
|
||||
}
|
||||
else cmdPromote = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("cmdDemote"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
cmdDemote = true;
|
||||
}
|
||||
else cmdDemote = false;
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("cmdWhoIs"))
|
||||
{
|
||||
if(split[1].equalsIgnoreCase("true"))
|
||||
{
|
||||
cmdWhoIs = true;
|
||||
}
|
||||
else cmdWhoIs = false;
|
||||
}
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
catch (Exception e) {log.log(Level.SEVERE, "Oh shi-: "+ e.getMessage() );}
|
||||
|
||||
}
|
||||
|
||||
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 static settings getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new settings();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
220
vminecraft.java
220
vminecraft.java
@ -16,7 +16,6 @@ public class vminecraft extends Plugin {
|
||||
}
|
||||
static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
@Override
|
||||
public void onLogin(Player player)
|
||||
{
|
||||
settings.getInstance().loadSettings();
|
||||
@ -26,14 +25,14 @@ public class vminecraft extends Plugin {
|
||||
//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.LightGreen + "{" + player.getColor() + player.getName() + Colors.LightGreen +"}" + Colors.White + " "; //Inserts names admin chat style before the message
|
||||
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 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"))) {
|
||||
if (settings.getInstance().adminchat()&&message.startsWith("@") && (etc.getInstance().isUserInGroup(player, "mods") || etc.getInstance().isUserInGroup(player, "admins") || etc.getInstance().isUserInGroup(player, "superadmins"))) {
|
||||
for (Player p : etc.getServer().getPlayerList()) {
|
||||
if (p != null) {
|
||||
if (player.isInGroup("mods") || (player.isInGroup("admins")) || (player.isInGroup("superadmins"))) {
|
||||
if (etc.getInstance().isUserInGroup(p, "mods") || (etc.getInstance().isUserInGroup(p, "admins")) || (etc.getInstance().isUserInGroup(p, "superadmins"))) {
|
||||
String blaa = "";
|
||||
for ( int x = 1; x< message.length(); x++) {
|
||||
blaa+=message.charAt(x);
|
||||
@ -90,7 +89,7 @@ public class vminecraft extends Plugin {
|
||||
return false;
|
||||
}
|
||||
public boolean onCommand(Player player, String[] split) {
|
||||
if (player.canUseCommand(split[0])) {
|
||||
if (!etc.getInstance().canUseCommand(player.getName(), split[0])) {
|
||||
return false;
|
||||
}
|
||||
//Fabulous
|
||||
@ -100,7 +99,7 @@ public class vminecraft extends Plugin {
|
||||
String temp = "";
|
||||
String str = "";
|
||||
//str = paramString.substring(paramString.indexOf(" ")).trim();
|
||||
str = etc.combineSplit(1, split, " ");
|
||||
str = id.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;
|
||||
@ -116,7 +115,7 @@ public class vminecraft extends Plugin {
|
||||
if(counter==7){counter = 0; }
|
||||
}
|
||||
str = temp+" ";
|
||||
String message = "<" + player.getColor() + player.getName() + Colors.White + "> " + str;
|
||||
String message = "<" + etc.getInstance().getUserColor(player.getName()) + player.getName() + Colors.White + "> " + str;
|
||||
|
||||
other.gmsg(message);
|
||||
} else {
|
||||
@ -124,108 +123,105 @@ public class vminecraft extends Plugin {
|
||||
}
|
||||
}
|
||||
//Promote
|
||||
else 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(player);
|
||||
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(player);
|
||||
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")))
|
||||
{
|
||||
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 + "Player not found");
|
||||
}
|
||||
log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" ");
|
||||
}
|
||||
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) {
|
||||
player.sendMessage(Colors.Rose + "Usage is /promote [player]");
|
||||
}
|
||||
if(user2 == null) { //Currently broken
|
||||
player.sendMessage(Colors.Rose + "Player does not exist.");
|
||||
return false;
|
||||
}
|
||||
//ea player2 = id.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);
|
||||
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";
|
||||
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);
|
||||
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 (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);
|
||||
else if (settings.getInstance().cmdDemote()&&split[0].equalsIgnoreCase("/demote")) {
|
||||
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]");
|
||||
}
|
||||
if(player == null) { //Currently broken
|
||||
player.sendMessage(Colors.Rose + "Player does not exist.");
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
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(player);
|
||||
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(player);
|
||||
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]+" ");
|
||||
}
|
||||
} else if (etc.getInstance().isUserInGroup(split[1], "mods")&& etc.getInstance().isUserInGroup(player, "admins")) {
|
||||
user.Groups = ranks.Trusted;
|
||||
etc.getInstance().getDataSource().modifyUser(user);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
//Whois will display info about a player
|
||||
else if (settings.getInstance().cmdWhoIs()&&split[0].equalsIgnoreCase("/whois")) {
|
||||
} else if (settings.getInstance().cmdWhoIs()&&split[0].equalsIgnoreCase("/whois")) {
|
||||
String admin ="";
|
||||
String group ="";
|
||||
String ignore ="";
|
||||
@ -234,23 +230,23 @@ public class vminecraft extends Plugin {
|
||||
if (split.length < 2) {
|
||||
player.sendMessage(Colors.Rose + "Usage is /whois [player]");
|
||||
}
|
||||
if (player.canIgnoreRestrictions()) {
|
||||
if (etc.getInstance().canIgnoreRestrictions(split[1])) {
|
||||
ignore = "True";
|
||||
} else {
|
||||
ignore ="False";
|
||||
}
|
||||
if (player.canIgnoreRestrictions()) {
|
||||
if (etc.getInstance().isAdmin(split[1])) {
|
||||
admin = "True";
|
||||
} else {
|
||||
admin = "False";
|
||||
}
|
||||
if (player.isInGroup("superadmins")){
|
||||
if (etc.getInstance().isUserInGroup(split[1], "superadmins")){
|
||||
group = "superadmins";
|
||||
}else if(player.isInGroup("admins")){
|
||||
}else if(etc.getInstance().isUserInGroup(split[1], "admins")){
|
||||
group = "admins";
|
||||
}else if(player.isInGroup("mods")){
|
||||
}else if(etc.getInstance().isUserInGroup(split[1], "mods")){
|
||||
group = "mods";
|
||||
}else if(player.isInGroup("trusted")){
|
||||
}else if(etc.getInstance().isUserInGroup(split[1], "trusted")){
|
||||
group = "trusted";
|
||||
}else{
|
||||
group = "Default";
|
||||
|
Loading…
Reference in New Issue
Block a user