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