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.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
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.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GoldPanning extends JavaPlugin implements Listener{
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
public class GoldPanning extends JavaPlugin implements Listener, CommandExecutor{
|
||||
HashMap<String, BukkitTask> tasks = new HashMap<String, BukkitTask>();
|
||||
@Override
|
||||
public FileConfiguration config;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
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
|
||||
|
@ -36,17 +50,16 @@ public class GoldPanning extends JavaPlugin implements Listener{
|
|||
Player player = event.getPlayer();
|
||||
ItemStack item = event.getItem();
|
||||
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;
|
||||
|
||||
this.getLogger().log(Level.INFO, item.toString());
|
||||
|
||||
|
||||
|
||||
Inventory goldpan = Bukkit.createInventory(player, 54, "Gold Pan");
|
||||
player.openInventory(goldpan);
|
||||
this.getLogger().log(Level.INFO, item.toString());
|
||||
|
||||
new PopulatePan(this, goldpan, player);
|
||||
String name = "Gold Pan";
|
||||
if(config.contains("pans."+item.getType().name()+".name")) {
|
||||
name = config.getString("pans."+item.getType().name()+".name");
|
||||
}
|
||||
new GoldPan(this, player, name);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
Loading…
Reference in New Issue