diff --git "a/test.csv" "b/test.csv"
--- "a/test.csv"
+++ "b/test.csv"
@@ -1,67642 +1,45195 @@
commit_id,project,commit_message,type,url,git_diff
-4f8fa5ff72b1ae2ef4a5c2e4be4f9c8f749da9bb,Delta Spike,"DELTASPIKE-315 add more JavaDoc
-",p,https://github.com/apache/deltaspike,"diff --git a/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java b/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
-index 45e94581f..5d16153c6 100644
---- a/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
-+++ b/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
-@@ -35,7 +35,7 @@
- * EntityManagerFactoryProducer.
- */
- @Target( { TYPE, METHOD, PARAMETER, FIELD })
--@Retention(value= RetentionPolicy.RUNTIME)
-+@Retention(value = RetentionPolicy.RUNTIME)
- @Documented
- @Qualifier
- public @interface PersistenceUnitName
-diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
-index 05129f3a5..002e28cb8 100644
---- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
-+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
-@@ -32,7 +32,32 @@
+84ff885f72d1ec8228407b6cdc9c09d342b5a0dc,kotlin,Constructor body generation extracted as a method- (+ migrated to Printer for convenience)--,p,https://github.com/JetBrains/kotlin,"diff --git a/injector-generator/src/org/jetbrains/jet/di/DependencyInjectorGenerator.java b/injector-generator/src/org/jetbrains/jet/di/DependencyInjectorGenerator.java
+index 6fc139585610e..a0af388cecfbc 100644
+--- a/injector-generator/src/org/jetbrains/jet/di/DependencyInjectorGenerator.java
++++ b/injector-generator/src/org/jetbrains/jet/di/DependencyInjectorGenerator.java
+@@ -16,15 +16,13 @@
+ package org.jetbrains.jet.di;
- /**
-- * TODO
-+ *
Built in support for injecting EntityManagerFactories into own beans.
-+ * The injection point must use the Qualifier {@link PersistenceUnitName}
-+ * to express the desired persistence unit name.
-+ *
-+ * The EntityManagerFactory for the given persistence unit will be produced
-+ * as @Dependent scoped. It can be used to easily implement own
-+ * EntityManagerProviders as shown in the following example which provides
-+ * a producer according to the entitymanager-per-request design pattern:
-+ *
-+ * @ApplicationScoped
-+ * public class SampleEntityManagerProducer {
-+ * @Inject
-+ * @PersistenceUnitName(""testPersistenceUnit"")
-+ * private EntityManagerFactory emf;
-+ *
-+ * @Produces
-+ * @RequestScoped
-+ * public EntityManager createEntityManager() {
-+ * return emf.createEntityManager();
-+ * }
-+ *
-+ * public void closeEm(@Disposes EntityManager em) {
-+ * em.close();
-+ * }
-+ * }
-+ *
- */
- public class EntityManagerFactoryProducer
- {
-@@ -44,7 +69,7 @@ public class EntityManagerFactoryProducer
+-import com.google.common.collect.HashMultimap;
+-import com.google.common.collect.Lists;
+-import com.google.common.collect.Multimap;
+-import com.google.common.collect.Sets;
++import com.google.common.collect.*;
+ import com.intellij.openapi.util.SystemInfo;
+ import com.intellij.openapi.util.io.FileUtil;
+ import com.intellij.openapi.util.text.StringUtil;
+ import org.jetbrains.annotations.NotNull;
+ import org.jetbrains.annotations.Nullable;
++import org.jetbrains.jet.utils.Printer;
- @Produces
- @Dependent
-- @PersistenceUnitName(""any"") // the value is nonbinding, thus this is just a dummy parameter here
-+ @PersistenceUnitName(""any"") // the value is nonbinding, thus 'any' is just a dummy parameter here
- public EntityManagerFactory createEntityManagerFactoryForUnit(InjectionPoint injectionPoint)
- {
- PersistenceUnitName unitNameAnnotation = injectionPoint.getAnnotated().getAnnotation(PersistenceUnitName.class);"
-53c2131d4411fac6fbe43fc757bc6acea780e2a1,crashub$crash,"Add flexibility for plugin a custom class manager
-",p,https://github.com/crashub/crash,"diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java b/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java
-new file mode 100644
-index 000000000..f9a8180ba
---- /dev/null
-+++ b/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java
-@@ -0,0 +1,143 @@
-+/*
-+ * Copyright (C) 2012 eXo Platform SAS.
-+ *
-+ * This is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU Lesser General Public License as
-+ * published by the Free Software Foundation; either version 2.1 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This software 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. See the GNU
-+ * Lesser General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU Lesser General Public
-+ * License along with this software; if not, write to the Free
-+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-+ */
+ import javax.annotation.PostConstruct;
+ import javax.annotation.PreDestroy;
+@@ -281,70 +279,80 @@ private static DiType getEffectiveFieldType(Field field) {
+ }
+
+ private void generateConstructor(String injectorClassName, PrintStream out) {
+- String indent = "" "";
++ Printer p = new Printer(out);
++ p.pushIndent();
+
+ // Constructor parameters
+ if (parameters.isEmpty()) {
+- out.println("" public "" + injectorClassName + ""() {"");
++ p.println(""public "", injectorClassName, ""() {"");
+ }
+ else {
+- out.println("" public "" + injectorClassName + ""("");
++ p.println(""public "", injectorClassName, ""("");
++ p.pushIndent();
+ for (Iterator iterator = parameters.iterator(); iterator.hasNext(); ) {
+ Parameter parameter = iterator.next();
+- out.print(indent);
++ p.print(); // indent
+ if (parameter.isRequired()) {
+- out.print(""@NotNull "");
++ p.printWithNoIndent(""@NotNull "");
+ }
+- out.print(parameter.getType().getSimpleName() + "" "" + parameter.getName());
++ p.printWithNoIndent(parameter.getType().getSimpleName(), "" "", parameter.getName());
+ if (iterator.hasNext()) {
+- out.println("","");
++ p.printlnWithNoIndent("","");
+ }
+ }
+- out.println();
+- out.println("" ) {"");
++ p.printlnWithNoIndent();
++ p.popIndent();
++ p.println("") {"");
+ }
+
++ p.pushIndent();
+ if (lazy) {
+ // Remember parameters
+ for (Parameter parameter : parameters) {
+- out.println(indent + ""this."" + parameter.getField().getName() + "" = "" + parameter.getName() + "";"");
++ p.println(""this."", parameter.getField().getName(), "" = "", parameter.getName(), "";"");
+ }
+ }
+ else {
+- // Initialize fields
+- for (Field field : fields) {
+- //if (!backsParameter.contains(field) || field.isPublic()) {
+- String prefix = ""this."";
+- out.println(indent + prefix + field.getName() + "" = "" + field.getInitialization().renderAsCode() + "";"");
+- //}
+- }
+- out.println();
++ generateInitializingCode(p, fields);
++ }
+
+- // Call setters
+- for (Field field : fields) {
+- for (SetterDependency dependency : field.getDependencies()) {
+- String prefix = field.isPublic() ? ""this."" : """";
+- out.println(indent + prefix + dependency.getDependent().getName() + ""."" + dependency.getSetterName() + ""("" + dependency.getDependency().getName() + "");"");
+- }
+- if (!field.getDependencies().isEmpty()) {
+- out.println();
+- }
+- }
++ p.popIndent();
++ p.println(""}"");
++ }
+
+- // call @PostConstruct
+- for (Field field : fields) {
+- // TODO: type of field may be different from type of object
+- List postConstructMethods = getPostConstructMethods(getEffectiveFieldType(field).getClazz());
+- for (Method postConstruct : postConstructMethods) {
+- out.println(indent + field.getName() + ""."" + postConstruct.getName() + ""();"");
+- }
+- if (postConstructMethods.size() > 0) {
+- out.println();
+- }
++ private static void generateInitializingCode(@NotNull Printer p, @NotNull Collection fields) {
++ // Initialize fields
++ for (Field field : fields) {
++ //if (!backsParameter.contains(field) || field.isPublic()) {
++ p.println(""this."", field.getName(), "" = "", field.getInitialization().renderAsCode(), "";"");
++ //}
++ }
++ p.printlnWithNoIndent();
++
++ // Call setters
++ for (Field field : fields) {
++ for (SetterDependency dependency : field.getDependencies()) {
++ String prefix = field.isPublic() ? ""this."" : """";
++ String dependencyName = dependency.getDependency().getName();
++ String dependentName = dependency.getDependent().getName();
++ p.println(prefix, dependentName, ""."", dependency.getSetterName(), ""("", dependencyName, "");"");
++ }
++ if (!field.getDependencies().isEmpty()) {
++ p.printlnWithNoIndent();
+ }
+ }
+
+- out.println("" }"");
++ // call @PostConstruct
++ for (Field field : fields) {
++ // TODO: type of field may be different from type of object
++ List postConstructMethods = getPostConstructMethods(getEffectiveFieldType(field).getClazz());
++ for (Method postConstruct : postConstructMethods) {
++ p.println(field.getName(), ""."", postConstruct.getName(), ""();"");
++ }
++ if (postConstructMethods.size() > 0) {
++ p.printlnWithNoIndent();
++ }
++ }
+ }
+
+ private static List getPostConstructMethods(Class> clazz) {"
+e0e1bdf57aa4f1dae1de5b7a51b58fad1fd4696b,brandonborkholder$glg2d,Abstracted some of the init/tear-down functionality to make it easier to customize.,p,https://github.com/brandonborkholder/glg2d,"diff --git a/src/main/java/glg2d/G2DGLCanvas.java b/src/main/java/glg2d/G2DGLCanvas.java
+index 33a0d734..db9405a2 100644
+--- a/src/main/java/glg2d/G2DGLCanvas.java
++++ b/src/main/java/glg2d/G2DGLCanvas.java
+@@ -107,7 +107,7 @@ public boolean isGLDrawing() {
+ /**
+ * Sets the drawing path, {@code true} for OpenGL, {@code false} for normal
+ * Java2D.
+- *
++ *
+ * @see #isGLDrawing()
+ */
+ public void setGLDrawing(boolean drawGL) {
+@@ -131,12 +131,20 @@ public void setDrawableComponent(JComponent component) {
+
+ drawableComponent = component;
+ if (drawableComponent != null) {
+- g2dglListener = new G2DGLEventListener(drawableComponent);
++ g2dglListener = createG2DListener(drawableComponent);
+ canvas.addGLEventListener(g2dglListener);
+ add(drawableComponent);
+ }
+ }
+
++ /**
++ * Creates the GLEventListener that will draw the given component to the
++ * canvas.
++ */
++ protected GLEventListener createG2DListener(JComponent drawingComponent) {
++ return new G2DGLEventListener(drawingComponent);
++ }
++
+ public JComponent getDrawableComponent() {
+ return drawableComponent;
+ }
+diff --git a/src/main/java/glg2d/G2DGLEventListener.java b/src/main/java/glg2d/G2DGLEventListener.java
+index bcb48139..c5e0c74f 100644
+--- a/src/main/java/glg2d/G2DGLEventListener.java
++++ b/src/main/java/glg2d/G2DGLEventListener.java
+@@ -18,7 +18,9 @@
+
+ import java.awt.Component;
+
++import javax.media.opengl.GL;
+ import javax.media.opengl.GLAutoDrawable;
++import javax.media.opengl.GLContext;
+ import javax.media.opengl.GLEventListener;
+ import javax.swing.RepaintManager;
+
+@@ -36,7 +38,7 @@ public class G2DGLEventListener implements GLEventListener {
+ * {@code baseComponent} is used to provide default font, backgroundColor,
+ * etc. to the {@code GLGraphics2D} object. It is also used for width, height
+ * of the viewport in OpenGL.
+- *
++ *
+ * @param baseComponent
+ * The component to use for default settings.
+ */
+@@ -47,9 +49,73 @@ public G2DGLEventListener(Component baseComponent) {
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ g2d.setCanvas(drawable);
+- g2d.prePaint(baseComponent);
++ prePaint(drawable.getContext());
+ paintGL(g2d);
++ postPaint(drawable.getContext());
++ }
+
-+package org.crsh.shell.impl.command;
++ /**
++ * Called after the canvas is set on {@code g2d} but before any painting is
++ * done. This should setup the matrices and ask {@code g2d} to setup any
++ * client state.
++ */
++ protected void prePaint(GLContext context) {
++ setupMatrices(context);
++ g2d.prePaint(baseComponent);
++ }
+
-+import groovy.lang.GroovyClassLoader;
-+import groovy.lang.GroovyCodeSource;
-+import groovy.lang.Script;
-+import org.codehaus.groovy.control.CompilationFailedException;
-+import org.codehaus.groovy.control.CompilerConfiguration;
-+import org.crsh.command.CommandInvoker;
-+import org.crsh.command.NoSuchCommandException;
-+import org.crsh.plugin.PluginContext;
-+import org.crsh.shell.ErrorType;
-+import org.crsh.util.TimestampedObject;
-+import org.crsh.vfs.Resource;
++ /**
++ * Sets up the three matrices, including the transform from OpenGL coordinate
++ * system to Java2D coordinates.
++ */
++ protected void setupMatrices(GLContext context) {
++ GL gl = context.getGL();
+
-+import java.io.UnsupportedEncodingException;
++ // push all the matrices
++ gl.glMatrixMode(GL.GL_PROJECTION);
++ gl.glPushMatrix();
+
-+public abstract class AbstractClassManager {
++ int width = baseComponent.getWidth();
++ int height = baseComponent.getHeight();
+
-+ /** . */
-+ private final PluginContext context;
++ // and setup the viewport
++ gl.glViewport(0, 0, width, height);
++ gl.glLoadIdentity();
++ gl.glOrtho(0, width, 0, height, -1, 1);
+
-+ /** . */
-+ private final CompilerConfiguration config;
++ gl.glMatrixMode(GL.GL_MODELVIEW);
++ gl.glPushMatrix();
++ gl.glLoadIdentity();
+
-+ /** . */
-+ private final Class baseClass;
++ // do the transform from Graphics2D coords to openGL coords
++ gl.glTranslatef(0, height, 0);
++ gl.glScalef(1, -1, 1);
+
-+ protected AbstractClassManager(PluginContext context, Class baseClass, Class extends Script> baseScriptClass) {
-+ CompilerConfiguration config = new CompilerConfiguration();
-+ config.setRecompileGroovySource(true);
-+ config.setScriptBaseClass(baseScriptClass.getName());
++ gl.glMatrixMode(GL.GL_TEXTURE);
++ gl.glPushMatrix();
++ gl.glLoadIdentity();
++ }
+
-+ //
-+ this.context = context;
-+ this.config = config;
-+ this.baseClass = baseClass;
++ /**
++ * Called after all Java2D painting is complete. This should restore the
++ * matrices if they were modified.
++ */
++ protected void postPaint(GLContext context) {
+ g2d.postPaint();
++ popMatrices(context);
+ }
-+
-+ protected abstract TimestampedObject> loadClass(String name);
+
-+ protected abstract void saveClass(String name, TimestampedObject> clazz);
++ /**
++ * Pops all the matrices.
++ */
++ protected void popMatrices(GLContext context) {
++ GL gl = context.getGL();
++ gl.glMatrixMode(GL.GL_MODELVIEW);
++ gl.glPopMatrix();
++ gl.glMatrixMode(GL.GL_PROJECTION);
++ gl.glPopMatrix();
++ gl.glMatrixMode(GL.GL_TEXTURE);
++ gl.glPopMatrix();
+ }
+
+ /**
+diff --git a/src/main/java/glg2d/GLGraphics2D.java b/src/main/java/glg2d/GLGraphics2D.java
+index 324c3ed3..f3d4e437 100644
+--- a/src/main/java/glg2d/GLGraphics2D.java
++++ b/src/main/java/glg2d/GLGraphics2D.java
+@@ -131,37 +131,9 @@ protected void prePaint(Component component) {
+ gl.glDisable(GL.GL_CULL_FACE);
+ gl.glShadeModel(GL.GL_FLAT);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+-
+- // push all the matrices
+- gl.glMatrixMode(GL.GL_PROJECTION);
+- gl.glPushMatrix();
+-
+- // and setup the viewport
+- gl.glViewport(0, 0, width, height);
+- gl.glLoadIdentity();
+- gl.glOrtho(0, width, 0, height, -1, 1);
+-
+- gl.glMatrixMode(GL.GL_MODELVIEW);
+- gl.glPushMatrix();
+- gl.glLoadIdentity();
+-
+- // do the transform from Graphics2D coords to openGL coords
+- gl.glTranslatef(0, height, 0);
+- gl.glScalef(1, -1, 1);
+-
+- gl.glMatrixMode(GL.GL_TEXTURE);
+- gl.glPushMatrix();
+- gl.glLoadIdentity();
+ }
+
+ protected void postPaint() {
+- gl.glMatrixMode(GL.GL_MODELVIEW);
+- gl.glPopMatrix();
+- gl.glMatrixMode(GL.GL_PROJECTION);
+- gl.glPopMatrix();
+- gl.glMatrixMode(GL.GL_TEXTURE);
+- gl.glPopMatrix();
+-
+ gl.glPopClientAttrib();
+ gl.glPopAttrib();
+ gl.glFlush();"
+4cc637f7b8b94f0cd1a97a6b618e333e7ef4d525,mctcp$terraincontrol,"Refactor CustomObjects and Resources
+There are now CustomObjects, and all BO2 are a CustomObject. UseWorld
+and UseBiome are also CustomObjects. Even all trees are now a
+CustomObject.
+All resources now inherit Resource. All settings don't have to be stored
+in a generic Resource object, but they are stored in the resource
+itself. This allow for more flexibility.
+Plugin developers can now add their own CustomObjects and Resources.
+",p,https://github.com/mctcp/terraincontrol,"diff --git a/bukkit/src/com/khorn/terraincontrol/bukkit/TCListener.java b/bukkit/src/com/khorn/terraincontrol/bukkit/TCListener.java
+index bbc001aae..9e5d29205 100644
+--- a/bukkit/src/com/khorn/terraincontrol/bukkit/TCListener.java
++++ b/bukkit/src/com/khorn/terraincontrol/bukkit/TCListener.java
+@@ -12,20 +12,15 @@
+ import org.bukkit.event.world.WorldInitEvent;
+
+ import com.khorn.terraincontrol.configuration.BiomeConfig;
+-import com.khorn.terraincontrol.configuration.Resource;
+-import com.khorn.terraincontrol.generator.resourcegens.TreeGen;
++import com.khorn.terraincontrol.generator.resourcegens.SaplingGen;
+
+ public class TCListener implements Listener
+ {
+ private TCPlugin tcPlugin;
+- private Random random;
+-
+- private TreeGen treeGenerator = new TreeGen();
+
+ public TCListener(TCPlugin plugin)
+ {
+ this.tcPlugin = plugin;
+- this.random = new Random();
+ Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+@@ -51,7 +46,7 @@ public void onStructureGrow(StructureGrowEvent event)
+ return;
+
+ BiomeConfig biomeConfig = bukkitWorld.getSettings().biomeConfigs[biomeId];
+- Resource sapling;
++ SaplingGen sapling;
+
+ switch (event.getSpecies())
+ {
+@@ -76,8 +71,25 @@ public void onStructureGrow(StructureGrowEvent event)
+
+ if (sapling != null)
+ {
+- treeGenerator.SpawnTree(bukkitWorld, this.random, sapling, x, y, z);
+- event.getBlocks().clear();
++ boolean success = false;
++ for(int i = 0; i < bukkitWorld.getSettings().objectSpawnRatio; i++)
++ {
++ if(sapling.growSapling(bukkitWorld, new Random(), x, y, z))
++ {
++ success = true;
++ break;
++ }
++ }
++
++ if(success)
++ {
++ // Just spawned the tree, clear the blocks list to prevent Bukkit spawning another tree
++ event.getBlocks().clear();
++ } else
++ {
++ // Cannot grow, so leave the sapling there
++ event.setCancelled(true);
++ }
+ }
+ }
+
+diff --git a/bukkit/src/com/khorn/terraincontrol/bukkit/TCPlugin.java b/bukkit/src/com/khorn/terraincontrol/bukkit/TCPlugin.java
+index 030e4dfb0..e309e4e64 100644
+--- a/bukkit/src/com/khorn/terraincontrol/bukkit/TCPlugin.java
++++ b/bukkit/src/com/khorn/terraincontrol/bukkit/TCPlugin.java
+@@ -6,7 +6,7 @@
+ import com.khorn.terraincontrol.bukkit.commands.TCCommandExecutor;
+ import com.khorn.terraincontrol.configuration.TCDefaultValues;
+ import com.khorn.terraincontrol.configuration.WorldConfig;
+-import com.khorn.terraincontrol.customobjects.ObjectsStore;
++import com.khorn.terraincontrol.customobjects.BODefaultValues;
+ import com.khorn.terraincontrol.util.Txt;
+ import net.minecraft.server.BiomeBase;
+ import org.bukkit.Bukkit;
+@@ -50,8 +50,6 @@ public void onEnable()
+
+ this.listener = new TCListener(this);
+
+- ObjectsStore.ReadObjects(this.getDataFolder());
+-
+ Bukkit.getMessenger().registerOutgoingPluginChannel(this, TCDefaultValues.ChannelName.stringValue());
+
+ TerrainControl.log(""Enabled"");
+@@ -185,4 +183,10 @@ public LocalWorld getWorld(String name)
+ }
+ return this.worlds.get(world.getUID());
+ }
++
++ @Override
++ public File getGlobalObjectsDirectory()
++ {
++ return new File(this.getDataFolder(), BODefaultValues.BO_GlobalDirectoryName.stringValue());
++ }
+ }
+\ No newline at end of file
+diff --git a/bukkit/src/com/khorn/terraincontrol/bukkit/commands/ListCommand.java b/bukkit/src/com/khorn/terraincontrol/bukkit/commands/ListCommand.java
+index c8efffcff..bce1ac038 100644
+--- a/bukkit/src/com/khorn/terraincontrol/bukkit/commands/ListCommand.java
++++ b/bukkit/src/com/khorn/terraincontrol/bukkit/commands/ListCommand.java
+@@ -1,93 +1,91 @@
+-package com.khorn.terraincontrol.bukkit.commands;
+-
+-import com.khorn.terraincontrol.bukkit.BukkitWorld;
+-import com.khorn.terraincontrol.bukkit.TCPerm;
+-import com.khorn.terraincontrol.bukkit.TCPlugin;
+-import com.khorn.terraincontrol.customobjects.CustomObject;
+-import com.khorn.terraincontrol.customobjects.CustomObjectCompiled;
+-import com.khorn.terraincontrol.customobjects.ObjectsStore;
+-import org.bukkit.command.CommandSender;
+-
+-import java.util.ArrayList;
+-import java.util.List;
+-
+-public class ListCommand extends BaseCommand
+-{
+- public ListCommand(TCPlugin _plugin)
+- {
+- super(_plugin);
+- name = ""list"";
+- perm = TCPerm.CMD_LIST.node;
+- usage = ""list [-w World] [page]"";
+- workOnConsole = false;
+- }
+-
+- @Override
+- public boolean onCommand(CommandSender sender, List args)
+- {
+-
+- int page = 1;
+-
+- if (args.size() > 1 && args.get(0).equals(""-w""))
+- {
+- String worldName = args.get(1);
+- if (args.size() > 2)
+- {
+- try
+- {
+- page = Integer.parseInt(args.get(2));
+- } catch (Exception e)
+- {
+- sender.sendMessage(ErrorColor + ""Wrong page number "" + args.get(2));
+- }
+- }
+- BukkitWorld world = this.getWorld(sender, worldName);
+-
+- if (world != null)
+- {
+- if (world.getSettings().CustomObjectsCompiled.size() == 0)
+- sender.sendMessage(MessageColor + ""This world does not have custom objects"");
+-
+- List pluginList = new ArrayList();
+- for (CustomObjectCompiled object : world.getSettings().CustomObjectsCompiled)
+- {
+- pluginList.add(ValueColor + object.Name);
+- }
+-
+- this.ListMessage(sender, pluginList, page, ""World bo2 objects"");
+-
+- } else
+- sender.sendMessage(ErrorColor + ""World not found "" + worldName);
+- return true;
+-
+-
+- }
+- if (args.size() > 0)
+- {
+- try
+- {
+- page = Integer.parseInt(args.get(0));
+- } catch (Exception e)
+- {
+- sender.sendMessage(ErrorColor + ""Wrong page number "" + args.get(0));
+- }
+- }
+-
+- ArrayList globalObjects = ObjectsStore.LoadObjectsFromDirectory(ObjectsStore.GlobalDirectory);
+-
+- if (globalObjects.size() == 0)
+- sender.sendMessage(MessageColor + ""This global directory does not have custom objects"");
+-
+- List pluginList = new ArrayList();
+- for (CustomObject object : globalObjects)
+- {
+- pluginList.add(ValueColor + object.Name);
+- }
+-
+- this.ListMessage(sender, pluginList, page, ""Global bo2 objects"");
+-
+-
+- return true;
+-
+- }
++package com.khorn.terraincontrol.bukkit.commands;
++
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.bukkit.BukkitWorld;
++import com.khorn.terraincontrol.bukkit.TCPerm;
++import com.khorn.terraincontrol.bukkit.TCPlugin;
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import org.bukkit.command.CommandSender;
+
-+ protected abstract Resource getResource(String name);
++import java.util.ArrayList;
++import java.util.Collection;
++import java.util.List;
+
-+ Class extends T> getClass(String name) throws NoSuchCommandException, NullPointerException {
-+ if (name == null) {
-+ throw new NullPointerException(""No null argument allowed"");
++public class ListCommand extends BaseCommand
++{
++ public ListCommand(TCPlugin _plugin)
++ {
++ super(_plugin);
++ name = ""list"";
++ perm = TCPerm.CMD_LIST.node;
++ usage = ""list [-w World] [page]"";
++ workOnConsole = false;
+ }
+
-+ TimestampedObject> providerRef = loadClass(name);
++ @Override
++ public boolean onCommand(CommandSender sender, List args)
++ {
++
++ int page = 1;
+
-+ //
-+ Resource script = getResource(name);
++ if (args.size() > 1 && args.get(0).equals(""-w""))
++ {
++ String worldName = args.get(1);
++ if (args.size() > 2)
++ {
++ try
++ {
++ page = Integer.parseInt(args.get(2));
++ } catch (Exception e)
++ {
++ sender.sendMessage(ErrorColor + ""Wrong page number "" + args.get(2));
++ }
++ }
++ BukkitWorld world = this.getWorld(sender, worldName);
++
++ if (world != null)
++ {
++ if (world.getSettings().customObjects.size() == 0)
++ sender.sendMessage(MessageColor + ""This world does not have custom objects"");
++
++ List pluginList = new ArrayList();
++ for (CustomObject object : world.getSettings().customObjects.values())
++ {
++ pluginList.add(ValueColor + object.getName());
++ }
++
++ this.ListMessage(sender, pluginList, page, ""World bo2 objects"");
++
++ } else
++ sender.sendMessage(ErrorColor + ""World not found "" + worldName);
++ return true;
+
-+ //
-+ if (script != null) {
-+ if (providerRef != null) {
-+ if (script.getTimestamp() != providerRef.getTimestamp()) {
-+ providerRef = null;
+ }
-+ }
++ if (args.size() > 0)
++ {
++ try
++ {
++ page = Integer.parseInt(args.get(0));
++ } catch (Exception e)
++ {
++ sender.sendMessage(ErrorColor + ""Wrong page number "" + args.get(0));
++ }
++ }
+
-+ //
-+ if (providerRef == null) {
++ Collection globalObjects = TerrainControl.getCustomObjectManager().globalObjects.values();
+
-+ //
-+ String source;
-+ try {
-+ source = new String(script.getContent(), ""UTF-8"");
++ if (globalObjects.size() == 0)
++ sender.sendMessage(MessageColor + ""This global directory does not have custom objects"");
++
++ List pluginList = new ArrayList();
++ for (CustomObject object : globalObjects)
++ {
++ pluginList.add(ValueColor + object.getName());
+ }
-+ catch (UnsupportedEncodingException e) {
-+ throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not compile command script "" + name, e);
++
++ this.ListMessage(sender, pluginList, page, ""Global bo2 objects"");
++
++ return true;
++
++ }
+ }
+\ No newline at end of file
+diff --git a/bukkit/src/com/khorn/terraincontrol/bukkit/commands/SpawnCommand.java b/bukkit/src/com/khorn/terraincontrol/bukkit/commands/SpawnCommand.java
+index c706d9558..6c3252e26 100644
+--- a/bukkit/src/com/khorn/terraincontrol/bukkit/commands/SpawnCommand.java
++++ b/bukkit/src/com/khorn/terraincontrol/bukkit/commands/SpawnCommand.java
+@@ -1,97 +1,90 @@
+-package com.khorn.terraincontrol.bukkit.commands;
+-
+-import com.khorn.terraincontrol.bukkit.BukkitWorld;
+-import com.khorn.terraincontrol.bukkit.TCPerm;
+-import com.khorn.terraincontrol.bukkit.TCPlugin;
+-import com.khorn.terraincontrol.customobjects.CustomObjectCompiled;
+-import com.khorn.terraincontrol.customobjects.CustomObjectGen;
+-import com.khorn.terraincontrol.customobjects.ObjectsStore;
+-import org.bukkit.block.Block;
+-import org.bukkit.command.CommandSender;
+-import org.bukkit.entity.Player;
+-import org.bukkit.util.BlockIterator;
+-
+-import java.util.Iterator;
+-import java.util.List;
+-import java.util.Random;
+-
+-public class SpawnCommand extends BaseCommand
+-{
+- public SpawnCommand(TCPlugin _plugin)
+- {
+- super(_plugin);
+- name = ""spawn"";
+- perm = TCPerm.CMD_SPAWN.node;
+- usage = ""spawn Name [World]"";
+- workOnConsole = false;
+- }
+-
+- @Override
+- public boolean onCommand(CommandSender sender, List args)
+- {
+- Player me = (Player) sender;
+-
+- BukkitWorld bukkitWorld = this.getWorld(me, args.size() > 1 ? args.get(1) : """");
+-
+- if (args.size() == 0)
+- {
+- me.sendMessage(ErrorColor + ""You must enter the name of the BO2."");
+- return true;
+- }
+- CustomObjectCompiled spawnObject = null;
+-
+- if (bukkitWorld != null)
+- spawnObject = ObjectsStore.CompileString(args.get(0), bukkitWorld.getSettings().CustomObjectsDirectory);
+-
+- if (spawnObject == null)
+- {
+- me.sendMessage(BaseCommand.MessageColor + ""BO2 not found in world directory. Searching in global directory."");
+- spawnObject = ObjectsStore.CompileString(args.get(0), ObjectsStore.GlobalDirectory);
+- }
+-
+- if (spawnObject == null)
+- {
+- sender.sendMessage(ErrorColor + ""BO2 not found, use '/tc list' to list the available ones."");
+- return true;
+- }
+-
+- Block block = this.getWatchedBlock(me, true);
+- if (block == null)
+- return true;
+-
+- if (CustomObjectGen.GenerateCustomObject(bukkitWorld, new Random(), block.getX(), block.getY(), block.getZ(), spawnObject))
+- {
+- me.sendMessage(BaseCommand.MessageColor + spawnObject.Name + "" was spawned."");
+- } else
+- {
+- me.sendMessage(BaseCommand.ErrorColor + ""BO2 cant be spawned over there."");
+- }
+-
+- return true;
+- }
+-
+- public Block getWatchedBlock(Player me, boolean verbose)
+- {
+- if (me == null)
+- return null;
+-
+- Block block;
+-
+- Iterator itr = new BlockIterator(me, 200);
+- while (itr.hasNext())
+- {
+- block = itr.next();
+- if (block.getTypeId() != 0)
+- {
+- return block;
+- }
+- }
+-
+- if (verbose)
+- {
+- me.sendMessage(ErrorColor + ""No block in sight."");
+- }
+-
+- return null;
+- }
++package com.khorn.terraincontrol.bukkit.commands;
++
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.bukkit.BukkitWorld;
++import com.khorn.terraincontrol.bukkit.TCPerm;
++import com.khorn.terraincontrol.bukkit.TCPlugin;
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import org.bukkit.block.Block;
++import org.bukkit.command.CommandSender;
++import org.bukkit.entity.Player;
++import org.bukkit.util.BlockIterator;
++
++import java.util.Iterator;
++import java.util.List;
++import java.util.Random;
++
++public class SpawnCommand extends BaseCommand
++{
++ public SpawnCommand(TCPlugin _plugin)
++ {
++ super(_plugin);
++ name = ""spawn"";
++ perm = TCPerm.CMD_SPAWN.node;
++ usage = ""spawn Name [World]"";
++ workOnConsole = false;
++ }
++
++ @Override
++ public boolean onCommand(CommandSender sender, List args)
++ {
++ Player me = (Player) sender;
++
++ BukkitWorld bukkitWorld = this.getWorld(me, args.size() > 1 ? args.get(1) : """");
++
++ if (args.size() == 0)
++ {
++ me.sendMessage(ErrorColor + ""You must enter the name of the BO2."");
++ return true;
+ }
++ CustomObject spawnObject = null;
+
-+ //
-+ Class> clazz;
-+ try {
-+ GroovyCodeSource gcs = new GroovyCodeSource(source, name, ""/groovy/shell"");
-+ GroovyClassLoader gcl = new GroovyClassLoader(context.getLoader(), config);
-+ clazz = gcl.parseClass(gcs, false);
++ if (bukkitWorld != null)
++ spawnObject = TerrainControl.getCustomObjectManager().getObjectFromString(args.get(0), bukkitWorld);
++
++ if (spawnObject == null)
++ {
++ sender.sendMessage(ErrorColor + ""Object not found, use '/tc list' to list the available ones."");
++ return true;
+ }
-+ catch (NoClassDefFoundError e) {
-+ throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not compile command script "" + name, e);
++
++ Block block = this.getWatchedBlock(me, true);
++ if (block == null)
++ return true;
++
++ if (spawnObject.spawn(bukkitWorld, new Random(), block.getX(), block.getY(), block.getZ()))
++ {
++ me.sendMessage(BaseCommand.MessageColor + spawnObject.getName() + "" was spawned."");
++ } else
++ {
++ me.sendMessage(BaseCommand.ErrorColor + ""BO2 cant be spawned over there."");
+ }
-+ catch (CompilationFailedException e) {
-+ throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not compile command script "" + name, e);
++
++ return true;
++ }
++
++ public Block getWatchedBlock(Player me, boolean verbose)
++ {
++ if (me == null)
++ return null;
++
++ Block block;
++
++ Iterator itr = new BlockIterator(me, 200);
++ while (itr.hasNext())
++ {
++ block = itr.next();
++ if (block.getTypeId() != 0)
++ {
++ return block;
++ }
+ }
+
-+ //
-+ if (baseClass.isAssignableFrom(clazz)) {
-+ Class extends T> providerClass = clazz.asSubclass(baseClass);
-+ providerRef = new TimestampedObject>(script.getTimestamp(), providerClass);
-+ saveClass(name, providerRef);
-+ } else {
-+ throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Parsed script "" + clazz.getName() +
-+ "" does not implements "" + CommandInvoker.class.getName());
++ if (verbose)
++ {
++ me.sendMessage(ErrorColor + ""No block in sight."");
+ }
-+ }
++
++ return null;
+ }
+ }
+\ No newline at end of file
+diff --git a/common/src/com/khorn/terraincontrol/TerrainControl.java b/common/src/com/khorn/terraincontrol/TerrainControl.java
+index 0384414d4..5fa04436f 100644
+--- a/common/src/com/khorn/terraincontrol/TerrainControl.java
++++ b/common/src/com/khorn/terraincontrol/TerrainControl.java
+@@ -1,10 +1,37 @@
+ package com.khorn.terraincontrol;
+
++import java.util.HashMap;
++import java.util.Map;
+ import java.util.logging.Level;
+
++import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import com.khorn.terraincontrol.customobjects.CustomObjectLoader;
++import com.khorn.terraincontrol.customobjects.CustomObjectManager;
++import com.khorn.terraincontrol.generator.resourcegens.ResourcesManager;
+
-+ //
-+ if (providerRef == null) {
-+ return null;
+ public class TerrainControl
+ {
++ /**
++ * The world height that the engine supports. Not the actual height the
++ * world is capped at. 256 in Minecraft.
++ */
++ public static int worldHeight = 256;
++
++ /**
++ * The world depth that the engine supports. Not the actual depth the world
++ * is capped at. 0 in Minecraft.
++ */
++ public static int worldDepth = 0;
++
+ private static TerrainControlEngine engine;
++ private static ResourcesManager resourcesManager;
++ private static CustomObjectManager customObjectManager;
++
++ // Used before TerrainControl is initialized
++ private static Map customObjectLoaders = new HashMap();
++ private static Map specialCustomObjects;
++ private static Map> resourceTypes;
+
+ private TerrainControl()
+ {
+@@ -12,7 +39,7 @@ private TerrainControl()
+ }
+
+ /**
+- * Starts the engine, making all API methods availible.
++ * Starts the engine, making all API methods available.
+ *
+ * @param engine
+ * The implementation of the engine.
+@@ -24,6 +51,24 @@ public static void startEngine(TerrainControlEngine engine)
+ throw new UnsupportedOperationException(""Engine is already set!"");
+ }
+ TerrainControl.engine = engine;
++
++ if (customObjectLoaders == null)
++ {
++ customObjectLoaders = new HashMap();
++ }
++ if (specialCustomObjects == null)
++ {
++ specialCustomObjects = new HashMap();
++ }
++ customObjectManager = new CustomObjectManager(customObjectLoaders, specialCustomObjects);
++
++ if (resourceTypes == null)
++ {
++ resourceTypes = new HashMap>();
++ }
++
++ resourcesManager = new ResourcesManager(resourceTypes);
++ //resourcesManager.start(resourceTypes);
+ }
+
+ /**
+@@ -33,6 +78,12 @@ public static void startEngine(TerrainControlEngine engine)
+ public static void stopEngine()
+ {
+ engine = null;
++ customObjectManager = null;
++ resourcesManager = null;
++
++ customObjectLoaders.clear();
++ specialCustomObjects.clear();
++ resourceTypes.clear();
+ }
+
+ /**
+@@ -105,4 +156,75 @@ public static void log(Level level, String... messages)
+ {
+ engine.log(level, messages);
+ }
++
++ /**
++ * Returns the CustomObject manager, with hooks to spawn CustomObjects.
++ *
++ * @return The CustomObject manager.
++ */
++ public static CustomObjectManager getCustomObjectManager()
++ {
++ return customObjectManager;
+ }
+
-+ //
-+ return providerRef.getObject();
-+ }
++ /**
++ * Returns the Resource manager.
++ *
++ * @return The Resource manager.
++ */
++ public static ResourcesManager getResourcesManager()
++ {
++ return resourcesManager;
++ }
+
-+ T getInstance(String name) throws NoSuchCommandException, NullPointerException {
-+ Class extends T> clazz = getClass(name);
-+ if (clazz == null) {
-+ return null;
++ /**
++ * Registers a CustomObject loader. Can be called before Terrain Control is
++ * fully loaded.
++ *
++ * @param extension
++ * The file extension, without a dot.
++ * @param loader
++ * The loader.
++ */
++ public static void registerCustomObjectLoader(String extension, CustomObjectLoader loader)
++ {
++ if (customObjectLoaders == null)
++ {
++ customObjectLoaders = new HashMap();
++ }
++ customObjectLoaders.put(extension.toLowerCase(), loader);
+ }
+
-+ //
-+ try {
-+ return clazz.newInstance();
++ /**
++ * Registers a special CustomObject, like UseWorld or UseBiome or a tree.
++ * Can be called before Terrain Control is fully loaded.
++ *
++ * @param extension
++ * @param loader
++ */
++ public static void registerSpecialCustomObject(String name, CustomObject object)
++ {
++ if (specialCustomObjects == null)
++ {
++ specialCustomObjects = new HashMap();
++ }
++ specialCustomObjects.put(name.toLowerCase(), object);
+ }
-+ catch (Exception e) {
-+ throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not create command "" + name + "" instance"", e);
++
++ /**
++ * Register a new Resource type. Can be called before Terrain Control is
++ * fully loaded.
++ *
++ * @param name
++ * @param resourceType
++ */
++ public static void registerResourceType(String name, Class extends Resource> resourceType)
++ {
++ if (resourceTypes == null)
++ {
++ resourceTypes = new HashMap>();
++ }
++ resourceTypes.put(name.toLowerCase(), resourceType);
+ }
-+ }
-+}
-diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java b/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java
-index ce0d38949..35c96e519 100644
---- a/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java
-+++ b/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java
-@@ -19,7 +19,6 @@
++
+ }
+diff --git a/common/src/com/khorn/terraincontrol/TerrainControlEngine.java b/common/src/com/khorn/terraincontrol/TerrainControlEngine.java
+index 118bda6a0..c3f5c54ed 100644
+--- a/common/src/com/khorn/terraincontrol/TerrainControlEngine.java
++++ b/common/src/com/khorn/terraincontrol/TerrainControlEngine.java
+@@ -1,5 +1,6 @@
+ package com.khorn.terraincontrol;
- package org.crsh.shell.impl.command;
++import java.io.File;
+ import java.util.logging.Level;
--import groovy.lang.Script;
- import org.crsh.command.GroovyScript;
- import org.crsh.command.GroovyScriptCommand;
- import org.crsh.command.NoSuchCommandException;
-@@ -33,10 +32,10 @@ public class CRaSH {
+ public interface TerrainControlEngine
+@@ -9,11 +10,17 @@ public interface TerrainControlEngine
+ * @param name The name of the world.
+ * @return The world object.
+ */
+- public abstract LocalWorld getWorld(String name);
++ public LocalWorld getWorld(String name);
+
+ /**
+ * Logs the messages.
+ * @param message The messages to log.
+ */
+- public abstract void log(Level level, String... message);
++ public void log(Level level, String... message);
++
++ /**
++ * Returns the folder where the global objects are stored in.
++ * @return
++ */
++ public File getGlobalObjectsDirectory();
+ }
+diff --git a/common/src/com/khorn/terraincontrol/configuration/BiomeConfig.java b/common/src/com/khorn/terraincontrol/configuration/BiomeConfig.java
+index b72c0087e..0d4d81fb3 100644
+--- a/common/src/com/khorn/terraincontrol/configuration/BiomeConfig.java
++++ b/common/src/com/khorn/terraincontrol/configuration/BiomeConfig.java
+@@ -4,11 +4,26 @@
+ import com.khorn.terraincontrol.DefaultMaterial;
+ import com.khorn.terraincontrol.DefaultMobType;
+ import com.khorn.terraincontrol.LocalBiome;
+-import com.khorn.terraincontrol.customobjects.BODefaultValues;
+-import com.khorn.terraincontrol.customobjects.CustomObjectCompiled;
+-import com.khorn.terraincontrol.customobjects.ObjectsStore;
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import com.khorn.terraincontrol.generator.resourcegens.AboveWaterGen;
++import com.khorn.terraincontrol.generator.resourcegens.CactusGen;
++import com.khorn.terraincontrol.generator.resourcegens.CustomObjectGen;
++import com.khorn.terraincontrol.generator.resourcegens.DungeonGen;
++import com.khorn.terraincontrol.generator.resourcegens.GrassGen;
++import com.khorn.terraincontrol.generator.resourcegens.LiquidGen;
++import com.khorn.terraincontrol.generator.resourcegens.OreGen;
++import com.khorn.terraincontrol.generator.resourcegens.PlantGen;
++import com.khorn.terraincontrol.generator.resourcegens.ReedGen;
+ import com.khorn.terraincontrol.generator.resourcegens.ResourceType;
++import com.khorn.terraincontrol.generator.resourcegens.SaplingGen;
++import com.khorn.terraincontrol.generator.resourcegens.SmallLakeGen;
++import com.khorn.terraincontrol.generator.resourcegens.TreeGen;
+ import com.khorn.terraincontrol.generator.resourcegens.TreeType;
++import com.khorn.terraincontrol.generator.resourcegens.UnderWaterOreGen;
++import com.khorn.terraincontrol.generator.resourcegens.UndergroundLakeGen;
++import com.khorn.terraincontrol.generator.resourcegens.VinesGen;
+ import com.khorn.terraincontrol.util.Txt;
+ import java.io.DataInputStream;
+@@ -16,6 +31,7 @@
+ import java.io.File;
+ import java.io.IOException;
+ import java.util.ArrayList;
++import java.util.Arrays;
+ import java.util.List;
+ import java.util.Map;
- /** . */
-- final ClassManager extends ShellCommand> commandManager;
-+ final AbstractClassManager extends ShellCommand> commandManager;
+@@ -33,7 +49,7 @@ public class BiomeConfig extends ConfigFile
+ public ArrayList IsleInBiome;
+ public ArrayList NotBorderNear;
- /** . */
-- final ClassManager extends GroovyScript> scriptManager;
-+ final AbstractClassManager extends GroovyScript> scriptManager;
+- //Surface config
++ // Surface config
+ public float BiomeHeight;
+ public float BiomeVolatility;
- /** . */
- final PluginContext context;
-@@ -55,7 +54,7 @@ public CRaSH(PluginContext context) throws NullPointerException {
- );
- }
+@@ -47,7 +63,6 @@ public class BiomeConfig extends ConfigFile
-- public CRaSH(PluginContext context, ClassManager commandManager, ClassManager extends GroovyScript> scriptManager) {
-+ public CRaSH(PluginContext context, AbstractClassManager commandManager, AbstractClassManager extends GroovyScript> scriptManager) {
- this.context = context;
- this.commandManager = commandManager;
- this.scriptManager = scriptManager;
-diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java b/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java
-index 1369cee1d..ddf3cfaea 100644
---- a/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java
-+++ b/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java
-@@ -19,25 +19,16 @@
-
- package org.crsh.shell.impl.command;
-
--import groovy.lang.GroovyClassLoader;
--import groovy.lang.GroovyCodeSource;
- import groovy.lang.Script;
--import org.codehaus.groovy.control.CompilationFailedException;
--import org.codehaus.groovy.control.CompilerConfiguration;
--import org.crsh.command.CommandInvoker;
--import org.crsh.command.GroovyScriptCommand;
--import org.crsh.command.NoSuchCommandException;
- import org.crsh.plugin.PluginContext;
- import org.crsh.plugin.ResourceKind;
--import org.crsh.shell.ErrorType;
- import org.crsh.util.TimestampedObject;
- import org.crsh.vfs.Resource;
-
--import java.io.UnsupportedEncodingException;
- import java.util.Map;
- import java.util.concurrent.ConcurrentHashMap;
+ public String ReplaceBiomeName;
--class ClassManager {
-+public class ClassManager extends AbstractClassManager {
+-
+ public boolean UseWorldWaterLevel;
+ public int waterLevelMax;
+ public int waterLevelMin;
+@@ -63,10 +78,11 @@ public class BiomeConfig extends ConfigFile
+ public boolean FoliageColorIsMultiplier;
- /** . */
- private final Map>> classes = new ConcurrentHashMap>>();
-@@ -45,104 +36,29 @@ class ClassManager {
- /** . */
- private final PluginContext context;
+ public Resource[] ResourceSequence = new Resource[256];
+- public Resource[] SaplingTypes = new Resource[4];
+- public Resource SaplingResource = null;
++ public SaplingGen[] SaplingTypes = new SaplingGen[4];
++ public SaplingGen SaplingResource = null;
-- /** . */
-- private final CompilerConfiguration config;
--
-- /** . */
-- private final Class baseClass;
--
- /** . */
- private final ResourceKind kind;
+- public ArrayList CustomObjectsCompiled;
++ public ArrayList biomeObjects;
++ public ArrayList biomeObjectStrings;
-- ClassManager(PluginContext context, ResourceKind kind, Class baseClass, Class extends Script> baseScriptClass) {
-- CompilerConfiguration config = new CompilerConfiguration();
-- config.setRecompileGroovySource(true);
-- config.setScriptBaseClass(baseScriptClass.getName());
-+ public ClassManager(PluginContext context, ResourceKind kind, Class baseClass, Class extends Script> baseScriptClass) {
-+ super(context, baseClass, baseScriptClass);
+ public double maxAverageHeight;
+ public double maxAverageDepth;
+@@ -83,13 +99,12 @@ public class BiomeConfig extends ConfigFile
- //
- this.context = context;
-- this.config = config;
-- this.baseClass = baseClass;
- this.kind = kind;
- }
+ public int ResourceCount = 0;
-- Class extends T> getClass(String name) throws NoSuchCommandException, NullPointerException {
-- if (name == null) {
-- throw new NullPointerException(""No null argument allowed"");
-- }
-
-- TimestampedObject> providerRef = classes.get(name);
--
-- //
-- Resource script = context.loadResource(name, kind);
--
-- //
-- if (script != null) {
-- if (providerRef != null) {
-- if (script.getTimestamp() != providerRef.getTimestamp()) {
-- providerRef = null;
-- }
-- }
--
-- //
-- if (providerRef == null) {
--
-- //
-- String source;
-- try {
-- source = new String(script.getContent(), ""UTF-8"");
-- }
-- catch (UnsupportedEncodingException e) {
-- throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not compile command script "" + name, e);
-- }
+ public LocalBiome Biome;
+
+ public WorldConfig worldConfig;
+ public String Name;
+
+- //Spawn Config
++ // Spawn Config
+ public boolean spawnMonstersAddDefaults = true;
+ public List spawnMonsters = new ArrayList();
+ public boolean spawnCreaturesAddDefaults = true;
+@@ -124,12 +139,10 @@ public BiomeConfig(File settingsDir, LocalBiome biome, WorldConfig config)
+ this.iceBlock = worldConfig.iceBlock;
+ }
+
-
-- //
-- Class> clazz;
-- try {
-- GroovyCodeSource gcs = new GroovyCodeSource(source, name, ""/groovy/shell"");
-- GroovyClassLoader gcl = new GroovyClassLoader(context.getLoader(), config);
-- clazz = gcl.parseClass(gcs, false);
-- }
-- catch (NoClassDefFoundError e) {
-- throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not compile command script "" + name, e);
-- }
-- catch (CompilationFailedException e) {
-- throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not compile command script "" + name, e);
-- }
+ if (biome.isCustom())
+ biome.setVisuals(this);
+ }
+
-
-- //
-- if (baseClass.isAssignableFrom(clazz)) {
-- Class extends T> providerClass = clazz.asSubclass(baseClass);
-- providerRef = new TimestampedObject>(script.getTimestamp(), providerClass);
-- classes.put(name, providerRef);
-- } else {
-- throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Parsed script "" + clazz.getName() +
-- "" does not implements "" + CommandInvoker.class.getName());
-- }
-- }
-- }
+ public int getTemperature()
+ {
+ return (int) (this.BiomeTemperature * 65536.0F);
+@@ -144,199 +157,193 @@ private void CreateDefaultResources()
+ {
+ Resource resource;
+
+- //Small lakes
+- resource = new Resource(ResourceType.SmallLake, DefaultMaterial.WATER.id, TCDefaultValues.SmallLakeWaterFrequency.intValue(), TCDefaultValues.SmallLakeWaterRarity.intValue(), TCDefaultValues.SmallLakeMinAltitude.intValue(), TCDefaultValues.SmallLakeMaxAltitude.intValue());
++ // Small lakes
++ resource = Resource.create(worldConfig, SmallLakeGen.class, DefaultMaterial.WATER.id, TCDefaultValues.SmallLakeWaterFrequency.intValue(), TCDefaultValues.SmallLakeWaterRarity.intValue(), TCDefaultValues.SmallLakeMinAltitude.intValue(), TCDefaultValues.SmallLakeMaxAltitude.intValue());
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Small lakes
+- resource = new Resource(ResourceType.SmallLake, DefaultMaterial.LAVA.id, TCDefaultValues.SmallLakeLavaFrequency.intValue(), TCDefaultValues.SmallLakeLavaRarity.intValue(), TCDefaultValues.SmallLakeMinAltitude.intValue(), TCDefaultValues.SmallLakeMaxAltitude.intValue());
++ // Small lakes
++ resource = Resource.create(worldConfig, SmallLakeGen.class, DefaultMaterial.LAVA.id, TCDefaultValues.SmallLakeLavaFrequency.intValue(), TCDefaultValues.SmallLakeLavaRarity.intValue(), TCDefaultValues.SmallLakeMinAltitude.intValue(), TCDefaultValues.SmallLakeMaxAltitude.intValue());
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Underground lakes
+- resource = new Resource(ResourceType.UnderGroundLake, TCDefaultValues.undergroundLakeMinSize.intValue(), TCDefaultValues.undergroundLakeMaxSize.intValue(), TCDefaultValues.undergroundLakeFrequency.intValue(), TCDefaultValues.undergroundLakeRarity.intValue(), TCDefaultValues.undergroundLakeMinAltitude.intValue(), TCDefaultValues.undergroundLakeMaxAltitude.intValue());
++ // Underground lakes
++ resource = Resource.create(worldConfig, UndergroundLakeGen.class, TCDefaultValues.undergroundLakeMinSize.intValue(), TCDefaultValues.undergroundLakeMaxSize.intValue(), TCDefaultValues.undergroundLakeFrequency.intValue(), TCDefaultValues.undergroundLakeRarity.intValue(), TCDefaultValues.undergroundLakeMinAltitude.intValue(), TCDefaultValues.undergroundLakeMaxAltitude.intValue());
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Dungeon
+- resource = new Resource(ResourceType.Dungeon, 0, 0, 0, TCDefaultValues.dungeonFrequency.intValue(), TCDefaultValues.dungeonRarity.intValue(), TCDefaultValues.dungeonMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Dungeon
++ resource = Resource.create(worldConfig, DungeonGen.class, TCDefaultValues.dungeonFrequency.intValue(), TCDefaultValues.dungeonRarity.intValue(), TCDefaultValues.dungeonMinAltitude.intValue(), this.worldConfig.WorldHeight);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Resource(ResourceType type,int blockId, int blockData, int size,int frequency, int rarity, int minAltitude,int maxAltitude,int[] sourceBlockIds)
+- //Dirt
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.DIRT.id, 0, TCDefaultValues.dirtDepositSize.intValue(), TCDefaultValues.dirtDepositFrequency.intValue(), TCDefaultValues.dirtDepositRarity.intValue(), TCDefaultValues.dirtDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Dirt
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.DIRT.id, TCDefaultValues.dirtDepositSize.intValue(), TCDefaultValues.dirtDepositFrequency.intValue(), TCDefaultValues.dirtDepositRarity.intValue(), TCDefaultValues.dirtDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Gravel
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.GRAVEL.id, 0, TCDefaultValues.gravelDepositSize.intValue(), TCDefaultValues.gravelDepositFrequency.intValue(), TCDefaultValues.gravelDepositRarity.intValue(), TCDefaultValues.gravelDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Gravel
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.GRAVEL.id, TCDefaultValues.gravelDepositSize.intValue(), TCDefaultValues.gravelDepositFrequency.intValue(), TCDefaultValues.gravelDepositRarity.intValue(), TCDefaultValues.gravelDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Clay
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.CLAY.id, 0, TCDefaultValues.clayDepositSize.intValue(), TCDefaultValues.clayDepositFrequency.intValue(), TCDefaultValues.clayDepositRarity.intValue(), TCDefaultValues.clayDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Clay
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.CLAY.id, TCDefaultValues.clayDepositSize.intValue(), TCDefaultValues.clayDepositFrequency.intValue(), TCDefaultValues.clayDepositRarity.intValue(), TCDefaultValues.clayDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Coal
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.COAL_ORE.id, 0, TCDefaultValues.coalDepositSize.intValue(), TCDefaultValues.coalDepositFrequency.intValue(), TCDefaultValues.coalDepositRarity.intValue(), TCDefaultValues.coalDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Coal
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.COAL_ORE.id, TCDefaultValues.coalDepositSize.intValue(), TCDefaultValues.coalDepositFrequency.intValue(), TCDefaultValues.coalDepositRarity.intValue(), TCDefaultValues.coalDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Iron
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.IRON_ORE.id, 0, TCDefaultValues.ironDepositSize.intValue(), TCDefaultValues.ironDepositFrequency.intValue(), TCDefaultValues.ironDepositRarity.intValue(), TCDefaultValues.ironDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 2, new int[]{DefaultMaterial.STONE.id});
++ // Iron
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.IRON_ORE.id, TCDefaultValues.ironDepositSize.intValue(), TCDefaultValues.ironDepositFrequency.intValue(), TCDefaultValues.ironDepositRarity.intValue(), TCDefaultValues.ironDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 2, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Gold
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.GOLD_ORE.id, 0, TCDefaultValues.goldDepositSize.intValue(), TCDefaultValues.goldDepositFrequency.intValue(), TCDefaultValues.goldDepositRarity.intValue(), TCDefaultValues.goldDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 4, new int[]{DefaultMaterial.STONE.id});
++ // Gold
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.GOLD_ORE.id, TCDefaultValues.goldDepositSize.intValue(), TCDefaultValues.goldDepositFrequency.intValue(), TCDefaultValues.goldDepositRarity.intValue(), TCDefaultValues.goldDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 4, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Redstone
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.REDSTONE_ORE.id, 0, TCDefaultValues.redstoneDepositSize.intValue(), TCDefaultValues.redstoneDepositFrequency.intValue(), TCDefaultValues.redstoneDepositRarity.intValue(), TCDefaultValues.redstoneDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 8, new int[]{DefaultMaterial.STONE.id});
++ // Redstone
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.REDSTONE_ORE.id, TCDefaultValues.redstoneDepositSize.intValue(), TCDefaultValues.redstoneDepositFrequency.intValue(), TCDefaultValues.redstoneDepositRarity.intValue(), TCDefaultValues.redstoneDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 8, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Diamond
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.DIAMOND_ORE.id, 0, TCDefaultValues.diamondDepositSize.intValue(), TCDefaultValues.diamondDepositFrequency.intValue(), TCDefaultValues.diamondDepositRarity.intValue(), TCDefaultValues.diamondDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 8, new int[]{DefaultMaterial.STONE.id});
++ // Diamond
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.DIAMOND_ORE.id, TCDefaultValues.diamondDepositSize.intValue(), TCDefaultValues.diamondDepositFrequency.intValue(), TCDefaultValues.diamondDepositRarity.intValue(), TCDefaultValues.diamondDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 8, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Lapislazuli
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.LAPIS_ORE.id, 0, TCDefaultValues.lapislazuliDepositSize.intValue(), TCDefaultValues.lapislazuliDepositFrequency.intValue(), TCDefaultValues.lapislazuliDepositRarity.intValue(), TCDefaultValues.lapislazuliDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 8, new int[]{DefaultMaterial.STONE.id});
++ // Lapislazuli
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.LAPIS_ORE.id, TCDefaultValues.lapislazuliDepositSize.intValue(), TCDefaultValues.lapislazuliDepositFrequency.intValue(), TCDefaultValues.lapislazuliDepositRarity.intValue(), TCDefaultValues.lapislazuliDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 8, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+ DefaultBiome biome = DefaultBiome.getBiome(this.Biome.getId());
+
+ if (biome != null && (biome == DefaultBiome.EXTREME_HILLS || biome == DefaultBiome.SMALL_MOUNTAINS))
+ {
+- resource = new Resource(ResourceType.Ore, DefaultMaterial.EMERALD_ORE.id, 0, TCDefaultValues.emeraldDepositSize.intValue(), TCDefaultValues.emeraldDepositFrequency.intValue(), TCDefaultValues.emeraldDepositRarity.intValue(), TCDefaultValues.emeraldDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 4, new int[]{DefaultMaterial.STONE.id});
++ resource = Resource.create(worldConfig, OreGen.class, DefaultMaterial.EMERALD_ORE.id, TCDefaultValues.emeraldDepositSize.intValue(), TCDefaultValues.emeraldDepositFrequency.intValue(), TCDefaultValues.emeraldDepositRarity.intValue(), TCDefaultValues.emeraldDepositMinAltitude.intValue(), this.worldConfig.WorldHeight / 4, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+ }
+
+- //Under water sand
+- resource = new Resource(ResourceType.UnderWaterOre, DefaultMaterial.SAND.id, 0, TCDefaultValues.waterSandDepositSize.intValue(), TCDefaultValues.waterSandDepositFrequency.intValue(), TCDefaultValues.waterSandDepositRarity.intValue(), 0, 0, new int[]{DefaultMaterial.DIRT.id, DefaultMaterial.GRASS.id});
++ // Under water sand
++ resource = Resource.create(worldConfig, UnderWaterOreGen.class, DefaultMaterial.SAND.id, TCDefaultValues.waterSandDepositSize.intValue(), TCDefaultValues.waterSandDepositFrequency.intValue(), TCDefaultValues.waterSandDepositRarity.intValue(), DefaultMaterial.DIRT.id, DefaultMaterial.GRASS.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Under water clay
++ // Under water clay
+ if (this.DefaultClay > 0)
+ {
+- resource = new Resource(ResourceType.UnderWaterOre, DefaultMaterial.CLAY.id, 0, TCDefaultValues.waterClayDepositSize.intValue(), this.DefaultClay, TCDefaultValues.waterClayDepositRarity.intValue(), 0, 0, new int[]{DefaultMaterial.DIRT.id, DefaultMaterial.CLAY.id});
++ resource = Resource.create(worldConfig, UnderWaterOreGen.class, DefaultMaterial.CLAY.id, TCDefaultValues.waterClayDepositSize.intValue(), this.DefaultClay, TCDefaultValues.waterClayDepositRarity.intValue(), DefaultMaterial.DIRT.id, DefaultMaterial.CLAY.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+ }
+- //Custom objects
+- resource = new Resource(ResourceType.CustomObject);
+- ResourceType.CustomObject.Generator.ReadFromString(resource, new String[]{BODefaultValues.BO_Use_World.stringValue()}, this);
++ // Custom objects
++ resource = Resource.create(worldConfig, CustomObjectGen.class, ""UseWorld"");
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
-
-- //
-- if (providerRef == null) {
-- return null;
-- }
++ // Trees
+ if (biome != null)
+ switch (biome)
+ {
+- case OCEAN: // Ocean - default
+- case EXTREME_HILLS: // BigHills - default
+- case RIVER: // River - default
+- case SMALL_MOUNTAINS: // SmallHills
+- resource = new Resource(ResourceType.Tree, this.DefaultTrees, new TreeType[]{TreeType.BigTree, TreeType.Tree}, new int[]{1, 9});
+- this.ResourceSequence[this.ResourceCount++] = resource;
+- break;
+- case PLAINS: // Plains - no tree
+- case DESERT: // Desert - no tree
+- case DESERT_HILLS: //HillsDesert
+- break;
+- case FOREST_HILLS: // HillsForest
+- case FOREST: // Forest - forest
+- resource = new Resource(ResourceType.Tree, this.DefaultTrees, new TreeType[]{TreeType.Forest, TreeType.BigTree, TreeType.Tree}, new int[]{20, 10, 100});
+- this.ResourceSequence[this.ResourceCount++] = resource;
+- break;
+- case TAIGA_HILLS: //HillsTaiga
+- case TAIGA: // Taiga - taiga
+- resource = new Resource(ResourceType.Tree, this.DefaultTrees, new TreeType[]{TreeType.Taiga1, TreeType.Taiga2}, new int[]{35, 100});
+- this.ResourceSequence[this.ResourceCount++] = resource;
+- break;
+- case SWAMPLAND: // Swamp - swamp
+- resource = new Resource(ResourceType.Tree, this.DefaultTrees, new TreeType[]{TreeType.SwampTree}, new int[]{100});
+- this.ResourceSequence[this.ResourceCount++] = resource;
+- break;
+- case MUSHROOM_ISLAND: // Mushroom island
+- resource = new Resource(ResourceType.Tree, this.DefaultTrees, new TreeType[]{TreeType.HugeMushroom}, new int[]{100});
+- this.ResourceSequence[this.ResourceCount++] = resource;
+- break;
+- case JUNGLE:// Jungle
+- case JUNGLE_HILLS:
+- resource = new Resource(ResourceType.Tree, this.DefaultTrees, new TreeType[]{TreeType.BigTree, TreeType.GroundBush, TreeType.JungleTree, TreeType.CocoaTree}, new int[]{10, 50, 35, 100});
+- this.ResourceSequence[this.ResourceCount++] = resource;
+- break;
-
-- //
-- return providerRef.getObject();
-+ @Override
-+ protected TimestampedObject> loadClass(String name) {
-+ return classes.get(name);
- }
++ case OCEAN: // Ocean - default
++ case EXTREME_HILLS: // BigHills - default
++ case RIVER: // River - default
++ case SMALL_MOUNTAINS: // SmallHills
++ resource = Resource.create(worldConfig, TreeGen.class, this.DefaultTrees, TreeType.BigTree, 1, TreeType.Tree, 9);
++ this.ResourceSequence[this.ResourceCount++] = resource;
++ break;
++ case PLAINS: // Plains - no tree
++ case DESERT: // Desert - no tree
++ case DESERT_HILLS: // HillsDesert
++ break;
++ case FOREST_HILLS: // HillsForest
++ case FOREST: // Forest - forest
++ resource = Resource.create(worldConfig, TreeGen.class, this.DefaultTrees, TreeType.Forest, 20, TreeType.BigTree, 10, TreeType.Tree, 100);
++ this.ResourceSequence[this.ResourceCount++] = resource;
++ break;
++ case TAIGA_HILLS: // HillsTaiga
++ case TAIGA: // Taiga - taiga
++ resource = Resource.create(worldConfig, TreeGen.class, this.DefaultTrees, TreeType.Taiga1, 35, TreeType.Taiga2, 100);
++ this.ResourceSequence[this.ResourceCount++] = resource;
++ break;
++ case SWAMPLAND: // Swamp - swamp
++ resource = Resource.create(worldConfig, TreeGen.class, this.DefaultTrees, TreeType.SwampTree, 100);
++ this.ResourceSequence[this.ResourceCount++] = resource;
++ break;
++ case MUSHROOM_ISLAND: // Mushroom island
++ resource = Resource.create(worldConfig, TreeGen.class, this.DefaultTrees, TreeType.HugeMushroom, 100);
++ this.ResourceSequence[this.ResourceCount++] = resource;
++ break;
++ case JUNGLE:// Jungle
++ case JUNGLE_HILLS:
++ resource = Resource.create(worldConfig, TreeGen.class, this.DefaultTrees, TreeType.BigTree, 10, TreeType.GroundBush, 50, TreeType.JungleTree, 35, TreeType.CocoaTree, 100);
++ this.ResourceSequence[this.ResourceCount++] = resource;
++ break;
-- T getInstance(String name) throws NoSuchCommandException, NullPointerException {
-- Class extends T> clazz = getClass(name);
-- if (clazz == null) {
-- return null;
-- }
-+ @Override
-+ protected void saveClass(String name, TimestampedObject> clazz) {
-+ classes.put(name, clazz);
-+ }
+ }
+ if (this.DefaultWaterLily > 0)
+ {
+- resource = new Resource(ResourceType.AboveWaterRes, DefaultMaterial.WATER_LILY.id, 0, 0, this.DefaultWaterLily, 100, 0, 0, new int[0]);
++ resource = Resource.create(worldConfig, AboveWaterGen.class, DefaultMaterial.WATER_LILY.id, this.DefaultWaterLily, 100);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+ }
-- //
-- try {
-- return clazz.newInstance();
-- }
-- catch (Exception e) {
-- throw new NoSuchCommandException(name, ErrorType.INTERNAL, ""Could not create command "" + name + "" instance"", e);
-- }
-+ @Override
-+ protected Resource getResource(String name) {
-+ return context.loadResource(name, kind);
- }
- }"
-5f232224c4de92467c4de6385590ec19e0568ba5,Mylyn Reviews,"322734: Display just the last review result for a task
-",p,https://github.com/eclipse-mylyn/org.eclipse.mylyn.reviews,"diff --git a/org.eclipse.mylyn.reviews.core/src/org/eclipse/mylyn/reviews/core/ReviewsUtil.java b/org.eclipse.mylyn.reviews.core/src/org/eclipse/mylyn/reviews/core/ReviewsUtil.java
-index d1a7e91b..9cd94ab5 100644
---- a/org.eclipse.mylyn.reviews.core/src/org/eclipse/mylyn/reviews/core/ReviewsUtil.java
-+++ b/org.eclipse.mylyn.reviews.core/src/org/eclipse/mylyn/reviews/core/ReviewsUtil.java
-@@ -148,12 +148,32 @@ public static List getReviewAttachmentFromTask(
- List reviews = new ArrayList();
- TaskData taskData = taskDataManager.getTaskData(task);
- if (taskData != null) {
-- for (TaskAttribute attribute : getReviewAttachments(
-- repositoryModel, taskData)) {
-- reviews.addAll(parseAttachments(attribute,
-- new NullProgressMonitor()));
-+ List attributesByType = taskData
-+ .getAttributeMapper().getAttributesByType(taskData,
-+ TaskAttribute.TYPE_ATTACHMENT);
-+ ITaskAttachment lastReview = null;
-+
-+ for (TaskAttribute attribute : attributesByType) {
-+ // TODO move RepositoryModel.createTaskAttachment to interface?
-+ ITaskAttachment taskAttachment = ((RepositoryModel) repositoryModel)
-+ .createTaskAttachment(attribute);
-+ if (taskAttachment != null
-+ && taskAttachment.getFileName().equals(
-+ ReviewConstants.REVIEW_DATA_CONTAINER)) {
-+
-+ if (lastReview == null
-+ || lastReview.getCreationDate().before(
-+ taskAttachment.getCreationDate())) {
-+ lastReview = taskAttachment;
-+ }
-+ }
-
- }
-+
-+ if (lastReview != null) {
-+ reviews.addAll(parseAttachments(lastReview.getTaskAttribute(),
-+ new NullProgressMonitor()));
-+ }
-
- }
- return reviews;
-@@ -203,4 +223,5 @@ public static void markAsReview(ITask task) {
- public static boolean hasReviewMarker(ITask task) {
- return task.getAttribute(ReviewConstants.ATTR_REVIEW_FLAG) != null;
- }
-+
- }"
-01e706466e561557d8591b3031cd85ae39b0559a,intellij-community,gradle: correctly set TestModuleProperties for- modules containing '-' in names (IDEA-151590)--,c,https://github.com/JetBrains/intellij-community,"diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java
-index 4179681ab59ba..c2c06d2180435 100644
---- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java
-+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java
-@@ -3,7 +3,6 @@
- import com.intellij.ide.highlighter.ModuleFileType;
- import com.intellij.openapi.externalSystem.model.ProjectSystemId;
- import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
--import com.intellij.openapi.util.io.FileUtil;
- import com.intellij.util.containers.ContainerUtil;
- import org.jetbrains.annotations.NotNull;
- import org.jetbrains.annotations.Nullable;
-@@ -58,7 +57,7 @@ protected ModuleData(@NotNull String id,
- @NotNull String internalName,
- @NotNull String moduleFileDirectoryPath,
- @NotNull String externalConfigPath) {
-- super(owner, externalName, FileUtil.sanitizeFileName(internalName));
-+ super(owner, externalName, internalName);
- myId = id;
- myModuleTypeId = typeId;
- myExternalConfigPath = externalConfigPath;
-diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java
-index 2a7f6b2eb6c25..9f67df07d6893 100644
---- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java
-+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java
-@@ -234,8 +234,8 @@ public DataNode createModule(@NotNull IdeaModule gradleModule, @NotN
- }
-
- @NotNull
-- public String getInternalModuleName(@NotNull IdeaModule gradleModule, @NotNull String sourceSetName) {
-- return gradleModule.getName() + ""_"" + sourceSetName;
-+ private static String getInternalModuleName(@NotNull IdeaModule gradleModule, @NotNull String sourceSetName) {
-+ return FileUtil.sanitizeFileName(gradleModule.getName() + ""_"" + sourceSetName);
- }
-
- @Override
-diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleMiscImportingTest.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleMiscImportingTest.java
-index c28a1745846c8..88c0cb575d438 100644
---- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleMiscImportingTest.java
-+++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleMiscImportingTest.java
-@@ -59,6 +59,20 @@ public void testTestModuleProperties() throws Exception {
- assertSame(productionModule, testModuleProperties.getProductionModule());
- }
-
-+ @Test
-+ public void testTestModulePropertiesForModuleWithHyphenInName() throws Exception {
-+ createSettingsFile(""rootProject.name='my-project'"");
-+ importProject(
-+ ""apply plugin: 'java'""
-+ );
-+
-+ assertModules(""my-project"", ""my_project_main"", ""my_project_test"");
-+
-+ final Module testModule = getModule(""my_project_test"");
-+ TestModuleProperties testModuleProperties = TestModuleProperties.getInstance(testModule);
-+ assertEquals(""my_project_main"", testModuleProperties.getProductionModuleName());
-+ }
-+
- @Test
- public void testInheritProjectJdkForModules() throws Exception {
- importProject("
-19152416a44473325a6c3605f9accc4fee379b63,elasticsearch,add an index level setting to disable/enable- purging of expired docs --,a,https://github.com/elastic/elasticsearch,"diff --git a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java
-index ae4a010e95c40..f000ba6987225 100644
---- a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java
-+++ b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java
-@@ -31,6 +31,8 @@
- import org.elasticsearch.action.bulk.BulkResponse;
- import org.elasticsearch.action.delete.DeleteRequest;
- import org.elasticsearch.client.Client;
-+import org.elasticsearch.cluster.ClusterService;
-+import org.elasticsearch.cluster.metadata.IndexMetaData;
- import org.elasticsearch.cluster.metadata.MetaData;
- import org.elasticsearch.common.component.AbstractLifecycleComponent;
- import org.elasticsearch.common.inject.Inject;
-@@ -65,8 +67,13 @@ public class IndicesTTLService extends AbstractLifecycleComponent 0)
+ {
+- //Red flower
+- resource = new Resource(ResourceType.Plant, DefaultMaterial.RED_ROSE.id, 0, 0, this.DefaultFlowers, TCDefaultValues.roseDepositRarity.intValue(), TCDefaultValues.roseDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id, DefaultMaterial.SOIL.id});
++ // Red flower
++ resource = Resource.create(worldConfig, PlantGen.class, DefaultMaterial.RED_ROSE.id, this.DefaultFlowers, TCDefaultValues.roseDepositRarity.intValue(), TCDefaultValues.roseDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id, DefaultMaterial.SOIL.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Yellow flower
+- resource = new Resource(ResourceType.Plant, DefaultMaterial.YELLOW_FLOWER.id, 0, 0, this.DefaultFlowers, TCDefaultValues.flowerDepositRarity.intValue(), TCDefaultValues.flowerDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id, DefaultMaterial.SOIL.id});
++ // Yellow flower
++ resource = Resource.create(worldConfig, PlantGen.class, DefaultMaterial.YELLOW_FLOWER.id, this.DefaultFlowers, TCDefaultValues.flowerDepositRarity.intValue(), TCDefaultValues.flowerDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id, DefaultMaterial.SOIL.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
}
- /**
-- * Returns the shards to purge, i.e. the local started primary shards that have ttl enabled
-+ * Returns the shards to purge, i.e. the local started primary shards that have ttl enabled and disable_purge to false
- */
- private List getShardsToPurge() {
- List shardsToPurge = new ArrayList();
- for (IndexService indexService : indicesService) {
-+ // check the value of disable_purge for this index
-+ IndexMetaData indexMetaData = clusterService.state().metaData().index(indexService.index().name());
-+ boolean disablePurge = indexMetaData.settings().getAsBoolean(""index.ttl.disable_purge"", false);
-+ if (disablePurge) {
-+ continue;
-+ }
-+
- // should be optimized with the hasTTL flag
- FieldMappers ttlFieldMappers = indexService.mapperService().name(TTLFieldMapper.NAME);
- if (ttlFieldMappers == null) {"
-c6f22949dc72af5edfd18bf4d350ae925fcc2d2c,Valadoc,"valadoc: LinkHelper: turn get_package_link into a virtual method
-",a,https://github.com/GNOME/vala/,⚠️ Could not parse repo info
-00db7d150b22031a0c030d55f1395e0ba41c1c76,kotlin,Fix KT-10472: compare all overloads including- varargs in a single pass.--,c,https://github.com/JetBrains/intellij-community,⚠️ HTTP 404: Not Found
-c1af71dbf3e85cba514b7cda53ffa20618f7cda3,hidendra$lwc,"FULL removal of Memory Database. Every single usage of it has been removed - gone. Still may be UNSTABLE and volatile; it has not be tested extensively just yet !! [#53] The current implementation will be smoothed out later on.
-",p,https://github.com/hidendra/lwc,"diff --git a/modules/core/src/main/java/com/griefcraft/modules/admin/AdminForceOwner.java b/modules/core/src/main/java/com/griefcraft/modules/admin/AdminForceOwner.java
-index 0ac0df12b..cf9c04c67 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/admin/AdminForceOwner.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/admin/AdminForceOwner.java
-@@ -19,6 +19,7 @@
-
- import com.griefcraft.lwc.LWC;
- import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCBlockInteractEvent;
-@@ -41,9 +42,9 @@ public void onProtectionInteract(LWCProtectionInteractEvent event) {
-
- LWC lwc = event.getLWC();
- Protection protection = event.getProtection();
-- Player player = event.getPlayer();
-+ LWCPlayer player = lwc.wrapPlayer(event.getPlayer());
-
-- Action action = lwc.getMemoryDatabase().getAction(""forceowner"", player.getName());
-+ Action action = player.getAction(""forceowner"");
- String newOwner = action.getData();
-
- protection.setOwner(newOwner);
-@@ -106,10 +107,15 @@ public void onCommand(LWCCommandEvent event) {
- return;
+ if (this.DefaultMushroom > 0)
+ {
+- //Red mushroom
+- resource = new Resource(ResourceType.Plant, DefaultMaterial.RED_MUSHROOM.id, 0, 0, this.DefaultMushroom, TCDefaultValues.redMushroomDepositRarity.intValue(), TCDefaultValues.redMushroomDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id});
++ // Red mushroom
++ resource = Resource.create(worldConfig, PlantGen.class, DefaultMaterial.RED_MUSHROOM.id, this.DefaultMushroom, TCDefaultValues.redMushroomDepositRarity.intValue(), TCDefaultValues.redMushroomDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+
+- //Brown mushroom
+- resource = new Resource(ResourceType.Plant, DefaultMaterial.BROWN_MUSHROOM.id, 0, 0, this.DefaultMushroom, TCDefaultValues.brownMushroomDepositRarity.intValue(), TCDefaultValues.brownMushroomDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id});
++ // Brown mushroom
++ resource = Resource.create(worldConfig, PlantGen.class, DefaultMaterial.BROWN_MUSHROOM.id, this.DefaultMushroom, TCDefaultValues.brownMushroomDepositRarity.intValue(), TCDefaultValues.brownMushroomDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
}
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String newOwner = args[1];
-
-- lwc.getMemoryDatabase().registerAction(""forceowner"", player.getName(), newOwner);
-+ Action action = new Action();
-+ action.setName(""forceowner"");
-+ action.setPlayer(player);
-+ action.setData(newOwner);
-+ player.addAction(action);
-+
- lwc.sendLocale(sender, ""protection.admin.forceowner.finalize"", ""player"", newOwner);
-
- return;
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/create/CreateModule.java b/modules/core/src/main/java/com/griefcraft/modules/create/CreateModule.java
-index 408b80120..32f56cd3d 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/create/CreateModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/create/CreateModule.java
-@@ -20,6 +20,7 @@
- import com.griefcraft.lwc.LWC;
- import com.griefcraft.model.AccessRight;
- import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.model.ProtectionTypes;
- import com.griefcraft.scripting.JavaModule;
-@@ -29,7 +30,6 @@
- import com.griefcraft.scripting.event.LWCProtectionInteractEvent;
- import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
- import com.griefcraft.scripting.event.LWCProtectionRegistrationPostEvent;
--import com.griefcraft.sql.MemDB;
- import com.griefcraft.sql.PhysDB;
- import com.griefcraft.util.Colors;
- import com.griefcraft.util.StringUtils;
-@@ -76,16 +76,15 @@ public void onBlockInteract(LWCBlockInteractEvent event) {
-
- LWC lwc = event.getLWC();
- Block block = event.getBlock();
-- Player player = event.getPlayer();
-+ LWCPlayer player = lwc.wrapPlayer(event.getPlayer());
-
- if (!lwc.isProtectable(block)) {
- return;
+ if (this.DefaultGrass > 0)
+ {
+- //Grass
+- resource = new Resource(ResourceType.Grass, DefaultMaterial.LONG_GRASS.id, 1, 0, this.DefaultGrass, TCDefaultValues.longGrassDepositRarity.intValue(), 0, 0, new int[]{DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id});
++ // Grass
++ resource = Resource.create(worldConfig, GrassGen.class, DefaultMaterial.LONG_GRASS.id, 1, this.DefaultGrass, TCDefaultValues.longGrassDepositRarity.intValue(), DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
}
- PhysDB physDb = lwc.getPhysicalDatabase();
-- MemDB memDb = lwc.getMemoryDatabase();
-
-- Action action = memDb.getAction(""create"", player.getName());
-+ Action action = player.getAction(""create"");
- String actionData = action.getData();
- String[] split = actionData.split("" "");
- String protectionType = split[0].toLowerCase();
-@@ -107,8 +106,8 @@ public void onBlockInteract(LWCBlockInteractEvent event) {
- int blockZ = block.getZ();
-
- lwc.removeModes(player);
-- Result registerProtection = lwc.getModuleLoader().dispatchEvent(Event.REGISTER_PROTECTION, player, block);
-- LWCProtectionRegisterEvent evt = new LWCProtectionRegisterEvent(player, block);
-+ Result registerProtection = lwc.getModuleLoader().dispatchEvent(Event.REGISTER_PROTECTION, player.getBukkitPlayer(), block);
-+ LWCProtectionRegisterEvent evt = new LWCProtectionRegisterEvent(player.getBukkitPlayer(), block);
- lwc.getModuleLoader().dispatchEvent(evt);
-
- // another plugin cancelled the registration
-@@ -126,7 +125,7 @@ public void onBlockInteract(LWCBlockInteractEvent event) {
- String password = lwc.encrypt(protectionData);
-
- protection = physDb.registerProtection(block.getTypeId(), ProtectionTypes.PASSWORD, worldName, playerName, password, blockX, blockY, blockZ);
-- memDb.registerPlayer(playerName, protection.getId());
-+ player.addAccessibleProtection(protection);
-
- lwc.sendLocale(player, ""protection.interact.create.finalize"");
- lwc.sendLocale(player, ""protection.interact.create.password"");
-@@ -234,7 +233,7 @@ public void onCommand(LWCCommandEvent event) {
- return;
+ if (this.DefaultDeadBrush > 0)
+ {
+- //Dead Bush
+- resource = new Resource(ResourceType.Grass, DefaultMaterial.DEAD_BUSH.id, 0, 0, this.DefaultDeadBrush, TCDefaultValues.deadBushDepositRarity.intValue(), 0, 0, new int[]{DefaultMaterial.SAND.id});
++ // Dead Bush
++ resource = Resource.create(worldConfig, GrassGen.class, DefaultMaterial.DEAD_BUSH.id, 0, this.DefaultDeadBrush, TCDefaultValues.deadBushDepositRarity.intValue(), DefaultMaterial.SAND.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
}
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
+- //Pumpkin
+- resource = new Resource(ResourceType.Plant, DefaultMaterial.PUMPKIN.id, 0, 0, TCDefaultValues.pumpkinDepositFrequency.intValue(), TCDefaultValues.pumpkinDepositRarity.intValue(), TCDefaultValues.pumpkinDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.GRASS.id});
++ // Pumpkin
++ resource = Resource.create(worldConfig, PlantGen.class, DefaultMaterial.PUMPKIN.id, TCDefaultValues.pumpkinDepositFrequency.intValue(), TCDefaultValues.pumpkinDepositRarity.intValue(), TCDefaultValues.pumpkinDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.GRASS.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
- String full = StringUtils.join(args, 0);
- String type = args[0].toLowerCase();
-@@ -272,12 +271,15 @@ public void onCommand(LWCCommandEvent event) {
- return;
+-
+ if (this.DefaultReed > 0)
+ {
+- //Reed
+- resource = new Resource(ResourceType.Reed, DefaultMaterial.SUGAR_CANE_BLOCK.id, 0, 0, this.DefaultReed, TCDefaultValues.reedDepositRarity.intValue(), TCDefaultValues.reedDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id, DefaultMaterial.SAND.id});
++ // Reed
++ resource = Resource.create(worldConfig, ReedGen.class, DefaultMaterial.SUGAR_CANE_BLOCK.id, this.DefaultReed, TCDefaultValues.reedDepositRarity.intValue(), TCDefaultValues.reedDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.GRASS.id, DefaultMaterial.DIRT.id, DefaultMaterial.SAND.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
}
-- MemDB db = lwc.getMemoryDatabase();
-- db.unregisterAllActions(player.getName());
-- db.registerAction(""create"", player.getName(), full);
-+ Action action = new Action();
-+ action.setName(""create"");
-+ action.setPlayer(player);
-+ action.setData(full);
-+
-+ player.removeAllActions();
-+ player.addAction(action);
+-
+ if (this.DefaultCactus > 0)
+ {
+- //Cactus
+- resource = new Resource(ResourceType.Cactus, DefaultMaterial.CACTUS.id, 0, 0, this.DefaultCactus, TCDefaultValues.cactusDepositRarity.intValue(), TCDefaultValues.cactusDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.SAND.id});
++ // Cactus
++ resource = Resource.create(worldConfig, CactusGen.class, DefaultMaterial.CACTUS.id, this.DefaultCactus, TCDefaultValues.cactusDepositRarity.intValue(), TCDefaultValues.cactusDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.SAND.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+ }
+- if (biome == DefaultBiome.JUNGLE || biome == DefaultBiome.JUNGLE_HILLS) // Jungle and Jungle Hills
++ if (biome == DefaultBiome.JUNGLE || biome == DefaultBiome.JUNGLE_HILLS)
+ {
+- resource = new Resource(ResourceType.Vines, 0, 0, 0, TCDefaultValues.vinesFrequency.intValue(), TCDefaultValues.vinesRarity.intValue(), TCDefaultValues.vinesMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.VINE.id});
++ resource = Resource.create(worldConfig, VinesGen.class, TCDefaultValues.vinesFrequency.intValue(), TCDefaultValues.vinesRarity.intValue(), TCDefaultValues.vinesMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.VINE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
+ }
- lwc.sendLocale(player, ""protection.create.finalize"", ""type"", lwc.getLocale(type));
-- return;
- }
+- //Water source
+- resource = new Resource(ResourceType.Liquid, DefaultMaterial.WATER.id, 0, 0, TCDefaultValues.waterSourceDepositFrequency.intValue(), TCDefaultValues.waterSourceDepositRarity.intValue(), TCDefaultValues.waterSourceDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Water source
++ resource = Resource.create(worldConfig, LiquidGen.class, DefaultMaterial.WATER.id, TCDefaultValues.waterSourceDepositFrequency.intValue(), TCDefaultValues.waterSourceDepositRarity.intValue(), TCDefaultValues.waterSourceDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
- }
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/flag/BaseFlagModule.java b/modules/core/src/main/java/com/griefcraft/modules/flag/BaseFlagModule.java
-index 8d000e82f..92576dcde 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/flag/BaseFlagModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/flag/BaseFlagModule.java
-@@ -19,13 +19,13 @@
-
- import com.griefcraft.lwc.LWC;
- import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCCommandEvent;
- import com.griefcraft.scripting.event.LWCProtectionInteractEvent;
- import com.griefcraft.util.StringUtils;
- import org.bukkit.command.CommandSender;
--import org.bukkit.entity.Player;
+- //Lava source
+- resource = new Resource(ResourceType.Liquid, DefaultMaterial.LAVA.id, 0, 0, TCDefaultValues.lavaSourceDepositFrequency.intValue(), TCDefaultValues.lavaSourceDepositRarity.intValue(), TCDefaultValues.lavaSourceDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, new int[]{DefaultMaterial.STONE.id});
++ // Lava source
++ resource = Resource.create(worldConfig, LiquidGen.class, DefaultMaterial.LAVA.id, TCDefaultValues.lavaSourceDepositFrequency.intValue(), TCDefaultValues.lavaSourceDepositRarity.intValue(), TCDefaultValues.lavaSourceDepositMinAltitude.intValue(), this.worldConfig.WorldHeight, DefaultMaterial.STONE.id);
+ this.ResourceSequence[this.ResourceCount++] = resource;
- public class BaseFlagModule extends JavaModule {
+-
+ }
-@@ -37,9 +37,9 @@ public void onProtectionInteract(LWCProtectionInteractEvent event) {
+ protected void ReadConfigSettings()
+@@ -348,7 +355,6 @@ protected void ReadConfigSettings()
- LWC lwc = event.getLWC();
- Protection protection = event.getProtection();
-- Player player = event.getPlayer();
-+ LWCPlayer player = lwc.wrapPlayer(event.getPlayer());
+ this.BiomeRivers = ReadModSettings(TCDefaultValues.BiomeRivers.name(), this.DefaultRiver);
-- Action action = lwc.getMemoryDatabase().getAction(""flag"", player.getName());
-+ Action action = player.getAction(""flag"");
- String data = action.getData();
- event.setResult(Result.CANCEL);
+-
+ this.IsleInBiome = ReadModSettings(TCDefaultValues.IsleInBiome.name(), this.DefaultIsle);
+ this.BiomeIsBorder = ReadModSettings(TCDefaultValues.BiomeIsBorder.name(), this.DefaultBorder);
+ this.NotBorderNear = ReadModSettings(TCDefaultValues.NotBorderNear.name(), this.DefaultNotBorderNear);
+@@ -364,7 +370,6 @@ protected void ReadConfigSettings()
+ this.SurfaceBlock = ReadModSettings(TCDefaultValues.SurfaceBlock.name(), this.DefaultSurfaceBlock);
+ this.GroundBlock = ReadModSettings(TCDefaultValues.GroundBlock.name(), this.DefaultGroundBlock);
-@@ -99,7 +99,7 @@ public void onCommand(LWCCommandEvent event) {
- return;
- }
+-
+ this.UseWorldWaterLevel = ReadSettings(TCDefaultValues.UseWorldWaterLevel);
+ this.waterLevelMax = ReadSettings(TCDefaultValues.WaterLevelMax);
+ this.waterLevelMin = ReadSettings(TCDefaultValues.WaterLevelMin);
+@@ -389,7 +394,6 @@ protected void ReadConfigSettings()
+ if (DefaultBiome.getBiome(this.Biome.getId()) == null)
+ {
+ // Only for custom biomes
+- // System.out.println(""Reading mobs for ""+this.Name); // debug
+ this.spawnMonstersAddDefaults = ReadModSettings(""spawnMonstersAddDefaults"", true);
+ this.spawnMonsters = ReadModSettings(""spawnMonsters"", new ArrayList());
+ this.spawnCreaturesAddDefaults = ReadModSettings(""spawnCreaturesAddDefaults"", true);
+@@ -487,33 +491,30 @@ private void ReadResourceSettings()
+ for (Map.Entry entry : this.SettingsCache.entrySet())
+ {
+ String key = entry.getKey();
+- for (ResourceType type : ResourceType.values())
++ int start = key.indexOf(""("");
++ int end = key.lastIndexOf("")"");
++ if (start != -1 && end != -1)
+ {
+- if (key.startsWith(type.name()))
++ String name = key.substring(0, start);
++ String[] props = ReadComplexString(key.substring(start + 1, end));
++
++ Resource res = TerrainControl.getResourcesManager().getResource(name, this, Arrays.asList(props));
++
++ if (res != null)
+ {
+- int start = key.indexOf(""("");
+- int end = key.lastIndexOf("")"");
+- if (start != -1 && end != -1)
++
++ if (res.getType() == ResourceType.saplingResource)
+ {
+- Resource res = new Resource(type);
+- String[] props = ReadComplexString(key.substring(start + 1, end));
+-
+- if (type.Generator.ReadFromString(res, props, this))
+- {
+- if (res.Type == ResourceType.Sapling)
+- {
+- if (res.BlockData == -1)
+- this.SaplingResource = res;
+- else
+- this.SaplingTypes[res.BlockData] = res;
+-
+- } else
+- {
+- LineNumbers.add(Integer.valueOf(entry.getValue()));
+- this.ResourceSequence[this.ResourceCount++] = res;
+- }
+- } else
+- System.out.println(""TerrainControl: wrong resource "" + type.name() + key);
++ SaplingGen sapling = (SaplingGen) res;
++ if (sapling.saplingType == -1)
++ this.SaplingResource = sapling;
++ else
++ this.SaplingTypes[sapling.saplingType] = sapling;
++
++ } else if (res.getType() == ResourceType.biomeConfigResource)
++ {
++ LineNumbers.add(Integer.valueOf(entry.getValue()));
++ this.ResourceSequence[this.ResourceCount++] = res;
+ }
+ }
+ }
+@@ -541,43 +542,30 @@ private void ReadResourceSettings()
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String flagName = args[0];
- String type = args[1].toLowerCase();
- String internalType; // + or -
-@@ -142,8 +142,14 @@ public void onCommand(LWCCommandEvent event) {
- return;
+ private void ReadCustomObjectSettings()
+ {
+- CustomObjectsCompiled = new ArrayList();
++ biomeObjects = new ArrayList();
++ biomeObjectStrings = new ArrayList();
+
+ // Read from BiomeObjects setting
+- String customObjectsString = ReadModSettings(""biomeobjects"","""");
+- if(customObjectsString.length() > 0)
++ String biomeObjectsValue = ReadModSettings(""biomeobjects"", """");
++ if (biomeObjectsValue.length() > 0)
+ {
+- String[] customObjects = customObjectsString.split("","");
+- for (String customObject : customObjects)
++ String[] customObjectStrings = biomeObjectsValue.split("","");
++ for (String customObjectString : customObjectStrings)
+ {
+- CustomObjectCompiled object = ObjectsStore.CompileString(customObject, worldConfig.CustomObjectsDirectory);
+- if (object == null)
+- object = ObjectsStore.CompileString(customObject, ObjectsStore.GlobalDirectory);
++ CustomObject object = TerrainControl.getCustomObjectManager().getObjectFromString(customObjectString, worldConfig);
+ if (object != null)
+- CustomObjectsCompiled.add(object);
++ {
++ biomeObjects.add(object);
++ biomeObjectStrings.add(customObjectString);
++ }
+ }
}
+-
+- // Read from random places in BiomeConfig
+- // TODO: Remove this in 2.4, as it's quite resource intensive
+- for (Map.Entry entry : this.SettingsCache.entrySet())
+- {
+- CustomObjectCompiled object = ObjectsStore.CompileString(entry.getKey(), worldConfig.CustomObjectsDirectory);
+- if (object == null)
+- object = ObjectsStore.CompileString(entry.getKey(), ObjectsStore.GlobalDirectory);
+- if (object != null)
+- CustomObjectsCompiled.add(object);
+-
+- }
+-
+ }
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-- lwc.getMemoryDatabase().registerAction(""flag"", player.getName(), internalType + flagName);
-+ Action action = new Action();
-+ action.setName(""flag"");
-+ action.setPlayer(player);
-+ action.setData(internalType + flagName);
-+
-+ player.removeAllActions();
-+ player.addAction(action);
-+
- lwc.sendLocale(sender, ""protection.flag.finalize"");
-
- return;
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/free/FreeModule.java b/modules/core/src/main/java/com/griefcraft/modules/free/FreeModule.java
-index d880ebc4f..86dca114e 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/free/FreeModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/free/FreeModule.java
-@@ -18,6 +18,8 @@
- package com.griefcraft.modules.free;
-
- import com.griefcraft.lwc.LWC;
-+import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCBlockInteractEvent;
-@@ -110,19 +112,19 @@ public void onCommand(LWCCommandEvent event) {
- }
+-
+ protected void WriteConfigSettings() throws IOException
+ {
+ WriteTitle(this.Name + "" biome config"");
- String type = args[0].toLowerCase();
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
+-
+ WriteComment(""Biome size from 0 to GenerationDepth. Show in what zoom level biome will be generated (see GenerationDepth)"");
+ WriteComment(""Higher numbers=Smaller% of world / Lower numbers=Bigger % of world"");
+ WriteComment(""Don`t work on Ocean and River (frozen versions too) biomes until not added as normal biome."");
+@@ -601,7 +589,6 @@ protected void WriteConfigSettings() throws IOException
+ WriteValue(TCDefaultValues.BiomeRivers.name(), this.BiomeRivers);
+ this.WriteNewLine();
- if (type.equals(""protection"") || type.equals(""chest"") || type.equals(""furnace"") || type.equals(""dispenser"")) {
-- if (lwc.getMemoryDatabase().hasPendingChest(player.getName())) {
-- lwc.sendLocale(sender, ""protection.general.pending"");
-- return;
-- }
-+ Action action = new Action();
-+ action.setName(""free"");
-+ action.setPlayer(player);
-+
-+ player.removeAllActions();
-+ player.addAction(action);
-
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-- lwc.getMemoryDatabase().registerAction(""free"", player.getName());
- lwc.sendLocale(sender, ""protection.remove.protection.finalize"");
- } else if (type.equals(""modes"")) {
-- lwc.getMemoryDatabase().unregisterAllModes(player.getName());
-+ player.disableAllModes();
- lwc.sendLocale(sender, ""protection.remove.modes.finalize"");
- } else {
- lwc.sendSimpleUsage(sender, ""/lwc -r "");
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/info/InfoModule.java b/modules/core/src/main/java/com/griefcraft/modules/info/InfoModule.java
-index 840d8e71d..24a8f6e21 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/info/InfoModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/info/InfoModule.java
-@@ -18,6 +18,8 @@
- package com.griefcraft.modules.info;
-
- import com.griefcraft.lwc.LWC;
-+import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCBlockInteractEvent;
-@@ -99,7 +101,7 @@ public void onCommand(LWCCommandEvent event) {
- return;
- }
+-
+ WriteComment(""Biome name list where this biome will be spawned as isle. Like Mushroom isle in Ocean. This work only if this biome is in IsleBiomes in world config"");
+ WriteValue(TCDefaultValues.IsleInBiome.name(), this.IsleInBiome);
+ this.WriteNewLine();
+@@ -625,7 +612,6 @@ protected void WriteConfigSettings() throws IOException
+ WriteValue(TCDefaultValues.ReplaceToBiomeName.name(), this.ReplaceBiomeName);
+ this.WriteNewLine();
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String type = ""info"";
+-
+ WriteTitle(""Terrain Generator Variables"");
+ WriteComment(""BiomeHeight mean how much height will be added in terrain generation"");
+ WriteComment(""It is double value from -10.0 to 10.0"");
+@@ -668,7 +654,6 @@ protected void WriteConfigSettings() throws IOException
+ WriteComment(""Make empty layer above bedrock layer. "");
+ WriteHeightSettings();
- if (args.length > 0) {
-@@ -107,8 +109,13 @@ public void onCommand(LWCCommandEvent event) {
- }
+-
+ this.WriteNewLine();
+ WriteComment(""Surface block id"");
+ WriteValue(TCDefaultValues.SurfaceBlock.name(), this.SurfaceBlock);
+@@ -691,7 +676,6 @@ protected void WriteConfigSettings() throws IOException
+ WriteComment(""BlockId used as ice"");
+ WriteValue(TCDefaultValues.IceBlock.name(), this.iceBlock);
- if (type.equals(""info"")) {
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-- lwc.getMemoryDatabase().registerAction(""info"", player.getName());
-+ Action action = new Action();
-+ action.setName(""info"");
-+ action.setPlayer(player);
+-
+ this.WriteNewLine();
+ WriteComment(""Replace Variable: (BlockIdFrom,BlockIdTo[,BlockDataTo,minHeight,maxHeight])"");
+ WriteComment(""Example :"");
+@@ -713,7 +697,7 @@ protected void WriteConfigSettings() throws IOException
+ this.WriteNewLine();
+ this.WriteComment(""Biome grass color"");
+ this.WriteColorValue(TCDefaultValues.GrassColor.name(), this.GrassColor);
+-
+
-+ player.removeAllActions();
-+ player.addAction(action);
-+
- lwc.sendLocale(player, ""protection.info.finalize"");
- }
+ this.WriteNewLine();
+ this.WriteComment(""Whether the grass color is a multiplier"");
+ this.WriteComment(""If you set it to true, the color will be based on this value, the BiomeTemperature and the BiomeWetness"");
+@@ -786,7 +770,6 @@ protected void WriteConfigSettings() throws IOException
+ this.WriteComment(""These objects will spawn when using the UseBiome keyword."");
+ this.WriteCustomObjects();
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/modes/DropTransferModule.java b/modules/core/src/main/java/com/griefcraft/modules/modes/DropTransferModule.java
-index 7e1e90db0..cbd0eb625 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/modes/DropTransferModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/modes/DropTransferModule.java
-@@ -18,6 +18,9 @@
- package com.griefcraft.modules.modes;
-
- import com.griefcraft.lwc.LWC;
-+import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
-+import com.griefcraft.model.Mode;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCCommandEvent;
-@@ -48,8 +51,8 @@ public void load(LWC lwc) {
- * @param player
- * @return
- */
-- private boolean isPlayerDropTransferring(String player) {
-- return lwc.getMemoryDatabase().hasMode(player, ""+dropTransfer"");
-+ private boolean isPlayerDropTransferring(LWCPlayer player) {
-+ return player.hasMode(""+dropTransfer"");
+-
+ if (DefaultBiome.getBiome(this.Biome.getId()) != null)
+ {
+ this.WriteTitle(""MOB SPAWNING"");
+@@ -862,7 +845,6 @@ private void WriteHeightSettings() throws IOException
+ this.WriteValue(TCDefaultValues.CustomHeightControl.name(), output);
}
- /**
-@@ -58,8 +61,9 @@ private boolean isPlayerDropTransferring(String player) {
- * @param player
- * @return
- */
-- private int getPlayerDropTransferTarget(String player) {
-- String target = lwc.getMemoryDatabase().getModeData(player, ""dropTransfer"");
-+ private int getPlayerDropTransferTarget(LWCPlayer player) {
-+ Mode mode = player.getMode(""dropTransfer"");
-+ String target = mode.getData();
-
- try {
- return Integer.parseInt(target);
-@@ -70,14 +74,15 @@ private int getPlayerDropTransferTarget(String player) {
+-
+ private void WriteModReplaceSettings() throws IOException
+ {
+ if (this.ReplaceCount == 0)
+@@ -914,22 +896,20 @@ private void WriteModReplaceSettings() throws IOException
+ private void WriteResources() throws IOException
+ {
+ for (int i = 0; i < this.ResourceCount; i++)
+- this.WriteValue(this.ResourceSequence[i].Type.Generator.WriteToString(this.ResourceSequence[i]));
++ {
++ this.WriteValue(this.ResourceSequence[i].makeString());
++ }
}
- @Override
-- public Result onDropItem(LWC lwc, Player player, Item item, ItemStack itemStack) {
-- int protectionId = getPlayerDropTransferTarget(player.getName());
-+ public Result onDropItem(LWC lwc, Player bPlayer, Item item, ItemStack itemStack) {
-+ LWCPlayer player = lwc.wrapPlayer(bPlayer);
-+ int protectionId = getPlayerDropTransferTarget(player);
-
- if (protectionId == -1) {
- return DEFAULT;
- }
-
-- if (!isPlayerDropTransferring(player.getName())) {
-+ if (!isPlayerDropTransferring(player)) {
- return DEFAULT;
- }
-
-@@ -85,7 +90,7 @@ public Result onDropItem(LWC lwc, Player player, Item item, ItemStack itemStack)
-
- if (protection == null) {
- player.sendMessage(Colors.Red + ""Protection no longer exists"");
-- lwc.getMemoryDatabase().unregisterMode(player.getName(), ""dropTransfer"");
-+ player.disableMode(player.getMode(""dropTransfer""));
- return DEFAULT;
+ private void WriteCustomObjects() throws IOException
+ {
+ StringBuilder builder = new StringBuilder();
+- for (CustomObjectCompiled objectCompiled : CustomObjectsCompiled)
++ for (String objectString : biomeObjectStrings)
+ {
+- builder.append(objectCompiled.Name);
+- if(!objectCompiled.ChangedSettings.equals(""""))
+- {
+- builder.append(""("" + objectCompiled.ChangedSettings + "")"");
+- }
++ builder.append(objectString);
+ builder.append(',');
}
+- if(builder.length() > 0)
++ if (builder.length() > 0)
+ {
+ // Delete last char
+ builder.deleteCharAt(builder.length() - 1);
+@@ -940,11 +920,11 @@ private void WriteCustomObjects() throws IOException
+ private void WriteSaplingSettings() throws IOException
+ {
+ if (this.SaplingResource != null)
+- this.WriteValue(ResourceType.Sapling.Generator.WriteToString(this.SaplingResource));
++ this.WriteValue(SaplingResource.makeString());
-@@ -94,7 +99,7 @@ public Result onDropItem(LWC lwc, Player player, Item item, ItemStack itemStack)
-
- if (world == null) {
- player.sendMessage(Colors.Red + ""Invalid world!"");
-- lwc.getMemoryDatabase().unregisterMode(player.getName(), ""dropTransfer"");
-+ player.disableMode(player.getMode(""dropTransfer""));
- return DEFAULT;
- }
+ for (Resource res : this.SaplingTypes)
+ if (res != null)
+- this.WriteValue(ResourceType.Sapling.Generator.WriteToString(res));
++ this.WriteValue(res.makeString());
-@@ -105,36 +110,46 @@ public Result onDropItem(LWC lwc, Player player, Item item, ItemStack itemStack)
- player.sendMessage(""Chest could not hold all the items! Have the remaining items back."");
+ }
- for (ItemStack temp : remaining.values()) {
-- player.getInventory().addItem(temp);
-+ bPlayer.getInventory().addItem(temp);
+@@ -976,11 +956,12 @@ protected void CorrectSettings()
+ protected void RenameOldSettings()
+ {
+ // Old values from WorldConfig
+- TCDefaultValues[] copyFromWorld = {TCDefaultValues.MaxAverageHeight, TCDefaultValues.MaxAverageDepth, TCDefaultValues.Volatility1, TCDefaultValues.Volatility2, TCDefaultValues.VolatilityWeight1, TCDefaultValues.VolatilityWeight2, TCDefaultValues.DisableBiomeHeight, TCDefaultValues.CustomHeightControl};
++ TCDefaultValues[] copyFromWorld = { TCDefaultValues.MaxAverageHeight, TCDefaultValues.MaxAverageDepth, TCDefaultValues.Volatility1, TCDefaultValues.Volatility2, TCDefaultValues.VolatilityWeight1, TCDefaultValues.VolatilityWeight2, TCDefaultValues.DisableBiomeHeight, TCDefaultValues.CustomHeightControl };
+ for (TCDefaultValues value : copyFromWorld)
+ if (this.worldConfig.SettingsCache.containsKey(value.name().toLowerCase()))
+ {
+- //this.SettingsCache.put(value.name(), this.worldConfig.SettingsCache.get(value.name().toLowerCase()));
++ // this.SettingsCache.put(value.name(),
++ // this.worldConfig.SettingsCache.get(value.name().toLowerCase()));
+ this.SettingsCache.put(value.name().toLowerCase(), this.worldConfig.SettingsCache.get(value.name().toLowerCase()));
}
- }
-- player.updateInventory(); // if they're in the chest and dropping items, this is required
-+ bPlayer.updateInventory(); // if they're in the chest and dropping items, this is required
- item.remove();
- return DEFAULT;
- }
+@@ -994,27 +975,29 @@ protected void RenameOldSettings()
+ }
- @Override
-- public Result onProtectionInteract(LWC lwc, Player player, Protection protection, List actions, boolean canAccess, boolean canAdmin) {
-+ public Result onProtectionInteract(LWC lwc, Player bPlayer, Protection protection, List actions, boolean canAccess, boolean canAdmin) {
- if (!actions.contains(""dropTransferSelect"")) {
- return DEFAULT;
}
-
-+ LWCPlayer player = lwc.wrapPlayer(bPlayer);
+-
+
- if (!canAccess) {
- lwc.sendLocale(player, ""protection.interact.dropxfer.noaccess"");
- } else {
- if (protection.getBlockId() != Material.CHEST.getId()) {
- lwc.sendLocale(player, ""protection.interact.dropxfer.notchest"");
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-+ player.removeAllActions();
- return CANCEL;
+ // CustomTreeChance
+ int customTreeChance = 0; // Default value
+- if(worldConfig.SettingsCache.containsKey(""customtreechance""))
++ if (worldConfig.SettingsCache.containsKey(""customtreechance""))
+ {
+- try {
++ try
++ {
+ customTreeChance = Integer.parseInt(worldConfig.SettingsCache.get(""customtreechance""));
+- } catch(NumberFormatException e) {
++ } catch (NumberFormatException e)
++ {
+ // Ignore, so leave customTreeChance at 0
}
-
-- lwc.getMemoryDatabase().registerMode(player.getName(), ""dropTransfer"", protection.getId() + """");
-- lwc.getMemoryDatabase().registerMode(player.getName(), ""+dropTransfer"");
-+ Mode mode = new Mode();
-+ mode.setName(""dropTransfer"");
-+ mode.setData(protection.getId() + """");
-+ mode.setPlayer(bPlayer);
-+ player.enableMode(mode);
-+ mode = new Mode();
-+ mode.setName(""+dropTransfer"");
-+ mode.setPlayer(bPlayer);
-+ player.enableMode(mode);
-+
- lwc.sendLocale(player, ""protection.interact.dropxfer.finalize"");
}
-
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName()); // ignore the persist mode
-+ player.removeAllActions(); // ignore the persist mode
- return DEFAULT;
- }
-
-@@ -145,7 +160,7 @@ public Result onBlockInteract(LWC lwc, Player player, Block block, List
+- if(customTreeChance == 100)
++ if (customTreeChance == 100)
+ {
+ this.SettingsCache.put(""Sapling(All,UseWorld,100)"", ""-"");
+ }
+- if(customTreeChance > 0 && customTreeChance < 100)
++ if (customTreeChance > 0 && customTreeChance < 100)
+ {
+- this.SettingsCache.put(""Sapling(0,UseWorld,""+customTreeChance+"",BigTree,10,Tree,100)"", ""-""); // Oak
+- this.SettingsCache.put(""Sapling(1,UseWorld,""+customTreeChance+"",Taiga2,100)"", ""-""); // Redwood
+- this.SettingsCache.put(""Sapling(2,UseWorld,""+customTreeChance+"",Forest,100)"", ""-""); // Birch
+- this.SettingsCache.put(""Sapling(3,UseWorld,""+customTreeChance+"",CocoaTree,100)"", ""-""); // Jungle
++ this.SettingsCache.put(""Sapling(0,UseWorld,"" + customTreeChance + "",BigTree,10,Tree,100)"", ""-""); // Oak
++ this.SettingsCache.put(""Sapling(1,UseWorld,"" + customTreeChance + "",Taiga2,100)"", ""-""); // Redwood
++ this.SettingsCache.put(""Sapling(2,UseWorld,"" + customTreeChance + "",Forest,100)"", ""-""); // Birch
++ this.SettingsCache.put(""Sapling(3,UseWorld,"" + customTreeChance + "",CocoaTree,100)"", ""-""); // Jungle
}
- lwc.sendLocale(player, ""protection.interact.dropxfer.notprotected"");
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-+ lwc.removeModes(player);
+ // ReplacedBlocks
+@@ -1088,11 +1071,9 @@ protected void RenameOldSettings()
- return DEFAULT;
+ this.SettingsCache.put(""ReplacedBlocks"" + "":"" + output.substring(0, output.length() - 1), """");
+
+-
+ }
}
-@@ -164,7 +179,7 @@ public void onCommand(LWCCommandEvent event) {
- CommandSender sender = event.getSender();
- String[] args = event.getArgs();
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String mode = args[0].toLowerCase();
+-
+ private int DefaultTrees = 1;
+ private int DefaultFlowers = 2;
+ private int DefaultGrass = 10;
+@@ -1128,161 +1109,160 @@ private void InitDefaults()
+ this.DefaultBiomeTemperature = this.Biome.getTemperature();
+ this.DefaultBiomeWetness = this.Biome.getWetness();
- if (!mode.equals(""droptransfer"")) {
-@@ -185,40 +200,48 @@ public void onCommand(LWCCommandEvent event) {
- String playerName = player.getName();
+-
+ switch (this.Biome.getId())
+ {
+- case 0:
+- this.DefaultColor = ""0x3333FF"";
+- break;
+- case 1:
+- {
+- this.DefaultTrees = 0;
+- this.DefaultFlowers = 4;
+- this.DefaultGrass = 20;
+- this.DefaultColor = ""0x999900"";
+- break;
+- }
+- case 2:
+- {
+- this.DefaultTrees = 0;
+- this.DefaultDeadBrush = 4;
+- this.DefaultGrass = 0;
+- this.DefaultReed = 10;
+- this.DefaultCactus = 10;
+- this.DefaultColor = ""0xFFCC33"";
+- break;
+- }
+- case 3:
+- this.DefaultColor = ""0x333300"";
+- break;
+- case 4:
+- {
+- this.DefaultTrees = 10;
+- this.DefaultGrass = 15;
+- this.DefaultColor = ""0x00FF00"";
+- break;
+- }
+- case 5:
+- {
+- this.DefaultTrees = 10;
+- this.DefaultGrass = 10;
+- this.DefaultColor = ""0x007700"";
+- break;
+- }
+- case 6:
+- {
+- this.DefaultTrees = 2;
+- this.DefaultFlowers = -999;
+- this.DefaultDeadBrush = 1;
+- this.DefaultMushroom = 8;
+- this.DefaultReed = 10;
+- this.DefaultClay = 1;
+- this.DefaultWaterLily = 1;
+- this.DefaultColor = ""0x99CC66"";
+- this.DefaultWaterColorMultiplier = ""0xe0ffae"";
+- this.DefaultGrassColor = ""0x7E6E7E"";
+- this.DefaultFoliageColor = ""0x7E6E7E"";
+- break;
+- }
+- case 7:
+- this.DefaultSize = 8;
+- this.DefaultRarity = 95;
+- this.DefaultIsle.add(DefaultBiome.SWAMPLAND.Name);
+- this.DefaultColor = ""0x00CCCC"";
+- case 8:
+- case 9:
+-
+- break;
+- case 10:
+- this.DefaultColor = ""0xFFFFFF"";
+- break;
+- case 11:
+- this.DefaultColor = ""0x66FFFF"";
+- break;
+- case 12:
+- this.DefaultColor = ""0xCCCCCC"";
+- break;
+- case 13:
+- this.DefaultColor = ""0xCC9966"";
+- break;
+- case 14:
+- {
+- this.DefaultSurfaceBlock = (byte) DefaultMaterial.MYCEL.id;
+- this.DefaultMushroom = 1;
+- this.DefaultGrass = 0;
+- this.DefaultFlowers = 0;
+- this.DefaultTrees = 0;
+- this.DefaultRarity = 1;
+- this.DefaultRiver = false;
+- this.DefaultSize = 6;
+- this.DefaultIsle.add(DefaultBiome.OCEAN.Name);
+- this.DefaultColor = ""0xFF33CC"";
+- this.DefaultWaterLily = 1;
+- break;
+- }
+- case 15:
+- {
+- this.DefaultRiver = false;
+- this.DefaultSize = 9;
+- this.DefaultBorder.add(DefaultBiome.MUSHROOM_ISLAND.Name);
+- this.DefaultColor = ""0xFF9999"";
+- break;
+- }
+- case 16:
+- this.DefaultTrees = 0;
+- this.DefaultSize = 8;
+- this.DefaultBorder.add(DefaultBiome.OCEAN.Name);
+- this.DefaultNotBorderNear.add(DefaultBiome.RIVER.Name);
+- this.DefaultNotBorderNear.add(DefaultBiome.SWAMPLAND.Name);
+- this.DefaultNotBorderNear.add(DefaultBiome.EXTREME_HILLS.Name);
+- this.DefaultNotBorderNear.add(DefaultBiome.MUSHROOM_ISLAND.Name);
+- this.DefaultColor = ""0xFFFF00"";
+- break;
+- case 17:
+- this.DefaultSize = 6;
+- this.DefaultRarity = 97;
+- this.DefaultIsle.add(DefaultBiome.DESERT.Name);
+- this.DefaultTrees = 0;
+- this.DefaultDeadBrush = 4;
+- this.DefaultGrass = 0;
+- this.DefaultReed = 50;
+- this.DefaultCactus = 10;
+- this.DefaultColor = ""0x996600"";
+- break;
+- case 18:
+- this.DefaultSize = 6;
+- this.DefaultRarity = 97;
+- this.DefaultIsle.add(DefaultBiome.FOREST.Name);
+- this.DefaultTrees = 10;
+- this.DefaultGrass = 15;
+- this.DefaultColor = ""0x009900"";
+- break;
+- case 19:
+- this.DefaultSize = 6;
+- this.DefaultRarity = 97;
+- this.DefaultIsle.add(DefaultBiome.TAIGA.Name);
+- this.DefaultTrees = 10;
+- this.DefaultGrass = 10;
+- this.DefaultColor = ""0x003300"";
+- break;
+- case 20:
+- this.DefaultSize = 8;
+- this.DefaultBorder.add(DefaultBiome.EXTREME_HILLS.Name);
+- this.DefaultColor = ""0x666600"";
+- break;
+- case 21:
+- this.DefaultTrees = 50;
+- this.DefaultGrass = 25;
+- this.DefaultFlowers = 4;
+- this.DefaultColor = ""0xCC6600"";
+- break;
+- case 22:
+- this.DefaultTrees = 50;
+- this.DefaultGrass = 25;
+- this.DefaultFlowers = 4;
+- this.DefaultColor = ""0x663300"";
+- this.DefaultIsle.add(DefaultBiome.JUNGLE.Name);
+- break;
++ case 0:
++ this.DefaultColor = ""0x3333FF"";
++ break;
++ case 1:
++ {
++ this.DefaultTrees = 0;
++ this.DefaultFlowers = 4;
++ this.DefaultGrass = 20;
++ this.DefaultColor = ""0x999900"";
++ break;
++ }
++ case 2:
++ {
++ this.DefaultTrees = 0;
++ this.DefaultDeadBrush = 4;
++ this.DefaultGrass = 0;
++ this.DefaultReed = 10;
++ this.DefaultCactus = 10;
++ this.DefaultColor = ""0xFFCC33"";
++ break;
++ }
++ case 3:
++ this.DefaultColor = ""0x333300"";
++ break;
++ case 4:
++ {
++ this.DefaultTrees = 10;
++ this.DefaultGrass = 15;
++ this.DefaultColor = ""0x00FF00"";
++ break;
++ }
++ case 5:
++ {
++ this.DefaultTrees = 10;
++ this.DefaultGrass = 10;
++ this.DefaultColor = ""0x007700"";
++ break;
++ }
++ case 6:
++ {
++ this.DefaultTrees = 2;
++ this.DefaultFlowers = -999;
++ this.DefaultDeadBrush = 1;
++ this.DefaultMushroom = 8;
++ this.DefaultReed = 10;
++ this.DefaultClay = 1;
++ this.DefaultWaterLily = 1;
++ this.DefaultColor = ""0x99CC66"";
++ this.DefaultWaterColorMultiplier = ""0xe0ffae"";
++ this.DefaultGrassColor = ""0x7E6E7E"";
++ this.DefaultFoliageColor = ""0x7E6E7E"";
++ break;
++ }
++ case 7:
++ this.DefaultSize = 8;
++ this.DefaultRarity = 95;
++ this.DefaultIsle.add(DefaultBiome.SWAMPLAND.Name);
++ this.DefaultColor = ""0x00CCCC"";
++ case 8:
++ case 9:
++
++ break;
++ case 10:
++ this.DefaultColor = ""0xFFFFFF"";
++ break;
++ case 11:
++ this.DefaultColor = ""0x66FFFF"";
++ break;
++ case 12:
++ this.DefaultColor = ""0xCCCCCC"";
++ break;
++ case 13:
++ this.DefaultColor = ""0xCC9966"";
++ break;
++ case 14:
++ {
++ this.DefaultSurfaceBlock = (byte) DefaultMaterial.MYCEL.id;
++ this.DefaultMushroom = 1;
++ this.DefaultGrass = 0;
++ this.DefaultFlowers = 0;
++ this.DefaultTrees = 0;
++ this.DefaultRarity = 1;
++ this.DefaultRiver = false;
++ this.DefaultSize = 6;
++ this.DefaultIsle.add(DefaultBiome.OCEAN.Name);
++ this.DefaultColor = ""0xFF33CC"";
++ this.DefaultWaterLily = 1;
++ break;
++ }
++ case 15:
++ {
++ this.DefaultRiver = false;
++ this.DefaultSize = 9;
++ this.DefaultBorder.add(DefaultBiome.MUSHROOM_ISLAND.Name);
++ this.DefaultColor = ""0xFF9999"";
++ break;
++ }
++ case 16:
++ this.DefaultTrees = 0;
++ this.DefaultSize = 8;
++ this.DefaultBorder.add(DefaultBiome.OCEAN.Name);
++ this.DefaultNotBorderNear.add(DefaultBiome.RIVER.Name);
++ this.DefaultNotBorderNear.add(DefaultBiome.SWAMPLAND.Name);
++ this.DefaultNotBorderNear.add(DefaultBiome.EXTREME_HILLS.Name);
++ this.DefaultNotBorderNear.add(DefaultBiome.MUSHROOM_ISLAND.Name);
++ this.DefaultColor = ""0xFFFF00"";
++ break;
++ case 17:
++ this.DefaultSize = 6;
++ this.DefaultRarity = 97;
++ this.DefaultIsle.add(DefaultBiome.DESERT.Name);
++ this.DefaultTrees = 0;
++ this.DefaultDeadBrush = 4;
++ this.DefaultGrass = 0;
++ this.DefaultReed = 50;
++ this.DefaultCactus = 10;
++ this.DefaultColor = ""0x996600"";
++ break;
++ case 18:
++ this.DefaultSize = 6;
++ this.DefaultRarity = 97;
++ this.DefaultIsle.add(DefaultBiome.FOREST.Name);
++ this.DefaultTrees = 10;
++ this.DefaultGrass = 15;
++ this.DefaultColor = ""0x009900"";
++ break;
++ case 19:
++ this.DefaultSize = 6;
++ this.DefaultRarity = 97;
++ this.DefaultIsle.add(DefaultBiome.TAIGA.Name);
++ this.DefaultTrees = 10;
++ this.DefaultGrass = 10;
++ this.DefaultColor = ""0x003300"";
++ break;
++ case 20:
++ this.DefaultSize = 8;
++ this.DefaultBorder.add(DefaultBiome.EXTREME_HILLS.Name);
++ this.DefaultColor = ""0x666600"";
++ break;
++ case 21:
++ this.DefaultTrees = 50;
++ this.DefaultGrass = 25;
++ this.DefaultFlowers = 4;
++ this.DefaultColor = ""0xCC6600"";
++ break;
++ case 22:
++ this.DefaultTrees = 50;
++ this.DefaultGrass = 25;
++ this.DefaultFlowers = 4;
++ this.DefaultColor = ""0x663300"";
++ this.DefaultIsle.add(DefaultBiome.JUNGLE.Name);
++ break;
+ }
+ }
- if (action.equals(""select"")) {
-- if (isPlayerDropTransferring(playerName)) {
-+ if (isPlayerDropTransferring(player)) {
- lwc.sendLocale(player, ""protection.modes.dropxfer.select.error"");
- return;
- }
+diff --git a/common/src/com/khorn/terraincontrol/configuration/ConfigFile.java b/common/src/com/khorn/terraincontrol/configuration/ConfigFile.java
+index 93e688b2a..7ef4da5a4 100644
+--- a/common/src/com/khorn/terraincontrol/configuration/ConfigFile.java
++++ b/common/src/com/khorn/terraincontrol/configuration/ConfigFile.java
+@@ -8,6 +8,7 @@
+ import java.util.Collections;
+ import java.util.HashMap;
+ import java.util.List;
++import java.util.Map;
-- lwc.getMemoryDatabase().unregisterMode(playerName, mode);
-- lwc.getMemoryDatabase().registerAction(""dropTransferSelect"", playerName, """");
-+ player.disableMode(player.getMode(mode));
+ public abstract class ConfigFile
+ {
+@@ -15,7 +16,7 @@ public abstract class ConfigFile
+
+ // TODO: This map is populated with lowercase versions as well.
+ // TODO: That is a derped approach. Use TreeSet with CASE_INSENSITIVE_ORDER instead.
+- protected HashMap SettingsCache = new HashMap();
++ protected Map SettingsCache = new HashMap();
+
+ // TODO: We should use GSON only instead of just for a few fields.
+ // TODO: Hah. We should remove that buggy GSON.
+diff --git a/common/src/com/khorn/terraincontrol/configuration/Resource.java b/common/src/com/khorn/terraincontrol/configuration/Resource.java
+index 5169b3f42..569fe97e3 100644
+--- a/common/src/com/khorn/terraincontrol/configuration/Resource.java
++++ b/common/src/com/khorn/terraincontrol/configuration/Resource.java
+@@ -1,99 +1,258 @@
+ package com.khorn.terraincontrol.configuration;
-+ Action temp = new Action();
-+ temp.setName(""dropTransferSelect"");
-+ temp.setPlayer(player);
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Random;
+
-+ player.addAction(temp);
- lwc.sendLocale(player, ""protection.modes.dropxfer.select.finalize"");
- } else if (action.equals(""on"")) {
-- int target = getPlayerDropTransferTarget(playerName);
-+ int target = getPlayerDropTransferTarget(player);
+ import com.khorn.terraincontrol.DefaultMaterial;
+-import com.khorn.terraincontrol.customobjects.CustomObjectCompiled;
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
+ import com.khorn.terraincontrol.generator.resourcegens.ResourceType;
+-import com.khorn.terraincontrol.generator.resourcegens.TreeType;
- if (target == -1) {
- lwc.sendLocale(player, ""protection.modes.dropxfer.selectchest"");
- return;
- }
+-public class Resource
++public abstract class Resource
+ {
+- public ResourceType Type;
+- public int MinAltitude;
+- public int MaxAltitude;
+- public int MinSize;
+- public int MaxSize;
+- public int BlockId;
+- public int BlockData;
+- public int[] SourceBlockId = new int[0];
+- public int Frequency;
+- public int Rarity;
+- public TreeType[] TreeTypes = new TreeType[0];
+- public int[] TreeChances = new int[0];
+-
+- // For custom trees
+- public CustomObjectCompiled[] CUObjectsWorld = new CustomObjectCompiled[0];
+- public CustomObjectCompiled[] CUObjectsBiome = new CustomObjectCompiled[0];
+-
+- public CustomObjectCompiled[] CUObjects = new CustomObjectCompiled[0];
+- public String[] CUObjectsNames = new String[0];
+-
+-
+- public Resource(ResourceType type)
++ protected int frequency;
++ protected int rarity;
++ protected WorldConfig worldConfig;
++
++ /**
++ * Sets the world. Needed for some resources, like CustomObject and Tree.
++ * @param world
++ */
++ public void setWorldConfig(WorldConfig worldConfig)
+ {
+- Type = type;
++ this.worldConfig = worldConfig;
+ }
+-
+- public Resource(ResourceType type, int blockId, int blockData, int size, int frequency, int rarity, int minAltitude, int maxAltitude, int[] sourceBlockIds)
++
++ /**
++ * Convenience method for creating a resource. Used to create the default resources.
++ * @param world
++ * @param clazz
++ * @param args
++ * @return
++ */
++ public static Resource create(WorldConfig config, Class extends Resource> clazz, Object... args)
+ {
+- this.Type = type;
+- this.BlockId = blockId;
+- this.BlockData = blockData;
+- this.MaxSize = size;
+- this.Frequency = frequency;
+- this.Rarity = rarity;
+- this.MinAltitude = minAltitude;
+- this.MaxAltitude = maxAltitude;
+- this.SourceBlockId = sourceBlockIds;
++ List stringArgs = new ArrayList(args.length);
++ for(Object arg: args)
++ {
++ stringArgs.add("""" + arg);
++ }
++
++ Resource resource;
++ try
++ {
++ resource = clazz.newInstance();
++ } catch (InstantiationException e)
++ {
++ return null;
++ } catch (IllegalAccessException e)
++ {
++ return null;
++ }
++ resource.setWorldConfig(config);
++ try {
++ resource.load(stringArgs);
++ } catch(InvalidResourceException e)
++ {
++ TerrainControl.log(""Invalid default resource! Please report! "" + clazz.getName() + "": ""+e.getMessage());
++ e.printStackTrace();
++ }
++
++ return resource;
+ }
-- lwc.getMemoryDatabase().registerMode(playerName, ""+dropTransfer"");
-+ Mode temp = new Mode();
-+ temp.setName(""+dropTransfer"");
-+ temp.setPlayer(player.getBukkitPlayer());
+- public Resource(ResourceType type, int minSize, int maxSize, int frequency, int rarity, int minAltitude, int maxAltitude)
++ /**
++ * Loads the settings. Returns false if one of the arguments contains an
++ * error.
++ *
++ * @param args
++ * List of args.
++ * @return Returns false if one of the arguments contains an error,
++ * otherwise true.
++ * @throws InvalidResourceException
++ * If the resoure is invalid.
++ */
++ public abstract void load(List args) throws InvalidResourceException;
+
-+ player.enableMode(temp);
- lwc.sendLocale(player, ""protection.modes.dropxfer.on.finalize"");
- } else if (action.equals(""off"")) {
-- int target = getPlayerDropTransferTarget(playerName);
-+ int target = getPlayerDropTransferTarget(player);
++ /**
++ * Spawns the resource at this position, ignoring rarity and frequency.
++ *
++ * @param world
++ * @param chunkX
++ * @param chunkZ
++ */
++ public abstract void spawn(LocalWorld world, Random random, int x, int z);
++
++ /**
++ * Spawns the resource normally.
++ *
++ * @param world
++ * @param chunkX
++ * @param chunkZ
++ */
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
+ {
+- this.Type = type;
+- this.MaxSize = maxSize;
+- this.MinSize = minSize;
+- this.Frequency = frequency;
+- this.Rarity = rarity;
+- this.MinAltitude = minAltitude;
+- this.MaxAltitude = maxAltitude;
++ for (int t = 0; t < frequency; t++)
++ {
++ if (random.nextInt(100) > rarity)
++ continue;
++ int x = chunkX * 16 + random.nextInt(16) + 8;
++ int z = chunkZ * 16 + random.nextInt(16) + 8;
++ spawn(world, random, x, z);
++ }
+ }
- if (target == -1) {
- lwc.sendLocale(player, ""protection.modes.dropxfer.selectchest"");
- return;
- }
+- public Resource(ResourceType type, int blockId, int frequency, int rarity, int minAltitude, int maxAltitude)
++ /**
++ * Gets the type of this resource.
++ *
++ * @return The type of this resource.
++ */
++ public abstract ResourceType getType();
++
++ /**
++ * Gets a String representation, like Tree(10,BigTree,50,Tree,100)
++ *
++ * @return A String representation, like Tree(10,BigTree,50,Tree,100)
++ */
++ public abstract String makeString();
++
++ /**
++ * Parses the string and returns a number between minValue and maxValue.
++ * Returns Resource.INCORRECT_NUMBER if the string is not a number.
++ *
++ * @param string
++ * @param minValue
++ * @param maxValue
++ * @return
++ * @throws InvalidResourceException
++ * If the number is invalid.
++ */
++ public int getInt(String string, int minValue, int maxValue) throws InvalidResourceException
+ {
+- this.Type = type;
+- this.BlockId = blockId;
+- this.Frequency = frequency;
+- this.Rarity = rarity;
+- this.MinAltitude = minAltitude;
+- this.MaxAltitude = maxAltitude;
++ try
++ {
++ int number = Integer.parseInt(string);
++ if (number < minValue)
++ {
++ return minValue;
++ }
++ if (number > maxValue)
++ {
++ return maxValue;
++ }
++ return number;
++ } catch (NumberFormatException e)
++ {
++ throw new InvalidResourceException(""Incorrect number: "" + string);
++ }
+ }
-- lwc.getMemoryDatabase().unregisterMode(playerName, ""+dropTransfer"");
-+ player.disableMode(player.getMode(""+dropTransfer""));
- lwc.sendLocale(player, ""protection.modes.dropxfer.off.finalize"");
- } else if (action.equals(""status"")) {
-- if (getPlayerDropTransferTarget(playerName) == -1) {
-+ if (getPlayerDropTransferTarget(player) == -1) {
- lwc.sendLocale(player, ""protection.modes.dropxfer.status.off"");
- } else {
-- if (isPlayerDropTransferring(playerName)) {
-+ if (isPlayerDropTransferring(player)) {
- lwc.sendLocale(player, ""protection.modes.dropxfer.status.active"");
- } else {
- lwc.sendLocale(player, ""protection.modes.dropxfer.status.inactive"");
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/modes/NoSpamModule.java b/modules/core/src/main/java/com/griefcraft/modules/modes/NoSpamModule.java
-index ef14c3da7..abf81768a 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/modes/NoSpamModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/modes/NoSpamModule.java
-@@ -18,13 +18,12 @@
- package com.griefcraft.modules.modes;
-
- import com.griefcraft.lwc.LWC;
-+import com.griefcraft.model.LWCPlayer;
-+import com.griefcraft.model.Mode;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCCommandEvent;
- import com.griefcraft.scripting.event.LWCSendLocaleEvent;
- import org.bukkit.command.CommandSender;
--import org.bukkit.entity.Player;
--
--import java.util.List;
+- public Resource(ResourceType type, int frequency, TreeType[] types, int[] treeChances)
++ /**
++ * Returns the block id with the given name.
++ *
++ * @param string
++ * @return
++ */
++ public int getBlockId(String string) throws InvalidResourceException
+ {
+- this.Type = type;
+- this.Frequency = frequency;
+- if (types != null)
++ if (string.indexOf('.') != -1)
++ {
++ // Ignore block data
++ string = string.split(""\\."")[0];
++ }
++
++ DefaultMaterial material = DefaultMaterial.getMaterial(string);
++ if (material != null)
+ {
+- this.TreeTypes = types;
+- this.TreeChances = treeChances;
++ return material.id;
+ }
++
++ return getInt(string, 0, 256);
+ }
- public class NoSpamModule extends JavaModule {
+- public boolean CheckSourceId(int blockId)
++ /**
++ * Gets the block data from a material string.
++ *
++ * @param string
++ * @return
++ * @throws InvalidResourceException
++ */
++ public int getBlockData(String string) throws InvalidResourceException
+ {
+- for (int id : this.SourceBlockId)
+- if (blockId == id)
+- return true;
+- return false;
++ if (string.indexOf('.') == -1)
++ {
++ // No block data
++ return 0;
++ }
++
++ // Get block data
++ string = string.split(""\\."")[1];
++ return getInt(string, 0, 16);
+ }
-@@ -42,37 +41,36 @@ public void onCommand(LWCCommandEvent event) {
- CommandSender sender = event.getSender();
- String[] args = event.getArgs();
++ public void assureSize(int size, List args) throws InvalidResourceException
++ {
++ if (args.size() < size)
++ {
++ throw new InvalidResourceException(""Too few arguments supplied"");
++ }
++ }
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String mode = args[0].toLowerCase();
+- public String BlockIdToName(int id)
++ /**
++ * Gets the material name back from the id and data.
++ *
++ * @param id
++ * The block id
++ * @param data
++ * The block data
++ * @return String in the format blockname[.blockdata]
++ */
++ public String makeMaterial(int id, int data)
+ {
++ String materialString = """" + id;
+ DefaultMaterial material = DefaultMaterial.getMaterial(id);
+ if (material != DefaultMaterial.UNKNOWN_BLOCK)
+- return material.name();
+- else
+- return Integer.toString(id);
++ {
++ // No name, return number as String
++ materialString = material.toString();
++ }
++
++ if (data > 0)
++ {
++ materialString = materialString + ""."" + data;
++ }
++
++ return materialString;
+ }
- if (!mode.equals(""nospam"")) {
- return;
- }
++ /**
++ * Gets the material name back from the id.
++ *
++ * @param id
++ * The block id
++ * @return String in the format blockname
++ */
++ public String makeMaterial(int id)
++ {
++ return makeMaterial(id, 0);
++ }
++
++ /**
++ * Returns a String in the format "",materialName,materialName,etc""
++ *
++ * @param ids
++ * @return
++ */
++ public String makeMaterial(List ids)
++ {
++ String string = """";
++ for (int blockId : ids)
++ {
++ string += "","";
++ string += makeMaterial(blockId);
++ }
++ return string;
++ }
+ }
+diff --git a/common/src/com/khorn/terraincontrol/configuration/WorldConfig.java b/common/src/com/khorn/terraincontrol/configuration/WorldConfig.java
+index a25695090..b7fbf0fac 100644
+--- a/common/src/com/khorn/terraincontrol/configuration/WorldConfig.java
++++ b/common/src/com/khorn/terraincontrol/configuration/WorldConfig.java
+@@ -3,9 +3,8 @@
+ import com.khorn.terraincontrol.DefaultBiome;
+ import com.khorn.terraincontrol.LocalBiome;
+ import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
+ import com.khorn.terraincontrol.customobjects.CustomObject;
+-import com.khorn.terraincontrol.customobjects.CustomObjectCompiled;
+-import com.khorn.terraincontrol.customobjects.ObjectsStore;
-- List modes = lwc.getMemoryDatabase().getModes(player.getName());
-+ if (!player.hasMode(mode)) {
-+ Mode temp = new Mode();
-+ temp.setName(mode);
-+ temp.setPlayer(player.getBukkitPlayer());
+ import java.io.DataInputStream;
+ import java.io.DataOutputStream;
+@@ -13,13 +12,19 @@
+ import java.io.IOException;
+ import java.util.ArrayList;
+ import java.util.HashMap;
++import java.util.Map;
-- if (!modes.contains(mode)) {
-- lwc.getMemoryDatabase().registerMode(player.getName(), mode);
-+ player.enableMode(temp);
- lwc.sendLocale(player, ""protection.modes.nospam.finalize"");
- } else {
-- lwc.getMemoryDatabase().unregisterMode(player.getName(), mode);
-+ player.disableMode(player.getMode(mode));
- lwc.sendLocale(player, ""protection.modes.nospam.off"");
- }
+ public class WorldConfig extends ConfigFile
+ {
++ public LocalWorld world;
++
+ public ArrayList CustomBiomes = new ArrayList();
+ public HashMap CustomBiomeIds = new HashMap();
- event.setCancelled(true);
-- return;
- }
+- public ArrayList CustomObjectsCompiled;
++ /**
++ * Holds all world CustomObjects. All keys should be lowercase.
++ */
++ public Map customObjects = new HashMap();
- @Override
- public void onSendLocale(LWCSendLocaleEvent event) {
- LWC lwc = event.getLWC();
-- Player player = event.getPlayer();
-+ LWCPlayer player = lwc.wrapPlayer(event.getPlayer());
- String locale = event.getLocale();
+ public ArrayList NormalBiomes = new ArrayList();
+ public ArrayList IceBiomes = new ArrayList();
+@@ -32,10 +37,6 @@ public class WorldConfig extends ConfigFile
+ public byte[] ReplaceMatrixBiomes = new byte[256];
+ public boolean HaveBiomeReplace = false;
-- List modes = lwc.getMemoryDatabase().getModes(player.getName());
+- // public BiomeBase currentBiome;
+- // --Commented out by Inspection (17.07.11 1:49):String seedValue;
-
- // they don't intrigue us
-- if (!modes.contains(""nospam"")) {
-+ if (!player.hasMode(""nospam"")) {
- return;
- }
-
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/modes/PersistModule.java b/modules/core/src/main/java/com/griefcraft/modules/modes/PersistModule.java
-index 6d082be9a..cd91987ad 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/modes/PersistModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/modes/PersistModule.java
-@@ -18,12 +18,11 @@
- package com.griefcraft.modules.modes;
-
- import com.griefcraft.lwc.LWC;
-+import com.griefcraft.model.LWCPlayer;
-+import com.griefcraft.model.Mode;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCCommandEvent;
- import org.bukkit.command.CommandSender;
--import org.bukkit.entity.Player;
-
--import java.util.List;
-
- public class PersistModule extends JavaModule {
+ // For old biome generator
+ public double oldBiomeSize;
-@@ -41,25 +40,26 @@ public void onCommand(LWCCommandEvent event) {
- CommandSender sender = event.getSender();
- String[] args = event.getArgs();
+@@ -161,6 +162,7 @@ public WorldConfig(File settingsDir, LocalWorld world, boolean checkOnly)
+ {
+ this.SettingsDir = settingsDir;
+ this.WorldName = world.getName();
++ this.world = world;
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String mode = args[0].toLowerCase();
+ File settingsFile = new File(this.SettingsDir, TCDefaultValues.WorldSettingsName.stringValue());
- if (!mode.equals(""persist"")) {
- return;
+@@ -285,15 +287,9 @@ private void ReadWorldCustomObjects()
+ }
}
-- List modes = lwc.getMemoryDatabase().getModes(player.getName());
-+ if (!player.hasMode(mode)) {
-+ Mode temp = new Mode();
-+ temp.setName(mode);
-+ temp.setPlayer(player.getBukkitPlayer());
+- ArrayList rawObjects = ObjectsStore.LoadObjectsFromDirectory(CustomObjectsDirectory);
+-
+-
+- CustomObjectsCompiled = new ArrayList();
+-
+- for (CustomObject object : rawObjects)
+- CustomObjectsCompiled.add(object.Compile(""""));
+- System.out.println(""TerrainControl: "" + CustomObjectsCompiled.size() + "" world custom objects loaded"");
++ customObjects = TerrainControl.getCustomObjectManager().loadObjects(CustomObjectsDirectory);
-- if (!modes.contains(mode)) {
-- lwc.getMemoryDatabase().registerMode(player.getName(), mode);
-+ player.enableMode(temp);
- lwc.sendLocale(player, ""protection.modes.persist.finalize"");
- } else {
-- lwc.getMemoryDatabase().unregisterMode(player.getName(), mode);
-+ player.disableMode(player.getMode(mode));
- lwc.sendLocale(player, ""protection.modes.persist.off"");
- }
++ TerrainControl.log(customObjects.size() + "" world custom objects loaded"");
- event.setCancelled(true);
-- return;
}
- }
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/modify/ModifyModule.java b/modules/core/src/main/java/com/griefcraft/modules/modify/ModifyModule.java
-index deed3ec5e..3a5e6e5fe 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/modify/ModifyModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/modify/ModifyModule.java
-@@ -20,6 +20,7 @@
- import com.griefcraft.lwc.LWC;
- import com.griefcraft.model.AccessRight;
- import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCBlockInteractEvent;
-@@ -46,11 +47,11 @@ public void onProtectionInteract(LWCProtectionInteractEvent event) {
-
- LWC lwc = event.getLWC();
- Protection protection = event.getProtection();
-- Player player = event.getPlayer();
-+ LWCPlayer player = lwc.wrapPlayer(event.getPlayer());
- event.setResult(Result.CANCEL);
-
-- if (lwc.canAdminProtection(player, protection)) {
-- Action action = lwc.getMemoryDatabase().getAction(""modify"", player.getName());
-+ if (lwc.canAdminProtection(player.getBukkitPlayer(), protection)) {
-+ Action action = player.getAction(""modify"");
-
- final String defaultEntities = action.getData();
- String[] entities = new String[0];
-@@ -172,10 +173,16 @@ public void onCommand(LWCCommandEvent event) {
- }
-
- String full = join(args, 0);
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
-+
-+ Action action = new Action();
-+ action.setName(""modify"");
-+ action.setPlayer(player);
-+ action.setData(full);
-+
-+ player.removeAllActions();
-+ player.addAction(action);
-
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-- lwc.getMemoryDatabase().registerAction(""modify"", player.getName(), full);
- lwc.sendLocale(sender, ""protection.modify.finalize"");
- return;
- }
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/owners/OwnersModule.java b/modules/core/src/main/java/com/griefcraft/modules/owners/OwnersModule.java
-index 7657f6176..f280e7379 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/owners/OwnersModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/owners/OwnersModule.java
-@@ -20,6 +20,7 @@
- import com.griefcraft.lwc.LWC;
- import com.griefcraft.model.AccessRight;
- import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.JavaModule;
- import com.griefcraft.scripting.event.LWCBlockInteractEvent;
-@@ -46,10 +47,10 @@ public void onProtectionInteract(LWCProtectionInteractEvent event) {
-
- LWC lwc = event.getLWC();
- Protection protection = event.getProtection();
-- Player player = event.getPlayer();
-+ LWCPlayer player = lwc.wrapPlayer(event.getPlayer());
- event.setResult(Result.CANCEL);
-
-- Action action = lwc.getMemoryDatabase().getAction(""owners"", player.getName());
-+ Action action = player.getAction(""owners"");
- int accessPage = Integer.parseInt(action.getData());
-
- /*
-@@ -142,7 +143,7 @@ public void onCommand(LWCCommandEvent event) {
- return;
- }
-
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- int page = 1;
-
- if (args.length > 0) {
-@@ -154,8 +155,14 @@ public void onCommand(LWCCommandEvent event) {
- }
- }
-
-- lwc.getMemoryDatabase().unregisterAllActions(player.getName());
-- lwc.getMemoryDatabase().registerAction(""owners"", player.getName(), page + """");
-+ Action action = new Action();
-+ action.setName(""owners"");
-+ action.setPlayer(player);
-+ action.setData(page + """");
-+
-+ player.removeAllActions();
-+ player.addAction(action);
-+
- lwc.sendLocale(sender, ""protection.owners.finalize"");
- return;
- }
-diff --git a/modules/core/src/main/java/com/griefcraft/modules/unlock/UnlockModule.java b/modules/core/src/main/java/com/griefcraft/modules/unlock/UnlockModule.java
-index 5475424e5..139deca8f 100644
---- a/modules/core/src/main/java/com/griefcraft/modules/unlock/UnlockModule.java
-+++ b/modules/core/src/main/java/com/griefcraft/modules/unlock/UnlockModule.java
-@@ -18,6 +18,8 @@
- package com.griefcraft.modules.unlock;
-
- import com.griefcraft.lwc.LWC;
-+import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.model.ProtectionTypes;
- import com.griefcraft.scripting.JavaModule;
-@@ -61,38 +63,35 @@ public void onCommand(LWCCommandEvent event) {
- return;
- }
-
-- Player player = (Player) sender;
-+ LWCPlayer player = lwc.wrapPlayer(sender);
- String password = join(args, 0);
- password = encrypt(password);
-
-- if (!lwc.getMemoryDatabase().hasPendingUnlock(player.getName())) {
-+ // see if they have the protection interaction action
-+ Action action = player.getAction(""interacted"");
-+
-+ if (action == null) {
- player.sendMessage(Colors.Red + ""Nothing selected. Open a locked protection first."");
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/CustomObject.java b/common/src/com/khorn/terraincontrol/customobjects/CustomObject.java
+index bdb8e3347..a7394627a 100644
+--- a/common/src/com/khorn/terraincontrol/customobjects/CustomObject.java
++++ b/common/src/com/khorn/terraincontrol/customobjects/CustomObject.java
+@@ -1,101 +1,123 @@
+-package com.khorn.terraincontrol.customobjects;
+-
+-
+-import com.khorn.terraincontrol.configuration.ConfigFile;
+-
+-import java.io.File;
+-import java.io.IOException;
+-import java.util.HashMap;
+-import java.util.Map;
+-
+-public class CustomObject extends ConfigFile
+-{
+- public boolean IsValid = false;
+- public File FilePath;
+- public String Name = """";
+-
+- public CustomObject(File objectFile)
+- {
+- FilePath = objectFile;
+- Name = objectFile.getName();
+-
+- if(!Name.toLowerCase().endsWith(BODefaultValues.BO_Extension.stringValue().toLowerCase()))
- return;
- } else {
-- int protectionId = lwc.getMemoryDatabase().getUnlockID(player.getName());
-+ Protection protection = action.getProtection();
-
-- if (protectionId == -1) {
-+ if (protection == null) {
- lwc.sendLocale(player, ""protection.internalerror"", ""id"", ""unlock"");
- return;
- }
-
-- Protection entity = lwc.getPhysicalDatabase().loadProtection(protectionId);
-
-- if (entity.getType() != ProtectionTypes.PASSWORD) {
-+ if (protection.getType() != ProtectionTypes.PASSWORD) {
- lwc.sendLocale(player, ""protection.unlock.notpassword"");
- return;
- }
-
-- if (entity.getData().equals(password)) {
-- lwc.getMemoryDatabase().unregisterUnlock(player.getName());
-- lwc.getMemoryDatabase().registerPlayer(player.getName(), protectionId);
-+ if (protection.getData().equals(password)) {
-+ player.addAccessibleProtection(protection);
- lwc.sendLocale(player, ""protection.unlock.password.valid"");
- } else {
- lwc.sendLocale(player, ""protection.unlock.password.invalid"");
- }
- }
+- //Remove extension.
+- Name = Name.substring(0, Name.length() - 4);
-
-- return;
- }
-
- }
-diff --git a/modules/spout/src/main/java/com/griefcraft/lwc/PasswordRequestModule.java b/modules/spout/src/main/java/com/griefcraft/lwc/PasswordRequestModule.java
-index 475d235f5..e6251cc9a 100644
---- a/modules/spout/src/main/java/com/griefcraft/lwc/PasswordRequestModule.java
-+++ b/modules/spout/src/main/java/com/griefcraft/lwc/PasswordRequestModule.java
-@@ -18,6 +18,8 @@
- package com.griefcraft.lwc;
-
- import com.griefcraft.bukkit.LWCSpoutPlugin;
-+import com.griefcraft.model.Action;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.model.ProtectionTypes;
- import com.griefcraft.scripting.JavaModule;
-@@ -104,9 +106,12 @@ public void onButtonClicked(ButtonClickEvent event) {
- Button button = event.getButton();
- SpoutPlayer player = event.getPlayer();
- LWC lwc = LWC.getInstance();
-+ LWCPlayer lwcPlayer = lwc.wrapPlayer(player);
-+
-+ Action action = lwcPlayer.getAction(""interacted"");
-
- // if they don't have an unlock req, why is the screen open?
-- if (!lwc.getMemoryDatabase().hasPendingUnlock(player.getName())) {
-+ if (action == null) {
- player.getMainScreen().closePopup();
- return;
- }
-@@ -117,24 +122,21 @@ public void onButtonClicked(ButtonClickEvent event) {
- // check their password
- String password = lwc.encrypt(textField.getText().trim());
-
-- int protectionId = lwc.getMemoryDatabase().getUnlockID(player.getName());
-+ // load the protection they had clicked
-+ Protection protection = action.getProtection();
-
-- if (protectionId == -1) {
-+ if (protection == null) {
- lwc.sendLocale(player, ""protection.internalerror"", ""id"", ""unlock"");
- return;
- }
-
-- // load the protection they had clicked
-- Protection protection = lwc.getPhysicalDatabase().loadProtection(protectionId);
-
- if (protection.getType() != ProtectionTypes.PASSWORD) {
- lwc.sendLocale(player, ""protection.unlock.notpassword"");
- return;
- }
-
- if (protection.getData().equals(password)) {
-- lwc.getMemoryDatabase().unregisterUnlock(player.getName());
-- lwc.getMemoryDatabase().registerPlayer(player.getName(), protectionId);
-+ lwcPlayer.addAccessibleProtection(protection);
- player.getMainScreen().closePopup();
-
- // open the chest that they clicked :P
-diff --git a/skel/doors.yml b/skel/doors.yml
-index c602913bc..4ce685a32 100644
---- a/skel/doors.yml
-+++ b/skel/doors.yml
-@@ -10,7 +10,7 @@ doors:
- # toggle: the door will just open if it's closed, or close if it's opened. Will not auto close.
- # openAndClose: the door will automatically close after . If it was already opened, it will NOT re-open.
- #
-- action: toggle
-+ name: toggle
-
-- # The amount of seconds after opening a door for it to close. No effect if openAndClose action is not being used.
-+ # The amount of seconds after opening a door for it to close. No effect if openAndClose name is not being used.
- interval: 3
-\ No newline at end of file
-diff --git a/src/lang/lwc_cz.properties b/src/lang/lwc_cz.properties
-index b52246589..737f1fae4 100644
---- a/src/lang/lwc_cz.properties
-+++ b/src/lang/lwc_cz.properties
-@@ -45,7 +45,7 @@ protection.general.locked.password=\
- %red%Musis napsat %gold%%cunlock% %red% k odemknuti !
- protection.general.locked.private=%green%%block% %white%->%red% objekt je uzamknut magickym klicem ! %white%:-)
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Jiz mas nevyrizeny prikaz s LWC!
-
- ##################
-diff --git a/src/lang/lwc_da.properties b/src/lang/lwc_da.properties
-index 8bee5fd15..6e43e768c 100644
---- a/src/lang/lwc_da.properties
-+++ b/src/lang/lwc_da.properties
-@@ -44,7 +44,7 @@ protection.general.locked.password=\
- %red%Skriv %gold%%cunlock% %red% for at låse op.
- protection.general.locked.private=%red%Denne %block% er låst med en trylleformular
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Du har allerede en ventende handling.
-
- ##################
-diff --git a/src/lang/lwc_de.properties b/src/lang/lwc_de.properties
-index 0faeb46e9..6eee83e52 100644
---- a/src/lang/lwc_de.properties
-+++ b/src/lang/lwc_de.properties
-@@ -45,7 +45,7 @@ protection.general.locked.password=\
- %red%Schreibe %gold%%cunlock% %red%zum entriegeln.
- protection.general.locked.private=%red%Diese %block% ist abgeschlossen.
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Du hast derzeit noch eine offene Anfrage.
-
- ##################
-diff --git a/src/lang/lwc_en.properties b/src/lang/lwc_en.properties
-index a9e491641..e641a3ba2 100644
---- a/src/lang/lwc_en.properties
-+++ b/src/lang/lwc_en.properties
-@@ -44,8 +44,8 @@ protection.general.locked.password=\
- %red%Type %gold%%cunlock% %red% to unlock it.
- protection.general.locked.private=%red%This %block% is locked with a magical spell
-
--# Pending action
--protection.general.pending=%red%You already have a pending action.
-+# Pending name
-+protection.general.pending=%red%You already have a pending name.
-
- ##################
- ## Commands ##
-diff --git a/src/lang/lwc_es.properties b/src/lang/lwc_es.properties
-index 00bd24fbc..f37e00bf5 100644
---- a/src/lang/lwc_es.properties
-+++ b/src/lang/lwc_es.properties
-@@ -35,7 +35,7 @@ protection.general.locked.password=\
- %red%Escribe %gold%%cunlock% %red% para desbloquearlo.
- protection.general.locked.private=%red%Este %block% esta protegido con un hechizo magico.
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Ya tienes una accion pendiente.
-
- ##################
-diff --git a/src/lang/lwc_fr.properties b/src/lang/lwc_fr.properties
-index be4addd2b..3a78963f8 100644
---- a/src/lang/lwc_fr.properties
-+++ b/src/lang/lwc_fr.properties
-@@ -31,8 +31,8 @@ protection.general.locked.password=\
- %red%Veuillez taper %gold%%cunlock% %red% pour le/la déverrouiller.
- protection.general.locked.private=%red%Ce/Cette %block% est bloqué par un sort magique.
-
--# Pending action
--protection.general.pending=%red%Vous avez déjà une action en cours.
-+# Pending name
-+protection.general.pending=%red%Vous avez déjà une name en cours.
-
- ##################
- ## Commands ##
-diff --git a/src/lang/lwc_nl.properties b/src/lang/lwc_nl.properties
-index 813313d55..d7e779b01 100644
---- a/src/lang/lwc_nl.properties
-+++ b/src/lang/lwc_nl.properties
-@@ -35,7 +35,7 @@ protection.general.locked.password=\
- %red%Typ %gold%%cunlock% %red% om er toegang tot te krijgen.
- protection.general.locked.private=%red%deze %block% is beveiligd met een magische spreuk.
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Er is al een actie bezig.
-
- ##################
-diff --git a/src/lang/lwc_pl.properties b/src/lang/lwc_pl.properties
-index e8657902c..d44c07529 100644
---- a/src/lang/lwc_pl.properties
-+++ b/src/lang/lwc_pl.properties
-@@ -44,7 +44,7 @@ protection.general.locked.password=\
- %gold%%cunlock% %red%, aby odblokowac.
- protection.general.locked.private=%red%Ten %block% jest zablokowany magicznym zakleciem.
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Juz wykonujesz akcje.
-
- ##################
-diff --git a/src/lang/lwc_ru.properties b/src/lang/lwc_ru.properties
-index f9243536c..b312d7dc1 100644
---- a/src/lang/lwc_ru.properties
-+++ b/src/lang/lwc_ru.properties
-@@ -43,7 +43,7 @@ protection.general.locked.password=\
- %red%Введите %gold%%cunlock% <Пароль>%red% чтобы открыть его.
- protection.general.locked.private=%red%%block% защищён магией.
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Вы уже выполняете это действие
-
- ##################
-diff --git a/src/lang/lwc_sv.properties b/src/lang/lwc_sv.properties
-index 7c025c889..d19e1f4d4 100644
---- a/src/lang/lwc_sv.properties
-+++ b/src/lang/lwc_sv.properties
-@@ -44,7 +44,7 @@ protection.general.locked.password=\
- %red%Skriv %gold%%cunlock% %red% för att låsa upp den.
- protection.general.locked.private=%red%Detta %block% är låst med en trollformel
-
--# Pending action
-+# Pending name
- protection.general.pending=%red%Du har redan et pågående utspel.
-
- ##################
-diff --git a/src/main/java/com/griefcraft/listeners/LWCPlayerListener.java b/src/main/java/com/griefcraft/listeners/LWCPlayerListener.java
-index de6a125b9..2fd2c88a7 100644
---- a/src/main/java/com/griefcraft/listeners/LWCPlayerListener.java
-+++ b/src/main/java/com/griefcraft/listeners/LWCPlayerListener.java
-@@ -19,6 +19,7 @@
-
- import com.griefcraft.lwc.LWC;
- import com.griefcraft.lwc.LWCPlugin;
-+import com.griefcraft.model.LWCPlayer;
- import com.griefcraft.model.Protection;
- import com.griefcraft.scripting.Module;
- import com.griefcraft.scripting.Module.Result;
-@@ -43,6 +44,7 @@
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.inventory.ItemStack;
-
-+import java.util.ArrayList;
- import java.util.List;
-
- public class LWCPlayerListener extends PlayerListener {
-@@ -103,6 +105,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
-
- LWC lwc = plugin.getLWC();
- Player player = event.getPlayer();
-+ LWCPlayer lwcPlayer = lwc.wrapPlayer(player);
- Block clickedBlock = event.getClickedBlock();
- Location location = clickedBlock.getLocation();
-
-@@ -122,12 +125,22 @@ public void onPlayerInteract(PlayerInteractEvent event) {
- }
-
- try {
-- List actions = lwc.getMemoryDatabase().getActions(player.getName());
-+ List actions = new ArrayList(lwcPlayer.getActionNames());
- Protection protection = lwc.findProtection(block);
- Module.Result result = Module.Result.CANCEL;
- boolean canAccess = lwc.canAccessProtection(player, protection);
- boolean canAdmin = lwc.canAdminProtection(player, protection);
-
-+ // register in an action what protection they interacted with (if applicable.)
-+ if (protection != null) {
-+ com.griefcraft.model.Action action = new com.griefcraft.model.Action();
-+ action.setName(""interacted"");
-+ action.setPlayer(lwcPlayer);
-+ action.setProtection(protection);
-+
-+ lwcPlayer.addAction(action);
-+ }
-+
- if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
- boolean ignoreLeftClick = Boolean.parseBoolean(lwc.resolveProtectionConfiguration(material, ""ignoreLeftClick""));
-
-@@ -188,14 +201,10 @@ public void onPlayerQuit(PlayerQuitEvent event) {
- return;
- }
-
-- LWC lwc = plugin.getLWC();
-- String player = event.getPlayer().getName();
+- ReadSettingsFile(objectFile);
+- CorrectSettings();
+- if (SettingsCache.containsKey(""[META]"") && SettingsCache.containsKey(""[DATA]""))
+- this.IsValid = true;
-
-- lwc.getMemoryDatabase().unregisterPlayer(player);
-- lwc.getMemoryDatabase().unregisterUnlock(player);
-- lwc.getMemoryDatabase().unregisterPendingLock(player);
-- lwc.getMemoryDatabase().unregisterAllActions(player);
-- lwc.getMemoryDatabase().unregisterAllModes(player);
-+ LWCPlayer player = LWC.getInstance().wrapPlayer(event.getPlayer());
-+ player.removeAllAccessibleProtections();
-+ player.removeAllActions();
-+ player.disableAllModes();
- }
-
- }
-diff --git a/src/main/java/com/griefcraft/lwc/LWC.java b/src/main/java/com/griefcraft/lwc/LWC.java
-index 1081b9642..595656229 100644
---- a/src/main/java/com/griefcraft/lwc/LWC.java
-+++ b/src/main/java/com/griefcraft/lwc/LWC.java
-@@ -66,7 +66,6 @@
- import com.griefcraft.scripting.ModuleLoader.Event;
- import com.griefcraft.scripting.event.LWCSendLocaleEvent;
- import com.griefcraft.sql.Database;
--import com.griefcraft.sql.MemDB;
- import com.griefcraft.sql.PhysDB;
- import com.griefcraft.util.Colors;
- import com.griefcraft.util.Performance;
-@@ -142,11 +141,6 @@ public class LWC {
- */
- private CacheSet caches;
-
-- /**
-- * Memory database instance
-- */
-- private MemDB memoryDatabase;
+- if (!this.IsValid)
+- return;
-
- /**
- * Physical database instance
- */
-@@ -205,11 +199,19 @@ public LWC(LWCPlugin plugin) {
- /**
- * Create an LWCPlayer object for a player
- *
-- * @param player
-+ * @param sender
- * @return
- */
-- public LWCPlayer wrapPlayer(Player player) {
-- return new LWCPlayer(this, player);
-+ public LWCPlayer wrapPlayer(CommandSender sender) {
-+ if (sender instanceof LWCPlayer) {
-+ return (LWCPlayer) sender;
-+ }
-+
-+ if (!(sender instanceof Player)) {
-+ return null;
-+ }
-+
-+ return LWCPlayer.getPlayer((Player) sender);
- }
-
- /**
-@@ -254,11 +256,17 @@ public CacheSet getCaches() {
- /**
- * Remove all modes if the player is not in persistent mode
- *
-- * @param player
-+ * @param sender
- */
-- public void removeModes(Player player) {
-- if (notInPersistentMode(player.getName())) {
-- memoryDatabase.unregisterAllActions(player.getName());
-+ public void removeModes(CommandSender sender) {
-+ if (sender instanceof Player) {
-+ Player bPlayer = (Player) sender;
-+
-+ if (notInPersistentMode(bPlayer.getName())) {
-+ wrapPlayer(bPlayer).getActions().clear();
-+ }
-+ } else if (sender instanceof LWCPlayer) {
-+ removeModes(((LWCPlayer) sender).getBukkitPlayer());
- }
- }
-
-@@ -369,7 +377,7 @@ public boolean canAccessProtection(Player player, Protection protection) {
- return true;
-
- case ProtectionTypes.PASSWORD:
-- return memoryDatabase.hasAccess(player.getName(), protection);
-+ return wrapPlayer(player).getAccessibleProtections().contains(protection);
-
- case ProtectionTypes.PRIVATE:
- if (playerName.equalsIgnoreCase(protection.getOwner())) {
-@@ -437,7 +445,7 @@ public boolean canAdminProtection(Player player, Protection protection) {
- return player.getName().equalsIgnoreCase(protection.getOwner());
-
- case ProtectionTypes.PASSWORD:
-- return player.getName().equalsIgnoreCase(protection.getOwner()) && memoryDatabase.hasAccess(player.getName(), protection);
-+ return player.getName().equalsIgnoreCase(protection.getOwner()) && wrapPlayer(player).getAccessibleProtections().contains(protection);
-
- case ProtectionTypes.PRIVATE:
- if (playerName.equalsIgnoreCase(protection.getOwner())) {
-@@ -483,12 +491,7 @@ public void destruct() {
- physicalDatabase.dispose();
- }
-
-- if (memoryDatabase != null) {
-- memoryDatabase.dispose();
+- ReadConfigSettings();
+- }
+-
+- public CustomObjectCompiled Compile(String settingsLine)
+- {
+- HashMap newSettings = new HashMap();
+- for (Map.Entry entry : this.SettingsCache.entrySet())
+- if (BODefaultValues.Contains(entry.getKey()) || ObjectCoordinate.isCoordinateString(entry.getKey()))
+- newSettings.put(entry.getKey(), entry.getValue());
+-
+- String[] keys = settingsLine.split("";"");
+- String changedSettings = """";
+- boolean first = true;
+-
+- for (String key : keys)
+- {
+- String[] values = null;
+- if (key.contains(""=""))
+- values = key.split(""="", 2);
+- else if (key.contains("":""))
+- values = key.split(""="", 2);
+- if (values == null)
+- continue;
+- if (BODefaultValues.Contains(values[0].toLowerCase()) || ObjectCoordinate.isCoordinateString(values[0]))
+- {
+- newSettings.put(values[0].toLowerCase(), values[1]);
+- changedSettings = changedSettings + (first ? """" : "";"") + key;
+- if (first)
+- first = false;
+- }
- }
-
- physicalDatabase = null;
-- memoryDatabase = null;
- }
-
- /**
-@@ -576,8 +579,7 @@ public boolean enforceAccess(Player player, Block block) {
- switch (protection.getType()) {
- case ProtectionTypes.PASSWORD:
- if (!hasAccess) {
-- getMemoryDatabase().unregisterUnlock(player.getName());
-- getMemoryDatabase().registerUnlock(player.getName(), protection.getId());
-+ wrapPlayer(player).addAccessibleProtection(protection);
-
- sendLocale(player, ""protection.general.locked.password"", ""block"", materialToString(block));
- }
-@@ -778,13 +780,6 @@ public String getLocale(String key, Object... args) {
- return value;
- }
-
-- /**
-- * @return memory database object
-- */
-- public MemDB getMemoryDatabase() {
-- return memoryDatabase;
+- return new CustomObjectCompiled(newSettings, Name, changedSettings, this);
+-
- }
-
- /**
- * @return the Permissions handler
- */
-@@ -1060,7 +1055,6 @@ public void load() {
- Performance.init();
-
- physicalDatabase = new PhysDB();
-- memoryDatabase = new MemDB();
- updateThread = new UpdateThread(this);
-
- // Permissions init
-@@ -1114,10 +1108,7 @@ public void load() {
- log(""Loading "" + Database.DefaultType);
- try {
- physicalDatabase.connect();
-- memoryDatabase.connect();
+- @Override
+- public boolean sayNotFoundEnabled()
+- {
+- return false;
+- }
+-
+- @Override
+- protected void ReadConfigSettings()
+- {
-
- physicalDatabase.load();
-- memoryDatabase.load();
-
- log(""Using: "" + StringUtils.capitalizeFirstLetter(physicalDatabase.getConnection().getMetaData().getDriverVersion()));
- } catch (Exception e) {
-@@ -1257,7 +1248,7 @@ public ItemStack[] mergeInventories(List blocks) {
- * @return true if the player is NOT in persistent mode
- */
- public boolean notInPersistentMode(String player) {
-- return !memoryDatabase.hasMode(player, ""persist"");
-+ return !wrapPlayer(Bukkit.getServer().getPlayer(player)).hasMode(""persist"");
- }
-
- /**
-diff --git a/src/main/java/com/griefcraft/model/Action.java b/src/main/java/com/griefcraft/model/Action.java
-index 5ea7d69f0..e5b68e884 100644
---- a/src/main/java/com/griefcraft/model/Action.java
-+++ b/src/main/java/com/griefcraft/model/Action.java
-@@ -19,24 +19,23 @@
-
- public class Action {
-
-- public int id;
-- private String action;
-- private int protectionId;
-+ private String name;
-+ private Protection protection;
- private String data;
-- private String player;
-+ private LWCPlayer player;
-
- /**
-- * @return the action
-+ * @return the name
- */
-- public String getAction() {
-- return action;
-+ public String getName() {
-+ return name;
- }
-
- /**
-- * @return the protectionId
-+ * @return the Protection associated with this action
- */
-- public int getProtectionId() {
-- return protectionId;
-+ public Protection getProtection() {
-+ return protection;
- }
-
- /**
-@@ -46,32 +45,25 @@ public String getData() {
- return data;
- }
-
-- /**
-- * @return the id
-- */
-- public int getId() {
-- return id;
- }
-
- /**
- * @return the player
- */
-- public String getPlayer() {
-+ public LWCPlayer getPlayer() {
- return player;
- }
-
- /**
-- * @param action the action to set
-+ * @param name the name to set
- */
-- public void setAction(String action) {
-- this.action = action;
-+ public void setName(String name) {
-+ this.name = name;
- }
-
- /**
-- * @param protectionId the protectionId to set
-+ * @param protection the Protection to set
- */
-- public void setProtectionId(int protectionId) {
-- this.protectionId = protectionId;
-+ public void setProtection(Protection protection) {
-+ this.protection = protection;
- }
-
- /**
-@@ -81,17 +73,10 @@ public void setData(String data) {
- this.data = data;
- }
-
-- /**
-- * @param id the id to set
-- */
-- public void setId(int id) {
-- this.id = id;
+- @Override
+- protected void WriteConfigSettings() throws IOException
+- {
+-
- }
-
- /**
- * @param player the player to set
- */
-- public void setPlayer(String player) {
-+ public void setPlayer(LWCPlayer player) {
- this.player = player;
- }
-
-diff --git a/src/main/java/com/griefcraft/model/LWCPlayer.java b/src/main/java/com/griefcraft/model/LWCPlayer.java
-index e0ad1e771..bc93c9aaa 100644
---- a/src/main/java/com/griefcraft/model/LWCPlayer.java
-+++ b/src/main/java/com/griefcraft/model/LWCPlayer.java
-@@ -18,21 +18,269 @@
- package com.griefcraft.model;
-
- import com.griefcraft.lwc.LWC;
-+import org.bukkit.Server;
-+import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
-+import org.bukkit.permissions.Permission;
-+import org.bukkit.permissions.PermissionAttachment;
-+import org.bukkit.permissions.PermissionAttachmentInfo;
-+import org.bukkit.plugin.Plugin;
-
- import java.util.ArrayList;
-+import java.util.Collections;
-+import java.util.HashMap;
-+import java.util.HashSet;
- import java.util.List;
-+import java.util.Map;
-+import java.util.Set;
-
--public class LWCPlayer {
-+public class LWCPlayer implements CommandSender {
-
-+ /**
-+ * The LWC instance
-+ */
- private LWC lwc;
-+
-+ /**
-+ * The player instance
-+ */
- private Player player;
-
-+ /**
-+ * Cache of LWCPlayer objects
-+ */
-+ private final static Map players = new HashMap();
-+
-+ /**
-+ * The modes bound to all players
-+ */
-+ private final static Map> modes = Collections.synchronizedMap(new HashMap>());
-+
-+ /**
-+ * The actions bound to all players
-+ */
-+ private final static Map> actions = Collections.synchronizedMap(new HashMap>());
-+
-+ /**
-+ * Map of protections a player can temporarily access
-+ */
-+ private final static Map> accessibleProtections = Collections.synchronizedMap(new HashMap>());
-+
- public LWCPlayer(LWC lwc, Player player) {
- this.lwc = lwc;
- this.player = player;
- }
-
-+ /**
-+ * Get the LWCPlayer object from a Player object
-+ *
-+ * @param player
-+ * @return
-+ */
-+ public static LWCPlayer getPlayer(Player player) {
-+ if (!players.containsKey(player)) {
-+ players.put(player, new LWCPlayer(LWC.getInstance(), player));
-+ }
-+
-+ return players.get(player);
-+ }
-+
-+ /**
-+ * @return the Bukkit Player object
-+ */
-+ public Player getBukkitPlayer() {
-+ return player;
-+ }
-+
-+ /**
-+ * @return the player's name
-+ */
-+ public String getName() {
-+ return player.getName();
-+ }
-+
-+ /**
-+ * Enable a mode on the player
-+ *
-+ * @param mode
-+ * @return
-+ */
-+ public boolean enableMode(Mode mode) {
-+ return getModes().add(mode);
-+ }
-+
-+ /**
-+ * Disable a mode on the player
-+ *
-+ * @param mode
-+ * @return
-+ */
-+ public boolean disableMode(Mode mode) {
-+ return getModes().remove(mode);
-+ }
+- @Override
+- protected void CorrectSettings()
+- {
+-
+- }
+-
+- @Override
+- protected void RenameOldSettings()
+- {
+- }
+-}
++package com.khorn.terraincontrol.customobjects;
+
-+ /**
-+ * Disable all modes enabled by the player
-+ *
-+ * @return
-+ */
-+ public void disableAllModes() {
-+ getModes().clear();
-+ }
++import java.util.Map;
++import java.util.Random;
+
-+ /**
-+ * Check if the player has an action
-+ *
-+ * @param name
-+ * @return
-+ */
-+ public boolean hasAction(String name) {
-+ return getAction(name) != null;
-+ }
++import com.khorn.terraincontrol.LocalBiome;
++import com.khorn.terraincontrol.LocalWorld;
+
++public interface CustomObject
++{
+ /**
-+ * Get the action represented by the name
-+ *
-+ * @param name
++ * Returns the name of this object.
++ *
+ * @return
+ */
-+ public Action getAction(String name) {
-+ for (Action action : getActions()) {
-+ if (action.getName().equals(name)) {
-+ return action;
-+ }
-+ }
-+
-+ return null;
-+ }
++ public String getName();
+
+ /**
-+ * Add an action
-+ *
-+ * @param action
-+ * @return
++ * Returns whether this object can spawn as a tree. UseWorld and UseBiome
++ * should return true.
++ *
++ * @return Whether this object can spawn as a tree.
+ */
-+ public boolean addAction(Action action) {
-+ return getActions().add(action);
-+ }
++ public boolean canSpawnAsTree();
+
+ /**
-+ * Remove an action
++ * Returns whether this object can spawn from the CustomObject() resource.
++ * Vanilla trees should return false; everything else should return true.
+ *
-+ * @param action
+ * @return
+ */
-+ public boolean removeAction(Action action) {
-+ return getActions().remove(action);
-+ }
-+
-+ /**
-+ * Remove all actions
-+ */
-+ public void removeAllActions() {
-+ getActions().clear();
-+ }
++ public boolean canSpawnAsObject();
+
+ /**
-+ * Retrieve a Mode object for a player
-+ *
-+ * @param name
-+ * @return
++ * Spawns the object at the given position.
++ *
++ * @param world
++ * @param x
++ * @param y
++ * @param z
++ * @return Whether the attempt was successful.
+ */
-+ public Mode getMode(String name) {
-+ for (Mode mode : getModes()) {
-+ if (mode.getName().equals(name)) {
-+ return mode;
-+ }
-+ }
-+
-+ return null;
-+ }
++ public boolean spawn(LocalWorld world, Random random, int x, int y, int z);
+
+ /**
-+ * Check if the player has the given mode
-+ *
-+ * @param name
-+ * @return
++ * Spawns the object at the given position. If the object isn't a tree, it
++ * shouldn't spawn and it should return false.
++ *
++ * @param world
++ * @param x
++ * @param y
++ * @param z
++ * @return Whether the attempt was successful.
+ */
-+ public boolean hasMode(String name) {
-+ return getMode(name) != null;
-+ }
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int y, int z);
+
+ /**
-+ * @return the Set of modes the player has activated
++ * Spawns the object at the given position. It should search a suitable y
++ * location by itself.
++ *
++ * @param world
++ * @param x
++ * @param y
++ * @param z
++ * @return Whether the attempt was successful.
+ */
-+ public Set getModes() {
-+ if (!modes.containsKey(this)) {
-+ modes.put(this, new HashSet());
-+ }
-+
-+ return modes.get(this);
-+ }
++ public boolean spawn(LocalWorld world, Random random, int x, int z);
+
+ /**
-+ * @return the Set of actions the player has
++ * Spawns the object at the given position. It should search a suitable y
++ * location by itself. If the object isn't a tree, it shouldn't spawn and it
++ * should return false.
++ *
++ * @param world
++ * @param x
++ * @param y
++ * @param z
++ * @return Whether the attempt was successful.
+ */
-+ public Set getActions() {
-+ if (!actions.containsKey(this)) {
-+ actions.put(this, new HashSet());
-+ }
-+
-+ return actions.get(this);
-+ }
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int z);
+
+ /**
-+ * @return a Set containing all of the action names
++ * Spawns the object in a chunk. The object can search a good y position by
++ * itself.
++ *
++ * @param world
++ * @param random
++ * @param chunkX
++ * @param chunkZ
+ */
-+ public Set getActionNames() {
-+ Set actions = getActions();
-+ Set names = new HashSet(actions.size());
-+
-+ for (Action action : actions) {
-+ names.add(action.getName());
-+ }
-+
-+ return names;
-+ }
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ);
+
+ /**
-+ * @return the set of protections the player can temporarily access
++ * Spawns the object in a chunk. The object can search a good y position by
++ * itself. If the object isn't a tree, the object shouldn't spawn and it
++ * should return false.
++ *
++ * @param world
++ * @param random
++ * @param x
++ * @param z
+ */
-+ public Set getAccessibleProtections() {
-+ if (!accessibleProtections.containsKey(this)) {
-+ accessibleProtections.put(this, new HashSet());
-+ }
-+
-+ return accessibleProtections.get(this);
-+ }
++ public void processAsTree(LocalWorld world, Random random, int chunkX, int chunkZ);
+
+ /**
-+ * Add an accessible protection for the player
-+ *
-+ * @param protection
-+ * @return
++ * Returns a copy of this object will all the settings applied. Can return
++ * null if the settings are invalid.
++ *
++ * @param settings
++ * A Map with all the settings.
++ * @return A copy of this object will all the settings applied.
+ */
-+ public boolean addAccessibleProtection(Protection protection) {
-+ return getAccessibleProtections().add(protection);
-+ }
++ public CustomObject applySettings(Map settings);
+
+ /**
-+ * Remove an accessible protection from the player
-+ *
-+ * @param protection
++ * Returns whether this object would like to spawn in this biome. BO2s will
++ * return whether this biome is in their spawnInBiome setting.
++ *
++ * @param biome
+ * @return
+ */
-+ public boolean removeAccessibleProtection(Protection protection) {
-+ return getAccessibleProtections().remove(protection);
-+ }
-+
-+ /**
-+ * Remove all accessible protections
-+ */
-+ public void removeAllAccessibleProtections() {
-+ getAccessibleProtections().clear();
-+ }
-+
- /**
- * Create a History object that is attached to this protection
- *
-@@ -84,4 +332,63 @@ public List getRelatedHistory(History.Type type) {
- return related;
- }
-
-+ public void sendMessage(String s) {
-+ player.sendMessage(s);
-+ }
-+
-+ public Server getServer() {
-+ return player.getServer();
-+ }
-+
-+ public boolean isPermissionSet(String s) {
-+ return player.isPermissionSet(s);
-+ }
-+
-+ public boolean isPermissionSet(Permission permission) {
-+ return player.isPermissionSet(permission);
-+ }
-+
-+ public boolean hasPermission(String s) {
-+ return player.hasPermission(s);
-+ }
-+
-+ public boolean hasPermission(Permission permission) {
-+ return player.hasPermission(permission);
-+ }
-+
-+ public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) {
-+ return player.addAttachment(plugin, s, b);
-+ }
-+
-+ public PermissionAttachment addAttachment(Plugin plugin) {
-+ return player.addAttachment(plugin);
-+ }
-+
-+ public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) {
-+ return player.addAttachment(plugin, s, b, i);
-+ }
-+
-+ public PermissionAttachment addAttachment(Plugin plugin, int i) {
-+ return player.addAttachment(plugin, i);
-+ }
-+
-+ public void removeAttachment(PermissionAttachment permissionAttachment) {
-+ player.removeAttachment(permissionAttachment);
-+ }
-+
-+ public void recalculatePermissions() {
-+ player.recalculatePermissions();
-+ }
-+
-+ public Set getEffectivePermissions() {
-+ return player.getEffectivePermissions();
-+ }
-+
-+ public boolean isOp() {
-+ return player.isOp();
-+ }
-+
-+ public void setOp(boolean b) {
-+ player.setOp(b);
-+ }
- }
-diff --git a/src/main/java/com/griefcraft/model/Mode.java b/src/main/java/com/griefcraft/model/Mode.java
-new file mode 100644
-index 000000000..75a5450cd
---- /dev/null
-+++ b/src/main/java/com/griefcraft/model/Mode.java
-@@ -0,0 +1,63 @@
-+/**
-+ * This file is part of LWC (https://github.com/Hidendra/LWC)
-+ *
-+ * This program is free software: you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation, either version 3 of the License, or
-+ * (at your option) any later version.
-+ *
-+ * 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. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program. If not, see .
-+ */
-+
-+package com.griefcraft.model;
-+
-+import org.bukkit.entity.Player;
-+
-+public class Mode {
-+
-+ /**
-+ * The name of this mode
-+ */
-+ private String name;
-+
-+ /**
-+ * The player this mode belongs to
-+ */
-+ private Player player;
-+
-+ /**
-+ * Mode data
-+ */
-+ private String data;
-+
-+ public String getName() {
-+ return name;
-+ }
-+
-+ public Player getPlayer() {
-+ return player;
-+ }
-+
-+ public String getData() {
-+ return data;
-+ }
-+
-+ public void setName(String name) {
-+ this.name = name;
-+ }
-+
-+ public void setPlayer(Player player) {
-+ this.player = player;
-+ }
-+
-+ public void setData(String data) {
-+ this.data = data;
-+ }
-+
++ public boolean hasPreferenceToSpawnIn(LocalBiome biome);
+}
-diff --git a/src/main/java/com/griefcraft/sql/MemDB.java b/src/main/java/com/griefcraft/sql/MemDB.java
-deleted file mode 100755
-index b92531459..000000000
---- a/src/main/java/com/griefcraft/sql/MemDB.java
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/CustomObjectCompiled.java b/common/src/com/khorn/terraincontrol/customobjects/CustomObjectCompiled.java
+deleted file mode 100644
+index 032cf215c..000000000
+--- a/common/src/com/khorn/terraincontrol/customobjects/CustomObjectCompiled.java
+++ /dev/null
-@@ -1,831 +0,0 @@
--/**
-- * This file is part of LWC (https://github.com/Hidendra/LWC)
-- *
-- * This program is free software: you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License as published by
-- * the Free Software Foundation, either version 3 of the License, or
-- * (at your option) any later version.
-- *
-- * 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. See the
-- * GNU General Public License for more details.
-- *
-- * You should have received a copy of the GNU General Public License
-- * along with this program. If not, see .
-- */
--
--package com.griefcraft.sql;
+@@ -1,229 +0,0 @@
+-package com.khorn.terraincontrol.customobjects;
-
--import com.griefcraft.model.Action;
--import com.griefcraft.model.Protection;
--import com.griefcraft.util.Performance;
+-import com.khorn.terraincontrol.DefaultMaterial;
+-import com.khorn.terraincontrol.configuration.ConfigFile;
-
--import java.sql.PreparedStatement;
--import java.sql.ResultSet;
--import java.sql.Statement;
+-import java.io.IOException;
-import java.util.ArrayList;
--import java.util.List;
+-import java.util.HashMap;
+-import java.util.HashSet;
-
--public class MemDB extends Database {
+-public class CustomObjectCompiled extends ConfigFile
+-{
+- public ObjectCoordinate[][] Data = new ObjectCoordinate[4][];
-
-- public MemDB() {
-- super();
-- }
+- public CustomObjectCompiled[] GroupObjects = null;
-
-- public MemDB(Type currentType) {
-- super(currentType);
-- }
+- public String Name;
-
-- @Override
-- protected void postPrepare() {
-- Performance.addMemDBQuery();
-- }
+- public HashSet SpawnInBiome;
-
-- public Action getAction(String action, String player) {
-- try {
-- PreparedStatement statement = prepare(""SELECT * FROM "" + prefix + ""actions WHERE player = ? AND action = ?"");
-- statement.setString(1, player);
-- statement.setString(2, action);
--
-- ResultSet set = statement.executeQuery();
--
-- if (set.next()) {
-- final int id = set.getInt(""id"");
-- final String actionString = set.getString(""action"");
-- final String playerString = set.getString(""player"");
-- final int chestID = set.getInt(""chest"");
-- final String data = set.getString(""data"");
--
-- final Action act = new Action();
-- act.setId(id);
-- act.setAction(actionString);
-- act.setPlayer(playerString);
-- act.setProtectionId(chestID);
-- act.setData(data);
--
-- return act;
-- }
+- public String Version;
+- public HashSet SpawnOnBlockType;
-
+- public HashSet CollisionBlockType;
-
-- } catch (final Exception e) {
-- printException(e);
-- }
+- public boolean SpawnWater;
+- public boolean SpawnLava;
+- public boolean SpawnAboveGround;
+- public boolean SpawnUnderGround;
-
-- return null;
-- }
+- public boolean SpawnSunlight;
+- public boolean SpawnDarkness;
-
-- /**
-- * Get the chest ID associated with a player's unlock request
-- *
-- * @param player the player to lookup
-- * @return the chest ID
-- */
-- public int getActionID(String action, String player) {
-- try {
-- int chestID = -1;
+- public boolean UnderFill;
+- public boolean RandomRotation;
+- public boolean Dig;
+- public boolean Tree;
+- public boolean Branch;
+- public boolean DiggingBranch;
+- public boolean NeedsFoundation;
+- public int Rarity;
+- public double CollisionPercentage;
+- public int SpawnElevationMin;
+- public int SpawnElevationMax;
-
-- PreparedStatement statement = prepare(""SELECT chest FROM "" + prefix + ""actions WHERE action = ? AND player = ?"");
-- statement.setString(1, action);
-- statement.setString(2, player);
+- public int GroupFrequencyMin;
+- public int GroupFrequencyMax;
+- public int GroupSeparationMin;
+- public int GroupSeparationMax;
+- public String GroupId;
-
-- final ResultSet set = statement.executeQuery();
+- public int BranchLimit;
-
-- while (set.next()) {
-- chestID = set.getInt(""chest"");
-- }
+- public String ChangedSettings;
-
+- public CustomObject parent;
-
-- return chestID;
-- } catch (final Exception e) {
-- printException(e);
-- }
+- public CustomObjectCompiled(HashMap settings, String name, String changedSettings, CustomObject parent)
+- {
+- SettingsCache = settings;
+- this.Name = name;
+- this.ChangedSettings = changedSettings;
+- this.parent = parent;
+-
+- ReadConfigSettings();
+- CorrectSettings();
-
-- return -1;
+- SettingsCache.clear();
+- SettingsCache = null;
- }
-
-- /**
-- * Get all the active actions for a player
-- *
-- * @param player the player to get actions for
-- * @return the List of actions
-- */
-- public List getActions(String player) {
-- final List actions = new ArrayList();
-
-- try {
-- PreparedStatement statement = prepare(""SELECT action FROM "" + prefix + ""actions WHERE player = ?"");
-- statement.setString(1, player);
+- public boolean CheckBiome(String biomeName)
+- {
+- return (SpawnInBiome.contains(BODefaultValues.BO_ALL_KEY.stringValue()) || SpawnInBiome.contains(BODefaultValues.BO_ALL_KEY.stringValue().toLowerCase()) || SpawnInBiome.contains(biomeName));
+- }
-
-- final ResultSet set = statement.executeQuery();
-
-- while (set.next()) {
-- final String action = set.getString(""action"");
+- @Override
+- protected void ReadConfigSettings()
+- {
+- this.Version = ReadModSettings(BODefaultValues.version.name(), BODefaultValues.version.stringValue());
-
-- actions.add(action);
-- }
-
-- } catch (final Exception e) {
-- printException(e);
-- }
+- this.SpawnOnBlockType = this.ReadBlockList(ReadModSettings(BODefaultValues.spawnOnBlockType.name(), BODefaultValues.spawnOnBlockType.StringArrayListValue()),BODefaultValues.spawnOnBlockType.name());
+- this.CollisionBlockType = this.ReadBlockList(ReadModSettings(BODefaultValues.collisionBlockType.name(), BODefaultValues.collisionBlockType.StringArrayListValue()),BODefaultValues.collisionBlockType.name());
-
-- return actions;
-- }
+- this.SpawnInBiome = new HashSet(ReadModSettings(BODefaultValues.spawnInBiome.name(), BODefaultValues.spawnInBiome.StringArrayListValue()));
-
-- /**
-- * @return the path where the database file should be saved
-- */
-- @Override
-- public String getDatabasePath() {
-- // if we're using mysql, just open another connection
-- if (currentType == Type.MySQL) {
-- return super.getDatabasePath();
-- }
-
-- return "":memory:"";
-- }
+- this.SpawnSunlight = ReadModSettings(BODefaultValues.spawnSunlight.name(), BODefaultValues.spawnSunlight.booleanValue());
+- this.SpawnDarkness = ReadModSettings(BODefaultValues.spawnDarkness.name(), BODefaultValues.spawnDarkness.booleanValue());
+- this.SpawnWater = ReadModSettings(BODefaultValues.spawnWater.name(), BODefaultValues.spawnWater.booleanValue());
+- this.SpawnLava = ReadModSettings(BODefaultValues.spawnLava.name(), BODefaultValues.spawnLava.booleanValue());
+- this.SpawnAboveGround = ReadModSettings(BODefaultValues.spawnAboveGround.name(), BODefaultValues.spawnAboveGround.booleanValue());
+- this.SpawnUnderGround = ReadModSettings(BODefaultValues.spawnUnderGround.name(), BODefaultValues.spawnUnderGround.booleanValue());
-
-- /**
-- * Get the password submitted for a pending chest lock
-- *
-- * @param player the player to lookup
-- * @return the password for the pending lock
-- */
-- public String getLockPassword(String player) {
-- try {
-- String password = """";
+- this.UnderFill = ReadModSettings(BODefaultValues.underFill.name(), BODefaultValues.underFill.booleanValue());
-
-- PreparedStatement statement = prepare(""SELECT password FROM "" + prefix + ""locks WHERE player = ?"");
-- statement.setString(1, player);
+- this.RandomRotation = ReadModSettings(BODefaultValues.randomRotation.name(), BODefaultValues.randomRotation.booleanValue());
+- this.Dig = ReadModSettings(BODefaultValues.dig.name(), BODefaultValues.dig.booleanValue());
+- this.Tree = ReadModSettings(BODefaultValues.tree.name(), BODefaultValues.tree.booleanValue());
+- this.Branch = ReadModSettings(BODefaultValues.branch.name(), BODefaultValues.branch.booleanValue());
+- this.DiggingBranch = ReadModSettings(BODefaultValues.diggingBranch.name(), BODefaultValues.diggingBranch.booleanValue());
+- this.NeedsFoundation = ReadModSettings(BODefaultValues.needsFoundation.name(), BODefaultValues.needsFoundation.booleanValue());
+- this.Rarity = ReadModSettings(BODefaultValues.rarity.name(), BODefaultValues.rarity.intValue());
+- this.CollisionPercentage = ReadModSettings(BODefaultValues.collisionPercentage.name(), BODefaultValues.collisionPercentage.intValue());
+- this.SpawnElevationMin = ReadModSettings(BODefaultValues.spawnElevationMin.name(), BODefaultValues.spawnElevationMin.intValue());
+- this.SpawnElevationMax = ReadModSettings(BODefaultValues.spawnElevationMax.name(), BODefaultValues.spawnElevationMax.intValue());
-
-- final ResultSet set = statement.executeQuery();
+- this.GroupFrequencyMin = ReadModSettings(BODefaultValues.groupFrequencyMin.name(), BODefaultValues.groupFrequencyMin.intValue());
+- this.GroupFrequencyMax = ReadModSettings(BODefaultValues.groupFrequencyMax.name(), BODefaultValues.groupFrequencyMax.intValue());
+- this.GroupSeparationMin = ReadModSettings(BODefaultValues.groupSeperationMin.name(), BODefaultValues.groupSeperationMin.intValue());
+- this.GroupSeparationMax = ReadModSettings(BODefaultValues.groupSeperationMax.name(), BODefaultValues.groupSeperationMax.intValue());
+- this.GroupId = ReadModSettings(BODefaultValues.groupId.name(), BODefaultValues.groupId.stringValue());
-
-- while (set.next()) {
-- password = set.getString(""password"");
-- }
-
+- this.BranchLimit = ReadModSettings(BODefaultValues.branchLimit.name(), BODefaultValues.branchLimit.intValue());
-
-- return password;
-- } catch (final Exception e) {
-- printException(e);
-- }
+- this.ReadCoordinates();
+- }
-
-- return null;
+- @Override
+- protected boolean sayNotFoundEnabled()
+- {
+- return false;
- }
+-
+- @Override
+- protected void CorrectSettings()
+- {
-
-- /**
-- * Get the mode data for a player's mode
-- *
-- * @param player
-- * @param mode
-- * @return
-- */
-- public String getModeData(String player, String mode) {
-- String ret = null;
-- try {
-- PreparedStatement statement = prepare(""SELECT data FROM "" + prefix + ""modes WHERE player = ? AND mode = ?"");
-- statement.setString(1, player);
-- statement.setString(2, mode);
-
-- final ResultSet set = statement.executeQuery();
-- if (set.next()) {
-- ret = set.getString(""data"");
-- }
+- }
-
+- @Override
+- protected void WriteConfigSettings() throws IOException
+- {
-
-- } catch (final Exception e) {
-- printException(e);
-- }
-- return ret;
- }
-
-- /**
-- * Get the modes a player has activated
-- *
-- * @param player the player to get
-- * @return the List of modes the player is using
-- */
-- public List getModes(String player) {
-- final List modes = new ArrayList();
+- @Override
+- protected void RenameOldSettings()
+- {
-
-- try {
-- PreparedStatement statement = prepare(""SELECT * FROM "" + prefix + ""modes WHERE player = ?"");
-- statement.setString(1, player);
+- }
-
-- final ResultSet set = statement.executeQuery();
-
-- while (set.next()) {
-- final String mode = set.getString(""mode"");
+- private void ReadCoordinates()
+- {
+- ArrayList coordinates = new ArrayList();
-
-- modes.add(mode);
-- }
+- for (String key : SettingsCache.keySet())
+- {
+- ObjectCoordinate buffer = ObjectCoordinate.getCoordinateFromString(key, SettingsCache.get(key));
+- if (buffer != null)
+- coordinates.add(buffer);
+- }
-
+- Data[0] = new ObjectCoordinate[coordinates.size()];
+- Data[1] = new ObjectCoordinate[coordinates.size()];
+- Data[2] = new ObjectCoordinate[coordinates.size()];
+- Data[3] = new ObjectCoordinate[coordinates.size()];
-
-- } catch (final Exception e) {
-- printException(e);
+- for (int i = 0; i < coordinates.size(); i++)
+- {
+- ObjectCoordinate coordinate = coordinates.get(i);
+-
+- Data[0][i] = coordinate;
+- coordinate = coordinate.Rotate();
+- Data[1][i] = coordinate;
+- coordinate = coordinate.Rotate();
+- Data[2][i] = coordinate;
+- coordinate = coordinate.Rotate();
+- Data[3][i] = coordinate;
- }
-
-- return modes;
-- }
-
-- /**
-- * Get all of the users ""logged in"" to a chest
-- *
-- * @param chestID the chest ID to look at
-- * @return
-- */
-- public List getSessionUsers(int chestID) {
-- final List sessionUsers = new ArrayList();
+- }
-
-- try {
-- PreparedStatement statement = prepare(""SELECT player FROM "" + prefix + ""sessions WHERE chest = ?"");
-- statement.setInt(1, chestID);
+- private HashSet ReadBlockList(ArrayList blocks, String settingName)
+- {
+- HashSet output = new HashSet();
-
-- final ResultSet set = statement.executeQuery();
+- boolean nonIntegerValues = false;
+- boolean all = false;
+- boolean solid = false;
-
-- while (set.next()) {
-- final String player = set.getString(""player"");
+- for (String block : blocks)
+- {
-
-- sessionUsers.add(player);
+- if (block.equals(BODefaultValues.BO_ALL_KEY.stringValue()))
+- {
+- all = true;
+- continue;
+- }
+- if (block.equals(BODefaultValues.BO_SolidKey.stringValue()))
+- {
+- solid = true;
+- continue;
+- }
+- try
+- {
+- int blockID = Integer.decode(block);
+- if (blockID != 0)
+- output.add(blockID);
+- } catch (NumberFormatException e)
+- {
+- nonIntegerValues = true;
- }
--
-- } catch (final Exception e) {
-- printException(e);
- }
-
-- return sessionUsers;
-- }
+- if (all || solid)
+- for (DefaultMaterial material : DefaultMaterial.values())
+- {
+- if(material.id == 0)
+- continue;
+- if (solid && !material.isSolid())
+- continue;
+- output.add(material.id);
-
-- /**
-- * Get the chest ID associated with a player's unlock request
-- *
-- * @param player the player to lookup
-- * @return the chest ID
-- */
-- public int getUnlockID(String player) {
-- return getActionID(""unlock"", player);
-- }
+- }
+- if (nonIntegerValues)
+- System.out.println(""TerrainControl: Custom object "" + this.Name + "" have wrong value "" + settingName);
-
-- /**
-- * Check if a player has an active chest session
-- *
-- * @param player the player to check
-- * @param chestID the chest ID to check
-- * @return true if the player has access
-- */
-- public boolean hasAccess(String player, int chestID) {
-- try {
-- PreparedStatement statement = prepare(""SELECT player FROM "" + prefix + ""sessions WHERE chest = ?"");
-- statement.setInt(1, chestID);
+- return output;
-
-- final ResultSet set = statement.executeQuery();
+- }
+-}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/CustomObjectGen.java b/common/src/com/khorn/terraincontrol/customobjects/CustomObjectGen.java
+deleted file mode 100644
+index 06acaad21..000000000
+--- a/common/src/com/khorn/terraincontrol/customobjects/CustomObjectGen.java
++++ /dev/null
+@@ -1,344 +0,0 @@
+-package com.khorn.terraincontrol.customobjects;
-
-- while (set.next()) {
-- final String player2 = set.getString(""player"");
+-import com.khorn.terraincontrol.DefaultMaterial;
+-import com.khorn.terraincontrol.LocalWorld;
+-import com.khorn.terraincontrol.configuration.BiomeConfig;
+-import com.khorn.terraincontrol.configuration.Resource;
+-import com.khorn.terraincontrol.generator.resourcegens.ResourceGenBase;
-
-- if (player.equals(player2)) {
+-import java.util.ArrayList;
+-import java.util.HashMap;
+-import java.util.Random;
-
+-public class CustomObjectGen extends ResourceGenBase
+-{
-
-- return true;
-- }
-- }
-
+- @Override
+- public void Process(LocalWorld world, Random rand, Resource res, int _x, int _z)
+- {
-
-- } catch (final Exception e) {
-- printException(e);
-- }
+- if (res.CUObjects.length == 0)
+- return;
-
-- return false;
-- }
+- _x = _x + 8;
+- _z = _z + 8;
-
-- /**
-- * Check if a player has an active chest session
-- *
-- * @param player the player to check
-- * @param chest the chest to check
-- * @return true if the player has access
-- */
-- public boolean hasAccess(String player, Protection chest) {
-- return chest == null || hasAccess(player, chest.getId());
+- boolean objectSpawned = false;
+- int spawnAttempts = 0;
+- while (!objectSpawned)
+- {
+- if (spawnAttempts > world.getSettings().objectSpawnRatio)
+- return;
-
-- }
+- spawnAttempts++;
-
-- /**
-- * Return if a player has the mode
-- *
-- * @param player the player to check
-- * @param mode the mode to check
-- */
-- public boolean hasMode(String player, String mode) {
-- List modes = getModes(player);
+- CustomObjectCompiled SelectedObject = res.CUObjects[rand.nextInt(res.CUObjects.length)];
+- if (SelectedObject.Branch)
+- continue;
-
-- return modes.size() > 0 && modes.contains(mode);
-- }
+- int randomRoll = rand.nextInt(100);
+- int ObjectRarity = SelectedObject.Rarity;
-
-- /**
-- * Check if a player has a pending action
-- *
-- * @param player the player to check
-- * @param action the action to check
-- * @return true if they have a record
-- */
-- public boolean hasPendingAction(String action, String player) {
-- return getAction(action, player) != null;
-- }
+- while (randomRoll < ObjectRarity)
+- {
+- ObjectRarity -= 100;
+-
+- int x = _x + rand.nextInt(16);
+- int z = _z + rand.nextInt(16);
+- int y;
+-
+- if (SelectedObject.SpawnAboveGround)
+- y = world.getSolidHeight(x, z);
+- else if (SelectedObject.SpawnUnderGround)
+- {
+- int solidHeight = world.getSolidHeight(x, z);
+- if (solidHeight < 1 || solidHeight <= SelectedObject.SpawnElevationMin)
+- continue;
+- if (solidHeight > SelectedObject.SpawnElevationMax)
+- solidHeight = SelectedObject.SpawnElevationMax;
+- y = rand.nextInt(solidHeight - SelectedObject.SpawnElevationMin) + SelectedObject.SpawnElevationMin;
+- } else
+- y = world.getHighestBlockYAt(x, z);
-
-- /**
-- * Check if a player has a pending chest request
-- *
-- * @param player The player to check
-- * @return true if the player has a pending chest request
-- */
-- public boolean hasPendingChest(String player) {
-- try {
-- PreparedStatement statement = prepare(""SELECT id FROM "" + prefix + ""locks WHERE player = ?"");
-- statement.setString(1, player);
+- if (y < 0)
+- continue;
+-
+- if (!ObjectCanSpawn(world, x, y, z, SelectedObject))
+- continue;
-
-- ResultSet set = statement.executeQuery();
-
-- if (set.next()) {
-- set.close();
-- return true;
-- }
+- objectSpawned = GenerateCustomObject(world, rand, x, y, z, SelectedObject);
-
-- set.close();
-- } catch (final Exception e) {
-- printException(e);
+- if (objectSpawned)
+- GenerateCustomObjectFromGroup(world, rand, x, y, z, SelectedObject);
+- }
- }
-
-- return false;
-- }
-
-- /**
-- * Check if a player has a pending unlock request
-- *
-- * @param player the player to check
-- * @return true if the player has a pending unlock request
-- */
-- public boolean hasPendingUnlock(String player) {
-- return getUnlockID(player) != -1;
- }
-
-- /**
-- * create the in-memory table which hold sessions, users that have activated a chest. Not needed past a restart, so no need for extra disk i/o
-- */
-- @Override
-- public void load() {
-- if (loaded) {
+- public static void GenerateCustomObjectFromGroup(LocalWorld world, Random rand, int x, int y, int z, CustomObjectCompiled workObject)
+- {
+- if (workObject.GroupObjects == null)
- return;
-- }
-
-- try {
-- // reusable column
-- Column column;
+- int attempts = 3;
+- if ((workObject.GroupFrequencyMax - workObject.GroupFrequencyMin) > 0)
+- attempts = workObject.GroupFrequencyMin + rand.nextInt(workObject.GroupFrequencyMax - workObject.GroupFrequencyMin);
+-
+- while (attempts > 0)
+- {
+- attempts--;
-
-- Table sessions = new Table(this, ""sessions"");
-- sessions.setMemory(true);
+- int objIndex = rand.nextInt(workObject.GroupObjects.length);
+- CustomObjectCompiled ObjectFromGroup = workObject.GroupObjects[objIndex];
-
-- {
-- column = new Column(""id"");
-- column.setType(""INTEGER"");
-- column.setPrimary(true);
-- sessions.add(column);
--
-- column = new Column(""player"");
-- column.setType(""VARCHAR(255)"");
-- sessions.add(column);
--
-- column = new Column(""chest"");
-- column.setType(""INTEGER"");
-- sessions.add(column);
-- }
+- if (ObjectFromGroup.Branch)
+- continue;
-
-- Table locks = new Table(this, ""locks"");
-- locks.setMemory(true);
+- x = x + rand.nextInt(workObject.GroupSeparationMax - workObject.GroupSeparationMin) + workObject.GroupSeparationMin;
+- z = z + rand.nextInt(workObject.GroupSeparationMax - workObject.GroupSeparationMin) + workObject.GroupSeparationMin;
+- int _y;
-
+- if (workObject.SpawnAboveGround)
+- _y = world.getSolidHeight(x, z);
+- else if (workObject.SpawnUnderGround)
- {
-- column = new Column(""id"");
-- column.setType(""INTEGER"");
-- column.setPrimary(true);
-- locks.add(column);
--
-- column = new Column(""player"");
-- column.setType(""VARCHAR(255)"");
-- locks.add(column);
--
-- column = new Column(""password"");
-- column.setType(""VARCHAR(100)"");
-- locks.add(column);
-- }
+- int solidHeight = world.getSolidHeight(x, z);
+- if (solidHeight < 1 || solidHeight <= workObject.SpawnElevationMin)
+- continue;
+- if (solidHeight > workObject.SpawnElevationMax)
+- solidHeight = workObject.SpawnElevationMax;
+- _y = rand.nextInt(solidHeight - workObject.SpawnElevationMin) + workObject.SpawnElevationMin;
+- } else
+- _y = world.getHighestBlockYAt(x, z);
+-
+- if (y < 0)
+- continue;
+-
+- if ((y - _y) > 10 || (_y - y) > 10)
+- continue;
+-
+- if (!ObjectCanSpawn(world, x, y, z, ObjectFromGroup))
+- continue;
+- GenerateCustomObject(world, rand, x, _y, z, ObjectFromGroup);
+- }
+-
+-
+- }
+-
+-
+- public static boolean GenerateCustomObject(LocalWorld world, Random rand, int x, int y, int z, CustomObjectCompiled workObject)
+- {
+-
+- ObjectCoordinate[] data = workObject.Data[0];
+- if (workObject.RandomRotation)
+- data = workObject.Data[rand.nextInt(4)];
-
-- Table actions = new Table(this, ""actions"");
-- actions.setMemory(true);
-
+- int faultCounter = 0;
+-
+- for (ObjectCoordinate point : data)
+- {
+- if (!world.isLoaded((x + point.x), (y + point.y), (z + point.z)))
+- return false;
+-
+- if (!workObject.Dig)
- {
-- column = new Column(""id"");
-- column.setType(""INTEGER"");
-- column.setPrimary(true);
-- actions.add(column);
--
-- column = new Column(""action"");
-- column.setType(""VARCHAR(255)"");
-- actions.add(column);
--
-- column = new Column(""player"");
-- column.setType(""VARCHAR(255)"");
-- actions.add(column);
--
-- column = new Column(""chest"");
-- column.setType(""INTEGER"");
-- actions.add(column);
--
-- column = new Column(""data"");
-- column.setType(""VARCHAR(255)"");
-- actions.add(column);
+- if (workObject.CollisionBlockType.contains(world.getTypeId((x + point.x), (y + point.y), (z + point.z))))
+- {
+- faultCounter++;
+- if (faultCounter > (data.length * (workObject.CollisionPercentage / 100)))
+- {
+- return false;
+- }
+- }
- }
-
-- Table modes = new Table(this, ""modes"");
-- modes.setMemory(true);
-
+- }
+-
+- for (ObjectCoordinate point : data)
+- {
+-
+- if (world.getTypeId(x + point.x, y + point.y, z + point.z) == 0)
+- {
+- world.setBlock((x + point.x), y + point.y, z + point.z, point.BlockId, point.BlockData, true, false, true);
+- } else if (workObject.Dig)
- {
-- column = new Column(""id"");
-- column.setType(""INTEGER"");
-- column.setPrimary(true);
-- modes.add(column);
--
-- column = new Column(""player"");
-- column.setType(""VARCHAR(255)"");
-- modes.add(column);
--
-- column = new Column(""mode"");
-- column.setType(""VARCHAR(255)"");
-- modes.add(column);
--
-- column = new Column(""data"");
-- column.setType(""VARCHAR(255)"");
-- modes.add(column);
+- world.setBlock((x + point.x), y + point.y, z + point.z, point.BlockId, point.BlockData, true, false, true);
- }
-
-- // now create all of the tables
-- sessions.execute();
-- locks.execute();
-- actions.execute();
-- modes.execute();
-- } catch (final Exception e) {
-- printException(e);
- }
+- return true;
-
-- loaded = true;
- }
-
-- /**
-- * @return the number of pending chest locks
-- */
-- public int pendingCount() {
-- int count = 0;
+- public static boolean ObjectCanSpawn(LocalWorld world, int x, int y, int z, CustomObjectCompiled obj)
+- {
+- if ((world.getTypeId(x, y - 5, z) == 0) && (obj.NeedsFoundation))
+- return false;
-
-- try {
-- Statement statement = connection.createStatement();
-- final ResultSet set = statement.executeQuery(""SELECT id FROM "" + prefix + ""locks"");
+- boolean output = true;
+- int checkBlock = world.getTypeId(x, y + 2, z);
+- if (!obj.SpawnWater)
+- output = !((checkBlock == DefaultMaterial.WATER.id) || (checkBlock == DefaultMaterial.STATIONARY_WATER.id));
+- if (!obj.SpawnLava)
+- output = !((checkBlock == DefaultMaterial.LAVA.id) || (checkBlock == DefaultMaterial.STATIONARY_LAVA.id));
-
-- while (set.next()) {
-- count++;
-- }
+- checkBlock = world.getLightLevel(x, y + 2, z);
+- if (!obj.SpawnSunlight)
+- output = !(checkBlock > 8);
+- if (!obj.SpawnDarkness)
+- output = !(checkBlock < 9);
-
-- statement.close();
+- if ((y < obj.SpawnElevationMin) || (y > obj.SpawnElevationMax))
+- output = false;
-
-- } catch (final Exception e) {
-- printException(e);
-- }
+- if (!obj.SpawnOnBlockType.contains(world.getTypeId(x, y - 1, z)))
+- output = false;
-
-- return count;
+- return output;
- }
-
-- /**
-- * Register a pending chest unlock, for when the player does /unlock
-- *
-- * @param action
-- * @param player
-- */
-- public void registerAction(String action, String player) {
-- try {
-- /*
-- * We only want 1 action per player, no matter what!
-- */
-- unregisterAction(action, player);
--
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""actions (action, player, chest) VALUES (?, ?, ?)"");
-- statement.setString(1, action);
-- statement.setString(2, player);
-- statement.setInt(3, -1);
--
-- statement.executeUpdate();
+- @Override
+- protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x, int z)
+- {
-
-
-- } catch (final Exception e) {
-- printException(e);
-- }
- }
-
-- /**
-- * Register a pending chest unlock, for when the player does /unlock
-- *
-- * @param player the player to register
-- * @param chestID the chestID to unlock
-- */
-- public void registerAction(String action, String player, int chestID) {
-- try {
-- /*
-- * We only want 1 action per player, no matter what!
-- */
-- unregisterAction(action, player);
+- @Override
+- protected String WriteString(Resource res, String blockSources)
+- {
+- String output = """";
+- boolean first = true;
-
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""actions (action, player, chest) VALUES (?, ?, ?)"");
-- statement.setString(1, action);
-- statement.setString(2, player);
-- statement.setInt(3, chestID);
+- for (String name : res.CUObjectsNames)
+- {
+- output = output + (first ? """" : "","");
+- if (first)
+- first = false;
-
-- statement.executeUpdate();
+- if (name.equals(BODefaultValues.BO_Use_World.stringValue()) || name.equals(BODefaultValues.BO_Use_Biome.stringValue()))
+- {
+- output += name;
+- continue;
+- }
-
+- for (CustomObjectCompiled object : res.CUObjects)
+- if (object.Name.equals(name))
+- output += name + (object.ChangedSettings.equals("""") ? """" : (""("" + object.ChangedSettings + "")""));
-
-- } catch (final Exception e) {
-- printException(e);
- }
+-
+- return output;
+-
- }
-
-- /**
-- * Register an action, used for various actions (stating the obvious here)
-- *
-- * @param player the player to register
-- * @param data data
-- */
-- public void registerAction(String action, String player, String data) {
-- try {
-- /*
-- * We only want 1 action per player, no matter what!
-- */
-- unregisterAction(action, player);
+- @Override
+- protected boolean ReadString(Resource res, String[] Props, BiomeConfig biomeConfig) throws NumberFormatException
+- {
-
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""actions (action, player, data) VALUES (?, ?, ?)"");
-- statement.setString(1, action);
-- statement.setString(2, player);
-- statement.setString(3, data);
+- ArrayList objects = new ArrayList();
+- ArrayList objectsName = new ArrayList();
+- HashMap> Groups = new HashMap>();
-
-- statement.executeUpdate();
+- if (Props.length == 1 && Props[0].equals(""""))
+- {
+- AddCompiledObjectsFromWorld(biomeConfig, objects, Groups);
+- objectsName.add(BODefaultValues.BO_Use_World.stringValue());
-
+- } else
+- for (String key : Props)
+- {
+- if (key.equals(BODefaultValues.BO_Use_World.stringValue()))
+- {
+- AddCompiledObjectsFromWorld(biomeConfig, objects, Groups);
+- objectsName.add(BODefaultValues.BO_Use_World.stringValue());
+- continue;
+- }
-
-- } catch (final Exception e) {
-- printException(e);
-- }
-- }
+- if (key.equals(BODefaultValues.BO_Use_Biome.stringValue()))
+- {
+- AddCompiledObjectsFromBiome(biomeConfig, objects, Groups);
+- objectsName.add(BODefaultValues.BO_Use_Biome.stringValue());
+- continue;
+- }
-
-- /**
-- * Register a mode to a player (temporary)
-- *
-- * @param player the player to register the mode to
-- * @param mode the mode to register
-- */
-- public void registerMode(String player, String mode) {
-- try {
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""modes (player, mode) VALUES (?, ?)"");
-- statement.setString(1, player);
-- statement.setString(2, mode);
+- CustomObjectCompiled obj = ObjectsStore.CompileString(key, biomeConfig.worldConfig.CustomObjectsDirectory);
+- if (obj == null)
+- obj = ObjectsStore.CompileString(key, ObjectsStore.GlobalDirectory);
+- if (obj != null)
+- {
+- objects.add(obj);
+- objectsName.add(obj.Name);
-
-- statement.executeUpdate();
+- if (!obj.GroupId.equals(""""))
+- {
+- if (!Groups.containsKey(obj.GroupId))
+- Groups.put(obj.GroupId, new ArrayList());
-
+- Groups.get(obj.GroupId).add(obj);
-
-- } catch (final Exception e) {
-- printException(e);
-- }
-- }
+- }
-
-- /**
-- * Register a mode with data to a player (temporary)
-- *
-- * @param player the player to register the mode to
-- * @param mode the mode to register
-- * @param data additional data
-- */
-- public void registerMode(String player, String mode, String data) {
-- try {
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""modes (player, mode, data) VALUES (?, ?, ?)"");
-- statement.setString(1, player);
-- statement.setString(2, mode);
-- statement.setString(3, data);
-
-- statement.executeUpdate();
+- }
-
+- }
-
-- } catch (final Exception e) {
-- printException(e);
+- for (CustomObjectCompiled objectCompiled : objects)
+- {
+- if (Groups.containsKey(objectCompiled.GroupId))
+- {
+- objectCompiled.GroupObjects = Groups.get(objectCompiled.GroupId).toArray(new CustomObjectCompiled[0]);
+- }
- }
+-
+- res.CUObjects = objects.toArray(res.CUObjects);
+- res.CUObjectsNames = objectsName.toArray(res.CUObjectsNames);
+-
+- return true;
- }
-
-- /**
-- * Register a pending lock request to a player
-- *
-- * @param player the player to assign the chest to
-- * @param password the password to register with
-- */
-- public void registerPendingLock(String player, String password) {
-- try {
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""locks (player, password) VALUES (?, ?)"");
-- statement.setString(1, player);
-- statement.setString(2, password);
-
-- statement.executeUpdate();
+- private void AddCompiledObjectsFromWorld(BiomeConfig biomeConfig, ArrayList output, HashMap> groups)
+- {
+- for (CustomObjectCompiled objectCompiled : biomeConfig.worldConfig.CustomObjectsCompiled)
+- if (objectCompiled.CheckBiome(biomeConfig.Name))
+- {
+- output.add(objectCompiled);
+- if (!objectCompiled.GroupId.equals(""""))
+- {
+- if (!groups.containsKey(objectCompiled.GroupId))
+- groups.put(objectCompiled.GroupId, new ArrayList());
-
+- groups.get(objectCompiled.GroupId).add(objectCompiled);
+-
+- }
+-
+- }
-
-- } catch (final Exception e) {
-- printException(e);
-- }
- }
-
-- /**
-- * Add a player to be allowed to access a chest
-- *
-- * @param player the player to add
-- * @param chestID the chest ID to allow them to access
-- */
-- public void registerPlayer(String player, int chestID) {
-- try {
-- PreparedStatement statement = prepare(""INSERT INTO "" + prefix + ""sessions (player, chest) VALUES(?, ?)"");
-- statement.setString(1, player);
-- statement.setInt(2, chestID);
+- private void AddCompiledObjectsFromBiome(BiomeConfig biomeConfig, ArrayList output, HashMap> groups)
+- {
+- for (CustomObjectCompiled objectCompiled : biomeConfig.CustomObjectsCompiled)
+- {
+- output.add(objectCompiled);
+- if (!objectCompiled.GroupId.equals(""""))
+- {
+- if (!groups.containsKey(objectCompiled.GroupId))
+- groups.put(objectCompiled.GroupId, new ArrayList());
-
-- statement.executeUpdate();
+- groups.get(objectCompiled.GroupId).add(objectCompiled);
-
+- }
-
-- } catch (final Exception e) {
-- printException(e);
- }
-- }
-
-- /**
-- * Register a pending chest unlock, for when the player does /unlock
-- *
-- * @param player the player to register
-- * @param chestID the chestID to unlock
-- */
-- public void registerUnlock(String player, int chestID) {
-- registerAction(""unlock"", player, chestID);
- }
-
-- /**
-- * @return the number of active session
-- */
-- public int sessionCount() {
-- int count = 0;
+-}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/CustomObjectLoader.java b/common/src/com/khorn/terraincontrol/customobjects/CustomObjectLoader.java
+new file mode 100644
+index 000000000..b4ab6a652
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/CustomObjectLoader.java
+@@ -0,0 +1,8 @@
++package com.khorn.terraincontrol.customobjects;
++
++import java.io.File;
++
++public interface CustomObjectLoader
++{
++ public CustomObject loadFromFile(String objectName, File file);
++}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/CustomObjectManager.java b/common/src/com/khorn/terraincontrol/customobjects/CustomObjectManager.java
+new file mode 100644
+index 000000000..580a41005
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/CustomObjectManager.java
+@@ -0,0 +1,221 @@
++package com.khorn.terraincontrol.customobjects;
++
++import java.io.File;
++import java.util.HashMap;
++import java.util.Map;
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.configuration.WorldConfig;
++import com.khorn.terraincontrol.customobjects.bo2.BO2Loader;
++import com.khorn.terraincontrol.generator.resourcegens.TreeType;
++
++public class CustomObjectManager
++{
++ /*
++ * Khoorn's comment, copied from the removed class ObjectsStore:
++
++ Load:
++ 1)Load here all objects.
++ 2)Start save coordinates thread.
++ 2)Pre compile objects (make arrays for different angle) ??
++ 3)Compile custom objects array for each biome. Based on world Bo2 list + Biome Bo2 list + Biome CustomTree list
++ a) store in one array in biome
++ b) store in different arrays in biome ???
++ 4) Load ObjectCoordinates from file and add that instance to save thread.
++
++ New load
++ 1) Load all objects from world directory
++ 2) Search and load objects from plugin directory
++
++
++
++ Spawn:
++ 1)CustomObject resource, Tree resource, sapling, command
++ 2)Select random object if needed.
++ 3)Check for biome and select CustomBiome array if needed.
++ 4)Check for spawn conditions.
++ 5)Check for collision
++ a) Check for block collisions
++ b) If out of loaded chunks and object.dig == false - drop.
++ c) If out of loaded chunks and object.branch && !object.digBranch == true - drop
++ d) ??
++ 6)Set blocks
++ a) If out of loaded chunks - get ObjectBuffer from CoordinatesStore and save to it.
++ b) If found branch start point - select random branch from group and call 5 for it.
++
++
++ Calculate branch size for in chunk check??
++ Call branch in this chunk or in next ??
++
++ */
++
++
++
++ public final Map loaders;
++ public final Map globalObjects;
++
++ public CustomObjectManager(Map loaders, Map globalObjects)
++ {
++ // These are the actual lists, not just a copy.
++ this.loaders = loaders;
++ this.globalObjects = globalObjects;
++
++ // Register loaders
++ TerrainControl.registerCustomObjectLoader(""bo2"", new BO2Loader());
++
++ // Load all global objects (they can overwrite special objects)
++ TerrainControl.getEngine().getGlobalObjectsDirectory().mkdirs();
++ this.globalObjects.putAll(loadObjects(TerrainControl.getEngine().getGlobalObjectsDirectory()));
++ TerrainControl.log(this.globalObjects.size() + "" global custom objects loaded."");
++
++ // Put some default CustomObjects
++ for(TreeType type: TreeType.values())
++ {
++ globalObjects.put(type.name().toLowerCase(), new TreeObject(type));
++ }
++ globalObjects.put(""useworld"", new UseWorld());
++ globalObjects.put(""usebiome"", new UseBiome());
++ }
++
++ /**
++ * Returns the global CustomObject with the given name.
++ * @param name Name of the CustomObject, case-insensitive.
++ * @return The CustomObject, or null if there isn't one with that name.
++ */
++ public CustomObject getCustomObject(String name)
++ {
++ return globalObjects.get(name.toLowerCase());
++ }
++
++ /**
++ * Returns the CustomObject with the given name. It searches for a world object first, and then it searches for a global object.
++ * @param name Name of the CustomObject, case-insensitive.
++ * @param world The world to search in first before searching the global objects.
++ * @return The CustomObject, or null if there isn't one with that name.
++ */
++ public CustomObject getCustomObject(String name, LocalWorld world)
++ {
++ return getCustomObject(name, world.getSettings());
++ }
++
++ /**
++ * Returns the CustomObject with the given name. It searches for a world object first, and then it searches for a global object.
++ * @param name Name of the CustomObject, case-insensitive.
++ * @param config The config to search in first before searching the global objects.
++ * @return The CustomObject, or null if there isn't one with that name.
++ */
++ public CustomObject getCustomObject(String name, WorldConfig config)
++ {
++ if(config.customObjects.containsKey(name.toLowerCase())) {
++ return config.customObjects.get(name.toLowerCase());
++ }
++ return getCustomObject(name);
++ }
++
++ /**
++ * Returns a Map with all CustomObjects in a directory in it. The Map will
++ * have the lowercase object name as a key.
++ *
++ * @param directory
++ * The directory to load from.
++ * @return
++ */
++ public Map loadObjects(File directory)
++ {
++ if (!directory.isDirectory())
++ {
++ throw new IllegalArgumentException(""Given file is not a directory: "" + directory.getAbsolutePath());
++ }
++
++ Map objects = new HashMap();
++ for (File file : directory.listFiles())
++ {
++ // Get name and extension
++ String[] fileName = file.getName().split(""\\."");
++ String objectName;
++ String objectType;
++ if (fileName.length == 1)
++ {
++ // Found an object without an extension
++ objectName = fileName[0];
++ objectType = """";
++ } else
++ {
++ // Found an object with an extension
++ objectType = fileName[fileName.length - 1];
++ objectName = """";
++ for (int i = 0; i < fileName.length - 2; i++)
++ {
++ objectName += fileName[i];
++ }
++ }
++
++ // Get the object
++ CustomObjectLoader loader = loaders.get(objectType);
++ if (loader != null)
++ {
++ objects.put(objectName.toLowerCase(), loader.loadFromFile(objectName, file));
++ }
++ }
++
++ return objects;
++ }
++
++ /**
++ * Parses a String in the format name(setting1=foo,setting2=bar) and returns a CustomObject.
++ * @param string
++ * @param world The world to search in
++ * @return A CustomObject, or null if no one was found.
++ */
++ public CustomObject getObjectFromString(String string, LocalWorld world)
++ {
++ return this.getObjectFromString(string, world.getSettings());
++ }
++
++ /**
++ * Parses a String in the format name(setting1=foo,setting2=bar) and returns a CustomObject.
++ * @param string
++ * @param config The config to search in
++ * @return A CustomObject, or null if no one was found.
++ */
++ public CustomObject getObjectFromString(String string, WorldConfig config)
++ {
++ String[] parts = new String[]{string, """"};
++
++ int start = string.indexOf(""("");
++ int end = string.lastIndexOf("")"");
++ if (start != -1 && end != -1)
++ {
++ parts[0] = string.substring(0, start);
++ parts[1] = string.substring(start + 1, end);
++ }
++
++ CustomObject object = getCustomObject(parts[0], config);
++
++ if(object != null && parts[1].length() != 0) {
++ // More settings have been given
++ Map settingsMap = new HashMap();
++
++ String[] settings = parts[1].split("";"");
++ for(String setting: settings)
++ {
++ String[] settingParts = setting.split(""="");
++ if(settingParts.length == 1)
++ {
++ // Boolean values
++ settingsMap.put(settingParts[0], ""true"");
++ } else if(settingParts.length == 2)
++ {
++ settingsMap.put(settingParts[0], settingParts[1]);
++ }
++ }
++
++ if(settingsMap.size() > 0)
++ {
++ object = object.applySettings(settingsMap);
++ }
++ }
++
++ return object;
++ }
++}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/ObjectBuffer.java b/common/src/com/khorn/terraincontrol/customobjects/ObjectBuffer.java
+deleted file mode 100644
+index fb4562ae5..000000000
+--- a/common/src/com/khorn/terraincontrol/customobjects/ObjectBuffer.java
++++ /dev/null
+@@ -1,6 +0,0 @@
+-package com.khorn.terraincontrol.customobjects;
-
-- try {
-- Statement statement = connection.createStatement();
-- final ResultSet set = statement.executeQuery(""SELECT id FROM "" + prefix + ""sessions"");
+-public class ObjectBuffer
+-{
-
-- while (set.next()) {
-- count++;
-- }
+-}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/ObjectCoordinatesStore.java b/common/src/com/khorn/terraincontrol/customobjects/ObjectCoordinatesStore.java
+deleted file mode 100644
+index 1236b4b6d..000000000
+--- a/common/src/com/khorn/terraincontrol/customobjects/ObjectCoordinatesStore.java
++++ /dev/null
+@@ -1,28 +0,0 @@
+-package com.khorn.terraincontrol.customobjects;
+-
+-import java.io.File;
+-import java.util.Hashtable;
-
-- statement.close();
+-public class ObjectCoordinatesStore implements Runnable
+-{
-
-- } catch (final Exception e) {
-- printException(e);
-- }
+- public Hashtable Coordinates;
+-
+- public ObjectCoordinatesStore()
+- {
+- this.Coordinates = new Hashtable();
-
-- return count;
- }
-
-- /**
-- * Unregister a pending chest unlock
-- *
-- * @param player the player to unregister
-- */
-- public void unregisterAction(String action, String player) {
-- try {
-- PreparedStatement statement = prepare(""DELETE FROM "" + prefix + ""actions WHERE action = ? AND player = ?"");
-- statement.setString(1, action);
-- statement.setString(2, player);
+- public void ReadStore(File data)
+- {
-
-- statement.executeUpdate();
+- }
-
+- // Save thread.
+- @Override
+- public void run()
+- {
-
-- } catch (final Exception e) {
-- printException(e);
-- }
- }
+-}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/ObjectsStore.java b/common/src/com/khorn/terraincontrol/customobjects/ObjectsStore.java
+deleted file mode 100644
+index b54a7a491..000000000
+--- a/common/src/com/khorn/terraincontrol/customobjects/ObjectsStore.java
++++ /dev/null
+@@ -1,139 +0,0 @@
+-package com.khorn.terraincontrol.customobjects;
-
-- /**
-- * Unregister all of the actions for a player
-- *
-- * @param player the player to unregister
-- */
-- public void unregisterAllActions(String player) {
-- try {
-- PreparedStatement statement = prepare(""DELETE FROM "" + prefix + ""actions WHERE player = ?"");
-- statement.setString(1, player);
-
-- statement.executeUpdate();
+-import java.io.File;
+-import java.util.ArrayList;
-
+-public class ObjectsStore
+-{
-
-- } catch (final Exception e) {
-- printException(e);
-- }
-- }
+- /*
+- Load:
+- 1)Load here all objects.
+- 2)Start save coordinates thread.
+- 2)Pre compile objects (make arrays for different angle) ??
+- 3)Compile custom objects array for each biome. Based on world Bo2 list + Biome Bo2 list + Biome CustomTree list
+- a) store in one array in biome
+- b) store in different arrays in biome ???
+- 4) Load ObjectCoordinates from file and add that instance to save thread.
-
-- /**
-- * Remove all the pending chest requests
-- */
-- public void unregisterAllChests() {
-- try {
-- Statement statement = connection.createStatement();
-- statement.executeUpdate(""DELETE FROM "" + prefix + ""locks"");
+- New load
+- 1) Load all objects from world directory
+- 2) Search and load objects from plugin directory
-
-- statement.close();
-
-- } catch (final Exception e) {
-- printException(e);
-- }
-- }
-
-- /**
-- * Unregister all of the modes FROM "" + prefix + ""a player
-- *
-- * @param player the player to unregister all modes from
-- */
-- public void unregisterAllModes(String player) {
-- try {
-- PreparedStatement statement = prepare(""DELETE FROM "" + prefix + ""modes WHERE player = ?"");
-- statement.setString(1, player);
+- Spawn:
+- 1)CustomObject resource, Tree resource, sapling, command
+- 2)Select random object if needed.
+- 3)Check for biome and select CustomBiome array if needed.
+- 4)Check for spawn conditions.
+- 5)Check for collision
+- a) Check for block collisions
+- b) If out of loaded chunks and object.dig == false - drop.
+- c) If out of loaded chunks and object.branch && !object.digBranch == true - drop
+- d) ??
+- 6)Set blocks
+- a) If out of loaded chunks - get ObjectBuffer from CoordinatesStore and save to it.
+- b) If found branch start point - select random branch from group and call 5 for it.
+-
+-
+- Calculate branch size for in chunk check??
+- Call branch in this chunk or in next ??
+-
-
-- statement.executeUpdate();
-
-
-- } catch (final Exception e) {
-- printException(e);
-- }
-- }
-
-- /**
-- * Unregister a mode FROM "" + prefix + ""a player
-- *
-- * @param player the player to register the mode to
-- * @param mode the mode to unregister
- */
-- public void unregisterMode(String player, String mode) {
-- try {
-- PreparedStatement statement = prepare(""DELETE FROM "" + prefix + ""modes WHERE player = ? AND mode = ?"");
-- statement.setString(1, player);
-- statement.setString(2, mode);
-
-- statement.executeUpdate();
-
+- public static File GlobalDirectory;
+-
+- public static void ReadObjects(File pluginPath)
+- {
+- GlobalDirectory = new File(pluginPath, BODefaultValues.BO_GlobalDirectoryName.stringValue());
-
-- } catch (final Exception e) {
-- printException(e);
+- if (!GlobalDirectory.exists())
+- {
+- if (!GlobalDirectory.mkdirs())
+- {
+- System.out.println(""TerrainControl: can`t create GlobalObjects directory"");
+- }
- }
+-
+-
+- //objectsList = LoadObjectsFromDirectory(directory);
+-
+- //System.out.println(""TerrainControl: "" + objectsList.size() + "" custom objects loaded"");
+-
+-
- }
-
-- /**
-- * Remove a pending lock request FROM "" + prefix + ""a player
-- *
-- * @param player the player to remove
-- */
-- public void unregisterPendingLock(String player) {
-- try {
-- PreparedStatement statement = prepare(""DELETE FROM "" + prefix + ""locks WHERE player = ?"");
-- statement.setString(1, player);
-
-- statement.executeUpdate();
+- public static ArrayList LoadObjectsFromDirectory(File path)
+- {
+- ArrayList outputList = new ArrayList();
-
+- File[] files = path.listFiles();
+- if (files == null)
+- return outputList;
-
-- } catch (final Exception e) {
-- printException(e);
+- for (File customObjectFile : files)
+- {
+- if (customObjectFile.isFile())
+- {
+- CustomObject object = new CustomObject(customObjectFile);
+- if (object.IsValid)
+- outputList.add(object);
+- }
- }
-- }
+- return outputList;
-
-- /**
-- * Remove a player FROM "" + prefix + ""any sessions
-- *
-- * @param player the player to remove
-- */
-- public void unregisterPlayer(String player) {
-- try {
-- PreparedStatement statement = prepare(""DELETE FROM "" + prefix + ""sessions WHERE player = ?"");
-- statement.setString(1, player);
-
-- statement.executeUpdate();
+- }
+-
+- public static String[] ParseString(String key)
+- {
+- String[] output = new String[]{key, """"};
-
-- } catch (final Exception e) {
-- printException(e);
+- int start = key.indexOf(""("");
+- int end = key.lastIndexOf("")"");
+- if (start != -1 && end != -1)
+- {
+- output[0] = key.substring(0, start);
+- output[1] = key.substring(start + 1, end);
- }
+- return output;
- }
-
-- /**
-- * Unregister a pending chest unlock
-- *
-- * @param player the player to unregister
-- */
-- public void unregisterUnlock(String player) {
-- unregisterAction(""unlock"", player);
+- public static CustomObject GetObjectFromDirectory(String name, File directory)
+- {
+- File customObjectFile = new File(directory, name+"".""+BODefaultValues.BO_Extension.stringValue());
+-
+- if (!customObjectFile.isFile())
+- {
+- return null;
+- }
+-
+- CustomObject object = new CustomObject(customObjectFile);
+-
+- if (!object.IsValid)
+- {
+- return null;
+- }
+-
+- return object;
- }
-
--}"
-c9d4924dcf129512dadd22dcd6fe0046cbcded43,drools,BZ-1039639 - GRE doesn't recognize MVEL inline- lists when opening rule--,c,https://github.com/kiegroup/drools,"diff --git a/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java b/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java
-index 05b7b836bf1..9da1dd93e78 100644
---- a/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java
-+++ b/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java
-@@ -26,7 +26,9 @@
- import org.drools.workbench.models.datamodel.oracle.ModelField;
- import org.drools.workbench.models.datamodel.oracle.PackageDataModelOracle;
- import org.drools.workbench.models.datamodel.rule.ActionCallMethod;
-+import org.drools.workbench.models.datamodel.rule.ActionFieldValue;
- import org.drools.workbench.models.datamodel.rule.ActionGlobalCollectionAdd;
-+import org.drools.workbench.models.datamodel.rule.ActionSetField;
- import org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint;
- import org.drools.workbench.models.datamodel.rule.CEPWindow;
- import org.drools.workbench.models.datamodel.rule.CompositeFactPattern;
-@@ -36,6 +38,8 @@
- import org.drools.workbench.models.datamodel.rule.ExpressionVariable;
- import org.drools.workbench.models.datamodel.rule.FactPattern;
- import org.drools.workbench.models.datamodel.rule.FieldConstraint;
-+import org.drools.workbench.models.datamodel.rule.FieldNature;
-+import org.drools.workbench.models.datamodel.rule.FieldNatureType;
- import org.drools.workbench.models.datamodel.rule.FreeFormLine;
- import org.drools.workbench.models.datamodel.rule.IPattern;
- import org.drools.workbench.models.datamodel.rule.RuleModel;
-@@ -1982,6 +1986,43 @@ public void testExpressionWithListSize() throws Exception {
- assertEquals(1,constraint.getConstraintValueType());
- }
-
-+ @Test
-+ @Ignore(""https://bugzilla.redhat.com/show_bug.cgi?id=1039639 - GRE doesn't recognize MVEL inline lists when opening rule"")
-+ public void testMVELInlineList() throws Exception {
-+ String drl = """" +
-+ ""rule \""Borked\""\n"" +
-+ "" dialect \""mvel\""\n"" +
-+ "" when\n"" +
-+ "" c : Company( )\n"" +
-+ "" then\n"" +
-+ "" c.setEmps( [\""item1\"", \""item2\""] );\n"" +
-+ ""end"";
+- public static CustomObjectCompiled CompileString(String key, File directory)
+- {
+- String[] values = ParseString(key);
+- CustomObject object = GetObjectFromDirectory(values[0], directory);
+-
+- if (object == null)
+- return null;
+-
+- return object.Compile(values[1]);
+- }
+-}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/TreeObject.java b/common/src/com/khorn/terraincontrol/customobjects/TreeObject.java
+new file mode 100644
+index 000000000..aa19e3a59
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/TreeObject.java
+@@ -0,0 +1,90 @@
++package com.khorn.terraincontrol.customobjects;
+
-+ addModelField(""Company"",
-+ ""emps"",
-+ ""java.util.List"",
-+ ""List"");
++import java.util.Map;
++import java.util.Random;
+
-+ RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl,
-+ dmo );
-+ assertEquals( 1,
-+ m.rhs.length );
-+ assertTrue( m.rhs[0] instanceof ActionSetField);
-+ ActionSetField actionSetField = (ActionSetField) m.rhs[0];
++import com.khorn.terraincontrol.LocalBiome;
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.generator.resourcegens.TreeType;
+
-+ assertEquals(""c"", actionSetField.getVariable());
++public class TreeObject implements CustomObject
++{
++ TreeType type;
++
++ public TreeObject(TreeType type)
++ {
++ this.type = type;
++ }
++
++ @Override
++ public String getName()
++ {
++ return type.name();
++ }
+
-+ assertEquals(1, actionSetField.getFieldValues().length);
++ @Override
++ public boolean canSpawnAsTree()
++ {
++ return true;
++ }
++
++ @Override
++ public boolean canSpawnAsObject()
++ {
++ return false;
++ }
+
-+ ActionFieldValue actionFieldValue = actionSetField.getFieldValues()[0];
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int y, int z)
++ {
++ return world.PlaceTree(type, random, x, y, z);
++ }
+
-+ assertEquals(""[\""item1\"", \""item2\""]"",actionFieldValue.getValue());
-+ assertEquals(""emps"",actionFieldValue.getField());
-+ assertEquals(FieldNatureType.TYPE_FORMULA, actionFieldValue.getNature());
-+ assertEquals(""Collection"",actionFieldValue.getType());
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int y, int z)
++ {
++ return world.PlaceTree(type, random, x, y, z);
++ }
++
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int z)
++ {
++ return world.PlaceTree(type, random, x, world.getHighestBlockYAt(x, z), z);
++ }
+
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int z)
++ {
++ return world.PlaceTree(type, random, x, world.getHighestBlockYAt(x, z), z);
+ }
+
- private void assertEqualsIgnoreWhitespace( final String expected,
- final String actual ) {
- final String cleanExpected = expected.replaceAll( ""\\s+"","
-83d5b1e6a0280cc78625bacc2d3f7d1676c7385e,kotlin,Supported propagation for subclass of- j.u.Collection and similar classes.--,a,https://github.com/JetBrains/intellij-community,⚠️ HTTP 404: Not Found
-7db30f8428ef341cc39b2758d3bd6dcccc25b080,hadoop,MAPREDUCE-3345. Fixed a race condition in- ResourceManager that was causing TestContainerManagerSecurity to fail- sometimes. Contributed by Hitesh Shah. svn merge -c r1199144- --ignore-ancestry ../../trunk/--git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1199145 13f79535-47bb-0310-9956-ffa450edef68-,c,https://github.com/apache/hadoop,"diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt
-index 43cb6b7dd248c..e1034c880ef65 100644
---- a/hadoop-mapreduce-project/CHANGES.txt
-+++ b/hadoop-mapreduce-project/CHANGES.txt
-@@ -39,6 +39,9 @@ Release 0.23.1 - Unreleased
- MAPREDUCE-3342. Fixed JobHistoryServer to also show the job's queue
- name. (Jonathan Eagles via vinodkv)
-
-+ MAPREDUCE-3345. Fixed a race condition in ResourceManager that was causing
-+ TestContainerManagerSecurity to fail sometimes. (Hitesh Shah via vinodkv)
++ @Override
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ // A tree has no rarity, so spawn it once in the chunk
++ int x = chunkX * 16 + random.nextInt(16);
++ int z = chunkZ * 16 + random.nextInt(16);
++ int y = world.getHighestBlockYAt(x, z);
++ world.PlaceTree(type, random, x, y, z);
++ }
+
- Release 0.23.0 - 2011-11-01
-
- INCOMPATIBLE CHANGES
-diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
-index 0d81f80121213..71dd982b607af 100644
---- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
-+++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
-@@ -595,8 +595,13 @@ public void transition(RMAppAttemptImpl appAttempt,
- AM_CONTAINER_PRIORITY, ""*"", appAttempt.submissionContext
- .getAMContainerSpec().getResource(), 1);
-
-- appAttempt.scheduler.allocate(appAttempt.applicationAttemptId,
-- Collections.singletonList(request), EMPTY_CONTAINER_RELEASE_LIST);
-+ Allocation amContainerAllocation =
-+ appAttempt.scheduler.allocate(appAttempt.applicationAttemptId,
-+ Collections.singletonList(request), EMPTY_CONTAINER_RELEASE_LIST);
-+ if (amContainerAllocation != null
-+ && amContainerAllocation.getContainers() != null) {
-+ assert(amContainerAllocation.getContainers().size() == 0);
-+ }
- }
- }
-
-diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
-index c61c7ab89f0ec..977150520a195 100644
---- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
-+++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
-@@ -236,28 +236,30 @@ public Allocation allocate(
- RMContainerEventType.RELEASED);
- }
-
-- if (!ask.isEmpty()) {
-- LOG.debug(""allocate: pre-update"" +
-- "" applicationId="" + applicationAttemptId +
-- "" application="" + application);
-- application.showRequests();
--
-- // Update application requests
-- application.updateResourceRequests(ask);
--
-- LOG.debug(""allocate: post-update"" +
-- "" applicationId="" + applicationAttemptId +
-- "" application="" + application);
-- application.showRequests();
-+ synchronized (application) {
-+ if (!ask.isEmpty()) {
-+ LOG.debug(""allocate: pre-update"" +
-+ "" applicationId="" + applicationAttemptId +
-+ "" application="" + application);
-+ application.showRequests();
++ @Override
++ public void processAsTree(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ process(world, random, chunkX, chunkZ);
++ }
+
-+ // Update application requests
-+ application.updateResourceRequests(ask);
++ @Override
++ public CustomObject applySettings(Map settings)
++ {
++ // Trees don't support this
++ return this;
++ }
+
-+ LOG.debug(""allocate: post-update"" +
-+ "" applicationId="" + applicationAttemptId +
-+ "" application="" + application);
-+ application.showRequests();
++ @Override
++ public boolean hasPreferenceToSpawnIn(LocalBiome biome)
++ {
++ return true;
++ }
+
-+ LOG.debug(""allocate:"" +
-+ "" applicationId="" + applicationAttemptId +
-+ "" #ask="" + ask.size());
-+ }
-
-- LOG.debug(""allocate:"" +
-- "" applicationId="" + applicationAttemptId +
-- "" #ask="" + ask.size());
-+ return new Allocation(
-+ application.pullNewlyAllocatedContainers(),
-+ application.getHeadroom());
- }
--
-- return new Allocation(
-- application.pullNewlyAllocatedContainers(),
-- application.getHeadroom());
- }
-
- private SchedulerApp getApplication("
-7631ac6f526edf472d1383f7b82171c7ac29f0fb,Delta Spike,"DELTASPIKE-378 add getPropertyAwarePropertyValue
-
-feel free to propose a better name if you find one :)
-",a,https://github.com/apache/deltaspike,"diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
-index 05cbc59df..6b3ada263 100644
---- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
-+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
-@@ -162,18 +162,110 @@ public static String getPropertyValue(String key)
- * Attention This method must only be used after all ConfigSources
- * got registered and it also must not be used to determine the ProjectStage itself.
- * @param key
-+ * @return the configured value or if non found the defaultValue
-+ *
-+ */
-+ public static String getProjectStageAwarePropertyValue(String key)
++}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/UseBiome.java b/common/src/com/khorn/terraincontrol/customobjects/UseBiome.java
+new file mode 100644
+index 000000000..ca6864099
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/UseBiome.java
+@@ -0,0 +1,124 @@
++package com.khorn.terraincontrol.customobjects;
++
++import java.util.ArrayList;
++import java.util.Map;
++import java.util.Random;
++
++import com.khorn.terraincontrol.LocalBiome;
++import com.khorn.terraincontrol.LocalWorld;
++
++/**
++ * UseBiome is a keyword that spawns the objects in the BiomeConfig/BiomeObjects
++ * setting.
++ *
++ */
++public class UseBiome implements CustomObject
++{
++ public ArrayList getPossibleObjectsAt(LocalWorld world, int x, int z)
++ {
++ return world.getSettings().biomeConfigs[world.getBiome(x, z).getId()].biomeObjects;
++ }
++
++ @Override
++ public String getName()
++ {
++ return ""UseBiome"";
++ }
++
++ @Override
++ public boolean canSpawnAsTree()
++ {
++ return true;
++ }
++
++ @Override
++ public boolean canSpawnAsObject()
+ {
-+ ProjectStage ps = getProjectStage();
++ return true;
++ }
+
-+ String value = getPropertyValue(key + '.' + ps);
-+ if (value == null)
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int y, int z)
++ {
++ for (CustomObject object : getPossibleObjectsAt(world, x, z))
+ {
-+ value = getPropertyValue(key);
++ if (object.spawn(world, random, x, y, z))
++ {
++ return true;
++ }
+ }
++ return false;
++ }
+
-+ return value;
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int y, int z)
++ {
++ for (CustomObject object : getPossibleObjectsAt(world, x, z))
++ {
++ if (object.spawnAsTree(world, random, x, y, z))
++ {
++ return true;
++ }
++ }
++ return false;
+ }
-+ /**
-+ * {@link #getProjectStageAwarePropertyValue(String)} which returns the defaultValue
-+ * if the property is null or empty.
-+ * @param key
- * @param defaultValue
- * @return the configured value or if non found the defaultValue
- *
- */
- public static String getProjectStageAwarePropertyValue(String key, String defaultValue)
- {
-- ProjectStage ps = getProjectStage();
-+ String value = getProjectStageAwarePropertyValue(key);
+
-+ if (value == null || value.length() == 0)
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int z)
++ {
++ for (CustomObject object : getPossibleObjectsAt(world, x, z))
+ {
-+ value = defaultValue;
++ if (object.spawn(world, random, x, z))
++ {
++ return true;
++ }
+ }
++ return false;
++ }
+
-+ return value;
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int z)
++ {
++ for (CustomObject object : getPossibleObjectsAt(world, x, z))
++ {
++ if (object.spawnAsTree(world, random, x, z))
++ {
++ return true;
++ }
++ }
++ return false;
+ }
+
-+ /**
-+ * Search for the configured value in all {@link ConfigSource}s and take the
-+ * current {@link org.apache.deltaspike.core.api.projectstage.ProjectStage}
-+ * and the value configured for the given property into account.
-+ *
-+ * The first step is to resolve the value of the given property. This will
-+ * take the current ProjectStage into account. E.g. given the property is 'dbvendor'
-+ * and the ProjectStage is 'UnitTest', the first lookup is
-+ *
.
-+ * If this value is not found then we will do a 2nd lookup for
-+ *
-+ *
-+ * If a value was found for the given property (e.g. dbvendor = 'mysql'
-+ * then we will use this value to lookup in the following order until we
-+ * found a non-null value. If there was no value found for the property
-+ * we will only do the key+ProjectStage and key lookup.
-+ * In the following sample 'dataSource' is used as key parameter:
-+ *
-+ *
-+ * - 'datasource.mysql.UnitTest'
-+ * - 'datasource.mysql'
-+ * - 'datasource.UnitTest'
-+ * - 'datasource'
-+ *
-+ *
-+ *
-+ *
-+ * Attention This method must only be used after all ConfigSources
-+ * got registered and it also must not be used to determine the ProjectStage itself.
-+ * @param key
-+ * @param property the property to look up first
-+ * @return the configured value or if non found the defaultValue
-+ *
-+ */
-+ public static String getPropertyAwarePropertyValue(String key, String property)
++ @Override
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ for (CustomObject object : getPossibleObjectsAt(world, chunkX * 16 + 8, chunkZ * 16 + 8))
++ {
++ object.process(world, random, chunkX, chunkZ);
++ }
++ }
++
++ @Override
++ public void processAsTree(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ for (CustomObject object : getPossibleObjectsAt(world, chunkX * 16 + 8, chunkZ * 16 + 8))
++ {
++ object.processAsTree(world, random, chunkX, chunkZ);
++ }
++ }
++
++ @Override
++ public CustomObject applySettings(Map settings)
++ {
++ // Not supported
++ return this;
++ }
++
++ @Override
++ public boolean hasPreferenceToSpawnIn(LocalBiome biome)
++ {
++ // Never, ever spawn this with UseWorld.
++ return false;
++ }
++
++}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/UseWorld.java b/common/src/com/khorn/terraincontrol/customobjects/UseWorld.java
+new file mode 100644
+index 000000000..cfd50f842
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/UseWorld.java
+@@ -0,0 +1,118 @@
++package com.khorn.terraincontrol.customobjects;
++
++import java.util.Map;
++import java.util.Random;
++
++import com.khorn.terraincontrol.LocalBiome;
++import com.khorn.terraincontrol.LocalWorld;
++
++/**
++ * UseWorld is a keyword that spawns the objects in the WorldObjects folder.
++ *
++ */
++public class UseWorld implements CustomObject
++{
++
++ @Override
++ public String getName()
++ {
++ return ""UseWorld"";
++ }
++
++ @Override
++ public boolean canSpawnAsTree()
+ {
-+ String propertyValue = getProjectStageAwarePropertyValue(property);
++ return true;
++ }
+
-+ String value = null;
++ @Override
++ public boolean canSpawnAsObject()
++ {
++ return true;
++ }
+
-+ if (propertyValue != null && propertyValue.length() > 0)
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int y, int z)
++ {
++ for(CustomObject object: world.getSettings().customObjects.values())
+ {
-+ value = getProjectStageAwarePropertyValue(key + '.' + propertyValue);
++ if(object.hasPreferenceToSpawnIn(world.getBiome(x, z)) && object.spawn(world, random, x, y, z))
++ {
++ return true;
++ }
+ }
-
-- String value = getPropertyValue(key + '.' + ps, defaultValue);
- if (value == null)
- {
-- value = getPropertyValue(key, defaultValue);
-+ value = getProjectStageAwarePropertyValue(key);
++ return false;
++ }
++
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int y, int z)
++ {
++ for(CustomObject object: world.getSettings().customObjects.values())
++ {
++ if(object.spawnAsTree(world, random, x, y, z))
++ {
++ return true;
++ }
+ }
++ return false;
++ }
+
-+ return value;
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int z)
++ {
++ for(CustomObject object: world.getSettings().customObjects.values())
++ {
++ if(object.spawn(world, random, x, z))
++ {
++ return true;
++ }
++ }
++ return false;
+ }
+
-+ /*
-+ * Attention This method must only be used after all ConfigSources
-+ * got registered and it also must not be used to determine the ProjectStage itself.
-+ * @param key
-+ * @param property the property to look up first
-+ * @param defaultValue
-+ * @return the configured value or if non found the defaultValue
-+ *
-+ */
-+ public static String getPropertyAwarePropertyValue(String key, String property, String defaultValue)
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int z)
+ {
-+ String value = getPropertyAwarePropertyValue(key, property);
++ for(CustomObject object: world.getSettings().customObjects.values())
++ {
++ if(object.spawnAsTree(world, random, x, z))
++ {
++ return true;
++ }
++ }
++ return false;
++ }
+
-+ if (value == null || value.length() == 0)
++ @Override
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ for(CustomObject object: world.getSettings().customObjects.values())
+ {
-+ value = defaultValue;
- }
-
- return value;
-diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/ConfigResolverTest.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/ConfigResolverTest.java
-index 91ebb22dc..d30e7de52 100644
---- a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/ConfigResolverTest.java
-+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/ConfigResolverTest.java
-@@ -28,6 +28,7 @@
-
- public class ConfigResolverTest
- {
-+ private static final String DEFAULT_VALUE = ""defaultValue"";
- @Test
- public void testOverruledValue()
- {
-@@ -60,12 +61,43 @@ public void testGetProjectStageAwarePropertyValue()
- Assert.assertNull(ConfigResolver.getProjectStageAwarePropertyValue(""notexisting"", null));
-
- Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyValue(""testkey"", null));
-+ Assert.assertEquals(""unittestvalue"", ConfigResolver.getProjectStageAwarePropertyValue(""testkey""));
- Assert.assertEquals(""unittestvalue"", ConfigResolver.getProjectStageAwarePropertyValue(""testkey"", null));
-
- Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyValue(""testkey2"", null));
-+ Assert.assertEquals(""testvalue"", ConfigResolver.getProjectStageAwarePropertyValue(""testkey2""));
- Assert.assertEquals(""testvalue"", ConfigResolver.getProjectStageAwarePropertyValue(""testkey2"", null));
-
- Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyValue(""testkey3"", null));
-- Assert.assertEquals("""", ConfigResolver.getProjectStageAwarePropertyValue(""testkey3"", null));
-+ Assert.assertEquals("""", ConfigResolver.getProjectStageAwarePropertyValue(""testkey3""));
-+ Assert.assertEquals(DEFAULT_VALUE, ConfigResolver.getProjectStageAwarePropertyValue(""testkey3"", DEFAULT_VALUE));
++ object.process(world, random, chunkX, chunkZ);
++ }
+ }
+
-+ @Test
-+ public void testGetPropertyAwarePropertyValue() {
-+ ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
++ @Override
++ public void processAsTree(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ for(CustomObject object: world.getSettings().customObjects.values())
++ {
++ object.processAsTree(world, random, chunkX, chunkZ);
++ }
++ }
+
-+ Assert.assertNull(ConfigResolver.getPropertyAwarePropertyValue(""notexisting"", null));
++ @Override
++ public CustomObject applySettings(Map settings)
++ {
++ // Not supported
++ return this;
++ }
+
-+ Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyValue(""testkey"", null));
-+ Assert.assertEquals(""unittestvalue"", ConfigResolver.getPropertyAwarePropertyValue(""testkey"", ""dbvendor""));
-+ Assert.assertEquals(""unittestvalue"", ConfigResolver.getPropertyAwarePropertyValue(""testkey"", ""dbvendor"", null));
++ @Override
++ public boolean hasPreferenceToSpawnIn(LocalBiome biome)
++ {
++ // Never, ever spawn this in UseWorld. It would cause an infinite loop.
++ return false;
++ }
+
-+ Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyValue(""testkey2"", null));
-+ Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyAwarePropertyValue(""testkey2"", ""dbvendor""));
-+ Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyAwarePropertyValue(""testkey2"", ""dbvendor"", null));
++}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/bo2/BO2.java b/common/src/com/khorn/terraincontrol/customobjects/bo2/BO2.java
+new file mode 100644
+index 000000000..638fe02bf
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/bo2/BO2.java
+@@ -0,0 +1,454 @@
++package com.khorn.terraincontrol.customobjects.bo2;
+
-+ Assert.assertEquals(""testvalue"", ConfigResolver.getPropertyValue(""testkey3"", null));
-+ Assert.assertEquals("""", ConfigResolver.getPropertyAwarePropertyValue(""testkey3"", ""dbvendor""));
-+ Assert.assertEquals(DEFAULT_VALUE, ConfigResolver.getPropertyAwarePropertyValue(""testkey3"", ""dbvendor"", DEFAULT_VALUE));
++import java.io.File;
++import java.io.IOException;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.HashSet;
++import java.util.Map;
++import java.util.Random;
+
-+ Assert.assertEquals(""TestDataSource"", ConfigResolver.getPropertyAwarePropertyValue(""dataSource"", ""dbvendor""));
-+ Assert.assertEquals(""PostgreDataSource"", ConfigResolver.getPropertyAwarePropertyValue(""dataSource"", ""dbvendor2""));
-+ Assert.assertEquals(""DefaultDataSource"", ConfigResolver.getPropertyAwarePropertyValue(""dataSource"", ""dbvendorX""));
++import com.khorn.terraincontrol.DefaultMaterial;
++import com.khorn.terraincontrol.LocalBiome;
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.configuration.ConfigFile;
++import com.khorn.terraincontrol.customobjects.BODefaultValues;
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import com.khorn.terraincontrol.customobjects.ObjectCoordinate;
+
-+ Assert.assertEquals(""TestDataSource"", ConfigResolver.getPropertyAwarePropertyValue(""dataSource"", ""dbvendor"", null));
-+ Assert.assertEquals(""PostgreDataSource"", ConfigResolver.getPropertyAwarePropertyValue(""dataSource"", ""dbvendor2"", null));
-+ Assert.assertEquals(""DefaultDataSource"", ConfigResolver.getPropertyAwarePropertyValue(""dataSource"", ""dbvendorX"", null));
-+ Assert.assertEquals(DEFAULT_VALUE, ConfigResolver.getPropertyAwarePropertyValue(""dataSourceX"", ""dbvendorX"", DEFAULT_VALUE));
- }
- }
-diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/TestConfigSource.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/TestConfigSource.java
-index e9e066fba..d0f2c938b 100644
---- a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/TestConfigSource.java
-+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/config/TestConfigSource.java
-@@ -48,6 +48,20 @@ public TestConfigSource()
- // a value which got ProjectStage overloaded to an empty value
- props.put(""testkey3"", ""testvalue"");
- props.put(""testkey3.UnitTest"", """");
++/**
++ * The good old BO2.
++ *
++ */
++public class BO2 extends ConfigFile implements CustomObject
++{
++ public ObjectCoordinate[][] Data = new ObjectCoordinate[4][];
+
-+ // now for the PropertyAware tests
-+ props.put(""dbvendor.UnitTest"", ""mysql"");
-+ props.put(""dbvendor"", ""postgresql"");
++ public BO2[] GroupObjects = null;
+
-+ props.put(""dataSource.mysql.Production"", ""java:/comp/env/MyDs"");
-+ props.put(""dataSource.mysql.UnitTest"", ""TestDataSource"");
-+ props.put(""dataSource.postgresql"", ""PostgreDataSource"");
-+ props.put(""dataSource"", ""DefaultDataSource"");
++ public String Name;
+
-+ // another one
-+ props.put(""dbvendor2.Production"", ""mysql"");
-+ props.put(""dbvendor2"", ""postgresql"");
++ public HashSet SpawnInBiome;
+
- }
-
- @Override"
-3cf09ec9a51263838270cb5f62d5b34cb58f26bb,Vala,"clutter-1.0: add missing type_arguments for several new methods
-
-Partially fixes bug 609875.
-",c,https://github.com/GNOME/vala/,⚠️ Could not parse repo info
-1cda4eacbf8e44d03ecdfb6f16ab523306677cbc,restlet-framework-java, - The Request-isConfidential() method has- been refactored to be supported by Message and Response as well.- The method Request-setConfidential() has been removed (back to- Restlet 1.0 state). Added Protocol-isConfidential() method to- support the new implementation which rely on Request-getProtocol().- Reported by Kevin Conaway.--,p,https://github.com/restlet/restlet-framework-java,"diff --git a/build/tmpl/text/changes.txt b/build/tmpl/text/changes.txt
-index 3bb3740fe2..51208741e0 100644
---- a/build/tmpl/text/changes.txt
-+++ b/build/tmpl/text/changes.txt
-@@ -44,6 +44,12 @@ Changes log
- ""style"" attributes are required.
- - Added the ability the give a title to WadlApplication or
- WadlResource instances. Suggested by Jérôme Bernard.
-+ - The Request#isConfidential() method has been refactored to
-+ be supported by Message and Response as well. The method
-+ Request#setConfidential() has been removed (back to Restlet
-+ 1.0 state). Added Protocol#isConfidential() method to support
-+ the new implementation which rely on Request#getProtocol().
-+ Reported by Kevin Conaway.
- - Misc
- - Updated JAX-RS API to version 1.0. The implementation of the
- runtime environment is not fully finished yet. We are
-diff --git a/modules/com.noelios.restlet/src/com/noelios/restlet/component/ChildClientDispatcher.java b/modules/com.noelios.restlet/src/com/noelios/restlet/component/ChildClientDispatcher.java
-index 4239efb2cf..6d9f19d948 100644
---- a/modules/com.noelios.restlet/src/com/noelios/restlet/component/ChildClientDispatcher.java
-+++ b/modules/com.noelios.restlet/src/com/noelios/restlet/component/ChildClientDispatcher.java
-@@ -72,9 +72,6 @@ public void doHandle(Request request, Response response) {
- final Protocol protocol = request.getProtocol();
-
- if (protocol.equals(Protocol.RIAP)) {
-- // Consider that the request is confidential
-- request.setConfidential(true);
--
- // Let's dispatch it
- final LocalReference cr = new LocalReference(request
- .getResourceRef());
-diff --git a/modules/com.noelios.restlet/src/com/noelios/restlet/component/ComponentClientDispatcher.java b/modules/com.noelios.restlet/src/com/noelios/restlet/component/ComponentClientDispatcher.java
-index fc66f6e836..d81f983b14 100644
---- a/modules/com.noelios.restlet/src/com/noelios/restlet/component/ComponentClientDispatcher.java
-+++ b/modules/com.noelios.restlet/src/com/noelios/restlet/component/ComponentClientDispatcher.java
-@@ -64,9 +64,6 @@ protected void doHandle(Request request, Response response) {
- final Protocol protocol = request.getProtocol();
-
- if (protocol.equals(Protocol.RIAP)) {
-- // Consider that the request is confidential
-- request.setConfidential(true);
--
- // Let's dispatch it
- final LocalReference cr = new LocalReference(request
- .getResourceRef());
-diff --git a/modules/com.noelios.restlet/src/com/noelios/restlet/http/HttpRequest.java b/modules/com.noelios.restlet/src/com/noelios/restlet/http/HttpRequest.java
-index ab6f7fa405..120613d7f6 100644
---- a/modules/com.noelios.restlet/src/com/noelios/restlet/http/HttpRequest.java
-+++ b/modules/com.noelios.restlet/src/com/noelios/restlet/http/HttpRequest.java
-@@ -103,14 +103,6 @@ public HttpRequest(Context context, HttpServerCall httpCall) {
- // Set the properties
- setMethod(Method.valueOf(httpCall.getMethod()));
-
-- if (getHttpCall().isConfidential()) {
-- setConfidential(true);
-- } else {
-- // We don't want to autocreate the security data just for this
-- // information, because that will by the default value of this
-- // property if read by someone.
-- }
--
- // Set the host reference
- final StringBuilder sb = new StringBuilder();
- sb.append(httpCall.getProtocol().getSchemeName()).append(""://"");
-diff --git a/modules/org.restlet/src/org/restlet/data/Message.java b/modules/org.restlet/src/org/restlet/data/Message.java
-index d5ba7847fc..72fdfcd15e 100644
---- a/modules/org.restlet/src/org/restlet/data/Message.java
-+++ b/modules/org.restlet/src/org/restlet/data/Message.java
-@@ -78,49 +78,50 @@ public Message(Representation entity) {
- this.saxRepresentation = null;
- }
-
--/**
-- * Returns the modifiable map of attributes that can be used by developers
-- * to save information relative to the message. Creates a new instance if no
-- * one has been set. This is an easier alternative to the creation of a
-- * wrapper instance around the whole message.
-- *
-- *
-- * In addition, this map is a shared space between the developer and the
-- * connectors. In this case, it is used to exchange information that is not
-- * uniform across all protocols and couldn't therefore be directly included
-- * in the API. For this purpose, all attribute names starting with
-- * ""org.restlet"" are reserved. Currently the following attributes are used:
-- *
-- *
-- * | Attribute name |
-- * Class name |
-- * Description |
-- *
-- *
-- * | org.restlet.http.headers |
-- * org.restlet.data.Form |
-- * Server HTTP connectors must provide all request headers and client
-- * HTTP connectors must provide all response headers, exactly as they were
-- * received. In addition, developers can also use this attribute to specify
-- * non-standard headers that should be added to the request or to
-- * the response. |
-- *
-- *
-- * | org.restlet.https.clientCertificates |
-- * List |
-- * For requests received via a secure connector, indicates the ordered
-- * list of client certificates, if they are available and accessible. |
-- *
-- *
-- * Most of the standard HTTP headers are directly supported via the Restlet
-- * API. Thus, adding such HTTP headers is forbidden because it could
-- * conflict with the connector's internal behavior, limit portability or
-- * prevent future optimizations. The other standard HTTP headers (that are
-- * not supported) can be added as attributes via the
-- * ""org.restlet.http.headers"" key.
-- *
-- * @return The modifiable attributes map.
-- */
-+ /**
-+ * Returns the modifiable map of attributes that can be used by developers
-+ * to save information relative to the message. Creates a new instance if no
-+ * one has been set. This is an easier alternative to the creation of a
-+ * wrapper instance around the whole message.
-+ *
-+ *
-+ * In addition, this map is a shared space between the developer and the
-+ * connectors. In this case, it is used to exchange information that is not
-+ * uniform across all protocols and couldn't therefore be directly included
-+ * in the API. For this purpose, all attribute names starting with
-+ * ""org.restlet"" are reserved. Currently the following attributes are used:
-+ *
-+ *
-+ * | Attribute name |
-+ * Class name |
-+ * Description |
-+ *
-+ *
-+ * | org.restlet.http.headers |
-+ * org.restlet.data.Form |
-+ * Server HTTP connectors must provide all request headers and client
-+ * HTTP connectors must provide all response headers, exactly as they were
-+ * received. In addition, developers can also use this attribute to specify
-+ * non-standard headers that should be added to the request or to the
-+ * response. |
-+ *
-+ *
-+ * | org.restlet.https.clientCertificates |
-+ * List |
-+ * For requests received via a secure connector, indicates the ordered
-+ * list of client certificates, if they are available and accessible. |
-+ *
-+ *
-+ *
-+ * Most of the standard HTTP headers are directly supported via the Restlet
-+ * API. Thus, adding such HTTP headers is forbidden because it could
-+ * conflict with the connector's internal behavior, limit portability or
-+ * prevent future optimizations. The other standard HTTP headers (that are
-+ * not supported) can be added as attributes via the
-+ * ""org.restlet.http.headers"" key.
-+ *
-+ * @return The modifiable attributes map.
-+ */
- public Map getAttributes() {
- if (this.attributes == null) {
- this.attributes = new TreeMap();
-@@ -234,6 +235,14 @@ public SaxRepresentation getEntityAsSax() {
- return this.saxRepresentation;
- }
-
-+ /**
-+ * Indicates if the message was or will be exchanged confidentially, for
-+ * example via a SSL-secured connection.
-+ *
-+ * @return True if the message is confidential.
-+ */
-+ public abstract boolean isConfidential();
++ public String Version;
++ public HashSet SpawnOnBlockType;
+
- /**
- * Indicates if a content is available and can be sent. Several conditions
- * must be met: the content must exists and have some available data.
-diff --git a/modules/org.restlet/src/org/restlet/data/Protocol.java b/modules/org.restlet/src/org/restlet/data/Protocol.java
-index f21d806ff5..65669bbd3e 100644
---- a/modules/org.restlet/src/org/restlet/data/Protocol.java
-+++ b/modules/org.restlet/src/org/restlet/data/Protocol.java
-@@ -59,7 +59,7 @@ public final class Protocol extends Metadata {
- * @see org.restlet.data.LocalReference
- */
- public static final Protocol CLAP = new Protocol(""clap"", ""CLAP"",
-- ""Class Loader Access Protocol"", UNKNOWN_PORT);
-+ ""Class Loader Access Protocol"", UNKNOWN_PORT, true);
-
- /**
- * FILE is a standard scheme to access to representations stored in the file
-@@ -72,7 +72,7 @@ public final class Protocol extends Metadata {
- * @see org.restlet.data.LocalReference
- */
- public static final Protocol FILE = new Protocol(""file"", ""FILE"",
-- ""Local File System Protocol"", UNKNOWN_PORT);
-+ ""Local File System Protocol"", UNKNOWN_PORT, true);
-
- /** FTP protocol. */
- public static final Protocol FTP = new Protocol(""ftp"", ""FTP"",
-@@ -84,7 +84,7 @@ public final class Protocol extends Metadata {
-
- /** HTTPS protocol (via SSL socket). */
- public static final Protocol HTTPS = new Protocol(""https"", ""HTTPS"",
-- ""HyperText Transport Protocol (Secure)"", 443);
-+ ""HyperText Transport Protocol (Secure)"", 443, true);
-
- /**
- * JAR (Java ARchive) is a common scheme to access to representations inside
-@@ -94,7 +94,7 @@ public final class Protocol extends Metadata {
- * @see org.restlet.data.LocalReference
- */
- public static final Protocol JAR = new Protocol(""jar"", ""JAR"",
-- ""Java ARchive"", UNKNOWN_PORT);
-+ ""Java ARchive"", UNKNOWN_PORT, true);
-
- /** JDBC protocol. */
- public static final Protocol JDBC = new Protocol(""jdbc"", ""JDBC"",
-@@ -106,7 +106,7 @@ public final class Protocol extends Metadata {
-
- /** POPS protocol (via SSL/TLS socket).. */
- public static final Protocol POPS = new Protocol(""pops"", ""POPS"",
-- ""Post Office Protocol (Secure)"", 995);
-+ ""Post Office Protocol (Secure)"", 995, true);
-
- /**
- * RIAP (Restlet Internal Access Protocol) is a custom scheme to access
-@@ -120,7 +120,7 @@ public final class Protocol extends Metadata {
- * @see org.restlet.data.LocalReference
- */
- public static final Protocol RIAP = new Protocol(""riap"", ""RIAP"",
-- ""Restlet Internal Access Protocol"", UNKNOWN_PORT);
-+ ""Restlet Internal Access Protocol"", UNKNOWN_PORT, true);
-
- /** SMTP protocol. */
- public static final Protocol SMTP = new Protocol(""smtp"", ""SMTP"",
-@@ -135,15 +135,16 @@ public final class Protocol extends Metadata {
- @Deprecated
- public static final Protocol SMTP_STARTTLS = new Protocol(""smtp"",
- ""SMTP_STARTTLS"",
-- ""Simple Mail Transfer Protocol (starting a TLS encryption)"", 25);
-+ ""Simple Mail Transfer Protocol (starting a TLS encryption)"", 25,
-+ true);
-
- /** SMTPS protocol (via SSL/TLS socket). */
- public static final Protocol SMTPS = new Protocol(""smtps"", ""SMTPS"",
-- ""Simple Mail Transfer Protocol (Secure)"", 465);
-+ ""Simple Mail Transfer Protocol (Secure)"", 465, true);
-
- /** Local Web Archive access protocol. */
- public static final Protocol WAR = new Protocol(""war"", ""WAR"",
-- ""Web Archive Access Protocol"", UNKNOWN_PORT);
-+ ""Web Archive Access Protocol"", UNKNOWN_PORT, true);
-
- /**
- * Creates the protocol associated to a URI scheme name. If an existing
-@@ -195,6 +196,9 @@ public static Protocol valueOf(final String name) {
- return result;
- }
-
-+ /** The confidentiality. */
-+ private volatile boolean confidential;
++ public HashSet CollisionBlockType;
+
- /** The default port if known or -1. */
- private volatile int defaultPort;
-
-@@ -226,9 +230,30 @@ public Protocol(final String schemeName) {
- */
- public Protocol(final String schemeName, final String name,
- final String description, int defaultPort) {
-+ this(schemeName, name, description, defaultPort, false);
++ public boolean SpawnWater;
++ public boolean SpawnLava;
++ public boolean SpawnAboveGround;
++ public boolean SpawnUnderGround;
++
++ public boolean SpawnSunlight;
++ public boolean SpawnDarkness;
++
++ public boolean UnderFill;
++ public boolean RandomRotation;
++ public boolean Dig;
++ public boolean Tree;
++ public boolean Branch;
++ public boolean DiggingBranch;
++ public boolean NeedsFoundation;
++ public int Rarity;
++ public double CollisionPercentage;
++ public int SpawnElevationMin;
++ public int SpawnElevationMax;
++
++ public int GroupFrequencyMin;
++ public int GroupFrequencyMax;
++ public int GroupSeparationMin;
++ public int GroupSeparationMax;
++ public String GroupId;
++
++ public int BranchLimit;
++
++ public BO2(File file, String name)
++ {
++ ReadSettingsFile(file);
++ this.Name = name;
++
++ ReadConfigSettings();
++ CorrectSettings();
+ }
+
-+ /**
-+ * Constructor.
-+ *
-+ * @param schemeName
-+ * The scheme name.
-+ * @param name
-+ * The unique name.
-+ * @param description
-+ * The description.
-+ * @param defaultPort
-+ * The default port.
-+ * @param confidential
-+ * The confidentiality.
-+ */
-+ public Protocol(final String schemeName, final String name,
-+ final String description, int defaultPort,
-+ final boolean confidential) {
- super(name, description);
- this.schemeName = schemeName;
- this.defaultPort = defaultPort;
-+ this.confidential = confidential;
- }
-
- /** {@inheritDoc} */
-@@ -261,4 +286,15 @@ public String getSchemeName() {
- public int hashCode() {
- return (getName() == null) ? 0 : getName().toLowerCase().hashCode();
- }
++ public BO2(Map settings, String name)
++ {
++ SettingsCache = settings;
++ this.Name = name;
+
-+ /**
-+ * Indicates if the protocol guarantees the confidentially of the messages
-+ * exchanged, for example via a SSL-secured connection.
-+ *
-+ * @return True if the protocol is confidential.
-+ */
-+ public boolean isConfidential() {
-+ return this.confidential;
++ ReadConfigSettings();
++ CorrectSettings();
+ }
+
- }
-diff --git a/modules/org.restlet/src/org/restlet/data/Request.java b/modules/org.restlet/src/org/restlet/data/Request.java
-index 9c81cbd5d5..300e05e0ab 100644
---- a/modules/org.restlet/src/org/restlet/data/Request.java
-+++ b/modules/org.restlet/src/org/restlet/data/Request.java
-@@ -109,9 +109,6 @@ public static Request getCurrent() {
- /** The condition data. */
- private volatile Conditions conditions;
-
-- /** Indicates if the call came over a confidential channel. */
-- private volatile boolean confidential;
--
- /** The cookies provided by the client. */
- private volatile Series cookies;
-
-@@ -140,7 +137,6 @@ public static Request getCurrent() {
- * Constructor.
- */
- public Request() {
-- this.confidential = false;
- }
-
- /**
-@@ -387,13 +383,12 @@ public Reference getRootRef() {
- }
-
- /**
-- * Indicates if the call came over a confidential channel such as an
-- * SSL-secured connection.
-- *
-- * @return True if the call came over a confidential channel.
-+ * Implemented based on the {@link Protocol#isConfidential()} method for the
-+ * request's protocol returned by {@link #getProtocol()};
- */
+ @Override
- public boolean isConfidential() {
-- return this.confidential;
-+ return (getProtocol() == null) ? false : getProtocol().isConfidential();
- }
-
- /**
-@@ -444,17 +439,6 @@ public void setConditions(Conditions conditions) {
- this.conditions = conditions;
- }
-
-- /**
-- * Indicates if the call came over a confidential channel such as an
-- * SSL-secured connection.
-- *
-- * @param confidential
-- * True if the call came over a confidential channel.
-- */
-- public void setConfidential(boolean confidential) {
-- this.confidential = confidential;
-- }
--
- /**
- * Sets the cookies provided by the client.
- *
-diff --git a/modules/org.restlet/src/org/restlet/data/Response.java b/modules/org.restlet/src/org/restlet/data/Response.java
-index cd34d0b5a1..b88c96c3ef 100644
---- a/modules/org.restlet/src/org/restlet/data/Response.java
-+++ b/modules/org.restlet/src/org/restlet/data/Response.java
-@@ -307,6 +307,11 @@ public Status getStatus() {
- return this.status;
- }
-
++ public String getName()
++ {
++ return this.Name;
++ }
++
+ @Override
-+ public boolean isConfidential() {
-+ return getRequest().isConfidential();
++ public boolean canSpawnAsTree()
++ {
++ return Tree;
+ }
+
- /**
- * Permanently redirects the client to a target URI. The client is expected
- * to reuse the same method for the new request.
-diff --git a/modules/org.restlet/src/org/restlet/util/WrapperRequest.java b/modules/org.restlet/src/org/restlet/util/WrapperRequest.java
-index 039e608531..a8c52196d0 100644
---- a/modules/org.restlet/src/org/restlet/util/WrapperRequest.java
-+++ b/modules/org.restlet/src/org/restlet/util/WrapperRequest.java
-@@ -315,18 +315,6 @@ public void setChallengeResponse(ChallengeResponse response) {
- getWrappedRequest().setChallengeResponse(response);
- }
-
-- /**
-- * Indicates if the call came over a confidential channel such as an
-- * SSL-secured connection.
-- *
-- * @param confidential
-- * True if the call came over a confidential channel.
-- */
-- @Override
-- public void setConfidential(boolean confidential) {
-- getWrappedRequest().setConfidential(confidential);
-- }
--
- /**
- * Sets the entity from a higher-level object. This object is converted to a
- * representation using the Application's converter service. If you want to
-diff --git a/modules/org.restlet/src/org/restlet/util/WrapperResponse.java b/modules/org.restlet/src/org/restlet/util/WrapperResponse.java
-index f75306c2c1..1fc4fdf01d 100644
---- a/modules/org.restlet/src/org/restlet/util/WrapperResponse.java
-+++ b/modules/org.restlet/src/org/restlet/util/WrapperResponse.java
-@@ -301,6 +301,17 @@ protected Response getWrappedResponse() {
- return this.wrappedResponse;
- }
-
-+ /**
-+ * Indicates if the call came over a confidential channel such as an
-+ * SSL-secured connection.
-+ *
-+ * @return True if the call came over a confidential channel.
-+ */
+ @Override
-+ public boolean isConfidential() {
-+ return getWrappedResponse().isConfidential();
++ public boolean canSpawnAsObject()
++ {
++ return true;
+ }
+
- /**
- * Indicates if a content is available and can be sent. Several conditions
- * must be met: the content must exists and have some available data."
-8ee632caa79b92b1af98684f83b01c3447a119ee,hadoop,YARN-2740. Fix NodeLabelsManager to properly handle- node label modifications when distributed node label configuration enabled.- (Naganarasimha G R via wangda)--(cherry picked from commit db1b674b50ddecf2774f4092d677c412722bdcb1)-,c,https://github.com/apache/hadoop,"diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
-index 20de1edb7efbe..ca9247f13eb2d 100644
---- a/hadoop-yarn-project/CHANGES.txt
-+++ b/hadoop-yarn-project/CHANGES.txt
-@@ -217,6 +217,9 @@ Release 2.8.0 - UNRELEASED
- YARN-3530. ATS throws exception on trying to filter results without otherinfo.
- (zhijie shen via xgong)
-
-+ YARN-2740. Fix NodeLabelsManager to properly handle node label modifications
-+ when distributed node label configuration enabled. (Naganarasimha G R via wangda)
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int y, int z)
++ {
++ if (!ObjectCanSpawn(world, x, y, z))
++ {
++ return false;
++ }
+
- Release 2.7.1 - UNRELEASED
-
- INCOMPATIBLE CHANGES
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
-index c8f9648147fb3..4dd01d24bb8d9 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
-@@ -1779,6 +1779,12 @@ private static void addDeprecatedKeys() {
- public static final String DEFAULT_NODELABEL_CONFIGURATION_TYPE =
- CENTALIZED_NODELABEL_CONFIGURATION_TYPE;
-
-+ @Private
-+ public static boolean isDistributedNodeLabelConfiguration(Configuration conf) {
-+ return DISTRIBUTED_NODELABEL_CONFIGURATION_TYPE.equals(conf.get(
-+ NODELABEL_CONFIGURATION_TYPE, DEFAULT_NODELABEL_CONFIGURATION_TYPE));
-+ }
++ ObjectCoordinate[] data = Data[0];
++ if (RandomRotation)
++ data = Data[random.nextInt(4)];
+
- public YarnConfiguration() {
- super();
- }
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
-index 7493169201ebc..f2ff0f629971c 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
-@@ -97,6 +97,8 @@ public class CommonNodeLabelsManager extends AbstractService {
- protected NodeLabelsStore store;
- private boolean nodeLabelsEnabled = false;
-
-+ private boolean isDistributedNodeLabelConfiguration = false;
++ int faultCounter = 0;
+
- /**
- * A Host can have multiple Nodes
- */
-@@ -213,6 +215,10 @@ protected void serviceInit(Configuration conf) throws Exception {
- nodeLabelsEnabled =
- conf.getBoolean(YarnConfiguration.NODE_LABELS_ENABLED,
- YarnConfiguration.DEFAULT_NODE_LABELS_ENABLED);
++ for (ObjectCoordinate point : data)
++ {
++ if (!world.isLoaded((x + point.x), (y + point.y), (z + point.z)))
++ return false;
+
-+ isDistributedNodeLabelConfiguration =
-+ YarnConfiguration.isDistributedNodeLabelConfiguration(conf);
++ if (!Dig)
++ {
++ if (CollisionBlockType.contains(world.getTypeId((x + point.x), (y + point.y), (z + point.z))))
++ {
++ faultCounter++;
++ if (faultCounter > (data.length * (CollisionPercentage / 100)))
++ {
++ return false;
++ }
++ }
++ }
+
- if (nodeLabelsEnabled) {
- initNodeLabelStore(conf);
- }
-@@ -223,7 +229,7 @@ protected void serviceInit(Configuration conf) throws Exception {
- protected void initNodeLabelStore(Configuration conf) throws Exception {
- this.store = new FileSystemNodeLabelsStore(this);
- this.store.init(conf);
-- this.store.recover();
-+ this.store.recover(isDistributedNodeLabelConfiguration);
- }
-
- // for UT purpose
-@@ -613,7 +619,10 @@ protected void internalUpdateLabelsOnNodes(
- }
- }
-
-- if (null != dispatcher) {
-+ if (null != dispatcher && !isDistributedNodeLabelConfiguration) {
-+ // In case of DistributedNodeLabelConfiguration, no need to save the the
-+ // NodeLabels Mapping to the back-end store, as on RM restart/failover
-+ // NodeLabels are collected from NM through Register/Heartbeat again
- dispatcher.getEventHandler().handle(
- new UpdateNodeToLabelsMappingsEvent(newNMToLabels));
- }
-@@ -799,8 +808,10 @@ public List getClusterNodeLabels() {
- readLock.lock();
- List nodeLabels = new ArrayList<>();
- for (RMNodeLabel label : labelCollections.values()) {
-- nodeLabels.add(NodeLabel.newInstance(label.getLabelName(),
-- label.getIsExclusive()));
-+ if (!label.getLabelName().equals(NO_LABEL)) {
-+ nodeLabels.add(NodeLabel.newInstance(label.getLabelName(),
-+ label.getIsExclusive()));
+ }
- }
- return nodeLabels;
- } finally {
-@@ -824,7 +835,6 @@ public boolean isExclusiveNodeLabel(String nodeLabel) throws IOException {
- readLock.unlock();
- }
- }
--
-
- private void checkAndThrowLabelName(String label) throws IOException {
- if (label == null || label.isEmpty() || label.length() > MAX_LABEL_LENGTH) {
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
-index ea185f2c0a248..f26e2048a02cd 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java
-@@ -154,8 +154,12 @@ public void removeClusterNodeLabels(Collection labels)
- ensureCloseEditlogFile();
- }
-
-+ /* (non-Javadoc)
-+ * @see org.apache.hadoop.yarn.nodelabels.NodeLabelsStore#recover(boolean)
-+ */
- @Override
-- public void recover() throws YarnException, IOException {
-+ public void recover(boolean ignoreNodeToLabelsMappings) throws YarnException,
-+ IOException {
- /*
- * Steps of recover
- * 1) Read from last mirror (from mirror or mirror.old)
-@@ -222,7 +226,15 @@ public void recover() throws YarnException, IOException {
- new ReplaceLabelsOnNodeRequestPBImpl(
- ReplaceLabelsOnNodeRequestProto.parseDelimitedFrom(is))
- .getNodeToLabels();
-- mgr.replaceLabelsOnNode(map);
-+ if (!ignoreNodeToLabelsMappings) {
-+ /*
-+ * In case of Distributed NodeLabels setup,
-+ * ignoreNodeToLabelsMappings will be set to true and recover will
-+ * be invoked. As RM will collect the node labels from NM through
-+ * registration/HB
-+ */
-+ mgr.replaceLabelsOnNode(map);
++
++ for (ObjectCoordinate point : data)
++ {
++
++ if (world.getTypeId(x + point.x, y + point.y, z + point.z) == 0)
++ {
++ world.setBlock((x + point.x), y + point.y, z + point.z, point.BlockId, point.BlockData, true, false, true);
++ } else if (Dig)
++ {
++ world.setBlock((x + point.x), y + point.y, z + point.z, point.BlockId, point.BlockData, true, false, true);
+ }
- break;
- }
- }
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/NodeLabelsStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/NodeLabelsStore.java
-index 47b7370dff843..46b94fd0d5c9a 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/NodeLabelsStore.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/NodeLabelsStore.java
-@@ -56,9 +56,18 @@ public abstract void removeClusterNodeLabels(Collection labels)
- throws IOException;
-
- /**
-- * Recover labels and node to labels mappings from store
-+ * Recover labels and node to labels mappings from store, but if
-+ * ignoreNodeToLabelsMappings is true then node to labels mappings should not
-+ * be recovered. In case of Distributed NodeLabels setup
-+ * ignoreNodeToLabelsMappings will be set to true and recover will be invoked
-+ * as RM will collect the node labels from NM through registration/HB
-+ *
-+ * @param ignoreNodeToLabelsMappings
-+ * @throws IOException
-+ * @throws YarnException
- */
-- public abstract void recover() throws IOException, YarnException;
-+ public abstract void recover(boolean ignoreNodeToLabelsMappings)
-+ throws IOException, YarnException;
-
- public void init(Configuration conf) throws Exception {}
-
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/DummyCommonNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/DummyCommonNodeLabelsManager.java
-index 48d6dc877154b..fce663a1c952c 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/DummyCommonNodeLabelsManager.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/DummyCommonNodeLabelsManager.java
-@@ -39,7 +39,8 @@ public void initNodeLabelStore(Configuration conf) {
- this.store = new NodeLabelsStore(this) {
-
- @Override
-- public void recover() throws IOException {
-+ public void recover(boolean ignoreNodeToLabelsMappings)
-+ throws IOException {
- }
-
- @Override
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
-index beb2cf8585851..09838b43ada1d 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
-@@ -554,4 +554,29 @@ private void verifyNodeLabelAdded(Set expectedAddedLabelNames,
- Assert.assertTrue(expectedAddedLabelNames.contains(label.getName()));
- }
- }
+
-+ @Test(timeout = 5000)
-+ public void testReplaceLabelsOnNodeInDistributedMode() throws Exception {
-+ //create new DummyCommonNodeLabelsManager than the one got from @before
-+ mgr.stop();
-+ mgr = new DummyCommonNodeLabelsManager();
-+ Configuration conf = new YarnConfiguration();
-+ conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);
-+ conf.set(YarnConfiguration.NODELABEL_CONFIGURATION_TYPE,
-+ YarnConfiguration.DISTRIBUTED_NODELABEL_CONFIGURATION_TYPE);
++ }
++ return true;
++ }
+
-+ mgr.init(conf);
-+ mgr.start();
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int y, int z)
++ {
++ if (!Tree)
++ {
++ // Can only spawn as a tree if this is a tree.
++ return false;
++ }
++ return spawn(world, random, x, y, z);
++ }
+
-+ mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(""p1"", ""p2"", ""p3""));
-+ mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId(""n1""), toSet(""p1"")));
-+ Set labelsByNode = mgr.getLabelsByNode(toNodeId(""n1""));
++ @Override
++ public boolean spawn(LocalWorld world, Random random, int x, int z)
++ {
++ int y;
++ if (SpawnAboveGround)
++ y = world.getSolidHeight(x, z);
++ else if (SpawnUnderGround)
++ {
++ int solidHeight = world.getSolidHeight(x, z);
++ if (solidHeight < 1 || solidHeight <= SpawnElevationMin)
++ return false;
++ if (solidHeight > SpawnElevationMax)
++ solidHeight = SpawnElevationMax;
++ y = random.nextInt(solidHeight - SpawnElevationMin) + SpawnElevationMin;
++ } else
++ y = world.getHighestBlockYAt(x, z);
+
-+ Assert.assertNull(
-+ ""Labels are not expected to be written to the NodeLabelStore"",
-+ mgr.lastNodeToLabels);
-+ Assert.assertNotNull(""Updated labels should be available from the Mgr"",
-+ labelsByNode);
-+ Assert.assertTrue(labelsByNode.contains(""p1""));
-+ }
- }
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
-index f070c205f5a1c..fb60cd6a6427c 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
-@@ -144,6 +144,40 @@ public void testRecoverWithMirror() throws Exception {
- mgr.stop();
- }
-
-+ @SuppressWarnings({ ""unchecked"", ""rawtypes"" })
-+ @Test(timeout = 10000)
-+ public void testRecoverWithDistributedNodeLabels() throws Exception {
-+ mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(""p1"", ""p2"", ""p3""));
-+ mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(""p4""));
-+ mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(""p5"", ""p6""));
-+ mgr.replaceLabelsOnNode((Map) ImmutableMap.of(toNodeId(""n1""), toSet(""p1""),
-+ toNodeId(""n2""), toSet(""p2"")));
-+ mgr.replaceLabelsOnNode((Map) ImmutableMap.of(toNodeId(""n3""), toSet(""p3""),
-+ toNodeId(""n4""), toSet(""p4""), toNodeId(""n5""), toSet(""p5""),
-+ toNodeId(""n6""), toSet(""p6""), toNodeId(""n7""), toSet(""p6"")));
++ if (y < 0)
++ return false;
+
-+ mgr.removeFromClusterNodeLabels(toSet(""p1""));
-+ mgr.removeFromClusterNodeLabels(Arrays.asList(""p3"", ""p5""));
-+ mgr.stop();
++ if (!ObjectCanSpawn(world, x, y, z))
++ return false;
+
-+ mgr = new MockNodeLabelManager();
-+ Configuration cf = new Configuration(conf);
-+ cf.set(YarnConfiguration.NODELABEL_CONFIGURATION_TYPE,
-+ YarnConfiguration.DISTRIBUTED_NODELABEL_CONFIGURATION_TYPE);
-+ mgr.init(cf);
++ boolean objectSpawned = this.spawn(world, random, x, y, z);
+
-+ // check variables
-+ Assert.assertEquals(3, mgr.getClusterNodeLabels().size());
-+ Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
-+ Arrays.asList(""p2"", ""p4"", ""p6"")));
++ if (objectSpawned)
++ GenerateCustomObjectFromGroup(world, random, x, y, z);
+
-+ Assert.assertTrue(""During recovery in distributed node-labels setup, ""
-+ + ""node to labels mapping should not be recovered "", mgr
-+ .getNodeLabels().size() == 0);
++ return objectSpawned;
++ }
+
-+ mgr.stop();
-+ }
++ @Override
++ public boolean spawnAsTree(LocalWorld world, Random random, int x, int z)
++ {
++ return spawn(world, random, x, z);
++ }
+
- @SuppressWarnings({ ""unchecked"", ""rawtypes"" })
- @Test(timeout = 10000)
- public void testEditlogRecover() throws Exception {
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java
-index c921326fbdce3..0ad90c0ed4c6b 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java
-@@ -112,6 +112,9 @@ public class AdminService extends CompositeService implements
- private final RecordFactory recordFactory =
- RecordFactoryProvider.getRecordFactory(null);
-
-+ @VisibleForTesting
-+ boolean isDistributedNodeLabelConfiguration = false;
++ @Override
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ int randomRoll = random.nextInt(100);
++ int ObjectRarity = Rarity;
+
- public AdminService(ResourceManager rm, RMContext rmContext) {
- super(AdminService.class.getName());
- this.rm = rm;
-@@ -141,6 +144,10 @@ public void serviceInit(Configuration conf) throws Exception {
- YarnConfiguration.DEFAULT_YARN_ADMIN_ACL)), UserGroupInformation
- .getCurrentUser());
- rmId = conf.get(YarnConfiguration.RM_HA_ID);
++ while (randomRoll < ObjectRarity)
++ {
++ ObjectRarity -= 100;
+
-+ isDistributedNodeLabelConfiguration =
-+ YarnConfiguration.isDistributedNodeLabelConfiguration(conf);
++ int x = chunkX * 16 + random.nextInt(16);
++ int z = chunkZ * 16 + random.nextInt(16);
+
- super.serviceInit(conf);
- }
-
-@@ -637,32 +644,35 @@ public AddToClusterNodeLabelsResponse addToClusterNodeLabels(AddToClusterNodeLab
- @Override
- public RemoveFromClusterNodeLabelsResponse removeFromClusterNodeLabels(
- RemoveFromClusterNodeLabelsRequest request) throws YarnException, IOException {
-- String argName = ""removeFromClusterNodeLabels"";
-+ String operation = ""removeFromClusterNodeLabels"";
- final String msg = ""remove labels."";
-- UserGroupInformation user = checkAcls(argName);
-
-- checkRMStatus(user.getShortUserName(), argName, msg);
-+ UserGroupInformation user = checkAcls(operation);
++ spawn(world, random, x, z);
++ }
++ }
+
-+ checkRMStatus(user.getShortUserName(), operation, msg);
-
- RemoveFromClusterNodeLabelsResponse response =
- recordFactory.newRecordInstance(RemoveFromClusterNodeLabelsResponse.class);
- try {
- rmContext.getNodeLabelManager().removeFromClusterNodeLabels(request.getNodeLabels());
- RMAuditLogger
-- .logSuccess(user.getShortUserName(), argName, ""AdminService"");
-+ .logSuccess(user.getShortUserName(), operation, ""AdminService"");
- return response;
- } catch (IOException ioe) {
-- throw logAndWrapException(ioe, user.getShortUserName(), argName, msg);
-+ throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
- }
- }
-
- @Override
- public ReplaceLabelsOnNodeResponse replaceLabelsOnNode(
- ReplaceLabelsOnNodeRequest request) throws YarnException, IOException {
-- String argName = ""replaceLabelsOnNode"";
-+ String operation = ""replaceLabelsOnNode"";
- final String msg = ""set node to labels."";
-- UserGroupInformation user = checkAcls(argName);
++ @Override
++ public void processAsTree(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ if (!Tree)
++ {
++ return;
++ }
++
++ process(world, random, chunkX, chunkZ);
++ }
++
++ @Override
++ public CustomObject applySettings(Map extraSettings)
++ {
++ Map newSettings = new HashMap();
++ newSettings.putAll(SettingsCache);
++ newSettings.putAll(extraSettings);
++ return new BO2(newSettings, getName());
++ }
++
++ @Override
++ protected void WriteConfigSettings() throws IOException
++ {
++ // It doesn't write.
++ }
++
++ @Override
++ protected void ReadConfigSettings()
++ {
++ this.Version = ReadModSettings(BODefaultValues.version.name(), BODefaultValues.version.stringValue());
++
++ this.SpawnOnBlockType = this.ReadBlockList(ReadModSettings(BODefaultValues.spawnOnBlockType.name(), BODefaultValues.spawnOnBlockType.StringArrayListValue()), BODefaultValues.spawnOnBlockType.name());
++ this.CollisionBlockType = this.ReadBlockList(ReadModSettings(BODefaultValues.collisionBlockType.name(), BODefaultValues.collisionBlockType.StringArrayListValue()), BODefaultValues.collisionBlockType.name());
++
++ this.SpawnInBiome = new HashSet(ReadModSettings(BODefaultValues.spawnInBiome.name(), BODefaultValues.spawnInBiome.StringArrayListValue()));
++
++ this.SpawnSunlight = ReadModSettings(BODefaultValues.spawnSunlight.name(), BODefaultValues.spawnSunlight.booleanValue());
++ this.SpawnDarkness = ReadModSettings(BODefaultValues.spawnDarkness.name(), BODefaultValues.spawnDarkness.booleanValue());
++ this.SpawnWater = ReadModSettings(BODefaultValues.spawnWater.name(), BODefaultValues.spawnWater.booleanValue());
++ this.SpawnLava = ReadModSettings(BODefaultValues.spawnLava.name(), BODefaultValues.spawnLava.booleanValue());
++ this.SpawnAboveGround = ReadModSettings(BODefaultValues.spawnAboveGround.name(), BODefaultValues.spawnAboveGround.booleanValue());
++ this.SpawnUnderGround = ReadModSettings(BODefaultValues.spawnUnderGround.name(), BODefaultValues.spawnUnderGround.booleanValue());
++
++ this.UnderFill = ReadModSettings(BODefaultValues.underFill.name(), BODefaultValues.underFill.booleanValue());
++
++ this.RandomRotation = ReadModSettings(BODefaultValues.randomRotation.name(), BODefaultValues.randomRotation.booleanValue());
++ this.Dig = ReadModSettings(BODefaultValues.dig.name(), BODefaultValues.dig.booleanValue());
++ this.Tree = ReadModSettings(BODefaultValues.tree.name(), BODefaultValues.tree.booleanValue());
++ this.Branch = ReadModSettings(BODefaultValues.branch.name(), BODefaultValues.branch.booleanValue());
++ this.DiggingBranch = ReadModSettings(BODefaultValues.diggingBranch.name(), BODefaultValues.diggingBranch.booleanValue());
++ this.NeedsFoundation = ReadModSettings(BODefaultValues.needsFoundation.name(), BODefaultValues.needsFoundation.booleanValue());
++ this.Rarity = ReadModSettings(BODefaultValues.rarity.name(), BODefaultValues.rarity.intValue());
++ this.CollisionPercentage = ReadModSettings(BODefaultValues.collisionPercentage.name(), BODefaultValues.collisionPercentage.intValue());
++ this.SpawnElevationMin = ReadModSettings(BODefaultValues.spawnElevationMin.name(), BODefaultValues.spawnElevationMin.intValue());
++ this.SpawnElevationMax = ReadModSettings(BODefaultValues.spawnElevationMax.name(), BODefaultValues.spawnElevationMax.intValue());
++
++ this.GroupFrequencyMin = ReadModSettings(BODefaultValues.groupFrequencyMin.name(), BODefaultValues.groupFrequencyMin.intValue());
++ this.GroupFrequencyMax = ReadModSettings(BODefaultValues.groupFrequencyMax.name(), BODefaultValues.groupFrequencyMax.intValue());
++ this.GroupSeparationMin = ReadModSettings(BODefaultValues.groupSeperationMin.name(), BODefaultValues.groupSeperationMin.intValue());
++ this.GroupSeparationMax = ReadModSettings(BODefaultValues.groupSeperationMax.name(), BODefaultValues.groupSeperationMax.intValue());
++ this.GroupId = ReadModSettings(BODefaultValues.groupId.name(), BODefaultValues.groupId.stringValue());
++
++ this.BranchLimit = ReadModSettings(BODefaultValues.branchLimit.name(), BODefaultValues.branchLimit.intValue());
++
++ this.ReadCoordinates();
++ }
++
++ @Override
++ protected void CorrectSettings()
++ {
++ // Stub method
++ }
++
++ @Override
++ protected void RenameOldSettings()
++ {
++ // Stub method
++ }
++
++ private void ReadCoordinates()
++ {
++ ArrayList coordinates = new ArrayList();
++
++ for (String key : SettingsCache.keySet())
++ {
++ ObjectCoordinate buffer = ObjectCoordinate.getCoordinateFromString(key, SettingsCache.get(key));
++ if (buffer != null)
++ coordinates.add(buffer);
++ }
++
++ Data[0] = new ObjectCoordinate[coordinates.size()];
++ Data[1] = new ObjectCoordinate[coordinates.size()];
++ Data[2] = new ObjectCoordinate[coordinates.size()];
++ Data[3] = new ObjectCoordinate[coordinates.size()];
++
++ for (int i = 0; i < coordinates.size(); i++)
++ {
++ ObjectCoordinate coordinate = coordinates.get(i);
++
++ Data[0][i] = coordinate;
++ coordinate = coordinate.Rotate();
++ Data[1][i] = coordinate;
++ coordinate = coordinate.Rotate();
++ Data[2][i] = coordinate;
++ coordinate = coordinate.Rotate();
++ Data[3][i] = coordinate;
++ }
++
++ }
++
++ private HashSet ReadBlockList(ArrayList blocks, String settingName)
++ {
++ HashSet output = new HashSet();
++
++ boolean nonIntegerValues = false;
++ boolean all = false;
++ boolean solid = false;
++
++ for (String block : blocks)
++ {
++
++ if (block.equals(BODefaultValues.BO_ALL_KEY.stringValue()))
++ {
++ all = true;
++ continue;
++ }
++ if (block.equals(BODefaultValues.BO_SolidKey.stringValue()))
++ {
++ solid = true;
++ continue;
++ }
++ try
++ {
++ int blockID = Integer.decode(block);
++ if (blockID != 0)
++ output.add(blockID);
++ } catch (NumberFormatException e)
++ {
++ nonIntegerValues = true;
++ }
++ }
++
++ if (all || solid)
++ for (DefaultMaterial material : DefaultMaterial.values())
++ {
++ if (material.id == 0)
++ continue;
++ if (solid && !material.isSolid())
++ continue;
++ output.add(material.id);
++
++ }
++ if (nonIntegerValues)
++ System.out.println(""TerrainControl: Custom object "" + this.Name + "" have wrong value "" + settingName);
++
++ return output;
++
++ }
++
++ public boolean ObjectCanSpawn(LocalWorld world, int x, int y, int z)
++ {
++ if ((world.getTypeId(x, y - 5, z) == 0) && (NeedsFoundation))
++ return false;
++
++ boolean output = true;
++ int checkBlock = world.getTypeId(x, y + 2, z);
++ if (!SpawnWater)
++ output = !((checkBlock == DefaultMaterial.WATER.id) || (checkBlock == DefaultMaterial.STATIONARY_WATER.id));
++ if (!SpawnLava)
++ output = !((checkBlock == DefaultMaterial.LAVA.id) || (checkBlock == DefaultMaterial.STATIONARY_LAVA.id));
++
++ checkBlock = world.getLightLevel(x, y + 2, z);
++ if (!SpawnSunlight)
++ output = !(checkBlock > 8);
++ if (!SpawnDarkness)
++ output = !(checkBlock < 9);
++
++ if ((y < SpawnElevationMin) || (y > SpawnElevationMax))
++ output = false;
++
++ if (!SpawnOnBlockType.contains(world.getTypeId(x, y - 1, z)))
++ output = false;
++
++ return output;
++ }
++
++ public void GenerateCustomObjectFromGroup(LocalWorld world, Random random, int x, int y, int z)
++ {
++ if (GroupObjects == null)
++ return;
++
++ int attempts = 3;
++ if ((GroupFrequencyMax - GroupFrequencyMin) > 0)
++ attempts = GroupFrequencyMin + random.nextInt(GroupFrequencyMax - GroupFrequencyMin);
++
++ while (attempts > 0)
++ {
++ attempts--;
++
++ int objIndex = random.nextInt(GroupObjects.length);
++ BO2 ObjectFromGroup = GroupObjects[objIndex];
++
++ if (Branch)
++ continue;
++
++ x = x + random.nextInt(GroupSeparationMax - GroupSeparationMin) + GroupSeparationMin;
++ z = z + random.nextInt(GroupSeparationMax - GroupSeparationMin) + GroupSeparationMin;
++ int _y;
++
++ if (SpawnAboveGround)
++ _y = world.getSolidHeight(x, z);
++ else if (SpawnUnderGround)
++ {
++ int solidHeight = world.getSolidHeight(x, z);
++ if (solidHeight < 1 || solidHeight <= SpawnElevationMin)
++ continue;
++ if (solidHeight > SpawnElevationMax)
++ solidHeight = SpawnElevationMax;
++ _y = random.nextInt(solidHeight - SpawnElevationMin) + SpawnElevationMin;
++ } else
++ _y = world.getHighestBlockYAt(x, z);
++
++ if (y < 0)
++ continue;
++
++ if ((y - _y) > 10 || (_y - y) > 10)
++ continue;
++
++ ObjectFromGroup.spawn(world, random, x, _y, z);
++ }
++
++ }
++
++ @Override
++ public boolean hasPreferenceToSpawnIn(LocalBiome biome)
++ {
++ return SpawnInBiome.contains(biome.getName()) || SpawnInBiome.contains(""All"");
++ }
++
++}
+diff --git a/common/src/com/khorn/terraincontrol/customobjects/bo2/BO2Loader.java b/common/src/com/khorn/terraincontrol/customobjects/bo2/BO2Loader.java
+new file mode 100644
+index 000000000..e7ee8bb76
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/customobjects/bo2/BO2Loader.java
+@@ -0,0 +1,14 @@
++package com.khorn.terraincontrol.customobjects.bo2;
++
++import java.io.File;
++
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import com.khorn.terraincontrol.customobjects.CustomObjectLoader;
++
++public class BO2Loader implements CustomObjectLoader
++{
++ public CustomObject loadFromFile(String objectName, File file)
++ {
++ return new BO2(file, objectName);
++ }
++}
+diff --git a/common/src/com/khorn/terraincontrol/exception/InvalidResourceException.java b/common/src/com/khorn/terraincontrol/exception/InvalidResourceException.java
+new file mode 100644
+index 000000000..f53a907ae
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/exception/InvalidResourceException.java
+@@ -0,0 +1,11 @@
++package com.khorn.terraincontrol.exception;
++
++public class InvalidResourceException extends Exception
++{
++
++ public InvalidResourceException(String string)
++ {
++ super(string);
++ }
++
++}
+diff --git a/common/src/com/khorn/terraincontrol/generator/ObjectSpawner.java b/common/src/com/khorn/terraincontrol/generator/ObjectSpawner.java
+index a0f81f51b..d0dde206a 100644
+--- a/common/src/com/khorn/terraincontrol/generator/ObjectSpawner.java
++++ b/common/src/com/khorn/terraincontrol/generator/ObjectSpawner.java
+@@ -1,14 +1,14 @@
+ package com.khorn.terraincontrol.generator;
-- checkRMStatus(user.getShortUserName(), argName, msg);
-+ checkAndThrowIfDistributedNodeLabelConfEnabled(operation);
-+ UserGroupInformation user = checkAcls(operation);
++import java.util.Random;
+
-+ checkRMStatus(user.getShortUserName(), operation, msg);
+ import com.khorn.terraincontrol.DefaultMaterial;
+ import com.khorn.terraincontrol.LocalWorld;
+ import com.khorn.terraincontrol.configuration.BiomeConfig;
+ import com.khorn.terraincontrol.configuration.Resource;
+ import com.khorn.terraincontrol.configuration.TCDefaultValues;
+ import com.khorn.terraincontrol.configuration.WorldConfig;
+-import com.khorn.terraincontrol.generator.resourcegens.ResourceType;
+-
+-import java.util.Random;
++import com.khorn.terraincontrol.generator.resourcegens.SmallLakeGen;
- ReplaceLabelsOnNodeResponse response =
- recordFactory.newRecordInstance(ReplaceLabelsOnNodeResponse.class);
-@@ -670,30 +680,41 @@ public ReplaceLabelsOnNodeResponse replaceLabelsOnNode(
- rmContext.getNodeLabelManager().replaceLabelsOnNode(
- request.getNodeToLabels());
- RMAuditLogger
-- .logSuccess(user.getShortUserName(), argName, ""AdminService"");
-+ .logSuccess(user.getShortUserName(), operation, ""AdminService"");
- return response;
- } catch (IOException ioe) {
-- throw logAndWrapException(ioe, user.getShortUserName(), argName, msg);
-+ throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
- }
- }
+ public class ObjectSpawner
+ {
+@@ -42,10 +42,10 @@ public void populate(int chunkX, int chunkZ)
+ for (int i = 0; i < localBiomeConfig.ResourceCount; i++)
+ {
+ Resource res = localBiomeConfig.ResourceSequence[i];
+- if (res.Type == ResourceType.SmallLake && Village)
++ if (res instanceof SmallLakeGen && Village)
+ continue;
+- world.setChunksCreations(res.Type.CreateNewChunks);
+- res.Type.Generator.Process(world, rand, res, x, z);
++ world.setChunksCreations(false);
++ res.process(world, rand, chunkX, chunkZ);
+ }
-- private void checkRMStatus(String user, String argName, String msg)
-+ private void checkRMStatus(String user, String operation, String msg)
- throws StandbyException {
- if (!isRMActive()) {
-- RMAuditLogger.logFailure(user, argName, """",
-+ RMAuditLogger.logFailure(user, operation, """",
- ""AdminService"", ""ResourceManager is not active. Can not "" + msg);
- throwStandbyException();
- }
- }
+ // Snow and ice
+@@ -67,10 +67,11 @@ public void populate(int chunkX, int chunkZ)
+ world.setBlock(blockToFreezeX, blockToFreezeY - 1, blockToFreezeZ, biomeConfig.iceBlock, 0);
+ } else
+ {
+- // Snow has to be placed on an empty space on a solid block in the world
++ // Snow has to be placed on an empty space on a
++ // solid block in the world
+ if (world.getMaterial(blockToFreezeX, blockToFreezeY, blockToFreezeZ) == DefaultMaterial.AIR)
+ {
+- if (world.getMaterial(blockToFreezeX, blockToFreezeY - 1, blockToFreezeZ).isSolid())
++ if (world.getMaterial(blockToFreezeX, blockToFreezeY - 1, blockToFreezeZ).isSolid())
+ {
+ world.setBlock(blockToFreezeX, blockToFreezeY, blockToFreezeZ, DefaultMaterial.SNOW.id, 0);
+ }
+diff --git a/common/src/com/khorn/terraincontrol/generator/resourcegens/AboveWaterGen.java b/common/src/com/khorn/terraincontrol/generator/resourcegens/AboveWaterGen.java
+index 63f205514..b4060afca 100644
+--- a/common/src/com/khorn/terraincontrol/generator/resourcegens/AboveWaterGen.java
++++ b/common/src/com/khorn/terraincontrol/generator/resourcegens/AboveWaterGen.java
+@@ -1,15 +1,33 @@
+ package com.khorn.terraincontrol.generator.resourcegens;
+
+ import com.khorn.terraincontrol.LocalWorld;
+-import com.khorn.terraincontrol.configuration.BiomeConfig;
+ import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
- private YarnException logAndWrapException(Exception exception, String user,
-- String argName, String msg) throws YarnException {
-+ String operation, String msg) throws YarnException {
- LOG.warn(""Exception "" + msg, exception);
-- RMAuditLogger.logFailure(user, argName, """",
-+ RMAuditLogger.logFailure(user, operation, """",
- ""AdminService"", ""Exception "" + msg);
- return RPCUtil.getRemoteException(exception);
- }
++import java.util.List;
+ import java.util.Random;
-+ private void checkAndThrowIfDistributedNodeLabelConfEnabled(String operation)
-+ throws YarnException {
-+ if (isDistributedNodeLabelConfiguration) {
-+ String msg =
-+ String.format(""Error when invoke method=%s because of ""
-+ + ""distributed node label configuration enabled."", operation);
-+ LOG.error(msg);
-+ throw RPCUtil.getRemoteException(new IOException(msg));
+-public class AboveWaterGen extends ResourceGenBase
++public class AboveWaterGen extends Resource
+ {
++ private int blockId;
++ private int blockData;
++
+ @Override
+- protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x, int z)
++ public void load(List args) throws InvalidResourceException
++ {
++ if (args.size() < 3)
++ {
++ throw new InvalidResourceException(""Too few arguments supplied"");
++ }
++
++ blockId = getBlockId(args.get(0));
++ blockData = getBlockData(args.get(0));
++ frequency = getInt(args.get(1), 1, 100);
++ rarity = getInt(args.get(2), 1, 100);
+ }
-+ }
+
- @Override
- public CheckForDecommissioningNodesResponse checkForDecommissioningNodes(
- CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest)
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
-index 5e2dc7e4f2543..16b6a890ac923 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
-@@ -104,7 +104,7 @@ public class ResourceTrackerService extends AbstractService implements
- private int minAllocMb;
- private int minAllocVcores;
++ @Override
++ public void spawn(LocalWorld world, Random rand, int x, int z)
+ {
+ int y = world.getLiquidHeight(x, z);
+ if (y == -1)
+@@ -19,26 +37,23 @@ protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x,
+ for (int i = 0; i < 10; i++)
+ {
+ int j = x + rand.nextInt(8) - rand.nextInt(8);
+- //int k = y + rand.nextInt(4) - rand.nextInt(4);
+ int m = z + rand.nextInt(8) - rand.nextInt(8);
+ if (!world.isEmpty(j, y, m) || !world.getMaterial(j, y - 1, m).isLiquid())
+ continue;
+- world.setBlock(j, y, m, res.BlockId, 0, false, false, false);
++ world.setBlock(j, y, m, blockId, blockData, false, false, false);
+ }
+ }
-- private boolean isDistributesNodeLabelsConf;
-+ private boolean isDistributedNodeLabelsConf;
+ @Override
+- protected boolean ReadString(Resource res, String[] Props, BiomeConfig biomeConfig) throws NumberFormatException
++ public ResourceType getType()
+ {
+- res.BlockId = CheckBlock(Props[0]);
+- res.Frequency = CheckValue(Props[1], 1, 100);
+- res.Rarity = CheckValue(Props[2], 0, 100);
+- return true;
++ return ResourceType.biomeConfigResource;
+ }
- static {
- resync.setNodeAction(NodeAction.RESYNC);
-@@ -155,13 +155,8 @@ protected void serviceInit(Configuration conf) throws Exception {
- YarnConfiguration.RM_NODEMANAGER_MINIMUM_VERSION,
- YarnConfiguration.DEFAULT_RM_NODEMANAGER_MINIMUM_VERSION);
+ @Override
+- protected String WriteString(Resource res, String blockSources)
++ public String makeString()
+ {
+- return res.BlockIdToName(res.BlockId) + "","" + res.Frequency + "","" + res.Rarity;
++ return ""AboveWaterGen("" + makeMaterial(blockId) + "","" + frequency + "","" + rarity + "")"";
+ }
++
+ }
+diff --git a/common/src/com/khorn/terraincontrol/generator/resourcegens/CactusGen.java b/common/src/com/khorn/terraincontrol/generator/resourcegens/CactusGen.java
+index 9e530c630..f0f1f2cfa 100644
+--- a/common/src/com/khorn/terraincontrol/generator/resourcegens/CactusGen.java
++++ b/common/src/com/khorn/terraincontrol/generator/resourcegens/CactusGen.java
+@@ -1,17 +1,26 @@
+ package com.khorn.terraincontrol.generator.resourcegens;
-- String nodeLabelConfigurationType =
-- conf.get(YarnConfiguration.NODELABEL_CONFIGURATION_TYPE,
-- YarnConfiguration.DEFAULT_NODELABEL_CONFIGURATION_TYPE);
+-import com.khorn.terraincontrol.configuration.BiomeConfig;
+-import com.khorn.terraincontrol.configuration.Resource;
+-import com.khorn.terraincontrol.LocalWorld;
-
-- isDistributesNodeLabelsConf =
-- YarnConfiguration.DISTRIBUTED_NODELABEL_CONFIGURATION_TYPE
-- .equals(nodeLabelConfigurationType);
-+ isDistributedNodeLabelsConf =
-+ YarnConfiguration.isDistributedNodeLabelConfiguration(conf);
-
- super.serviceInit(conf);
- }
-@@ -352,7 +347,7 @@ public RegisterNodeManagerResponse registerNodeManager(
++import java.util.ArrayList;
++import java.util.List;
+ import java.util.Random;
- // Update node's labels to RM's NodeLabelManager.
- Set nodeLabels = request.getNodeLabels();
-- if (isDistributesNodeLabelsConf && nodeLabels != null) {
-+ if (isDistributedNodeLabelsConf && nodeLabels != null) {
- try {
- updateNodeLabelsFromNMReport(nodeLabels, nodeId);
- response.setAreNodeLabelsAcceptedByRM(true);
-@@ -470,7 +465,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request)
- this.rmContext.getDispatcher().getEventHandler().handle(nodeStatusEvent);
+-public class CactusGen extends ResourceGenBase
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
++
++public class CactusGen extends Resource
+ {
++ private int blockId;
++ private int blockData;
++ private int minAltitude;
++ private int maxAltitude;
++ private List sourceBlocks;
++
+ @Override
+- protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x, int z)
++ public void spawn(LocalWorld world, Random rand, int x, int z)
+ {
+- int y = rand.nextInt(res.MaxAltitude - res.MinAltitude) + res.MinAltitude;
++ int y = rand.nextInt(maxAltitude - minAltitude) + minAltitude;
- // 5. Update node's labels to RM's NodeLabelManager.
-- if (isDistributesNodeLabelsConf && request.getNodeLabels() != null) {
-+ if (isDistributedNodeLabelsConf && request.getNodeLabels() != null) {
- try {
- updateNodeLabelsFromNMReport(request.getNodeLabels(), nodeId);
- nodeHeartBeatResponse.setAreNodeLabelsAcceptedByRM(true);
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
-index 6cd6d56281f66..9aea62d1c8408 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
-@@ -149,6 +149,7 @@
- import org.apache.hadoop.yarn.webapp.NotFoundException;
- import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
+ for (int i = 0; i < 10; i++)
+ {
+@@ -24,9 +33,9 @@ protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x,
+ for (int i1 = 0; i1 < n; i1++)
+ {
+ int id = world.getTypeId(j, k + i1 - 1, m);
+- if (res.CheckSourceId(id) || id == res.BlockId)
++ if (sourceBlocks.contains(id))
+ {
+- world.setBlock(j, k + i1, m, res.BlockId, 0, false, false, false);
++ world.setBlock(j, k + i1, m, blockId, blockData, false, false, false);
+ }
+ }
+ }
+@@ -34,39 +43,35 @@ protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x,
+ }
-+import com.google.common.annotations.VisibleForTesting;
- import com.google.inject.Inject;
- import com.google.inject.Singleton;
+ @Override
+- protected boolean ReadString(Resource res, String[] Props, BiomeConfig biomeConfig) throws NumberFormatException
++ public ResourceType getType()
+ {
++ return ResourceType.biomeConfigResource;
++ }
-@@ -165,6 +166,9 @@ public class RMWebServices {
- private final Configuration conf;
- private @Context HttpServletResponse response;
+- if (Props[0].contains("".""))
+- {
+- String[] block = Props[0].split(""\\."");
+- res.BlockId = CheckBlock(block[0]);
+- res.BlockData = CheckValue(block[1], 0, 16);
+- } else
+- {
+- res.BlockId = CheckBlock(Props[0]);
+- }
+-
+- res.Frequency = CheckValue(Props[1], 1, 100);
+- res.Rarity = CheckValue(Props[2], 0, 100);
+- res.MinAltitude = CheckValue(Props[3], 0, biomeConfig.worldConfig.WorldHeight);
+- res.MaxAltitude = CheckValue(Props[4], 0, biomeConfig.worldConfig.WorldHeight, res.MinAltitude);
+-
+- res.SourceBlockId = new int[Props.length - 5];
+- for (int i = 5; i < Props.length; i++)
+- res.SourceBlockId[i - 5] = CheckBlock(Props[i]);
+-
+- return true;
++ @Override
++ public String makeString()
++ {
++ return ""Cactus("" + makeMaterial(blockId, blockData) + "","" + frequency + "","" + rarity + "","" + minAltitude + "","" + maxAltitude + makeMaterial(sourceBlocks);
+ }
-+ @VisibleForTesting
-+ boolean isDistributedNodeLabelConfiguration = false;
+ @Override
+- protected String WriteString(Resource res, String blockSources)
++ public void load(List args) throws InvalidResourceException
+ {
+- String blockId = res.BlockIdToName(res.BlockId);
+- if (res.BlockData > 0)
++ if (args.size() < 6)
++ {
++ throw new InvalidResourceException(""Too few arguments supplied"");
++ }
+
- public final static String DELEGATION_TOKEN_HEADER =
- ""Hadoop-YARN-RM-Delegation-Token"";
-
-@@ -172,6 +176,19 @@ public class RMWebServices {
- public RMWebServices(final ResourceManager rm, Configuration conf) {
- this.rm = rm;
- this.conf = conf;
-+ isDistributedNodeLabelConfiguration =
-+ YarnConfiguration.isDistributedNodeLabelConfiguration(conf);
-+ }
++ blockId = getBlockId(args.get(0));
++ blockData = getBlockData(args.get(0));
++ frequency = getInt(args.get(1), 1, 100);
++ rarity = getInt(args.get(2), 1, 100);
++ minAltitude = getInt(args.get(3), TerrainControl.worldDepth, TerrainControl.worldHeight);
++ maxAltitude = getInt(args.get(4), minAltitude + 1, TerrainControl.worldHeight);
++ sourceBlocks = new ArrayList();
++ for (int i = 5; i < args.size(); i++)
+ {
+- blockId += ""."" + res.BlockData;
++ sourceBlocks.add(getBlockId(args.get(i)));
+ }
+- return blockId + "","" + res.Frequency + "","" + res.Rarity + "","" + res.MinAltitude + "","" + res.MaxAltitude + blockSources;
+ }
+ }
+\ No newline at end of file
+diff --git a/common/src/com/khorn/terraincontrol/generator/resourcegens/CustomObjectGen.java b/common/src/com/khorn/terraincontrol/generator/resourcegens/CustomObjectGen.java
+new file mode 100644
+index 000000000..a4a943e57
+--- /dev/null
++++ b/common/src/com/khorn/terraincontrol/generator/resourcegens/CustomObjectGen.java
+@@ -0,0 +1,67 @@
++package com.khorn.terraincontrol.generator.resourcegens;
+
-+ private void checkAndThrowIfDistributedNodeLabelConfEnabled(String operation)
-+ throws IOException {
-+ if (isDistributedNodeLabelConfiguration) {
-+ String msg =
-+ String.format(""Error when invoke method=%s because of ""
-+ + ""distributed node label configuration enabled."", operation);
-+ LOG.error(msg);
-+ throw new IOException(msg);
-+ }
- }
-
- RMWebServices(ResourceManager rm, Configuration conf,
-@@ -816,38 +833,64 @@ public LabelsToNodesInfo getLabelsToNodes(
- @POST
- @Path(""/replace-node-to-labels"")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-- public Response replaceLabelsOnNodes(
-- final NodeToLabelsInfo newNodeToLabels,
-- @Context HttpServletRequest hsr)
-- throws IOException {
-+ public Response replaceLabelsOnNodes(final NodeToLabelsInfo newNodeToLabels,
-+ @Context HttpServletRequest hsr) throws IOException {
-+ Map> nodeIdToLabels =
-+ new HashMap>();
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Random;
+
-+ for (Map.Entry nitle : newNodeToLabels
-+ .getNodeToLabels().entrySet()) {
-+ nodeIdToLabels.put(
-+ ConverterUtils.toNodeIdWithDefaultPort(nitle.getKey()),
-+ new HashSet(nitle.getValue().getNodeLabels()));
++import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
++import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.customobjects.CustomObject;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
++import com.khorn.terraincontrol.util.Txt;
++
++public class CustomObjectGen extends Resource
++{
++ private List objects;
++ private List objectNames;
++
++ @Override
++ public void load(List args) throws InvalidResourceException
++ {
++ if (args.size() == 0)
++ {
++ // Backwards compability
++ args.add(""UseWorld"");
++ }
++ objects = new ArrayList();
++ for (String arg : args)
++ {
++ CustomObject object = TerrainControl.getCustomObjectManager().getObjectFromString(arg, worldConfig);
++ if (object == null || !object.canSpawnAsObject())
++ {
++ throw new InvalidResourceException(""No custom object found with the name "" + arg);
++ }
++ objects.add(object);
++ objectNames.add(arg);
++ }
+ }
+
-+ return replaceLabelsOnNode(nodeIdToLabels, hsr, ""/replace-node-to-labels"");
-+ }
++ @Override
++ public void spawn(LocalWorld world, Random random, int x, int z)
++ {
++ // Left blank, as process(..) already handles this.
++ }
+
-+ @POST
-+ @Path(""/nodes/{nodeId}/replace-labels"")
-+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-+ public Response replaceLabelsOnNode(NodeLabelsInfo newNodeLabelsInfo,
-+ @Context HttpServletRequest hsr, @PathParam(""nodeId"") String nodeId)
-+ throws Exception {
-+ NodeId nid = ConverterUtils.toNodeIdWithDefaultPort(nodeId);
-+ Map> newLabelsForNode =
-+ new HashMap>();
-+ newLabelsForNode.put(nid,
-+ new HashSet(newNodeLabelsInfo.getNodeLabels()));
++ @Override
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ for (CustomObject object : objects)
++ {
++ object.process(world, random, chunkX, chunkZ);
++ }
++ }
+
-+ return replaceLabelsOnNode(newLabelsForNode, hsr, ""/nodes/nodeid/replace-labels"");
-+ }
++ @Override
++ public ResourceType getType()
++ {
++ return ResourceType.biomeConfigResource;
++ }
+
-+ private Response replaceLabelsOnNode(
-+ Map> newLabelsForNode, HttpServletRequest hsr,
-+ String operation) throws IOException {
- init();
--
++ @Override
++ public String makeString()
++ {
++ return ""CustomObject("" + Txt.implode(objectNames, "","") + "")"";
++ }
+
-+ checkAndThrowIfDistributedNodeLabelConfEnabled(""replaceLabelsOnNode"");
++}
+diff --git a/common/src/com/khorn/terraincontrol/generator/resourcegens/DungeonGen.java b/common/src/com/khorn/terraincontrol/generator/resourcegens/DungeonGen.java
+index 630d447df..3d7b16d6a 100644
+--- a/common/src/com/khorn/terraincontrol/generator/resourcegens/DungeonGen.java
++++ b/common/src/com/khorn/terraincontrol/generator/resourcegens/DungeonGen.java
+@@ -1,34 +1,47 @@
+ package com.khorn.terraincontrol.generator.resourcegens;
+
+-import com.khorn.terraincontrol.configuration.BiomeConfig;
+ import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
+ import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
+
++import java.util.List;
+ import java.util.Random;
+
+-public class DungeonGen extends ResourceGenBase
++public class DungeonGen extends Resource
+ {
++ private int minAltitude;
++ private int maxAltitude;
+
- UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
- if (callerUGI == null) {
-- String msg = ""Unable to obtain user name, user not authenticated for""
-- + "" post to .../replace-node-to-labels"";
-+ String msg =
-+ ""Unable to obtain user name, user not authenticated for""
-+ + "" post to ..."" + operation;
- throw new AuthorizationException(msg);
+ @Override
+- protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x, int z)
++ public void load(List args) throws InvalidResourceException
+ {
+- int _y = rand.nextInt(res.MaxAltitude - res.MinAltitude) + res.MinAltitude;
+- world.PlaceDungeons(rand, x, _y, z);
++ if (args.size() < 4)
++ {
++ throw new InvalidResourceException(""Too few arguments supplied"");
++ }
++ frequency = getInt(args.get(0), 1, 100);
++ rarity = getInt(args.get(1), 1, 100);
++ minAltitude = getInt(args.get(2), TerrainControl.worldDepth, TerrainControl.worldHeight);
++ maxAltitude = getInt(args.get(3), minAltitude + 1, TerrainControl.worldHeight);
}
-+
- if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) {
-- String msg = ""User "" + callerUGI.getShortUserName() + "" not authorized""
-- + "" for post to .../replace-node-to-labels "";
-+ String msg =
-+ ""User "" + callerUGI.getShortUserName() + "" not authorized""
-+ + "" for post to ..."" + operation;
- throw new AuthorizationException(msg);
+
+ @Override
+- protected boolean ReadString(Resource res, String[] Props, BiomeConfig biomeConfig) throws NumberFormatException
++ public void spawn(LocalWorld world, Random random, int x, int z)
+ {
+- res.Frequency = CheckValue(Props[0], 1, 100);
+- res.Rarity = CheckValue(Props[1], 0, 100);
+- res.MinAltitude = CheckValue(Props[2], 0, biomeConfig.worldConfig.WorldHeight);
+- res.MaxAltitude = CheckValue(Props[3], 0, biomeConfig.worldConfig.WorldHeight, res.MinAltitude);
++ int y = random.nextInt(maxAltitude - minAltitude) + minAltitude;
++ world.PlaceDungeons(random, x, y, z);
++ }
+
+- return true;
++ @Override
++ public ResourceType getType()
++ {
++ return ResourceType.biomeConfigResource;
}
--
-- Map> nodeIdToLabels =
-- new HashMap>();
-- for (Map.Entry nitle :
-- newNodeToLabels.getNodeToLabels().entrySet()) {
-- nodeIdToLabels.put(ConverterUtils.toNodeIdWithDefaultPort(nitle.getKey()),
-- new HashSet(nitle.getValue().getNodeLabels()));
-- }
--
-- rm.getRMContext().getNodeLabelManager().replaceLabelsOnNode(nodeIdToLabels);
-+ rm.getRMContext().getNodeLabelManager()
-+ .replaceLabelsOnNode(newLabelsForNode);
+ @Override
+- protected String WriteString(Resource res, String blockSources)
++ public String makeString()
+ {
+- return res.Frequency + "","" + res.Rarity + "","" + res.MinAltitude + "","" + res.MaxAltitude;
++ return ""Dungeon("" + frequency + "","" + rarity + "","" + minAltitude + "","" + maxAltitude + "")"";
+ }
+ }
+\ No newline at end of file
+diff --git a/common/src/com/khorn/terraincontrol/generator/resourcegens/GrassGen.java b/common/src/com/khorn/terraincontrol/generator/resourcegens/GrassGen.java
+index 0bed67e32..79c895dcc 100644
+--- a/common/src/com/khorn/terraincontrol/generator/resourcegens/GrassGen.java
++++ b/common/src/com/khorn/terraincontrol/generator/resourcegens/GrassGen.java
+@@ -1,60 +1,74 @@
+ package com.khorn.terraincontrol.generator.resourcegens;
+
+-import com.khorn.terraincontrol.configuration.BiomeConfig;
+ import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
+ import com.khorn.terraincontrol.DefaultMaterial;
+ import com.khorn.terraincontrol.LocalWorld;
- return Response.status(Status.OK).build();
- }
--
++import java.util.ArrayList;
++import java.util.List;
+ import java.util.Random;
+
+-public class GrassGen extends ResourceGenBase
++public class GrassGen extends Resource
+ {
++ private int blockId;
++ private int blockData;
++ private List sourceBlocks;
+
- @GET
- @Path(""/get-node-labels"")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-@@ -897,7 +940,7 @@ public Response removeFromCluserNodeLabels(final NodeLabelsInfo oldNodeLabels,
- @Context HttpServletRequest hsr)
- throws Exception {
- init();
--
++ @Override
++ public void load(List args) throws InvalidResourceException
++ {
++ if (args.size() < 5)
++ {
++ throw new InvalidResourceException(""Too few arguments supplied"");
++ }
++ blockId = getBlockId(args.get(0));
++ blockData = getInt(args.get(1), 0, 16);
++ frequency = getInt(args.get(2), 1, 500);
++ rarity = getInt(args.get(3), 1, 100);
++ sourceBlocks = new ArrayList();
++ for (int i = 4; i < args.size(); i++)
++ {
++ sourceBlocks.add(getBlockId(args.get(i)));
++ }
++ }
+
- UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
- if (callerUGI == null) {
- String msg = ""Unable to obtain user name, user not authenticated for""
-@@ -931,40 +974,6 @@ public NodeLabelsInfo getLabelsOnNode(@Context HttpServletRequest hsr,
- rm.getRMContext().getNodeLabelManager().getLabelsOnNode(nid));
+ @Override
+- public void Process(LocalWorld world, Random rand, Resource res, int _x, int _z)
++ public void spawn(LocalWorld world, Random random, int x, int z)
+ {
++ // Handled by process().
++ }
- }
--
-- @POST
-- @Path(""/nodes/{nodeId}/replace-labels"")
-- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-- public Response replaceLabelsOnNode(NodeLabelsInfo newNodeLabelsInfo,
-- @Context HttpServletRequest hsr, @PathParam(""nodeId"") String nodeId)
-- throws Exception {
-- init();
--
-- UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
-- if (callerUGI == null) {
-- String msg = ""Unable to obtain user name, user not authenticated for""
-- + "" post to .../nodes/nodeid/replace-labels"";
-- throw new AuthorizationException(msg);
-- }
--
-- if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) {
-- String msg = ""User "" + callerUGI.getShortUserName() + "" not authorized""
-- + "" for post to .../nodes/nodeid/replace-labels"";
-- throw new AuthorizationException(msg);
+- for (int t = 0; t < res.Frequency; t++)
++ @Override
++ public void process(LocalWorld world, Random random, int chunkX, int chunkZ)
++ {
++ for (int t = 0; t < frequency; t++)
+ {
+- if (rand.nextInt(100) >= res.Rarity)
++ if (random.nextInt(100) >= rarity)
+ continue;
+- int x = _x + rand.nextInt(16) + 8;
+- int y = world.getHeight();
+- int z = _z + rand.nextInt(16) + 8;
++ int x = chunkX * 16 + random.nextInt(16) + 8;
++ int z = chunkZ * 16 + random.nextInt(16) + 8;
++ int y = world.getHighestBlockYAt(x, z);
+
+ int i;
+ while ((((i = world.getTypeId(x, y, z)) == 0) || (i == DefaultMaterial.LEAVES.id)) && (y > 0))
+ y--;
+
+- if ((!world.isEmpty(x, y + 1, z)) || (!res.CheckSourceId(world.getTypeId(x, y, z))))
++ if ((!world.isEmpty(x, y + 1, z)) || (!sourceBlocks.contains(world.getTypeId(x, y, z))))
+ continue;
+- world.setBlock(x, y + 1, z, res.BlockId, res.BlockData, false, false, false);
++ world.setBlock(x, y + 1, z, blockId, blockData, false, false, false);
+ }
+ }
+
+ @Override
+- protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x, int z)
++ public ResourceType getType()
+ {
+-
- }
--
-- NodeId nid = ConverterUtils.toNodeIdWithDefaultPort(nodeId);
--
-- Map> newLabelsForNode = new HashMap>();
--
-- newLabelsForNode.put(nid, new HashSet(newNodeLabelsInfo.getNodeLabels()));
--
-- rm.getRMContext().getNodeLabelManager().replaceLabelsOnNode(newLabelsForNode);
--
-- return Response.status(Status.OK).build();
-
-- }
+- @Override
+- protected boolean ReadString(Resource res, String[] Props, BiomeConfig biomeConfig) throws NumberFormatException
+- {
+- res.BlockId = CheckBlock(Props[0]);
+- res.BlockData = CheckValue(Props[1], 0, 16);
+- res.Frequency = CheckValue(Props[2], 1, 500);
+- res.Rarity = CheckValue(Props[3], 0, 100);
+-
+- res.SourceBlockId = new int[Props.length - 4];
+- for (int i = 4; i < Props.length; i++)
+- res.SourceBlockId[i - 4] = CheckBlock(Props[i]);
+-
+- return true;
++ return ResourceType.biomeConfigResource;
+ }
- protected Response killApp(RMApp app, UserGroupInformation callerUGI,
- HttpServletRequest hsr) throws IOException, InterruptedException {
-diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java
-index da04c9ec32b11..fe0b8a8d1ff35 100644
---- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java
-+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java
-@@ -18,6 +18,7 @@
+ @Override
+- protected String WriteString(Resource res, String blockSources)
++ public String makeString()
+ {
+- return res.BlockIdToName(res.BlockId) + "","" + res.BlockData + "","" + res.Frequency + "","" + res.Rarity + blockSources;
++ return ""Grass("" + makeMaterial(blockId) + "","" + blockData + "","" + frequency + "","" + rarity + makeMaterial(sourceBlocks) + "")"";
+ }
+ }
+\ No newline at end of file
+diff --git a/common/src/com/khorn/terraincontrol/generator/resourcegens/LiquidGen.java b/common/src/com/khorn/terraincontrol/generator/resourcegens/LiquidGen.java
+index 00a6cb9f7..1688c7584 100644
+--- a/common/src/com/khorn/terraincontrol/generator/resourcegens/LiquidGen.java
++++ b/common/src/com/khorn/terraincontrol/generator/resourcegens/LiquidGen.java
+@@ -1,85 +1,97 @@
+ package com.khorn.terraincontrol.generator.resourcegens;
- package org.apache.hadoop.yarn.server.resourcemanager;
+ import com.khorn.terraincontrol.LocalWorld;
++import com.khorn.terraincontrol.TerrainControl;
-+import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.fail;
+-import com.khorn.terraincontrol.configuration.BiomeConfig;
+ import com.khorn.terraincontrol.configuration.Resource;
++import com.khorn.terraincontrol.exception.InvalidResourceException;
- import java.io.DataOutputStream;
-@@ -44,6 +45,7 @@
- import org.apache.hadoop.security.authorize.ProxyUsers;
- import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
- import org.apache.hadoop.yarn.api.records.DecommissionType;
-+import org.apache.hadoop.yarn.api.records.NodeId;
- import org.apache.hadoop.yarn.conf.HAUtil;
- import org.apache.hadoop.yarn.conf.YarnConfiguration;
- import org.apache.hadoop.yarn.exceptions.YarnException;
-@@ -53,6 +55,9 @@
- import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshServiceAclsRequest;
- import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshSuperUserGroupsConfigurationRequest;
- import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshUserToGroupsMappingsRequest;
-+import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest;
-+import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeRequest;
-+import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
- import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
- import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
- import org.junit.After;
-@@ -60,6 +65,8 @@
- import org.junit.Before;
- import org.junit.Test;
++import java.util.ArrayList;
++import java.util.List;
+ import java.util.Random;
-+import com.google.common.collect.ImmutableMap;
-+import com.google.common.collect.ImmutableSet;
+-public class LiquidGen extends ResourceGenBase
++public class LiquidGen extends Resource
+ {
++ private int blockId;
++ private int blockData;
++ private List sourceBlocks;
++ private int minAltitude;
++ private int maxAltitude;
++
+ @Override
+- protected void SpawnResource(LocalWorld world, Random rand, Resource res, int x, int z)
++ public void spawn(LocalWorld world, Random rand, int x, int z)
+ {
+- int y = rand.nextInt(res.MaxAltitude - res.MinAltitude) + res.MinAltitude;
++ int y = rand.nextInt(maxAltitude - minAltitude) + minAltitude;
- public class TestRMAdminService {
+- if (res.CheckSourceId(world.getTypeId(x, y + 1, z)))
++ if (sourceBlocks.contains(world.getTypeId(x, y + 1, z)))
+ return;
+- if (res.CheckSourceId(world.getTypeId(x, y - 1, z)))
++ if (sourceBlocks.contains(world.getTypeId(x, y - 1, z)))
+ return;
-@@ -754,6 +761,67 @@ public void testRMInitialsWithFileSystemBasedConfigurationProvider()
- }
- }
+- if ((world.getTypeId(x, y, z) != 0) && (res.CheckSourceId(world.getTypeId(x, y, z))))
++ if ((world.getTypeId(x, y, z) != 0) && (sourceBlocks.contains(world.getTypeId(x, y, z))))
+ return;
-+ @Test
-+ public void testModifyLabelsOnNodesWithDistributedConfigurationDisabled()
-+ throws IOException, YarnException {
-+ // create RM and set it's ACTIVE
-+ MockRM rm = new MockRM();
-+ ((RMContextImpl) rm.getRMContext())
-+ .setHAServiceState(HAServiceState.ACTIVE);
-+ RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager();
-+
-+ // by default, distributed configuration for node label is disabled, this
-+ // should pass
-+ labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of(""x"", ""y""));
-+ rm.adminService.replaceLabelsOnNode(ReplaceLabelsOnNodeRequest
-+ .newInstance(ImmutableMap.of(NodeId.newInstance(""host"", 0),
-+ (Set) ImmutableSet.of(""x""))));
-+ rm.close();
-+ }
-+
-+ @Test(expected = YarnException.class)
-+ public void testModifyLabelsOnNodesWithDistributedConfigurationEnabled()
-+ throws IOException, YarnException {
-+ // create RM and set it's ACTIVE, and set distributed node label
-+ // configuration to true
-+ MockRM rm = new MockRM();
-+ rm.adminService.isDistributedNodeLabelConfiguration = true;
-+
-+ ((RMContextImpl) rm.getRMContext())
-+ .setHAServiceState(HAServiceState.ACTIVE);
-+ RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager();
-+
-+ // by default, distributed configuration for node label is disabled, this
-+ // should pass
-+ labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of(""x"", ""y""));
-+ rm.adminService.replaceLabelsOnNode(ReplaceLabelsOnNodeRequest
-+ .newInstance(ImmutableMap.of(NodeId.newInstance(""host"", 0),
-+ (Set) ImmutableSet.of(""x""))));
-+ rm.close();
-+ }
-+
-+ @Test
-+ public void testRemoveClusterNodeLabelsWithDistributedConfigurationEnabled()
-+ throws IOException, YarnException {
-+ // create RM and set it's ACTIVE
-+ MockRM rm = new MockRM();
-+ ((RMContextImpl) rm.getRMContext())
-+ .setHAServiceState(HAServiceState.ACTIVE);
-+ RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager();
-+ rm.adminService.isDistributedNodeLabelConfiguration = true;
-+
-+ // by default, distributed configuration for node label is disabled, this
-+ // should pass
-+ labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of(""x"", ""y""));
-+ rm.adminService
-+ .removeFromClusterNodeLabels(RemoveFromClusterNodeLabelsRequest
-+ .newInstance((Set) ImmutableSet.of(""x"")));
-+
-+ Set