mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
More 1.13 things
This commit is contained in:
parent
113ab62f0b
commit
38e1769f0d
@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -24,10 +24,12 @@ import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||
import net.pravian.aero.component.service.ServiceManager;
|
||||
import net.pravian.aero.plugin.AeroPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.mcstats.Metrics;
|
||||
@ -341,4 +343,10 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||
{
|
||||
return new CleanroomChunkGenerator(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,20 +8,20 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Kick all non-superadmins on server.", usage = "/<command>")
|
||||
@CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>")
|
||||
public class Command_kicknoob extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Disconnecting all non-superadmins.", true);
|
||||
FUtil.adminAction(sender.getName(), "Disconnecting all non-admins.", true);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED + "All non-superadmins were kicked by " + sender.getName() + ".");
|
||||
player.kickPlayer(ChatColor.RED + "All non-admins were kicked by " + sender.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,62 +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++)
|
||||
{
|
||||
// xd dont know what im gonna do, ill come back to this later
|
||||
//world.getBlockAt(x + xx, y, z + zz).setData(dataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,206 +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 me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
private short[] layer;
|
||||
private byte[] layerDataValues;
|
||||
private Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
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)
|
||||
{
|
||||
FLog.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead.");
|
||||
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)
|
||||
{
|
||||
FLog.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]);
|
||||
}
|
||||
|
||||
log.warning(materialTokens[0]);
|
||||
|
||||
Material mat = Material.matchMaterial(materialTokens[0]);
|
||||
if (mat == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Mabe it's an integer?
|
||||
mat = Material.getMaterial(String.valueOf(materialTokens[0]));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Well, I guess it wasn't an integer after all... Awkward...
|
||||
}
|
||||
|
||||
if (mat == null)
|
||||
{
|
||||
FLog.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone.");
|
||||
mat = Material.STONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mat.isBlock())
|
||||
{
|
||||
FLog.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' is not a block. Defaulting to 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 (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 (!mat.isBlock()) {
|
||||
log.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' is not a block. Defaulting to stone.");
|
||||
mat = Material.STONE;
|
||||
}
|
||||
|
||||
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);
|
||||
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(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)
|
||||
{
|
||||
FLog.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
layerDataValues = null;
|
||||
layer = new short[65];
|
||||
layer[0] = (short) Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public short[][] generateExtBlockSections(World world, Random random, int x, int z, BiomeGrid biomes)
|
||||
{
|
||||
int maxHeight = world.getMaxHeight();
|
||||
if (layer.length > maxHeight)
|
||||
{
|
||||
FLog.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;
|
||||
materials = new Material[65];
|
||||
materials[0] = Material.BEDROCK;
|
||||
Arrays.fill(materials, 1, 65, Material.STONE);
|
||||
}
|
||||
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]);
|
||||
} else {
|
||||
materials = new Material[65];
|
||||
materials[0] = Material.BEDROCK;
|
||||
Arrays.fill(materials, 1, 65, Material.STONE);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||
{
|
||||
if (layerDataValues != null)
|
||||
{
|
||||
return Arrays.asList((BlockPopulator) new CleanroomBlockPopulator(layerDataValues));
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
|
||||
int maxHeight = world.getMaxHeight();
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the default, but just in case default populators change to stock minecraft populators by default...
|
||||
return new ArrayList<>();
|
||||
|
||||
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
|
||||
|
@ -63,6 +63,8 @@ public class Flatlands extends CustomWorld
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void wipeFlatlandsIfFlagged()
|
||||
{
|
||||
boolean doFlatlandsWipe = false;
|
||||
|
@ -37,7 +37,7 @@ public class WorldManager extends FreedomService
|
||||
protected void onStart()
|
||||
{
|
||||
// Disabled temporarily
|
||||
//flatlands.getWorld();
|
||||
flatlands.getWorld();
|
||||
//adminworld.getWorld();
|
||||
//masterBuilderWorld.getWorld();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user