Update CB 1.4.5-R1.0
Added chairs.sit.[item] perm node Added ability to use item numbers instead of item names.
This commit is contained in:
parent
7417e2cb8c
commit
73dd820949
@ -2,7 +2,7 @@
|
|||||||
# ------
|
# ------
|
||||||
# A list of all compatible block and item names: http://bit.ly/AmJgMb.
|
# A list of all compatible block and item names: http://bit.ly/AmJgMb.
|
||||||
# ------
|
# ------
|
||||||
# allowed-blocks: Set the blocks you want to be able to sit down on. Currently, only stairs-blocks are working.
|
# allowed-blocks: Set the blocks you want to be able to sit down on. Use descriptive name or item ID.
|
||||||
# auto-rotate: If set to true, you are automatically rotated to the descending face of the stairs-block when sitting down.
|
# auto-rotate: If set to true, you are automatically rotated to the descending face of the stairs-block when sitting down.
|
||||||
# sneaking: If set to true, you have to sneak to sit down on a chair.
|
# sneaking: If set to true, you have to sneak to sit down on a chair.
|
||||||
# max-chair-width: Define how many blocks a chair can be long (set to number <= 0 for unlimited width).
|
# max-chair-width: Define how many blocks a chair can be long (set to number <= 0 for unlimited width).
|
||||||
@ -32,3 +32,4 @@ permissions: true
|
|||||||
notify-player: true
|
notify-player: true
|
||||||
upside-down-check: true
|
upside-down-check: true
|
||||||
seat-occupied-check: true
|
seat-occupied-check: true
|
||||||
|
upper-step-check: true
|
@ -5,8 +5,9 @@
|
|||||||
package net.spoothie.chairs;
|
package net.spoothie.chairs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.server.DataWatcher;
|
import net.minecraft.server.v1_4_5.DataWatcher;
|
||||||
import net.minecraft.server.WatchableObject;
|
import net.minecraft.server.v1_4_5.WatchableObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -6,21 +6,21 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.minecraft.server.Packet40EntityMetadata;
|
import net.minecraft.server.v1_4_5.Packet40EntityMetadata;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_4_5.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Chairs extends JavaPlugin {
|
public class Chairs extends JavaPlugin {
|
||||||
|
|
||||||
public List<Material> allowedBlocks = new ArrayList<Material>();
|
public List<Material> allowedBlocks = new ArrayList<Material>();
|
||||||
public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer, invertedStairCheck, seatOccupiedCheck;
|
public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer, invertedStairCheck, seatOccupiedCheck, invertedStepCheck;
|
||||||
public double sittingHeight, distance;
|
public double sittingHeight, distance;
|
||||||
public int maxChairWidth;
|
public int maxChairWidth;
|
||||||
private File pluginFolder;
|
private File pluginFolder;
|
||||||
@ -33,6 +33,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
pluginFolder = getDataFolder();
|
pluginFolder = getDataFolder();
|
||||||
configFile = new File(pluginFolder, "config.yml");
|
configFile = new File(pluginFolder, "config.yml");
|
||||||
createConfig();
|
createConfig();
|
||||||
@ -76,10 +77,15 @@ public class Chairs extends JavaPlugin {
|
|||||||
notifyplayer = getConfig().getBoolean("notify-player");
|
notifyplayer = getConfig().getBoolean("notify-player");
|
||||||
invertedStairCheck = getConfig().getBoolean("upside-down-check");
|
invertedStairCheck = getConfig().getBoolean("upside-down-check");
|
||||||
seatOccupiedCheck = getConfig().getBoolean("seat-occupied-check");
|
seatOccupiedCheck = getConfig().getBoolean("seat-occupied-check");
|
||||||
|
invertedStepCheck = getConfig().getBoolean("upper-step-check");
|
||||||
|
|
||||||
for (String type : getConfig().getStringList("allowed-blocks")) {
|
for (String type : getConfig().getStringList("allowed-blocks")) {
|
||||||
try {
|
try {
|
||||||
allowedBlocks.add(Material.getMaterial(type));
|
if (type.matches("\\d+")) {
|
||||||
|
allowedBlocks.add(Material.getMaterial(Integer.parseInt(type)));
|
||||||
|
} else {
|
||||||
|
allowedBlocks.add(Material.getMaterial(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logInfo("ERROR: " + e.getMessage());
|
logInfo("ERROR: " + e.getMessage());
|
||||||
@ -144,4 +150,5 @@ public class Chairs extends JavaPlugin {
|
|||||||
public void logError(String _message) {
|
public void logError(String _message) {
|
||||||
log.log(Level.SEVERE, String.format("%s %s", LOG_HEADER, _message));
|
log.log(Level.SEVERE, String.format("%s %s", LOG_HEADER, _message));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.spoothie.chairs;
|
package net.spoothie.chairs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -19,6 +20,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.material.Stairs;
|
import org.bukkit.material.Stairs;
|
||||||
|
import org.bukkit.material.Step;
|
||||||
|
|
||||||
public class EventListener implements Listener {
|
public class EventListener implements Listener {
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ public class EventListener implements Listener {
|
|||||||
Location from = player.getLocation();
|
Location from = player.getLocation();
|
||||||
Location to = plugin.sit.get(pname);
|
Location to = plugin.sit.get(pname);
|
||||||
if (from.getWorld() == to.getWorld()) {
|
if (from.getWorld() == to.getWorld()) {
|
||||||
if (from.distance(to) > 1) {
|
if (from.distance(to) > 1.5) {
|
||||||
plugin.sendStand(player);
|
plugin.sendStand(player);
|
||||||
} else {
|
} else {
|
||||||
plugin.sendSit(player);
|
plugin.sendSit(player);
|
||||||
@ -75,12 +77,17 @@ public class EventListener implements Listener {
|
|||||||
public void onBlockDestroy(BlockBreakEvent event) {
|
public void onBlockDestroy(BlockBreakEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (!plugin.sit.isEmpty()) {
|
if (!plugin.sit.isEmpty()) {
|
||||||
|
ArrayList<String> standList = new ArrayList<String>();
|
||||||
for (String s : plugin.sit.keySet()) {
|
for (String s : plugin.sit.keySet()) {
|
||||||
if (plugin.sit.get(s).equals(block.getLocation())) {
|
if (plugin.sit.get(s).equals(block.getLocation())) {
|
||||||
Player player = Bukkit.getPlayer(s);
|
standList.add(s);
|
||||||
plugin.sendStand(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (String s : standList) {
|
||||||
|
Player player = Bukkit.getPlayer(s);
|
||||||
|
plugin.sendStand(player);
|
||||||
|
}
|
||||||
|
standList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,36 +96,40 @@ public class EventListener implements Listener {
|
|||||||
if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Stairs stairs = null;
|
Stairs stairs = null;
|
||||||
|
Step step = null;
|
||||||
|
double sh = plugin.sittingHeight;
|
||||||
if (block.getState().getData() instanceof Stairs) {
|
if (block.getState().getData() instanceof Stairs) {
|
||||||
stairs = (Stairs) block.getState().getData();
|
stairs = (Stairs) block.getState().getData();
|
||||||
|
} else if (block.getState().getData() instanceof Step) {
|
||||||
|
step = (Step) block.getState().getData();
|
||||||
|
} else {
|
||||||
|
sh += 1.0;
|
||||||
}
|
}
|
||||||
if (plugin.allowedBlocks.contains(block.getType())) {
|
Player player = event.getPlayer();
|
||||||
Player player = event.getPlayer();
|
// Permissions Check
|
||||||
|
if (plugin.permissions) {
|
||||||
|
if (!player.hasPermission("chairs.sit")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plugin.allowedBlocks.contains(block.getType())
|
||||||
|
|| player.hasPermission("chairs.sit." + block.getTypeId())
|
||||||
|
|| player.hasPermission("chairs.sit." + block.getType().toString()) ) {
|
||||||
|
|
||||||
int chairwidth = 1;
|
int chairwidth = 1;
|
||||||
|
|
||||||
// Check if block beneath chair is solid.
|
// Check if block beneath chair is solid.
|
||||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR) {
|
if (block.getRelative(BlockFace.DOWN).isLiquid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.WATER) {
|
if (block.getRelative(BlockFace.DOWN).isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) {
|
if (!net.minecraft.server.v1_4_5.Block.byId[block.getTypeId()].material.isSolid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!net.minecraft.server.Block.byId[block.getTypeId()].material.isSolid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Permissions Check
|
|
||||||
if (plugin.permissions) {
|
|
||||||
if (!player.hasPermission("chairs.sit")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if player is sitting.
|
// Check if player is sitting.
|
||||||
|
|
||||||
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
||||||
plugin.sit.remove(player.getName());
|
plugin.sit.remove(player.getName());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -139,6 +150,11 @@ public class EventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (step != null) {
|
||||||
|
if (step.isInverted() && plugin.invertedStepCheck) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for signs.
|
// Check for signs.
|
||||||
if (plugin.signCheck == true && stairs != null) {
|
if (plugin.signCheck == true && stairs != null) {
|
||||||
@ -193,7 +209,7 @@ public class EventListener implements Listener {
|
|||||||
// Rotate the player's view to the descending side of the block.
|
// Rotate the player's view to the descending side of the block.
|
||||||
if (plugin.autoRotate && stairs != null) {
|
if (plugin.autoRotate && stairs != null) {
|
||||||
Location plocation = block.getLocation().clone();
|
Location plocation = block.getLocation().clone();
|
||||||
plocation.add(0.5D, (plugin.sittingHeight - 0.5), 0.5D);
|
plocation.add(0.5D, (sh - 0.5D), 0.5D);
|
||||||
switch (stairs.getDescendingDirection()) {
|
switch (stairs.getDescendingDirection()) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
plocation.setYaw(90);
|
plocation.setYaw(90);
|
||||||
@ -207,11 +223,11 @@ public class EventListener implements Listener {
|
|||||||
case WEST:
|
case WEST:
|
||||||
plocation.setYaw(0);
|
plocation.setYaw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.teleport(plocation);
|
player.teleport(plocation);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.teleport(block.getLocation().add(0.5D, 0.0D, 0.5D));
|
Location plocation = block.getLocation().clone();
|
||||||
|
plocation.setYaw(player.getLocation().getYaw());
|
||||||
|
player.teleport(plocation.add(0.5D, (sh - 0.5D), 0.5D));
|
||||||
}
|
}
|
||||||
player.setSneaking(true);
|
player.setSneaking(true);
|
||||||
if (plugin.notifyplayer) {
|
if (plugin.notifyplayer) {
|
||||||
@ -223,7 +239,6 @@ public class EventListener implements Listener {
|
|||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
long delay = 1 * 2000;
|
long delay = 1 * 2000;
|
||||||
timer.schedule(new sendSitTask(), delay);
|
timer.schedule(new sendSitTask(), delay);
|
||||||
//plugin.sendSit(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: Chairs
|
name: Chairs
|
||||||
version: 1.10.1
|
version: 1.13.0
|
||||||
description: Let players sit on blocks.
|
description: Let players sit on blocks.
|
||||||
authors:
|
authors:
|
||||||
- spoothie
|
- spoothie
|
||||||
|
Loading…
Reference in New Issue
Block a user