Browse Source

Initial commit

Olyol95 8 years ago
commit
47b2b021c9

+ 8 - 0
.classpath

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="lib" path="C:/Users/Oliver/Documents/lib/Votifier.jar"/>
+	<classpathentry kind="lib" path="C:/Users/Oliver/Documents/lib/craftbukkit-1.7.9-R0.2.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 1 - 0
.idea/.name

@@ -0,0 +1 @@
+VoteForDiamonds

+ 10 - 0
.idea/artifacts/YARP.xml

@@ -0,0 +1,10 @@
+<component name="ArtifactManager">
+  <artifact type="jar" name="YARP">
+    <output-path>$PROJECT_DIR$/../../Server/plugins</output-path>
+    <root id="archive" name="YARP.jar">
+      <element id="module-output" name="YARP" />
+      <element id="file-copy" path="$PROJECT_DIR$/plugin.yml" />
+      <element id="file-copy" path="$PROJECT_DIR$/config.yml" />
+    </root>
+  </artifact>
+</component>

+ 23 - 0
.idea/compiler.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <option name="DEFAULT_COMPILER" value="Javac" />
+    <resourceExtensions />
+    <wildcardResourcePatterns>
+      <entry name="!?*.java" />
+      <entry name="!?*.form" />
+      <entry name="!?*.class" />
+      <entry name="!?*.groovy" />
+      <entry name="!?*.scala" />
+      <entry name="!?*.flex" />
+      <entry name="!?*.kt" />
+      <entry name="!?*.clj" />
+      <entry name="!?*.aj" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>

+ 3 - 0
.idea/copyright/profiles_settings.xml

@@ -0,0 +1,3 @@
+<component name="CopyrightManager">
+  <settings default="" />
+</component>

+ 9 - 0
.idea/libraries/Votifier.xml

@@ -0,0 +1,9 @@
+<component name="libraryTable">
+  <library name="Votifier">
+    <CLASSES>
+      <root url="jar://$PROJECT_DIR$/../../lib/Votifier.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>

+ 11 - 0
.idea/libraries/spigot_1_8_7.xml

@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="spigot-1.8.7">
+    <CLASSES>
+      <root url="jar://$PROJECT_DIR$/../../spigot/spigot-1.8.7.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$PROJECT_DIR$/../../spigot/spigot-1.8.7.jar!/" />
+    </SOURCES>
+  </library>
+</component>

+ 19 - 0
.idea/misc.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="EntryPointsManager">
+    <entry_points version="2.0" />
+  </component>
+  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
+    <OptionsSetting value="true" id="Add" />
+    <OptionsSetting value="true" id="Remove" />
+    <OptionsSetting value="true" id="Checkout" />
+    <OptionsSetting value="true" id="Update" />
+    <OptionsSetting value="true" id="Status" />
+    <OptionsSetting value="true" id="Edit" />
+    <ConfirmationsSetting value="0" id="Add" />
+    <ConfirmationsSetting value="0" id="Remove" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/classes" />
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/YARP.iml" filepath="$PROJECT_DIR$/YARP.iml" />
+    </modules>
+  </component>
+</project>

+ 124 - 0
.idea/uiDesigner.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="" />
+  </component>
+</project>

+ 17 - 0
.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>VoteForDiamonds</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 11 - 0
.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7

+ 39 - 0
YARP.iml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="EclipseModuleManager">
+    <libelement value="file://C:/Users/Oliver/Documents/lib/Votifier.jar" />
+    <libelement value="file://C:/Users/Oliver/Documents/lib/craftbukkit-1.7.9-R0.2.jar" />
+    <src_description expected_position="0">
+      <src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
+    </src_description>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/bin" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="module-library">
+      <library name="Votifier.jar">
+        <CLASSES>
+          <root url="file://C:/Users/Oliver/Documents/lib/Votifier.jar" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="craftbukkit-1.7.9-R0.2.jar">
+        <CLASSES>
+          <root url="file://C:/Users/Oliver/Documents/lib/craftbukkit-1.7.9-R0.2.jar" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="library" name="spigot-1.8.7" level="project" />
+    <orderEntry type="library" name="Votifier" level="project" />
+  </component>
+</module>

+ 130 - 0
config.yml

@@ -0,0 +1,130 @@
+#
+#       Y88b   d88P         d8888     8888888b.      8888888b.
+#        Y88b d88P         d88888     888   Y88b     888   Y88b
+#         Y88o88P         d88P888     888    888     888    888
+#          Y888P         d88P 888     888   d88P     888   d88P
+#           888         d88P  888     8888888P"      8888888P"
+#           888        d88P   888     888 T88b       888
+#           888  d8b  d8888888888 d8b 888  T88b  d8b 888
+#           888  Y8P d88P     888 Y8P 888   T88b Y8P 888
+#
+#                     Yet Another Rewards Plugin!
+#                            Configuration
+
+# Rewards section
+#
+# List rewards here, once set, do not change the name of a reward!
+#
+# Explanation of rewards config:
+#
+#   (note, *key_name* indicates a mandatory key.)
+#
+#   - *command*: the command to execute upon receiving the reward.
+#     - {user} the user that has received the reward.
+#     - {amount} the amount of the given reward received.
+#   - amount_per_reward: the amount of the reward given each time the
+#                        reward is achieved.
+#   - *description*: the name of the reward, broadcast upon receiving
+#                    the reward.
+#   - *votes_required*: the number of votes needed for the reward.
+#   - *repeatable*: indicates whether a player can get the reward more
+#                   than once.
+rewards:
+  reward_1:
+      command: "give {user} diamond {amount}"
+      amount_per_reward: 1
+      description: "{amount} diamond(s)."
+      votes_required: 5
+      repeatable: true
+  reward_2:
+      command: "amodwallet {user} {amount}"
+      amount_per_reward: 3000
+      description: "{amount}() of money."
+      votes_required: 15
+      repeatable: true
+
+# Milestones section
+#
+# Milestones act as a way of measuring the progress of voting on the
+# server. List them below in the same way as for the rewards.
+#
+# Explanation of milestone config:
+#
+#   (note, *key_name* indicates a mandatory key.)
+#
+#   - *amount*: the amount of votes required to reach the milestone.
+#   - *message*: the message broadcast on reaching the milestone.
+#   - colour: the colour of the broadcast, if this is not set, the
+#             colour will default to the main_colour.
+milestones:
+  milestone_1:
+      amount: 100
+      message: "The server just passed 100 votes!"
+      colour: "GREEN"
+  milestone_2:
+      amount: 200
+      message: "The server just passed 200 votes!"
+      colour: "GREEN"
+  milestone_3:
+      amount: 400
+      message: "The server just passed 400 votes!"
+      colour: "GREEN"
+  milestone_4:
+      amount: 800
+      message: "The server just passed 800 votes!"
+      colour: "GREEN"
+
+# Links section
+#
+# Below, list the links which you would like your players to vote at.
+voting_links:
+  - "http://tinyurl.com/pm-lb-vote"
+  - "http://tinyurl.com/mc-mp-vote"
+  - "http://tinyurl.com/minecraft-servers-vote"
+  - "http://tinyurl.com/mc-server-list-vote"
+  - "http://tinyurl.com/mc-servers-list-vote"
+
+# Plugin prefix
+#
+# text: the text contained in the prefix.
+# colour: the colour of the prefix.
+# start: the symbols before the text of the prefix.
+# end: the symbols after the prefix text, but before the message.
+prefix:
+  text: "VOTE"
+  colour: "AQUA"
+  start: "["
+  end: "] "
+
+# when set to true, this option will place the plugin prefix before
+# all of the messages produced by the plugin.
+show_prefix: true
+
+# the default colour for the messages produced by the plugin.
+main_colour: "GREEN"
+
+# when set to true, every vote by a player will be broadcast over the
+# server chat, to all players on the server.
+broadcast_votes: true
+
+# when set to true, every reward earned by a player will be broadcast
+# over the server chat, to all players on the server.
+broadcast_rewards: true
+
+# Saving options
+#
+# You may choose to either use a mysql database to store results
+# (recommended) or, if you do not have a database available, you
+# may use a file detailed by the save_file option.
+save_file: "user_votes.dat"
+use_mysql: false
+table_prefix: "YARP_"
+mysql_host:
+mysql_port:
+mysql_database:
+mysql_username:
+mysql_password:
+
+# That's it, you're done!
+# Make sure to /yarp reload if you have edited this whilst your
+# server is running!

+ 47 - 0
plugin.yml

@@ -0,0 +1,47 @@
+name: YARP
+main: org.noip.olyol95.yarp.Yarp
+version: 1.0
+author: Olyol95
+depend:
+  - Votifier
+commands:
+  vote:
+    description: Displays the voting links for the server.
+    usage: /vote
+  vote reward:
+    description: Collect the rewards that you have earned by voting.
+    usage: /vote reward
+  vote status:
+    description: See the current status of a voting record.
+    usage: /vote status [player_name]
+  vote leaderboard:
+    description: See the current server-wide voting statistics.
+    usage: /vote leaderboard
+  vote rewards:
+    description: See the list of current rewards available by voting.
+    usage: /vote rewards
+  vote reload:
+    description: Reload YARP.
+    usage: /vote reload
+permissions:
+  yarp.user.vote:
+    description: Gives access to the voting links.
+    default: true
+  yarp.user.reward:
+    description: Gives access to rewards earned from voting.
+    default: true
+  yarp.user.rewards:
+    description: Gives access to the list of rewards available.
+    default: true
+  yarp.user.status:
+    description: Gives access to voting records for yourself.
+    default: true
+  yarp.user.status.other:
+    description: Gives access to voting records for another.
+    default: true
+  yarp.user.leaderboard:
+    description: Gives access to the server-wide voting statistics.
+    default: true
+  yarp.admin.reload:
+    description: Allows a player to reload the plugin.
+    default: op

+ 119 - 0
src/com/evilmidget38/UUIDFetcher.java

@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2015 Nate Mortensen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.evilmidget38;
+
+import com.google.common.collect.ImmutableList;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+public class UUIDFetcher implements Callable<Map<String, UUID>> {
+
+    private static final double PROFILES_PER_REQUEST = 100;
+    private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
+    private final JSONParser jsonParser = new JSONParser();
+    private final List<String> names;
+    private final boolean rateLimiting;
+
+    public UUIDFetcher(List<String> names, boolean rateLimiting) {
+        this.names = ImmutableList.copyOf(names);
+        this.rateLimiting = rateLimiting;
+    }
+
+    public UUIDFetcher(List<String> names) {
+        this(names, true);
+    }
+
+    public Map<String, UUID> call() throws Exception {
+        Map<String, UUID> uuidMap = new HashMap<String, UUID>();
+        int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
+        for (int i = 0; i < requests; i++) {
+            HttpURLConnection connection = createConnection();
+            String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
+            writeBody(connection, body);
+            JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
+            for (Object profile : array) {
+                JSONObject jsonProfile = (JSONObject) profile;
+                String id = (String) jsonProfile.get("id");
+                String name = (String) jsonProfile.get("name");
+                UUID uuid = UUIDFetcher.getUUID(id);
+                uuidMap.put(name, uuid);
+            }
+            if (rateLimiting && i != requests - 1) {
+                Thread.sleep(100L);
+            }
+        }
+        return uuidMap;
+    }
+
+    private static void writeBody(HttpURLConnection connection, String body) throws Exception {
+        OutputStream stream = connection.getOutputStream();
+        stream.write(body.getBytes());
+        stream.flush();
+        stream.close();
+    }
+
+    private static HttpURLConnection createConnection() throws Exception {
+        URL url = new URL(PROFILE_URL);
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("POST");
+        connection.setRequestProperty("Content-Type", "application/json");
+        connection.setUseCaches(false);
+        connection.setDoInput(true);
+        connection.setDoOutput(true);
+        return connection;
+    }
+
+    private static UUID getUUID(String id) {
+        return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" +id.substring(20, 32));
+    }
+
+    public static byte[] toBytes(UUID uuid) {
+        ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
+        byteBuffer.putLong(uuid.getMostSignificantBits());
+        byteBuffer.putLong(uuid.getLeastSignificantBits());
+        return byteBuffer.array();
+    }
+
+    public static UUID fromBytes(byte[] array) {
+        if (array.length != 16) {
+            throw new IllegalArgumentException("Illegal byte array length: " + array.length);
+        }
+        ByteBuffer byteBuffer = ByteBuffer.wrap(array);
+        long mostSignificant = byteBuffer.getLong();
+        long leastSignificant = byteBuffer.getLong();
+        return new UUID(mostSignificant, leastSignificant);
+    }
+
+    public static UUID getUUIDOf(String name) throws Exception {
+        return new UUIDFetcher(Arrays.asList(name)).call().get(name);
+    }
+
+}

+ 365 - 0
src/org/noip/olyol95/yarp/Yarp.java

@@ -0,0 +1,365 @@
+package org.noip.olyol95.yarp;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.UUID;
+import java.util.logging.Level;
+
+import com.evilmidget38.UUIDFetcher;
+import com.vexsoftware.votifier.model.Vote;
+import com.vexsoftware.votifier.model.VotifierEvent;
+import org.bukkit.GameMode;
+import org.bukkit.Material;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.PlayerInventory;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.noip.olyol95.yarp.entities.Milestone;
+import org.noip.olyol95.yarp.entities.Reward;
+import org.noip.olyol95.yarp.entities.VoteRecord;
+import org.noip.olyol95.yarp.listeners.VotingListener;
+import org.noip.olyol95.yarp.util.ChatUtils;
+import org.noip.olyol95.yarp.util.ConfigurationParser;
+
+public class Yarp extends JavaPlugin {
+
+    private static Yarp instance;
+
+    public static Boolean BROADCAST_VOTES, BROADCAST_REWARDS;
+
+    private Hashtable<UUID,VoteRecord> userVotes;
+    private ArrayList<Milestone> milestones;
+    private ArrayList<Reward> rewards;
+    private ArrayList<String> links;
+
+    @Override
+    public void onEnable() {
+
+        instance = this;
+        milestones = new ArrayList<>();
+        rewards = new ArrayList<>();
+        links = new ArrayList<>();
+        userVotes = new Hashtable<>();
+
+        saveDefaultConfig();
+
+        if (!ConfigurationParser.parse()) {
+
+            getLogger().log(Level.INFO,"Disabling Yarp.");
+            setEnabled(false);
+            return;
+
+        }
+
+        getServer().getPluginManager().registerEvents(new VotingListener(), this);
+
+    }
+
+    @Override
+    public void onDisable() {
+
+        milestones = null;
+        rewards = null;
+        links = null;
+        userVotes = null;
+        instance = null;
+
+    }
+
+    public Hashtable<UUID,VoteRecord> getUserVotes() {
+
+        return userVotes;
+
+    }
+
+    public void addVoteRecord(VoteRecord record) {
+
+        userVotes.put(record.getPlayerID(),record);
+
+    }
+
+    public VoteRecord getVoteRecord(UUID playerID) {
+
+        return userVotes.get(playerID);
+
+    }
+
+    public VoteRecord getVoteRecord(String username) throws Exception {
+
+        if (isOnline(username)) {
+
+            return userVotes.get(getServer().getPlayer(username).getUniqueId());
+
+        } else {
+
+            return userVotes.get(getServer().getOfflinePlayer(UUIDFetcher.getUUIDOf(username)).getUniqueId());
+
+        }
+
+    }
+
+    public int getTotalVotes() {
+
+        int totalVotes = 0;
+
+        for (VoteRecord voteRecord: userVotes.values()) {
+
+            totalVotes += voteRecord.getTotalVotes();
+
+        }
+
+        return totalVotes;
+
+    }
+
+    public boolean isOnline(String username) {
+
+        boolean isOnline = false;
+
+        for (Player p: getServer().getOnlinePlayers()) {
+
+            if (p.getName().equals(username)) {
+
+                isOnline = true;
+
+            }
+
+        }
+
+        return isOnline;
+
+    }
+
+    public void broadcastVoteMessage(String username, String address) {
+
+        if (BROADCAST_VOTES) {
+
+            getServer().broadcastMessage(ChatUtils.formatMessage(username + " has voted for the server at: " + address + "!"));
+
+        } else {
+
+            if (isOnline(username)) {
+
+                getServer().getPlayer(username).sendMessage(ChatUtils.formatMessage("You have voted for the server at: " + address + "!"));
+
+            }
+
+        }
+
+    }
+
+    public void broadcastRewardMessage(String username, ArrayList<String> rewards) {
+
+        String rewardText = "";
+
+        for (String reward: rewards) {
+
+            rewardText += "\n\t"+reward;
+
+        }
+
+        if (BROADCAST_REWARDS) {
+
+            getServer().broadcastMessage(ChatUtils.formatMessage(username + " has earned themselves the following by voting:" + rewardText));
+
+        } else {
+
+            if (isOnline(username)) {
+
+                getServer().getPlayer(username).sendMessage(ChatUtils.formatMessage("You have earned the following rewards:"+rewardText));
+
+            }
+
+        }
+
+    }
+
+    public static Yarp getInstance() {
+
+        return instance;
+
+    }
+
+    public void checkForRewards(VoteRecord voteRecord) {
+
+        for (Reward reward: getRewards()) {
+
+            if (reward.isEarned(voteRecord)) {
+
+                Player player = getServer().getPlayer(voteRecord.getPlayerID());
+
+                player.sendMessage(ChatUtils.formatMessage("You have a reward waiting for you, use /vote reward to claim it!"));
+                break;
+
+            }
+
+        }
+
+    }
+
+    public ArrayList<Milestone> getMilestones() {
+
+        return milestones;
+
+    }
+
+    public void addMilestone(Milestone milestone) {
+
+        if (!milestones.contains(milestone)) {
+
+            milestones.add(milestone);
+
+        }
+
+    }
+
+    public ArrayList<Reward> getRewards() {
+
+        return rewards;
+
+    }
+
+    public void addReward(Reward reward) {
+
+        if (!rewards.contains(reward)) {
+
+            rewards.add(reward);
+
+        }
+
+    }
+
+    public ArrayList<String> getLinks() {
+
+        return links;
+
+    }
+
+    public void addLink(String link) {
+
+        if (!links.contains(link)) {
+
+            links.add(link);
+
+        }
+
+    }
+
+    @Override
+    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+
+        if (command.getName().equalsIgnoreCase("vote")) {
+
+            if (args.length == 0) {
+
+                if (sender.hasPermission("yarp.user.vote")) {
+
+                    sender.sendMessage(ChatUtils.formatMessage("Vote for us at the following links to earn rewards:"));
+
+                    Vote vote = new Vote();
+                    vote.setServiceName("Test.com");
+                    vote.setUsername("Olyol95");
+
+                    getServer().getPluginManager().callEvent(new VotifierEvent(vote));
+
+                } else {
+
+                    sender.sendMessage(ChatUtils.formatMessage("You do not have permission to do that!"));
+
+                }
+
+                return true;
+
+            } else {
+
+                if (args[0].equalsIgnoreCase("reward")) {
+
+                    if (sender.equals(getServer().getConsoleSender())) {
+
+                        sender.sendMessage(ChatUtils.formatMessage("Only players can use this command!"));
+
+                    } else if (sender.hasPermission("yarp.user.reward")) {
+
+                        Player player = (Player) sender;
+
+                        VoteRecord voteRecord = getVoteRecord(player.getUniqueId());
+
+                        if (voteRecord == null) {
+
+                            sender.sendMessage(ChatUtils.formatMessage("You have no rewards waiting for you at this time. Vote for the server to earn some!"));
+                            return true;
+
+                        }
+
+                        ArrayList<String> rewardMessages = new ArrayList<>();
+
+                        PlayerInventory playerInventory = player.getInventory();
+
+                        boolean isFull = true;
+
+                        for (ItemStack itemStack : playerInventory.getContents()) {
+
+                            if (itemStack == null || itemStack.getType() == Material.AIR) {
+
+                                isFull = false;
+                                break;
+
+                            }
+
+                        }
+
+                        for (Reward reward : getRewards()) {
+
+                            if (reward.isEarned(voteRecord)) {
+
+                                if (player.getGameMode() == GameMode.CREATIVE) {
+
+                                    player.sendMessage(ChatUtils.formatMessage("You have a reward waiting for you, however you are in creative mode!\nPlease change your game mode and try again."));
+                                    return true;
+
+                                }
+
+                                if (isFull) {
+
+                                    player.sendMessage(ChatUtils.formatMessage("You have a reward waiting for you, however your inventory is full!\nPlease free up a slot and try again."));
+                                    return true;
+
+                                }
+
+                                rewardMessages.add(reward.execute(voteRecord));
+
+                            }
+
+                        }
+
+                        if (rewardMessages.isEmpty()) {
+
+                            sender.sendMessage(ChatUtils.formatMessage("You have no rewards waiting for you at this time. Vote for the server to earn some!"));
+
+                        } else {
+
+                            broadcastRewardMessage(getServer().getPlayer(voteRecord.getPlayerID()).getName(), rewardMessages);
+
+                        }
+
+                    } else {
+
+                        sender.sendMessage(ChatUtils.formatMessage("You do not have permission to do that!"));
+
+                    }
+
+                    return true;
+
+                }
+
+            }
+
+        }
+
+        return false;
+
+    }
+
+}

+ 47 - 0
src/org/noip/olyol95/yarp/entities/Milestone.java

@@ -0,0 +1,47 @@
+package org.noip.olyol95.yarp.entities;
+
+import org.bukkit.ChatColor;
+
+/**
+ * Created by Ollie on 13/06/15.
+ */
+public class Milestone {
+
+    private ChatColor color;
+    private String message;
+    private int amount;
+    private boolean achieved;
+
+    public Milestone(ChatColor color, String message, int amount) {
+
+        this.color = color;
+        this.amount = amount;
+        this.message = message;
+
+    }
+
+    public String getMessage() {
+
+        return color+message;
+
+    }
+
+    public int getAmount() {
+
+        return amount;
+
+    }
+
+    public void setAchieved(boolean achieved) {
+
+        this.achieved = achieved;
+
+    }
+
+    public boolean isAchieved() {
+
+        return achieved;
+
+    }
+
+}

+ 73 - 0
src/org/noip/olyol95/yarp/entities/Reward.java

@@ -0,0 +1,73 @@
+package org.noip.olyol95.yarp.entities;
+
+import org.noip.olyol95.yarp.Yarp;
+
+/**
+ * Created by Ollie on 13/06/15.
+ */
+public class Reward {
+
+    private final String identifier;
+    private String command,description;
+    private int amount,requirement;
+    private boolean repeatable;
+
+    public Reward(String identifier, String command, String description, int requirement, boolean repeatable) {
+
+        this.identifier = identifier;
+        this.command = command;
+        this.description = description;
+        this.requirement = requirement;
+        this.repeatable = repeatable;
+
+        this.amount = 1;
+
+    }
+
+    public void setAmount(int amount) {
+
+        this.amount = amount;
+
+    }
+
+    public boolean isEarned(VoteRecord voteRecord) {
+
+        return (repeatable || voteRecord.getTimesAchieved(identifier) == 0) &&
+                ((voteRecord.getTotalVotes()/requirement) - voteRecord.getTimesAchieved(identifier)) > 0;
+
+    }
+
+    public String getIdentifier() {
+
+        return identifier;
+
+    }
+
+    public int getRequirement() {
+
+        return requirement;
+
+    }
+
+    public int getAmount() {
+
+        return amount;
+
+    }
+
+    public String execute(VoteRecord voteRecord) {
+
+        int amountEarned = ((voteRecord.getTotalVotes()/requirement) - voteRecord.getTimesAchieved(identifier))*amount;
+
+        String execution = command.replaceAll("\\{amount\\}",""+amountEarned);
+        execution = execution.replaceAll("\\{user\\}",Yarp.getInstance().getServer().getPlayer(voteRecord.getPlayerID()).getName());
+
+        Yarp.getInstance().getServer().dispatchCommand(Yarp.getInstance().getServer().getConsoleSender(), execution);
+
+        voteRecord.awardReward(identifier,amountEarned);
+
+        return description.replaceAll("\\{amount\\}",""+amountEarned);
+
+    }
+
+}

+ 90 - 0
src/org/noip/olyol95/yarp/entities/VoteRecord.java

@@ -0,0 +1,90 @@
+package org.noip.olyol95.yarp.entities;
+
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.UUID;
+
+/**
+ * Created by Ollie on 14/06/15.
+ */
+public class VoteRecord {
+
+    private final UUID playerID;
+    private int totalVotes;
+    private Hashtable<String,Integer> achievedRewards;
+
+    public VoteRecord(UUID playerID) {
+
+        this.playerID = playerID;
+
+        totalVotes = 0;
+        achievedRewards = new Hashtable<>();
+
+    }
+
+    public UUID getPlayerID() {
+
+        return playerID;
+
+    }
+
+    public int getTotalVotes() {
+
+        return totalVotes;
+
+    }
+
+    public void setTotalVotes(int totalVotes) {
+
+        this.totalVotes = totalVotes;
+
+    }
+
+    public Set<String> getAchievedRewards() {
+
+        return achievedRewards.keySet();
+
+    }
+
+    public int getTimesAchieved(String reward) {
+
+        if (getAchievedRewards().contains(reward)) {
+
+            return achievedRewards.get(reward);
+
+        } else {
+
+            return 0;
+
+        }
+
+    }
+
+    public void setAchievedReward(String reward, int timesAchieved) {
+
+        achievedRewards.put(reward, timesAchieved);
+
+    }
+
+    public void awardReward(String reward, int amountEarned) {
+
+        if (getAchievedRewards().contains(reward)) {
+
+            achievedRewards.put(reward, achievedRewards.get(reward)+amountEarned);
+
+        } else {
+
+            System.out.println("bananas");
+            achievedRewards.put(reward,amountEarned);
+
+        }
+
+    }
+
+    public void removeAchievedReward(String reward) {
+
+        achievedRewards.remove(reward);
+
+    }
+
+}

+ 107 - 0
src/org/noip/olyol95/yarp/listeners/VotingListener.java

@@ -0,0 +1,107 @@
+package org.noip.olyol95.yarp.listeners;
+
+import com.evilmidget38.UUIDFetcher;
+import org.bukkit.GameMode;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerGameModeChangeEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.noip.olyol95.yarp.Yarp;
+import org.noip.olyol95.yarp.entities.Milestone;
+import org.noip.olyol95.yarp.entities.Reward;
+import org.noip.olyol95.yarp.entities.VoteRecord;
+import org.noip.olyol95.yarp.util.ChatUtils;
+import org.noip.olyol95.yarp.util.FileHandler;
+
+import com.vexsoftware.votifier.model.Vote;
+import com.vexsoftware.votifier.model.VotifierEvent;
+
+import java.util.ArrayList;
+import java.util.logging.Level;
+
+public class VotingListener implements Listener {
+	
+	@EventHandler(priority = EventPriority.NORMAL)
+	public void onVotifierEvent(VotifierEvent event) {
+		
+		Vote vote = event.getVote();
+
+		VoteRecord voteRecord;
+
+		try {
+
+			voteRecord = Yarp.getInstance().getVoteRecord(vote.getUsername());
+
+		} catch (Exception e) {
+
+			Yarp.getInstance().getLogger().log(Level.WARNING,"Vote for invalid player: "+vote.getUsername()+" received at "+vote.getTimeStamp()+". Discarding vote.");
+			return;
+
+		}
+
+        if (voteRecord == null) {
+
+            try {
+
+                voteRecord = new VoteRecord(UUIDFetcher.getUUIDOf(vote.getUsername()));
+                Yarp.getInstance().addVoteRecord(voteRecord);
+
+            } catch (Exception e) {
+
+                Yarp.getInstance().getLogger().log(Level.WARNING,"Vote for invalid player: "+vote.getUsername()+" received at "+vote.getTimeStamp()+". Discarding vote.");
+                return;
+
+            }
+
+        }
+
+        voteRecord.setTotalVotes(voteRecord.getTotalVotes()+1);
+
+        Yarp.getInstance().broadcastVoteMessage(vote.getUsername(),vote.getServiceName());
+
+        Yarp.getInstance().checkForRewards(voteRecord);
+
+        for (Reward reward: Yarp.getInstance().getRewards()) {
+
+            System.out.println(reward.getIdentifier()+" "+reward.getAmount()+" "+reward.getRequirement());
+
+        }
+
+        for (Milestone milestone: Yarp.getInstance().getMilestones()) {
+
+            if (!milestone.isAchieved() && Yarp.getInstance().getTotalVotes() > milestone.getAmount()) {
+
+                Yarp.getInstance().getServer().broadcastMessage(ChatUtils.formatMessage(milestone.getMessage()));
+                milestone.setAchieved(true);
+
+            }
+
+        }
+		
+	}
+	
+	@EventHandler(priority = EventPriority.NORMAL)
+	public void onPlayerJoinEvent(PlayerJoinEvent event) {
+		
+		//todo load
+
+        VoteRecord voteRecord = Yarp.getInstance().getVoteRecord(event.getPlayer().getUniqueId());
+
+        if (voteRecord != null) {
+
+            Yarp.getInstance().checkForRewards(voteRecord);
+
+        }
+		
+	}
+
+    @EventHandler (priority = EventPriority.NORMAL)
+    public void onPlayerQuitEvent(PlayerQuitEvent event) {
+
+        //todo unload
+
+    }
+
+}

+ 28 - 0
src/org/noip/olyol95/yarp/util/ChatUtils.java

@@ -0,0 +1,28 @@
+package org.noip.olyol95.yarp.util;
+
+import org.bukkit.ChatColor;
+
+/**
+ * Created by Ollie on 13/06/15.
+ */
+public class ChatUtils {
+
+    public static ChatColor PREFIX_COLOUR,DEFAULT_COLOUR;
+    public static String PREFIX, PREFIX_PREFIX, PREFIX_SUFFIX;
+    public static boolean SHOW_PREFIX;
+
+    public static String formatMessage(String message) {
+
+        if (SHOW_PREFIX) {
+
+            return PREFIX_PREFIX + PREFIX_COLOUR + PREFIX + PREFIX_SUFFIX + DEFAULT_COLOUR + message;
+
+        } else {
+
+            return DEFAULT_COLOUR + message;
+
+        }
+
+    }
+
+}

+ 117 - 0
src/org/noip/olyol95/yarp/util/ConfigurationParser.java

@@ -0,0 +1,117 @@
+package org.noip.olyol95.yarp.util;
+
+import org.bukkit.ChatColor;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.noip.olyol95.yarp.Yarp;
+import org.noip.olyol95.yarp.entities.Milestone;
+import org.noip.olyol95.yarp.entities.Reward;
+import org.yaml.snakeyaml.error.YAMLException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+/**
+ * Created by Ollie on 13/06/15.
+ */
+public class ConfigurationParser {
+
+    private static FileConfiguration config;
+
+    public static boolean parse() {
+
+         config = Yarp.getInstance().getConfig();
+
+        try {
+
+            ChatUtils.DEFAULT_COLOUR = ChatColor.valueOf(config.getString("main_colour"));
+            ChatUtils.PREFIX_COLOUR = ChatColor.valueOf(config.getString("prefix.colour"));
+            ChatUtils.PREFIX = config.getString("prefix.text");
+            ChatUtils.PREFIX_PREFIX = config.getString("prefix.start");
+            ChatUtils.PREFIX_SUFFIX = config.getString("prefix.end");
+            ChatUtils.SHOW_PREFIX = config.getBoolean("show_prefix");
+
+            Yarp.BROADCAST_VOTES = config.getBoolean("broadcast_votes");
+            Yarp.BROADCAST_REWARDS = config.getBoolean("broadcast_rewards");
+
+            FileHandler.FILE_NAME = config.getString("save_file");
+
+            FileHandler.USE_DB = config.getBoolean("use_mysql");
+
+            if (FileHandler.USE_DB) {
+
+                FileHandler.TABLE_PREFIX = config.getString("table_prefix");
+                FileHandler.HOST = config.getString("mysql_host");
+                FileHandler.PORT = config.getString("mysql_port");
+                FileHandler.DATABASE = config.getString("mysql_database");
+                FileHandler.USERNAME = config.getString("mysql_username");
+                FileHandler.PASSWORD = config.getString("mysql_password");
+
+            }
+
+            for (String key: config.getConfigurationSection("milestones").getKeys(false)) {
+
+                Yarp.getInstance().addMilestone(buildMilestone(key));
+
+            }
+
+            for (String key: config.getConfigurationSection("rewards").getKeys(false)) {
+
+                System.out.println(key);
+                Yarp.getInstance().addReward(buildReward(key));
+
+            }
+
+            for (String link: config.getStringList("voting_links")) {
+
+                Yarp.getInstance().addLink(link);
+
+            }
+
+        } catch (Exception e) {
+
+            Yarp.getInstance().getLogger().log(Level.SEVERE,"Encountered an exception " +
+                    "whilst parsing configuration:\n"+e.getMessage());
+
+            return false;
+
+        }
+
+        return true;
+
+    }
+
+    private static Milestone buildMilestone(String key) {
+
+        return new Milestone(
+                ChatColor.valueOf(config.getString("milestones."+key+".colour")),
+                config.getString("milestones."+key+".message"),
+                config.getInt("milestones."+key+".amount")
+        );
+
+    }
+
+    private static Reward buildReward(String key) {
+
+        Reward reward = new Reward(key,
+                config.getString("rewards."+key+".command"),
+                config.getString("rewards."+key+".description"),
+                config.getInt("rewards."+key+".votes_required"),
+                config.getBoolean("rewards."+key+".repeatable")
+        );
+
+        try {
+
+            reward.setAmount(config.getInt("rewards." + key + ".amount_per_reward"));
+
+        } catch (YAMLException e) {
+
+            //swallow - this is an optional item
+
+        }
+
+        return reward;
+
+    }
+
+}

+ 19 - 0
src/org/noip/olyol95/yarp/util/FileHandler.java

@@ -0,0 +1,19 @@
+package org.noip.olyol95.yarp.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Hashtable;
+
+import org.noip.olyol95.yarp.Yarp;
+
+public class FileHandler {
+
+	public static String FILE_NAME, TABLE_PREFIX, HOST, PORT, DATABASE, USERNAME, PASSWORD;
+    public static boolean USE_DB;
+
+}