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

Added velocity support #641

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Added velocity support #641

wants to merge 6 commits into from

Conversation

KikyoC
Copy link

@KikyoC KikyoC commented May 13, 2024

Hello,
I added velocity support and I tested it and it looks working. I checked that the /unban bug (because of not cached) is fixed.

@Hopefuls
Copy link
Collaborator

are the changes based off of the development branch?

@KikyoC
Copy link
Author

KikyoC commented Jun 22, 2024

Nope I don't think, you can see here that I'm up to date with leoko dev branch here: https://github.com/KikyoC/AdvancedBan/tree/master

@Bensonheimer992
Copy link

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

@Hopefuls
Copy link
Collaborator

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

is this related to this pull request? if no then that is known.

@KikyoC
Copy link
Author

KikyoC commented Jun 30, 2024

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

Hello, check this one, I'm waiting they response to open a second pr (because I did something stupid): https://github.com/Swordfun-Server/AdvancedBan

@Bensonheimer992
Copy link

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

Hello, check this one, I'm waiting they response to open a second pr (because I did something stupid): https://github.com/Swordfun-Server/AdvancedBan

this version does not work either it still says after banning this player is not banned

@KikyoC
Copy link
Author

KikyoC commented Jun 30, 2024

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

Hello, check this one, I'm waiting they response to open a second pr (because I did something stupid): https://github.com/Swordfun-Server/AdvancedBan

this version does not work either it still says after banning this player is not banned

I don't have this issue. i'm checking it

@KikyoC
Copy link
Author

KikyoC commented Jun 30, 2024

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

Hello, check this one, I'm waiting they response to open a second pr (because I did something stupid): https://github.com/Swordfun-Server/AdvancedBan

this version does not work either it still says after banning this player is not banned

I missed something. Should now work (with new release)

@Bensonheimer992
Copy link

can i still use the normal advancedban api or do i have to do something special for it to work with the velocity version ?

@Bensonheimer992
Copy link

can i still use the normal advancedban api or do i have to do something special for it to work with the velocity version ?

because im trying to use the PunishEvent and nothing happens (i checked that the event is registered)

@Bensonheimer992
Copy link

Hey every time i ban someone with the Velocity Version of AdvancedBan i have to restart the proxy to unban them if i don't restart the proxy i get the message that this player is not banned

Hello, check this one, I'm waiting they response to open a second pr (because I did something stupid): https://github.com/Swordfun-Server/AdvancedBan

this version does not work either it still says after banning this player is not banned

I missed something. Should now work (with new release)

?

@KikyoC
Copy link
Author

KikyoC commented Jul 7, 2024

Hello, I havent edited anything from the api.

@Bensonheimer992
Copy link

but the event does not get triggered

@Bensonheimer992
Copy link

Hello, I havent edited anything from the api.

and maybe change the server type from BungeeCord to Velocity

@DevLeoko
Copy link
Owner

Thanks for your effort to support velocity @KikyoC
Are the changes from this PR tested and stable? Because you mentioned newer changes and a second PR above.

@KikyoC
Copy link
Author

KikyoC commented Sep 1, 2024

Hey everyone !

I'm sorry if I don't answered on time. I get to many things in my life so that's why I'm answering late.

As I said I did something better on https://github.com/Swordfun-Server/AdvancedBan but I meged everything in this repo. I just tried and everything looks good.

@nhanledev
Copy link

Hello, I just tested the Velocity support by building https://github.com/Swordfun-Server/AdvancedBan and run it on my server (velocity only)

  • mute, tempmute: OK, player can not send message after being muted
  • ban, tempban: OK, player is kicked and can not join the server after being banned

@Hopefuls
Copy link
Collaborator

Hopefuls commented Oct 6, 2024

Hello @KikyoC,

wanted to possibly check up on this pr as I will also be testing it on my own soon (thanks @nhanledev for already looking into it).

Though I am still unsure as to how the specific change on the caching resolves the issue with the bans not being correctly handled, do you have some insights into this?

Thank you!

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, please specify which packages from java.io are used (avoid unecessary imports using * wildcards)

Comment on lines +452 to +509
public void saveResource(String resourcePath, boolean replace) {
if (resourcePath == null || resourcePath.equals("")) {
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
}

resourcePath = resourcePath.replace('\\', '/');
InputStream in = getResource(resourcePath);
if (in == null) {
throw new IllegalArgumentException("The embedded resource '" + resourcePath + "' cannot be found");
}

File outFile = new File(getDataFolder(), resourcePath);
int lastIndex = resourcePath.lastIndexOf('/');
File outDir = new File(getDataFolder(), resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));

if (!outDir.exists()) {
outDir.mkdirs();
}

try {
if (!outFile.exists() || replace) {
OutputStream out = new FileOutputStream(outFile);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
} else {
logger.warn("Could not save " + outFile.getName() + " to " + outFile + " because " + outFile.getName() + " already exists.");
}
} catch (IOException ex) {
logger.error("Could not save " + outFile.getName() + " to " + outFile, ex);
}
}


public InputStream getResource(String filename) {
if (filename == null) {
throw new IllegalArgumentException("Filename cannot be null");
}

try {
URL url = getClass().getClassLoader().getResource(filename);

if (url == null) {
return null;
}

URLConnection connection = url.openConnection();
connection.setUseCaches(false);
return connection.getInputStream();
} catch (IOException ex) {
return null;
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this implementation is based off of bukkit, does this work reliably in bungeecord and velocity too?

out.close();
in.close();
} else {
logger.warn("Could not save " + outFile.getName() + " to " + outFile + " because " + outFile.getName() + " already exists.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary warn when file exists (99% going to be the case after first use)

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

Successfully merging this pull request may close these issues.

5 participants