kept players yaw and pitch while walking through a gate; saving of actual gate size (preventing resizing of gates after creation); all credit goes to s1m0ne
This commit is contained in:
parent
4a6b5902e3
commit
ccc9a27917
@ -21,7 +21,7 @@ public class Conf {
|
||||
public static ChatColor colorCommand = ChatColor.AQUA;
|
||||
public static ChatColor colorParameter = ChatColor.DARK_AQUA;
|
||||
|
||||
private static double gateSearchRadius = 7.0;
|
||||
private static double gateSearchRadius = 10.0;
|
||||
|
||||
static {
|
||||
|
||||
@ -32,7 +32,7 @@ public class Conf {
|
||||
}
|
||||
|
||||
public static int getGateMaxArea() {
|
||||
return (int)gateSearchRadius*10;
|
||||
return (int)gateSearchRadius * 7;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -2,7 +2,9 @@ package org.mcteam.ancientgates;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Map;
|
||||
@ -12,7 +14,9 @@ import java.util.TreeMap;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import org.mcteam.ancientgates.gson.reflect.TypeToken;
|
||||
|
||||
import org.mcteam.ancientgates.util.DiscUtil;
|
||||
import org.mcteam.ancientgates.util.FloodUtil;
|
||||
|
||||
@ -25,6 +29,8 @@ public class Gate {
|
||||
private Location from;
|
||||
private Location to;
|
||||
|
||||
private Integer[][] gateBlocks;
|
||||
|
||||
public Gate() {
|
||||
|
||||
}
|
||||
@ -57,6 +63,27 @@ public class Gate {
|
||||
return to;
|
||||
}
|
||||
|
||||
public Integer[][] getGateBlocks() {
|
||||
return gateBlocks;
|
||||
}
|
||||
|
||||
public void setGateBlocks(Set<Block> gateBlocks) {
|
||||
if (gateBlocks == null)
|
||||
return;
|
||||
|
||||
this.gateBlocks = new Integer[gateBlocks.size()][3];
|
||||
|
||||
int blockcount = 0;
|
||||
for (Block b: gateBlocks) {
|
||||
if (b != null) {
|
||||
this.gateBlocks[blockcount][0] = b.getX();
|
||||
this.gateBlocks[blockcount][1] = b.getY();
|
||||
this.gateBlocks[blockcount][2] = b.getZ();
|
||||
}
|
||||
blockcount++;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// The Open And Close Methods
|
||||
//----------------------------------------------//
|
||||
@ -68,6 +95,8 @@ public class Gate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Uncomment lines below to have the old Portal open functionality back.
|
||||
|
||||
// This is not to do an effect
|
||||
// It is to stop portalblocks from destroyingthemself as they cant rely on non created blocks :P
|
||||
for (Block block : blocks) {
|
||||
@ -84,6 +113,7 @@ public class Gate {
|
||||
public void close() {
|
||||
Set<Block> blocks = FloodUtil.getGateFrameBlocks(from.getBlock());
|
||||
|
||||
// Uncomment lines below to have the old Portal open functionality back.
|
||||
for (Block block : blocks) {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import java.lang.reflect.Type;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
import org.mcteam.ancientgates.gson.JsonDeserializationContext;
|
||||
import org.mcteam.ancientgates.gson.JsonDeserializer;
|
||||
import org.mcteam.ancientgates.gson.JsonElement;
|
||||
@ -62,9 +63,10 @@ public class MyLocationTypeAdapter implements JsonDeserializer<Location>, JsonSe
|
||||
|
||||
private World getWorld(String name) {
|
||||
World world = Plugin.instance.getServer().getWorld(name);
|
||||
if (world == null) {
|
||||
world = Plugin.instance.getServer().createWorld(name, Environment.NORMAL);
|
||||
}
|
||||
|
||||
if (world == null)
|
||||
world = Plugin.instance.getServer().createWorld(new WorldCreator(name));
|
||||
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package org.mcteam.ancientgates.commands;
|
||||
|
||||
import java.util.Set;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.mcteam.ancientgates.Conf;
|
||||
import org.mcteam.ancientgates.Gate;
|
||||
import org.mcteam.ancientgates.util.FloodUtil;
|
||||
|
||||
public class CommandSetFrom extends BaseCommand {
|
||||
|
||||
@ -19,20 +23,35 @@ public class CommandSetFrom extends BaseCommand {
|
||||
// The player might stand in a halfblock or a sign or whatever
|
||||
// Therefore we load som extra locations and blocks
|
||||
Block playerBlock = player.getLocation().getBlock();
|
||||
Block upBlock = playerBlock.getFace(BlockFace.UP);
|
||||
Block upBlock = playerBlock.getRelative(BlockFace.UP);
|
||||
Location playerUpLocation = new Location(player.getLocation().getWorld(),
|
||||
player.getLocation().getX(),
|
||||
player.getLocation().getY() + 1,
|
||||
player.getLocation().getZ(),
|
||||
player.getLocation().getYaw(),
|
||||
player.getLocation().getPitch());
|
||||
|
||||
Set<Block> gateBlocks = FloodUtil.getGateFrameBlocks(player.getLocation().getBlock());
|
||||
if (gateBlocks == null) {
|
||||
sendMessage("There is no portal here, or your portal is too large.\nMax size is: " + Conf.getGateMaxArea() + " Blocks.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerBlock.getType() == Material.AIR) {
|
||||
gate.setFrom(playerBlock.getLocation());
|
||||
gate.setFrom(player.getLocation());
|
||||
gate.setGateBlocks(gateBlocks);
|
||||
} else if (upBlock.getType() == Material.AIR) {
|
||||
gate.setFrom(upBlock.getLocation());
|
||||
gate.setFrom(playerUpLocation);
|
||||
gate.setGateBlocks(gateBlocks);
|
||||
} else {
|
||||
sendMessage("There is not enough room for a gate to open here");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand.");
|
||||
sendMessage("Build a frame around that block and:");
|
||||
sendMessage(new CommandOpen().getUseageTemplate(true, true));
|
||||
sendMessage("Your gate includes " + gateBlocks.size() + " Blocks.");
|
||||
|
||||
Gate.save();
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ public class FloodUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
//System.out.println("limit: " + limit);
|
||||
if (foundBlocks.size() > limit) {
|
||||
System.out.println("Exceeding gate size limit.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -68,11 +70,13 @@ public class FloodUtil {
|
||||
|
||||
// ... And flood away !
|
||||
for (BlockFace face : expandFaces) {
|
||||
Block potentialBlock = startBlock.getFace(face);
|
||||
Block potentialBlock = startBlock.getRelative(face);
|
||||
foundBlocks = getAirFloodBlocks(potentialBlock, foundBlocks, expandFaces, limit);
|
||||
}
|
||||
}
|
||||
|
||||
if (foundBlocks != null) {
|
||||
//System.out.println("size: " + foundBlocks.size());
|
||||
}
|
||||
return foundBlocks;
|
||||
}
|
||||
|
||||
|
7
src/plugin.yml
Normal file
7
src/plugin.yml
Normal file
@ -0,0 +1,7 @@
|
||||
name: AncientGates
|
||||
version: 1.0.1
|
||||
main: org.mcteam.ancientgates.Plugin
|
||||
commands:
|
||||
gate:
|
||||
description: All of the AncientGates commands
|
||||
usage: See documentation.
|
Loading…
x
Reference in New Issue
Block a user