Merge pull request #1 from Shevchik/arrow

Get changes from base
This commit is contained in:
timafh 2016-06-11 14:32:59 +02:00 committed by GitHub
commit 9e0ae37e67
38 changed files with 181 additions and 462 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
libs/craftbukkit188.jar Normal file

Binary file not shown.

BIN
libs/craftbukkit19.jar Normal file

Binary file not shown.

BIN
libs/craftbukkit194.jar Normal file

Binary file not shown.

View File

@ -38,6 +38,16 @@ public class ChairsCommand implements CommandExecutor {
sender.sendMessage(plugin.msgNoPerm); sender.sendMessage(plugin.msgNoPerm);
} }
} }
if (sender instanceof Player) {
Player player = (Player) sender;
if (args[0].equalsIgnoreCase("off")) {
plugin.sitDisabled.add(player.getName());
player.sendMessage(plugin.msgDisabled);
} else if (args[0].equalsIgnoreCase("on")) {
plugin.sitDisabled.remove(player.getName());
player.sendMessage(plugin.msgEnabled);
}
}
return true; return true;
} }

View File

@ -7,6 +7,7 @@ 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 org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -25,6 +26,7 @@ import com.cnaude.chairs.vehiclearrow.NMSAccess;
public class Chairs extends JavaPlugin { public class Chairs extends JavaPlugin {
public HashSet<String> sitDisabled = new HashSet<String>();
public ChairEffects chairEffects; public ChairEffects chairEffects;
public List<ChairBlock> allowedBlocks; public List<ChairBlock> allowedBlocks;
public List<Material> validSigns; public List<Material> validSigns;
@ -84,7 +86,7 @@ public class Chairs extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
if (psitdata != null) { if (psitdata != null) {
for (Player player : Utils.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if (psitdata.isSitting(player)) { if (psitdata.isSitting(player)) {
psitdata.unsitPlayerForce(player); psitdata.unsitPlayerForce(player);
} }

View File

@ -1,12 +0,0 @@
package com.cnaude.chairs.core;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Utils {
public static Player[] getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
}

View File

@ -42,6 +42,12 @@ public class TrySitEventListener implements Listener {
} }
private boolean sitAllowed(Player player, Block block) { private boolean sitAllowed(Player player, Block block) {
// Check for sitting disabled
if (plugin.sitDisabled.contains(player.getName())) {
return false;
}
// Check for permissions // Check for permissions
if (!player.hasPermission("chairs.sit")) { if (!player.hasPermission("chairs.sit")) {
return false; return false;
@ -53,7 +59,7 @@ public class TrySitEventListener implements Listener {
} }
// Check for item in hand // Check for item in hand
if (plugin.ignoreIfBlockInHand && player.getItemInHand().getType() != Material.AIR) { if (plugin.ignoreIfBlockInHand && player.getInventory().getItemInMainHand().getType() != Material.AIR) {
return false; return false;
} }
@ -92,9 +98,6 @@ public class TrySitEventListener implements Listener {
if (block.getRelative(BlockFace.DOWN).isEmpty()) { if (block.getRelative(BlockFace.DOWN).isEmpty()) {
return false; return false;
} }
if (!block.getRelative(BlockFace.DOWN).getType().isSolid()) {
return false;
}
// Check for distance distance between player and chair. // Check for distance distance between player and chair.
if (plugin.distance > 0 && player.getLocation().distance(block.getLocation().add(0.5, 0, 0.5)) > plugin.distance) { if (plugin.distance > 0 && player.getLocation().distance(block.getLocation().add(0.5, 0, 0.5)) > plugin.distance) {

View File

@ -11,7 +11,6 @@ import org.bukkit.event.player.PlayerLevelChangeEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import com.cnaude.chairs.core.Chairs; import com.cnaude.chairs.core.Chairs;
import com.cnaude.chairs.core.Utils;
public class ChairEffects { public class ChairEffects {
@ -44,7 +43,7 @@ public class ChairEffects {
healTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { healTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
for (Player p : Utils.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
if (plugin.getPlayerSitData().isSitting(p)) { if (plugin.getPlayerSitData().isSitting(p)) {
if (p.hasPermission("chairs.sit.health")) { if (p.hasPermission("chairs.sit.health")) {
double pHealthPcnt = (getPlayerHealth(p)) / getMaxPlayerHealth(p) * 100d; double pHealthPcnt = (getPlayerHealth(p)) / getMaxPlayerHealth(p) * 100d;
@ -90,7 +89,7 @@ public class ChairEffects {
pickupTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { pickupTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
for (Player p : Utils.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
if (plugin.getPlayerSitData().isSitting(p)) { if (plugin.getPlayerSitData().isSitting(p)) {
for (Entity entity : p.getNearbyEntities(1, 2, 1)) { for (Entity entity : p.getNearbyEntities(1, 2, 1)) {
if (entity instanceof Item) { if (entity instanceof Item) {

View File

@ -1,23 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_6_R3;
import net.minecraft.server.v1_6_R3.EntityArrow;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
public class NMSChairsArrow extends EntityArrow {
public NMSChairsArrow(CraftWorld cworld, Location location) {
super(cworld.getHandle());
setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.addEntity(this);
bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this);
}
@Override
public void l_() {
}
}

View File

@ -1,30 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R1;
import net.minecraft.server.v1_7_R1.EntityArrow;
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import com.cnaude.chairs.api.ChairsAPI;
public class CraftChairsArrow extends CraftArrow implements Vehicle {
public CraftChairsArrow(CraftServer server, EntityArrow entity) {
super(server, entity);
}
@Override
public void remove() {
Entity passenger = getPassenger();
if (passenger != null && passenger instanceof Player) {
if (ChairsAPI.isSitting((Player) passenger)) {
return;
}
}
super.remove();
}
}

View File

@ -1,23 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R1;
import net.minecraft.server.v1_7_R1.EntityArrow;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
public class NMSChairsArrow extends EntityArrow {
public NMSChairsArrow(CraftWorld cworld, Location location) {
super(cworld.getHandle());
setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.addEntity(this);
bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this);
}
@Override
public void h() {
}
}

View File

@ -1,20 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R3;
import net.minecraft.server.v1_7_R3.EntityArrow;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;
public class NMSArrowFactory implements NMSArrowFactoryInterface {
@Override
public Arrow spawnArrow(Location location) {
CraftWorld world = (CraftWorld) location.getWorld();
EntityArrow arrow = new NMSChairsArrow(world, location);
return (Arrow) arrow.getBukkitEntity();
}
}

View File

@ -1,30 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R4;
import net.minecraft.server.v1_7_R4.EntityArrow;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import com.cnaude.chairs.api.ChairsAPI;
public class CraftChairsArrow extends CraftArrow implements Vehicle {
public CraftChairsArrow(CraftServer server, EntityArrow entity) {
super(server, entity);
}
@Override
public void remove() {
Entity passenger = getPassenger();
if (passenger != null && passenger instanceof Player) {
if (ChairsAPI.isSitting((Player) passenger)) {
return;
}
}
super.remove();
}
}

View File

@ -1,20 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R4;
import net.minecraft.server.v1_7_R4.EntityArrow;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;
public class NMSArrowFactory implements NMSArrowFactoryInterface {
@Override
public Arrow spawnArrow(Location location) {
CraftWorld world = (CraftWorld) location.getWorld();
EntityArrow arrow = new NMSChairsArrow(world, location);
return (Arrow) arrow.getBukkitEntity();
}
}

View File

@ -1,23 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R4;
import net.minecraft.server.v1_7_R4.EntityArrow;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
public class NMSChairsArrow extends EntityArrow {
public NMSChairsArrow(CraftWorld cworld, Location location) {
super(cworld.getHandle());
setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.addEntity(this);
bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this);
}
@Override
public void h() {
}
}

View File

@ -1,30 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_8_R1;
import net.minecraft.server.v1_8_R1.EntityArrow;
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import com.cnaude.chairs.api.ChairsAPI;
public class CraftChairsArrow extends CraftArrow implements Vehicle {
public CraftChairsArrow(CraftServer server, EntityArrow entity) {
super(server, entity);
}
@Override
public void remove() {
Entity passenger = getPassenger();
if (passenger != null && passenger instanceof Player) {
if (ChairsAPI.isSitting((Player) passenger)) {
return;
}
}
super.remove();
}
}

View File

@ -1,20 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_8_R1;
import net.minecraft.server.v1_8_R1.EntityArrow;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;
public class NMSArrowFactory implements NMSArrowFactoryInterface {
@Override
public Arrow spawnArrow(Location location) {
CraftWorld world = (CraftWorld) location.getWorld();
EntityArrow arrow = new NMSChairsArrow(world, location);
return (Arrow) arrow.getBukkitEntity();
}
}

View File

@ -1,23 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_8_R1;
import net.minecraft.server.v1_8_R1.EntityArrow;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
public class NMSChairsArrow extends EntityArrow {
public NMSChairsArrow(CraftWorld cworld, Location location) {
super(cworld.getHandle());
setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.addEntity(this);
bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this);
}
@Override
public void s_() {
}
}

View File

@ -1,30 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_8_R2;
import net.minecraft.server.v1_8_R2.EntityArrow;
import org.bukkit.craftbukkit.v1_8_R2.CraftServer;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import com.cnaude.chairs.api.ChairsAPI;
public class CraftChairsArrow extends CraftArrow implements Vehicle {
public CraftChairsArrow(CraftServer server, EntityArrow entity) {
super(server, entity);
}
@Override
public void remove() {
Entity passenger = getPassenger();
if (passenger != null && passenger instanceof Player) {
if (ChairsAPI.isSitting((Player) passenger)) {
return;
}
}
super.remove();
}
}

View File

@ -1,20 +0,0 @@
package com.cnaude.chairs.vehiclearrow.v1_8_R2;
import net.minecraft.server.v1_8_R2.EntityArrow;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;
public class NMSArrowFactory implements NMSArrowFactoryInterface {
@Override
public Arrow spawnArrow(Location location) {
CraftWorld world = (CraftWorld) location.getWorld();
EntityArrow arrow = new NMSChairsArrow(world, location);
return (Arrow) arrow.getBukkitEntity();
}
}

View File

@ -1,9 +1,9 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R3; package com.cnaude.chairs.vehiclearrow.v1_8_R3;
import net.minecraft.server.v1_7_R3.EntityArrow; import net.minecraft.server.v1_8_R3.EntityArrow;
import org.bukkit.craftbukkit.v1_7_R3.CraftServer; import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftArrow; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
@ -27,4 +27,13 @@ public class CraftChairsArrow extends CraftArrow implements Vehicle {
super.remove(); super.remove();
} }
@Override
public boolean isGlowing() {
return false;
}
@Override
public void setGlowing(boolean glowing) {
}
} }

View File

@ -1,9 +1,9 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R1; package com.cnaude.chairs.vehiclearrow.v1_8_R3;
import net.minecraft.server.v1_7_R1.EntityArrow; import net.minecraft.server.v1_8_R3.EntityArrow;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;

View File

@ -1,11 +1,11 @@
package com.cnaude.chairs.vehiclearrow.v1_8_R2; package com.cnaude.chairs.vehiclearrow.v1_8_R3;
import net.minecraft.server.v1_8_R2.EntityArrow; import net.minecraft.server.v1_8_R3.EntityArrow;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R2.CraftServer; import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
public class NMSChairsArrow extends EntityArrow { public class NMSChairsArrow extends EntityArrow {

View File

@ -1,9 +1,9 @@
package com.cnaude.chairs.vehiclearrow.v1_6_R3; package com.cnaude.chairs.vehiclearrow.v1_9_R1;
import net.minecraft.server.v1_6_R3.EntityArrow; import net.minecraft.server.v1_9_R1.EntityArrow;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer; import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftArrow; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftArrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;

View File

@ -1,9 +1,9 @@
package com.cnaude.chairs.vehiclearrow.v1_6_R3; package com.cnaude.chairs.vehiclearrow.v1_9_R1;
import net.minecraft.server.v1_6_R3.EntityArrow; import net.minecraft.server.v1_9_R1.EntityArrow;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld; import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;

View File

@ -1,13 +1,13 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R2; package com.cnaude.chairs.vehiclearrow.v1_9_R1;
import net.minecraft.server.v1_7_R2.EntityArrow; import net.minecraft.server.v1_9_R1.EntityTippedArrow;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R2.CraftServer; import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld; import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
public class NMSChairsArrow extends EntityArrow { public class NMSChairsArrow extends EntityTippedArrow {
public NMSChairsArrow(CraftWorld cworld, Location location) { public NMSChairsArrow(CraftWorld cworld, Location location) {
super(cworld.getHandle()); super(cworld.getHandle());
@ -17,7 +17,7 @@ public class NMSChairsArrow extends EntityArrow {
} }
@Override @Override
public void h() { public void m() {
} }
} }

View File

@ -1,9 +1,9 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R2; package com.cnaude.chairs.vehiclearrow.v1_9_R2;
import net.minecraft.server.v1_7_R2.EntityArrow; import net.minecraft.server.v1_9_R2.EntityArrow;
import org.bukkit.craftbukkit.v1_7_R2.CraftServer; import org.bukkit.craftbukkit.v1_9_R2.CraftServer;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftArrow; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftArrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;

View File

@ -1,9 +1,9 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R2; package com.cnaude.chairs.vehiclearrow.v1_9_R2;
import net.minecraft.server.v1_7_R2.EntityArrow; import net.minecraft.server.v1_9_R2.EntityArrow;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld; import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface;

View File

@ -1,13 +1,13 @@
package com.cnaude.chairs.vehiclearrow.v1_7_R3; package com.cnaude.chairs.vehiclearrow.v1_9_R2;
import net.minecraft.server.v1_7_R3.EntityArrow; import net.minecraft.server.v1_9_R2.EntityTippedArrow;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R3.CraftServer; import org.bukkit.craftbukkit.v1_9_R2.CraftServer;
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld; import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
public class NMSChairsArrow extends EntityArrow { public class NMSChairsArrow extends EntityTippedArrow {
public NMSChairsArrow(CraftWorld cworld, Location location) { public NMSChairsArrow(CraftWorld cworld, Location location) {
super(cworld.getHandle()); super(cworld.getHandle());
@ -17,7 +17,7 @@ public class NMSChairsArrow extends EntityArrow {
} }
@Override @Override
public void h() { public void m() {
} }
} }

View File

@ -1,5 +1,5 @@
name: Chairs name: Chairs
version: 4.5 version: 4.8
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: