command manager
This commit is contained in:
parent
786bb682d7
commit
1a0f33dcdb
7 changed files with 126 additions and 107 deletions
34
pom.xml
34
pom.xml
|
@ -54,39 +54,6 @@
|
||||||
<outputDirectory>E:\Files\SB\plugins</outputDirectory>
|
<outputDirectory>E:\Files\SB\plugins</outputDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-obf</id>
|
|
||||||
<configuration>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
|
|
||||||
<reverse>true</reverse>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
|
|
||||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
|
||||||
<remappedClassifierName>remapped-obf</remappedClassifierName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-spigot</id>
|
|
||||||
<configuration>
|
|
||||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
@ -111,7 +78,6 @@
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||||
<classifier>remapped-mojang</classifier>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -35,20 +35,7 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getConfig().options().copyDefaults();
|
getConfig().options().copyDefaults();
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
new VanishCommand();
|
new CommandManager(this).register();
|
||||||
new TestCommand();
|
|
||||||
new AnvilCommand();
|
|
||||||
new ArmorCommand();
|
|
||||||
new MenuCommand();
|
|
||||||
new MessageCommand();
|
|
||||||
new HologramCommand();
|
|
||||||
new CraftCommand();
|
|
||||||
new EnchantingCommand();
|
|
||||||
new BetaCommand();
|
|
||||||
new RankCommand(this);
|
|
||||||
new UtilCommand(this);
|
|
||||||
new WeaponCommand(this);
|
|
||||||
new MinerCommand(this);
|
|
||||||
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
|
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
|
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
|
||||||
|
@ -67,7 +54,6 @@ public final class Main extends JavaPlugin implements Listener {
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
|
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
|
||||||
bossbar.addPlayer(e.getPlayer());
|
bossbar.addPlayer(e.getPlayer());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -1,31 +1,48 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetHealthPacket;
|
import me.night.nullvalkyrie.Main;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static me.night.nullvalkyrie.database.Client.getUser;
|
import static me.night.nullvalkyrie.database.Client.getUser;
|
||||||
|
|
||||||
public class BetaCommand extends Command {
|
public class BetaCommand extends Command {
|
||||||
public BetaCommand() {
|
private Main main;
|
||||||
super(
|
|
||||||
"beta",
|
public BetaCommand(Main main) {
|
||||||
new String[]{"b"},
|
super("beta", new String[]{"b"}, "Beta", "");
|
||||||
"Beta",
|
this.main = main;
|
||||||
""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
getUser("Kaly15");
|
getUser("Kaly15");
|
||||||
if(sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
CraftPlayer p = (CraftPlayer) sender;
|
Player pa = (Player) sender;
|
||||||
ClientboundSetHealthPacket packet = new ClientboundSetHealthPacket(19.5f, 20, 0.0f);
|
CraftPlayer cp = (CraftPlayer) sender;
|
||||||
p.getHandle().connection.send(packet);
|
EntityPlayer ep = cp.getHandle();
|
||||||
|
Entity e = (Entity) ep;
|
||||||
|
PacketPlayOutUpdateHealth packet = new PacketPlayOutUpdateHealth(20f, 20, 5.0f); // health, food, food
|
||||||
|
// saturation
|
||||||
|
ep.b.a(packet); // Sends the Packet
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
pa.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||||
|
TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
|
||||||
|
}
|
||||||
|
}.runTaskTimer(main, 0L, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ public abstract class Command extends BukkitCommand {
|
||||||
this.setAliases(Arrays.asList(aliases));
|
this.setAliases(Arrays.asList(aliases));
|
||||||
this.setDescription(description);
|
this.setDescription(description);
|
||||||
this.setPermission(permission);
|
this.setPermission(permission);
|
||||||
this.setPermission(ChatColor.RED + "You must have" + permission + "in order to use this command");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
|
import me.night.nullvalkyrie.Main;
|
||||||
|
|
||||||
|
public class CommandManager {
|
||||||
|
private Main main;
|
||||||
|
public CommandManager(Main main) {
|
||||||
|
this.main = main;
|
||||||
|
}
|
||||||
|
public void register() {
|
||||||
|
new VanishCommand();
|
||||||
|
new TestCommand();
|
||||||
|
new AnvilCommand();
|
||||||
|
new ArmorCommand();
|
||||||
|
new MenuCommand();
|
||||||
|
new MessageCommand();
|
||||||
|
new HologramCommand();
|
||||||
|
new CraftCommand();
|
||||||
|
new EnchantingCommand();
|
||||||
|
new BetaCommand(main);
|
||||||
|
new RankCommand(main);
|
||||||
|
new UtilCommand(main);
|
||||||
|
new WeaponCommand(main);
|
||||||
|
new MinerCommand(main);
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,9 +24,11 @@ import java.util.*;
|
||||||
|
|
||||||
public class CustomItemEvents implements Listener {
|
public class CustomItemEvents implements Listener {
|
||||||
private Main main;
|
private Main main;
|
||||||
|
|
||||||
public CustomItemEvents(Main main) {
|
public CustomItemEvents(Main main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||||
if (e.getDamager().getType().equals(EntityType.SNOWBALL)) {
|
if (e.getDamager().getType().equals(EntityType.SNOWBALL)) {
|
||||||
|
@ -47,7 +49,7 @@ public class CustomItemEvents implements Listener {
|
||||||
Player player = (Player) e.getDamager();
|
Player player = (Player) e.getDamager();
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if(name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Fabled Widow Sword")) {
|
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Fabled Widow Sword")) {
|
||||||
if (e.getEntity() instanceof Zombie) {
|
if (e.getEntity() instanceof Zombie) {
|
||||||
int zombie = CustomItemManager.loadConfig("ItemData\\WidowSword.yml").getInt("zombie");
|
int zombie = CustomItemManager.loadConfig("ItemData\\WidowSword.yml").getInt("zombie");
|
||||||
e.setDamage(e.getDamage() * (1 + zombie / 100));
|
e.setDamage(e.getDamage() * (1 + zombie / 100));
|
||||||
|
@ -69,13 +71,14 @@ public class CustomItemEvents implements Listener {
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.RARE.getColor() + "Grappling Hook")) {
|
if (name.equalsIgnoreCase(Rarity.RARE.getColor() + "Grappling Hook")) {
|
||||||
if(e.getState().equals(PlayerFishEvent.State.REEL_IN)) {
|
if (e.getState().equals(PlayerFishEvent.State.REEL_IN)) {
|
||||||
Location change = e.getHook().getLocation().subtract(player.getLocation());
|
Location change = e.getHook().getLocation().subtract(player.getLocation());
|
||||||
player.setVelocity(change.toVector().multiply(0.4));
|
player.setVelocity(change.toVector().multiply(0.4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
@ -112,7 +115,7 @@ public class CustomItemEvents implements Listener {
|
||||||
a2.setShooter(player);
|
a2.setShooter(player);
|
||||||
a2.setDamage(50);
|
a2.setDamage(50);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
} else if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
||||||
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
||||||
arrow.setShooter(player);
|
arrow.setShooter(player);
|
||||||
|
@ -137,7 +140,7 @@ public class CustomItemEvents implements Listener {
|
||||||
a2.setShooter(player);
|
a2.setShooter(player);
|
||||||
a2.setDamage(50);
|
a2.setDamage(50);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
} else if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
Arrow arrow = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection());
|
||||||
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
arrow.setVelocity(arrow.getVelocity().multiply(5));
|
||||||
arrow.setShooter(player);
|
arrow.setShooter(player);
|
||||||
|
@ -147,6 +150,7 @@ public class CustomItemEvents implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityShoot(EntityShootBowEvent e) {
|
public void onEntityShoot(EntityShootBowEvent e) {
|
||||||
if (e.getProjectile() instanceof Arrow) {
|
if (e.getProjectile() instanceof Arrow) {
|
||||||
|
@ -156,29 +160,30 @@ public class CustomItemEvents implements Listener {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
|
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
} else if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileHit(ProjectileHitEvent e) {
|
public void onProjectileHit(ProjectileHitEvent e) {
|
||||||
if(e.getEntity().getShooter() instanceof Player) {
|
if (e.getEntity().getShooter() instanceof Player) {
|
||||||
Player shooter = (Player) e.getEntity().getShooter();
|
Player shooter = (Player) e.getEntity().getShooter();
|
||||||
if(shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
||||||
if(e.getHitBlock() == null) {
|
if (e.getHitBlock() == null) {
|
||||||
Location l = e.getHitEntity().getLocation();
|
Location l = e.getHitEntity().getLocation();
|
||||||
e.getEntity().setShooter(shooter);
|
e.getEntity().setShooter(shooter);
|
||||||
e.getHitEntity().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
|
e.getHitEntity().getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 100, false, false);
|
||||||
} else if(e.getHitEntity() == null) {
|
} else if (e.getHitEntity() == null) {
|
||||||
Location l = e.getHitBlock().getLocation();
|
Location l = e.getHitBlock().getLocation();
|
||||||
e.getHitBlock().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false);
|
e.getHitBlock().getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 100, false, false);
|
||||||
}
|
}
|
||||||
} else if(name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
} else if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Explosive Bow")) {
|
||||||
Arrow arrow = (Arrow) e.getEntity();
|
Arrow arrow = (Arrow) e.getEntity();
|
||||||
Location al = arrow.getLocation();
|
Location al = arrow.getLocation();
|
||||||
arrow.setShooter(shooter);
|
arrow.setShooter(shooter);
|
||||||
|
@ -188,17 +193,19 @@ public class CustomItemEvents implements Listener {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) {
|
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void Projectile(ProjectileLaunchEvent e) {
|
public void Projectile(ProjectileLaunchEvent e) {
|
||||||
if(e.getEntity().getShooter() instanceof Player) {
|
if (e.getEntity().getShooter() instanceof Player) {
|
||||||
Player player = (Player) e.getEntity().getShooter();
|
Player player = (Player) e.getEntity().getShooter();
|
||||||
if(player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
||||||
Egg s = (Egg) e.getEntity();
|
Egg s = (Egg) e.getEntity();
|
||||||
|
@ -207,44 +214,49 @@ public class CustomItemEvents implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent e) {
|
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent e) {
|
||||||
int x = e.getBlockClicked().getX() + e.getBlockFace().getModX();
|
int x = e.getBlockClicked().getX() + e.getBlockFace().getModX();
|
||||||
int y = e.getBlockClicked().getY() + e.getBlockFace().getModY();
|
int y = e.getBlockClicked().getY() + e.getBlockFace().getModY();
|
||||||
int z = e.getBlockClicked().getZ() + e.getBlockFace().getModZ();
|
int z = e.getBlockClicked().getZ() + e.getBlockFace().getModZ();
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if(player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite Water Bucket")) {
|
if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite Water Bucket")) {
|
||||||
e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.WATER);
|
e.getPlayer().getWorld().getBlockAt(x, y, z).setType(Material.WATER);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite LAVA Bucket")) {
|
} else if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite LAVA Bucket")) {
|
||||||
e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.LAVA);
|
e.getPlayer().getWorld().getBlockAt(x, y, z).setType(Material.LAVA);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location l;
|
private Location l;
|
||||||
private boolean spawnable = false;
|
private boolean spawnable = false;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDamage(EntityDamageByEntityEvent e) {
|
public void onDamage(EntityDamageByEntityEvent e) {
|
||||||
if(e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player) {
|
||||||
Player player = (Player) e.getEntity();
|
Player player = (Player) e.getEntity();
|
||||||
if((player.getHealth() - e.getDamage()) <= 0) {
|
if ((player.getHealth() - e.getDamage()) <= 0) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Location loc = player.getWorld().getBlockAt(-3,23,-3).getLocation();
|
Location loc = player.getWorld().getBlockAt(-3, 23, -3).getLocation();
|
||||||
player.teleport(loc);
|
player.teleport(loc);
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.sendMessage(e.getDamager() instanceof Player ? ChatColor.RED + player.getName() + " has been killed by " + e.getDamager().getName() : ChatColor.RED + player.getName() + " died");
|
p.sendMessage(e.getDamager() instanceof Player
|
||||||
p.hidePlayer(player);
|
? ChatColor.RED + player.getName() + " has been killed by " + e.getDamager().getName()
|
||||||
}
|
: ChatColor.RED + player.getName() + " died");
|
||||||
new BukkitRunnable() {
|
p.hidePlayer(player);
|
||||||
@Override
|
}
|
||||||
public void run() {
|
new BukkitRunnable() {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
@Override
|
||||||
p.showPlayer(player);
|
public void run() {
|
||||||
}
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
player.setHealth(20);
|
p.showPlayer(player);
|
||||||
|
}
|
||||||
|
player.setHealth(20);
|
||||||
// while(!spawnable) {
|
// while(!spawnable) {
|
||||||
// l = generateRandomCoord(9, Bukkit.getWorld("world"));
|
// l = generateRandomCoord(9, Bukkit.getWorld("world"));
|
||||||
// if(isSpawnable(l)) {
|
// if(isSpawnable(l)) {
|
||||||
|
@ -252,27 +264,34 @@ public class CustomItemEvents implements Listener {
|
||||||
// player.teleport(l);
|
// player.teleport(l);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
player.teleport(generateRandomCoord(9, Bukkit.getWorld("world")));
|
player.teleport(generateRandomCoord(9, Bukkit.getWorld("world")));
|
||||||
}
|
}
|
||||||
}.runTaskLater(main, 100L);
|
}.runTaskLater(main, 100L);
|
||||||
run(player, new int[]{5});
|
run(player, new int[]{5});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location generateRandomCoord(int size, World world) {
|
public Location generateRandomCoord(int size, World world) {
|
||||||
int ranX = SpawnCommand.getRandomWithNeg(size), ranZ = SpawnCommand.getRandomWithNeg(size);
|
int ranX = SpawnCommand.getRandomWithNeg(size), ranZ = SpawnCommand.getRandomWithNeg(size);
|
||||||
Block block = world.getHighestBlockAt(ranX, ranZ);
|
Block block = world.getHighestBlockAt(ranX, ranZ);
|
||||||
return block.getLocation();
|
return block.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSpawnable(Location loc) {
|
public boolean isSpawnable(Location loc) {
|
||||||
Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(), upperBlock = loc.clone().add(0, 2, 0).getBlock();
|
Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(),
|
||||||
return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid();
|
upperBlock = loc.clone().add(0, 2, 0).getBlock();
|
||||||
|
return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid()
|
||||||
|
&& upperBlock.isPassable() && !upperBlock.isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int taskID;
|
private int taskID;
|
||||||
|
|
||||||
public void run(Player player, int[] a) {
|
public void run(Player player, int[] a) {
|
||||||
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> {
|
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> {
|
||||||
player.sendTitle(ChatColor.RED +"YOU DIED!",ChatColor.GREEN +"You will revive in " + a[0] + " seconds",0,20,0);
|
player.sendTitle(ChatColor.RED + "YOU DIED!", ChatColor.GREEN + "You will revive in " + a[0] + " seconds",
|
||||||
|
0, 20, 0);
|
||||||
a[0]--;
|
a[0]--;
|
||||||
if (a[0] == 0) {
|
if (a[0] == 0) {
|
||||||
Bukkit.getScheduler().cancelTask(taskID);
|
Bukkit.getScheduler().cancelTask(taskID);
|
||||||
|
@ -281,12 +300,14 @@ public class CustomItemEvents implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<UUID, Merchant> villagerlist = new HashMap<>();
|
private final Map<UUID, Merchant> villagerlist = new HashMap<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(PlayerInteractEntityEvent e) {
|
public void onClick(PlayerInteractEntityEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
Entity clickedEntity = e.getRightClicked();
|
Entity clickedEntity = e.getRightClicked();
|
||||||
if (clickedEntity instanceof Creeper) {
|
if (clickedEntity instanceof Creeper) {
|
||||||
if (p.getInventory().getItemInMainHand().getType() != Material.STICK) return;
|
if (p.getInventory().getItemInMainHand().getType() != Material.STICK)
|
||||||
|
return;
|
||||||
clickedEntity.remove();
|
clickedEntity.remove();
|
||||||
Location loc = clickedEntity.getLocation();
|
Location loc = clickedEntity.getLocation();
|
||||||
Villager villager = (Villager) p.getWorld().spawnEntity(loc, EntityType.VILLAGER);
|
Villager villager = (Villager) p.getWorld().spawnEntity(loc, EntityType.VILLAGER);
|
||||||
|
@ -309,7 +330,8 @@ public class CustomItemEvents implements Listener {
|
||||||
}
|
}
|
||||||
if (e.getRightClicked() instanceof Villager) {
|
if (e.getRightClicked() instanceof Villager) {
|
||||||
Merchant merchant = villagerlist.get(clickedEntity.getUniqueId());
|
Merchant merchant = villagerlist.get(clickedEntity.getUniqueId());
|
||||||
if (merchant == null) return;
|
if (merchant == null)
|
||||||
|
return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.openMerchant(merchant, true);
|
p.openMerchant(merchant, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,7 @@ main: me.night.nullvalkyrie.Main
|
||||||
api-version: 1.18
|
api-version: 1.18
|
||||||
authors: [ NightKaly, Leocthl ]
|
authors: [ NightKaly, Leocthl ]
|
||||||
description: Null Valkyrie
|
description: Null Valkyrie
|
||||||
website: https://github.com/night0721/nullvalkyrie
|
website: https://github.com/night0721/nullvalkyrie
|
||||||
|
permissions:
|
||||||
|
nv.command.use:
|
||||||
|
default: true
|
||||||
|
|
Loading…
Reference in a new issue