elBukkit/MagicPlugin

use_scoreboard_teams config option not working

KidneyMafia opened this issue · 10 comments

Hello.
I've been working with your plugin for a while and I've run into a problem regarding teams. I want spells to respect teams set up by the bukkit api system (that should be similar to those found in the vanilla /team command). This means, players on the same team should be able to shoot spells through teammates, as they do with arrows, and unable to target them with spell effects such as potions, velocities, etc. Problem is, non of this works. Damage is indeed halted, as they are on the same team, but harmful spell effects still apply.
Furthermore I also have Heroes plugin installed, and, using use_heroes_parties = true achives the disered effect, and parties are respected properly, leading me to believe it could be a configuration problem. This could be fine, but unfortunately heroes parties cannot include non player mobs, which is not ideal for my plugin.
I tried using the automated discord bot for help to no avail. If any of you could take a look at your code to see if everything is up and running, or maybe tell me what I could be doing wrong I would be much appreciated.
Thank you and keep up the good work

To be clear, you have tried setting use_scoreboard_teams: true ?
With use_heroes_parties turned off? (I think that will override the scoreboard teams)

It sounds like you're aware of that option existing, you have tried it but it doesn't seem to work?

That is correct. I've tried use_scoreboard_teams: true
with use_heroes_parties turned off.

"Last I checked" this was working, but it's been a long time and I'm not aware of anyone else actively using the feature.

You can try /mage debug 100 to turn on debug chat messages. I think if you target a teammate with a spell you should get a message like

Controller says can't target entity

I can try to test this myself when I get a chance, I'd have to use mobs but sounds like that's your use case anyway. Are you assigning teams via commands, do you happen to have a simple way to test this, maybe with a summon command and the commands required to set up the scoreboard teams?

I am assigning teams with a bukkit plugin I am coding, so I am using the bukkit api.
The plugin in question teams both players and mobs (mostly players) so having the option to include mobs in teams would be nice.
I was not aware of the debug option. I will be using it avidly from now on as I make heavy use of your plugin xD
I will test it as soon as I can as well and get back to you.
Some context can help here: to test this kinds of things I use 2-3 minecraft accounts assigned to teams via my plugin. I am making an overwatch like shield that spawn no AI slimes mounted on a player upon player interact event and those slides have the team of the player that fired the event. That way, those slides will be trespassed by friendly spells and projectiles but block enemy ones.
Sorry for the lengthy explanation and eventually lack of language clarity, as English is not my first language. If you need more information feel free to ask

Is the option working for you for players? Is it just mobs that it's not working?

The Bukkit API seems to only have team support for players. How are you adding mobs to teams in your plugin?

The use_scoreboard_teams: true seems to not work to players as well.
For now, i am still unable to add mobs to teams, however, in the spigot forums, i've heared multiple times that the method .addEntry(slime.getUniqueId().toString()) is sucessfull.
The present issue shoud be more focused on the players, not the mobs. I apologize for the confusion

Unfortunately players is a lot harder for me to test. I'll see if I can rig something up but can't really give an ETA.

Thank you. Take your time of course. I'll do some tests in the mean time and if i arrive at some worthwhile conclusions, i'll make sure to let you know.

I've figured out in the mean time that you can indeed add mobs to teams via bukkit api, however, team options such as friendly fire do not apply to them. This is a minecraft feature/bug, and unavoidable in a server setting, unfortunatly. Fortunately however i was able to find a work around via the ProjectileHitEvent for arrows. Canceling that event allows arrows to travel throught teammates' boddies just like intended. The only thing missing is do this for spells. My idea is to achive this via CastEvent, removing the target, allowing the projectile to go throught the mob. I don't know how to this, however. I tried with the spellResult method to no avail, using NO_TARGER or ENTITY_REQUIRED to no avail. Another good way could be through the controller, disalowing some players to target some mobs, but i cannot find the apropriate method for this.
Solving this, would probably complete my workaround neatly and allow me to complete this feature without the need for use_scoreboard_teams: true . If you were so kind to help me in this, i would be much apreciated

After some hours of testing and consideration, I was able to get it working. The awnser is teamProvider.
You can use the PreLoadEvent to register a teamProvider to tell the controller what entity is frendly to what, no matter their type, scoreboard teams, etc. This is imensly powerfull, and bypasses the need for the use_scoreboard_teams: true config option entirely, as i can freely designate what entities are allowed to be targeted and under what conditions.
I am going to post my code here to show what i did more concretly, as this might be able to help somebody else in this situation. I am also going to close the issue.
Thank you very much for the help. Looking foward to keep working with your plugin what else it can do.

@EventHandler(priority = EventPriority.HIGHEST) public void onShieldDamageWithSpells(PreLoadEvent e){ Bukkit.getLogger().info("Registered team providers for shield tanks"); TeamProvider teamProvider = new TeamProvider() { @Override public boolean isFriendly(Entity entity, Entity entity1) { if (entity instanceof Player){ Player player = (Player) entity; if (player.getScoreboard().getEntryTeam(player.getName()).getName().equals("blue")){ return entity1 instanceof Slime; } else { return entity1 instanceof MagmaCube; } } return false; } }; e.getTeamProviders().add(teamProvider); }