Clean up and reformat source
This commit is contained in:
parent
ff38ead562
commit
9d231ca8b8
@ -29,7 +29,7 @@ public class ChairsCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (sender.hasPermission("chairs.reload") || !(sender instanceof Player)) {
|
||||
plugin.loadConfig();
|
||||
@ -81,5 +81,5 @@ public class ChairsCommand implements CommandExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,12 @@
|
||||
*/
|
||||
package com.cnaude.chairs.commands;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.cnaude.chairs.core.Chairs;
|
||||
@ -17,35 +22,35 @@ import com.cnaude.chairs.core.Chairs;
|
||||
public class ChairsIgnoreList implements Serializable{
|
||||
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
||||
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
||||
|
||||
|
||||
private Chairs plugin;
|
||||
public ChairsIgnoreList(Chairs plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load() {
|
||||
public void load() {
|
||||
File file = new File(IGNORE_FILE);
|
||||
if (!file.exists()) {
|
||||
plugin.logInfo("Ignore file '"+file.getAbsolutePath()+"' does not exist.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
try {
|
||||
FileInputStream f_in = new FileInputStream(file);
|
||||
ObjectInputStream obj_in = new ObjectInputStream (f_in);
|
||||
ignoreList = (ArrayList<String>) obj_in.readObject();
|
||||
obj_in.close();
|
||||
obj_in.close();
|
||||
plugin.logInfo("Loaded ignore list. (Count = "+ignoreList.size()+")");
|
||||
}
|
||||
catch(Exception e) {
|
||||
plugin.logError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
File file = new File(IGNORE_FILE);
|
||||
File file = new File(IGNORE_FILE);
|
||||
FileOutputStream f_out = new FileOutputStream (file);
|
||||
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
|
||||
obj_out.writeObject (ignoreList);
|
||||
@ -56,7 +61,7 @@ public class ChairsIgnoreList implements Serializable{
|
||||
plugin.logError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addPlayer(String s) {
|
||||
if (ignoreList.contains(s)) {
|
||||
return;
|
||||
@ -64,12 +69,12 @@ public class ChairsIgnoreList implements Serializable{
|
||||
//Chairs.get().logInfo("Adding " + s + " to ignore list.");
|
||||
ignoreList.add(s);
|
||||
}
|
||||
|
||||
|
||||
public void removePlayer(String s) {
|
||||
//Chairs.get().logInfo("Removing " + s + " from ignore list.");
|
||||
ignoreList.remove(s);
|
||||
}
|
||||
|
||||
|
||||
public boolean isIgnored(String s) {
|
||||
if (ignoreList.contains(s)) {
|
||||
return true;
|
||||
|
@ -13,16 +13,16 @@ import org.bukkit.Material;
|
||||
public class ChairBlock {
|
||||
private Material mat;
|
||||
private double sitHeight;
|
||||
|
||||
|
||||
public ChairBlock(Material m, double s) {
|
||||
mat = m;
|
||||
sitHeight = s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Material getMat() {
|
||||
return mat;
|
||||
}
|
||||
|
||||
|
||||
public double getSitHeight() {
|
||||
return sitHeight;
|
||||
}
|
||||
|
@ -44,16 +44,16 @@ public class Chairs extends JavaPlugin {
|
||||
public boolean sitDisableAllCommands = false;
|
||||
public HashSet<String> sitDisabledCommands = new HashSet<String>();
|
||||
private Logger log;
|
||||
public ChairsIgnoreList ignoreList;
|
||||
public ChairsIgnoreList ignoreList;
|
||||
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled, msgCommandRestricted;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private PlayerSitData psitdata;
|
||||
public PlayerSitData getPlayerSitData()
|
||||
{
|
||||
return psitdata;
|
||||
}
|
||||
}
|
||||
private Class<?> vehiclearrowclass;
|
||||
protected Class<?> getVehicleArrowClass()
|
||||
{
|
||||
@ -61,10 +61,10 @@ public class Chairs extends JavaPlugin {
|
||||
}
|
||||
|
||||
GetVehicleArrowClass genvehiclearrow = new GetVehicleArrowClass();
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
log = this.getLogger();
|
||||
log = this.getLogger();
|
||||
//load vehiclearrowclass
|
||||
try {
|
||||
World world = getServer().getWorlds().get(0);
|
||||
@ -104,7 +104,7 @@ public class Chairs extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
if (psitdata.isSitting(player)) {
|
||||
psitdata.unSitPlayer(player, false, true);
|
||||
}
|
||||
@ -120,7 +120,7 @@ public class Chairs extends JavaPlugin {
|
||||
vehiclearrowclass = null;
|
||||
psitdata = null;
|
||||
}
|
||||
|
||||
|
||||
public void loadConfig() {
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(),"config.yml"));
|
||||
autoRotate = config.getBoolean("auto-rotate");
|
||||
@ -129,19 +129,19 @@ public class Chairs extends JavaPlugin {
|
||||
maxChairWidth = config.getInt("max-chair-width");
|
||||
notifyplayer = config.getBoolean("notify-player");
|
||||
ignoreIfBlockInHand = config.getBoolean("ignore-if-item-in-hand");
|
||||
|
||||
|
||||
disabledRegions = new HashSet<String>(config.getStringList("disabledWGRegions"));
|
||||
|
||||
|
||||
sitHealEnabled = config.getBoolean("sit-effects.healing.enabled", false);
|
||||
sitHealInterval = config.getInt("sit-effects.healing.interval",20);
|
||||
sitMaxHealth = config.getInt("sit-effects.healing.max-percent",100);
|
||||
sitHealthPerInterval = config.getInt("sit-effects.healing.amount",1);
|
||||
|
||||
|
||||
sitPickupEnabled = config.getBoolean("sit-effects.itempickup.enabled", false);
|
||||
|
||||
|
||||
sitDisableAllCommands = config.getBoolean("sit-restrictions.commands.all");
|
||||
sitDisabledCommands = new HashSet<String>(config.getStringList("sit-restrictions.commands.list"));
|
||||
|
||||
|
||||
msgSitting = ChatColor.translateAlternateColorCodes('&',config.getString("messages.sitting"));
|
||||
msgStanding = ChatColor.translateAlternateColorCodes('&',config.getString("messages.standing"));
|
||||
msgOccupied = ChatColor.translateAlternateColorCodes('&',config.getString("messages.occupied"));
|
||||
@ -156,21 +156,21 @@ public class Chairs extends JavaPlugin {
|
||||
String type;
|
||||
double sh = 0.7;
|
||||
String tmp[] = s.split("[:]");
|
||||
type = tmp[0];
|
||||
type = tmp[0];
|
||||
if (tmp.length == 2) {
|
||||
sh = Double.parseDouble(tmp[1]);
|
||||
}
|
||||
}
|
||||
Material mat = Material.matchMaterial(type);
|
||||
if (mat != null) {
|
||||
if (mat != null) {
|
||||
logInfo("Allowed block: " + mat.toString() + " => " + sh);
|
||||
allowedBlocks.add(new ChairBlock(mat,sh));
|
||||
} else {
|
||||
logError("Invalid block: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
validSigns = new ArrayList<Material>();
|
||||
for (String type : config.getStringList("valid-signs")) {
|
||||
|
||||
validSigns = new ArrayList<Material>();
|
||||
for (String type : config.getStringList("valid-signs")) {
|
||||
try {
|
||||
validSigns.add(Material.matchMaterial(type));
|
||||
}
|
||||
@ -178,8 +178,8 @@ public class Chairs extends JavaPlugin {
|
||||
logError(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void logInfo(String _message) {
|
||||
log.log(Level.INFO, _message);
|
||||
}
|
||||
@ -187,5 +187,5 @@ public class Chairs extends JavaPlugin {
|
||||
public void logError(String _message) {
|
||||
log.log(Level.SEVERE, _message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,40 +19,32 @@ public class PlayerSitData {
|
||||
public PlayerSitData(Chairs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, Entity> sit = new HashMap<String, Entity>();
|
||||
private HashMap<Block, String> sitblock = new HashMap<Block, String>();
|
||||
private HashMap<String, Block> sitblockbr = new HashMap<String, Block>();
|
||||
private HashMap<String, Location> sitstopteleportloc = new HashMap<String, Location>();
|
||||
private HashMap<String, Integer> sittask = new HashMap<String, Integer>();
|
||||
public boolean isSitting(Player player)
|
||||
{
|
||||
public boolean isSitting(Player player) {
|
||||
return sit.containsKey(player.getName());
|
||||
}
|
||||
public boolean isAroowOccupied(Entity entity)
|
||||
{
|
||||
for (Entity usedentity : sit.values())
|
||||
{
|
||||
if (usedentity.getEntityId() == entity.getEntityId())
|
||||
{
|
||||
public boolean isAroowOccupied(Entity entity) {
|
||||
for (Entity usedentity : sit.values()) {
|
||||
if (usedentity.getEntityId() == entity.getEntityId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isBlockOccupied(Block block)
|
||||
{
|
||||
public boolean isBlockOccupied(Block block) {
|
||||
return sitblock.containsKey(block);
|
||||
}
|
||||
public Player getPlayerOnChair(Block chair)
|
||||
{
|
||||
public Player getPlayerOnChair(Block chair) {
|
||||
return Bukkit.getPlayerExact(sitblock.get(chair));
|
||||
}
|
||||
public void sitPlayer(Player player, Location sitlocation)
|
||||
{
|
||||
public void sitPlayer(Player player, Location sitlocation) {
|
||||
try {
|
||||
if (plugin.notifyplayer)
|
||||
{
|
||||
if (plugin.notifyplayer) {
|
||||
player.sendMessage(plugin.msgSitting);
|
||||
}
|
||||
Block block = sitlocation.getBlock();
|
||||
@ -68,15 +60,13 @@ public class PlayerSitData {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void startReSitTask(final Player player)
|
||||
{
|
||||
int task =
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
public void startReSitTask(final Player player) {
|
||||
int task =
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reSitPlayer(player);
|
||||
}
|
||||
}
|
||||
},1000,1000);
|
||||
sittask.put(player.getName(), task);
|
||||
}
|
||||
@ -90,10 +80,9 @@ public class PlayerSitData {
|
||||
Location arrowloc = block.getLocation().add(0.5, 0 , 0.5);
|
||||
Entity arrow = sitPlayerOnArrow(player, arrowloc);
|
||||
sit.put(player.getName(), arrow);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
prevarrow.remove();
|
||||
}
|
||||
},100);
|
||||
@ -101,8 +90,7 @@ public class PlayerSitData {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private Entity sitPlayerOnArrow(Player player, Location arrowloc) throws NoSuchMethodException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException
|
||||
{
|
||||
private Entity sitPlayerOnArrow(Player player, Location arrowloc) throws NoSuchMethodException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException {
|
||||
Entity arrow = player.getWorld().spawnArrow(arrowloc, new Vector(0, 0 ,0), 0, 0);
|
||||
Method getHandleMethod = arrow.getClass().getDeclaredMethod("getHandle");
|
||||
getHandleMethod.setAccessible(true);
|
||||
@ -116,25 +104,23 @@ public class PlayerSitData {
|
||||
arrow.setPassenger(player);
|
||||
return arrow;
|
||||
}
|
||||
public void unSitPlayer(final Player player, boolean restoreposition, boolean correctleaveposition)
|
||||
{
|
||||
public void unSitPlayer(final Player player, boolean restoreposition, boolean correctleaveposition) {
|
||||
final Entity arrow = sit.get(player.getName());
|
||||
sit.remove(player.getName());
|
||||
player.eject();
|
||||
arrow.remove();
|
||||
final Location tploc = sitstopteleportloc.get(player.getName());
|
||||
if (restoreposition)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
if (restoreposition) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.teleport(tploc);
|
||||
player.setSneaking(false);
|
||||
}
|
||||
},1);
|
||||
} else if (correctleaveposition)
|
||||
{
|
||||
} else if (correctleaveposition) {
|
||||
player.teleport(tploc);
|
||||
}
|
||||
sitblock.remove(sitblockbr.get(player.getName()));
|
||||
@ -142,10 +128,9 @@ public class PlayerSitData {
|
||||
sitstopteleportloc.remove(player.getName());
|
||||
Bukkit.getScheduler().cancelTask(sittask.get(player.getName()));
|
||||
sittask.remove(player.getName());
|
||||
if (plugin.notifyplayer)
|
||||
{
|
||||
if (plugin.notifyplayer) {
|
||||
player.sendMessage(plugin.msgStanding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -29,9 +30,8 @@ public class TrySitEventListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
this.ignoreList = ignoreList;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
@ -44,51 +44,50 @@ public class TrySitEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sitAllowed(Player player, Block block)
|
||||
{
|
||||
private boolean sitAllowed(Player player, Block block) {
|
||||
// Check for permissions
|
||||
if (!player.hasPermission("chairs.sit")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for already sitting
|
||||
if (isSitting(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for item in hand
|
||||
if (plugin.ignoreIfBlockInHand && player.getItemInHand().getType() != Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for sneaking
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for /chairs off
|
||||
if (ignoreList.isIgnored(player.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Sit occupied check
|
||||
if (plugin.getPlayerSitData().isBlockOccupied(block)) {
|
||||
player.sendMessage(plugin.msgOccupied.replace("%PLAYER%", plugin.getPlayerSitData().getPlayerOnChair(block).getName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Region allowance check
|
||||
if (!WGHook.isAllowedInRegion(plugin.disabledRegions, block.getLocation())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Stairs stairs = null;
|
||||
Step step = null;
|
||||
WoodenStep wStep = null;
|
||||
|
||||
// Check for block is chair
|
||||
if (
|
||||
isValidChair(block) ||
|
||||
isValidChair(block) ||
|
||||
(
|
||||
!player.hasPermission("chairs.sit.antiopcheck") &&
|
||||
player.hasPermission("chairs.sit." + block.getType().toString())
|
||||
@ -131,7 +130,7 @@ public class TrySitEventListener implements Listener {
|
||||
if (wStep != null && wStep.isInverted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for signs (only for stairs)
|
||||
if (plugin.signCheck && stairs != null) {
|
||||
boolean sign1 = false;
|
||||
@ -167,26 +166,26 @@ public class TrySitEventListener implements Listener {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private Location getSitLocation(Block block, Float playerYaw)
|
||||
{
|
||||
double sh = 0.7;
|
||||
|
||||
|
||||
for (ChairBlock cb : plugin.allowedBlocks) {
|
||||
if (cb.getMat().equals(block.getType())) {
|
||||
sh = cb.getSitHeight();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Stairs stairs = null;
|
||||
if (block.getState().getData() instanceof Stairs) {
|
||||
stairs = (Stairs) block.getState().getData();
|
||||
}
|
||||
|
||||
|
||||
Location plocation = block.getLocation().clone();
|
||||
plocation.add(0.5D, (sh - 0.5D), 0.5D);
|
||||
|
||||
@ -212,9 +211,9 @@ public class TrySitEventListener implements Listener {
|
||||
}
|
||||
return plocation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean isValidChair(Block block) {
|
||||
for (ChairBlock cb : plugin.allowedBlocks) {
|
||||
if (cb.getMat().equals(block.getType())) {
|
||||
|
@ -17,60 +17,49 @@ import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import com.cnaude.chairs.core.Chairs;
|
||||
|
||||
public class TryUnsitEventListener implements Listener {
|
||||
|
||||
|
||||
public Chairs plugin;
|
||||
|
||||
public TryUnsitEventListener(Chairs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.getPlayerSitData().isSitting(player))
|
||||
{
|
||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||
plugin.getPlayerSitData().unSitPlayer(player, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.getPlayerSitData().isSitting(player))
|
||||
{
|
||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
if (plugin.getPlayerSitData().isSitting(player))
|
||||
{
|
||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||
plugin.getPlayerSitData().unSitPlayer(player, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private HashSet<String> queueUnsit = new HashSet<String>();
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onExitVehicle(VehicleExitEvent e)
|
||||
{
|
||||
if (e.getVehicle().getPassenger() instanceof Player)
|
||||
{
|
||||
public void onExitVehicle(VehicleExitEvent e) {
|
||||
if (e.getVehicle().getPassenger() instanceof Player) {
|
||||
final Player player = (Player) e.getVehicle().getPassenger();
|
||||
if (plugin.getPlayerSitData().isSitting(player))
|
||||
{
|
||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||
e.setCancelled(true);
|
||||
if (!queueUnsit.contains(player.getName()))
|
||||
{
|
||||
if (!queueUnsit.contains(player.getName())) {
|
||||
queueUnsit.add(player.getName());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
queueUnsit.remove(player.getName());
|
||||
plugin.getPlayerSitData().unSitPlayer(player, true, false);
|
||||
}
|
||||
@ -79,17 +68,14 @@ public class TryUnsitEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Block b = event.getBlock();
|
||||
if (plugin.getPlayerSitData().isBlockOccupied(b))
|
||||
{
|
||||
if (plugin.getPlayerSitData().isBlockOccupied(b)) {
|
||||
Player player = plugin.getPlayerSitData().getPlayerOnChair(b);
|
||||
plugin.getPlayerSitData().unSitPlayer(player, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -10,19 +10,19 @@ import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.WGBukkit;
|
||||
|
||||
public class WGHook {
|
||||
|
||||
public static boolean isAllowedInRegion(HashSet<String> disabledRegions, Location location) {
|
||||
|
||||
public static boolean isAllowedInRegion(HashSet<String> disabledRegions, Location location) {
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (disabledRegions.isEmpty())
|
||||
if (disabledRegions.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
List<String> aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location));
|
||||
for (String region : aregions)
|
||||
for (String region : aregions)
|
||||
{
|
||||
if (disabledRegions.contains(region))
|
||||
{
|
||||
@ -31,5 +31,5 @@ public class WGHook {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ public class ChairEffects {
|
||||
private Chairs plugin;
|
||||
private int healTaskID = -1;
|
||||
private int pickupTaskID = -1;
|
||||
|
||||
|
||||
|
||||
public ChairEffects(Chairs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
public void startHealing() {
|
||||
healEffectsTask();
|
||||
}
|
||||
@ -37,7 +37,7 @@ public class ChairEffects {
|
||||
healTaskID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void restartHealing() {
|
||||
cancelHealing();
|
||||
startHealing();
|
||||
@ -64,25 +64,27 @@ public class ChairEffects {
|
||||
}
|
||||
}, plugin.sitHealInterval, plugin.sitHealInterval);
|
||||
}
|
||||
|
||||
|
||||
public void startPickup() {
|
||||
pickupEffectsTask();
|
||||
}
|
||||
|
||||
public void cancelPickup() {
|
||||
if (pickupTaskID != -1)
|
||||
plugin.getServer().getScheduler().cancelTask(pickupTaskID);
|
||||
if (pickupTaskID != -1) {
|
||||
plugin.getServer().getScheduler().cancelTask(pickupTaskID);
|
||||
}
|
||||
pickupTaskID = -1;
|
||||
}
|
||||
|
||||
|
||||
public void restartPickup() {
|
||||
cancelPickup();
|
||||
startPickup();
|
||||
}
|
||||
|
||||
|
||||
private void pickupEffectsTask() {
|
||||
pickupTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (plugin.getPlayerSitData().isSitting(p)) {
|
||||
for (Entity entity : p.getNearbyEntities(1, 2, 1)) {
|
||||
@ -105,5 +107,5 @@ public class ChairEffects {
|
||||
}
|
||||
},0,1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,12 +9,12 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import com.cnaude.chairs.core.Chairs;
|
||||
|
||||
public class CommandRestrict implements Listener {
|
||||
|
||||
|
||||
private Chairs plugin;
|
||||
public CommandRestrict(Chairs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ public class GetVehicleArrowClass {
|
||||
if (nmspackageversion.equals("v1_7_R1"))
|
||||
{
|
||||
return Class.forName(pkgname+"."+"nms172"+"."+vehiclearrowclassname);
|
||||
} else
|
||||
} else
|
||||
if (nmspackageversion.equals("v1_6_R3"))
|
||||
{
|
||||
return Class.forName(pkgname+"."+"nms164"+"."+vehiclearrowclassname);
|
||||
@ -22,5 +22,5 @@ public class GetVehicleArrowClass {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,15 @@ import org.bukkit.entity.Vehicle;
|
||||
|
||||
public class VehicleArrow extends CraftArrow implements Vehicle {
|
||||
|
||||
public VehicleArrow(CraftServer server, EntityArrow entity)
|
||||
public VehicleArrow(CraftServer server, EntityArrow entity)
|
||||
{
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
public void remove()
|
||||
{
|
||||
if (this.getPassenger() == null)
|
||||
if (this.getPassenger() == null)
|
||||
{
|
||||
super.remove();
|
||||
}
|
||||
|
@ -8,15 +8,15 @@ import org.bukkit.entity.Vehicle;
|
||||
|
||||
public class VehicleArrow extends CraftArrow implements Vehicle {
|
||||
|
||||
public VehicleArrow(CraftServer server, EntityArrow entity)
|
||||
public VehicleArrow(CraftServer server, EntityArrow entity)
|
||||
{
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
public void remove()
|
||||
{
|
||||
if (this.getPassenger() == null)
|
||||
if (this.getPassenger() == null)
|
||||
{
|
||||
super.remove();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user