本文整理汇总了Java中org.bukkit.event.vehicle.VehicleDamageEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java VehicleDamageEvent.setCancelled方法的具体用法?Java VehicleDamageEvent.setCancelled怎么用?Java VehicleDamageEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.vehicle.VehicleDamageEvent
的用法示例。
在下文中一共展示了VehicleDamageEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onVehicleDamageEvent
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleDamageEvent(VehicleDamageEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info(e.getAttacker().getType().toString());
}
if (Util.inWorld(e.getVehicle())) {
if (!(e.getAttacker() instanceof Player)) {
return;
}
Player p = (Player) e.getAttacker();
if (actionAllowed(p, e.getVehicle().getLocation(), SettingsFlag.BREAK_BLOCKS)) {
return;
}
// Not allowed
Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
e.setCancelled(true);
}
}
示例2: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event) {
EntityProtection entityProtection = this.module.getProtectManager().getEntityProtection(event.getVehicle().getType(), event.getVehicle().getUniqueId());
if(entityProtection.exists()) {
if(event.getAttacker() instanceof Player) {
Player player = (Player) event.getAttacker();
if(entityProtection.getOwner().equals(player.getUniqueId()) || player.hasPermission(ProtectPermissions.MODIFY_ALL)) {
return;
}
sendMessage(player, "protect.entity-protected-by", getDisplayName(this.module.getManager().getUsername(entityProtection.getOwner()), event.getVehicle().getWorld().getName()));
}
event.setCancelled(true);
}
}
示例3: onVehicleDamageEvent
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleDamageEvent(VehicleDamageEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info(e.getAttacker().getType().toString());
}
if (inWorld(e.getVehicle())) {
if (!(e.getAttacker() instanceof Player)) {
return;
}
Player p = (Player) e.getAttacker();
if (actionAllowed(p, e.getVehicle().getLocation(), SettingsFlag.BREAK_BLOCKS)) {
return;
}
// Not allowed
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
示例4: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVehicleDamage(final VehicleDamageEvent event) {
debug("VehicleDamageEvent triggered!");
if (event.getAttacker() == null) {
// If the attacker is unknown atleast check if the damaged entity is protected and cancel event
Optional<EntityProtection> prot = this.module.cache.getByUniqueId(event.getVehicle().getUniqueId());
if (prot.isPresent()) {
event.setCancelled(true);
debug("onVehicleDamage("+event.getVehicle().getType()+")",
"Cancelled event because entity is protected and damager unknown!");
}
return;
}
final Entity damager = Utility.getRealDamager(event.getAttacker());
if (!(damager instanceof Player)) { return; }
debug("Determined real damager: " + damager.getName());
if (!this.canInteract(event.getVehicle(), (Player)damager)) { event.setCancelled(true); }
}
示例5: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event) {
if (event.getAttacker() != null && event.getAttacker() instanceof Player) {
if (isSpectating((Player) event.getAttacker())) {
event.setCancelled(true);
}
}
}
示例6: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event) {
if (event.getAttacker() instanceof Player) {
Player player = (Player) event.getAttacker();
if (isPlayerSpectator(player)) {
event.setCancelled(true);
}
}
}
示例7: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
/**
* Prevents a player that can't interact from damaging vehicles.
*
* @param event The event.
*/
@EventHandler(ignoreCancelled = true)
public void onVehicleDamage(VehicleDamageEvent event) {
if (event.getActor() instanceof Player && !canInteract((Player) event.getActor())) {
event.setCancelled(true);
}
}
示例8: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
/**
* Prevents damaging vehicles outside of the game area
* @param event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleDamage(final VehicleDamageEvent event) {
if (!(event.getAttacker() instanceof Player)) {
return;
}
Player player = (Player)event.getAttacker();
if (player.getWorld().equals(getBeaconzWorld())) {
if (getGameMgr().getGame(event.getVehicle().getLocation()) == null) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + Lang.errorYouCannotDoThat);
}
}
}
示例9: on
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void on(VehicleDamageEvent e) {
if (breakVehicleEnabled || !(e.getAttacker() instanceof Player)) {
return;
}
Player player = (Player) e.getAttacker();
if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) {
return;
}
e.setCancelled(true);
player.sendMessage(tr("\u00a7eYou cannot break vehicles while being a visitor!"));
}
示例10: onClick
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
/**
* @param e
* This event check throws the boat at a player when they hit it
* unless someone is in it
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onClick(VehicleDamageEvent e) {
// plugin.getLogger().info("Damage event " + e.getDamage());
// Find out what block is being clicked
Vehicle boat = e.getVehicle();
if (!(boat instanceof Boat)) {
return;
}
if (!boat.isEmpty()) {
return;
}
final World playerWorld = boat.getWorld();
if (!playerWorld.getName().equalsIgnoreCase(Settings.worldName)) {
// Not the right world
return;
}
// plugin.getLogger().info("Boat ");
// Find out who is doing the clicking
if (!(e.getAttacker() instanceof Player)) {
// If a creeper blows up the boat, tough cookies!
return;
}
Player p = (Player) e.getAttacker();
if (p == null) {
return;
}
// Try to remove the boat and throw it at the player
Location boatSpot = new Location(boat.getWorld(), boat.getLocation().getX(), boat.getLocation().getY() + 2, boat.getLocation().getZ());
Location throwTo = new Location(boat.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 1, p.getLocation().getZ());
ItemStack newBoat = new ItemStack(Material.BOAT, 1);
// Find the direction the boat should move in
Vector dir = throwTo.toVector().subtract(boatSpot.toVector()).normalize();
dir = dir.multiply(0.5);
Entity newB = boat.getWorld().dropItem(boatSpot, newBoat);
newB.setVelocity(dir);
boat.remove();
e.setCancelled(true);
}
示例11: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVehicleDamage(VehicleDamageEvent e) {
if (e.getAttacker() instanceof Player) {
Player player = (Player) e.getAttacker();
User u = Necessities.getUM().getUser(player.getUniqueId());
YamlConfiguration config = Necessities.getInstance().getConfig();
if (config.contains("Necessities.Guilds") && config.getBoolean("Necessities.Guilds") && !player.hasPermission("Necessities.guilds.admin")) {
Guild g = Necessities.getGM().chunkOwner(e.getVehicle().getLocation().getChunk());
if (g != null && u.getGuild() != g)
e.setCancelled(true);
}
}
}
示例12: VehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void VehicleDamage(final VehicleDamageEvent event)
{
if (!(event.getAttacker() instanceof Player))
return;
final Player player = (Player) event.getAttacker();
if (plugin.isLoggedIn(player))
return;
event.setCancelled(true);
plugin.sendAuthReminderMessage(player);
}
示例13: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
/**
* Stops players trying to break entities such as Minecarts, Boats, etc.
*/
@EventHandler (priority = EventPriority.HIGHEST)
public void onVehicleDamage(final VehicleDamageEvent e)
{
if (e.getAttacker() instanceof Player && p.getPlayerData((Player) e.getAttacker()).isSpectating())
{
e.setCancelled(true);
}
}
示例14: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleDamage(final VehicleDamageEvent event) {
if(freeze.isFrozen(event.getAttacker())) {
event.setCancelled(true);
}
}
示例15: onVehicleDamage
import org.bukkit.event.vehicle.VehicleDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event) {
if (event.getAttacker() instanceof Player && isObserver((Player) event.getAttacker())) {
event.setCancelled(true);
}
}