本文整理汇总了Java中org.bukkit.entity.Creeper.getTarget方法的典型用法代码示例。如果您正苦于以下问题:Java Creeper.getTarget方法的具体用法?Java Creeper.getTarget怎么用?Java Creeper.getTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Creeper
的用法示例。
在下文中一共展示了Creeper.getTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBreakHanging
import org.bukkit.entity.Creeper; //导入方法依赖的package包/类
/**
* Prevents the breakage of hanging items
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW)
public void onBreakHanging(final HangingBreakByEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info(e.getRemover().toString());
}
if (Util.inWorld(e.getEntity())) {
if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperDamage) {
e.setCancelled(true);
return;
}
// Check if creeper griefing is allowed
if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperGriefing) {
// Find out who the creeper was targeting
Creeper creeper = (Creeper)e.getRemover();
if (creeper.getTarget() instanceof Player) {
Player target = (Player)creeper.getTarget();
// Check if the target is on their own island or not
if (!plugin.getIslands().locationIsOnIsland(target, e.getEntity().getLocation())) {
// They are a visitor tsk tsk
e.setCancelled(true);
return;
}
}
// Check if this creeper was lit by a visitor
if (litCreeper.contains(creeper.getUniqueId())) {
if (DEBUG) {
plugin.getLogger().info("DBEUG: preventing creeper from damaging");
}
e.setCancelled(true);
return;
}
}
if (e.getRemover() instanceof Player) {
Player p = (Player) e.getRemover();
// This permission bypasses protection
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) {
return;
}
// Not allowed
Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
e.setCancelled(true);
}
}
}
示例2: onBreakHanging
import org.bukkit.entity.Creeper; //导入方法依赖的package包/类
/**
* Prevents the breakage of hanging items
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW)
public void onBreakHanging(final HangingBreakByEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info(e.getRemover().toString());
}
if (inWorld(e.getEntity())) {
if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperDamage) {
e.setCancelled(true);
return;
}
// Check if creeper griefing is allowed
if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperGriefing) {
// Find out who the creeper was targeting
Creeper creeper = (Creeper)e.getRemover();
if (creeper.getTarget() instanceof Player) {
Player target = (Player)creeper.getTarget();
// Check if the target is on their own island or not
if (!plugin.getGrid().locationIsOnIsland(target, e.getEntity().getLocation())) {
// They are a visitor tsk tsk
e.setCancelled(true);
return;
}
}
// Check if this creeper was lit by a visitor
if (litCreeper.contains(creeper.getUniqueId())) {
if (DEBUG) {
plugin.getLogger().info("DBEUG: preventing creeper from damaging");
}
e.setCancelled(true);
return;
}
}
if (e.getRemover() instanceof Player) {
Player p = (Player) e.getRemover();
// This permission bypasses protection
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) {
return;
}
// Not allowed
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
}