本文整理汇总了Java中org.bukkit.entity.Snowball类的典型用法代码示例。如果您正苦于以下问题:Java Snowball类的具体用法?Java Snowball怎么用?Java Snowball使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Snowball类属于org.bukkit.entity包,在下文中一共展示了Snowball类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shoot
import org.bukkit.entity.Snowball; //导入依赖的package包/类
public void shoot(Player player){
setAttackTimer(getAttackTimer() + System.currentTimeMillis() - getLastAttackTimer());
setLastAttackTimer(System.currentTimeMillis());
if(getAttackTimer() < getShootCooldown()) return;
/*if (hasBullets()) {
System.out.println("Tiene balas: " + Integer.parseInt(lore.get(lore.size() - 1).split(" ")[1]));
youShotM8();
}*/
Snowball snowball = player.getWorld().spawn(player.getEyeLocation(), Snowball.class);
snowball.setVelocity(player.getLocation().getDirection().multiply(distance()));
snowball.setShooter(player);
snowball.setMetadata("twd", new FixedMetadataValue(WCTWD.getInstance(), "weapon_" + getId()));
//
player.playSound(player.getLocation(), sound, 1, 1);
particle.display(particleData, 0, 0, 0, 1, 3, player.getLocation(), 20);
}
示例2: onEntityDamage
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
e.setDamage(e.getDamage() + damage);
if (effect != null) {
((LivingEntity) e.getEntity()).addPotionEffect(effect);
}
}
if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
e.setDamage(e.getDamage() + damage);
}
if ((e.getDamager() instanceof Snowball) && (((Snowball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
e.setDamage(e.getDamage() + damage);
}
}
示例3: test
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@Test
public void test() {
final Object[] random = {
// Java
(byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37,
"String",
// Skript
Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER,
new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000),
new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}),
new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50),
// Bukkit - simple classes only
GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL,
// there is also at least one variable for each class on my test server which are tested whenever the server shuts down.
};
for (final Object o : random) {
Classes.serialize(o); // includes a deserialisation test
}
}
示例4: testSnowballDamage
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testSnowballDamage() {
dut.start();
List<Player> damagers = dut.getSortedDamagers(player);
assertEquals(0, damagers.size());
Snowball snowball = mock(Snowball.class);
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(snowball, player, null, 5);
dut.onEntityDamageByEntity(damageEvent);
damagers = dut.getSortedDamagers(player);
assertEquals(0, damagers.size());
when(snowball.getShooter()).thenReturn(d1);
dut.onEntityDamageByEntity(damageEvent);
damagers = dut.getSortedDamagers(player);
assertEquals(1, damagers.size());
assertEquals(d1, damagers.get(0));
}
示例5: onProjectileLaunch
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
if (!(event.getEntity().getShooter() instanceof Player)) {
return;
}
Player player = (Player) event.getEntity().getShooter();
NormalAchievements category;
if (event.getEntity() instanceof Snowball) {
category = NormalAchievements.SNOWBALLS;
} else if (event.getEntity() instanceof Egg) {
category = NormalAchievements.EGGS;
} else {
return;
}
if (plugin.getDisabledCategorySet().contains(category.toString())) {
return;
}
if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
return;
}
updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
示例6: onInteract
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
void onInteract(PlayerInteractEvent e){
Player p = e.getPlayer();
if(p.getItemInHand().getType() == Material.BLAZE_ROD){
if(p.hasPermission("aos.usegun")){
if(Game.CheckArenaState()==ArenaMode.INGAME){
int AmountOfBullet=PlayersStatsboard.IleNaboi(p);
if(AmountOfBullet>0){
if(e.getAction()== Action.RIGHT_CLICK_AIR||e.getAction()==Action.RIGHT_CLICK_BLOCK){
StoringData.snowballsID.put(p.launchProjectile(Snowball.class).getEntityId(),p);
PlayersStatsboard.odejmijNaboje(p);
}
}
}
else{
p.sendMessage(PluginPrefixes.getPrefix()+ChatColor.RED+"Nie mozesz tego teraz uzywac!");
}
}
}
}
示例7: onShovelClick
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
public void onShovelClick(PlayerInteractEvent e){
if(e.getAction() == Action.RIGHT_CLICK_AIR){
if(e.getPlayer().getItemInHand().getType() == Material.IRON_BARDING){
if(GadgetManager.isImmune(e.getPlayer().getName())){
e.getPlayer().sendMessage(ChatColor.BLUE + "Hub > " + ChatColor.GRAY
+ "You are not playing hub games.");
return;
}
if(DexCore.getCurrencySystem().hasEnoughGC(e.getPlayer().getUniqueId().toString(), 2)){
DexCore.getCurrencySystem().removeGC(e.getPlayer().getUniqueId().toString(), 2);
e.getPlayer().launchProjectile(Snowball.class, e.getPlayer().getLocation().getDirection().multiply(2));
}
}
}
}
示例8: projectilehit
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
public void projectilehit(EntityDamageByEntityEvent e){
if((e.getEntity() instanceof Player) && (e.getDamager() instanceof Snowball)){
Player hitp = (Player) e.getEntity();
if(GadgetManager.isImmune(hitp.getName())){
Snowball s = (Snowball) e.getDamager();
Player shooter = (Player) s.getShooter();
shooter.sendMessage(ChatColor.BLUE + "Hub > "
+ ChatColor.GRAY + "Player " + ChatColor.RED + hitp.getName() + ChatColor.GRAY
+ " is not playing hub games!");
return;
}
if(hit.contains(hitp.getName()))
return;
doSnowBallHit(hitp);
}
}
示例9: interact
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW)
public void interact(PlayerInteractEvent event) {
if (event.getPlayer().getItemInHand().getTypeId() == LetItRain.item && event.getPlayer().hasPermission("LetItRain.launcher")){
Entity snow = event.getPlayer().launchProjectile(Snowball.class);
snow.setFireTicks(1000);
snows.add(snow);
}else if(event.getPlayer().getItemInHand().getTypeId() == LetItRain.itemZeus && event.getPlayer().hasPermission("LetItRain.zeus")){
Player player = event.getPlayer();
Location location = player.getTargetBlock((HashSet<Byte>)null, 800).getLocation();
World world = player.getWorld();
world.createExplosion(location, LetItRain.dLightningPower);
world.strikeLightning(location);
}
}
示例10: onEntityDamageByEntityEvent
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
private void onEntityDamageByEntityEvent(
final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player))
return;
Player player = (Player) event.getEntity();
if (!api.getGameManager().isPlayerInGame(player))
return;
Game game = api.getGameManager().getGame(player);
if (event.getDamager() instanceof Snowball) {
if (game.getZombies().getMembers().containsKey(player.getUniqueId())) {
player.damage(1.0);
if (game.getZombies().getMembers().get(player.getUniqueId()) != ZombieType.GARGANTUAR)
player.setVelocity(((Snowball) event.getDamager()).getLocation().getDirection().multiply(0.5));
return;
}
checkCancel(event, player, null, (Projectile) event.getDamager());
} else if (event.getDamager() instanceof Player) {
if (!(event.getDamager() instanceof Player))
return;
checkCancel(event, player, (Player) event.getDamager(), null);
} else if (event.getDamager() instanceof Projectile) {
checkCancel(event, player, null, (Projectile) event.getDamager());
}
}
示例11: onProjectileHitEvent
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
private void onProjectileHitEvent(final ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
if (!(projectile instanceof Snowball))
return;
if (projectile.getShooter() instanceof Player) {
Player player = (Player) projectile.getShooter();
Game game = api.getGameManager().getGame(player);
if (game == null)
return;
if (game.getState() != GameState.PLAYING)
return;
PlantType type = game.getPlants().getMembers().get(player.getUniqueId());
if (type == null)
return;
if (type == PlantType.WINTER_MELON) {
freeze(getZombies(projectile, game), game);
}
}
}
示例12: onProjectileHit
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
Entity entity = event.getEntity();
// Config
float size = plugin.getConfig().getInt("Size of Explosion");
boolean damage = plugin.getConfig().getBoolean("Block Damage");
boolean fire = plugin.getConfig().getBoolean("Set Fire");
if (entity instanceof Snowball) {
Snowball snowball = (Snowball) entity;
Entity shooter = snowball.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
Location sb = snowball.getLocation();
if (plugin.players.contains(player.getName())) {
player.getWorld().createExplosion(sb.getX(), sb.getY(),
sb.getZ(), size, fire, damage);
}
}
}
}
示例13: onSnowballHit
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
public void onSnowballHit(ProjectileHitEvent event) {
if(event.getEntity() instanceof Snowball) {
if(event.getHitBlock() != null && event.getHitBlock().getType() == Material.SNOW_BLOCK) {
event.getHitBlock().breakNaturally(new ItemStack(Material.AIR));
}
}
}
示例14: display
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@Override
public void display()
{
new BukkitRunnable()
{
private int times = 0;
@Override
public void run()
{
Snowball snowball = PaintballDisplayer.this.player.launchProjectile(Snowball.class);
snowball.setVelocity(snowball.getVelocity().multiply(1.5));
snowball.setMetadata("paintball-ball", new FixedMetadataValue(PaintballDisplayer.this.hub, PaintballDisplayer.this.uuid.toString()));
this.times++;
if (this.times == 30)
{
PaintballDisplayer.this.restore();
PaintballDisplayer.this.end();
HandlerList.unregisterAll(PaintballDisplayer.this);
this.cancel();
}
}
}.runTaskTimer(this.hub, 5L, 5L);
}
示例15: projectileLaunch
import org.bukkit.entity.Snowball; //导入依赖的package包/类
@EventHandler
public void projectileLaunch(ProjectileLaunchEvent e) {
Projectile projectile = e.getEntity();
if (projectile instanceof Snowball || projectile instanceof Egg || projectile instanceof Arrow) {
if (projectile.getShooter() instanceof Player) {
GamePlayer shooter = SkyWarsReloaded.getPC().getPlayer(((Player) projectile.getShooter()).getUniqueId());
String effect = shooter.getProjEffect();
if (effect != null) {
if (!effect.equalsIgnoreCase("normal") && shooter.inGame()) {
SkyWarsReloaded.getProjC().addProjectile(projectile, shooter.getProjEffect());
}
}
}
}
}