我RuneCraft
在包中命名的主类中有这个com.mcvigor
:
public static ArrayList<String> prospPlayers = new ArrayList<String>();
我在另一个名为MiningListener
package的类中有这个com.mcvigor.listeners
:
` public void playerRClickOre(PlayerInteractEvent event) { //Ore Interactions
final Player p = event.getPlayer();
if(event.getPlayer().isOp()) return;
if(RuneCraft.prospPlayers.contains(p.getName())) return;
if(isClickedBlockMineral(event) && event.getAction() == Action.LEFT_CLICK_BLOCK && !hasPickaxe(p)) { //block is mineral, player left clicked it, no pickaxe
p.sendMessage(ChatColor.DARK_RED + "You need a pickaxe to mine this."); // ADD CHECKS FOR PICKAXE REQUIRED LEVEL 2 USE
}
if(isClickedBlockMineral(event) && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
switch(event.getClickedBlock().getType()) {
case CLAY: //clay
RuneCraft.prospPlayers.add(p.getName());
p.sendMessage(ChatColor.DARK_RED + "You examine the rock for ores...");
Bukkit.getScheduler().runTaskLater(plugin, new Runnable(){
public void run() {
p.sendMessage(ChatColor.GRAY + "This rock contains" + ChatColor.DARK_RED + " clay" + ChatColor.GRAY + ".");
}
}, 3*20L); // TODO: Change time
RuneCraft.prospPlayers.remove(p.getName());
break;`
在这之下还有其他的东西,但这并不重要。问题是当我勘探或检查矿石的岩石时,它应该将我添加到列表中,如果我再次尝试这样做,它不会让我直到我完成勘探(它从 ArrayList 中删除我的名字) .
为什么会这样?
是if(RuneCraft.prospPlayers.contains(p.getName())) return;
问题吗?