下面列出了怎么用org.bukkit.entity.minecart.HopperMinecart的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler
public void minecartBreak(VehicleDestroyEvent e) {
Entity entity = e.getVehicle();
if (plugin.getLWC().isProtectable(e.getVehicle().getType())) {
int A = 50000 + entity.getUniqueId().hashCode();
LWC lwc = LWC.getInstance();
Protection protection = lwc.getPhysicalDatabase().loadProtection(entity.getWorld().getName(), A, A, A);
if ((((entity instanceof StorageMinecart)) || ((entity instanceof HopperMinecart)))
&& (protection != null)) {
if (e.getAttacker() instanceof Projectile) {
e.setCancelled(true);
}
Player p = (Player) e.getAttacker();
boolean canAccess = lwc.canAccessProtection(p, protection);
if (canAccess) {
protection.remove();
protection.removeAllPermissions();
protection.removeCache();
return;
}
e.setCancelled(true);
}
}
}
@EventHandler
public void storageMinecraftInventoryOpen(InventoryOpenEvent event) {
InventoryHolder holder = event.getInventory().getHolder();
Player player = (Player) event.getPlayer();
if ((!(holder instanceof StorageMinecart)) && (!(holder instanceof HopperMinecart))) {
return;
}
Entity entity = (Entity) holder;
if (plugin.getLWC().isProtectable(entity.getType())) {
if (!plugin.getLWC().hasPermission(player, "lwc.protect")
&& plugin.getLWC().hasPermission(player, "lwc.deny") && !plugin.getLWC().isAdmin(player)
&& !plugin.getLWC().isMod(player)) {
plugin.getLWC().sendLocale(player, "protection.interact.error.blocked");
event.setCancelled(true);
return;
}
if (onPlayerEntityInteract((Player) event.getPlayer(), entity, event.isCancelled())) {
event.setCancelled(true);
}
}
}
@EventHandler
public void itemFrameItemRemoval(EntityDamageByEntityEvent e) {
if (e.isCancelled())
return;
Entity entity = e.getEntity();
if (plugin.getLWC().isProtectable(e.getEntity().getType())) {
int A = 50000 + entity.getUniqueId().hashCode();
LWC lwc = LWC.getInstance();
Protection protection = lwc.getPhysicalDatabase().loadProtection(entity.getWorld().getName(), A, A, A);
if (!(entity instanceof Player)) {
if (e.getDamager() instanceof Projectile) {
if (protection != null) {
e.setCancelled(true);
}
if ((((entity instanceof StorageMinecart)) || ((entity instanceof HopperMinecart)))
&& (protection != null)) {
e.setCancelled(true);
}
}
if (e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager();
if (protection != null && !lwc.canAccessProtection(p, protection)) {
e.setCancelled(true);
}
if (p.hasPermission("lwc.lockentity." + e.getEntityType())
|| p.hasPermission("lwc.lockentity.all")) {
if (onPlayerEntityInteract(p, entity, e.isCancelled())) {
e.setCancelled(true);
}
}
if ((((entity instanceof StorageMinecart)) || ((entity instanceof HopperMinecart)))
&& (protection != null)) {
e.setCancelled(true);
}
}
}
}
}
public HopperMinecartBlock(HopperMinecart minecart) {
super(minecart);
this.minecart = minecart;
}
public HopperMinecart getMinecart() {
return this.minecart;
}