mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2025-08-07 04:53:00 +00:00
Weekly code cleanup
This commit is contained in:
parent
ffc7a5c7b7
commit
59be72aefe
168 changed files with 5733 additions and 3829 deletions
|
@ -21,24 +21,37 @@
|
|||
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.jnbt.*;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.NBTInputStream;
|
||||
import com.intellectualcrafters.jnbt.NBTOutputStream;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
/**
|
||||
* Schematic Handler
|
||||
*
|
||||
|
@ -49,9 +62,12 @@ public class SchematicHandler {
|
|||
/**
|
||||
* Paste a schematic
|
||||
*
|
||||
* @param location origin
|
||||
* @param schematic schematic to paste
|
||||
* @param plot plot to paste in
|
||||
* @param location
|
||||
* origin
|
||||
* @param schematic
|
||||
* schematic to paste
|
||||
* @param plot
|
||||
* plot to paste in
|
||||
* @return true if succeeded
|
||||
*/
|
||||
public static boolean paste(final Location location, final Schematic schematic, final Plot plot, final int x_offset, final int z_offset) {
|
||||
|
@ -79,7 +95,8 @@ public class SchematicHandler {
|
|||
int y_offset;
|
||||
if (HEIGHT == location.getWorld().getMaxHeight()) {
|
||||
y_offset = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
y_offset = l1.getBlockY();
|
||||
}
|
||||
|
||||
|
@ -108,7 +125,8 @@ public class SchematicHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
catch (final Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -117,7 +135,8 @@ public class SchematicHandler {
|
|||
/**
|
||||
* Get a schematic
|
||||
*
|
||||
* @param name to check
|
||||
* @param name
|
||||
* to check
|
||||
* @return schematic if found, else null
|
||||
*/
|
||||
public static Schematic getSchematic(final String name) {
|
||||
|
@ -161,10 +180,12 @@ public class SchematicHandler {
|
|||
if ((index >> 1) >= addId.length) { // No corresponding
|
||||
// AddBlocks index
|
||||
blocks[index] = (short) (b[index] & 0xFF);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ((index & 1) == 0) {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF));
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +233,8 @@ public class SchematicHandler {
|
|||
// }
|
||||
// }
|
||||
schematic = new Schematic(collection, dimension, file);
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -222,8 +244,10 @@ public class SchematicHandler {
|
|||
/**
|
||||
* Saves a schematic to a file path
|
||||
*
|
||||
* @param tag to save
|
||||
* @param path to save in
|
||||
* @param tag
|
||||
* to save
|
||||
* @param path
|
||||
* to save in
|
||||
* @return true if succeeded
|
||||
*/
|
||||
public static boolean save(final CompoundTag tag, final String path) {
|
||||
|
@ -239,7 +263,8 @@ public class SchematicHandler {
|
|||
output.writeTag(tag);
|
||||
output.close();
|
||||
stream.close();
|
||||
} catch (final IOException e) {
|
||||
}
|
||||
catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -249,8 +274,10 @@ public class SchematicHandler {
|
|||
/**
|
||||
* Gets the schematic of a plot
|
||||
*
|
||||
* @param world to check
|
||||
* @param id plot
|
||||
* @param world
|
||||
* to check
|
||||
* @param id
|
||||
* plot
|
||||
* @return tag
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -279,7 +306,8 @@ public class SchematicHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
catch (final Exception e) {
|
||||
PlotMain.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16));
|
||||
return null;
|
||||
}
|
||||
|
@ -380,8 +408,8 @@ public class SchematicHandler {
|
|||
*/
|
||||
public static class Schematic {
|
||||
private final DataCollection[] blockCollection;
|
||||
private final Dimension schematicDimension;
|
||||
private final File file;
|
||||
private final Dimension schematicDimension;
|
||||
private final File file;
|
||||
|
||||
public Schematic(final DataCollection[] blockCollection, final Dimension schematicDimension, final File file) {
|
||||
this.blockCollection = blockCollection;
|
||||
|
@ -438,7 +466,7 @@ public class SchematicHandler {
|
|||
*/
|
||||
public static class DataCollection {
|
||||
private final short block;
|
||||
private final byte data;
|
||||
private final byte data;
|
||||
|
||||
// public CompoundTag tag;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue