added reload config command
This commit is contained in:
parent
938db166ee
commit
b2ac9006c8
@ -1,7 +1,11 @@
|
||||
package net.teamonster.tealimit;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -12,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener
|
||||
public class Main extends JavaPlugin implements Listener, CommandExecutor
|
||||
{
|
||||
private int breedLimit;
|
||||
private int naturalLimit;
|
||||
@ -23,9 +27,11 @@ public class Main extends JavaPlugin implements Listener
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
Bukkit.getConsoleSender().sendMessage("TeaLimit Enabled");
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
getCommand("tealimit").setExecutor(this);
|
||||
|
||||
this.breedLimit = getConfig().getInt("breed-limit");
|
||||
this.naturalLimit = getConfig().getInt("natural-limit");
|
||||
@ -34,6 +40,10 @@ public class Main extends JavaPlugin implements Listener
|
||||
this.spawnerLimit = getConfig().getInt("spawner-limit");
|
||||
}
|
||||
|
||||
public void onDisable(){
|
||||
Bukkit.getConsoleSender().sendMessage("TeaLimit Disabled");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
@ -136,4 +146,20 @@ public class Main extends JavaPlugin implements Listener
|
||||
|
||||
return count > limit;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
|
||||
if(cmd.getName().equalsIgnoreCase("tealimit")){
|
||||
if(args.length == 0){
|
||||
sender.sendMessage("Invalid argument!");
|
||||
return false;
|
||||
}
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("reload")){
|
||||
sender.sendMessage("Reloading Configuration");
|
||||
reloadConfig();
|
||||
sender.sendMessage("Configuration Reloaded");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,8 @@ main: net.teamonster.tealimit.Main
|
||||
version: ${project.version}
|
||||
api-version: 1.15
|
||||
authors: [TeaMaster, Artuto]
|
||||
description: Limit entity spawns
|
||||
description: Limit entity spawns
|
||||
|
||||
commands:
|
||||
tealimit:
|
||||
description: Basic Command
|
||||
|
Loading…
Reference in New Issue
Block a user