Compare commits

...

2 Commits

Author SHA1 Message Date
Jimmy b0c0d211f4 Remove debug message 2021-05-19 17:44:20 +12:00
Jimmy 064321ffd2 Pan only work on water 2021-05-19 17:43:58 +12:00
2 changed files with 8 additions and 12 deletions

View File

@ -37,7 +37,6 @@ public class GoldPan implements Runnable {
int adddelaymax = plugin.getConfig().getInt("pans."+pan+".items."+item+".delay.add.max"); int adddelaymax = plugin.getConfig().getInt("pans."+pan+".items."+item+".delay.add.max");
int removedelaymin = plugin.getConfig().getInt("pans."+pan+".items."+item+".delay.remove.min"); int removedelaymin = plugin.getConfig().getInt("pans."+pan+".items."+item+".delay.remove.min");
int removedelaymax = plugin.getConfig().getInt("pans."+pan+".items."+item+".delay.remove.max"); int removedelaymax = plugin.getConfig().getInt("pans."+pan+".items."+item+".delay.remove.max");
plugin.getLogger().log(Level.INFO, item+String.valueOf(chance));
this.items.add(new PanItem(item, chance, adddelaymin, adddelaymax, this.items.add(new PanItem(item, chance, adddelaymin, adddelaymax,
removedelaymin, removedelaymax)); removedelaymin, removedelaymax));

View File

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