本文整理汇总了Java中org.bukkit.event.hanging.HangingBreakEvent.RemoveCause类的典型用法代码示例。如果您正苦于以下问题:Java RemoveCause类的具体用法?Java RemoveCause怎么用?Java RemoveCause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoveCause类属于org.bukkit.event.hanging.HangingBreakEvent包,在下文中一共展示了RemoveCause类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
@EventHandler
public void onHangingBreak(HangingBreakEvent event)
{
if(event.isCancelled())
return;
if(event.getCause() == RemoveCause.ENTITY)
event.setCancelled(true);
}
开发者ID:Limeth,项目名称:Breakpoint,代码行数:9,代码来源:PlayerInteractListener.java
示例2: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHangingBreak(HangingBreakEvent event) {
Hanging hanging = event.getEntity();
if (event.getCause().equals(RemoveCause.OBSTRUCTION)) {
hanging.getLocation().getBlock().breakNaturally();
event.setCancelled(true);
} else if (event.getCause().equals(RemoveCause.EXPLOSION)) {
event.setCancelled(true);
}
}
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:12,代码来源:HangingListener.java
示例3: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
if (event.getCause() == RemoveCause.ENTITY) {
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
if (entityEvent.getRemover() instanceof Player) {
Player remover = (Player) entityEvent.getRemover();
if (remover.isOp() && remover.getGameMode() == GameMode.CREATIVE) {
return;
}
}
}
event.setCancelled(true);
}
开发者ID:PaulBGD,项目名称:MiniMiniGames,代码行数:14,代码来源:WorldListener.java
示例4: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
/**
* On hanging break.
*
* @param event the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onHangingBreak(HangingBreakEvent event) {
if (conf.isOverrideExplosions()) {
// Check for painting
if (event.getCause() == RemoveCause.EXPLOSION) {
Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause());
event.setCancelled(true);
}
}
}
开发者ID:Tabinol,项目名称:Factoid,代码行数:17,代码来源:WorldListener.java
示例5: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
if (event.getCause() == RemoveCause.DEFAULT || event.getCause() == RemoveCause.EXPLOSION)
event.setCancelled(true);
}
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:6,代码来源:EnvironmentManager.java
示例6: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onHangingBreak(HangingBreakEvent event)
{
//don't track in worlds where claims are not enabled
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getEntity().getWorld())) return;
//FEATURE: claimed paintings are protected from breakage
//explosions don't destroy hangings
if(event.getCause() == RemoveCause.EXPLOSION)
{
event.setCancelled(true);
return;
}
//only allow players to break paintings, not anything else (like water and explosions)
if(!(event instanceof HangingBreakByEntityEvent))
{
event.setCancelled(true);
return;
}
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent)event;
//who is removing it?
Entity remover = entityEvent.getRemover();
//again, making sure the breaker is a player
if(!(remover instanceof Player))
{
event.setCancelled(true);
return;
}
//if the player doesn't have build permission, don't allow the breakage
Player playerRemover = (Player)entityEvent.getRemover();
String noBuildReason = GriefPrevention.instance.allowBuild(playerRemover, event.getEntity().getLocation(), Material.AIR);
if(noBuildReason != null)
{
event.setCancelled(true);
GriefPrevention.sendMessage(playerRemover, TextMode.Err, noBuildReason);
}
}
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:44,代码来源:EntityEventHandler.java
示例7: onHangingBreak
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
@EventHandler
public void onHangingBreak(final HangingBreakEvent event) {
if (!this.module.canBeProtected(event.getEntity().getType(), event.getEntity().getLocation())) { return; }
Optional<EntityProtection> prot = this.module.cache.getByUniqueId(event.getEntity().getUniqueId());
if (!prot.isPresent()) { return; }
if (event.getCause().equals(RemoveCause.EXPLOSION) || event.getCause().equals(RemoveCause.OBSTRUCTION)
|| event.getCause().equals(RemoveCause.OBSTRUCTION) || event.getCause().equals(RemoveCause.DEFAULT)) { event.setCancelled(true); return; }
if (event instanceof HangingBreakByEntityEvent) {
Entity breaker = ((HangingBreakByEntityEvent)event).getRemover();
breaker = Utility.getRealDamager(breaker);
if (!(breaker instanceof Player)) { event.setCancelled(true); return; }
if (this.canInteract(event.getEntity(), (Player) breaker)) {
this.module.unprotect(prot.get());
}
else { debug(event.getEntity().getName() + " tried to break hanging!"); event.setCancelled(true); }
}
else {
// Check if leash ib roken
if (!event.getEntity().getType().equals(EntityType.LEASH_HITCH) || !event.getCause().equals(RemoveCause.ENTITY)) { return; }
debug("hangingBreak() called!");
// Leash broken so check if an protected entity was attached to it
final LeashHitch leash = (LeashHitch) event.getEntity();
Entity leashedEntity = null;
final HashSet<Integer> nearbyPlayers = new HashSet<>();
// Find owner & leashholder
for (final Entity entity : leash.getNearbyEntities(16, 16, 16)) {
if (entity instanceof LivingEntity && !(entity instanceof Player)) {
final LivingEntity living = (LivingEntity) entity;
if (living.isLeashed() && living.getLeashHolder().getUniqueId().equals(leash.getUniqueId())) {
debug("Leashholder of " + living.getType() + " is: " + living.getLeashHolder().getType());
leashedEntity = living;
}
}
else if (entity instanceof Player) {
final Optional<CraftoPlayer> player = CraftoPlayer.getPlayer(entity.getUniqueId());
if (!player.isPresent()) { warn("Player " + entity.getName() + " is missing a craftoplayer instance!"); continue; }
nearbyPlayers.add(player.get().getId());
debug("Found a player nearby with id: " + player.get().getId());
}
}
// If leashed was found check protectionse etc
if (leashedEntity != null) {
prot = this.module.cache.getByUniqueId(leashedEntity.getUniqueId());
if (!prot.isPresent()) { debug("failed to find protection for " + leashedEntity.getType()); return; }
debug("Found entityprotection with id: " + prot.get().getId());
if (nearbyPlayers.contains(prot.get().getOwnerId())) { debug("Owner is nearby! Returning..."); return; }
for (final int playerId : nearbyPlayers) {
final Optional<CraftoPlayer> otherPlayer = CraftoPlayer.getPlayer(playerId);
if (!otherPlayer.isPresent()) { continue; }
if (this.module.isAllowedToInteract(prot.get(), otherPlayer.get())) { debug("WhitelistedPlayer nearby! Returning..."); return; }
}
event.setCancelled(true);
}
}
}
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:69,代码来源:EntityProtectionBreakListener.java
示例8: HangingBreakByEntityEvent
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
public HangingBreakByEntityEvent(Hanging hanging, Entity remover) {
super(hanging, RemoveCause.ENTITY);
}
开发者ID:deathcap,项目名称:BedrockAPI,代码行数:4,代码来源:HangingBreakByEntityEvent.java
示例9: HangingBreakEvent
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
public HangingBreakEvent(Hanging hanging, HangingBreakEvent.RemoveCause cause) {
super(hanging);
}
开发者ID:deathcap,项目名称:BedrockAPI,代码行数:4,代码来源:HangingBreakEvent.java
示例10: getCause
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; //导入依赖的package包/类
public HangingBreakEvent.RemoveCause getCause() {
return null;
}
开发者ID:deathcap,项目名称:BedrockAPI,代码行数:4,代码来源:HangingBreakEvent.java
注:本文中的org.bukkit.event.hanging.HangingBreakEvent.RemoveCause类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论