2016-09-05 24 views
-1

嘿傢伙我只是讓我的tablist插件。我一直在嘗試這一點。我已經嘗試了很多東西,迄今爲止還沒有人出來工作。我的目標是自動添加一個派系成員名稱,如果他們加入顯示在線成員的列表並自動刪除它。自動添加和刪除列表中的項目

更清晰的解釋: 派系成員的名字必須在他們加入時顯示在tablist上。我嘗試過,並且將它們全部組合在Tablist的1條或1條插槽中。 我希望他們在1個tablot中顯示1個名字。

我怎麼能這樣做任何想法?

任何人有任何想法?這裏是我的代碼(這不包括自動加入和離開)

代碼幾乎是無用的,但在這裏它是

if (fplayer.hasFaction()) 
{ 
    list.setSlot(0, "", ChatColor.DARK_PURPLE + "Home:", ""); 
    if (faction.hasHome()) 
    { 
    int x = faction.getHome().getBlockX(); 
    int z = faction.getHome().getBlockZ(); 

    String xz = x + ", " + z; 

    list.setSlot(3, "", ChatColor.BLUE.toString(), ChatColor.YELLOW + xz); 
    } 
    else 
    { 
    list.setSlot(3, "", ChatColor.DARK_RED.toString(), ChatColor.YELLOW + "Not Set"); 
    } 
    list.setSlot(1, "", ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("SERVER-NAME")), ""); 

    list.setSlot(2, "", ChatColor.DARK_PURPLE + "End Portals:", ""); 
    list.setSlot(5, "", ChatColor.YELLOW + plugin.getConfig().getString("END-PORTAL-COORDS"), ""); 
    list.setSlot(8, "", ChatColor.YELLOW + "in each ", ChatColor.YELLOW + "quadrant."); 


    int KILLS = Stats.kdc.getInt("p." + p.getUniqueId().toString() + ".kills"); 
    String KILLSS = Integer.toString(KILLS); 
    int DEATHS = Stats.kdc.getInt("p." + p.getUniqueId().toString() + ".deaths"); 
    String DEATHSS = Integer.toString(DEATHS); 

    list.setSlot(22, "", ChatColor.DARK_BLUE.toString(), ChatColor.DARK_PURPLE + "Player Info:"); 
    list.setSlot(25, "", ChatColor.YELLOW + "Kills: ", ChatColor.YELLOW + KILLSS); 
    list.setSlot(28, "", ChatColor.YELLOW + "Deaths: ", ChatColor.YELLOW + DEATHSS); 

    DecimalFormat dtrf = new DecimalFormat("#.###"); 

    list.setSlot(10, "", ChatColor.DARK_GREEN.toString(), ChatColor.DARK_PURPLE + "Faction Info:"); 
    list.setSlot(13, "", ChatColor.YELLOW + "DTR: ", String.valueOf(dtrf.format(faction.getDTR()))); 
    list.setSlot(16, "", ChatColor.YELLOW + "Online: ", String.valueOf(faction.getOnlinePlayers().size() + "/" + faction.getSize())); 

    int x = p.getLocation().getBlockX(); 
    int z = p.getLocation().getBlockZ(); 

    String xz = "(" + x + ", " + z + ")"; 

    list.setSlot(34, "", ChatColor.DARK_PURPLE + "Location:", ""); 

    list.setSlot(37, "", ChatColor.UNDERLINE.toString(), ChatColor.YELLOW + "Unknown"); 

    list.setSlot(40, ChatColor.GRAY + "[" + getCardinalDirection(p) + "] ", ChatColor.MAGIC.toString(), ChatColor.GRAY + xz); 

    list.setSlot(46, "", ChatColor.DARK_PURPLE + "KoTH:", ""); 
    list.setSlot(49, "", ChatColor.YELLOW + "Name: ", ChatColor.YELLOW + "None"); 
    list.setSlot(52, "", ChatColor.YELLOW + "Loc: ", ChatColor.YELLOW + "None"); 
    list.setSlot(55, "", ChatColor.YELLOW + "Time: ", ChatColor.YELLOW + "None"); 

    list.setSlot(15, "", ChatColor.DARK_PURPLE + "Kit:", ""); 
    list.setSlot(18, "", ChatColor.YELLOW + plugin.getConfig().getString("MAP-KIT"), ""); 

    list.setSlot(24, "", ChatColor.DARK_PURPLE + "Border:", ""); 
    list.setSlot(27, "", ChatColor.YELLOW + plugin.getConfig().getString("BORDER-COORDS"), ""); 

    int i = 0; 
    for (Player o : Bukkit.getOnlinePlayers()) { 
    i++; 
    } 
    list.setSlot(33, "", ChatColor.DARK_PURPLE + "Players Online ", ChatColor.DARK_PURPLE + ": "); 
    list.setSlot(36, "", ChatColor.WHITE.toString(), ChatColor.YELLOW + String.valueOf(i)); 

    list.setDefaultPing(1); 
+0

也許你應該看看這裏http://docs.oracle.com/javase/tutorial/uiswing/components/table.html – MikeJRamsey56

+0

看看泰德星2015年12月28日答案#16。 https://www.spigotmc.org/threads/add-fake-players-to-tablist.111142/ – MikeJRamsey56

+0

@ MikeJRamsey56我的tablist工作正常。我面臨的問題是通過自動創建自定義插槽來添加和移除其他玩家陣營中的玩家 – jackc

回答

0

你可以連接到派系,並聽取對於用於觸發事件時,玩家加入/離開一個陣營,然後循環通過源和目標派系的玩家,在途中更新他們的選舉名單。

或者你可以做的更laggy方式,通過建立一個ASYC重複的任務,試圖不管他們派地位,以更新所有玩家的桌選手。我說ASYC的原因是因爲如果該方法失敗,則不會在主服務器線程上導致中斷。

相關問題