Fix schematic material id bug, add new schematics from build team, fix field ore bug, make /gear admin+, enable server join for staff ranks, remove annoying log spam from VisibilityManager

This commit is contained in:
Shaun Bennett 2015-07-13 19:11:17 -05:00
parent a9e68ff777
commit dc1fe5fc2c
14 changed files with 52 additions and 14 deletions

View File

@ -9,10 +9,10 @@ public class Schematic
private final short _width;
private final short _height;
private final short _length;
private final byte[] _blocks;
private final short[] _blocks;
private final byte[] _blockData;
public Schematic(short width, short height, short length, byte[] blocks, byte[] blockData)
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData)
{
_width = width;
_height = height;
@ -61,7 +61,7 @@ public class Schematic
return y * _width * _length + z * _width + x;
}
public byte getBlock(int x, int y, int z)
public short getBlock(int x, int y, int z)
{
return _blocks[getIndex(x, y, z)];
}
@ -86,7 +86,7 @@ public class Schematic
return _length;
}
public byte[] getBlocks()
public short[] getBlocks()
{
return _blocks;
}

View File

@ -98,7 +98,7 @@ public class SchematicRunnable implements Runnable
private void setBlock(Block block, int x, int y, int z)
{
int materialId = Math.abs(_schematic.getBlock(x, y, z));
int materialId = _schematic.getBlock(x, y, z);
byte data = _schematic.getData(x, y, z);
Material material = Material.getMaterial(materialId);

View File

@ -32,9 +32,30 @@ public class UtilSchematic
short width = getChildTag(schematic, "Width", ShortTag.class).getValue();
short height = getChildTag(schematic, "Height", ShortTag.class).getValue();
short length = getChildTag(schematic, "Length", ShortTag.class).getValue();
byte[] blocks = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
byte[] blockId = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
byte[] addId = new byte[0];
short[] blocks = new short[blockId.length];
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
if (schematic.containsKey("AddBlocks"))
{
addId = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
}
for (int index = 0; index < blockId.length; index++)
{
if ((index >> 1) >= addId.length)
blocks[index] = (short) (blockId[index] & 0xFF);
else
{
if ((index & 1) == 0)
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (blockId[index] & 0xFF));
else
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF));
}
}
return new Schematic(width, height, length, blocks, blockData);
}

View File

@ -21,7 +21,7 @@ public class BlockRestoreMap
protected BlockRestoreMap(BlockRestore blockRestore)
{
this(blockRestore, 200);
this(blockRestore, 50);
}
protected BlockRestoreMap(BlockRestore blockRestore, int blocksPerTick)

View File

@ -97,7 +97,6 @@ public class VisibilityManager extends MiniPlugin
if (event.getType() != UpdateType.MIN_01)
return;
System.out.println(" ");
TimingManager.endTotal("VisMan update", true);
TimingManager.endTotal("VisMan setVis", true);
TimingManager.endTotal("VisData attemptToProcess", true);
@ -106,6 +105,5 @@ public class VisibilityManager extends MiniPlugin
TimingManager.endTotal("VisData attemptToProcessUpdate lastState", true);
TimingManager.endTotal("Hide Player", true);
TimingManager.endTotal("Show Player", true);
System.out.println(" ");
}
}

View File

@ -121,6 +121,8 @@ public class Clans extends JavaPlugin
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
getServer().setWhitelist(false); // TODO: remove
}
public static String prettifyName(Material material)

View File

@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -20,6 +21,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
@ -606,4 +608,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_blockRestore.onDisable();
_worldEvent.onDisable();
}
@EventHandler
public void onJoin(PlayerLoginEvent event)
{
Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
if (!rank.Has(Rank.HELPER) && !event.getPlayer().isWhitelisted())
{
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.setKickMessage("Only Trainee+ can join this server");
}
}
}

View File

@ -248,6 +248,9 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
@EventHandler
public void gear(PlayerCommandPreprocessEvent event)
{
if (!event.getPlayer().isOp())
return;
// TODO: Remove
if (event.getMessage().equalsIgnoreCase("/dgear"))
{

View File

@ -220,6 +220,7 @@ public abstract class WorldEvent implements Listener
}
});
task.setBlocksPerTick(100);
task.start();
}

View File

@ -28,7 +28,7 @@ public class KingHill extends WorldEvent
// TODO load hills from schematic folder with extra hill data from a config file?
try
{
LOADED_HILLS.add(new HillData("hill.schematic", 28, 28, 28, 5, 5, 5));
LOADED_HILLS.add(new HillData("ClansKOTHFinal.schematic", 28, 28, 28, 5, 5, 5));
}
catch (IOException e)
{

View File

@ -29,7 +29,7 @@ public class SlimeBoss extends WorldEvent
try
{
schematic = UtilSchematic.loadSchematic(new File("schematic/PhiSlimeArena.schematic"));
schematic = UtilSchematic.loadSchematic(new File("schematic/ClansSlimeFinal.schematic"));
}
catch (IOException e)
{

View File

@ -207,7 +207,7 @@ public class FieldBlock extends MiniPlugin
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void BlockBreak(BlockBreakEvent event)
{
if (ClansManager.isFields(event.getBlock().getLocation()))

View File

@ -204,7 +204,7 @@ public class FieldOre extends MiniPlugin
if (!_oreLocations.contains(event.getBlock().getLocation()))
return;
FieldOreData ore = Get(event.getBlock().getLocation());
if (ore == null)

View File

@ -42,7 +42,7 @@ public class GearCommand extends CommandBase<GearManager>
public GearCommand(GearManager plugin)
{
super(plugin, Rank.ALL, "gear", "custom-gear");
super(plugin, Rank.ADMIN, "gear", "custom-gear");
_gearManager = plugin;
}