Clean up
This commit is contained in:
parent
28e483267d
commit
e838c79941
@ -17,69 +17,69 @@ import com.cnaude.chairs.core.Chairs;
|
|||||||
*/
|
*/
|
||||||
public class ChairsCommand implements CommandExecutor {
|
public class ChairsCommand implements CommandExecutor {
|
||||||
|
|
||||||
private final Chairs plugin;
|
private final Chairs plugin;
|
||||||
public ChairsIgnoreList ignoreList;
|
public ChairsIgnoreList ignoreList;
|
||||||
|
|
||||||
public ChairsCommand(Chairs instance, ChairsIgnoreList ignoreList) {
|
public ChairsCommand(Chairs instance, ChairsIgnoreList ignoreList) {
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.ignoreList = ignoreList;
|
this.ignoreList = ignoreList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
if (sender.hasPermission("chairs.reload") || !(sender instanceof Player)) {
|
if (sender.hasPermission("chairs.reload") || !(sender instanceof Player)) {
|
||||||
plugin.loadConfig();
|
plugin.loadConfig();
|
||||||
if (plugin.sitHealEnabled) {
|
if (plugin.sitHealEnabled) {
|
||||||
plugin.chairEffects.restartHealing();
|
plugin.chairEffects.restartHealing();
|
||||||
} else {
|
} else {
|
||||||
plugin.chairEffects.cancelHealing();
|
plugin.chairEffects.cancelHealing();
|
||||||
}
|
}
|
||||||
if (plugin.sitPickupEnabled) {
|
if (plugin.sitPickupEnabled) {
|
||||||
plugin.chairEffects.restartPickup();
|
plugin.chairEffects.restartPickup();
|
||||||
} else {
|
} else {
|
||||||
plugin.chairEffects.cancelPickup();
|
plugin.chairEffects.cancelPickup();
|
||||||
}
|
}
|
||||||
if (!plugin.msgReloaded.isEmpty()) {
|
if (!plugin.msgReloaded.isEmpty()) {
|
||||||
sender.sendMessage(plugin.msgReloaded);
|
sender.sendMessage(plugin.msgReloaded);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!plugin.msgNoPerm.isEmpty()) {
|
if (!plugin.msgNoPerm.isEmpty()) {
|
||||||
sender.sendMessage(plugin.msgNoPerm);
|
sender.sendMessage(plugin.msgNoPerm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (args[0].equalsIgnoreCase("on")) {
|
if (args[0].equalsIgnoreCase("on")) {
|
||||||
if (p.hasPermission("chairs.self")) {
|
if (p.hasPermission("chairs.self")) {
|
||||||
ignoreList.removePlayer(p.getName());
|
ignoreList.removePlayer(p.getName());
|
||||||
if (!plugin.msgEnabled.isEmpty()) {
|
if (!plugin.msgEnabled.isEmpty()) {
|
||||||
p.sendMessage(plugin.msgEnabled);
|
p.sendMessage(plugin.msgEnabled);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!plugin.msgNoPerm.isEmpty()) {
|
if (!plugin.msgNoPerm.isEmpty()) {
|
||||||
p.sendMessage(plugin.msgNoPerm);
|
p.sendMessage(plugin.msgNoPerm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("off")) {
|
if (args[0].equalsIgnoreCase("off")) {
|
||||||
if (p.hasPermission("chairs.self")) {
|
if (p.hasPermission("chairs.self")) {
|
||||||
ignoreList.addPlayer(p.getName());
|
ignoreList.addPlayer(p.getName());
|
||||||
if (!plugin.msgDisabled.isEmpty()) {
|
if (!plugin.msgDisabled.isEmpty()) {
|
||||||
p.sendMessage(plugin.msgDisabled);
|
p.sendMessage(plugin.msgDisabled);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!plugin.msgNoPerm.isEmpty()) {
|
if (!plugin.msgNoPerm.isEmpty()) {
|
||||||
p.sendMessage(plugin.msgNoPerm);
|
p.sendMessage(plugin.msgNoPerm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,67 +20,67 @@ import com.cnaude.chairs.core.Chairs;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ChairsIgnoreList implements Serializable{
|
public class ChairsIgnoreList implements Serializable{
|
||||||
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
||||||
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
||||||
|
|
||||||
private Chairs plugin;
|
private Chairs plugin;
|
||||||
public ChairsIgnoreList(Chairs plugin)
|
public ChairsIgnoreList(Chairs plugin)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load() {
|
public void load() {
|
||||||
File file = new File(IGNORE_FILE);
|
File file = new File(IGNORE_FILE);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
plugin.logInfo("Ignore file '"+file.getAbsolutePath()+"' does not exist.");
|
plugin.logInfo("Ignore file '"+file.getAbsolutePath()+"' does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
FileInputStream f_in = new FileInputStream(file);
|
FileInputStream f_in = new FileInputStream(file);
|
||||||
ObjectInputStream obj_in = new ObjectInputStream (f_in);
|
ObjectInputStream obj_in = new ObjectInputStream (f_in);
|
||||||
ignoreList = (ArrayList<String>) obj_in.readObject();
|
ignoreList = (ArrayList<String>) obj_in.readObject();
|
||||||
obj_in.close();
|
obj_in.close();
|
||||||
plugin.logInfo("Loaded ignore list. (Count = "+ignoreList.size()+")");
|
plugin.logInfo("Loaded ignore list. (Count = "+ignoreList.size()+")");
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
plugin.logError(e.getMessage());
|
plugin.logError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
try {
|
try {
|
||||||
File file = new File(IGNORE_FILE);
|
File file = new File(IGNORE_FILE);
|
||||||
FileOutputStream f_out = new FileOutputStream (file);
|
FileOutputStream f_out = new FileOutputStream (file);
|
||||||
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
|
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
|
||||||
obj_out.writeObject (ignoreList);
|
obj_out.writeObject (ignoreList);
|
||||||
obj_out.close();
|
obj_out.close();
|
||||||
plugin.logInfo("Saved ignore list. (Count = "+ignoreList.size()+")");
|
plugin.logInfo("Saved ignore list. (Count = "+ignoreList.size()+")");
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
plugin.logError(e.getMessage());
|
plugin.logError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(String s) {
|
public void addPlayer(String s) {
|
||||||
if (ignoreList.contains(s)) {
|
if (ignoreList.contains(s)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Chairs.get().logInfo("Adding " + s + " to ignore list.");
|
//Chairs.get().logInfo("Adding " + s + " to ignore list.");
|
||||||
ignoreList.add(s);
|
ignoreList.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(String s) {
|
public void removePlayer(String s) {
|
||||||
//Chairs.get().logInfo("Removing " + s + " from ignore list.");
|
//Chairs.get().logInfo("Removing " + s + " from ignore list.");
|
||||||
ignoreList.remove(s);
|
ignoreList.remove(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnored(String s) {
|
public boolean isIgnored(String s) {
|
||||||
if (ignoreList.contains(s)) {
|
if (ignoreList.contains(s)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,20 +11,20 @@ import org.bukkit.Material;
|
|||||||
* @author cnaude
|
* @author cnaude
|
||||||
*/
|
*/
|
||||||
public class ChairBlock {
|
public class ChairBlock {
|
||||||
private Material mat;
|
private Material mat;
|
||||||
private double sitHeight;
|
private double sitHeight;
|
||||||
|
|
||||||
public ChairBlock(Material m, double s) {
|
public ChairBlock(Material m, double s) {
|
||||||
mat = m;
|
mat = m;
|
||||||
sitHeight = s;
|
sitHeight = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material getMat() {
|
public Material getMat() {
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getSitHeight() {
|
public double getSitHeight() {
|
||||||
return sitHeight;
|
return sitHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,153 +25,153 @@ import com.cnaude.chairs.sitaddons.CommandRestrict;
|
|||||||
import com.cnaude.chairs.vehiclearrow.NMSAccess;
|
import com.cnaude.chairs.vehiclearrow.NMSAccess;
|
||||||
|
|
||||||
public class Chairs extends JavaPlugin {
|
public class Chairs extends JavaPlugin {
|
||||||
public ChairEffects chairEffects;
|
public ChairEffects chairEffects;
|
||||||
public List<ChairBlock> allowedBlocks;
|
public List<ChairBlock> allowedBlocks;
|
||||||
public List<Material> validSigns;
|
public List<Material> validSigns;
|
||||||
public boolean autoRotate, signCheck, notifyplayer;
|
public boolean autoRotate, signCheck, notifyplayer;
|
||||||
public boolean ignoreIfBlockInHand;
|
public boolean ignoreIfBlockInHand;
|
||||||
public double distance;
|
public double distance;
|
||||||
public HashSet<String> disabledRegions = new HashSet<String>();
|
public HashSet<String> disabledRegions = new HashSet<String>();
|
||||||
public int maxChairWidth;
|
public int maxChairWidth;
|
||||||
public boolean sitHealEnabled;
|
public boolean sitHealEnabled;
|
||||||
public int sitMaxHealth;
|
public int sitMaxHealth;
|
||||||
public int sitHealthPerInterval;
|
public int sitHealthPerInterval;
|
||||||
public int sitHealInterval;
|
public int sitHealInterval;
|
||||||
public boolean sitPickupEnabled;
|
public boolean sitPickupEnabled;
|
||||||
public boolean sitDisableAllCommands = false;
|
public boolean sitDisableAllCommands = false;
|
||||||
public HashSet<String> sitDisabledCommands = new HashSet<String>();
|
public HashSet<String> sitDisabledCommands = new HashSet<String>();
|
||||||
private Logger log;
|
private Logger log;
|
||||||
public ChairsIgnoreList ignoreList;
|
public ChairsIgnoreList ignoreList;
|
||||||
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled, msgCommandRestricted;
|
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled, msgCommandRestricted;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private PlayerSitData psitdata;
|
private PlayerSitData psitdata;
|
||||||
public PlayerSitData getPlayerSitData() {
|
public PlayerSitData getPlayerSitData() {
|
||||||
return psitdata;
|
return psitdata;
|
||||||
}
|
}
|
||||||
private NMSAccess nmsaccess = new NMSAccess();
|
private NMSAccess nmsaccess = new NMSAccess();
|
||||||
protected NMSAccess getNMSAccess() {
|
protected NMSAccess getNMSAccess() {
|
||||||
return nmsaccess;
|
return nmsaccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
log = this.getLogger();
|
log = this.getLogger();
|
||||||
try {
|
try {
|
||||||
nmsaccess.setupVehicleArrow();
|
nmsaccess.setupVehicleArrow();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.severe("Failed to generate VehicleArrow class, exiting");
|
log.severe("Failed to generate VehicleArrow class, exiting");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chairEffects = new ChairEffects(this);
|
chairEffects = new ChairEffects(this);
|
||||||
ignoreList = new ChairsIgnoreList(this);
|
ignoreList = new ChairsIgnoreList(this);
|
||||||
ignoreList.load();
|
ignoreList.load();
|
||||||
psitdata = new PlayerSitData(this);
|
psitdata = new PlayerSitData(this);
|
||||||
getConfig().options().copyDefaults(true);
|
getConfig().options().copyDefaults(true);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
loadConfig();
|
loadConfig();
|
||||||
if (sitHealEnabled) {
|
if (sitHealEnabled) {
|
||||||
chairEffects.startHealing();
|
chairEffects.startHealing();
|
||||||
}
|
}
|
||||||
if (sitPickupEnabled) {
|
if (sitPickupEnabled) {
|
||||||
chairEffects.startPickup();
|
chairEffects.startPickup();
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new NANLoginListener(), this);
|
getServer().getPluginManager().registerEvents(new NANLoginListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new TrySitEventListener(this, ignoreList), this);
|
getServer().getPluginManager().registerEvents(new TrySitEventListener(this, ignoreList), this);
|
||||||
getServer().getPluginManager().registerEvents(new TryUnsitEventListener(this), this);
|
getServer().getPluginManager().registerEvents(new TryUnsitEventListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new CommandRestrict(this), this);
|
getServer().getPluginManager().registerEvents(new CommandRestrict(this), this);
|
||||||
getCommand("chairs").setExecutor(new ChairsCommand(this, ignoreList));
|
getCommand("chairs").setExecutor(new ChairsCommand(this, ignoreList));
|
||||||
new ChairsAPI(getPlayerSitData());
|
new ChairsAPI(getPlayerSitData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
if (psitdata.isSitting(player)) {
|
if (psitdata.isSitting(player)) {
|
||||||
psitdata.unsitPlayerNow(player);
|
psitdata.unsitPlayerNow(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ignoreList != null) {
|
if (ignoreList != null) {
|
||||||
ignoreList.save();
|
ignoreList.save();
|
||||||
}
|
}
|
||||||
if (chairEffects != null) {
|
if (chairEffects != null) {
|
||||||
chairEffects.cancelHealing();
|
chairEffects.cancelHealing();
|
||||||
chairEffects.cancelPickup();
|
chairEffects.cancelPickup();
|
||||||
chairEffects = null;
|
chairEffects = null;
|
||||||
}
|
}
|
||||||
log = null;
|
log = null;
|
||||||
nmsaccess = null;
|
nmsaccess = null;
|
||||||
psitdata = null;
|
psitdata = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(),"config.yml"));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(),"config.yml"));
|
||||||
autoRotate = config.getBoolean("auto-rotate");
|
autoRotate = config.getBoolean("auto-rotate");
|
||||||
signCheck = config.getBoolean("sign-check");
|
signCheck = config.getBoolean("sign-check");
|
||||||
distance = config.getDouble("distance");
|
distance = config.getDouble("distance");
|
||||||
maxChairWidth = config.getInt("max-chair-width");
|
maxChairWidth = config.getInt("max-chair-width");
|
||||||
notifyplayer = config.getBoolean("notify-player");
|
notifyplayer = config.getBoolean("notify-player");
|
||||||
ignoreIfBlockInHand = config.getBoolean("ignore-if-item-in-hand");
|
ignoreIfBlockInHand = config.getBoolean("ignore-if-item-in-hand");
|
||||||
|
|
||||||
disabledRegions = new HashSet<String>(config.getStringList("disabledWGRegions"));
|
disabledRegions = new HashSet<String>(config.getStringList("disabledWGRegions"));
|
||||||
|
|
||||||
sitHealEnabled = config.getBoolean("sit-effects.healing.enabled", false);
|
sitHealEnabled = config.getBoolean("sit-effects.healing.enabled", false);
|
||||||
sitHealInterval = config.getInt("sit-effects.healing.interval",20);
|
sitHealInterval = config.getInt("sit-effects.healing.interval",20);
|
||||||
sitMaxHealth = config.getInt("sit-effects.healing.max-percent",100);
|
sitMaxHealth = config.getInt("sit-effects.healing.max-percent",100);
|
||||||
sitHealthPerInterval = config.getInt("sit-effects.healing.amount",1);
|
sitHealthPerInterval = config.getInt("sit-effects.healing.amount",1);
|
||||||
|
|
||||||
sitPickupEnabled = config.getBoolean("sit-effects.itempickup.enabled", false);
|
sitPickupEnabled = config.getBoolean("sit-effects.itempickup.enabled", false);
|
||||||
|
|
||||||
sitDisableAllCommands = config.getBoolean("sit-restrictions.commands.all");
|
sitDisableAllCommands = config.getBoolean("sit-restrictions.commands.all");
|
||||||
sitDisabledCommands = new HashSet<String>(config.getStringList("sit-restrictions.commands.list"));
|
sitDisabledCommands = new HashSet<String>(config.getStringList("sit-restrictions.commands.list"));
|
||||||
|
|
||||||
msgSitting = ChatColor.translateAlternateColorCodes('&',config.getString("messages.sitting"));
|
msgSitting = ChatColor.translateAlternateColorCodes('&',config.getString("messages.sitting"));
|
||||||
msgStanding = ChatColor.translateAlternateColorCodes('&',config.getString("messages.standing"));
|
msgStanding = ChatColor.translateAlternateColorCodes('&',config.getString("messages.standing"));
|
||||||
msgOccupied = ChatColor.translateAlternateColorCodes('&',config.getString("messages.occupied"));
|
msgOccupied = ChatColor.translateAlternateColorCodes('&',config.getString("messages.occupied"));
|
||||||
msgNoPerm = ChatColor.translateAlternateColorCodes('&',config.getString("messages.no-permission"));
|
msgNoPerm = ChatColor.translateAlternateColorCodes('&',config.getString("messages.no-permission"));
|
||||||
msgEnabled = ChatColor.translateAlternateColorCodes('&',config.getString("messages.enabled"));
|
msgEnabled = ChatColor.translateAlternateColorCodes('&',config.getString("messages.enabled"));
|
||||||
msgDisabled = ChatColor.translateAlternateColorCodes('&',config.getString("messages.disabled"));
|
msgDisabled = ChatColor.translateAlternateColorCodes('&',config.getString("messages.disabled"));
|
||||||
msgReloaded = ChatColor.translateAlternateColorCodes('&',config.getString("messages.reloaded"));
|
msgReloaded = ChatColor.translateAlternateColorCodes('&',config.getString("messages.reloaded"));
|
||||||
msgCommandRestricted = ChatColor.translateAlternateColorCodes('&',config.getString("messages.command-restricted"));
|
msgCommandRestricted = ChatColor.translateAlternateColorCodes('&',config.getString("messages.command-restricted"));
|
||||||
|
|
||||||
allowedBlocks = new ArrayList<ChairBlock>();
|
allowedBlocks = new ArrayList<ChairBlock>();
|
||||||
for (String s : config.getStringList("sit-blocks")) {
|
for (String s : config.getStringList("sit-blocks")) {
|
||||||
String type;
|
String type;
|
||||||
double sh = 0.7;
|
double sh = 0.7;
|
||||||
String tmp[] = s.split("[:]");
|
String tmp[] = s.split("[:]");
|
||||||
type = tmp[0];
|
type = tmp[0];
|
||||||
if (tmp.length == 2) {
|
if (tmp.length == 2) {
|
||||||
sh = Double.parseDouble(tmp[1]);
|
sh = Double.parseDouble(tmp[1]);
|
||||||
}
|
}
|
||||||
Material mat = Material.matchMaterial(type);
|
Material mat = Material.matchMaterial(type);
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
logInfo("Allowed block: " + mat.toString() + " => " + sh);
|
logInfo("Allowed block: " + mat.toString() + " => " + sh);
|
||||||
allowedBlocks.add(new ChairBlock(mat,sh));
|
allowedBlocks.add(new ChairBlock(mat,sh));
|
||||||
} else {
|
} else {
|
||||||
logError("Invalid block: " + type);
|
logError("Invalid block: " + type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
validSigns = new ArrayList<Material>();
|
validSigns = new ArrayList<Material>();
|
||||||
for (String type : config.getStringList("valid-signs")) {
|
for (String type : config.getStringList("valid-signs")) {
|
||||||
try {
|
try {
|
||||||
validSigns.add(Material.matchMaterial(type));
|
validSigns.add(Material.matchMaterial(type));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logError(e.getMessage());
|
logError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logInfo(String _message) {
|
public void logInfo(String _message) {
|
||||||
log.log(Level.INFO, _message);
|
log.log(Level.INFO, _message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logError(String _message) {
|
public void logError(String _message) {
|
||||||
log.log(Level.SEVERE, _message);
|
log.log(Level.SEVERE, _message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,39 +30,39 @@ public class PlayerSitData {
|
|||||||
public Player getPlayerOnChair(Block chair) {
|
public Player getPlayerOnChair(Block chair) {
|
||||||
return Bukkit.getPlayerExact(sitblock.get(chair));
|
return Bukkit.getPlayerExact(sitblock.get(chair));
|
||||||
}
|
}
|
||||||
public void sitPlayer(Player player, Location sitlocation) {
|
public void sitPlayer(Player player, Location sitlocation) {
|
||||||
try {
|
try {
|
||||||
if (plugin.notifyplayer) {
|
if (plugin.notifyplayer) {
|
||||||
player.sendMessage(plugin.msgSitting);
|
player.sendMessage(plugin.msgSitting);
|
||||||
}
|
}
|
||||||
Block block = sitlocation.getBlock();
|
Block block = sitlocation.getBlock();
|
||||||
sitstopteleportloc.put(player.getName(), player.getLocation());
|
sitstopteleportloc.put(player.getName(), player.getLocation());
|
||||||
player.teleport(sitlocation);
|
player.teleport(sitlocation);
|
||||||
Location arrowloc = block.getLocation().add(0.5, 0 , 0.5);
|
Location arrowloc = block.getLocation().add(0.5, 0 , 0.5);
|
||||||
Entity arrow = sitPlayerOnArrow(player, arrowloc);
|
Entity arrow = sitPlayerOnArrow(player, arrowloc);
|
||||||
sit.put(player.getName(), arrow);
|
sit.put(player.getName(), arrow);
|
||||||
sitblock.put(block, player.getName());
|
sitblock.put(block, player.getName());
|
||||||
sitblockbr.put(player.getName(), block);
|
sitblockbr.put(player.getName(), block);
|
||||||
startReSitTask(player);
|
startReSitTask(player);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void startReSitTask(final Player player) {
|
public void startReSitTask(final Player player) {
|
||||||
int task =
|
int task =
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
reSitPlayer(player);
|
reSitPlayer(player);
|
||||||
}
|
}
|
||||||
},1000,1000);
|
},1000,1000);
|
||||||
sittask.put(player.getName(), task);
|
sittask.put(player.getName(), task);
|
||||||
}
|
}
|
||||||
public void reSitPlayer(final Player player) {
|
public void reSitPlayer(final Player player) {
|
||||||
try {
|
try {
|
||||||
final Entity prevarrow = sit.get(player.getName());
|
final Entity prevarrow = sit.get(player.getName());
|
||||||
sit.remove(player.getName());
|
sit.remove(player.getName());
|
||||||
player.eject();
|
player.eject();
|
||||||
Block block = sitblockbr.get(player.getName());
|
Block block = sitblockbr.get(player.getName());
|
||||||
Location arrowloc = block.getLocation().add(0.5, 0 , 0.5);
|
Location arrowloc = block.getLocation().add(0.5, 0 , 0.5);
|
||||||
Entity arrow = sitPlayerOnArrow(player, arrowloc);
|
Entity arrow = sitPlayerOnArrow(player, arrowloc);
|
||||||
@ -73,51 +73,51 @@ public class PlayerSitData {
|
|||||||
prevarrow.remove();
|
prevarrow.remove();
|
||||||
}
|
}
|
||||||
},100);
|
},100);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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 = plugin.getNMSAccess().spawnArrow(arrowloc);
|
Entity arrow = plugin.getNMSAccess().spawnArrow(arrowloc);
|
||||||
arrow.setPassenger(player);
|
arrow.setPassenger(player);
|
||||||
return arrow;
|
return arrow;
|
||||||
}
|
}
|
||||||
public void unsitPlayerNormal(Player player) {
|
public void unsitPlayerNormal(Player player) {
|
||||||
unsitPlayer(player, false, true, false);
|
unsitPlayer(player, false, true, false);
|
||||||
}
|
}
|
||||||
public void unsitPlayerForce(Player player) {
|
public void unsitPlayerForce(Player player) {
|
||||||
unsitPlayer(player, true, true, false);
|
unsitPlayer(player, true, true, false);
|
||||||
}
|
}
|
||||||
public void unsitPlayerNow(Player player) {
|
public void unsitPlayerNow(Player player) {
|
||||||
unsitPlayer(player, true, false, true);
|
unsitPlayer(player, true, false, true);
|
||||||
}
|
}
|
||||||
private void unsitPlayer(final Player player, boolean eject, boolean restoreposition, boolean correctleaveposition) {
|
private void unsitPlayer(final Player player, boolean eject, boolean restoreposition, boolean correctleaveposition) {
|
||||||
final Entity arrow = sit.get(player.getName());
|
final Entity arrow = sit.get(player.getName());
|
||||||
sit.remove(player.getName());
|
sit.remove(player.getName());
|
||||||
if (eject) {
|
if (eject) {
|
||||||
player.eject();
|
player.eject();
|
||||||
}
|
}
|
||||||
arrow.remove();
|
arrow.remove();
|
||||||
final Location tploc = sitstopteleportloc.get(player.getName());
|
final Location tploc = sitstopteleportloc.get(player.getName());
|
||||||
if (restoreposition) {
|
if (restoreposition) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
player.teleport(tploc);
|
player.teleport(tploc);
|
||||||
player.setSneaking(false);
|
player.setSneaking(false);
|
||||||
}
|
}
|
||||||
},1);
|
},1);
|
||||||
} else if (correctleaveposition) {
|
} else if (correctleaveposition) {
|
||||||
player.teleport(tploc);
|
player.teleport(tploc);
|
||||||
}
|
}
|
||||||
sitblock.remove(sitblockbr.get(player.getName()));
|
sitblock.remove(sitblockbr.get(player.getName()));
|
||||||
sitblockbr.remove(player.getName());
|
sitblockbr.remove(player.getName());
|
||||||
sitstopteleportloc.remove(player.getName());
|
sitstopteleportloc.remove(player.getName());
|
||||||
Bukkit.getScheduler().cancelTask(sittask.get(player.getName()));
|
Bukkit.getScheduler().cancelTask(sittask.get(player.getName()));
|
||||||
sittask.remove(player.getName());
|
sittask.remove(player.getName());
|
||||||
if (plugin.notifyplayer) {
|
if (plugin.notifyplayer) {
|
||||||
player.sendMessage(plugin.msgStanding);
|
player.sendMessage(plugin.msgStanding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ public class ChairsAPI {
|
|||||||
public static boolean isSitting(Player player) {
|
public static boolean isSitting(Player player) {
|
||||||
return pdata.isSitting(player);
|
return pdata.isSitting(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,282 +23,282 @@ import com.cnaude.chairs.pluginhooks.WGHook;
|
|||||||
|
|
||||||
public class TrySitEventListener implements Listener {
|
public class TrySitEventListener implements Listener {
|
||||||
|
|
||||||
public Chairs plugin;
|
public Chairs plugin;
|
||||||
public ChairsIgnoreList ignoreList;
|
public ChairsIgnoreList ignoreList;
|
||||||
|
|
||||||
public TrySitEventListener(Chairs plugin, ChairsIgnoreList ignoreList) {
|
public TrySitEventListener(Chairs plugin, ChairsIgnoreList ignoreList) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.ignoreList = ignoreList;
|
this.ignoreList = ignoreList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (sitAllowed(player, block)) {
|
if (sitAllowed(player, block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Location sitLocation = getSitLocation(block, player.getLocation().getYaw());
|
Location sitLocation = getSitLocation(block, player.getLocation().getYaw());
|
||||||
plugin.getPlayerSitData().sitPlayer(player, sitLocation);
|
plugin.getPlayerSitData().sitPlayer(player, sitLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sitAllowed(Player player, Block block) {
|
private boolean sitAllowed(Player player, Block block) {
|
||||||
// Check for permissions
|
// Check for permissions
|
||||||
if (!player.hasPermission("chairs.sit")) {
|
if (!player.hasPermission("chairs.sit")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for already sitting
|
// Check for already sitting
|
||||||
if (isSitting(player)) {
|
if (isSitting(player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for item in hand
|
// Check for item in hand
|
||||||
if (plugin.ignoreIfBlockInHand && player.getItemInHand().getType() != Material.AIR) {
|
if (plugin.ignoreIfBlockInHand && player.getItemInHand().getType() != Material.AIR) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for sneaking
|
// Check for sneaking
|
||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for /chairs off
|
// Check for /chairs off
|
||||||
if (ignoreList.isIgnored(player.getName())) {
|
if (ignoreList.isIgnored(player.getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sit occupied check
|
// Sit occupied check
|
||||||
if (plugin.getPlayerSitData().isBlockOccupied(block)) {
|
if (plugin.getPlayerSitData().isBlockOccupied(block)) {
|
||||||
player.sendMessage(plugin.msgOccupied.replace("%PLAYER%", plugin.getPlayerSitData().getPlayerOnChair(block).getName()));
|
player.sendMessage(plugin.msgOccupied.replace("%PLAYER%", plugin.getPlayerSitData().getPlayerOnChair(block).getName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Region allowance check
|
// Region allowance check
|
||||||
if (!WGHook.isAllowedInRegion(plugin.disabledRegions, block.getLocation())) {
|
if (!WGHook.isAllowedInRegion(plugin.disabledRegions, block.getLocation())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stairs stairs = null;
|
Stairs stairs = null;
|
||||||
Step step = null;
|
Step step = null;
|
||||||
WoodenStep wStep = null;
|
WoodenStep wStep = null;
|
||||||
|
|
||||||
// Check for block is chair
|
// Check for block is chair
|
||||||
if (
|
if (
|
||||||
isValidChair(block) ||
|
isValidChair(block) ||
|
||||||
(
|
(
|
||||||
!player.hasPermission("chairs.sit.antiopcheck") &&
|
!player.hasPermission("chairs.sit.antiopcheck") &&
|
||||||
player.hasPermission("chairs.sit." + block.getType().toString())
|
player.hasPermission("chairs.sit." + block.getType().toString())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
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) {
|
} else if (block.getState().getData() instanceof Step) {
|
||||||
step = (Step) block.getState().getData();
|
step = (Step) block.getState().getData();
|
||||||
} else if (block.getState().getData() instanceof WoodenStep) {
|
} else if (block.getState().getData() instanceof WoodenStep) {
|
||||||
wStep = (WoodenStep) block.getState().getData();
|
wStep = (WoodenStep) block.getState().getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).isLiquid()) {
|
if (block.getRelative(BlockFace.DOWN).isLiquid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (block.getRelative(BlockFace.DOWN).isEmpty()) {
|
if (block.getRelative(BlockFace.DOWN).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!block.getRelative(BlockFace.DOWN).getType().isSolid()) {
|
if (!block.getRelative(BlockFace.DOWN).getType().isSolid()) {
|
||||||
return false;
|
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) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if block is inverted
|
// Check if block is inverted
|
||||||
if (stairs != null && stairs.isInverted()) {
|
if (stairs != null && stairs.isInverted()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (step != null && step.isInverted()) {
|
if (step != null && step.isInverted()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wStep != null && wStep.isInverted()) {
|
if (wStep != null && wStep.isInverted()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for signs (only for stairs)
|
// Check for signs (only for stairs)
|
||||||
if (plugin.signCheck && stairs != null) {
|
if (plugin.signCheck && stairs != null) {
|
||||||
boolean sign1 = false;
|
boolean sign1 = false;
|
||||||
boolean sign2 = false;
|
boolean sign2 = false;
|
||||||
|
|
||||||
if (stairs.getDescendingDirection() == BlockFace.NORTH || stairs.getDescendingDirection() == BlockFace.SOUTH) {
|
if (stairs.getDescendingDirection() == BlockFace.NORTH || stairs.getDescendingDirection() == BlockFace.SOUTH) {
|
||||||
sign1 = checkSign(block, BlockFace.EAST) || checkFrame(block, BlockFace.EAST, player);
|
sign1 = checkSign(block, BlockFace.EAST) || checkFrame(block, BlockFace.EAST, player);
|
||||||
sign2 = checkSign(block, BlockFace.WEST) || checkFrame(block, BlockFace.WEST, player);
|
sign2 = checkSign(block, BlockFace.WEST) || checkFrame(block, BlockFace.WEST, player);
|
||||||
} else if (stairs.getDescendingDirection() == BlockFace.EAST || stairs.getDescendingDirection() == BlockFace.WEST) {
|
} else if (stairs.getDescendingDirection() == BlockFace.EAST || stairs.getDescendingDirection() == BlockFace.WEST) {
|
||||||
sign1 = checkSign(block, BlockFace.NORTH) || checkFrame(block, BlockFace.NORTH, player);
|
sign1 = checkSign(block, BlockFace.NORTH) || checkFrame(block, BlockFace.NORTH, player);
|
||||||
sign2 = checkSign(block, BlockFace.SOUTH) || checkFrame(block, BlockFace.SOUTH, player);
|
sign2 = checkSign(block, BlockFace.SOUTH) || checkFrame(block, BlockFace.SOUTH, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sign1 && sign2)) {
|
if (!(sign1 && sign2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for maximal chair width (only for stairs)
|
// Check for maximal chair width (only for stairs)
|
||||||
if (plugin.maxChairWidth > 0 && stairs != null) {
|
if (plugin.maxChairWidth > 0 && stairs != null) {
|
||||||
if (stairs.getDescendingDirection() == BlockFace.NORTH || stairs.getDescendingDirection() == BlockFace.SOUTH) {
|
if (stairs.getDescendingDirection() == BlockFace.NORTH || stairs.getDescendingDirection() == BlockFace.SOUTH) {
|
||||||
chairwidth += getChairWidth(block, BlockFace.EAST);
|
chairwidth += getChairWidth(block, BlockFace.EAST);
|
||||||
chairwidth += getChairWidth(block, BlockFace.WEST);
|
chairwidth += getChairWidth(block, BlockFace.WEST);
|
||||||
} else if (stairs.getDescendingDirection() == BlockFace.EAST || stairs.getDescendingDirection() == BlockFace.WEST) {
|
} else if (stairs.getDescendingDirection() == BlockFace.EAST || stairs.getDescendingDirection() == BlockFace.WEST) {
|
||||||
chairwidth += getChairWidth(block, BlockFace.NORTH);
|
chairwidth += getChairWidth(block, BlockFace.NORTH);
|
||||||
chairwidth += getChairWidth(block, BlockFace.SOUTH);
|
chairwidth += getChairWidth(block, BlockFace.SOUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chairwidth > plugin.maxChairWidth) {
|
if (chairwidth > plugin.maxChairWidth) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location getSitLocation(Block block, Float playerYaw)
|
private Location getSitLocation(Block block, Float playerYaw)
|
||||||
{
|
{
|
||||||
double sh = 0.7;
|
double sh = 0.7;
|
||||||
|
|
||||||
for (ChairBlock cb : plugin.allowedBlocks) {
|
for (ChairBlock cb : plugin.allowedBlocks) {
|
||||||
if (cb.getMat().equals(block.getType())) {
|
if (cb.getMat().equals(block.getType())) {
|
||||||
sh = cb.getSitHeight();
|
sh = cb.getSitHeight();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stairs stairs = null;
|
Stairs stairs = null;
|
||||||
if (block.getState().getData() instanceof Stairs) {
|
if (block.getState().getData() instanceof Stairs) {
|
||||||
stairs = (Stairs) block.getState().getData();
|
stairs = (Stairs) block.getState().getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
Location plocation = block.getLocation().clone();
|
Location plocation = block.getLocation().clone();
|
||||||
plocation.add(0.5D, (sh - 0.5D), 0.5D);
|
plocation.add(0.5D, (sh - 0.5D), 0.5D);
|
||||||
|
|
||||||
// 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) {
|
||||||
switch (stairs.getDescendingDirection()) {
|
switch (stairs.getDescendingDirection()) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
plocation.setYaw(180);
|
plocation.setYaw(180);
|
||||||
break;
|
break;
|
||||||
case EAST:
|
case EAST:
|
||||||
plocation.setYaw(-90);
|
plocation.setYaw(-90);
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
plocation.setYaw(0);
|
plocation.setYaw(0);
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
plocation.setYaw(90);
|
plocation.setYaw(90);
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plocation.setYaw(playerYaw);
|
plocation.setYaw(playerYaw);
|
||||||
}
|
}
|
||||||
return plocation;
|
return plocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isValidChair(Block block) {
|
private boolean isValidChair(Block block) {
|
||||||
for (ChairBlock cb : plugin.allowedBlocks) {
|
for (ChairBlock cb : plugin.allowedBlocks) {
|
||||||
if (cb.getMat().equals(block.getType())) {
|
if (cb.getMat().equals(block.getType())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSitting(Player player) {
|
private boolean isSitting(Player player) {
|
||||||
return plugin.getPlayerSitData().isSitting(player);
|
return plugin.getPlayerSitData().isSitting(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getChairWidth(Block block, BlockFace face) {
|
private int getChairWidth(Block block, BlockFace face) {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
// Go through the blocks next to the clicked block and check if there are any further stairs.
|
// Go through the blocks next to the clicked block and check if there are any further stairs.
|
||||||
for (int i = 1; i <= plugin.maxChairWidth; i++) {
|
for (int i = 1; i <= plugin.maxChairWidth; i++) {
|
||||||
Block relative = block.getRelative(face, i);
|
Block relative = block.getRelative(face, i);
|
||||||
if (relative.getState().getData() instanceof Stairs) {
|
if (relative.getState().getData() instanceof Stairs) {
|
||||||
if (isValidChair(relative) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) {
|
if (isValidChair(relative) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) {
|
||||||
width++;
|
width++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkSign(Block block, BlockFace face) {
|
private boolean checkSign(Block block, BlockFace face) {
|
||||||
// Go through the blocks next to the clicked block and check if are signs on the end.
|
// Go through the blocks next to the clicked block and check if are signs on the end.
|
||||||
for (int i = 1; i <= 100; i++) {
|
for (int i = 1; i <= 100; i++) {
|
||||||
Block relative = block.getRelative(face, i);
|
Block relative = block.getRelative(face, i);
|
||||||
if (checkDirection(block, relative)) {
|
if (checkDirection(block, relative)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plugin.validSigns.contains(relative.getType())) {
|
if (plugin.validSigns.contains(relative.getType())) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkDirection(Block block1, Block block2) {
|
private boolean checkDirection(Block block1, Block block2) {
|
||||||
if (block1.getState().getData() instanceof Stairs
|
if (block1.getState().getData() instanceof Stairs
|
||||||
&& block2.getState().getData() instanceof Stairs) {
|
&& block2.getState().getData() instanceof Stairs) {
|
||||||
if (((Stairs) block1.getState().getData()).getDescendingDirection()
|
if (((Stairs) block1.getState().getData()).getDescendingDirection()
|
||||||
.equals(((Stairs) block2.getState().getData()).getDescendingDirection())) {
|
.equals(((Stairs) block2.getState().getData()).getDescendingDirection())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkFrame(Block block, BlockFace face, Player player) {
|
private boolean checkFrame(Block block, BlockFace face, Player player) {
|
||||||
// Go through the blocks next to the clicked block and check if are signs on the end.
|
// Go through the blocks next to the clicked block and check if are signs on the end.
|
||||||
|
|
||||||
for (int i = 1; i <= 100; i++) {
|
for (int i = 1; i <= 100; i++) {
|
||||||
Block relative = block.getRelative(face, i);
|
Block relative = block.getRelative(face, i);
|
||||||
if (checkDirection(block, relative)) {
|
if (checkDirection(block, relative)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (relative.getType().equals(Material.AIR)) {
|
if (relative.getType().equals(Material.AIR)) {
|
||||||
int x = relative.getLocation().getBlockX();
|
int x = relative.getLocation().getBlockX();
|
||||||
int y = relative.getLocation().getBlockY();
|
int y = relative.getLocation().getBlockY();
|
||||||
int z = relative.getLocation().getBlockZ();
|
int z = relative.getLocation().getBlockZ();
|
||||||
for (Entity e : player.getNearbyEntities(plugin.distance, plugin.distance, plugin.distance)) {
|
for (Entity e : player.getNearbyEntities(plugin.distance, plugin.distance, plugin.distance)) {
|
||||||
if (e instanceof ItemFrame && plugin.validSigns.contains(Material.ITEM_FRAME)) {
|
if (e instanceof ItemFrame && plugin.validSigns.contains(Material.ITEM_FRAME)) {
|
||||||
int x2 = e.getLocation().getBlockX();
|
int x2 = e.getLocation().getBlockX();
|
||||||
int y2 = e.getLocation().getBlockY();
|
int y2 = e.getLocation().getBlockY();
|
||||||
int z2 = e.getLocation().getBlockZ();
|
int z2 = e.getLocation().getBlockZ();
|
||||||
if (x == x2 && y == y2 && z == z2) {
|
if (x == x2 && y == y2 && z == z2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,53 +15,53 @@ import com.cnaude.chairs.core.Chairs;
|
|||||||
|
|
||||||
public class TryUnsitEventListener implements Listener {
|
public class TryUnsitEventListener implements Listener {
|
||||||
|
|
||||||
public Chairs plugin;
|
public Chairs plugin;
|
||||||
|
|
||||||
public TryUnsitEventListener(Chairs plugin) {
|
public TryUnsitEventListener(Chairs plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||||
plugin.getPlayerSitData().unsitPlayerNow(player);
|
plugin.getPlayerSitData().unsitPlayerNow(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||||
plugin.getPlayerSitData().unsitPlayerNow(player);
|
plugin.getPlayerSitData().unsitPlayerNow(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
public void onExitVehicle(VehicleExitEvent e) {
|
public void onExitVehicle(VehicleExitEvent e) {
|
||||||
if (e.getVehicle().getPassenger() instanceof Player) {
|
if (e.getVehicle().getPassenger() instanceof Player) {
|
||||||
final Player player = (Player) e.getVehicle().getPassenger();
|
final Player player = (Player) e.getVehicle().getPassenger();
|
||||||
if (plugin.getPlayerSitData().isSitting(player)) {
|
if (plugin.getPlayerSitData().isSitting(player)) {
|
||||||
plugin.getPlayerSitData().unsitPlayerNormal(player);
|
plugin.getPlayerSitData().unsitPlayerNormal(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true)
|
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
Block b = event.getBlock();
|
Block b = event.getBlock();
|
||||||
if (plugin.getPlayerSitData().isBlockOccupied(b)) {
|
if (plugin.getPlayerSitData().isBlockOccupied(b)) {
|
||||||
Player player = plugin.getPlayerSitData().getPlayerOnChair(b);
|
Player player = plugin.getPlayerSitData().getPlayerOnChair(b);
|
||||||
plugin.getPlayerSitData().unsitPlayerForce(player);
|
plugin.getPlayerSitData().unsitPlayerForce(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,119 +21,119 @@ import com.cnaude.chairs.core.Chairs;
|
|||||||
*/
|
*/
|
||||||
public class ChairEffects {
|
public class ChairEffects {
|
||||||
|
|
||||||
private Chairs plugin;
|
private Chairs plugin;
|
||||||
private int healTaskID = -1;
|
private int healTaskID = -1;
|
||||||
private int pickupTaskID = -1;
|
private int pickupTaskID = -1;
|
||||||
|
|
||||||
|
|
||||||
public ChairEffects(Chairs plugin) {
|
public ChairEffects(Chairs plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startHealing() {
|
public void startHealing() {
|
||||||
healEffectsTask();
|
healEffectsTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelHealing() {
|
public void cancelHealing() {
|
||||||
if (healTaskID != -1) {
|
if (healTaskID != -1) {
|
||||||
plugin.getServer().getScheduler().cancelTask(healTaskID);
|
plugin.getServer().getScheduler().cancelTask(healTaskID);
|
||||||
healTaskID = -1;
|
healTaskID = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restartHealing() {
|
public void restartHealing() {
|
||||||
cancelHealing();
|
cancelHealing();
|
||||||
startHealing();
|
startHealing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void healEffectsTask() {
|
private void healEffectsTask() {
|
||||||
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 : Bukkit.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 = (p.getHealth()) / p.getMaxHealth() * 100d;
|
double pHealthPcnt = (p.getHealth()) / p.getMaxHealth() * 100d;
|
||||||
if ((pHealthPcnt < plugin.sitMaxHealth) && (p.getHealth() < p.getMaxHealth())) {
|
if ((pHealthPcnt < plugin.sitMaxHealth) && (p.getHealth() < p.getMaxHealth())) {
|
||||||
double 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();
|
||||||
}
|
}
|
||||||
p.setHealth(newHealth);
|
p.setHealth(newHealth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, plugin.sitHealInterval, plugin.sitHealInterval);
|
}, plugin.sitHealInterval, plugin.sitHealInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPickup() {
|
public void startPickup() {
|
||||||
pickupEffectsTask();
|
pickupEffectsTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelPickup() {
|
public void cancelPickup() {
|
||||||
if (pickupTaskID != -1) {
|
if (pickupTaskID != -1) {
|
||||||
plugin.getServer().getScheduler().cancelTask(pickupTaskID);
|
plugin.getServer().getScheduler().cancelTask(pickupTaskID);
|
||||||
}
|
}
|
||||||
pickupTaskID = -1;
|
pickupTaskID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restartPickup() {
|
public void restartPickup() {
|
||||||
cancelPickup();
|
cancelPickup();
|
||||||
startPickup();
|
startPickup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pickupEffectsTask() {
|
private void pickupEffectsTask() {
|
||||||
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 : Bukkit.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) {
|
||||||
Item item = (Item) entity;
|
Item item = (Item) entity;
|
||||||
if (item.getPickupDelay() == 0) {
|
if (item.getPickupDelay() == 0) {
|
||||||
if (p.getInventory().firstEmpty() != -1) {
|
if (p.getInventory().firstEmpty() != -1) {
|
||||||
PlayerPickupItemEvent pickupevent = new PlayerPickupItemEvent(p, item, 0);
|
PlayerPickupItemEvent pickupevent = new PlayerPickupItemEvent(p, item, 0);
|
||||||
Bukkit.getPluginManager().callEvent(pickupevent);
|
Bukkit.getPluginManager().callEvent(pickupevent);
|
||||||
if (!pickupevent.isCancelled()) {
|
if (!pickupevent.isCancelled()) {
|
||||||
p.getInventory().addItem(item.getItemStack());
|
p.getInventory().addItem(item.getItemStack());
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (entity instanceof ExperienceOrb) {
|
} else if (entity instanceof ExperienceOrb) {
|
||||||
ExperienceOrb eorb = (ExperienceOrb) entity;
|
ExperienceOrb eorb = (ExperienceOrb) entity;
|
||||||
int exptoadd = eorb.getExperience();
|
int exptoadd = eorb.getExperience();
|
||||||
while (exptoadd > 0) {
|
while (exptoadd > 0) {
|
||||||
int localexptoadd = 0;
|
int localexptoadd = 0;
|
||||||
if (p.getExpToLevel() < exptoadd) {
|
if (p.getExpToLevel() < exptoadd) {
|
||||||
localexptoadd = p.getExpToLevel();
|
localexptoadd = p.getExpToLevel();
|
||||||
PlayerExpChangeEvent expchangeevent = new PlayerExpChangeEvent(p, localexptoadd);
|
PlayerExpChangeEvent expchangeevent = new PlayerExpChangeEvent(p, localexptoadd);
|
||||||
Bukkit.getPluginManager().callEvent(expchangeevent);
|
Bukkit.getPluginManager().callEvent(expchangeevent);
|
||||||
p.giveExp(expchangeevent.getAmount());
|
p.giveExp(expchangeevent.getAmount());
|
||||||
if (p.getExpToLevel() <= 0) {
|
if (p.getExpToLevel() <= 0) {
|
||||||
PlayerLevelChangeEvent levelchangeevent = new PlayerLevelChangeEvent(p, p.getLevel(), p.getLevel()+1);
|
PlayerLevelChangeEvent levelchangeevent = new PlayerLevelChangeEvent(p, p.getLevel(), p.getLevel()+1);
|
||||||
Bukkit.getPluginManager().callEvent(levelchangeevent);
|
Bukkit.getPluginManager().callEvent(levelchangeevent);
|
||||||
p.setExp(0);
|
p.setExp(0);
|
||||||
p.giveExpLevels(1);
|
p.giveExpLevels(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localexptoadd = exptoadd;
|
localexptoadd = exptoadd;
|
||||||
PlayerExpChangeEvent expchangeevent = new PlayerExpChangeEvent(p, localexptoadd);
|
PlayerExpChangeEvent expchangeevent = new PlayerExpChangeEvent(p, localexptoadd);
|
||||||
Bukkit.getPluginManager().callEvent(expchangeevent);
|
Bukkit.getPluginManager().callEvent(expchangeevent);
|
||||||
p.giveExp(expchangeevent.getAmount());
|
p.giveExp(expchangeevent.getAmount());
|
||||||
}
|
}
|
||||||
exptoadd -= localexptoadd;
|
exptoadd -= localexptoadd;
|
||||||
}
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},0,1);
|
},0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,33 +15,33 @@ public class CommandRestrict implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event)
|
public void onPlayerCommand(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String playercommand = event.getMessage().toLowerCase();
|
String playercommand = event.getMessage().toLowerCase();
|
||||||
if (plugin.getPlayerSitData().isSitting(player))
|
if (plugin.getPlayerSitData().isSitting(player))
|
||||||
{
|
{
|
||||||
if (plugin.sitDisableAllCommands)
|
if (plugin.sitDisableAllCommands)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(plugin.msgCommandRestricted);
|
player.sendMessage(plugin.msgCommandRestricted);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String disabledCommand : plugin.sitDisabledCommands)
|
for (String disabledCommand : plugin.sitDisabledCommands)
|
||||||
{
|
{
|
||||||
if (disabledCommand.startsWith(playercommand))
|
if (disabledCommand.startsWith(playercommand))
|
||||||
{
|
{
|
||||||
String therest = playercommand.replace(disabledCommand, "");
|
String therest = playercommand.replace(disabledCommand, "");
|
||||||
if (therest.isEmpty() || therest.startsWith(" "))
|
if (therest.isEmpty() || therest.startsWith(" "))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(plugin.msgCommandRestricted);
|
player.sendMessage(plugin.msgCommandRestricted);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,24 +12,24 @@ import org.bukkit.entity.Arrow;
|
|||||||
public class NMSAccess {
|
public class NMSAccess {
|
||||||
|
|
||||||
private Class<?> nmsArrowClass;
|
private Class<?> nmsArrowClass;
|
||||||
|
|
||||||
public void setupVehicleArrow() throws Exception {
|
public void setupVehicleArrow() throws Exception {
|
||||||
String pkgname = getClass().getPackage().getName();
|
String pkgname = getClass().getPackage().getName();
|
||||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||||
switch (nmspackageversion) {
|
switch (nmspackageversion) {
|
||||||
case "v1_7_R1": {
|
case "v1_7_R1": {
|
||||||
nmsArrowClass = Class.forName(pkgname+"."+"nms172"+".NMSChairsArrow");
|
nmsArrowClass = Class.forName(pkgname+"."+"nms172"+".NMSChairsArrow");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_6_R3": {
|
case "v1_6_R3": {
|
||||||
nmsArrowClass = Class.forName(pkgname+"."+"nms164"+".NMSChairsArrow");
|
nmsArrowClass = Class.forName(pkgname+"."+"nms164"+".NMSChairsArrow");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("ChairsReloaded is not compatible with your server version");
|
throw new Exception("ChairsReloaded is not compatible with your server version");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Arrow spawnArrow(Location location) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
|
public Arrow spawnArrow(Location location) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
World world = location.getWorld();
|
World world = location.getWorld();
|
||||||
Method getHandle = world.getClass().getDeclaredMethod("getHandle");
|
Method getHandle = world.getClass().getDeclaredMethod("getHandle");
|
||||||
|
@ -7,11 +7,11 @@ import org.bukkit.entity.Arrow;
|
|||||||
public interface NMSChairsArrowInterface {
|
public interface NMSChairsArrowInterface {
|
||||||
|
|
||||||
public void setBukkitEntity(Server server);
|
public void setBukkitEntity(Server server);
|
||||||
|
|
||||||
public Arrow getBukkitArrow();
|
public Arrow getBukkitArrow();
|
||||||
|
|
||||||
public void setArrowLocation(Location location);
|
public void setArrowLocation(Location location);
|
||||||
|
|
||||||
public void addToWorld();
|
public void addToWorld();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.cnaude.chairs.vehiclearrow.nms172;
|
package com.cnaude.chairs.vehiclearrow.nms172;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R1.EntityArrow;
|
||||||
|
import net.minecraft.server.v1_7_R1.World;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||||
@ -7,19 +10,17 @@ import org.bukkit.entity.Arrow;
|
|||||||
|
|
||||||
import com.cnaude.chairs.vehiclearrow.NMSChairsArrowInterface;
|
import com.cnaude.chairs.vehiclearrow.NMSChairsArrowInterface;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R1.EntityArrow;
|
|
||||||
import net.minecraft.server.v1_7_R1.World;
|
|
||||||
|
|
||||||
public class NMSChairsArrow extends EntityArrow implements NMSChairsArrowInterface {
|
public class NMSChairsArrow extends EntityArrow implements NMSChairsArrowInterface {
|
||||||
|
|
||||||
public NMSChairsArrow(World world) {
|
public NMSChairsArrow(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void h() {
|
public void h() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBukkitEntity(Server server) {
|
public void setBukkitEntity(Server server) {
|
||||||
bukkitEntity = new CraftChairsArrow((CraftServer) server, this);
|
bukkitEntity = new CraftChairsArrow((CraftServer) server, this);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user