Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring Attack Speed #11

Closed
Vervatwala opened this issue Aug 23, 2016 · 39 comments
Closed

Restoring Attack Speed #11

Vervatwala opened this issue Aug 23, 2016 · 39 comments

Comments

@Vervatwala
Copy link

When plugin was removed, swords and weapons still crafted with high attack speed? How would I change it back to its 1.9 default?

@kernitus
Copy link
Owner

The plugin sets an attribute on players with the attack speed, that attribute must be reversed so you would have to keep the plugin enabled and set the attack speed to the default 4 in the config file until all the people that were set to the new speed are set back.

@Vervatwala
Copy link
Author

I see, I will have to keep it on then for a bit so that during the week people can log in to get the reverted mechanics. Now what if I later just remove the plugin and somebody hadn't logged in when I made changes? Would they be still be set to fast attackspeeds as deault?
cheers again for your help!

@kernitus
Copy link
Owner

Yes, they would still be set to fast attack speed if they had logged in
when the plugin was previously enabled.

2016-08-23 21:35 GMT+01:00 Yohan Vervatwala notifications@github.com:

I see, I will have to keep it on then for a bit so that during the week
people can log in to get the reverted mechanics. Now what if I later just
remove the plugin and somebody hadn't logged in when I made changes? Would
they be still be set to fast attackspeeds as deault?
cheers again for your help!


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACqRZi0U2_GOpQ8Sht1AM9RoOUQE2jhMks5qi1magaJpZM4JrSC4
.

@Vervatwala
Copy link
Author

Vervatwala commented Aug 23, 2016

So now I've made changes disabled features, done a restart, on my client I see on a sword attack speed as 1.6 but a few users are reporting an attackspeed of 1021.6 and can spam click.
Is there a step I missed? a bug perhaps?

@kernitus
Copy link
Owner

Try keeping the old attack speed enabled but setting the speed to 4

Il 23/ago/2016 22:25, "Yohan Vervatwala" notifications@github.com ha
scritto:

So now I've made changes disabled features, done a restart, on my client I
see on a sword attack speed as 1.6 but a few users are reporting seeing
attackspeed of 1021.6 and can spam click again?
Is there a step I missed? a bug perhaps?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACqRZh2zlvO70piSUVGFf4nfNbKPrUABks5qi2U9gaJpZM4JrSC4
.

@Vervatwala
Copy link
Author

I've realized now that once a feature is disabled when config is reloaded it only affects people who are currently online, so now what is happening is some people have one version of pvp (1.8) some some back to default (1.9)
I should also point out this is on v1.0.1 of the plugin as the newest one did not refresh the config so even after reloads changes would not be present.

@Vervatwala
Copy link
Author

I understand (sort of) that the plugin changes some player NBT data or something but it would really be nice if there was a config once reloaded would change it for everyone (people who arent online either) since players on a server can be of different timezones and there might not be an admin to reload the plugin.
(I really hope what I am trying to say makes any sense?)

@kernitus
Copy link
Owner

Due to efficiency features, when you disable the module the plugin no longer peforms any check. This means that if you want to revert everyone back (including people who are offline) you must keep the module enabled and set the speed to 4 (default for 1.8). I'm not sure if it is possible to change the attack speed for offline players but I'll have a look.

@kernitus
Copy link
Owner

There seems to be a way to get a list of all players including offline players but we can't get the world they're in nor edit their attributes in any reasonable manner.

@Vervatwala
Copy link
Author

Ok thank you @gvlfm78 , apologies for the confusion and thank you for helping me through it.

@kernitus
Copy link
Owner

I might have another look at this some other time, but for now it doesn't seem to be possible.

@goosewoman
Copy link

Why not just reset a player's attributes upon logout? Should be possible, shouldn't it?

@rayzr522
Copy link
Collaborator

rayzr522 commented Sep 6, 2016

Depends on the timing of events, but it's not a bad idea. That might be a better solution.

On Sep 6, 2016, at 7:14 AM, Luuk Jacobs notifications@github.com wrote:

Why not just reset a player's attributes upon logout? Should be possible, shouldn't it?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@goosewoman
Copy link

PlayerQuitEvent is called right before the player gets disconnected, so the player is stil loaded in memory.
Something like this should suffice:

@EventHandler( priority = EventPriority.HIGHEST )
public void onPlayerQuit( PlayerQuitEvent e )
{
    Player player = e.getPlayer();
    AttributeInstance attribute = player.getAttribute( Attribute.GENERIC_ATTACK_SPEED );
    double baseValue = attribute.getBaseValue();
    if ( baseValue != 4 )
    {
        attribute.setBaseValue( 4 );
        player.saveData();
    }
}

@rayzr522
Copy link
Collaborator

rayzr522 commented Sep 6, 2016

Well that makes our job easy :P
Yeah, I just wasn't sure if the player was still loaded in the PlayerQuitEvent. Thanks for saving me the work XD

On Sep 6, 2016, at 7:45 AM, Luuk Jacobs notifications@github.com wrote:

PlayerQuitEvent is called right before the player gets disconnected, so the player is stil loaded in memory.
Something like this should suffice:

@eventhandler( priority = EventPriority.HIGHEST )
public void onPlayerQuit( PlayerQuitEvent e )
{
Player player = e.getPlayer();
AttributeInstance attribute = player.getAttribute( Attribute.GENERIC_ATTACK_SPEED );
double baseValue = attribute.getBaseValue();
if ( baseValue != 4 )
{
attribute.setBaseValue( 4 );
player.saveData();
}
}

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@kernitus
Copy link
Owner

kernitus commented Sep 6, 2016

Indeed that would work. I believe the original reason for not doing that was to have the least amount of listeners/operations for the plugin to be as efficient as possible, I never considered anyone would want to get rid of the plugin after having allowed their playerbase on.

@Vervatwala
Copy link
Author

@gvlfm78 it is still something to be considered that a plugin could be removed after it was put in. I am not a programmer by any stretch but as a user (simple server admin) I would think some easier kind of reset would be in place.

@rayzr522
Copy link
Collaborator

Here's the problem: to my knowledge, we don't' have access to the attack speeds of offline players.

Now even if we implemented a better system, you'd still have a bunch of offline players that would have the wrong attack speed.

I can do some checking though to see if we have access to the offline players, if so then we can probably figure something out.

@Vervatwala
Copy link
Author

How about something that refreshes the config as the player logs in? like right now when i am online i just reload the plugin just so i know it changes some of the old players attack speed

@kernitus
Copy link
Owner

If you enable the combat coold-down module and set the speed to 4 players will be set back to 1.9 speeds upon entering the server.

@mibby
Copy link

mibby commented Sep 22, 2016

:o So if we use OCM and one day decide to remove it, some players would be stuck with faster combat compared to new players? Seems extremely inefficient for large community servers. Can't wait for every single person to login once to be 'reset'. :s

@kernitus
Copy link
Owner

We haven't found a way yet to edit the Attributes of offline player, but by adding kukelekuuk00's code anyone that installs the plugin after it's been added should not have this problem. I'm still looking around if there's a practical way to edit offline player's attributes.

@mibby
Copy link

mibby commented Sep 23, 2016

Hopefully you are able to find a way. :) Don't want to be stuck with some players being broken permanently if the plugin is ever removed in the future. Would be nice to reset everyone's attributes before removal.

@mibby
Copy link

mibby commented Oct 17, 2016

Any update to this problem?

@rayzr522
Copy link
Collaborator

Really the only way I can think of is to crawl through all playerdata files and manually modify the NBT. I think the server would have to be offline for this though....

Anyways it wouldn't be easy to say the least, but it might be possible. I guess I can look into it...

@kernitus
Copy link
Owner

I have put @kukelekuuk00 's fix in place for version 1.0.2, so that in the meantime at least new installs will not have the same problem.

@mibby
Copy link

mibby commented Oct 25, 2016

Would it be possible to create a temporary offline tool to use on all player files in the world folder to reset their attack speed to default? I don't want to be stuck with broken users forever. :(

@rayzr522
Copy link
Collaborator

@mibby
I might be able to make a plugin to modify offline players' playerdata files... it won't be pretty, but I might be able to get it to work, and that's all that matters.

I've done it once before to restore players inventories by reading their playerdata files, so I should be able to use that as a starting point.

Sorry for the inconvenience this has caused you :/

@rayzr522
Copy link
Collaborator

rayzr522 commented Nov 3, 2016

@mibby
So sorry that I have taken so long! I actually forgot about this :(

I just create OCMFixer and it should fix your problems. It's SUPER simple to use, and I did test it out. Let me know if it works!

@mibby
Copy link

mibby commented Nov 3, 2016

It just sets the AttackSpeed NBT tag to 4 (assuming default 1.9/10+ value) for all players? Won't corrupt the player.dat file?

@rayzr522
Copy link
Collaborator

rayzr522 commented Nov 3, 2016 via email

@mibby
Copy link

mibby commented Nov 3, 2016

Thanks. I'll give it a try later today. :)

Does OCM modify any other player NBT strings? Or was it just attack speed which should now revert on logout?

@rayzr522
Copy link
Collaborator

rayzr522 commented Nov 3, 2016

It was only modifying attack speed I believe... and it wasn't using the NBT system. The Bukkit API itself lets you change a player's attack speed without any NMS / Reflection, but there just wasn't any way to do that for offline players.

So instead I just wrote OCMFixer to read all the playerdata files and change the attribute value. It should be 100% safe, I wrote some protections into the code so if it doesn't find the right NBT structure in the file it just kinda fails silently without touching the file.

@kernitus
Copy link
Owner

kernitus commented Nov 3, 2016

@mibby If you enabled the old armour values, which causes the plugin to add a large armour toughness value to armour pieces upon wearing them, those values won't be removed upon removing the plugin as players could have easily put the armour pieces in chests etc.

@rayzr522
Copy link
Collaborator

rayzr522 commented Nov 8, 2016

@mibby
Did OCMFixer solve your problems?

@mibby
Copy link

mibby commented Nov 8, 2016

Assuming OCM doesn't set the attack speed value to the player.dat file anymore (removing it on logout), I hope so. :P I did run the plugin and read command on the world. No way of fully knowing without using an NBT editor and looking at every user file.

@rayzr522
Copy link
Collaborator

rayzr522 commented Nov 8, 2016

Just look at a few that haven't been online in a while. To make sure.

And @gvlfm78 it does reset on logout now, right?

@kernitus
Copy link
Owner

kernitus commented Nov 8, 2016

If you have the module enabled it does. This means that those that haven't logged it since before the update will still have the fast attack speed and you'll have to use Rayzr's utility if you're uninstalling or disabling the module.

@kernitus kernitus mentioned this issue Nov 12, 2016
@kernitus
Copy link
Owner

kernitus commented Nov 20, 2016

I have made the plugin set armour NBT tags to default when armour is unequipped or the player leave the server. This means from version 1.1.1 of OCM removing OCM should leave no trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants