Fix issues with wooden steps.
Add option to select blocks by data value.
This commit is contained in:
parent
0c36d138b9
commit
2566addf8d
@ -13,10 +13,12 @@ import org.bukkit.Material;
|
||||
public class ChairBlock {
|
||||
private Material mat;
|
||||
private double sitHeight;
|
||||
private byte data;
|
||||
|
||||
public ChairBlock(Material m, double d) {
|
||||
public ChairBlock(Material m, double s, String d) {
|
||||
mat = m;
|
||||
sitHeight = d;
|
||||
sitHeight = s;
|
||||
data = Byte.parseByte(d);
|
||||
}
|
||||
|
||||
public Material getMat() {
|
||||
@ -26,4 +28,8 @@ public class ChairBlock {
|
||||
public double getSitHeight() {
|
||||
return sitHeight;
|
||||
}
|
||||
|
||||
public byte getDamage() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
@ -152,10 +152,16 @@ public class Chairs extends JavaPlugin {
|
||||
for (String s : getConfig().getStringList("allowed-blocks")) {
|
||||
String type;
|
||||
double sh = sittingHeight;
|
||||
String d = "0";
|
||||
if (s.contains(":")) {
|
||||
String tmp[] = s.split(":",2);
|
||||
String tmp[] = s.split(":",3);
|
||||
type = tmp[0];
|
||||
sh = Double.parseDouble(tmp[1]);
|
||||
if (!tmp[1].isEmpty()) {
|
||||
sh = Double.parseDouble(tmp[1]);
|
||||
}
|
||||
if (tmp.length == 3) {
|
||||
d = tmp[2];
|
||||
}
|
||||
} else {
|
||||
type = s;
|
||||
}
|
||||
@ -167,8 +173,8 @@ public class Chairs extends JavaPlugin {
|
||||
mat = Material.matchMaterial(type);
|
||||
}
|
||||
if (mat != null) {
|
||||
logInfo("Allowed block: " + mat.toString() + " => " + sh);
|
||||
allowedBlocks.add(new ChairBlock(mat,sh));
|
||||
logInfo("Allowed block: " + mat.toString() + " => " + sh + " => " + d);
|
||||
allowedBlocks.add(new ChairBlock(mat,sh,d));
|
||||
} else {
|
||||
logError("Invalid block: " + type);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.material.Stairs;
|
||||
import org.bukkit.material.Step;
|
||||
import org.bukkit.material.WoodenStep;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
@ -122,6 +123,7 @@ public class EventListener implements Listener {
|
||||
Block block = event.getClickedBlock();
|
||||
Stairs stairs = null;
|
||||
Step step = null;
|
||||
WoodenStep wStep = null;
|
||||
double sh = plugin.sittingHeight;
|
||||
boolean blockOkay = false;
|
||||
|
||||
@ -149,21 +151,33 @@ public class EventListener implements Listener {
|
||||
}
|
||||
|
||||
for (ChairBlock cb : plugin.allowedBlocks) {
|
||||
if (cb.getMat().equals(block.getType())) {
|
||||
//plugin.logInfo("Comparing: (" + cb.getMat().name() + " ? " + block.getType().name() + ") ("
|
||||
// + cb.getDamage() + " ? " + block.getData() + ")");
|
||||
if (cb.getMat().equals(block.getType())
|
||||
&& cb.getDamage() == block.getData()) {
|
||||
blockOkay = true;
|
||||
sh = cb.getSitHeight();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (blockOkay
|
||||
|| (player.hasPermission("chairs.sit." + block.getTypeId() + ":" + block.getData()) && plugin.perItemPerms)
|
||||
|| (player.hasPermission("chairs.sit." + block.getType().toString() + ":" + block.getData()) && plugin.perItemPerms)
|
||||
|| (player.hasPermission("chairs.sit." + block.getTypeId()) && plugin.perItemPerms)
|
||||
|| (player.hasPermission("chairs.sit." + block.getType().toString()) && plugin.perItemPerms)) {
|
||||
|
||||
if (block.getState().getData() instanceof Stairs) {
|
||||
stairs = (Stairs) block.getState().getData();
|
||||
//plugin.logInfo("STAIR");
|
||||
} else if (block.getState().getData() instanceof Step) {
|
||||
step = (Step) block.getState().getData();
|
||||
//plugin.logInfo("STEP");
|
||||
} else if (block.getState().getData() instanceof WoodenStep) {
|
||||
wStep = (WoodenStep) block.getState().getData();
|
||||
//plugin.logInfo("WOODEN_STEP");
|
||||
} else {
|
||||
sh += plugin.sittingHeightAdj;
|
||||
//plugin.logInfo("OTHER");
|
||||
}
|
||||
|
||||
int chairwidth = 1;
|
||||
@ -205,6 +219,11 @@ public class EventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (wStep != null) {
|
||||
if (wStep.isInverted() && plugin.invertedStepCheck) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for signs.
|
||||
if (plugin.signCheck == true && stairs != null) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: Chairs
|
||||
version: 2.1.2
|
||||
version: 2.1.3
|
||||
description: Let players sit on blocks.
|
||||
website: http://dev.bukkit.org/bukkit-plugins/chairsreloaded/
|
||||
authors:
|
||||
|
Loading…
Reference in New Issue
Block a user