Java 气泡插件不';行不通

Java 气泡插件不';行不通,java,bukkit,Java,Bukkit,基本上,我正在尝试创建一个插件,允许某人(有烫发)进行/bubble操作,并且无论谁的名字与这个名字相对应,都会得到“bubbled”。这个冒泡基本上是一个拒绝字段(sphere),因此每当args[0](用户名到冒泡)之外的人被快速而突然地抛出时。我不知道你是否见过这个,但是如果你需要更多的概念证明,mineplex.com是一个minecraft服务器,它将这个概念应用到了宝箱中。基本上,只要有人点击它,他们就会被困在一个1x2的区域,每个试图从中取出5个街区的人都会被射出,就像他们被弹回一

基本上,我正在尝试创建一个插件,允许某人(有烫发)进行/bubble操作,并且无论谁的名字与这个名字相对应,都会得到“bubbled”。这个冒泡基本上是一个拒绝字段(sphere),因此每当args[0](用户名到冒泡)之外的人被快速而突然地抛出时。我不知道你是否见过这个,但是如果你需要更多的概念证明,mineplex.com是一个minecraft服务器,它将这个概念应用到了宝箱中。基本上,只要有人点击它,他们就会被困在一个1x2的区域,每个试图从中取出5个街区的人都会被射出,就像他们被弹回一样。这是我想出的代码。我不知道为什么这不起作用,没有任何错误,但它不会抛出它们

注意:我使用的是一个调用这个类的主类(主类称为“main”。另外,这个类称为“Bubble”)

编辑:我刚刚更新了使用hashmaps的代码。它们目前还没有实现,但我想在插件中使用它们

package me.Glowhoo.EpicUtil;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
/*
 * Author =
 * Glowhoo
 * 
 */
public class Bubble implements CommandExecutor, Listener {
private Main plugin;

public Bubble(Main plugin)
{
  this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
    if (cmd.getName().equalsIgnoreCase("bubble"))
    {
        if (sender instanceof Player)
        {
            if (args.length > 0 && args.length <= 2)
            {
            if (Bukkit.getPlayer(args[0]) != null)
            { //Note: I suck with hashmaps.
                HashMap<String, Boolean> bubbles = new HashMap<>(); //Attempted to make a hashmap of the player which has the bubble, and if the bubble is on/off.
                Player victim = (Bukkit.getPlayer(args[0]));
                Bukkit.broadcastMessage(ChatColor.BOLD.GREEN + victim.getName() + ChatColor.BOLD.DARK_GRAY + " Is now in a bubble!");
                FixedMetadataValue metadataValue = new FixedMetadataValue((Plugin)this.plugin, true);
                victim.setMetadata("isInBubble", metadataValue);


                if (args[1].equalsIgnoreCase("on")) //i.e /bubble <username> <on/off>
                {
                bubbles.put(args[0], true);
                }else if (args[1].equalsIgnoreCase("off"))
                {
                    bubbles.put(args[0], false);
                }


            }
            else
            {
                sender.sendMessage(ChatColor.RED + "Player is not online!");

            }

            }
            else
            {
                sender.sendMessage(ChatColor.RED + "Invalid arguments!");
            }


        }
        else
        {
            sender.sendMessage(ChatColor.AQUA + "The console cannot bubble someone!");
        }

    }



    return false;
}
public void onPlayerMove(PlayerMoveEvent e) {
     Player mover = e.getPlayer();
     Location from = e.getFrom();
     Location to = e.getTo();
     Collection<Entity> nearbyEntities = mover.getWorld().
     getNearbyEntities(from,  10, 10, 10);//Get entities in a 10 block square from loc "from"
     List<Player> nearbyPlayers = new ArrayList<Player>();
     for (Entity en : nearbyEntities) {
         if (en instanceof Player)
           nearbyPlayers.add((Player) en);
     }
     for (Player victim : nearbyPlayers) {
         if (victim.hasMetadata("isInBubble") && victim != mover) {
            Location victimLoc = victim.getLocation();
            if (victimLoc.distance(to) <= 5) {//Radius 5
                e.setCancelled(true); //Cancel so cant move
                return; //we have nothing left no need to get in for statement again
            }
            }
         }
     }
 }
package me.Glowhoo.EpicUtil;
导入java.util.ArrayList;
导入java.util.Collection;
导入java.util.HashMap;
导入java.util.List;
导入java.util.array;
导入org.bukkit.bukkit;
导入org.bukkit.ChatColor;
导入org.bukkit.Location;
导入org.bukkit.command.command;
导入org.bukkit.command.CommandExecutor;
导入org.bukkit.command.CommandSender;
导入org.bukkit.entity.entity;
导入org.bukkit.entity.Player;
导入org.bukkit.event.Listener;
导入org.bukkit.event.player.PlayerMoveEvent;
导入org.bukkit.metadata.FixedMetadataValue;
导入org.bukkit.plugin.plugin;
导入org.bukkit.util.Vector;
/*
*作者=
*怒吼
* 
*/
公共类Bubble实现CommandExecutor、Listener{
私有主插件;
公共泡泡(主插件)
{
this.plugin=plugin;
}
公共布尔onCommand(CommandSender-sender、Command cmd、String commandLabel、String[]args)
{
if(cmd.getName().equalsIgnoreCase(“气泡”))
{
if(播放机的发送方实例)
{

如果(args.length>0&&args.length您忘记在
onPlayerMove
方法之前添加
@EventHandler
注释

您还需要在插件管理器中注册
playermovevent
,因此将以下代码添加到
onEnable()
方法中:

getServer().getPluginManager().registerEvents(this, new Bubble());
如果要在
HashMap
中存储播放机上的气泡状态,则需要使用
HashMap
字段,在该字段中存储播放机UUID和气泡切换状态。
您需要在玩家加入时存储该玩家,并在他退出游戏时将其移除。

您忘记在
onPlayerMove
方法之前添加
@EventHandler
注释

您还需要在插件管理器中注册
playermovevent
,因此将以下代码添加到
onEnable()
方法中:

getServer().getPluginManager().registerEvents(this, new Bubble());
如果要在
HashMap
中存储播放机上的气泡状态,则需要使用
HashMap
字段,在该字段中存储播放机UUID和气泡切换状态。
您需要在玩家加入时存储该玩家,并在他退出游戏时将其移除。

您忘记在
onPlayerMove
方法之前添加
@EventHandler
注释

您还需要在插件管理器中注册
playermovevent
,因此将以下代码添加到
onEnable()
方法中:

getServer().getPluginManager().registerEvents(this, new Bubble());
如果要在
HashMap
中存储播放机上的气泡状态,则需要使用
HashMap
字段,在该字段中存储播放机UUID和气泡切换状态。
您需要在玩家加入时存储该玩家,并在他退出游戏时将其移除。

您忘记在
onPlayerMove
方法之前添加
@EventHandler
注释

您还需要在插件管理器中注册
playermovevent
,因此将以下代码添加到
onEnable()
方法中:

getServer().getPluginManager().registerEvents(this, new Bubble());
如果要在
HashMap
中存储播放机上的气泡状态,则需要使用
HashMap
字段,在该字段中存储播放机UUID和气泡切换状态。
你需要在玩家加入时存储他,在他退出游戏时删除他。

你也可以使用
ArrayList
而不是
HashMap
。不要将HashMap值设置为false,从列表中删除,也不要将HashMap值设置为true,而是添加到列表中。你也可以只使用
ArrayList
而不是
HashMap
。不是将HashMap值设置为false,而是从列表中删除,也不是将HashMap值设置为true,而是添加到列表中。您也可以使用
ArrayList
而不是
HashMap
。不是将HashMap值设置为false,而是从列表中删除,而不是使用sett如果将HashMap值设置为true,则添加到列表中。您也可以使用
ArrayList
而不是
HashMap
。与其将HashMap值设置为false,不如从列表中删除,与其将HashMap值设置为true,不如添加到列表中。