Iterating through Scoreboard.getObjectives

Discussion in 'Spigot Plugin Help' started by blastman3000, May 22, 2017.

  1. Hey guys, I'm currently attempting to edit the SpigotPotion.jar v1.7.10 to allow a scoreboard length of 32 rather than 16. That was the easy part. However, I'm stuck on a problem:
    Here is my current code and then I'll explain

    Code (Text):
    final net.minecraft.server.v1_7_R4.Scoreboard board;
    /*  22 */   final Map<String, CraftObjective> objectives = new HashMap();
    /*  23 */   final Map<String, CraftTeam> teams = new HashMap();
    /*     */  
    /*     */       CraftScoreboard(final net.minecraft.server.v1_7_R4.Scoreboard board) {
        this.objectives = new HashMap<String, CraftObjective>();
        this.teams = new HashMap<String, CraftTeam>();
        this.board = board;
        for (ScoreboardObjective objective : board.getObjectives()) {
            new CraftObjective(Sets.newHashSet(this), objective);
        }
        for (ScoreboardTeam team : board.getTeams()) {
            new CraftTeam(Sets.newHashSet(this), team);
        }
    }
    The problem is, the implementation of the new CraftObjective and new CraftTeam. Before you suggest the 1.8 version, I need to have the 1.7.10 version for personal reasons. Also, I need help with the iterating through the board.getObjectives() and board.getTeams()

    Errors I've encountered:
    • The constructor CraftObjective(HashSet<CraftScoreboard>, ScoreboardObjective) is undefined
    • Type mismatch: cannot convert from element type Object to ScoreboardObjective
    • The constructor CraftTeam(HashSet<CraftScoreboard>, ScoreboardTeam) is undefined

    What I've tried:

    Casting both to their respective object, but have been greeted with with "cannot iterate"

    Any help would be greatly appreciated. Also, if you could give any explanation as to why the answer to the problem would be correct, I would greatly appreciate it! Thanks
     
  2. Alright, so:

    I believe I fixed part of it, however I dont know if there will be any deprecation/data loss from this

    What I did for it was:
    Code (Text):
    final net.minecraft.server.v1_7_R4.Scoreboard board;
    /*  22 */   Map<String, CraftObjective> objectives = new HashMap();
    /*  23 */   Map<String, CraftTeam> teams = new HashMap();
    /*     */  
    /*     */       CraftScoreboard(final net.minecraft.server.v1_7_R4.Scoreboard board) {
        this.objectives = new HashMap<String, CraftObjective>();
        this.teams = new HashMap<String, CraftTeam>();
        this.board = board;
        ArrayList<ScoreboardObjective> objectivess = (ArrayList<ScoreboardObjective>) board.getObjectives();
        for (ScoreboardObjective objective : objectivess) {
            new CraftObjective(this, objective);
        }
        @SuppressWarnings("unchecked")
        ArrayList<ScoreboardTeam> teams = (ArrayList<ScoreboardTeam>) board.getTeams();
        for (ScoreboardTeam team : teams) {
            new CraftTeam(this, team);
        }
    }
     
  3. You are really going for the overkill approach, don't edit the spigot. Your clearly having trouble with this approach and there are far better alternatives that don't involve relying on a custom edited spigot. Just design your scoreboard code to support thirty two characters, split it at sixteen characters, team prefix to the first 16 and suffix to the remaining 16.