mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-05-15 15:31:17 +00:00
First pass at a 1.13 release. The basics appear to work
This commit is contained in:
parent
cb2ddee4e9
commit
0797702dc8
6
pom.xml
6
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>totalfreedom</artifactId>
|
||||
<version>5.0.1</version>
|
||||
<version>5.0.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -77,13 +77,13 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.6</version>
|
||||
<version>1.16.16</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-pre5-SNAPSHOT</version>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -463,7 +463,7 @@ public class FrontDoor extends FreedomService
|
|||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.SIGN_POST);
|
||||
block.setType(Material.SIGN);
|
||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -39,7 +39,6 @@ public class BlockBlocker extends FreedomService
|
|||
switch (event.getBlockPlaced().getType())
|
||||
{
|
||||
case LAVA:
|
||||
case STATIONARY_LAVA:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
|
@ -57,7 +56,6 @@ public class BlockBlocker extends FreedomService
|
|||
break;
|
||||
}
|
||||
case WATER:
|
||||
case STATIONARY_WATER:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ public class InteractBlocker extends FreedomService
|
|||
break;
|
||||
}
|
||||
|
||||
case EXPLOSIVE_MINECART:
|
||||
case TNT_MINECART:
|
||||
{
|
||||
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||
{
|
||||
|
@ -97,7 +97,6 @@ public class InteractBlocker extends FreedomService
|
|||
}
|
||||
|
||||
case SIGN:
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Sign interaction is currently disabled.");
|
||||
|
|
|
@ -165,7 +165,7 @@ public class CageData
|
|||
|
||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||
|
||||
if (material != Material.SKULL)
|
||||
if (material != Material.SKELETON_SKULL)
|
||||
{
|
||||
// Glowstone light
|
||||
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
||||
|
@ -184,7 +184,7 @@ public class CageData
|
|||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.SKULL);
|
||||
block.setType(Material.SKELETON_SKULL);
|
||||
final Skull skull = (Skull) block.getState();
|
||||
skull.setSkullType(SkullType.PLAYER);
|
||||
skull.setOwner("Prozza");
|
||||
|
|
|
@ -70,7 +70,7 @@ public class Command_cage extends FreedomCommand
|
|||
{
|
||||
if ("darth".equalsIgnoreCase(args[1]))
|
||||
{
|
||||
outerMaterial = Material.SKULL;
|
||||
outerMaterial = Material.SKELETON_SKULL;
|
||||
}
|
||||
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);
|
||||
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
if (outerMaterial != Material.SKULL)
|
||||
if (outerMaterial != Material.SKELETON_SKULL)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||
}
|
||||
|
|
|
@ -44,16 +44,7 @@ public class Command_dispfill extends FreedomCommand
|
|||
for (final String searchItem : itemsRaw)
|
||||
{
|
||||
Material material = Material.matchMaterial(searchItem);
|
||||
if (material == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
material = DepreciationAggregator.getMaterial(Integer.parseInt(searchItem));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (material != null)
|
||||
{
|
||||
|
|
|
@ -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("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
|
||||
{
|
||||
|
|
|
@ -33,16 +33,7 @@ public class Command_ro extends FreedomCommand
|
|||
for (String materialName : StringUtils.split(args[0], ","))
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -7,9 +7,11 @@ import org.bukkit.Location;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.Lever;
|
||||
|
||||
@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>")
|
||||
|
@ -63,10 +65,11 @@ public class Command_setlever extends FreedomCommand
|
|||
|
||||
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);
|
||||
DepreciationAggregator.setData_Block(targetBlock, DepreciationAggregator.getData_MaterialData(lever));
|
||||
targetBlock.getState().update();
|
||||
state.setData(lever);
|
||||
state.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -28,20 +27,10 @@ public class Command_whohas extends FreedomCommand
|
|||
|
||||
final String materialName = args[0];
|
||||
Material material = Material.matchMaterial(materialName);
|
||||
if (material == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
material = DepreciationAggregator.getMaterial(Integer.parseInt(materialName));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (material == null)
|
||||
{
|
||||
msg("Invalid block: " + materialName, ChatColor.RED);
|
||||
msg("Invalid item: " + materialName, ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,4 +59,4 @@ public class Command_whohas extends FreedomCommand
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ public class ItemFun extends FreedomService
|
|||
|
||||
switch (event.getMaterial())
|
||||
{
|
||||
case RAW_FISH:
|
||||
case TROPICAL_FISH:
|
||||
{
|
||||
final int RADIUS_HIT = 5;
|
||||
final int STRENGTH = 4;
|
||||
|
@ -77,7 +77,7 @@ public class ItemFun extends FreedomService
|
|||
}
|
||||
player.sendMessage(msg.toString());
|
||||
|
||||
player.getEquipment().getItemInMainHand().setType(Material.POTATO_ITEM);
|
||||
player.getEquipment().getItemInMainHand().setType(Material.POTATO);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class ItemFun extends FreedomService
|
|||
break;
|
||||
}
|
||||
|
||||
case CARROT_ITEM:
|
||||
case CARROT:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
|
@ -209,7 +209,7 @@ public class ItemFun extends FreedomService
|
|||
break;
|
||||
}
|
||||
|
||||
case SULPHUR:
|
||||
case GUNPOWDER:
|
||||
{
|
||||
if (!fPlayer.isMP44Armed())
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.bukkit.util.Vector;
|
|||
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;
|
||||
//
|
||||
private final Map<Player, Boolean> pushMap = Maps.newHashMap();
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Set;
|
|||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||
import org.bukkit.Material;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -60,8 +60,7 @@ public class Trailer extends FreedomService
|
|||
return;
|
||||
}
|
||||
|
||||
fromBlock.setType(Material.WOOL);
|
||||
DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16));
|
||||
fromBlock.setType(FUtil.WOOL_COLORS.get(random.nextInt(FUtil.WOOL_COLORS.size())));
|
||||
}
|
||||
|
||||
public void remove(Player player)
|
||||
|
|
|
@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.util.FLog;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class RollbackEntry
|
||||
|
@ -16,7 +17,7 @@ public class RollbackEntry
|
|||
public final int x;
|
||||
public final short y;
|
||||
public final int z;
|
||||
public final byte data;
|
||||
public final BlockData data;
|
||||
public final Material blockMaterial;
|
||||
private final boolean isBreak;
|
||||
|
||||
|
@ -33,13 +34,13 @@ public class RollbackEntry
|
|||
if (entryType == EntryType.BLOCK_BREAK)
|
||||
{
|
||||
this.blockMaterial = block.getType();
|
||||
this.data = DepreciationAggregator.getData_Block(block);
|
||||
this.data = block.getBlockData();
|
||||
this.isBreak = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.blockMaterial = block.getType();
|
||||
this.data = DepreciationAggregator.getData_Block(block);
|
||||
this.data = block.getBlockData();
|
||||
this.isBreak = false;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ public class RollbackEntry
|
|||
if (isBreak)
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
DepreciationAggregator.setData_Block(block, data);
|
||||
block.setBlockData(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -92,7 +93,7 @@ public class RollbackEntry
|
|||
else
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
DepreciationAggregator.setData_Block(block, data);
|
||||
block.setBlockData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ public class RollbackManager extends FreedomService
|
|||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package me.totalfreedom.totalfreedommod.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
|
@ -13,7 +14,7 @@ import org.bukkit.material.MaterialData;
|
|||
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);
|
||||
}
|
||||
|
@ -23,11 +24,6 @@ public class DepreciationAggregator
|
|||
return server.getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public static Material getMaterial(int id)
|
||||
{
|
||||
return Material.getMaterial(id);
|
||||
}
|
||||
|
||||
public static byte getData_MaterialData(MaterialData md)
|
||||
{
|
||||
return md.getData();
|
||||
|
@ -43,23 +39,13 @@ public class DepreciationAggregator
|
|||
return block.getData();
|
||||
}
|
||||
|
||||
public static void setData_Block(Block block, byte data)
|
||||
{
|
||||
block.setData(data);
|
||||
}
|
||||
|
||||
public static org.bukkit.material.Lever makeLeverWithData(byte 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)
|
||||
{
|
||||
return et.getName();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -400,4 +401,22 @@ public class FUtil
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public final class AdminWorld extends CustomWorld
|
|||
world.setSpawnLocation(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.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,210 +15,127 @@
|
|||
* 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 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.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
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
|
||||
{
|
||||
private Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private static final Logger log = Bukkit.getLogger();
|
||||
private short[] layer;
|
||||
private byte[] layerDataValues;
|
||||
private Material[] materials;
|
||||
|
||||
public CleanroomChunkGenerator()
|
||||
{
|
||||
this("64,stone");
|
||||
}
|
||||
|
||||
public CleanroomChunkGenerator(String id)
|
||||
{
|
||||
if (id != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
public CleanroomChunkGenerator(String id) {
|
||||
if (id != null) {
|
||||
try {
|
||||
int y = 0;
|
||||
|
||||
layer = new short[128]; // Default to 128, will be resized later if required
|
||||
layerDataValues = null;
|
||||
materials = new Material[128]; // Default to 128, will be resized later if required
|
||||
|
||||
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 .
|
||||
}
|
||||
else // Guess not, bedrock at layer0 it is then.
|
||||
{
|
||||
layer[y++] = (short) Material.BEDROCK.getId();
|
||||
} else {
|
||||
// Guess not, bedrock at layer0 it is then.
|
||||
materials[y++] = Material.BEDROCK;
|
||||
}
|
||||
|
||||
if (id.length() > 0)
|
||||
{
|
||||
if (id.length() > 0) {
|
||||
String tokens[] = id.split("[,]");
|
||||
|
||||
if ((tokens.length % 2) != 0)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
if ((tokens.length % 2) != 0) 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]);
|
||||
if (height <= 0)
|
||||
{
|
||||
if (height <= 0) {
|
||||
log.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead.");
|
||||
height = 64;
|
||||
}
|
||||
|
||||
String materialTokens[] = tokens[i + 1].split("[:]", 2);
|
||||
byte dataValue = 0;
|
||||
if (materialTokens.length == 2)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (materialTokens.length == 2) {
|
||||
log.warning("[CleanroomGenerator] Data values are no longer supported in 1.13. Defaulting to the base material for " + materialTokens[0]);
|
||||
}
|
||||
|
||||
Material mat = Material.matchMaterial(materialTokens[0]);
|
||||
if (mat == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 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 == null) {
|
||||
log.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone. (Integer IDs were removed in 1.13)");
|
||||
mat = Material.STONE;
|
||||
}
|
||||
|
||||
if (!mat.isBlock())
|
||||
{
|
||||
if (!mat.isBlock()) {
|
||||
log.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' is not a block. Defaulting to stone.");
|
||||
mat = Material.STONE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (y + height > materials.length) {
|
||||
Material[] newMaterials = new Material[Math.max(y + height, materials.length * 2)];
|
||||
|
||||
arraycopy(materials, 0, newMaterials, 0, y);
|
||||
materials = newMaterials;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
Arrays.fill(materials, y, y + height, mat);
|
||||
y += height;
|
||||
}
|
||||
}
|
||||
|
||||
// Trim to size
|
||||
if (layer.length > y)
|
||||
{
|
||||
short[] newLayer = new short[y];
|
||||
arraycopy(layer, 0, newLayer, 0, y);
|
||||
layer = newLayer;
|
||||
if (materials.length > y) {
|
||||
Material[] newMaterials = new Material[y];
|
||||
arraycopy(materials, 0, newMaterials, 0, y);
|
||||
materials = newMaterials;
|
||||
}
|
||||
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) {
|
||||
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
|
||||
e.printStackTrace();
|
||||
layerDataValues = null;
|
||||
layer = new short[65];
|
||||
layer[0] = (short) Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
|
||||
|
||||
materials = new Material[65];
|
||||
materials[0] = Material.BEDROCK;
|
||||
Arrays.fill(materials, 1, 65, Material.STONE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
layerDataValues = null;
|
||||
layer = new short[65];
|
||||
layer[0] = (short) Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
|
||||
} else {
|
||||
materials = new Material[65];
|
||||
materials[0] = Material.BEDROCK;
|
||||
Arrays.fill(materials, 1, 65, Material.STONE);
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
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;
|
||||
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.");
|
||||
Material[] newMaterials = new Material[maxHeight];
|
||||
arraycopy(materials, 0, newMaterials, 0, maxHeight);
|
||||
materials = newMaterials;
|
||||
}
|
||||
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]);
|
||||
}
|
||||
|
||||
ChunkData result = createChunkData(world);
|
||||
|
||||
for (int i = 0; i < materials.length; i++) {
|
||||
result.setRegion(0, i, 0, 15, i, 15, materials[i]);
|
||||
}
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.world;
|
|||
import java.io.File;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -46,7 +45,7 @@ public class Flatlands extends CustomWorld
|
|||
world.setSpawnLocation(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.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
name: TotalFreedomMod
|
||||
main: me.totalfreedom.totalfreedommod.TotalFreedomMod
|
||||
version: ${tfm.build.version}
|
||||
api-version: 1.13
|
||||
description: Plugin for the Total Freedom server.
|
||||
depend: [Aero, WorldEdit]
|
||||
softdepend: [BukkitTelnet, Essentials, LibsDisguises]
|
||||
|
|
Loading…
Reference in a new issue