friendlyhj/ZenUtils

[Feature/Tool] Expanded ITeam (whos idea was it to not have a method for fetching it other than an existing entity; I SWEAR)

Closed this issue · 1 comments

as the title insinuates; ITeam is a very niche thing used and even when I tried to use it I found it frustrating because of one thing; there is no method to call an ITeam object in the script. To elaborate; imagine this: imagine you have to make a script involving a team setup system and you cant use commandManager to use commands but the world will already have a team space in its scoreboard for them to be put in. The question is how? there is a setter .setTeam() that requires an ITeam object to use; but where would you get it? from an entity? well no entity has it set yet and trying to fetch it without a team will return null. Your thinking would be to call it using global functions like server.world or game. You be right BUT YOU CAN'N! there IS NO METHOD todo such so its IMPOSIBLE to do it in zen using pure script wtihout the use of commandManager and even then you would require AT LEAST ONE ENITTY to fetch a ITeam object that cant be stored (sure you could in customWorldData but for the sake of example and simplicity sake lets pretend we cant do that). Thus lies the problem; it seems that some of these things that would have been important were left out.

and thats where this mod comes in by expanding on those things to impliment the missing stuff that SHOULD have been there to begin with (how it was though to be OK as it was is beyond me, its a bit maddening)

  • Depending on where its stored, expanding IGame to include a method to call The Scoreboard (where teams are handled in this version) would be useful as the scoreboard is a global/server thing and can be refrenced anywhere regardless of dimension
  • game.teams could be how you would call/access this expanded form of it (would make sense as ITeam is under game to begin with.
    TEAMS
  • getTeams(); a method that will return a array containing every ITeam registered in the game; returns null if the array that is returned is empty as a result of no teams existing. List can be (or is by default; idk how they work) iterable with for
  • getTeamFromString( teamName as string); returns a specific ITeam object from a string with the matching name of it; otherwise returns null
  • createTeam( name as string); a method to create a new team without using the command manager (whether there are benefits to this or not is up to you I suppose but at least there's a way to do it if you wanna avoid using commandManager like the plague for whatever reason :P) can return true if it is done successfully
  • removeTeam( name as string); the opposite of createTeam; returns true if it succeeds, false if it fails (afaik this would happen if the thing doesn't exist anymore period.
world.teams
world.getTeam("foo")
world.createTeam("foo")
world.removeTeam("foo")