add /spawngiant

This commit is contained in:
Minecon724 2022-02-03 19:27:51 +01:00
parent 57aa85a3fc
commit 2f055e59cf
3 changed files with 23 additions and 3 deletions

View file

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>giants</groupId> <groupId>giants</groupId>
<artifactId>giants</artifactId> <artifactId>giants</artifactId>
<version>22.2.0</version> <version>22.2.1</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>

View file

@ -14,6 +14,9 @@ import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -32,7 +35,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class Main extends JavaPlugin implements Listener { public class Main extends JavaPlugin implements Listener, CommandExecutor {
File configFile = new File(getDataFolder(), "config.yml"); File configFile = new File(getDataFolder(), "config.yml");
FileConfiguration config; FileConfiguration config;
@ -107,6 +110,7 @@ public class Main extends JavaPlugin implements Listener {
} }
} }
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);
getCommand("spawngiant").setExecutor(this);
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -137,6 +141,12 @@ public class Main extends JavaPlugin implements Listener {
} }
} }
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) return true;
spawnGiant(true, ((Player) sender).getLocation());
return true;
}
@EventHandler @EventHandler
public void entitySpawn(EntitySpawnEvent e) { public void entitySpawn(EntitySpawnEvent e) {
if (e.getEntityType() == EntityType.ZOMBIE) { if (e.getEntityType() == EntityType.ZOMBIE) {

View file

@ -2,4 +2,14 @@ name: Giants
version: ${project.version} version: ${project.version}
api-version: 1.18 api-version: 1.18
main: pl.minecon724.giants.Main main: pl.minecon724.giants.Main
author: Minecon724 author: Minecon724
website: https://www.spigotmc.org/resources/giants.99600/
commands:
spawngiant:
description: Spawns a giant at players location.
permission: giants.spawngiant
permission-message: You do not have permission to use this command.
permissions:
giants.spawngiant:
description: Allows to use /spawngiant
default: op