Compare commits

..

33 Commits
v3.3 ... v3.4

Author SHA1 Message Date
4daad76e74 600th Commit, WOO!
Incremented version to reflect latest changes
2013-12-17 15:18:11 +01:00
05884ae806 Case-sensitive Telnet login names 2013-12-17 15:16:32 +01:00
aa0fd34859 Append to log files
Set maximum of 1Gig
2013-12-15 23:12:30 +01:00
2c14773c9b Generate logs in /server.log like CraftBukkit did 2013-12-07 10:58:29 +01:00
695168ebfe Merge pull request #112 from Wilee999/pull1
Fixed developer login message
2013-12-07 01:08:29 -08:00
bbc1255963 Fixed developer login message. 2013-12-06 23:37:56 -08:00
34d15d4c96 Fixed a neophyte bug
Custom login messages would be the same for anyone who logs in after the player with the same rank
2013-12-03 20:50:20 +01:00
75bc17cd8f Merge pull request #109 from Wilee999/pull1
Modified ban messages
2013-12-03 07:42:28 -08:00
87f338194c Removed "for a while" 2013-12-03 07:41:43 -08:00
b5760afbad Fixed. 2013-12-03 07:35:47 -08:00
5cfaf8970d Fixed all deprecated methods 2013-12-03 16:21:58 +01:00
9a48ec04aa Fixed developers not having the correct prefix
batch format
2013-12-03 14:24:09 +01:00
24fca9af97 Woops 2013-12-03 14:13:36 +01:00
a9ef738602 Merged from master 2013-12-03 14:05:59 +01:00
27a04635a2 Migrated /list-, AdminChat- and Login message-colors to TFM_PlayerRank
Reverted colors due to popular request
2013-12-03 14:05:06 +01:00
0f58746525 Modified the 2 ban messages. 2013-12-02 15:43:42 -08:00
a8d4b5f582 Merge pull request #108 from Wilee999/pull1
Developer login message
2013-12-01 10:57:49 -08:00
d7f1de4cb7 oops 2013-12-01 10:39:43 -08:00
ddbb6228f1 Added dev login message. (try 2) 2013-12-01 10:38:13 -08:00
d4c3a4ad45 Woops 2013-12-01 19:02:30 +01:00
7140e4c8df Changed colors to match the forums 2013-12-01 18:54:50 +01:00
808e02f660 Fixed potential mass-kick
This would happen if an admin joins the game when the server is full
2013-12-01 18:21:43 +01:00
bed78248fb Fixed /list for 1.7
for some weird reason, that ChatColor.WHITE was causing issues
2013-12-01 17:32:29 +01:00
ee39e89093 Fixed possible NPE in getPrefix() 2013-12-01 15:22:19 +01:00
9405604efc Fix imports 2013-12-01 13:42:13 +01:00
73acb2448b Force-allow superadmins to log in
Commented and cleaned up handlePlayerLogin()
2013-12-01 13:33:39 +01:00
c63540129f Cleaned up /list 2013-12-01 13:00:02 +01:00
6ba96b427d Update to CraftBukkit 1.7 2013-12-01 12:13:39 +01:00
acd8373f81 Fixed NPE in /list 2013-12-01 11:55:50 +01:00
0c4c36b2bd Merge pull request #103 from Wilee999/master
Fixed my name
2013-11-30 11:59:50 -08:00
7ce052900e Rewrote ServiceChecker, fixed NPE there
Formatting
2013-11-30 20:44:08 +01:00
f8741b0d4f Noooo dartheh!!!!
omg how offenciv
2013-11-30 10:52:40 -08:00
6fca19fa41 Load plugin version through plugin.yml 2013-11-30 18:04:43 +01:00
58 changed files with 893 additions and 657 deletions

View File

@ -1,5 +0,0 @@
#Tue, 08 Oct 2013 13:58:56 -0400
program.VERSION=3.3
program.BUILDNUM=616
program.BUILDDATE=10/08/2013 01\:58 PM

View File

@ -1,83 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="TotalFreedomMod" default="default" basedir="."> <project name="TotalFreedomMod" default="default" basedir=".">
<description>Builds, tests, and runs the project TotalFreedomMod.</description> <description>Builds, tests, and runs the project TotalFreedomMod.</description>
<import file="nbproject/build-impl.xml"/> <import file="nbproject/build-impl.xml" />
<!-- <target name="-pre-jar">
<buildnumber file="buildnumber.properties" />
There exist several targets which are by default empty and which can be <propertyfile file="appinfo.properties">
used for execution of your tasks. These targets are usually executed <entry key="program.buildnumber" value="${build.number}" />
before and after some main targets. They are: <entry key="program.builddate" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
</propertyfile>
-pre-init: called before initialization of project properties <copy file="appinfo.properties" todir="${build.classes.dir}" />
-post-init: called after initialization of project properties <delete file="appinfo.properties" />
-pre-compile: called before javac compilation </target>
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file <target name="-post-jar">
-post-compile-single: called after javac compilation of single file <!-- Cleanup -->
-pre-compile-test: called before javac compilation of JUnit tests <delete file="${dist.dir}/README.TXT" />
-post-compile-test: called after javac compilation of JUnit tests <delete dir="${dist.dir}/lib/" />
-pre-compile-test-single: called before javac compilation of single JUnit test </target>
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="TotalFreedomMod-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<target name="-pre-jar">
<buildnumber file="buildnumber.properties" />
<propertyfile file="appinfo.properties">
<entry key="program.VERSION" default="0.0" />
<entry key="program.BUILDNUM" value="${build.number}" />
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
</propertyfile>
<copy file="appinfo.properties" todir="${build.classes.dir}" />
</target>
</project> </project>

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Tue Oct 08 13:58:56 EDT 2013 #Tue Dec 17 15:17:32 CET 2013
build.number=617 build.number=681

View File

@ -18,7 +18,7 @@ is divided into following sections:
- applet - applet
- cleanup - cleanup
--> -->
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="TotalFreedomMod-impl"> <project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="TotalFreedomMod-impl">
<fail message="Please build using Ant 1.8.0 or higher."> <fail message="Please build using Ant 1.8.0 or higher.">
<condition> <condition>
@ -29,10 +29,10 @@ is divided into following sections:
</fail> </fail>
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/> <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
<!-- <!--
====================== ======================
INITIALIZATION SECTION INITIALIZATION SECTION
====================== ======================
--> -->
<target name="-pre-init"> <target name="-pre-init">
<!-- Empty placeholder for easier customization. --> <!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. --> <!-- You can override this target in the ../build.xml file. -->
@ -645,8 +645,8 @@ is divided into following sections:
</target> </target>
<target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/> <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
<!-- <!--
pre NB7.2 profiling section; consider it deprecated pre NB7.2 profiling section; consider it deprecated
--> -->
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/> <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
<target if="profiler.info.jvmargs.agent" name="-profile-pre-init"> <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
<!-- Empty placeholder for easier customization. --> <!-- Empty placeholder for easier customization. -->
@ -693,8 +693,8 @@ is divided into following sections:
<fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail> <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
</target> </target>
<!-- <!--
end of pre NB7.2 profiling section end of pre NB7.2 profiling section
--> -->
<target depends="-init-debug-args" name="-init-macrodef-nbjpda"> <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute default="${main.class}" name="name"/> <attribute default="${main.class}" name="name"/>
@ -854,10 +854,10 @@ is divided into following sections:
</target> </target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/> <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<!-- <!--
=================== ===================
COMPILATION SECTION COMPILATION SECTION
=================== ===================
--> -->
<target name="-deps-jar-init" unless="built-jar.properties"> <target name="-deps-jar-init" unless="built-jar.properties">
<property location="${build.dir}/built-jar.properties" name="built-jar.properties"/> <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
<delete file="${built-jar.properties}" quiet="true"/> <delete file="${built-jar.properties}" quiet="true"/>
@ -928,10 +928,10 @@ is divided into following sections:
</target> </target>
<target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/> <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
<!-- <!--
==================== ====================
JAR BUILDING SECTION JAR BUILDING SECTION
==================== ====================
--> -->
<target depends="init" name="-pre-pre-jar"> <target depends="init" name="-pre-pre-jar">
<dirname file="${dist.jar}" property="dist.jar.dir"/> <dirname file="${dist.jar}" property="dist.jar.dir"/>
<mkdir dir="${dist.jar.dir}"/> <mkdir dir="${dist.jar.dir}"/>
@ -1000,10 +1000,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/> <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
<!-- <!--
================= =================
EXECUTION SECTION EXECUTION SECTION
================= =================
--> -->
<target depends="init,compile" description="Run a main class." name="run"> <target depends="init,compile" description="Run a main class." name="run">
<j2seproject1:java> <j2seproject1:java>
<customize> <customize>
@ -1023,10 +1023,10 @@ is divided into following sections:
<j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/> <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
</target> </target>
<!-- <!--
================= =================
DEBUGGING SECTION DEBUGGING SECTION
================= =================
--> -->
<target depends="init" if="netbeans.home" name="-debug-start-debugger"> <target depends="init" if="netbeans.home" name="-debug-start-debugger">
<j2seproject1:nbjpdastart name="${debug.class}"/> <j2seproject1:nbjpdastart name="${debug.class}"/>
</target> </target>
@ -1064,13 +1064,13 @@ is divided into following sections:
</target> </target>
<target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
<!-- <!--
================= =================
PROFILING SECTION PROFILING SECTION
================= =================
--> -->
<!-- <!--
pre NB7.2 profiler integration pre NB7.2 profiler integration
--> -->
<target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72"> <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect> <nbprofiledirect>
@ -1127,8 +1127,8 @@ is divided into following sections:
</junit> </junit>
</target> </target>
<!-- <!--
end of pre NB72 profiling section end of pre NB72 profiling section
--> -->
<target if="netbeans.home" name="-profile-check"> <target if="netbeans.home" name="-profile-check">
<condition property="profiler.configured"> <condition property="profiler.configured">
<or> <or>
@ -1163,10 +1163,10 @@ is divided into following sections:
<antcall target="run-applet"/> <antcall target="run-applet"/>
</target> </target>
<!-- <!--
=============== ===============
JAVADOC SECTION JAVADOC SECTION
=============== ===============
--> -->
<target depends="init" if="have.sources" name="-javadoc-build"> <target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/> <mkdir dir="${dist.javadoc.dir}"/>
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}"> <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
@ -1204,10 +1204,10 @@ is divided into following sections:
</target> </target>
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/> <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
<!-- <!--
========================= =========================
TEST COMPILATION SECTION TEST COMPILATION SECTION
========================= =========================
--> -->
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test"> <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
<mkdir dir="${build.test.classes.dir}"/> <mkdir dir="${build.test.classes.dir}"/>
</target> </target>
@ -1243,10 +1243,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/> <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
<!-- <!--
======================= =======================
TEST EXECUTION SECTION TEST EXECUTION SECTION
======================= =======================
--> -->
<target depends="init" if="have.tests" name="-pre-test-run"> <target depends="init" if="have.tests" name="-pre-test-run">
<mkdir dir="${build.test.results.dir}"/> <mkdir dir="${build.test.results.dir}"/>
</target> </target>
@ -1280,10 +1280,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/> <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
<!-- <!--
======================= =======================
TEST DEBUGGING SECTION TEST DEBUGGING SECTION
======================= =======================
--> -->
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test"> <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail> <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/> <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
@ -1303,10 +1303,10 @@ is divided into following sections:
</target> </target>
<target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/> <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
<!-- <!--
========================= =========================
APPLET EXECUTION SECTION APPLET EXECUTION SECTION
========================= =========================
--> -->
<target depends="init,compile-single" name="run-applet"> <target depends="init,compile-single" name="run-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject1:java classname="sun.applet.AppletViewer"> <j2seproject1:java classname="sun.applet.AppletViewer">
@ -1316,10 +1316,10 @@ is divided into following sections:
</j2seproject1:java> </j2seproject1:java>
</target> </target>
<!-- <!--
========================= =========================
APPLET DEBUGGING SECTION APPLET DEBUGGING SECTION
========================= =========================
--> -->
<target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet"> <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject3:debug classname="sun.applet.AppletViewer"> <j2seproject3:debug classname="sun.applet.AppletViewer">
@ -1330,10 +1330,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/> <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
<!-- <!--
=============== ===============
CLEANUP SECTION CLEANUP SECTION
=============== ===============
--> -->
<target name="-deps-clean-init" unless="built-clean.properties"> <target name="-deps-clean-init" unless="built-clean.properties">
<property location="${build.dir}/built-clean.properties" name="built-clean.properties"/> <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
<delete file="${built-clean.properties}" quiet="true"/> <delete file="${built-clean.properties}" quiet="true"/>

View File

@ -85,7 +85,6 @@ jnlp.signed=false
jnlp.signing= jnlp.signing=
jnlp.signing.alias= jnlp.signing.alias=
jnlp.signing.keystore= jnlp.signing.keystore=
main.class=totalfreedommod.TotalFreedomMod
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=true mkdist.disabled=true

View File

@ -1,4 +1,4 @@
# TotalFreedomMod v3.3 Configuration # TotalFreedomMod v3.4 Configuration
# by Madgeek1450 and DarthSalamon # by Madgeek1450 and DarthSalamon
# Block placement prevention: # Block placement prevention:

View File

@ -4,8 +4,8 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_Log;
import org.apache.commons.lang3.ArrayUtils; import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;

View File

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -4,7 +4,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import me.StevenLawson.TotalFreedomMod.TFM_EssentialsBridge; import me.StevenLawson.TotalFreedomMod.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,8 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import org.apache.commons.lang3.ArrayUtils; import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserList; import me.StevenLawson.TotalFreedomMod.TFM_UserList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -7,7 +7,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_UserList; import me.StevenLawson.TotalFreedomMod.TFM_UserList;
import me.StevenLawson.TotalFreedomMod.TFM_UserList.TFM_UserListEntry; import me.StevenLawson.TotalFreedomMod.TFM_UserList.TFM_UserListEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -4,8 +4,8 @@ import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge; import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
import org.apache.commons.lang3.ArrayUtils; import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -2,106 +2,72 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin; import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH) @CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command>", aliases = "who") @CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a]", aliases = "who")
public class Command_list extends TFM_Command public class Command_list extends TFM_Command
{ {
private static enum ListFilter private static enum ListFilter
{ {
SHOW_ALL, SHOW_ADMINS ALL,
ADMINS;
} }
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if (args.length > 1)
{
return false;
}
if (TFM_Util.isFromHostConsole(sender.getName())) if (TFM_Util.isFromHostConsole(sender.getName()))
{ {
List<String> player_names = new ArrayList<String>(); final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
player_names.add(player.getName()); names.add(player.getName());
} }
playerMsg("There are " + player_names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(player_names, ", "), ChatColor.WHITE); playerMsg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
return true; return true;
} }
ListFilter listFilter = ListFilter.SHOW_ALL; final Command_list.ListFilter listFilter = (args.length == 1 && args[0].equals("-a") ? Command_list.ListFilter.ADMINS : Command_list.ListFilter.ALL);
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("-a"))
{
listFilter = ListFilter.SHOW_ADMINS;
}
}
StringBuilder onlineStats = new StringBuilder(); final StringBuilder onlineStats = new StringBuilder();
StringBuilder onlineUsers = new StringBuilder(); final StringBuilder onlineUsers = new StringBuilder();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length); onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers()); onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
onlineStats.append(ChatColor.BLUE).append(" players online."); onlineStats.append(ChatColor.BLUE).append(" players online.");
List<String> player_names = new ArrayList<String>(); final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player); final boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player);
if (listFilter == ListFilter.SHOW_ADMINS && !userSuperadmin) if (listFilter == Command_list.ListFilter.ADMINS && !userSuperadmin)
{ {
continue; continue;
} }
String prefix = ""; names.add(TFM_PlayerRank.fromSender(player).getPrefix() + player.getName());
if (userSuperadmin)
{
TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(player.getName());
if (!entry.isSeniorAdmin() && entry.isTelnetAdmin())
{
prefix = (ChatColor.DARK_GREEN + "[STA]");
}
else if (TFM_SuperadminList.isSeniorAdmin(player))
{
prefix = (ChatColor.LIGHT_PURPLE + "[SrA]");
}
else if (TFM_SuperadminList.isUserSuperadmin(player))
{
prefix = (ChatColor.GOLD + "[SA]");
}
if (TFM_Util.DEVELOPERS.contains(player.getName()))
{
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
}
if (player.getName().equals("markbyron"))
{
prefix = (ChatColor.BLUE + "[Owner]");
}
}
else
{
if (player.isOp())
{
prefix = (ChatColor.RED + "[OP]");
}
}
player_names.add(prefix + player.getName() + ChatColor.WHITE);
} }
onlineUsers.append("Connected ").append(listFilter == ListFilter.SHOW_ADMINS ? "admins" : "players").append(": ").append(StringUtils.join(player_names, ", ")); onlineUsers.append("Connected ");
onlineUsers.append(listFilter == Command_list.ListFilter.ADMINS ? "admins: " : "players: ");
onlineUsers.append(StringUtils.join(names, ChatColor.WHITE + ", "));
if (senderIsConsole) if (senderIsConsole)
{ {

View File

@ -14,7 +14,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin; import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -44,24 +44,24 @@ public class Command_permban extends TFM_Command
private void dumplist(CommandSender sender) private void dumplist(CommandSender sender)
{ {
if (TotalFreedomMod.permbanned_players.isEmpty()) if (TotalFreedomMod.permbannedPlayers.isEmpty())
{ {
playerMsg(sender, "No permanently banned player names."); playerMsg(sender, "No permanently banned player names.");
} }
else else
{ {
playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:"); playerMsg(sender, TotalFreedomMod.permbannedPlayers.size() + " permanently banned players:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_players, ", ")); playerMsg(sender, StringUtils.join(TotalFreedomMod.permbannedPlayers, ", "));
} }
if (TotalFreedomMod.permbanned_ips.isEmpty()) if (TotalFreedomMod.permbannedIps.isEmpty())
{ {
playerMsg(sender, "No permanently banned IPs."); playerMsg(sender, "No permanently banned IPs.");
} }
else else
{ {
playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:"); playerMsg(sender, TotalFreedomMod.permbannedIps.size() + " permanently banned IPs:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_ips, ", ")); playerMsg(sender, StringUtils.join(TotalFreedomMod.permbannedIps, ", "));
} }
} }
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -5,7 +5,7 @@ import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea; import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,7 +17,7 @@ public class Command_rank extends TFM_Command
{ {
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
playerMsg(player.getName() + " is " + TFM_Util.getRank(player)); playerMsg(player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage());
} }
return true; return true;
} }
@ -29,7 +29,7 @@ public class Command_rank extends TFM_Command
if (args.length == 0) if (args.length == 0)
{ {
playerMsg(sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA); playerMsg(sender.getName() + " is " + TFM_PlayerRank.fromSender(sender).getLoginMessage(), ChatColor.AQUA);
return true; return true;
} }
@ -44,7 +44,7 @@ public class Command_rank extends TFM_Command
return true; return true;
} }
playerMsg(player.getName() + " is " + TFM_Util.getRank(player), ChatColor.AQUA); playerMsg(player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage(), ChatColor.AQUA);
return true; return true;
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -6,7 +6,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler; import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker; import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker;
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker.TFM_ServiceChecker_ServiceStatus; import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker.ServiceStatus;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -16,12 +16,12 @@ public class Command_services extends TFM_Command
{ {
playerMsg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE); playerMsg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE);
for (TFM_ServiceChecker_ServiceStatus service : TFM_ServiceChecker.getInstance().getAllStatuses()) for (ServiceStatus service : TFM_ServiceChecker.getInstance().getAllStatuses())
{ {
playerMsg(service.getFormattedStatus()); playerMsg(service.getFormattedStatus());
} }
playerMsg("Version" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().version, ChatColor.DARK_PURPLE); playerMsg("Version" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().getVersion(), ChatColor.DARK_PURPLE);
playerMsg("Last Check" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().lastCheck, ChatColor.DARK_PURPLE); playerMsg("Last Check" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().getLastCheck(), ChatColor.DARK_PURPLE);
return true; return true;
} }

View File

@ -4,8 +4,8 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.ArrayUtils; import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import static org.apache.commons.lang3.StringEscapeUtils.*; import static net.minecraft.util.org.apache.commons.lang3.StringEscapeUtils.*;
public class HTMLGenerationTools public class HTMLGenerationTools
{ {

View File

@ -4,8 +4,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FileUtils; import net.minecraft.util.org.apache.commons.io.FileUtils;
import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_Log;
import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*; import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*;

View File

@ -13,10 +13,10 @@ import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader.TFM_DynamicCom
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.PluginIdentifiableCommand; import org.bukkit.command.PluginIdentifiableCommand;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*; import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*;
import static org.apache.commons.lang3.StringEscapeUtils.*; import static net.minecraft.util.org.apache.commons.lang3.StringEscapeUtils.*;
public class Module_help extends TFM_HTTPD_Module public class Module_help extends TFM_HTTPD_Module
{ {

View File

@ -14,9 +14,9 @@ import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Response;
import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin; import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import org.apache.commons.io.FileUtils; import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringEscapeUtils; import net.minecraft.util.org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
public class Module_schematic extends TFM_HTTPD_Module public class Module_schematic extends TFM_HTTPD_Module
{ {

View File

@ -11,8 +11,8 @@ import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Response;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import net.minecraft.util.org.apache.commons.lang3.exception.ExceptionUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
public class TFM_HTTPD_Manager public class TFM_HTTPD_Manager

View File

@ -1,7 +1,10 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin; import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -10,16 +13,30 @@ public class TFM_CustomListener implements Listener
{ {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onTelnetPreLogin(me.StevenLawson.BukkitTelnet.TelnetPreLoginEvent event) public void onTelnetPreLogin(me.StevenLawson.BukkitTelnet.TelnetPreLoginEvent event)
{ {
String ip = event.getIp();
if (ip != null && !ip.isEmpty()) final String ip = event.getIp();
if (ip == null || ip.isEmpty())
{ {
TFM_Superadmin admin = TFM_SuperadminList.getAdminEntryByIP(ip, true); return;
if (admin != null && (admin.isTelnetAdmin() || admin.isSeniorAdmin()))
{
event.setBypassPassword(true);
event.setName(admin.getName());
}
} }
final TFM_Superadmin admin = TFM_SuperadminList.getAdminEntryByIP(ip, true);
if (admin == null || !(admin.isTelnetAdmin() || admin.isSeniorAdmin()))
{
return;
}
event.setBypassPassword(true);
event.setName(admin.getName());
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin.getName());
if (player == null)
{
return;
}
event.setName(player.getName());
} }
} }

View File

@ -9,7 +9,7 @@ import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*; import me.StevenLawson.TotalFreedomMod.*;
import me.StevenLawson.TotalFreedomMod.Commands.Command_landmine; import me.StevenLawson.TotalFreedomMod.Commands.Command_landmine;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.RollbackEntry; import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.RollbackEntry;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -687,11 +687,11 @@ public class TFM_PlayerListener implements Listener
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(player); TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(player);
boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player); final boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player);
if (impostor || TFM_SuperadminList.isUserSuperadmin(player)) if (impostor || TFM_SuperadminList.isUserSuperadmin(player))
{ {
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_Util.getRank(player)); TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
if (impostor) if (impostor)
{ {
@ -718,6 +718,10 @@ public class TFM_PlayerListener implements Listener
player.setOp(true); player.setOp(true);
} }
} }
else if (TFM_Util.DEVELOPERS.contains(player.getName()))
{
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
}
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {

View File

@ -1,18 +1,14 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker; import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -30,37 +26,37 @@ public class TFM_ServerListener implements Listener
// Comment this method out if you want to compile this without a custom CraftBukkit. // Comment this method out if you want to compile this without a custom CraftBukkit.
// Just make sure that enable-command-block=false in server.properties. // Just make sure that enable-command-block=false in server.properties.
// -Madgeek // -Madgeek
@EventHandler(priority = EventPriority.NORMAL) /* Temporary: Until we get a custom CB build out
public void onCommandBlockSet(org.bukkit.event.server.CommandBlockSetEvent event) @EventHandler(priority = EventPriority.NORMAL)
{ public void onCommandBlockSet(org.bukkit.event.server.CommandBlockSetEvent event)
Player player = event.getPlayer(); {
String newCommandRaw = event.getNewCommand(); Player player = event.getPlayer();
String newCommandRaw = event.getNewCommand();
if (!TFM_SuperadminList.isSeniorAdmin(player, true)) if (!TFM_SuperadminList.isSeniorAdmin(player, true))
{ {
player.sendMessage(ChatColor.GRAY + "Only senior admins may set command block commands."); player.sendMessage(ChatColor.GRAY + "Only senior admins may set command block commands.");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(newCommandRaw); Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(newCommandRaw);
if (matcher.find()) if (matcher.find())
{ {
String topLevelCommand = matcher.group(1); String topLevelCommand = matcher.group(1);
if (topLevelCommand != null) if (topLevelCommand != null)
{ {
topLevelCommand = topLevelCommand.toLowerCase().trim(); topLevelCommand = topLevelCommand.toLowerCase().trim();
// We need to make it look like the command is coming from the console, so keep the player's name without the Player instance via dummy:
if (TFM_CommandBlocker.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false))
{
player.sendMessage(ChatColor.GRAY + "That command is blocked.");
event.setCancelled(true);
}
}
}
}
// We need to make it look like the command is coming from the console, so keep the player's name without the Player instance via dummy:
if (TFM_CommandBlocker.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false))
{
player.sendMessage(ChatColor.GRAY + "That command is blocked.");
event.setCancelled(true);
}
}
}
}*/
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onRemoteServerCommand(RemoteServerCommandEvent event) public void onRemoteServerCommand(RemoteServerCommandEvent event)
{ {

View File

@ -6,7 +6,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;

View File

@ -6,7 +6,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils; import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -77,7 +77,7 @@ public class TFM_EssentialsBridge
final User user = getEssentialsUser(username); final User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
return TFM_Util.getField(user, "lastActivity"); return TFM_Util.<Long>getField(user, "lastActivity"); // This is weird
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.io.File; import java.io.File;
import org.apache.commons.io.FileUtils; import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -11,7 +11,7 @@ import java.util.Random;
import me.StevenLawson.TotalFreedomMod.Commands.Command_trail; import me.StevenLawson.TotalFreedomMod.Commands.Command_trail;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command; import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader; import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import org.apache.commons.lang3.ArrayUtils; import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -0,0 +1,85 @@
package me.StevenLawson.TotalFreedomMod;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
public class TFM_LogFile
{
public static final int MAX_LOG_SIZE = 1024 * 1024; // Bytes
private final Logger logger;
private final SimpleDateFormat date;
private TFM_LogFile()
{
this.logger = TotalFreedomMod.server.getLogger();
this.date = new SimpleDateFormat("HH:mm:ss");
}
public void start()
{
try
{
logger.addHandler(getHandler());
}
catch (Exception ex)
{
TFM_Log.warning("Failed to register log handler!");
TFM_Log.warning(TotalFreedomMod.pluginName + " will not log to /server.log!");
TFM_Log.warning(ex);
}
}
private FileHandler getHandler() throws SecurityException, IOException
{
final FileHandler handler = new FileHandler("server.log", MAX_LOG_SIZE, 1);
handler.setLevel(Level.ALL);
handler.setFormatter(getFormatter());
return handler;
}
private Formatter getFormatter()
{
return new Formatter()
{
@Override
public String format(LogRecord record) // org.bukkit.craftbukkit.util.ShortConsoleFormatter
{
StringBuilder builder = new StringBuilder();
Throwable ex = record.getThrown();
builder.append(date.format(record.getMillis()));
builder.append(" [");
builder.append(record.getLevel().getLocalizedName().toUpperCase());
builder.append("] ");
builder.append(formatMessage(record));
builder.append('\n');
if (ex != null)
{
StringWriter writer = new StringWriter();
ex.printStackTrace(new PrintWriter(writer));
builder.append(writer);
}
return builder.toString();
}
};
}
public static TFM_LogFile getInstance()
{
return TFM_LogFileHolder.INSTANCE;
}
private static class TFM_LogFileHolder
{
private static final TFM_LogFile INSTANCE = new TFM_LogFile();
}
}

View File

@ -0,0 +1,120 @@
package me.StevenLawson.TotalFreedomMod;
import static me.StevenLawson.TotalFreedomMod.TFM_Util.DEVELOPERS;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public enum TFM_PlayerRank
{
DEVELOPER("a " + ChatColor.DARK_PURPLE + "Developer", ChatColor.DARK_PURPLE + "[Dev]"),
IMPOSTOR("an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor", ChatColor.YELLOW.toString() + ChatColor.UNDERLINE + "[IMP]"),
NON_OP("a " + ChatColor.GREEN + "Non-OP", ChatColor.GREEN.toString()),
OP("an " + ChatColor.RED + "OP", ChatColor.RED + "[OP]"),
SUPER("a " + ChatColor.GOLD + "Super Admin", ChatColor.GOLD + "[SA]"),
TELNET("a " + ChatColor.DARK_GREEN + "Super Telnet Admin", ChatColor.DARK_GREEN + "[STA]"),
SENIOR("a " + ChatColor.LIGHT_PURPLE + "Senior Admin", ChatColor.LIGHT_PURPLE + "[SrA]"),
OWNER("the " + ChatColor.BLUE + "Owner", ChatColor.BLUE + "[Owner]"),
CONSOLE("The " + ChatColor.DARK_PURPLE + "Console", ChatColor.DARK_PURPLE + "[Console]");
private String loginMessage;
private String prefix;
private TFM_PlayerRank(String loginMessage, String prefix)
{
this.loginMessage = loginMessage;
this.prefix = prefix;
}
public static String getLoginMessage(CommandSender sender)
{
if (!(sender instanceof Player))
{
return fromSender(sender).getLoginMessage();
}
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry((Player) sender);
if (entry == null)
{
return fromSender(sender).getLoginMessage();
}
final String loginMessage = entry.getCustomLoginMessage();
if (loginMessage != null && !loginMessage.isEmpty())
{
return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
else
{
return fromSender(sender).getLoginMessage();
}
}
public static TFM_PlayerRank fromSender(CommandSender sender)
{
if (!(sender instanceof Player))
{
return CONSOLE;
}
if (TFM_SuperadminList.isSuperadminImpostor(sender))
{
return IMPOSTOR;
}
if (DEVELOPERS.contains(sender.getName()))
{
return DEVELOPER;
}
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry((Player) sender);
final TFM_PlayerRank rank;
if (entry != null && entry.isActivated())
{
if (sender.getName().equals("markbyron"))
{
return OWNER;
}
if (entry.isSeniorAdmin())
{
rank = SENIOR;
}
else if (entry.isTelnetAdmin())
{
rank = TELNET;
}
else
{
rank = SUPER;
}
}
else
{
if (sender.isOp())
{
rank = OP;
}
else
{
rank = NON_OP;
}
}
return rank;
}
public String getPrefix()
{
return prefix;
}
public String getLoginMessage()
{
return loginMessage;
}
}

View File

@ -6,15 +6,16 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.minecraft.server.v1_6_R3.BanEntry; import net.minecraft.server.v1_7_R1.BanEntry;
import net.minecraft.server.v1_6_R3.BanList; import net.minecraft.server.v1_7_R1.BanList;
import net.minecraft.server.v1_6_R3.MinecraftServer; import net.minecraft.server.v1_7_R1.MinecraftServer;
import net.minecraft.server.v1_6_R3.PlayerList; import net.minecraft.server.v1_7_R1.PlayerList;
import net.minecraft.server.v1_6_R3.PropertyManager; import net.minecraft.server.v1_7_R1.PropertyManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
public class TFM_ServerInterface public class TFM_ServerInterface
{ {
@ -141,16 +142,16 @@ public class TFM_ServerInterface
// this should supersede all other onPlayerLogin authentication on the TFM server. // this should supersede all other onPlayerLogin authentication on the TFM server.
// when using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication. // when using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication.
final Server server = TotalFreedomMod.plugin.getServer(); final Server server = TotalFreedomMod.server;
final PlayerList playerList = MinecraftServer.getServer().getPlayerList(); final PlayerList playerList = MinecraftServer.getServer().getPlayerList();
final BanList banByIP = playerList.getIPBans(); final BanList ipBans = playerList.getIPBans();
final BanList banByName = playerList.getNameBans(); final BanList nameBans = playerList.getNameBans();
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final String username = player.getName(); final String username = player.getName();
final String ip = event.getAddress().getHostAddress().trim().toLowerCase(); final String ip = event.getAddress().getHostAddress().trim();
if (username.trim().length() <= 2) if (username.trim().length() <= 2)
{ {
@ -174,34 +175,36 @@ public class TFM_ServerInterface
isSuperadmin = TFM_SuperadminList.checkPartialSuperadminIP(ip, username.toLowerCase()); isSuperadmin = TFM_SuperadminList.checkPartialSuperadminIP(ip, username.toLowerCase());
} }
if (!isSuperadmin) // Validation below this point
if (!isSuperadmin) // non-admins
{ {
BanEntry entry = null; // banned-players.txt
if (nameBans.isBanned(username.toLowerCase()))
if (banByName.isBanned(username.toLowerCase()))
{ {
entry = (BanEntry) banByName.getEntries().get(username.toLowerCase()); final BanEntry nameBan = (BanEntry) nameBans.getEntries().get(username.toLowerCase());
String kickMessage = ChatColor.RED + "You are banned from this server."; String kickMessage = ChatColor.RED + "You are temporarily banned from this server.\nAppeal at http://totalfreedom.boards.net/.";
if (entry != null) if (nameBan != null)
{ {
kickMessage = kickMessage + "\nReason: " + entry.getReason(); kickMessage = kickMessage + "\nReason: " + nameBan.getReason();
if (entry.getExpires() != null) if (nameBan.getExpires() != null)
{ {
kickMessage = kickMessage + "\nYour ban will be removed on " + dateFormat.format(entry.getExpires()); kickMessage = kickMessage + "\nYour ban will be removed on " + dateFormat.format(nameBan.getExpires());
} }
} }
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kickMessage); event.disallow(Result.KICK_OTHER, kickMessage);
return; return;
} }
// banned-ips.txt
final Iterator ipBansIt = ipBans.getEntries().keySet().iterator();
boolean isIpBanned = false; boolean isIpBanned = false;
BanEntry ipBan = null;
Iterator ipBans = banByIP.getEntries().keySet().iterator(); while (ipBansIt.hasNext())
while (ipBans.hasNext())
{ {
String testIp = (String) ipBans.next(); String testIp = (String) ipBansIt.next();
if (!testIp.matches("^\\d{1,3}\\.\\d{1,3}\\.(\\d{1,3}|\\*)\\.(\\d{1,3}|\\*)$")) if (!testIp.matches("^\\d{1,3}\\.\\d{1,3}\\.(\\d{1,3}|\\*)\\.(\\d{1,3}|\\*)$"))
{ {
@ -210,71 +213,77 @@ public class TFM_ServerInterface
if (ip.equals(testIp)) if (ip.equals(testIp))
{ {
entry = (BanEntry) banByIP.getEntries().get(testIp);
isIpBanned = true; isIpBanned = true;
ipBan = (BanEntry) ipBans.getEntries().get(testIp);
break; break;
} }
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4)) if (TFM_Util.fuzzyIpMatch(testIp, ip, 4))
{ {
entry = (BanEntry) banByIP.getEntries().get(testIp);
isIpBanned = true; isIpBanned = true;
ipBan = (BanEntry) ipBans.getEntries().get(testIp);
break; break;
} }
} }
if (isIpBanned) if (isIpBanned)
{ {
String kickMessage = ChatColor.RED + "Your IP address is banned from this server."; String kickMessage = ChatColor.RED + "Your IP address is temporarily banned from this server.\nAppeal at http://totalfreedom.boards.net/.";
if (entry != null) if (ipBan != null)
{ {
kickMessage = kickMessage + "\nReason: " + entry.getReason(); kickMessage = kickMessage + "\nReason: " + ipBan.getReason();
if (entry.getExpires() != null) if (ipBan.getExpires() != null)
{ {
kickMessage = kickMessage + "\nYour ban will be removed on " + dateFormat.format(entry.getExpires()); kickMessage = kickMessage + "\nYour ban will be removed on " + dateFormat.format(ipBan.getExpires());
} }
} }
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kickMessage); event.disallow(Result.KICK_OTHER, kickMessage);
return; return;
} }
for (String testPlayer : TotalFreedomMod.permbanned_players) // permban.yml - ips
{ for (String testIp : TotalFreedomMod.permbannedIps)
if (testPlayer.equalsIgnoreCase(username))
{
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server.\nRelease procedures are available at http://bit.ly/TF_PermBan");
return;
}
}
for (String testIp : TotalFreedomMod.permbanned_ips)
{ {
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4)) if (TFM_Util.fuzzyIpMatch(testIp, ip, 4))
{ {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server.\nRelease procedures are available at http://bit.ly/TF_PermBan"); event.disallow(Result.KICK_OTHER, ChatColor.RED + "Your IP address is permanently banned from this server.\nRelease procedures are available at http://bit.ly/TF_PermBan");
return; return;
} }
} }
// permban.yml - names
for (String testPlayer : TotalFreedomMod.permbannedPlayers)
{
if (testPlayer.equalsIgnoreCase(username))
{
event.disallow(Result.KICK_OTHER, ChatColor.RED + "Your username is permanently banned from this server.\nRelease procedures are available at http://bit.ly/TF_PermBan");
return;
}
}
// Server full check
if (server.getOnlinePlayers().length >= server.getMaxPlayers()) if (server.getOnlinePlayers().length >= server.getMaxPlayers())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, but this server is full."); event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, but this server is full.");
return; return;
} }
// Admin-only mode
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only."); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
return; return;
} }
// Lockdown mode
if (TotalFreedomMod.lockdownEnabled) if (TotalFreedomMod.lockdownEnabled)
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode."); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode.");
return; return;
} }
// Whitelist check
if (playerList.hasWhitelist) if (playerList.hasWhitelist)
{ {
if (!playerList.getWhitelisted().contains(username.toLowerCase())) if (!playerList.getWhitelisted().contains(username.toLowerCase()))
@ -284,6 +293,7 @@ public class TFM_ServerInterface
} }
} }
// Username already logged in check
for (Player test_player : server.getOnlinePlayers()) for (Player test_player : server.getOnlinePlayers())
{ {
if (test_player.getName().equalsIgnoreCase(username)) if (test_player.getName().equalsIgnoreCase(username))
@ -293,8 +303,21 @@ public class TFM_ServerInterface
} }
} }
} }
else else // Player is superadmin
{ {
// force-allow superadmins to log in
event.allow();
if (isIPBanned(ip))
{
unbanIP(ip);
}
if (isNameBanned(username))
{
unbanUsername(username);
}
for (Player testPlayer : server.getOnlinePlayers()) for (Player testPlayer : server.getOnlinePlayers())
{ {
if (testPlayer.getName().equalsIgnoreCase(username)) if (testPlayer.getName().equalsIgnoreCase(username))
@ -303,25 +326,35 @@ public class TFM_ServerInterface
} }
} }
boolean canKick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop. int count = server.getOnlinePlayers().length;
while (server.getOnlinePlayers().length >= server.getMaxPlayers() && canKick) if (count >= server.getMaxPlayers())
{ {
canKick = false; for (Player p : server.getOnlinePlayers())
for (Player testPlayer : server.getOnlinePlayers())
{ {
if (!TFM_SuperadminList.isUserSuperadmin(testPlayer)) if (!TFM_SuperadminList.isUserSuperadmin(p))
{
p.kickPlayer("You have been kicked to free up room for an admin.");
count--;
}
if (count < server.getMaxPlayers())
{ {
canKick = true;
testPlayer.kickPlayer("You have been kicked to free up room for an admin.");
break; break;
} }
} }
} }
if (TotalFreedomMod.lockdownEnabled) if (count >= server.getMaxPlayers())
{ {
TFM_Util.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
return;
} }
}
if (TotalFreedomMod.lockdownEnabled)
{
TFM_Util.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
} }
} }

View File

@ -2,8 +2,10 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -17,22 +19,45 @@ import org.json.simple.JSONValue;
public class TFM_ServiceChecker public class TFM_ServiceChecker
{ {
public final Map<String, TFM_ServiceChecker_ServiceStatus> services = new HashMap<String, TFM_ServiceChecker_ServiceStatus>(); public final Map<String, ServiceStatus> services = new HashMap<String, ServiceStatus>();
public String lastCheck = "Unknown"; private URL url;
public String version = "1.0-Mojang"; private String lastCheck = "Unknown";
private String version = "1.0-Mojang";
public TFM_ServiceChecker() public TFM_ServiceChecker()
{ {
services.put("minecraft.net", new TFM_ServiceChecker_ServiceStatus("Minecraft.net")); services.put("minecraft.net", new ServiceStatus("Minecraft.net"));
services.put("account.mojang.com", new TFM_ServiceChecker_ServiceStatus("Mojang Account Website")); services.put("account.mojang.com", new ServiceStatus("Mojang Account Website"));
services.put("authserver.mojang.com", new TFM_ServiceChecker_ServiceStatus("Mojang Authentication")); services.put("authserver.mojang.com", new ServiceStatus("Mojang Authentication"));
services.put("skins.minecraft.net", new TFM_ServiceChecker_ServiceStatus("Minecraft Skins")); services.put("sessionserver.mojang.com", new ServiceStatus("Mojang Multiplayer sessions"));
services.put("auth.mojang.com", new TFM_ServiceChecker_ServiceStatus("Mojang Authentiation (Legacy)")); services.put("skins.minecraft.net", new ServiceStatus("Minecraft Skins"));
services.put("login.minecraft.net", new TFM_ServiceChecker_ServiceStatus("Minecraft Logins (Legacy)")); services.put("auth.mojang.com", new ServiceStatus("Mojang Authentiation (Legacy)"));
services.put("session.minecraft.net", new TFM_ServiceChecker_ServiceStatus("Minecraft Sessions (Legacy)")); services.put("login.minecraft.net", new ServiceStatus("Minecraft Logins (Legacy)"));
services.put("session.minecraft.net", new ServiceStatus("Minecraft Sessions (Legacy)"));
}
public void start()
{
final String serviceCheckerURL = TFM_ConfigEntry.SERVICE_CHECKER_URL.getString();
if (serviceCheckerURL == null || serviceCheckerURL.isEmpty())
{
return;
}
try
{
url = new URL(serviceCheckerURL);
}
catch (MalformedURLException ex)
{
TFM_Log.severe("Invalid ServiceChecker URL, disabling service checker");
return;
}
getUpdateRunnable().runTaskTimerAsynchronously(TotalFreedomMod.plugin, 40L, TotalFreedomMod.SERVICE_CHECKER_RATE * 20L);
} }
@SuppressWarnings("unchecked")
public BukkitRunnable getUpdateRunnable() public BukkitRunnable getUpdateRunnable()
{ {
return new BukkitRunnable() return new BukkitRunnable()
@ -40,78 +65,92 @@ public class TFM_ServiceChecker
@Override @Override
public void run() public void run()
{ {
final String serviceCheckerURL = TFM_ConfigEntry.SERVICE_CHECKER_URL.getString(); if (url == null)
if (serviceCheckerURL == null || serviceCheckerURL.isEmpty())
{ {
return; return;
} }
final JSONArray statusJson;
try try
{ {
URL mojangStatus = new URL(serviceCheckerURL); final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(mojangStatus.openStream())); statusJson = (JSONArray) JSONValue.parse(in.readLine());
JSONArray statusJson = (JSONArray) JSONValue.parse(in.readLine());
in.close(); in.close();
TFM_ServiceChecker serviceChecker = TFM_ServiceChecker.getInstance();
Iterator status_it = statusJson.iterator();
while (status_it.hasNext())
{
JSONObject service = (JSONObject) status_it.next();
Iterator serviceIt = service.entrySet().iterator();
while (serviceIt.hasNext())
{
Entry<String, String> pair = (Entry<String, String>) serviceIt.next();
if ("lastcheck".equals(pair.getKey()))
{
serviceChecker.lastCheck = pair.getValue();
continue;
}
if ("version".equals(pair.getKey()))
{
serviceChecker.version = pair.getValue();
continue;
}
if (pair.getValue().contains(":"))
{
String[] statusString = pair.getValue().split(":");
TFM_ServiceChecker_ServiceStatus status = serviceChecker.services.get(pair.getKey());
status.setColor(statusString[0]);
status.setMessage(statusString[1]);
status.setUptime(statusString[2]);
}
else
{
TFM_ServiceChecker_ServiceStatus status = serviceChecker.services.get(pair.getKey());
status.setColor(pair.getValue());
status.setMessage(("red".equals(pair.getValue()) ? "Offline" : ("yellow".equals(pair.getValue()) ? "Problem" : "Online")));
}
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
TFM_Log.severe("Error updating mojang services from " + serviceCheckerURL); TFM_Log.severe("Error updating mojang services from " + url);
TFM_Log.severe(ex); TFM_Log.severe(ex);
return;
}
final Iterator status = statusJson.iterator();
while (status.hasNext())
{
final Iterator serviceIt = ((JSONObject) status.next()).entrySet().iterator();
while (serviceIt.hasNext())
{
final Entry<String, String> pair = (Entry<String, String>) serviceIt.next();
if ("lastcheck".equals(pair.getKey()))
{
lastCheck = pair.getValue();
continue;
}
if ("version".equals(pair.getKey()))
{
version = pair.getValue();
continue;
}
final ServiceStatus service = services.get(pair.getKey());
if (service == null)
{
TFM_Log.warning("ServiceChecker found unknown service: " + pair.getKey());
continue;
}
if (pair.getValue().contains(":"))
{
String[] statusString = pair.getValue().split(":");
service.setColor(statusString[0]);
service.setMessage(statusString[1]);
service.setUptime(statusString[2]);
}
else
{
service.setColor(pair.getValue());
service.setMessage(("red".equals(pair.getValue()) ? "Offline" : ("yellow".equals(pair.getValue()) ? "Problem" : "Online")));
}
}
}
if (lastCheck.equals("Unknown"))
{
lastCheck = TFM_Util.dateToString(new Date());
} }
} }
}; };
} }
public List<TFM_ServiceChecker_ServiceStatus> getAllStatuses() public List<ServiceStatus> getAllStatuses()
{ {
List<TFM_ServiceChecker_ServiceStatus> ServicesList = new ArrayList<TFM_ServiceChecker_ServiceStatus>(); List<ServiceStatus> servicesList = new ArrayList<ServiceStatus>();
for (String key : services.keySet()) for (String key : services.keySet())
{ {
ServicesList.add(services.get(key)); servicesList.add(services.get(key));
} }
return ServicesList; return servicesList;
}
public String getLastCheck()
{
return lastCheck;
}
public String getVersion()
{
return version;
} }
public static TFM_ServiceChecker getInstance() public static TFM_ServiceChecker getInstance()
@ -124,14 +163,14 @@ public class TFM_ServiceChecker
private static final TFM_ServiceChecker INSTANCE = new TFM_ServiceChecker(); private static final TFM_ServiceChecker INSTANCE = new TFM_ServiceChecker();
} }
public class TFM_ServiceChecker_ServiceStatus public static class ServiceStatus
{ {
private String name; private String name;
private String uptime = "100.0"; // skins.minecraft.net, minecraft.net, etc.. private String uptime = "100.0"; // skins.minecraft.net, minecraft.net, etc..
private ChatColor color = ChatColor.DARK_GREEN; private ChatColor color = ChatColor.DARK_GREEN;
private String message = "Online"; // Online, Offline, Quite Slow, 404 Error, 500 Error, etc.. private String message = "Online"; // Online, Offline, Quite Slow, 404 Error, 500 Error, etc..
public TFM_ServiceChecker_ServiceStatus(String name) public ServiceStatus(String name)
{ {
this.name = name; this.name = name;
} }

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
public class TFM_Superadmin public class TFM_Superadmin

View File

@ -160,13 +160,41 @@ public class TFM_SuperadminList
} }
} }
public static TFM_Superadmin getAdminEntry(String admin_name) public static TFM_Superadmin getAdminEntry(Player player)
{ {
admin_name = admin_name.toLowerCase(); final String name = player.getName().toLowerCase();
if (superadminList.containsKey(admin_name)) if (Bukkit.getOnlineMode())
{ {
return superadminList.get(admin_name); if (superadminList.containsKey(name))
{
return superadminList.get(name);
}
}
try
{
final String ip = player.getAddress().getAddress().getHostAddress().trim();
if (ip != null && !ip.isEmpty())
{
return getAdminEntryByIP(ip);
}
}
catch (Exception ex)
{
return null;
}
return null;
}
@Deprecated
public static TFM_Superadmin getAdminEntry(String name)
{
name = name.toLowerCase();
if (superadminList.containsKey(name))
{
return superadminList.get(name);
} }
else else
{ {
@ -174,11 +202,6 @@ public class TFM_SuperadminList
} }
} }
public static TFM_Superadmin getAdminEntry(Player player)
{
return getAdminEntry(player.getName().toLowerCase());
}
public static TFM_Superadmin getAdminEntryByIP(String ip) public static TFM_Superadmin getAdminEntryByIP(String ip)
{ {
return getAdminEntryByIP(ip, false); return getAdminEntryByIP(ip, false);

View File

@ -7,7 +7,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -10,9 +10,9 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.apache.commons.io.FileUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -45,7 +45,7 @@ public class TFM_Util
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>(); public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
public static final List<String> STOP_COMMANDS = Arrays.asList("stop", "off", "end", "halt", "die"); public static final List<String> STOP_COMMANDS = Arrays.asList("stop", "off", "end", "halt", "die");
public static final List<String> REMOVE_COMMANDS = Arrays.asList("del", "delete", "rem", "remove"); public static final List<String> REMOVE_COMMANDS = Arrays.asList("del", "delete", "rem", "remove");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452", "xXWilee99Xx"); public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452", "xXWilee999Xx");
private static final Random RANDOM = new Random(); private static final Random RANDOM = new Random();
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<String, ChatColor>(); public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<String, ChatColor>();
@ -298,6 +298,7 @@ public class TFM_Util
return TFM_Util.mobtypes.get(mobname); return TFM_Util.mobtypes.get(mobname);
} }
@Deprecated
private static void copy(InputStream in, OutputStream out) throws IOException private static void copy(InputStream in, OutputStream out) throws IOException
{ {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
@ -414,53 +415,6 @@ public class TFM_Util
} }
} }
public static String getRank(CommandSender sender)
{
if (TFM_SuperadminList.isSuperadminImpostor(sender))
{
return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "impostor" + ChatColor.RESET + ChatColor.AQUA + "!";
}
TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
if (entry != null)
{
if (entry.isActivated())
{
String loginMessage = entry.getCustomLoginMessage();
if (loginMessage != null)
{
if (!loginMessage.isEmpty())
{
return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
}
if (!entry.isSeniorAdmin() && entry.isTelnetAdmin())
{
return "a " + ChatColor.DARK_GREEN + "Super Telnet Admin" + ChatColor.AQUA + ".";
}
if (entry.isSeniorAdmin())
{
return "a " + ChatColor.LIGHT_PURPLE + "Senior Admin" + ChatColor.AQUA + ".";
}
else
{
return "a " + ChatColor.GOLD + "Super Admin" + ChatColor.AQUA + ".";
}
}
}
if (sender.isOp())
{
return "an " + ChatColor.DARK_GREEN + "OP" + ChatColor.AQUA + ".";
}
return "a " + ChatColor.GREEN + "non-OP" + ChatColor.AQUA + ".";
}
public static Date parseDateOffset(String time) public static Date parseDateOffset(String time)
{ {
Pattern timePattern = Pattern.compile( Pattern timePattern = Pattern.compile(
@ -759,7 +713,7 @@ public class TFM_Util
public static void downloadFile(String url, File output, boolean verbose) throws java.lang.Exception public static void downloadFile(String url, File output, boolean verbose) throws java.lang.Exception
{ {
URL website = new URL(url); final URL website = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream()); ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(output); FileOutputStream fos = new FileOutputStream(output);
fos.getChannel().transferFrom(rbc, 0, 1 << 24); fos.getChannel().transferFrom(rbc, 0, 1 << 24);
@ -773,7 +727,7 @@ public class TFM_Util
public static void adminChatMessage(CommandSender sender, String message, boolean senderIsConsole) public static void adminChatMessage(CommandSender sender, String message, boolean senderIsConsole)
{ {
String name = sender.getName() + " " + getPrefix(sender, senderIsConsole); String name = sender.getName() + " " + TFM_PlayerRank.fromSender(sender).getPrefix() + ChatColor.WHITE;
TFM_Log.info("[ADMIN] " + name + ": " + message); TFM_Log.info("[ADMIN] " + name + ": " + message);
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
@ -785,36 +739,6 @@ public class TFM_Util
} }
} }
public static String getPrefix(CommandSender sender, boolean senderIsConsole)
{
String prefix;
if (senderIsConsole)
{
prefix = ChatColor.BLUE + "(Console)";
}
else
{
TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
if (!entry.isSeniorAdmin() && entry.isTelnetAdmin())
{
prefix = ChatColor.DARK_GREEN + "(STA)";
}
else if (TFM_SuperadminList.isSeniorAdmin(sender))
{
prefix = ChatColor.LIGHT_PURPLE + "(SrA)";
}
else
{
prefix = ChatColor.GOLD + "(SA)";
}
if (DEVELOPERS.contains(sender.getName()))
{
prefix = ChatColor.DARK_PURPLE + "(Dev)";
}
}
return prefix + ChatColor.WHITE;
}
//getField: Borrowed from WorldEdit //getField: Borrowed from WorldEdit
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T getField(Object from, String name) public static <T> T getField(Object from, String name)

View File

@ -8,9 +8,8 @@ import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader; import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager; import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager;
import me.StevenLawson.TotalFreedomMod.Listener.*; import me.StevenLawson.TotalFreedomMod.Listener.*;
import org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import net.minecraft.util.org.apache.commons.lang3.exception.ExceptionUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
@ -44,7 +43,7 @@ public class TotalFreedomMod extends JavaPlugin
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake."; public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console."; public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
// //
public static final Server server = Bukkit.getServer(); public static Server server = null;
public static TotalFreedomMod plugin = null; public static TotalFreedomMod plugin = null;
// //
public static String pluginName = ""; public static String pluginName = "";
@ -58,17 +57,19 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean lockdownEnabled = false; public static boolean lockdownEnabled = false;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>(); public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
// //
public static List<String> permbanned_players = new ArrayList<String>(); public static List<String> permbannedPlayers = new ArrayList<String>();
public static List<String> permbanned_ips = new ArrayList<String>(); public static List<String> permbannedIps = new ArrayList<String>();
@Override @Override
public void onLoad() public void onLoad()
{ {
TotalFreedomMod.plugin = this; TotalFreedomMod.plugin = this;
TotalFreedomMod.server = plugin.getServer();
TotalFreedomMod.pluginName = plugin.getDescription().getName(); TotalFreedomMod.pluginName = plugin.getDescription().getName();
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
TFM_Log.setPluginLogger(this.getLogger()); TFM_Log.setPluginLogger(plugin.getLogger());
TFM_Log.setServerLogger(this.getServer().getLogger()); TFM_Log.setServerLogger(server.getLogger());
setAppProperties(); setAppProperties();
} }
@ -130,7 +131,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Util.deleteFolder(new File("./_deleteme")); TFM_Util.deleteFolder(new File("./_deleteme"));
File[] coreDumps = new File(".").listFiles(new java.io.FileFilter() final File[] coreDumps = new File(".").listFiles(new java.io.FileFilter()
{ {
@Override @Override
public boolean accept(File file) public boolean accept(File file)
@ -159,13 +160,12 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage()); TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
} }
TFM_ServiceChecker.getInstance().getUpdateRunnable().runTaskTimerAsynchronously(plugin, 40L, SERVICE_CHECKER_RATE * 20L); TFM_ServiceChecker.getInstance().start();
TFM_HTTPD_Manager.getInstance().start(); TFM_HTTPD_Manager.getInstance().start();
TFM_FrontDoor.getInstance().start(); TFM_FrontDoor.getInstance().start();
TFM_LogFile.getInstance().start();
TFM_Log.info("Plugin enabled."); TFM_Log.info("Version " + pluginVersion + " enabled");
// Delayed Start : // Delayed Start :
new BukkitRunnable() new BukkitRunnable()
@ -186,7 +186,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_HTTPD_Manager.getInstance().stop(); TFM_HTTPD_Manager.getInstance().stop();
TFM_Log.info("Plugin disabled."); TFM_Log.info("Plugin disabled");
} }
@Override @Override
@ -214,10 +214,10 @@ public class TotalFreedomMod extends JavaPlugin
StringUtils.join(args, " ")), true); StringUtils.join(args, " ")), true);
} }
TFM_Command dispatcher; final TFM_Command dispatcher;
try try
{ {
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader(); final ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance(); dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
dispatcher.setup(plugin, sender, dispatcher.getClass()); dispatcher.setup(plugin, sender, dispatcher.getClass());
} }
@ -242,6 +242,7 @@ public class TotalFreedomMod extends JavaPlugin
catch (Throwable ex) catch (Throwable ex)
{ {
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex)); TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
sender.sendMessage(ChatColor.RED + "Command Error: " + ex.getMessage());
} }
} }
@ -274,20 +275,20 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Util.createDefaultConfiguration(PERMBAN_FILE); TFM_Util.createDefaultConfiguration(PERMBAN_FILE);
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), PERMBAN_FILE)); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), PERMBAN_FILE));
permbanned_players = new ArrayList<String>(); permbannedPlayers = new ArrayList<String>();
permbanned_ips = new ArrayList<String>(); permbannedIps = new ArrayList<String>();
for (String user : config.getKeys(false)) for (String user : config.getKeys(false))
{ {
permbanned_players.add(user.toLowerCase().trim()); permbannedPlayers.add(user.toLowerCase().trim());
List<String> user_ips = config.getStringList(user); List<String> user_ips = config.getStringList(user);
for (String ip : user_ips) for (String ip : user_ips)
{ {
ip = ip.toLowerCase().trim(); ip = ip.toLowerCase().trim();
if (!permbanned_ips.contains(ip)) if (!permbannedIps.contains(ip))
{ {
permbanned_ips.add(ip); permbannedIps.add(ip);
} }
} }
} }
@ -301,7 +302,7 @@ public class TotalFreedomMod extends JavaPlugin
private static void registerEventHandlers() private static void registerEventHandlers()
{ {
PluginManager pm = server.getPluginManager(); final PluginManager pm = server.getPluginManager();
pm.registerEvents(new TFM_EntityListener(), plugin); pm.registerEvents(new TFM_EntityListener(), plugin);
pm.registerEvents(new TFM_BlockListener(), plugin); pm.registerEvents(new TFM_BlockListener(), plugin);
@ -322,14 +323,16 @@ public class TotalFreedomMod extends JavaPlugin
props.load(in); props.load(in);
in.close(); in.close();
TotalFreedomMod.pluginVersion = props.getProperty("program.VERSION"); TotalFreedomMod.buildNumber = props.getProperty("program.buildnumber");
TotalFreedomMod.buildNumber = props.getProperty("program.BUILDNUM"); TotalFreedomMod.buildDate = props.getProperty("program.builddate");
TotalFreedomMod.buildDate = props.getProperty("program.BUILDDATE");
} }
catch (Exception ex) catch (Exception ex)
{ {
TFM_Log.severe("Could not load App properties!"); TFM_Log.severe("Could not load App properties!");
TFM_Log.severe(ex); TFM_Log.severe(ex);
TotalFreedomMod.buildNumber = "1";
TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date());
} }
} }
} }

View File

@ -54,70 +54,61 @@ import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
public class Metrics { public class Metrics
{
/** /**
* The current revision number * The current revision number
*/ */
private final static int REVISION = 7; private final static int REVISION = 7;
/** /**
* The base url of the metrics domain * The base url of the metrics domain
*/ */
private static final String BASE_URL = "http://report.mcstats.org"; private static final String BASE_URL = "http://report.mcstats.org";
/** /**
* The url used to report a server's status * The url used to report a server's status
*/ */
private static final String REPORT_URL = "/plugin/%s"; private static final String REPORT_URL = "/plugin/%s";
/** /**
* Interval of time to ping (in minutes) * Interval of time to ping (in minutes)
*/ */
private static final int PING_INTERVAL = 15; private static final int PING_INTERVAL = 15;
/** /**
* The plugin this metrics submits for * The plugin this metrics submits for
*/ */
private final Plugin plugin; private final Plugin plugin;
/** /**
* All of the custom graphs to submit to metrics * All of the custom graphs to submit to metrics
*/ */
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>()); private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/** /**
* The plugin configuration file * The plugin configuration file
*/ */
private final YamlConfiguration configuration; private final YamlConfiguration configuration;
/** /**
* The plugin configuration file * The plugin configuration file
*/ */
private final File configurationFile; private final File configurationFile;
/** /**
* Unique server id * Unique server id
*/ */
private final String guid; private final String guid;
/** /**
* Debug mode * Debug mode
*/ */
private final boolean debug; private final boolean debug;
/** /**
* Lock for synchronization * Lock for synchronization
*/ */
private final Object optOutLock = new Object(); private final Object optOutLock = new Object();
/** /**
* The scheduled task * The scheduled task
*/ */
private volatile BukkitTask task = null; private volatile BukkitTask task = null;
public Metrics(final Plugin plugin) throws IOException { public Metrics(final Plugin plugin) throws IOException
if (plugin == null) { {
if (plugin == null)
{
throw new IllegalArgumentException("Plugin cannot be null"); throw new IllegalArgumentException("Plugin cannot be null");
} }
@ -133,7 +124,8 @@ public class Metrics {
configuration.addDefault("debug", false); configuration.addDefault("debug", false);
// Do we need to create the file? // Do we need to create the file?
if (configuration.get("guid", null) == null) { if (configuration.get("guid", null) == null)
{
configuration.options().header("http://mcstats.org").copyDefaults(true); configuration.options().header("http://mcstats.org").copyDefaults(true);
configuration.save(configurationFile); configuration.save(configurationFile);
} }
@ -150,8 +142,10 @@ public class Metrics {
* @param name The name of the graph * @param name The name of the graph
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
*/ */
public Graph createGraph(final String name) { public Graph createGraph(final String name)
if (name == null) { {
if (name == null)
{
throw new IllegalArgumentException("Graph name cannot be null"); throw new IllegalArgumentException("Graph name cannot be null");
} }
@ -170,8 +164,10 @@ public class Metrics {
* *
* @param graph The name of the graph * @param graph The name of the graph
*/ */
public void addGraph(final Graph graph) { public void addGraph(final Graph graph)
if (graph == null) { {
if (graph == null)
{
throw new IllegalArgumentException("Graph cannot be null"); throw new IllegalArgumentException("Graph cannot be null");
} }
@ -185,33 +181,42 @@ public class Metrics {
* *
* @return True if statistics measuring is running, otherwise false. * @return True if statistics measuring is running, otherwise false.
*/ */
public boolean start() { public boolean start()
synchronized (optOutLock) { {
synchronized (optOutLock)
{
// Did we opt out? // Did we opt out?
if (isOptOut()) { if (isOptOut())
{
return false; return false;
} }
// Is metrics already running? // Is metrics already running?
if (task != null) { if (task != null)
{
return true; return true;
} }
// Begin hitting the server with glorious data // Begin hitting the server with glorious data
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
{
private boolean firstPost = true; private boolean firstPost = true;
public void run() { public void run()
try { {
try
{
// This has to be synchronized or it can collide with the disable method. // This has to be synchronized or it can collide with the disable method.
synchronized (optOutLock) { synchronized (optOutLock)
{
// Disable Task, if it is running and the server owner decided to opt-out // Disable Task, if it is running and the server owner decided to opt-out
if (isOptOut() && task != null) { if (isOptOut() && task != null)
{
task.cancel(); task.cancel();
task = null; task = null;
// Tell all plotters to stop gathering information. // Tell all plotters to stop gathering information.
for (Graph graph : graphs) { for (Graph graph : graphs)
{
graph.onOptOut(); graph.onOptOut();
} }
} }
@ -225,8 +230,11 @@ public class Metrics {
// After the first post we set firstPost to false // After the first post we set firstPost to false
// Each post thereafter will be a ping // Each post thereafter will be a ping
firstPost = false; firstPost = false;
} catch (IOException e) { }
if (debug) { catch (IOException e)
{
if (debug)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
} }
} }
@ -242,18 +250,27 @@ public class Metrics {
* *
* @return true if metrics should be opted out of it * @return true if metrics should be opted out of it
*/ */
public boolean isOptOut() { public boolean isOptOut()
synchronized (optOutLock) { {
try { synchronized (optOutLock)
{
try
{
// Reload the metrics file // Reload the metrics file
configuration.load(getConfigFile()); configuration.load(getConfigFile());
} catch (IOException ex) { }
if (debug) { catch (IOException ex)
{
if (debug)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
} }
return true; return true;
} catch (InvalidConfigurationException ex) { }
if (debug) { catch (InvalidConfigurationException ex)
{
if (debug)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
} }
return true; return true;
@ -267,17 +284,21 @@ public class Metrics {
* *
* @throws java.io.IOException * @throws java.io.IOException
*/ */
public void enable() throws IOException { public void enable() throws IOException
{
// This has to be synchronized or it can collide with the check in the task. // This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) { synchronized (optOutLock)
{
// Check if the server owner has already set opt-out, if not, set it. // Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) { if (isOptOut())
{
configuration.set("opt-out", false); configuration.set("opt-out", false);
configuration.save(configurationFile); configuration.save(configurationFile);
} }
// Enable Task, if it is not running // Enable Task, if it is not running
if (task == null) { if (task == null)
{
start(); start();
} }
} }
@ -288,17 +309,21 @@ public class Metrics {
* *
* @throws java.io.IOException * @throws java.io.IOException
*/ */
public void disable() throws IOException { public void disable() throws IOException
{
// This has to be synchronized or it can collide with the check in the task. // This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) { synchronized (optOutLock)
{
// Check if the server owner has already set opt-out, if not, set it. // Check if the server owner has already set opt-out, if not, set it.
if (!isOptOut()) { if (!isOptOut())
{
configuration.set("opt-out", true); configuration.set("opt-out", true);
configuration.save(configurationFile); configuration.save(configurationFile);
} }
// Disable Task, if it is running // Disable Task, if it is running
if (task != null) { if (task != null)
{
task.cancel(); task.cancel();
task = null; task = null;
} }
@ -310,7 +335,8 @@ public class Metrics {
* *
* @return the File object for the config file * @return the File object for the config file
*/ */
public File getConfigFile() { public File getConfigFile()
{
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
// is to abuse the plugin object we already have // is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/ // plugin.getDataFolder() => base/plugins/PluginA/
@ -325,7 +351,8 @@ public class Metrics {
/** /**
* Generic method that posts a plugin to the metrics website * Generic method that posts a plugin to the metrics website
*/ */
private void postPlugin(final boolean isPing) throws IOException { private void postPlugin(final boolean isPing) throws IOException
{
// Server software specific section // Server software specific section
PluginDescriptionFile description = plugin.getDescription(); PluginDescriptionFile description = plugin.getDescription();
String pluginName = description.getName(); String pluginName = description.getName();
@ -354,7 +381,8 @@ public class Metrics {
int coreCount = Runtime.getRuntime().availableProcessors(); int coreCount = Runtime.getRuntime().availableProcessors();
// normalize os arch .. amd64 -> x86_64 // normalize os arch .. amd64 -> x86_64
if (osarch.equals("amd64")) { if (osarch.equals("amd64"))
{
osarch = "x86_64"; osarch = "x86_64";
} }
@ -366,12 +394,15 @@ public class Metrics {
appendJSONPair(json, "java_version", java_version); appendJSONPair(json, "java_version", java_version);
// If we're pinging, append it // If we're pinging, append it
if (isPing) { if (isPing)
{
appendJSONPair(json, "ping", "1"); appendJSONPair(json, "ping", "1");
} }
if (graphs.size() > 0) { if (graphs.size() > 0)
synchronized (graphs) { {
synchronized (graphs)
{
json.append(','); json.append(',');
json.append('"'); json.append('"');
json.append("graphs"); json.append("graphs");
@ -383,19 +414,22 @@ public class Metrics {
final Iterator<Graph> iter = graphs.iterator(); final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) { while (iter.hasNext())
{
Graph graph = iter.next(); Graph graph = iter.next();
StringBuilder graphJson = new StringBuilder(); StringBuilder graphJson = new StringBuilder();
graphJson.append('{'); graphJson.append('{');
for (Plotter plotter : graph.getPlotters()) { for (Plotter plotter : graph.getPlotters())
{
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue())); appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
} }
graphJson.append('}'); graphJson.append('}');
if (!firstGraph) { if (!firstGraph)
{
json.append(','); json.append(',');
} }
@ -421,9 +455,12 @@ public class Metrics {
// Mineshafter creates a socks proxy, so we can safely bypass it // Mineshafter creates a socks proxy, so we can safely bypass it
// It does not reroute POST requests so we need to go around it // It does not reroute POST requests so we need to go around it
if (isMineshafterPresent()) { if (isMineshafterPresent())
{
connection = url.openConnection(Proxy.NO_PROXY); connection = url.openConnection(Proxy.NO_PROXY);
} else { }
else
{
connection = url.openConnection(); connection = url.openConnection();
} }
@ -441,7 +478,8 @@ public class Metrics {
connection.setDoOutput(true); connection.setDoOutput(true);
if (debug) { if (debug)
{
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
} }
@ -458,24 +496,34 @@ public class Metrics {
os.close(); os.close();
reader.close(); reader.close();
if (response == null || response.startsWith("ERR") || response.startsWith("7")) { if (response == null || response.startsWith("ERR") || response.startsWith("7"))
if (response == null) { {
if (response == null)
{
response = "null"; response = "null";
} else if (response.startsWith("7")) { }
else if (response.startsWith("7"))
{
response = response.substring(response.startsWith("7,") ? 2 : 1); response = response.substring(response.startsWith("7,") ? 2 : 1);
} }
throw new IOException(response); throw new IOException(response);
} else { }
else
{
// Is this the first update this hour? // Is this the first update this hour?
if (response.equals("1") || response.contains("This is your first update this hour")) { if (response.equals("1") || response.contains("This is your first update this hour"))
synchronized (graphs) { {
synchronized (graphs)
{
final Iterator<Graph> iter = graphs.iterator(); final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) { while (iter.hasNext())
{
final Graph graph = iter.next(); final Graph graph = iter.next();
for (Plotter plotter : graph.getPlotters()) { for (Plotter plotter : graph.getPlotters())
{
plotter.reset(); plotter.reset();
} }
} }
@ -490,19 +538,31 @@ public class Metrics {
* @param input * @param input
* @return * @return
*/ */
public static byte[] gzip(String input) { public static byte[] gzip(String input)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null; GZIPOutputStream gzos = null;
try { try
{
gzos = new GZIPOutputStream(baos); gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8")); gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} finally { }
if (gzos != null) try { finally
gzos.close(); {
} catch (IOException ignore) { if (gzos != null)
{
try
{
gzos.close();
}
catch (IOException ignore)
{
}
} }
} }
@ -514,11 +574,15 @@ public class Metrics {
* *
* @return true if mineshafter is installed on the server * @return true if mineshafter is installed on the server
*/ */
private boolean isMineshafterPresent() { private boolean isMineshafterPresent()
try { {
try
{
Class.forName("mineshafter.MineServer"); Class.forName("mineshafter.MineServer");
return true; return true;
} catch (Exception e) { }
catch (Exception e)
{
return false; return false;
} }
} }
@ -531,28 +595,37 @@ public class Metrics {
* @param value * @param value
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
*/ */
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException
{
boolean isValueNumeric = false; boolean isValueNumeric = false;
try { try
if (value.equals("0") || !value.endsWith("0")) { {
if (value.equals("0") || !value.endsWith("0"))
{
Double.parseDouble(value); Double.parseDouble(value);
isValueNumeric = true; isValueNumeric = true;
} }
} catch (NumberFormatException e) { }
catch (NumberFormatException e)
{
isValueNumeric = false; isValueNumeric = false;
} }
if (json.charAt(json.length() - 1) != '{') { if (json.charAt(json.length() - 1) != '{')
{
json.append(','); json.append(',');
} }
json.append(escapeJSON(key)); json.append(escapeJSON(key));
json.append(':'); json.append(':');
if (isValueNumeric) { if (isValueNumeric)
{
json.append(value); json.append(value);
} else { }
else
{
json.append(escapeJSON(value)); json.append(escapeJSON(value));
} }
} }
@ -563,14 +636,17 @@ public class Metrics {
* @param text * @param text
* @return * @return
*/ */
private static String escapeJSON(String text) { private static String escapeJSON(String text)
{
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append('"'); builder.append('"');
for (int index = 0; index < text.length(); index++) { for (int index = 0; index < text.length(); index++)
{
char chr = text.charAt(index); char chr = text.charAt(index);
switch (chr) { switch (chr)
{
case '"': case '"':
case '\\': case '\\':
builder.append('\\'); builder.append('\\');
@ -589,10 +665,13 @@ public class Metrics {
builder.append("\\r"); builder.append("\\r");
break; break;
default: default:
if (chr < ' ') { if (chr < ' ')
{
String t = "000" + Integer.toHexString(chr); String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4)); builder.append("\\u" + t.substring(t.length() - 4));
} else { }
else
{
builder.append(chr); builder.append(chr);
} }
break; break;
@ -609,27 +688,28 @@ public class Metrics {
* @param text the text to encode * @param text the text to encode
* @return the encoded text, as UTF-8 * @return the encoded text, as UTF-8
*/ */
private static String urlEncode(final String text) throws UnsupportedEncodingException { private static String urlEncode(final String text) throws UnsupportedEncodingException
{
return URLEncoder.encode(text, "UTF-8"); return URLEncoder.encode(text, "UTF-8");
} }
/** /**
* Represents a custom graph on the website * Represents a custom graph on the website
*/ */
public static class Graph { public static class Graph
{
/** /**
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
* rejected * rejected
*/ */
private final String name; private final String name;
/** /**
* The set of plotters that are contained within this graph * The set of plotters that are contained within this graph
*/ */
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>(); private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
private Graph(final String name) { private Graph(final String name)
{
this.name = name; this.name = name;
} }
@ -638,7 +718,8 @@ public class Metrics {
* *
* @return the Graph's name * @return the Graph's name
*/ */
public String getName() { public String getName()
{
return name; return name;
} }
@ -647,7 +728,8 @@ public class Metrics {
* *
* @param plotter the plotter to add to the graph * @param plotter the plotter to add to the graph
*/ */
public void addPlotter(final Plotter plotter) { public void addPlotter(final Plotter plotter)
{
plotters.add(plotter); plotters.add(plotter);
} }
@ -656,7 +738,8 @@ public class Metrics {
* *
* @param plotter the plotter to remove from the graph * @param plotter the plotter to remove from the graph
*/ */
public void removePlotter(final Plotter plotter) { public void removePlotter(final Plotter plotter)
{
plotters.remove(plotter); plotters.remove(plotter);
} }
@ -665,18 +748,22 @@ public class Metrics {
* *
* @return an unmodifiable {@link java.util.Set} of the plotter objects * @return an unmodifiable {@link java.util.Set} of the plotter objects
*/ */
public Set<Plotter> getPlotters() { public Set<Plotter> getPlotters()
{
return Collections.unmodifiableSet(plotters); return Collections.unmodifiableSet(plotters);
} }
@Override @Override
public int hashCode() { public int hashCode()
{
return name.hashCode(); return name.hashCode();
} }
@Override @Override
public boolean equals(final Object object) { public boolean equals(final Object object)
if (!(object instanceof Graph)) { {
if (!(object instanceof Graph))
{
return false; return false;
} }
@ -687,15 +774,16 @@ public class Metrics {
/** /**
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running. * Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
*/ */
protected void onOptOut() { protected void onOptOut()
{
} }
} }
/** /**
* Interface used to collect custom data for a plugin * Interface used to collect custom data for a plugin
*/ */
public static abstract class Plotter { public static abstract class Plotter
{
/** /**
* The plot's name * The plot's name
*/ */
@ -704,7 +792,8 @@ public class Metrics {
/** /**
* Construct a plotter with the default plot name * Construct a plotter with the default plot name
*/ */
public Plotter() { public Plotter()
{
this("Default"); this("Default");
} }
@ -713,7 +802,8 @@ public class Metrics {
* *
* @param name the name of the plotter to use, which will show up on the website * @param name the name of the plotter to use, which will show up on the website
*/ */
public Plotter(final String name) { public Plotter(final String name)
{
this.name = name; this.name = name;
} }
@ -731,24 +821,29 @@ public class Metrics {
* *
* @return the plotted point's column name * @return the plotted point's column name
*/ */
public String getColumnName() { public String getColumnName()
{
return name; return name;
} }
/** /**
* Called after the website graphs have been updated * Called after the website graphs have been updated
*/ */
public void reset() { public void reset()
{
} }
@Override @Override
public int hashCode() { public int hashCode()
{
return getColumnName().hashCode(); return getColumnName().hashCode();
} }
@Override @Override
public boolean equals(final Object object) { public boolean equals(final Object object)
if (!(object instanceof Plotter)) { {
if (!(object instanceof Plotter))
{
return false; return false;
} }

View File

@ -1,6 +1,6 @@
name: TotalFreedomMod name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 3.3 version: 3.4
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
authors: [Madgeek1450, DarthSalamon] authors: [Madgeek1450, DarthSalamon]