mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Starting v2.6
Updated cleanroom generator. Dont need to define server in some listeners, never use it.
This commit is contained in:
parent
5838eb23ff
commit
614d502bb6
@ -1,5 +1,5 @@
|
|||||||
#Sat, 28 Jul 2012 15:17:23 -0400
|
#Thu, 13 Sep 2012 19:16:42 -0400
|
||||||
|
|
||||||
program.VERSION=2.5
|
program.VERSION=2.6
|
||||||
program.BUILDNUM=77
|
program.BUILDNUM=20
|
||||||
program.BUILDDATE=07/28/2012 03\:17 PM
|
program.BUILDDATE=09/13/2012 07\:16 PM
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
<target name="-pre-jar">
|
<target name="-pre-jar">
|
||||||
<buildnumber file="buildnumber.properties" />
|
<buildnumber file="buildnumber.properties" />
|
||||||
<propertyfile file="appinfo.properties">
|
<propertyfile file="appinfo.properties">
|
||||||
<entry key="program.VERSION" default="2.5" />
|
<entry key="program.VERSION" default="0.0" />
|
||||||
<entry key="program.BUILDNUM" value="${build.number}" />
|
<entry key="program.BUILDNUM" value="${build.number}" />
|
||||||
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
|
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Sat Jul 28 15:17:23 EDT 2012
|
#Thu Sep 13 19:16:42 EDT 2012
|
||||||
build.number=78
|
build.number=21
|
||||||
|
@ -29,7 +29,7 @@ excludes=
|
|||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${libs.Bukkit.classpath}
|
${libs.CraftBukkit.classpath}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Cleanroom Generator
|
||||||
|
* Copyright (C) 2011-2012 nvx
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
|
public class CleanroomBlockPopulator extends BlockPopulator
|
||||||
|
{
|
||||||
|
byte[] layerDataValues;
|
||||||
|
protected CleanroomBlockPopulator(byte[] layerDataValues)
|
||||||
|
{
|
||||||
|
this.layerDataValues = layerDataValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populate(World world, Random random, Chunk chunk)
|
||||||
|
{
|
||||||
|
if (layerDataValues != null)
|
||||||
|
{
|
||||||
|
int x = chunk.getX() << 4;
|
||||||
|
int z = chunk.getZ() << 4;
|
||||||
|
|
||||||
|
for (int y = 0; y < layerDataValues.length ; y++)
|
||||||
|
{
|
||||||
|
byte dataValue = layerDataValues[y];
|
||||||
|
if (dataValue == 0) continue;
|
||||||
|
for (int xx = 0; xx < 16; xx++)
|
||||||
|
{
|
||||||
|
for (int zz = 0; zz < 16; zz++)
|
||||||
|
{
|
||||||
|
world.getBlockAt(x + xx, y, z + zz).setData(dataValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Cleanroom Generator
|
* Cleanroom Generator
|
||||||
* Copyright (C) 2011 nvx
|
* Copyright (C) 2011-2012 nvx
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -18,22 +18,23 @@
|
|||||||
|
|
||||||
package me.StevenLawson.TotalFreedomMod;
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
|
import static java.lang.System.arraycopy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import static java.lang.System.arraycopy;
|
|
||||||
|
|
||||||
public class CleanroomChunkGenerator extends ChunkGenerator
|
public class CleanroomChunkGenerator extends ChunkGenerator
|
||||||
{
|
{
|
||||||
private byte[] chunk = new byte[32768];
|
private Logger log = Logger.getLogger("Minecraft");
|
||||||
|
private short[] layer;
|
||||||
|
private byte[] layerDataValues;
|
||||||
|
|
||||||
public CleanroomChunkGenerator()
|
public CleanroomChunkGenerator()
|
||||||
{
|
{
|
||||||
@ -42,19 +43,21 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
|||||||
|
|
||||||
public CleanroomChunkGenerator(String id)
|
public CleanroomChunkGenerator(String id)
|
||||||
{
|
{
|
||||||
byte[] layer = new byte[128];
|
|
||||||
if (id != null)
|
if (id != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
|
layer = new short[128]; // Default to 128, will be resized later if required
|
||||||
|
layerDataValues = null;
|
||||||
|
|
||||||
if ((id.length() > 0) && (id.charAt(0) == '.')) // Is the first character a '.'? If so, skip bedrock generation.
|
if ((id.length() > 0) && (id.charAt(0) == '.')) // Is the first character a '.'? If so, skip bedrock generation.
|
||||||
{
|
{
|
||||||
id = id.substring(1); // Skip bedrock then and remove the .
|
id = id.substring(1); // Skip bedrock then and remove the .
|
||||||
} else // Guess not, bedrock at layer0 it is then.
|
} else // Guess not, bedrock at layer0 it is then.
|
||||||
{
|
{
|
||||||
layer[y++] = (byte)Material.BEDROCK.getId();
|
layer[y++] = (short)Material.BEDROCK.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id.length() > 0)
|
if (id.length() > 0)
|
||||||
@ -66,25 +69,33 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
|||||||
for (int i = 0; i < tokens.length; i += 2)
|
for (int i = 0; i < tokens.length; i += 2)
|
||||||
{
|
{
|
||||||
int height = Integer.parseInt(tokens[i]);
|
int height = Integer.parseInt(tokens[i]);
|
||||||
if ((height <= 0) || (height > 127))
|
if (height <= 0)
|
||||||
{
|
{
|
||||||
System.out.println("Invalid height '" + tokens[i] + "'. Using 64 instead.");
|
log.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead.");
|
||||||
height = 64;
|
height = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((height + y) > 127)
|
String materialTokens[] = tokens[i + 1].split("[:]", 2);
|
||||||
|
byte dataValue = 0;
|
||||||
|
if (materialTokens.length == 2)
|
||||||
{
|
{
|
||||||
System.out.println("Maximum height reached, ignoring additional layers.");
|
try
|
||||||
break;
|
{
|
||||||
|
// Lets try to read the data value
|
||||||
|
dataValue = Byte.parseByte(materialTokens[1]);
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
|
||||||
|
dataValue = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Material mat = Material.matchMaterial(tokens[i + 1]);
|
Material mat = Material.matchMaterial(materialTokens[0]);
|
||||||
if (mat == null)
|
if (mat == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Mabe it's an integer?
|
// Mabe it's an integer?
|
||||||
mat = Material.getMaterial(Integer.parseInt(tokens[i + 1]));
|
mat = Material.getMaterial(Integer.parseInt(materialTokens[0]));
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
// Well, I guess it wasn't an integer after all... Awkward...
|
// Well, I guess it wasn't an integer after all... Awkward...
|
||||||
@ -92,52 +103,110 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
|||||||
|
|
||||||
if (mat == null)
|
if (mat == null)
|
||||||
{
|
{
|
||||||
System.out.println("Invalid Block ID '" + tokens[i + 1] + "'. Defaulting to stone.");
|
log.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone.");
|
||||||
mat = Material.STONE;
|
mat = Material.STONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mat.isBlock())
|
if (!mat.isBlock())
|
||||||
{
|
{
|
||||||
System.out.println("Error, '" + tokens[i + 1] + "' is not a block. Defaulting to stone.");
|
log.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' is not a block. Defaulting to stone.");
|
||||||
mat = Material.STONE;
|
mat = Material.STONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arrays.fill(layer, y, y + height, (byte)mat.getId());
|
if (y + height > layer.length)
|
||||||
|
{
|
||||||
|
short[] newLayer = new short[Math.max(y + height, layer.length * 2)];
|
||||||
|
arraycopy(layer, 0, newLayer, 0, y);
|
||||||
|
layer = newLayer;
|
||||||
|
if (layerDataValues != null)
|
||||||
|
{
|
||||||
|
byte[] newLayerDataValues = new byte[Math.max(y + height, layerDataValues.length * 2)];
|
||||||
|
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
|
||||||
|
layerDataValues = newLayerDataValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Arrays.fill(layer, y, y + height, (short)mat.getId());
|
||||||
|
if (dataValue != 0)
|
||||||
|
{
|
||||||
|
if (layerDataValues == null)
|
||||||
|
{
|
||||||
|
layerDataValues = new byte[layer.length];
|
||||||
|
}
|
||||||
|
Arrays.fill(layerDataValues, y, y + height, dataValue);
|
||||||
|
}
|
||||||
y += height;
|
y += height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trim to size
|
||||||
|
if (layer.length > y)
|
||||||
|
{
|
||||||
|
short[] newLayer = new short[y];
|
||||||
|
arraycopy(layer, 0, newLayer, 0, y);
|
||||||
|
layer = newLayer;
|
||||||
|
}
|
||||||
|
if (layerDataValues != null && layerDataValues.length > y)
|
||||||
|
{
|
||||||
|
byte[] newLayerDataValues = new byte[y];
|
||||||
|
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
|
||||||
|
layerDataValues = newLayerDataValues;
|
||||||
|
}
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
System.out.println("Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
|
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
layer[0] = (byte)Material.BEDROCK.getId();
|
layerDataValues = null;
|
||||||
Arrays.fill(layer, 1, 65, (byte)Material.STONE.getId());
|
layer = new short[65];
|
||||||
Arrays.fill(layer, 65, 128, (byte)Material.AIR.getId()); // Just in case...
|
layer[0] = (short)Material.BEDROCK.getId();
|
||||||
|
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId());
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
layer[0] = (byte)Material.BEDROCK.getId();
|
layerDataValues = null;
|
||||||
Arrays.fill(layer, 1, 65, (byte)Material.STONE.getId());
|
layer = new short[65];
|
||||||
}
|
layer[0] = (short)Material.BEDROCK.getId();
|
||||||
|
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId());
|
||||||
for (int xz = 0; xz < 256; xz++)
|
|
||||||
{
|
|
||||||
arraycopy(layer, 0, chunk, xz * 128, layer.length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] generate(World world, Random random, int cx, int cz)
|
@Override
|
||||||
|
public short[][] generateExtBlockSections(World world, Random random, int x, int z, BiomeGrid biomes)
|
||||||
{
|
{
|
||||||
return chunk.clone(); // Can't get more efficient than that...
|
int maxHeight = world.getMaxHeight();
|
||||||
|
if (layer.length > maxHeight)
|
||||||
|
{
|
||||||
|
log.warning("[CleanroomGenerator] Error, chunk height " + layer.length + " is greater than the world max height (" + maxHeight + "). Trimming to world max height.");
|
||||||
|
short[] newLayer = new short[maxHeight];
|
||||||
|
arraycopy(layer, 0, newLayer, 0, maxHeight);
|
||||||
|
layer = newLayer;
|
||||||
|
}
|
||||||
|
short[][] result = new short[maxHeight / 16][]; // 16x16x16 chunks
|
||||||
|
for (int i = 0; i < layer.length; i += 16)
|
||||||
|
{
|
||||||
|
result[i >> 4] = new short[4096];
|
||||||
|
for (int y = 0; y < Math.min(16, layer.length - i); y++)
|
||||||
|
{
|
||||||
|
Arrays.fill(result[i >> 4], y * 16 * 16, (y + 1) * 16 * 16, layer[i + y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||||
|
{
|
||||||
|
if (layerDataValues != null)
|
||||||
|
{
|
||||||
|
return Arrays.asList((BlockPopulator)new CleanroomBlockPopulator(layerDataValues));
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
// This is the default, but just in case default populators change to stock minecraft populators by default...
|
// This is the default, but just in case default populators change to stock minecraft populators by default...
|
||||||
return new ArrayList<BlockPopulator>();
|
return new ArrayList<BlockPopulator>();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getFixedSpawnLocation(World world, Random random)
|
public Location getFixedSpawnLocation(World world, Random random)
|
||||||
|
@ -7,7 +7,6 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -18,13 +17,11 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class TFM_BlockListener implements Listener
|
public class TFM_BlockListener implements Listener
|
||||||
{
|
{
|
||||||
private final TotalFreedomMod plugin;
|
private final TotalFreedomMod plugin;
|
||||||
private final Server server;
|
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
public TFM_BlockListener(TotalFreedomMod instance)
|
public TFM_BlockListener(TotalFreedomMod instance)
|
||||||
{
|
{
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.server = plugin.getServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -11,12 +10,10 @@ import org.bukkit.event.entity.*;
|
|||||||
public class TFM_EntityListener implements Listener
|
public class TFM_EntityListener implements Listener
|
||||||
{
|
{
|
||||||
private final TotalFreedomMod plugin;
|
private final TotalFreedomMod plugin;
|
||||||
private final Server server;
|
|
||||||
|
|
||||||
public TFM_EntityListener(TotalFreedomMod instance)
|
public TFM_EntityListener(TotalFreedomMod instance)
|
||||||
{
|
{
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.server = plugin.getServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -11,12 +10,10 @@ import org.bukkit.event.weather.WeatherChangeEvent;
|
|||||||
public class TFM_WeatherListener implements Listener
|
public class TFM_WeatherListener implements Listener
|
||||||
{
|
{
|
||||||
private final TotalFreedomMod plugin;
|
private final TotalFreedomMod plugin;
|
||||||
private final Server server;
|
|
||||||
|
|
||||||
public TFM_WeatherListener(TotalFreedomMod instance)
|
public TFM_WeatherListener(TotalFreedomMod instance)
|
||||||
{
|
{
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.server = plugin.getServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: TotalFreedomMod
|
name: TotalFreedomMod
|
||||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||||
version: 2.5
|
version: 2.6
|
||||||
description: Plugin for the Total Freedom server.
|
description: Plugin for the Total Freedom server.
|
||||||
author: StevenLawson / Madgeek1450
|
author: StevenLawson / Madgeek1450
|
||||||
commands:
|
commands:
|
||||||
|
Loading…
Reference in New Issue
Block a user