-
Notifications
You must be signed in to change notification settings - Fork 130
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
base: master
Are you sure you want to change the base?
Conversation
are the changes based off of the development branch? |
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 |
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. |
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 |
I missed something. Should now work (with new release) |
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) |
? |
Hello, I havent edited anything from the api. |
but the event does not get triggered |
and maybe change the server type from BungeeCord to Velocity |
Thanks for your effort to support velocity @KikyoC |
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. |
Hello, I just tested the Velocity support by building https://github.com/Swordfun-Server/AdvancedBan and run it on my server (velocity only)
|
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.*; |
There was a problem hiding this comment.
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)
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; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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)
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.