本文整理匯總了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);
}
}
}