Only check damage values for non stairs.

This commit is contained in:
cnaude 2013-07-10 22:57:22 -07:00
parent c3e86c67d8
commit 2cb04a92f8
4 changed files with 17 additions and 20 deletions

View File

@ -42,7 +42,7 @@ public class ChairEffects {
double pHealthPcnt = (double) p.getHealth() / (double) p.getMaxHealth() * 100d; double pHealthPcnt = (double) p.getHealth() / (double) p.getMaxHealth() * 100d;
if ((pHealthPcnt < plugin.sitMaxHealth) if ((pHealthPcnt < plugin.sitMaxHealth)
&& (p.getHealth() < p.getMaxHealth())) { && (p.getHealth() < p.getMaxHealth())) {
int newHealth = plugin.sitHealthPerInterval + p.getHealth(); double newHealth = plugin.sitHealthPerInterval + p.getHealth();
if (newHealth > p.getMaxHealth()) { if (newHealth > p.getMaxHealth()) {
newHealth = p.getMaxHealth(); newHealth = p.getMaxHealth();
} }

View File

@ -5,8 +5,8 @@
package com.cnaude.chairs; package com.cnaude.chairs;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.server.v1_5_R3.DataWatcher; import net.minecraft.server.v1_6_R2.DataWatcher;
import net.minecraft.server.v1_5_R3.WatchableObject; import net.minecraft.server.v1_6_R2.WatchableObject;
/** /**
* *
@ -23,8 +23,7 @@ public class ChairWatcher extends DataWatcher {
@Override @Override
public ArrayList<WatchableObject> b() { public ArrayList<WatchableObject> b() {
ArrayList<WatchableObject> list = new ArrayList<WatchableObject>(); ArrayList<WatchableObject> list = new ArrayList<WatchableObject>();
WatchableObject wo = new WatchableObject(0, 0, Byte.valueOf(this.metadata)); WatchableObject wo = new WatchableObject(0, 0, this.metadata);
//WatchableObject wo = new WatchableObject(0, 0, 4);
list.add(wo); list.add(wo);
return list; return list;
} }

View File

@ -10,12 +10,11 @@ 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_5_R3.Packet40EntityMetadata; import net.minecraft.server.v1_6_R2.Packet40EntityMetadata;
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.craftbukkit.v1_5_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
@ -38,8 +37,7 @@ public class Chairs extends JavaPlugin {
public int sitEffectInterval; public int sitEffectInterval;
private File pluginFolder; private File pluginFolder;
private File configFile; private File configFile;
public byte metadata; public byte sitByte;
public int packet;
public HashMap<String, Location> sit = new HashMap<String, Location>(); public HashMap<String, Location> sit = new HashMap<String, Location>();
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 + "]";
@ -121,8 +119,8 @@ public class Chairs extends JavaPlugin {
} }
public void loadConfig() { public void loadConfig() {
packet = getConfig().getInt("packet"); sitByte = Byte.parseByte(getConfig().getString("packet"));
logInfo("Sitting packet byte: " + packet); logInfo("Sitting packet byte: " + sitByte);
autoRotate = getConfig().getBoolean("auto-rotate"); autoRotate = getConfig().getBoolean("auto-rotate");
sneaking = getConfig().getBoolean("sneaking"); sneaking = getConfig().getBoolean("sneaking");
signCheck = getConfig().getBoolean("sign-check"); signCheck = getConfig().getBoolean("sign-check");
@ -228,7 +226,7 @@ public class Chairs extends JavaPlugin {
PacketContainer fakeSit = protocolManager.createPacket(40); PacketContainer fakeSit = protocolManager.createPacket(40);
fakeSit.getSpecificModifier(int.class).write(0, p.getEntityId()); fakeSit.getSpecificModifier(int.class).write(0, p.getEntityId());
WrappedDataWatcher watcher = new WrappedDataWatcher(); WrappedDataWatcher watcher = new WrappedDataWatcher();
watcher.setObject(0, (byte)packet); watcher.setObject(0, sitByte);
fakeSit.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); fakeSit.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
return fakeSit; return fakeSit;
} }
@ -247,12 +245,12 @@ public class Chairs extends JavaPlugin {
if (protocolManager != null) { if (protocolManager != null) {
sendPacketToPlayers(getSitPacket(p),p); sendPacketToPlayers(getSitPacket(p),p);
} else { } else {
sendPacketToPlayers(new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) packet), false),p); sendPacketToPlayers(new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher(sitByte), true),p);
} }
} }
private void sendPacketToPlayers(PacketContainer pc, Player p) { private void sendPacketToPlayers(PacketContainer pc, Player p) {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { for (Player onlinePlayer : getServer().getOnlinePlayers()) {
if (onlinePlayer.canSee(p)) { if (onlinePlayer.canSee(p)) {
if (onlinePlayer.getWorld().equals(p.getWorld())) { if (onlinePlayer.getWorld().equals(p.getWorld())) {
try { try {
@ -266,7 +264,7 @@ public class Chairs extends JavaPlugin {
} }
private void sendPacketToPlayers(Packet40EntityMetadata packet, Player p) { private void sendPacketToPlayers(Packet40EntityMetadata packet, Player p) {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { for (Player onlinePlayer : getServer().getOnlinePlayers()) {
if (onlinePlayer.canSee(p)) { if (onlinePlayer.canSee(p)) {
if (onlinePlayer.getWorld().equals(p.getWorld())) { if (onlinePlayer.getWorld().equals(p.getWorld())) {
try { try {
@ -281,7 +279,7 @@ public class Chairs extends JavaPlugin {
public void sendSit() { public void sendSit() {
for (String s : sit.keySet()) { for (String s : sit.keySet()) {
Player p = Bukkit.getPlayer(s); Player p = getServer().getPlayer(s);
if (p != null) { if (p != null) {
sendSit(p); sendSit(p);
} }
@ -299,7 +297,7 @@ public class Chairs extends JavaPlugin {
if (protocolManager != null) { if (protocolManager != null) {
sendPacketToPlayers(getStandPacket(p),p); sendPacketToPlayers(getStandPacket(p),p);
} else { } else {
Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) 0), false); Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte)0), false);
sendPacketToPlayers(packet,p); sendPacketToPlayers(packet,p);
} }
} }

View File

@ -1,5 +1,5 @@
name: Chairs name: Chairs
version: 2.1.4c version: 2.1.6-SNAPSHOT1
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: