Pan only work on water

This commit is contained in:
Jimmy 2021-05-19 17:43:58 +12:00
parent 8e6dcee55f
commit 064321ffd2
1 changed files with 8 additions and 11 deletions

View File

@ -1,16 +1,13 @@
package gg.wildfrontier.goldpanning;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -24,8 +21,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.entity.Player;
public class GoldPanning extends JavaPlugin implements Listener, CommandExecutor{
Set<String> pans = new HashSet<String>();
public FileConfiguration config;
@ -35,9 +30,7 @@ public class GoldPanning extends JavaPlugin implements Listener, CommandExecutor
public void onEnable(){
getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
locadConfig();
locadConfig();
}
private void locadConfig() {
@ -61,13 +54,18 @@ public class GoldPanning extends JavaPlugin implements Listener, CommandExecutor
@EventHandler
public void panEvent(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
Action action = event.getAction();
Block block = event.getClickedBlock().getRelative(event.getBlockFace());
//check if item is a pan that has been right clicked
if(item == null || !config.contains("pans."+item.getType().name()) || !action.equals(Action.RIGHT_CLICK_BLOCK))
return;
//check water is clicked
if(block.getType() != Material.WATER)
return;
//get pan name
String name = item.getType().name();
@ -86,7 +84,6 @@ public class GoldPanning extends JavaPlugin implements Listener, CommandExecutor
event.setCancelled(true);
}
}
}