Add reload command
This commit is contained in:
parent
f231eb7237
commit
7df836845d
|
@ -3,31 +3,45 @@ package gg.wildfrontier.goldpanning;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class GoldPanning extends JavaPlugin implements Listener{
|
|
||||||
|
public class GoldPanning extends JavaPlugin implements Listener, CommandExecutor{
|
||||||
HashMap<String, BukkitTask> tasks = new HashMap<String, BukkitTask>();
|
HashMap<String, BukkitTask> tasks = new HashMap<String, BukkitTask>();
|
||||||
@Override
|
public FileConfiguration config;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEnable(){
|
public void onEnable(){
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
this.config = getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(command.getName().equals("gpreload")) {
|
||||||
|
this.config = getConfig();
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Reloaded Gold Panning");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -36,17 +50,16 @@ public class GoldPanning extends JavaPlugin implements Listener{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
if(item == null || !item.getType().equals(Material.BOWL) || !action.equals(Action.RIGHT_CLICK_BLOCK))
|
if(item == null || !config.contains("pans."+item.getType().name()) || !action.equals(Action.RIGHT_CLICK_BLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.getLogger().log(Level.INFO, item.toString());
|
this.getLogger().log(Level.INFO, item.toString());
|
||||||
|
|
||||||
|
String name = "Gold Pan";
|
||||||
|
if(config.contains("pans."+item.getType().name()+".name")) {
|
||||||
Inventory goldpan = Bukkit.createInventory(player, 54, "Gold Pan");
|
name = config.getString("pans."+item.getType().name()+".name");
|
||||||
player.openInventory(goldpan);
|
}
|
||||||
|
new GoldPan(this, player, name);
|
||||||
new PopulatePan(this, goldpan, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
Loading…
Reference in New Issue