12
0

Add ExplodingArrows

Dieser Commit ist enthalten in:
jojo 2020-10-23 16:00:15 +02:00
Ursprung 2d348c24b5
Commit 3b817b8f2b
5 geänderte Dateien mit 106 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -60,6 +60,7 @@ public class MissileWars extends JavaPlugin {
new PortalDestructListener();
new WaitingListener();
new FightListener();
new ArrowListener();
new ChatListener();
getCommand("spectate").setExecutor(new CommandSpectate());

Datei anzeigen

@ -25,7 +25,7 @@ import org.bukkit.inventory.ItemStack;
public class Arrows extends SpecialItem {
private final ItemStack item = createItem(Material.ARROW, "§ePfeile", 3);
private final ItemStack item = createItem(Material.ARROW, "§ePfeil", 3);
@Override
public ItemStack getItem() {

Datei anzeigen

@ -0,0 +1,40 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.misslewars.items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ExplodingArrows extends SpecialItem {
private final ItemStack item = createItem(Material.SPECTRAL_ARROW, "§eExplodierender Pfeil", 1);
@Override
public ItemStack getItem() {
return item;
}
@Override
public boolean handleUse(Player p) {
return false;
}
}

Datei anzeigen

@ -0,0 +1,64 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ProjectileHitEvent;
import java.util.EnumSet;
public class ArrowListener extends BasicListener {
public ArrowListener() {
super(EnumSet.of(FightState.FIGHTING));
}
@EventHandler
public void onHit(ProjectileHitEvent e) {
Projectile projectile = e.getEntity();
if (projectile.getType() != EntityType.SPECTRAL_ARROW) {
return;
}
Location location = getLocation(e);
if (location == null) return;
TNTPrimed tnt = e.getEntity().getWorld().spawn(location, TNTPrimed.class);
tnt.setYield(1.0F);
tnt.setIsIncendiary(false);
tnt.setFuseTicks(0);
}
private Location getLocation(ProjectileHitEvent e) {
if (e.getHitEntity() != null) {
return e.getHitEntity().getLocation();
}
if (e.getHitBlock() != null) {
return e.getHitBlock().getLocation();
}
return null;
}
}

Datei anzeigen

@ -31,7 +31,6 @@ import com.sk89q.worldedit.world.World;
import de.steamwar.misslewars.Config;
import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MissileWars;
import de.steamwar.misslewars.items.Missile;
import de.steamwar.misslewars.items.SpecialItem;
import org.bukkit.Bukkit;
import org.bukkit.Location;