First pass at a 1.13 release. The basics appear to work

This commit is contained in:
Ryan 2018-07-25 20:08:11 +01:00
parent cb2ddee4e9
commit 0797702dc8
24 changed files with 123 additions and 302 deletions

View file

@ -4,7 +4,7 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>totalfreedom</artifactId> <artifactId>totalfreedom</artifactId>
<version>5.0.1</version> <version>5.0.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
@ -77,13 +77,13 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.16.6</version> <version>1.16.16</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.12-pre5-SNAPSHOT</version> <version>1.13-R0.1-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View file

@ -463,7 +463,7 @@ public class FrontDoor extends FreedomService
continue; continue;
} }
block.setType(Material.SIGN_POST); block.setType(Material.SIGN);
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState(); org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData();
@ -541,7 +541,8 @@ public class FrontDoor extends FreedomService
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true); FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
Location targetPos = player.getLocation().clone().add(0, 1, 0); Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR); playerdata.getCageData().cage(targetPos, Material.SKELETON_SKULL, Material.AIR);
break; break;
} }

View file

@ -6,7 +6,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
public class ServerInterface extends FreedomService public class ServerInterface extends FreedomService
{ {
public static final String COMPILE_NMS_VERSION = "v1_12_R1"; public static final String COMPILE_NMS_VERSION = "v1_13_R1";
public ServerInterface(TotalFreedomMod plugin) public ServerInterface(TotalFreedomMod plugin)
{ {

View file

@ -39,7 +39,6 @@ public class BlockBlocker extends FreedomService
switch (event.getBlockPlaced().getType()) switch (event.getBlockPlaced().getType())
{ {
case LAVA: case LAVA:
case STATIONARY_LAVA:
{ {
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{ {
@ -57,7 +56,6 @@ public class BlockBlocker extends FreedomService
break; break;
} }
case WATER: case WATER:
case STATIONARY_WATER:
{ {
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{ {

View file

@ -83,7 +83,7 @@ public class InteractBlocker extends FreedomService
break; break;
} }
case EXPLOSIVE_MINECART: case TNT_MINECART:
{ {
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean()) if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{ {
@ -97,7 +97,6 @@ public class InteractBlocker extends FreedomService
} }
case SIGN: case SIGN:
case SIGN_POST:
case WALL_SIGN: case WALL_SIGN:
{ {
player.sendMessage(ChatColor.GRAY + "Sign interaction is currently disabled."); player.sendMessage(ChatColor.GRAY + "Sign interaction is currently disabled.");

View file

@ -165,7 +165,7 @@ public class CageData
final Block block = center.getRelative(xOffset, yOffset, zOffset); final Block block = center.getRelative(xOffset, yOffset, zOffset);
if (material != Material.SKULL) if (material != Material.SKELETON_SKULL)
{ {
// Glowstone light // Glowstone light
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0) if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
@ -184,7 +184,7 @@ public class CageData
continue; continue;
} }
block.setType(Material.SKULL); block.setType(Material.SKELETON_SKULL);
final Skull skull = (Skull) block.getState(); final Skull skull = (Skull) block.getState();
skull.setSkullType(SkullType.PLAYER); skull.setSkullType(SkullType.PLAYER);
skull.setOwner("Prozza"); skull.setOwner("Prozza");

View file

@ -70,7 +70,7 @@ public class Command_cage extends FreedomCommand
{ {
if ("darth".equalsIgnoreCase(args[1])) if ("darth".equalsIgnoreCase(args[1]))
{ {
outerMaterial = Material.SKULL; outerMaterial = Material.SKELETON_SKULL;
} }
else if (Material.matchMaterial(args[1]) != null) else if (Material.matchMaterial(args[1]) != null)
{ {
@ -79,24 +79,12 @@ public class Command_cage extends FreedomCommand
} }
} }
if (args.length >= 3)
{
if (args[2].equalsIgnoreCase("water"))
{
innerMaterial = Material.STATIONARY_WATER;
}
else if (args[2].equalsIgnoreCase("lava"))
{
innerMaterial = Material.STATIONARY_LAVA;
}
}
Location targetPos = player.getLocation().clone().add(0, 1, 0); Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial); playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
if (outerMaterial != Material.SKULL) if (outerMaterial != Material.SKELETON_SKULL)
{ {
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true); FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
} }

View file

@ -44,16 +44,7 @@ public class Command_dispfill extends FreedomCommand
for (final String searchItem : itemsRaw) for (final String searchItem : itemsRaw)
{ {
Material material = Material.matchMaterial(searchItem); Material material = Material.matchMaterial(searchItem);
if (material == null)
{
try
{
material = DepreciationAggregator.getMaterial(Integer.parseInt(searchItem));
}
catch (NumberFormatException ex)
{
}
}
if (material != null) if (material != null)
{ {

View file

@ -38,7 +38,7 @@ public class Command_mp44 extends FreedomCommand
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN); msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN); msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.SULPHUR, 1)); playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1));
} }
else else
{ {

View file

@ -33,16 +33,7 @@ public class Command_ro extends FreedomCommand
for (String materialName : StringUtils.split(args[0], ",")) for (String materialName : StringUtils.split(args[0], ","))
{ {
Material fromMaterial = Material.matchMaterial(materialName); Material fromMaterial = Material.matchMaterial(materialName);
if (fromMaterial == null)
{
try
{
fromMaterial = DepreciationAggregator.getMaterial(Integer.parseInt(materialName));
}
catch (NumberFormatException ex)
{
}
}
if (fromMaterial == null || fromMaterial == Material.AIR || !fromMaterial.isBlock()) if (fromMaterial == null || fromMaterial == Material.AIR || !fromMaterial.isBlock())
{ {

View file

@ -7,9 +7,11 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.material.Lever;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on|off>") @CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on|off>")
@ -63,10 +65,11 @@ public class Command_setlever extends FreedomCommand
if (targetBlock.getType() == Material.LEVER) if (targetBlock.getType() == Material.LEVER)
{ {
org.bukkit.material.Lever lever = DepreciationAggregator.makeLeverWithData(DepreciationAggregator.getData_Block(targetBlock)); BlockState state = targetBlock.getState();
Lever lever = (Lever) state.getData();
lever.setPowered(leverOn); lever.setPowered(leverOn);
DepreciationAggregator.setData_Block(targetBlock, DepreciationAggregator.getData_MaterialData(lever)); state.setData(lever);
targetBlock.getState().update(); state.update();
} }
else else
{ {

View file

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -28,20 +27,10 @@ public class Command_whohas extends FreedomCommand
final String materialName = args[0]; final String materialName = args[0];
Material material = Material.matchMaterial(materialName); Material material = Material.matchMaterial(materialName);
if (material == null)
{
try
{
material = DepreciationAggregator.getMaterial(Integer.parseInt(materialName));
}
catch (NumberFormatException ex)
{
}
}
if (material == null) if (material == null)
{ {
msg("Invalid block: " + materialName, ChatColor.RED); msg("Invalid item: " + materialName, ChatColor.RED);
return true; return true;
} }
@ -70,4 +59,4 @@ public class Command_whohas extends FreedomCommand
return true; return true;
} }
} }

View file

@ -56,7 +56,7 @@ public class ItemFun extends FreedomService
switch (event.getMaterial()) switch (event.getMaterial())
{ {
case RAW_FISH: case TROPICAL_FISH:
{ {
final int RADIUS_HIT = 5; final int RADIUS_HIT = 5;
final int STRENGTH = 4; final int STRENGTH = 4;
@ -77,7 +77,7 @@ public class ItemFun extends FreedomService
} }
player.sendMessage(msg.toString()); player.sendMessage(msg.toString());
player.getEquipment().getItemInMainHand().setType(Material.POTATO_ITEM); player.getEquipment().getItemInMainHand().setType(Material.POTATO);
break; break;
} }
@ -126,7 +126,7 @@ public class ItemFun extends FreedomService
break; break;
} }
case CARROT_ITEM: case CARROT:
{ {
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
@ -209,7 +209,7 @@ public class ItemFun extends FreedomService
break; break;
} }
case SULPHUR: case GUNPOWDER:
{ {
if (!fPlayer.isMP44Armed()) if (!fPlayer.isMP44Armed())
{ {

View file

@ -16,7 +16,7 @@ import org.bukkit.util.Vector;
public class Jumppads extends FreedomService public class Jumppads extends FreedomService
{ {
public static final Material BLOCK_ID = Material.WOOL; public static final Material BLOCK_ID = Material.WHITE_WOOL;
public static final double DAMPING_COEFFICIENT = 0.8; public static final double DAMPING_COEFFICIENT = 0.8;
// //
private final Map<Player, Boolean> pushMap = Maps.newHashMap(); private final Map<Player, Boolean> pushMap = Maps.newHashMap();

View file

@ -7,7 +7,7 @@ import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.bukkit.Material; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -60,8 +60,7 @@ public class Trailer extends FreedomService
return; return;
} }
fromBlock.setType(Material.WOOL); fromBlock.setType(FUtil.WOOL_COLORS.get(random.nextInt(FUtil.WOOL_COLORS.size())));
DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16));
} }
public void remove(Player player) public void remove(Player player)

View file

@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.Block; import org.bukkit.block.Block;
public class RollbackEntry public class RollbackEntry
@ -16,7 +17,7 @@ public class RollbackEntry
public final int x; public final int x;
public final short y; public final short y;
public final int z; public final int z;
public final byte data; public final BlockData data;
public final Material blockMaterial; public final Material blockMaterial;
private final boolean isBreak; private final boolean isBreak;
@ -33,13 +34,13 @@ public class RollbackEntry
if (entryType == EntryType.BLOCK_BREAK) if (entryType == EntryType.BLOCK_BREAK)
{ {
this.blockMaterial = block.getType(); this.blockMaterial = block.getType();
this.data = DepreciationAggregator.getData_Block(block); this.data = block.getBlockData();
this.isBreak = true; this.isBreak = true;
} }
else else
{ {
this.blockMaterial = block.getType(); this.blockMaterial = block.getType();
this.data = DepreciationAggregator.getData_Block(block); this.data = block.getBlockData();
this.isBreak = false; this.isBreak = false;
} }
} }
@ -73,7 +74,7 @@ public class RollbackEntry
if (isBreak) if (isBreak)
{ {
block.setType(getMaterial()); block.setType(getMaterial());
DepreciationAggregator.setData_Block(block, data); block.setBlockData(data);
} }
else else
{ {
@ -92,7 +93,7 @@ public class RollbackEntry
else else
{ {
block.setType(getMaterial()); block.setType(getMaterial());
DepreciationAggregator.setData_Block(block, data); block.setBlockData(data);
} }
} }
} }

View file

@ -248,7 +248,7 @@ public class RollbackManager extends FreedomService
for (RollbackEntry entry : entries) for (RollbackEntry entry : entries)
{ {
FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " " FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " "
+ StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data)); + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == null ? "" : ":" + entry.data));
} }
} }

View file

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.util; package me.totalfreedom.totalfreedommod.util;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
@ -13,7 +14,7 @@ import org.bukkit.material.MaterialData;
public class DepreciationAggregator public class DepreciationAggregator
{ {
public static Block getTargetBlock(LivingEntity entity, HashSet<Byte> transparent, int maxDistance) public static Block getTargetBlock(LivingEntity entity, HashSet<Material> transparent, int maxDistance)
{ {
return entity.getTargetBlock(transparent, maxDistance); return entity.getTargetBlock(transparent, maxDistance);
} }
@ -23,11 +24,6 @@ public class DepreciationAggregator
return server.getOfflinePlayer(name); return server.getOfflinePlayer(name);
} }
public static Material getMaterial(int id)
{
return Material.getMaterial(id);
}
public static byte getData_MaterialData(MaterialData md) public static byte getData_MaterialData(MaterialData md)
{ {
return md.getData(); return md.getData();
@ -43,23 +39,13 @@ public class DepreciationAggregator
return block.getData(); return block.getData();
} }
public static void setData_Block(Block block, byte data)
{
block.setData(data);
}
public static org.bukkit.material.Lever makeLeverWithData(byte data) public static org.bukkit.material.Lever makeLeverWithData(byte data)
{ {
return new org.bukkit.material.Lever(Material.LEVER, data); return new org.bukkit.material.Lever(Material.LEVER, data);
} }
public static int getTypeId_Block(Block block)
{
return block.getTypeId();
}
public static String getName_EntityType(EntityType et) public static String getName_EntityType(EntityType et)
{ {
return et.getName(); return et.getName();
} }
} }

View file

@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -400,4 +401,22 @@ public class FUtil
return packageName.substring(packageName.lastIndexOf('.') + 1); return packageName.substring(packageName.lastIndexOf('.') + 1);
} }
public static final List<Material> WOOL_COLORS = Arrays.asList(
Material.WHITE_WOOL,
Material.RED_WOOL,
Material.ORANGE_WOOL,
Material.YELLOW_WOOL,
Material.GREEN_WOOL,
Material.LIME_WOOL,
Material.LIGHT_BLUE_WOOL,
Material.CYAN_WOOL,
Material.BLUE_WOOL,
Material.PURPLE_WOOL,
Material.MAGENTA_WOOL,
Material.PINK_WOOL,
Material.BROWN_WOOL,
Material.GRAY_WOOL,
Material.LIGHT_GRAY_WOOL,
Material.BLACK_WOOL);
} }

View file

@ -68,7 +68,7 @@ public final class AdminWorld extends CustomWorld
world.setSpawnLocation(0, 50, 0); world.setSpawnLocation(0, 50, 0);
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
welcomeSignBlock.setType(Material.SIGN_POST); welcomeSignBlock.setType(Material.SIGN);
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();

View file

@ -1,61 +0,0 @@
/*
* 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.totalfreedom.totalfreedommod.world;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
@SuppressWarnings("deprecation")
public class CleanroomBlockPopulator extends BlockPopulator
{
byte[] layerDataValues;
protected CleanroomBlockPopulator(byte[] layerDataValues)
{
this.layerDataValues = layerDataValues;
}
@Override
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);
}
}
}
}
}
}

View file

@ -15,210 +15,127 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package me.totalfreedom.totalfreedommod.world; package me.totalfreedom.totalfreedommod.world;
import static java.lang.System.arraycopy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
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.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@SuppressWarnings("deprecation") import java.util.Arrays;
import java.util.Random;
import java.util.logging.Logger;
import static java.lang.System.arraycopy;
public class CleanroomChunkGenerator extends ChunkGenerator public class CleanroomChunkGenerator extends ChunkGenerator
{ {
private Logger log = Logger.getLogger("Minecraft");
private static final Logger log = Bukkit.getLogger(); private Material[] materials;
private short[] layer;
private byte[] layerDataValues;
public CleanroomChunkGenerator() public CleanroomChunkGenerator()
{ {
this("64,stone"); this("64,stone");
} }
public CleanroomChunkGenerator(String id) public CleanroomChunkGenerator(String id) {
{ 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 materials = new Material[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 {
else // Guess not, bedrock at layer0 it is then. // Guess not, bedrock at layer0 it is then.
{ materials[y++] = Material.BEDROCK;
layer[y++] = (short) Material.BEDROCK.getId();
} }
if (id.length() > 0) if (id.length() > 0) {
{
String tokens[] = id.split("[,]"); String tokens[] = id.split("[,]");
if ((tokens.length % 2) != 0) if ((tokens.length % 2) != 0) throw new Exception();
{
throw new Exception();
}
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) if (height <= 0) {
{
log.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead."); log.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead.");
height = 64; height = 64;
} }
String materialTokens[] = tokens[i + 1].split("[:]", 2); String materialTokens[] = tokens[i + 1].split("[:]", 2);
byte dataValue = 0;
if (materialTokens.length == 2) if (materialTokens.length == 2) {
{ log.warning("[CleanroomGenerator] Data values are no longer supported in 1.13. Defaulting to the base material for " + materialTokens[0]);
try
{
// 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(materialTokens[0]); Material mat = Material.matchMaterial(materialTokens[0]);
if (mat == null) if (mat == null) {
{ log.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone. (Integer IDs were removed in 1.13)");
try mat = Material.STONE;
{
// Mabe it's an integer?
mat = Material.getMaterial(Integer.parseInt(materialTokens[0]));
}
catch (Exception e)
{
// Well, I guess it wasn't an integer after all... Awkward...
}
if (mat == null)
{
log.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone.");
mat = Material.STONE;
}
} }
if (!mat.isBlock()) if (!mat.isBlock()) {
{
log.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' 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;
} }
if (y + height > layer.length) if (y + height > materials.length) {
{ Material[] newMaterials = new Material[Math.max(y + height, materials.length * 2)];
short[] newLayer = new short[Math.max(y + height, layer.length * 2)];
arraycopy(layer, 0, newLayer, 0, y); arraycopy(materials, 0, newMaterials, 0, y);
layer = newLayer; materials = newMaterials;
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()); Arrays.fill(materials, y, y + height, mat);
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 // Trim to size
if (layer.length > y) if (materials.length > y) {
{ Material[] newMaterials = new Material[y];
short[] newLayer = new short[y]; arraycopy(materials, 0, newMaterials, 0, y);
arraycopy(layer, 0, newLayer, 0, y); materials = newMaterials;
layer = newLayer;
} }
if (layerDataValues != null && layerDataValues.length > y) } catch (Exception e) {
{
byte[] newLayerDataValues = new byte[y];
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
layerDataValues = newLayerDataValues;
}
}
catch (Exception e)
{
log.severe("[CleanroomGenerator] 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();
layerDataValues = null;
layer = new short[65]; materials = new Material[65];
layer[0] = (short) Material.BEDROCK.getId(); materials[0] = Material.BEDROCK;
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId()); Arrays.fill(materials, 1, 65, Material.STONE);
} }
} } else {
else materials = new Material[65];
{ materials[0] = Material.BEDROCK;
layerDataValues = null; Arrays.fill(materials, 1, 65, Material.STONE);
layer = new short[65];
layer[0] = (short) Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
} }
} }
@Override @Override
public short[][] generateExtBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
{
int maxHeight = world.getMaxHeight(); int maxHeight = world.getMaxHeight();
if (layer.length > maxHeight) if (materials.length > maxHeight) {
{ log.warning("[CleanroomGenerator] Error, chunk height " + materials.length + " is greater than the world max height (" + maxHeight + "). Trimming to world max height.");
log.warning("[CleanroomGenerator] Error, chunk height " + layer.length + " is greater than the world max height (" + maxHeight + "). Trimming to world max height."); Material[] newMaterials = new Material[maxHeight];
short[] newLayer = new short[maxHeight]; arraycopy(materials, 0, newMaterials, 0, maxHeight);
arraycopy(layer, 0, newLayer, 0, maxHeight); materials = newMaterials;
layer = newLayer;
} }
short[][] result = new short[maxHeight / 16][]; // 16x16x16 chunks
for (int i = 0; i < layer.length; i += 16) ChunkData result = createChunkData(world);
{
result[i >> 4] = new short[4096]; for (int i = 0; i < materials.length; i++) {
for (int y = 0; y < Math.min(16, layer.length - i); y++) result.setRegion(0, i, 0, 15, i, 15, materials[i]);
{
Arrays.fill(result[i >> 4], y * 16 * 16, (y + 1) * 16 * 16, layer[i + y]);
}
} }
return result; return result;
} }
@Override
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...
return new ArrayList<>();
}
}
@Override @Override
public Location getFixedSpawnLocation(World world, Random random) public Location getFixedSpawnLocation(World world, Random random)
{ {
@ -234,4 +151,4 @@ public class CleanroomChunkGenerator extends ChunkGenerator
return new Location(world, 0, world.getHighestBlockYAt(0, 0), 0); return new Location(world, 0, world.getHighestBlockYAt(0, 0), 0);
} }
} }

View file

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.world;
import java.io.File; import java.io.File;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -46,7 +45,7 @@ public class Flatlands extends CustomWorld
world.setSpawnLocation(0, 50, 0); world.setSpawnLocation(0, 50, 0);
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
welcomeSignBlock.setType(Material.SIGN_POST); welcomeSignBlock.setType(Material.SIGN);
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();

View file

@ -1,6 +1,7 @@
name: TotalFreedomMod name: TotalFreedomMod
main: me.totalfreedom.totalfreedommod.TotalFreedomMod main: me.totalfreedom.totalfreedommod.TotalFreedomMod
version: ${tfm.build.version} version: ${tfm.build.version}
api-version: 1.13
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
depend: [Aero, WorldEdit] depend: [Aero, WorldEdit]
softdepend: [BukkitTelnet, Essentials, LibsDisguises] softdepend: [BukkitTelnet, Essentials, LibsDisguises]