Skip to content

Commit

Permalink
Automated code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 28, 2015
1 parent 5777481 commit 4fedf3f
Show file tree
Hide file tree
Showing 73 changed files with 1,253 additions and 972 deletions.
7 changes: 4 additions & 3 deletions src/main/java/net/aufdemrand/denizencore/DenizenCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.aufdemrand.denizencore.events.OldEventManager;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.events.core.ReloadScriptsScriptEvent;
import net.aufdemrand.denizencore.scripts.ScriptHelper;
import net.aufdemrand.denizencore.scripts.commands.CommandRegistry;
import net.aufdemrand.denizencore.scripts.queues.ScriptEngine;
Expand Down Expand Up @@ -50,7 +49,8 @@ public static ScriptEngine getScriptEngine() {
version = properties.getProperty("version") + " (Build " + properties.getProperty("build") + ")";
is.close();
}
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
VERSION = version;
Expand All @@ -64,6 +64,7 @@ public static DenizenImplementation getImplementation() {

/**
* Must be called first: prepares the engine!
*
* @param implementation your Denizen implementation.
*/
public static void init(DenizenImplementation implementation) {
Expand Down Expand Up @@ -126,7 +127,7 @@ public static void schedule(Schedulable sched) {
*/
public static void tick(int ms_elapsed) {
for (int i = 0; i < scheduled.size(); i++) {
if (!scheduled.get(i).tick((float)ms_elapsed / 1000)) {
if (!scheduled.get(i).tick((float) ms_elapsed / 1000)) {
scheduled.remove(i--);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.aufdemrand.denizencore;

import net.aufdemrand.denizencore.objects.Duration;
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
import net.aufdemrand.denizencore.scripts.containers.core.WorldScriptContainer;
import net.aufdemrand.denizencore.scripts.queues.ScriptQueue;
import net.aufdemrand.denizencore.scripts.queues.core.InstantQueue;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import net.aufdemrand.denizencore.utilities.YamlConfiguration;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import net.aufdemrand.denizencore.utilities.debugging.dB.DebugElement;
import net.aufdemrand.denizencore.utilities.text.StringHolder;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -234,7 +231,7 @@ public static List<String> doEvents(List<String> eventNames, ScriptEntryData dat

// Check the determination
if (DetermineCommand.hasOutcome(id))
determinations = DetermineCommand.getOutcome(id);
determinations = DetermineCommand.getOutcome(id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* To make the world event system as easy as possible, firing an event is as easy as calling the
* EventHandler's doEvents(...) from anywhere in your code that's appropriate. However, should
* you choose to implement SmartEvent, you'll make your event more efficient and manageable.
*
* <p/>
* SmartEvents must be registered with the EventManager
*
*/
public interface OldSmartEvent {

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/net/aufdemrand/denizencore/events/ScriptEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ScriptPath(ScriptContainer container, String event) {

public static void reload() {
dB.log("Reloading script events...");
for (ScriptContainer container: worldContainers) {
for (ScriptContainer container : worldContainers) {
YamlConfiguration config = container.getConfigurationSection("events");
if (config == null) {
dB.echoError("Missing or invalid events block for " + container.getName());
Expand All @@ -68,11 +68,11 @@ else if (evt.str.contains("@")) {
}
}
}
for (ScriptEvent event: events) {
for (ScriptEvent event : events) {
event.destroy();
event.eventPaths.clear();
boolean matched = false;
for (ScriptContainer container: worldContainers) {
for (ScriptContainer container : worldContainers) {
YamlConfiguration config = container.getConfigurationSection("events");
if (config == null) {
dB.echoError("Missing or invalid events block for " + container.getName());
Expand Down Expand Up @@ -142,15 +142,15 @@ public static boolean couldMatchScript(ScriptEvent sEvent, ScriptContainer scrip
// The default priority is 0.
// -->
public void sort() {
for (ScriptPath path: eventPaths) {
for (ScriptPath path : eventPaths) {
String gotten = getSwitch(path.event, "priority");
path.priority = gotten == null ? 0: aH.getIntegerFrom(gotten);
path.priority = gotten == null ? 0 : aH.getIntegerFrom(gotten);
}
Collections.sort(eventPaths, new Comparator<ScriptPath>() {
@Override
public int compare(ScriptPath scriptPath, ScriptPath t1) {
int rel = scriptPath.priority - t1.priority;
return rel < 0 ? -1: (rel > 0 ? 1: 0);
return rel < 0 ? -1 : (rel > 0 ? 1 : 0);
}
});
}
Expand All @@ -162,10 +162,10 @@ public void destroy() {
}

public boolean checkSwitch(String event, String switcher, String value) {
for (String possible: CoreUtilities.split(event, ' ')) {
for (String possible : CoreUtilities.split(event, ' ')) {
List<String> split = CoreUtilities.split(possible, ':', 2);
if (dB.verbose) dB.log("TEST: " + split.size() + ", " + split.get(0) + " && "
+ (split.size() > 1 ? split.get(1): "") + " comp " + switcher + ":" + value);
+ (split.size() > 1 ? split.get(1) : "") + " comp " + switcher + ":" + value);
if (split.get(0).equalsIgnoreCase(switcher) && split.size() > 1 && !split.get(1).equalsIgnoreCase(value)) {
return false;
}
Expand All @@ -174,7 +174,7 @@ public boolean checkSwitch(String event, String switcher, String value) {
}

public String getSwitch(String event, String switcher) {
for (String possible: CoreUtilities.split(event, ' ')) {
for (String possible : CoreUtilities.split(event, ' ')) {
List<String> split = CoreUtilities.split(possible, ':', 2);
if (split.get(0).equalsIgnoreCase(switcher) && split.size() > 1) {
return split.get(1);
Expand Down Expand Up @@ -221,9 +221,9 @@ public void reset() {

public void fire() {
fires++;
for (ScriptPath path: eventPaths) {
for (ScriptPath path : eventPaths) {
try {
if (matchesScript(this, path.container, path.event)) {
if (matchesScript(this, path.container, path.event)) {
run(path.container, path.event);
}
}
Expand All @@ -239,7 +239,7 @@ public void run(ScriptContainer script, String event) {
HashMap<String, dObject> context = getContext();
dB.echoDebug(script, "<Y>Running script event '<A>" + getName() + "<Y>', event='<A>" + event + "<Y>'"
+ " for script '<A>" + script.getName() + "<Y>'");
for (Map.Entry<String, dObject> obj: context.entrySet()) {
for (Map.Entry<String, dObject> obj : context.entrySet()) {
dB.echoDebug(script, "<Y>Context '<A>" + obj.getKey() + "<Y>' = '<A>" + obj.getValue().identify() + "<Y>'");
}
List<ScriptEntry> entries = script.getEntries(getScriptEntryData(), "events.on " + event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public boolean couldMatch(ScriptContainer script, String event) {

@Override
public boolean matches(ScriptContainer script, String event) {
return checkSwitch(event, "haderror", hadError ? "true": "false")
&& checkSwitch(event, "sender", sender.equalsIgnoreCase("console") ? "server": "player")
&& checkSwitch(event, "all", all ? "true": "false");
return checkSwitch(event, "haderror", hadError ? "true" : "false")
&& checkSwitch(event, "sender", sender.equalsIgnoreCase("console") ? "server" : "player")
&& checkSwitch(event, "all", all ? "true" : "false");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Container interface for instances loaded into a dRegistry.
*
* @author Jeremy Schroeder
*
*/

public interface RegistrationableInstance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ public interface dExternal {

/**
* Called by the RuntimeCompiler after an 'External Dependency' is compiled and loaded.
*
*/
public void load();

/**
* Called by Denizen when the server stops or '/denizen reload externals' is executed.
*
*/
public void unload();
}
22 changes: 4 additions & 18 deletions src/main/java/net/aufdemrand/denizencore/interfaces/dRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@
* including Commands, Requirements, and Activities.
*
* @author Jeremy Schroeder
*
*/

public interface dRegistry {

/**
* Called by an AbstractInstance to get added to the registry.
*
* @param registrationName
* The name to use in the registry
* @param commandInstance
* A cast (AbstractInstance) of the instance being registered. Usually '(AbstractInstance) this'.
*
* @param registrationName The name to use in the registry
* @param commandInstance A cast (AbstractInstance) of the instance being registered. Usually '(AbstractInstance) this'.
* @return false if an exception has been thrown.
*
*/
public boolean register(String registrationName, RegistrationableInstance commandInstance);

Expand All @@ -30,45 +25,36 @@ public interface dRegistry {
* Returns a Map of the instances added by the register() method keyed by the registration name.
*
* @return the entire registry.
*
*/
public Map<String, ? extends RegistrationableInstance> list();


/**
* Gets a specific instance of AbstractInstance that has been previously registered.
*
* @param clazz
* class of the requested AbstractInstance.
*
* @param clazz class of the requested AbstractInstance.
* @return the instance of the class specified.
*
*/
public <T extends RegistrationableInstance> T get(Class<T> clazz);


/**
* Gets a specific instance of AbstractInstance that has been previously registered.
*
* @param instanceKey
* string key in which the AbstractInstance was registered with.
*
* @param instanceKey string key in which the AbstractInstance was registered with.
* @return the instance of the key specified.
*
*/
public RegistrationableInstance get(String instanceKey);


/**
* Generic method for registering the core classes of this registry's type
*
*/
public void registerCoreMembers();


/**
* Calls an onDisable method on all registered instances.
*
*/
public void disableCoreMembers();
}
13 changes: 8 additions & 5 deletions src/main/java/net/aufdemrand/denizencore/license.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"><title>License</title>
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title>License</title>

</head>
<body>
Expand All @@ -14,6 +16,7 @@
This program is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br>
See the <a href="http://opensource.org/licenses/lgpl-3.0.html">GNU Lesser General
Public License</a> for more details.<br>
</body></html>
See the <a href="http://opensource.org/licenses/lgpl-3.0.html">GNU Lesser General
Public License</a> for more details.<br>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.aufdemrand.denizencore.objects;

import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.aufdemrand.denizencore.scripts.commands.core.DetermineCommand;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
Expand Down Expand Up @@ -70,10 +69,10 @@ public String getObjectType() {
@Override
public String identify() {
StringBuilder outp = new StringBuilder();
for (Map.Entry<String, String> var: vars.entrySet()) {
outp.append(var.getKey() + "=" + var.getValue().replace(';', (char)0x2011) + ";");
for (Map.Entry<String, String> var : vars.entrySet()) {
outp.append(var.getKey() + "=" + var.getValue().replace(';', (char) 0x2011) + ";");
}
return "custom@" + container.getName() + "[" + (outp.length() > 0 ? outp.substring(0, outp.length() - 1): "") + "]";
return "custom@" + container.getName() + "[" + (outp.length() > 0 ? outp.substring(0, outp.length() - 1) : "") + "]";
}

@Override
Expand Down
Loading

0 comments on commit 4fedf3f

Please sign in to comment.