Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Przerobienie tablisty na 1.8 z 1.7


Rekomendowane odpowiedzi

Opublikowano

Czemu i za co ktos ma czi przerabiac core'a dajmana robionego pod coresv?

Twoj kod:

package pl.hiber.core.utils.element;
 
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import pl.hiber.core.base.Guild;
import pl.hiber.core.base.OfflineUser;
import pl.hiber.core.configuration.Tab;
import pl.hiber.core.ranking.RankPoints;
import pl.hiber.core.utils.StringUtils;
import pl.hiber.core.utils.Util;
 
import java.util.Calendar;
 
public class TabCell
{
    private String message;
    private String name;
    private String prefix;
    private String suffix;
    private Tablist tab;
    private boolean teamExists;
   
    public TabCell(final Tablist tab) {
        this.teamExists = false;
        this.tab = tab;
    }
   
    public TabCell(final Tablist tab, final String name, final String message) {
        this.teamExists = false;
        this.tab = tab;
        this.name = name;
        this.message = message;
    }
   
    public void create() {
        final Scoreboard sb = this.tab.getUser().getScoreboard();
        if (sb == null) {
            return;
        }
        Team t = sb.getTeam(this.name);
        if (t == null) {
            t = sb.registerNewTeam(this.name);
            t.addPlayer((OfflinePlayer)new OfflineUser(this.name));
        }
        this.replace();
        t.setPrefix(this.prefix);
        t.setSuffix(this.suffix);
    }
   
    public void delete() {
        final Scoreboard sb = this.tab.getUser().getScoreboard();
        final Team t = sb.getTeam(this.name);
        if (t != null) {
            t.unregister();
        }
    }
   
    public String getMessage() {
        return this.message;
    }
   
    public String getName() {
        return this.name;
    }
   
    public String getPrefix() {
        return this.prefix;
    }
   
    public String getSuffix() {
        return this.suffix;
    }
   
    public Tablist getTab() {
        return this.tab;
    }
   
    public boolean isTeamExists() {
        return this.teamExists;
    }
   
    private void replace() {
        String msg = this.message;
        final Calendar calendar = Calendar.getInstance();
        final int secondi = calendar.get(13);
        final int minutei = calendar.get(12);
        msg = StringUtils.replace(msg, "{ONLINE}", Bukkit.getOnlinePlayers().size());
        msg = StringUtils.replace(msg, "{PLAYER}", this.tab.getUser().getName());
        msg = StringUtils.replace(msg, "{POINTS}", Integer.toString(this.tab.getUser().getPoints()));
        msg = StringUtils.replace(msg, "{KILLS}", Integer.toString(this.tab.getUser().getKills()));
        msg = StringUtils.replace(msg, "{DEATHS}", Integer.toString(this.tab.getUser().getDeaths()));
        msg = StringUtils.replace(msg, "{ASISTS}", Integer.toString(this.tab.getUser().getAsists()));
        msg = StringUtils.replace(msg, "{KD}", Double.toString(this.tab.getUser().getKd()));
        msg = StringUtils.replace(msg, "{LVL}", Integer.toString(this.tab.getUser().getLvl()));
        msg = StringUtils.replace(msg, "{BLOCKS}", Integer.toString(this.tab.getUser().getDrop("blocks")));
        msg = StringUtils.replace(msg, "{BLOCKSTONEXT}", Integer.toString(this.tab.getUser().getBlocksToNext()));
        msg = StringUtils.replace(msg, "{POSITION}", Integer.toString(RankPoints.getInst().getUser(this.tab.getUser().getName())));
        msg = StringUtils.replace(msg, "{ROLE}", this.tab.getUser().getRole());
        if (secondi < 10) {
            msg = StringUtils.replace(msg, "{SECOND}", "0" + Integer.toString(secondi));
        }
        else {
            msg = StringUtils.replace(msg, "{SECOND}", Integer.toString(secondi));
        }
        if (minutei < 10) {
            msg = StringUtils.replace(msg, "{MINUTE}", "0" + Integer.toString(minutei));
        }
        else {
            msg = StringUtils.replace(msg, "{MINUTE}", Integer.toString(minutei));
        }
        msg = StringUtils.replace(msg, "{HOUR}", Integer.toString(calendar.get(11)));
        msg = StringUtils.replace(msg, "{PING}", new StringBuilder().append(Integer.toString(this.tab.getUser().getPing())).toString());
        if (this.tab.getUser().hasGuild()) {
            final Guild g = this.tab.getUser().getGuild();
            msg = StringUtils.replace(msg, "{TAG}", g.getTag());
            msg = StringUtils.replace(msg, "{GPOINTS}", Integer.toString(g.getPoints()));
            msg = StringUtils.replace(msg, "{GDEATHS}", Integer.toString(g.getDeaths()));
            msg = StringUtils.replace(msg, "{GKILLS}", Integer.toString(g.getKills()));
            msg = StringUtils.replace(msg, "{LIVES}", Integer.toString(g.getLives()));
            msg = StringUtils.replace(msg, "{GKD}", Double.toString(g.getKd()));
        }
        else {
            msg = StringUtils.replace(msg, "{TAG}", "Brak");
            msg = StringUtils.replace(msg, "{GPOINTS}", "Brak");
            msg = StringUtils.replace(msg, "{GDEATHS}", "Brak");
            msg = StringUtils.replace(msg, "{GKILLS}", "Brak");
            msg = StringUtils.replace(msg, "{LIVES}", "Brak");
            msg = StringUtils.replace(msg, "{GKD}", "Brak");
        }
        if (msg.contains("{TOPTYPE}") && Tab.getInst().VARIABLE_TOPS) {
            switch (Util.getTopType()) {
                case 1: {
                    msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_KILLS);
                    break;
                }
                case 2: {
                    msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_ONLINE);
                    break;
                }
                case 3: {
                    msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_STONE);
                    break;
                }
                case 4: {
                    msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_KOX);
                    break;
                }
                default: {
                    msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_POINTS);
                    break;
                }
            }
        }
        final String r = StringUtils.parseRank(msg);
        if (r != null) {
            msg = r;
        }
        this.split(msg);
    }
   
    public void setMessage(final String message) {
        this.message = message;
    }
   
    public void setName(final String name) {
        this.name = name;
    }
   
    public void setPrefix(final String prefix) {
        this.prefix = prefix;
    }
   
    public void setSuffix(final String suffix) {
        this.suffix = suffix;
    }
   
    public void setTab(final Tablist tab) {
        this.tab = tab;
    }
   
    public void setTeamExists(final boolean teamExists) {
        this.teamExists = teamExists;
    }
   
    private void split(final String s) {
        String prefix = "";
        String suffix = "";
        if (s.length() <= 16) {
            this.prefix = s;
        }
        else {
            prefix = s.substring(0, 16);
            int l = 16;
            if (prefix.charAt(15) == '&') {
                prefix = s.substring(0, 15);
                l = 15;
            }
            String color = ChatColor.getLastColors(prefix);
            if (color == null || color.isEmpty()) {
                color = "&f";
            }
            if (l == 16) {
                suffix = String.valueOf(color) + s.substring(16);
            }
            else {
                suffix = String.valueOf(color) + s.substring(15);
            }
            if (suffix.length() > 16) {
                suffix = suffix.substring(0, 16);
            }
            this.prefix = prefix;
        }
        this.suffix = suffix;
    }
   
    public void update() {
        this.replace();
        final Scoreboard sb = this.tab.getUser().getScoreboard();
        if (sb == null) {
            return;
        }
        Team t = sb.getTeam(this.name);
        if (t == null) {
            t = sb.registerNewTeam(this.name);
            t.addPlayer((OfflinePlayer)new OfflineUser(this.name));
        }
        t.setPrefix(this.prefix);
        t.setSuffix(this.suffix);
    }
}

kod z core'a dajmana:

package net.dajman.core.utils.element;

import java.util.Calendar;
import net.dajman.core.base.Guild;
import net.dajman.core.base.OfflineUser;
import net.dajman.core.base.User;
import net.dajman.core.configuration.Tab;
import net.dajman.core.ranking.RankPoints;
import net.dajman.core.utils.StringUtils;
import net.dajman.core.utils.Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

public class TabCell
{
  private Tablist tab;
  private String name;
  private String message;
  private String prefix;
  private String suffix;
  private boolean teamExists = false;
  
  public TabCell(Tablist tab)
  {
    this.tab = tab;
  }
  
  public TabCell(Tablist tab, String name, String message)
  {
    this.tab = tab;
    this.name = name;
    this.message = message;
  }
  
  private void replace()
  {
    String msg = this.message;
    Calendar calendar = Calendar.getInstance();
    int secondi = calendar.get(13);
    int minutei = calendar.get(12);
    msg = StringUtils.replace(msg, "{ONLINE}", Bukkit.getOnlinePlayers().length);
    msg = StringUtils.replace(msg, "{PLAYER}", this.tab.getUser().getName());
    msg = StringUtils.replace(msg, "{POINTS}", Integer.toString(this.tab.getUser().getPoints()));
    msg = StringUtils.replace(msg, "{KILLS}", Integer.toString(this.tab.getUser().getKills()));
    msg = StringUtils.replace(msg, "{DEATHS}", Integer.toString(this.tab.getUser().getDeaths()));
    msg = StringUtils.replace(msg, "{ASISTS}", Integer.toString(this.tab.getUser().getAsists()));
    msg = StringUtils.replace(msg, "{KD}", Double.toString(this.tab.getUser().getKd()));
    msg = StringUtils.replace(msg, "{LVL}", Integer.toString(this.tab.getUser().getLvl()));
    msg = StringUtils.replace(msg, "{COINS}", Integer.toString(this.tab.getUser().getCoins()));
    msg = StringUtils.replace(msg, "{BLOCKS}", Integer.toString(this.tab.getUser().getDrop("blocks")));
    msg = StringUtils.replace(msg, "{BLOCKSTONEXT}", Integer.toString(this.tab.getUser().getBlocksToNext()));
    msg = StringUtils.replace(msg, "{POSITION}", Integer.toString(RankPoints.getInst().getUser(this.tab.getUser().getName())));
    msg = StringUtils.replace(msg, "{ROLE}", this.tab.getUser().getRole());
    if (secondi < 10) {
      msg = StringUtils.replace(msg, "{SECOND}", "0" + Integer.toString(secondi));
    } else {
      msg = StringUtils.replace(msg, "{SECOND}", Integer.toString(secondi));
    }
    if (minutei < 10) {
      msg = StringUtils.replace(msg, "{MINUTE}", "0" + Integer.toString(minutei));
    } else {
      msg = StringUtils.replace(msg, "{MINUTE}", Integer.toString(minutei));
    }
    msg = StringUtils.replace(msg, "{HOUR}", Integer.toString(calendar.get(11)));
    
    msg = StringUtils.replace(msg, "{PING}", Integer.toString(this.tab.getUser().getPing()));
    if (this.tab.getUser().hasGuild())
    {
      Guild g = this.tab.getUser().getGuild();
      msg = StringUtils.replace(msg, "{TAG}", g.getTag());
      msg = StringUtils.replace(msg, "{GPOINTS}", Integer.toString(g.getPoints()));
      msg = StringUtils.replace(msg, "{GDEATHS}", Integer.toString(g.getDeaths()));
      msg = StringUtils.replace(msg, "{GKILLS}", Integer.toString(g.getKills()));
      msg = StringUtils.replace(msg, "{LIVES}", Integer.toString(g.getLives()));
      msg = StringUtils.replace(msg, "{GKD}", Double.toString(g.getKd()));
    }
    else
    {
      msg = StringUtils.replace(msg, "{TAG}", "Brak");
      msg = StringUtils.replace(msg, "{GPOINTS}", "Brak");
      msg = StringUtils.replace(msg, "{GDEATHS}", "Brak");
      msg = StringUtils.replace(msg, "{GKILLS}", "Brak");
      msg = StringUtils.replace(msg, "{LIVES}", "Brak");
      msg = StringUtils.replace(msg, "{GKD}", "Brak");
    }
    if ((msg.contains("{TOPTYPE}")) && (Tab.getInst().VARIABLE_TOPS)) {
      switch (Util.getTopType())
      {
      case 1: 
        msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_KILLS);
        break;
      case 2: 
        msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_ONLINE);
        break;
      case 3: 
        msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_STONE);
        break;
      case 4: 
        msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_KOX);
        break;
      default: 
        msg = StringUtils.replace(msg, "{TOPTYPE}", Tab.getInst().TOPTYPE_POINTS);
      }
    }
    String r = StringUtils.parseRank(msg);
    if (r != null) {
      msg = r;
    }
    split(msg);
  }
  
  private void split(String s)
  {
    String prefix = "";
    String suffix = "";
    if (s.length() <= 16)
    {
      this.prefix = s;
    }
    else
    {
      prefix = s.substring(0, 16);
      int l = 16;
      if (prefix.charAt(15) == '�')
      {
        prefix = s.substring(0, 15);
        l = 15;
      }
      String color = ChatColor.getLastColors(prefix);
      if ((color == null) || (color.isEmpty())) {
        color = "�f";
      }
      if (l == 16) {
        suffix = color + s.substring(16);
      } else {
        suffix = color + s.substring(15);
      }
      if (suffix.length() > 16) {
        suffix = suffix.substring(0, 16);
      }
      this.prefix = prefix;
    }
    this.suffix = suffix;
  }
  
  public void create()
  {
    Scoreboard sb = this.tab.getUser().getScoreboard();
    if (sb == null) {
      return;
    }
    Team t = sb.getTeam(this.name);
    if (t == null)
    {
      t = sb.registerNewTeam(this.name);
      t.addPlayer(new OfflineUser(this.name));
    }
    replace();
    t.setPrefix(this.prefix);
    t.setSuffix(this.suffix);
  }
  
  public void update()
  {
    replace();
    Scoreboard sb = this.tab.getUser().getScoreboard();
    if (sb == null) {
      return;
    }
    Team t = sb.getTeam(this.name);
    if (t == null)
    {
      t = sb.registerNewTeam(this.name);
      t.addPlayer(new OfflineUser(this.name));
    }
    t.setPrefix(this.prefix);
    t.setSuffix(this.suffix);
  }
  
  public void delete()
  {
    Scoreboard sb = this.tab.getUser().getScoreboard();
    Team t = sb.getTeam(this.name);
    if (t != null) {
      t.unregister();
    }
  }
  
  public Tablist getTab()
  {
    return this.tab;
  }
  
  public String getName()
  {
    return this.name;
  }
  
  public String getMessage()
  {
    return this.message;
  }
  
  public String getPrefix()
  {
    return this.prefix;
  }
  
  public String getSuffix()
  {
    return this.suffix;
  }
  
  public boolean isTeamExists()
  {
    return this.teamExists;
  }
  
  public void setTab(Tablist tab)
  {
    this.tab = tab;
  }
  
  public void setName(String name)
  {
    this.name = name;
  }
  
  public void setMessage(String message)
  {
    this.message = message;
  }
  
  public void setPrefix(String prefix)
  {
    this.prefix = prefix;
  }
  
  public void setSuffix(String suffix)
  {
    this.suffix = suffix;
  }
  
  public void setTeamExists(boolean teamExists)
  {
    this.teamExists = teamExists;
  }
}

 

 

 

JAVA <3

 

Opublikowano
Dnia 6.07.2017 o 22:07, Hiber napisał:

@up Bo tak chce ? lol

Ale sie nie da! W 1.8 jest inny system tabu. Bys musiał przerobic w mc to

CPU i5 6600k 4,1GHZ | RAM HyperX SAVAGE 16GB RAMGPU ASUS GTX 1070 ROG STRIX 8GOC |

SSD1 Samsung EVO 850 120GB| SSD2 ADATA SP600 120GB |HDD Toshiba 1TB

Reklama serwera minigames w starym stylu Kliknij tutaj

 

Opublikowano

Oj wszyscy głupoty gadacie. Jeżeli znajdzie kogoś kto mu to zrobi to mu to zrobi. 

BungeeTabListPlus jest najprostszym rozwiązaniem.

Opublikowano
5 godzin temu, krzukosz napisał:

Oj wszyscy głupoty gadacie. Jeżeli znajdzie kogoś kto mu to zrobi to mu to zrobi. 

BungeeTabListPlus jest najprostszym rozwiązaniem.

Sam używałem ale to dziala na kazdym podserverze i tablicy gildii nie da. 

CPU i5 6600k 4,1GHZ | RAM HyperX SAVAGE 16GB RAMGPU ASUS GTX 1070 ROG STRIX 8GOC |

SSD1 Samsung EVO 850 120GB| SSD2 ADATA SP600 120GB |HDD Toshiba 1TB

Reklama serwera minigames w starym stylu Kliknij tutaj

 

Opublikowano

Możesz spróbować użyć moje API do prostszego i szybszego zarządzania tab listą na nowszych wersjach: https://github.com/Jaqobb/TabAPI

API nie było testowane na 1.8, więc jak nie będzie działać to pisz, poprawie.

Poprawka: API zostało przetestowane. Działa na 1.8.8-1.12

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...