Update for 1.4.6-R1.0.

This commit is contained in:
cnaude 2012-12-23 00:24:06 -07:00
parent 73dd820949
commit f5430b9101
5 changed files with 42 additions and 14 deletions

View File

@ -11,6 +11,7 @@
# sitting-height: Set how high you are sitting 'in' the stairs block (default is 0.7). # sitting-height: Set how high you are sitting 'in' the stairs block (default is 0.7).
# upsidedown-check: If true then prevent players from sitting on upside down stairs. # upsidedown-check: If true then prevent players from sitting on upside down stairs.
# seat-occupied-check: Check if seat is already occupied. # seat-occupied-check: Check if seat is already occupied.
# per-item-perms: Enable chairs.sit.[item] permission node. Set to false if you're sitting on every block.
# ------ # ------
allowed-blocks: allowed-blocks:
- WOOD_STAIRS - WOOD_STAIRS
@ -32,4 +33,5 @@ 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 upper-step-check: true
per-item-perms: true

View File

@ -5,8 +5,8 @@
package net.spoothie.chairs; package net.spoothie.chairs;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.server.v1_4_5.DataWatcher; import net.minecraft.server.v1_4_6.DataWatcher;
import net.minecraft.server.v1_4_5.WatchableObject; import net.minecraft.server.v1_4_6.WatchableObject;
/** /**

View File

@ -6,21 +6,23 @@ 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.v1_4_5.Packet40EntityMetadata; import net.minecraft.server.v1_4_6.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.v1_4_5.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_4_6.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
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, invertedStepCheck; public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer;
public boolean invertedStairCheck, seatOccupiedCheck, invertedStepCheck, perItemPerms;
public double sittingHeight, distance; public double sittingHeight, distance;
public int maxChairWidth; public int maxChairWidth;
private File pluginFolder; private File pluginFolder;
@ -30,6 +32,7 @@ public class Chairs extends JavaPlugin {
public static final String PLUGIN_NAME = "Chairs"; public static final String PLUGIN_NAME = "Chairs";
public static final String LOG_HEADER = "[" + PLUGIN_NAME + "]"; public static final String LOG_HEADER = "[" + PLUGIN_NAME + "]";
static final Logger log = Logger.getLogger("Minecraft"); static final Logger log = Logger.getLogger("Minecraft");
public PluginManager pm;
@Override @Override
public void onEnable() { public void onEnable() {
@ -42,6 +45,7 @@ public class Chairs extends JavaPlugin {
loadConfig(); loadConfig();
EventListener eventListener = new EventListener(this); EventListener eventListener = new EventListener(this);
getServer().getPluginManager().registerEvents(eventListener, this); getServer().getPluginManager().registerEvents(eventListener, this);
pm = this.getServer().getPluginManager();
} }
@Override @Override
@ -78,6 +82,7 @@ public class Chairs extends JavaPlugin {
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"); invertedStepCheck = getConfig().getBoolean("upper-step-check");
perItemPerms = getConfig().getBoolean("per-item-perms");
for (String type : getConfig().getStringList("allowed-blocks")) { for (String type : getConfig().getStringList("allowed-blocks")) {
try { try {
@ -116,7 +121,8 @@ public class Chairs extends JavaPlugin {
public void sendSit(Player p) { public void sendSit(Player p) {
Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) 4), false); Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) 4), false);
for (Player play : Bukkit.getOnlinePlayers()) { for (Player play : Bukkit.getOnlinePlayers()) {
((CraftPlayer) play).getHandle().netServerHandler.sendPacket(packet); ((CraftPlayer) play).getHandle().playerConnection.sendPacket(packet);
//((CraftPlayer) play).getHandle().netServerHandler.sendPacket(packet);
} }
} }
@ -139,7 +145,8 @@ public class Chairs extends JavaPlugin {
} }
Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) 0), false); Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) 0), false);
for (Player play : Bukkit.getOnlinePlayers()) { for (Player play : Bukkit.getOnlinePlayers()) {
((CraftPlayer) play).getHandle().netServerHandler.sendPacket(packet); ((CraftPlayer) play).getHandle().playerConnection.sendPacket(packet);
//((CraftPlayer) play).getHandle().netServerHandler.sendPacket(packet);
} }
} }

View File

@ -21,6 +21,7 @@ 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; import org.bukkit.material.Step;
import org.bukkit.permissions.PermissionDefault;
public class EventListener implements Listener { public class EventListener implements Listener {
@ -94,7 +95,7 @@ public class EventListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
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; Step step = null;
double sh = plugin.sittingHeight; double sh = plugin.sittingHeight;
@ -112,9 +113,23 @@ public class EventListener implements Listener {
return; return;
} }
} }
if (plugin.perItemPerms) {
if (plugin.pm.getPermission("chairs.sit." + block.getTypeId()) == null) {
plugin.pm.addPermission(new org.bukkit.permissions.Permission(
"chairs.sit." + block.getTypeId(),
"Allow players to sit on a '" + block.getType().name() + "'",
PermissionDefault.FALSE));
}
if (plugin.pm.getPermission("chairs.sit." + block.getType().toString()) == null) {
plugin.pm.addPermission(new org.bukkit.permissions.Permission(
"chairs.sit." + block.getType().toString(),
"Allow players to sit on a '" + block.getType().name() + "'",
PermissionDefault.FALSE));
}
}
if (plugin.allowedBlocks.contains(block.getType()) if (plugin.allowedBlocks.contains(block.getType())
|| player.hasPermission("chairs.sit." + block.getTypeId()) || (player.hasPermission("chairs.sit." + block.getTypeId()) && plugin.perItemPerms)
|| player.hasPermission("chairs.sit." + block.getType().toString()) ) { || (player.hasPermission("chairs.sit." + block.getType().toString())&& plugin.perItemPerms) ) {
int chairwidth = 1; int chairwidth = 1;
@ -125,7 +140,7 @@ public class EventListener implements Listener {
if (block.getRelative(BlockFace.DOWN).isEmpty()) { if (block.getRelative(BlockFace.DOWN).isEmpty()) {
return; return;
} }
if (!net.minecraft.server.v1_4_5.Block.byId[block.getTypeId()].material.isSolid()) { if (!net.minecraft.server.v1_4_6.Block.byId[block.getTypeId()].material.isSolid()) {
return; return;
} }

View File

@ -1,5 +1,5 @@
name: Chairs name: Chairs
version: 1.13.0 version: 1.13.2
description: Let players sit on blocks. description: Let players sit on blocks.
authors: authors:
- spoothie - spoothie
@ -8,4 +8,8 @@ main: net.spoothie.chairs.Chairs
commands: commands:
chairs: chairs:
description: Reloads the Chairs configuration file. description: Reloads the Chairs configuration file.
usage: /chairs reload usage: /chairs reload
permissions:
chairs.sit:
description: Allows players to sit on blocks.
default: false