added reload config command
This commit is contained in:
parent
3641df3f7e
commit
66870ee42e
@ -1,7 +1,11 @@
|
|||||||
package net.teamonster.tealimit;
|
package net.teamonster.tealimit;
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -12,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Main extends JavaPlugin implements Listener
|
public class Main extends JavaPlugin implements Listener, CommandExecutor
|
||||||
{
|
{
|
||||||
private int breedLimit;
|
private int breedLimit;
|
||||||
private int naturalLimit;
|
private int naturalLimit;
|
||||||
@ -23,9 +27,11 @@ public class Main extends JavaPlugin implements Listener
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
|
Bukkit.getConsoleSender().sendMessage("TeaLimit Enabled");
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
getConfig().options().copyDefaults(true);
|
getConfig().options().copyDefaults(true);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
getCommand("tealimit").setExecutor(this);
|
||||||
|
|
||||||
this.breedLimit = getConfig().getInt("breed-limit");
|
this.breedLimit = getConfig().getInt("breed-limit");
|
||||||
this.naturalLimit = getConfig().getInt("natural-limit");
|
this.naturalLimit = getConfig().getInt("natural-limit");
|
||||||
@ -34,6 +40,10 @@ public class Main extends JavaPlugin implements Listener
|
|||||||
this.spawnerLimit = getConfig().getInt("spawner-limit");
|
this.spawnerLimit = getConfig().getInt("spawner-limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onDisable(){
|
||||||
|
Bukkit.getConsoleSender().sendMessage("TeaLimit Disabled");
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
@ -136,4 +146,20 @@ public class Main extends JavaPlugin implements Listener
|
|||||||
|
|
||||||
return count > limit;
|
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}
|
version: ${project.version}
|
||||||
api-version: 1.15
|
api-version: 1.15
|
||||||
authors: [TeaMaster, Artuto]
|
authors: [TeaMaster, Artuto]
|
||||||
description: Limit entity spawns
|
description: Limit entity spawns
|
||||||
|
|
||||||
|
commands:
|
||||||
|
tealimit:
|
||||||
|
description: Basic Command
|
||||||
|
Loading…
Reference in New Issue
Block a user