#help-development
1 messages · Page 1816 of 1
true
arguably a good one as it increases readability :p
doesnt intellij nowadays show the name of the parameters? xD
yeah it does
so not much of a difference when u got a good ide
xD
but i guess for creating the code the building pattern is nicer
😎
How do I set direction of glass pane block change to client using Block Change?
isn't it like this since forever? 😳
Why does the map isn't empty?
Code: https://pastebin.com/mt6Gm5iZ
Output:
[19:51:11] [Server thread/INFO]: TASK IS BEING EXECUTED!
[19:51:11] [Server thread/INFO]: EFFECTS: {10={}}
@ivory sleet
Im playing a bit around with the #spawnParticle() method and I have the annoying thing that the particles disperse for some reason that I cannot seem to figure out. I'd rather want a continues "flawless" line
particles despawn after x time naturally
if you want to keep a particle alive
you need to reespawn it
if you want to make a line
get all the points in wich you want a particle
from x,y,z to x1,y1,z1 and spawn them there
Rather the issue is that the particles disperse (fly all over the place) instead of being a continues line
Happens with endrod aswell, and some others.
Here's the code, a bit of the vector math is off, but Im trying to fix that now
can you make a video showing what you mean by flying all over the place?
You can clearly see the line, but there are particles like flying away from it, which I find weird
It all seems in order
ye
When using command blocks you can set it's speed to 0, thats kinda what I want
did you check this out?https://www.spigotmc.org/threads/particle-effects.360579/
seems similar to your problem
Im gonna check it out
so thats the equivalent to setting speed 0 in the command block ?
shouldnt there be a function to set particle movement to zero?
the deltavalues are the vector its moving in
maybe the math is not correct
Well you're not setting speed either.
spawnParticle(Particle, location, amount, deltaX, deltaY, deltaZ, speed)
the point.getX
world.spawnParticle(Particle.FLAME, particleLoc, amount, 0, 0, 0);
Yep, and if you want speed, add another int
how'd you make it blue tho?
wait there's a speed :O OH thats the "extra" in the docs
That's the soul fire particle or something
ah
yup
Extra is for stuff like Redstone Dust particles & their colors.
Yeah, DustOptions I believe? Only specific particles will accept the extra options though
error or just not accept?
I think it throws an error but I'm not 100% sure
Why doesn't it remove entries?
infectionEffects.entrySet().removeIf(entry -> {
System.out.println("KEY: " + entry.getKey() + "; VALUE: " + entry.getValue());
System.out.println("CHECK: " + entry.getValue().isEmpty());
return entry.getValue().isEmpty();
});
[20:33:20] [Server thread/INFO]: KEY: 10; VALUE: {}
[20:33:20] [Server thread/INFO]: CHECK: true
Depends on your map impl
removeIf(entry -> entry.getValue().isEmpty()) Have you tried this?
HashMap
Can you post more of the code then cause that should work.
doesnt this remove the entry from the entrySet() that might be cloned / new and not from the hashmap ?
The map interface defines that removal of elements in the entryset is passed on to the map
The same applies to the keyset and values set
wdym
You're running remove while you're looping through the list.
It won't do that.
Unless you use an iterator.
Yeap didn't see that lol
I would say the issue lies in that the element is removed but too late or something
It prints me the keys and value of this map every second and nothing changes
[20:39:34] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:39:34] [Server thread/INFO]: EFFECTS: {10={}}
[20:39:35] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:39:35] [Server thread/INFO]: EFFECTS: {10={}}
[20:39:36] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:39:36] [Server thread/INFO]: EFFECTS: {10={}}
[20:39:37] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:39:37] [Server thread/INFO]: EFFECTS: {10={}}
[20:39:38] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:39:38] [Server thread/INFO]: EFFECTS: {10={}}
[20:39:39] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:39:39] [Server thread/INFO]: EFFECTS: {10={}}
For the hell of it, try an iterator for loop.
u mean instead of the lambda?
or what
yes
which
for(Iterator<k, v> it : infectionEffects.toIterator) I think
u mean instead of this?
infectionEffects.entrySet().removeIf(entry -> {
System.out.println("KEY: " + entry.getKey() + "; VALUE: " + entry.getValue());
System.out.println("CHECK: " + entry.getValue().isEmpty());
return entry.getValue().isEmpty();
});
yes
ok
Another thing you can try (I think it might error though) is just running inffectionEffects.remove(key) since you delayed it by a tick.
yeah, I tried
it throws me the CME
Ok yeah I thought so. Didn't know for sure.
You also could switch the original forEach lambda to an iterator and you won't get an error for removing during the loop.
Iterator<Map.Entry<Long, Map<PotionEffect, Integer>>> entryIterator = infectionEffects.entrySet().iterator();
while (entryIterator.hasNext()) {
Map.Entry<Long, Map<PotionEffect, Integer>> entry = entryIterator.next();
if(entry.getValue().isEmpty()) {
System.out.println("REMOVED!");
entryIterator.remove();
}
}
[20:53:23] [Server thread/INFO]: REMOVED!
[20:53:24] [Server thread/INFO]: TASK IS BEING EXECUTED!
[20:53:24] [Server thread/INFO]: EFFECTS: {10={}}
Same, @stone sinew
So you add to the Set afterwards?
?
So you add to the map
Yeah the only thing I can think of is because you running it within another forEach lambda. Try changing the original lambda to an iterator and just use iterator.remove()
Like do you invoke Map#put
So a system.Out.println infectionEffects after your removeIf
you mean to remove the iterator and change it back to the removeIf() method?
and then to add debug
after it
I kinda doubt that removeIf is bork, it is more likely that you are regenerating the entry
Yea
default boolean removeIf(Predicate<? super E> filter)
Removes all of the elements of this collection that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller.
Implementation Requirements:
The default implementation traverses all elements of the collection using its iterator(). Each matching element is removed using Iterator.remove(). If the collection's iterator does not support removal then an UnsupportedOperationException will be thrown on the first matching element.
Parameters:
filter - a predicate which returns true for elements to be removed
Returns:
true if any elements were removed
Throws:
NullPointerException - if the specified filter is null
UnsupportedOperationException - if elements cannot be removed from this collection. Implementations may throw this exception if a matching element cannot be removed or if, in general, removal is not supported.
Since:
1.8
So?
nvm, I just sent it for you to make sure that u are right
I mean to give u the possibility to check it out
@quaint mantle, lmao, [21:03:54] [Server thread/INFO]: AFTER REMOVEIF: {}
infectionEffects.entrySet().removeIf(entry -> {
System.out.println("KEY: " + entry.getKey() + "; VALUE: " + entry.getValue());
System.out.println("CHECK: " + entry.getValue().isEmpty());
return entry.getValue().isEmpty();
});
System.out.println("AFTER REMOVEIF: " + infectionEffects);
I fixed it somehow
ty for trying to help me
private HashMap<String, UUID> chunks;
plugin.addChunk(chunkID, player.getPlayer().getUniqueId());
public UUID getOwner(String chunk){
return chunks.get(chunk);
}
Error: getOwner returns null
Use: Trying to get the UUID of the chunk owner from the hashmap
If you know why I might not be able to get the UUID I would appreciate it!
Whatever you're passing into getOwner doesn't exist in the Map
But I have UUID a part of the hashmap? Did I set it up wrong?
You have to add them into the Map first
How?
Oh wait
public void addChunk(String chunk, UUID owner){
chunks.put(chunk, owner);
}
This is a part of the program
I just put the parts I think are the issue
If you might know why this is happening I would appreciate the help
So working on a plugin that uses PlayerDropEvent on 1.12.2 and for some reason it cannot get the players opened inventory since i'm checking if someone drops an item and it will give them 10 levels of a custom enchants but i was first trying to get the inventory's name by sending a player a message and it doesn't even send a name
Hi, can I check permissions for other plugin's command, and if player doesn't have it, interrupt command execution?
Search the docs for getCommand and get permission or something
But they should already be stopped...
Yes, but I ran into different error messages problem, so I want to unify it
Do you know how to intercept command execution before it goes to the other plugin?
PlayerCommandPreprocessEvent
what do you guys check for if looking for crits? i do
boolean crit = p.getFallDistance() > 0.0 && !((Entity)p).isOnGround() && !p.getLocation().getBlock().isLiquid() && !p.hasPotionEffect(PotionEffectType.BLINDNESS) && !p.hasPotionEffect(PotionEffectType.SLOW_FALLING) && !p.isInsideVehicle() && p.getLocation().getBlock().getType() == Material.AIR && p.getAttackCooldown() == 1.0; any other ideas?
its not 100% reliable so hats why im asking
why the SLOW_FALLING check?
even tho criting during slowfalling does produce particles, its doesnt actually increase the damage
in NMS i remember a flag where check the critical... and dont remember the SLOW_FALLING for this i ask
oh ok
Do you think something like this should work?
@EventHandler
public void onCommandPreprocess(PlayerCommandPreprocessEvent e) {
getLogger().info(e.getMessage());
}
because it doesn't
how do you get the top of an open inventory using PlayerDropEvent
because whatever i try it does not work
Hi guys, quick question. Does anyone know if it is possible, with gradle, redirect the output of the task "buildsNeeded" inside one single fat jar (Without using plugins like shadow)
what is a top of an open inventory
I'm making a plugin where if you die you get banned, But I want it so then if the player has not logged on before there will be a 12 hour grace period, how do I get it so then it ignores the event which gets you banned if you die?
so when you have an chest open there is a command that you can do player.getOpenInventory().getTopInventory() which will get the top gui
which you can use for stuff like PlayerDropEvent to see if the item is part of the top inventory
but it does not work for some reason
Oh you mean the Chest GUI compared to the player inventory?
kinda, since i am trying to make a custom enchant plugin for a javarock server which with geyser it doesnt send the server the right click packet for inventories so i have to check if they drop an item
so using PlayerDropEvent and checking the OpenInventory.getTopInventory().getName() should get its name but it doesn't show up
Use Player#getFirstPlayed and if the time between the current time and that time is less than 12 hours, don't ban them
it seems like the event doesn't even go off when you have an gui opened
how would I check the time between those two?
Subtraction
this video demonstrate what happens
while trying to use the PlayerDropEvent
with a custom gui
Well the event is being fired somewhere since it's being cancelled.
it is not being used anywhere else
this is the first time its being used
and this is the code i'm using:
public void onInventoryDrop(PlayerDropItemEvent e) {
Player p = e.getPlayer();
Inventory inv = p.getOpenInventory().getTopInventory();
String isinvnull = inv.getName();
p.sendMessage(isinvnull + "");
p.sendMessage(i.getName());
}```
it sends 0 errors in console
You need InventoryClickEvent with ClickType of DROP
okay
PlayerDropItemEvent only fires if they drop something from their inventory.
It works now ty very much DessieYT
How would I log their time played though?
I have a general idea of getting the current time but past that i'm a little confused
You don't have to log it, it's already logged for you.
Player#getFirstPlayed
Is it 12 hours from when they join or they have 12 hours of playtime?
12 hours from when they join
Yeah, Player#getFirstPlayed then.
Alright thanks
Hi everybody. I am a minecraft developer with Russian )
How many maximum people were on your server without bungee?
user@server:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-16-oracle/bin:/usr/lib/jvm/java-16-oracle/db/bin
Hi, does anybody know, where the file for the /usr/lib/jvm/java-16-oracle/bin:/usr/lib/jvm/java-16-oracle/db/bin section of the path is? My .bashrc file doesn't configure anyting path related and /etc/environment is just the default path.
Depends on the specs of the server and the version...
Is it possible to detect when an entity plays an idle sound using events or packets?
You'd have to use packets
Not all sounds are server side though. I'm not sure how idle sounds are handled
Do you know what packets I'd need to listen too?
Sorry still not great with packets, especially in 1.17+
It would be the NamedSoundEffect packet
Ok Ill take a look and see if i can figure something out
contents probably
also is the name of the inv nullable?
probably
private Inventory cloneInventory(Inventory inv){
Inventory cloneInv;
if(inv.getType() == InventoryType.CHEST) {
cloneInv = Bukkit.createInventory(inv.getHolder(), inv.getSize(), inv.getTitle());
} else {
cloneInv = Bukkit.createInventory(inv.getHolder(), inv.getType(), inv.getTitle());
}
cloneInv.setContents(inv.getContents().clone());
return cloneInv;
}
``` seems about right doesn't it
Do you know why .getPermission() called on default server command is working well, but when this command is from other plugin it returns null?
Did said plugin define a permission
I think that plugins like essentials or luckperms has defined permissions on commands
Check their plugin.yml
oh, they don't have in plugin.yml :v
In that case how can I manage permissions for their commands?
The name can be null
In that loop it's probably fine
When the server doesn't have a username stored
I want to check permissions for command before the other plugin does it, so how can I check it in that case? They must somehow check permissions because I can set they in permission plugin
if a plugin has assigned a permission to a command it never executes the onCommand
it never gets to check the permission. Spigot does it
Yeah, but the plugins doesn't have permissions in plugin.yml
bad plugin then
So where they have it? If I ran .getPermission() it returned null, so I think the Spigot doesn't check permissions for these commands
you ran .getPermission() on what?
I don't think that Essentials and LuckPerms are bad plugins
server.getPluginCommand(name).getPermission()
do you mean that threw an NPE or you checked the returned value?
I logged it and it says null
@EventHandler
public void onCommandPreprocess(PlayerCommandPreprocessEvent e) {
String commandName = e.getMessage().substring(1);
Command command = server.getPluginCommand(commandName);
if (command == null) command = commandMap.getCommand(commandName);
server.getLogger().info(command.getPermission());
}
Essentials registers the command but no command perms
Love essentials for that
CMI is even worse
So from where LuckPerms can autocomplete perms from essentials?
the perms are registered, but not with each command
LuckPerms command's permissions return null too :v
as I just said
Is there any chance to check permissions for command from these plugins?
So I must manually create a file with every permission listed?
So there's why they have custom deny messages :v
Yes
This is my main problem, so I read that any permission is handled by Spigot and I have an idea to create plugin to unify those messages... but it turned out that it isn't that easy....
What is a reason for that?
Are there real advantages from that?
I mean I do like having a custom no permission message
Plus you can make it editable and therefor translatable
Yeah, but some plugins, like Multiverse-Core doesn't have those messages.. Instead they just silently skip a command execution
And if you use for example paper, you can set your own message for lack of permissions :v
So I have an another idea 😅
Can I just remove Multiverse-Core commands form tab autocomplete? Because even if player doesn't have permission they still appear :v
There's an event you can use
Command send or whatever for 1.13+
Tab complete for older
I'm making it for 1.18
Yeah the is an event where the command list gets sent to the client
You can remove entries from it
I'm making a plugin where if you die you get banned, But I want it so then if the player has not logged on before there will be a 12 hour grace period, how do I get it so then it ignores the event which gets you banned if you die?
I've got this so far:
Date firstPlayedDate = new Date(player.getFirstPlayed());
You just need to check if (player.getFirstPlayed() + TimeUnit.HOURS.toMillis(12)) <= System.currentTimeMillis(); is true and if so ban them
So using that if statement to check if its equal to or above 12 hours played
yes
Am I allowed to ask basic things about Java here?
{
player.getInventory().clear();
player.banPlayer("You have died", Date.from(now.plus(duration)));
}```
Its telling me it has an empty body but it dosent?
Remove semicolon
Yes but don't expect people to code for you
Oh, how dare you, md5, I code my things myself
I just have weird problems while trying to build one library from github and idk what to do actually
It says
C:\the_path\GetPlatform.java:8: error: unmappable character (0x8F) for encoding windows-1252
* platform. Possible values: *'ios' — iOS,, *'android' — Android,, *'winphone' — Windows Phone,, *'web' — приложени�? на vk.com. By default: 'web'.```
Idk looks like gradle to me
SO didn't give any meaningful answer, so perhaps people here are slightly smarter?
Idk
Yes it is
Google gradle utf8 or something then
Sure, that's the first thing I did actually
how could i set a custom serializable to the root config path
Can someone help by writing a code that creates a config
something like config.set("", myObjectHere)
yo how do i set my plugin version as 1.8.8 with maven (using IntelliJ)
==: my.cool.object
my-cool: data```
and to get, config.get("")
[07:05:02 WARN]: at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
[07:05:02 WARN]: at java.base/java.io.File.createNewFile(File.java:1034)```
is there a reason why my file isnt creating?
``` if (!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}```
its saying it doesnt have permission and yes the directory is correct
so the permission is not then?
no like the file isnt creating its saying it cant create the file because it doesnt have permission
so check your permissions
make sure the folder is writable as the user you are running as
there's a nearby entities method, or just check their position with location.distance (squared)
whatever you pass as params
is there a way to create an entity, but completely remove all methods of saving it so when a world is reloaded/server restarts/crashes, the entity no longer exists? I mean other than from sending packets to users that are close to the entity. In any normal case I'd just store them in a list and remove then when the plugin disables, but if the server or plugin crashes, those entities will still be present causing issues
how did spigot patch the log4j thing if it's shaded into the vanilla server?
Does anyone recieve ``` Pulling updates for C:\Users\DevCow\Desktop\Build\BuildData.git
Successfully fetched updates!
Checked out: 0630ea462a82fdbd93018de7d5ec5e9d3b3c732b
Pulling updates for C:\Users\DevCow\Desktop\Build\Bukkit.git
Successfully fetched updates!
Checked out: 1d2509b99fb10b3bd6f597e63805f85b49d5a055
Pulling updates for C:\Users\DevCow\Desktop\Build\CraftBukkit.git
Successfully fetched updates!
Checked out: 7019900e276b7c9f6e940debf8529094c7f4da0c
Pulling updates for C:\Users\DevCow\Desktop\Build\Spigot.git
Successfully fetched updates!
Checked out: 550ebace4b43adc73854d7d5976e1343eba6fb98
Attempting to build Minecraft with details: VersionInfo(minecraftVersion=1.8, accessTransforms=bukkit-1.8.at, classMappings=bukkit-1.8-cl.csrg, memberMappings=bukkit-1.8-members.csrg, packageMappings=package.srg, minecraftHash=null, classMapCommand=null, memberMapCommand=null, finalMapCommand=null, decompileCommand=null, serverUrl=null, mappingsUrl=null, spigotVersion=null, toolsVersion=0)
Exception in thread "main" java.io.FileNotFoundException: work\minecraft_server.1.8.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.spigotmc.builder.Builder.main(Builder.java:411)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
didnt even know buildtools built anything lower than 1.8.8
couldve sworn it autoupgraded 1.8 to 1.8.8
it upgrades some of the closer versions, like 1.8.5-->1.8.8 I think
Too old! (Click the link to get the exact time)
incredibly
ah
fkn 1.8 gonna be older than the kids asking how to run it soon
will this trigger an endless loop?
anyone?
probably
looks like it
fix your permissions
wdym
what are the permissions on the folder
there are none
chmod
any way to not make it run in a loop?
How can i add xp without that event getting called?
(I am trying to sync all players xp)
what OS?
for the server?
yes
not sure where to find that on my server host
could possibly try and keep track of how much exp was given and then if it matches the last known amount, skip distributing? idk, slightly jank idea but might work
plugins/<my plugin name>/stats/data.yml
does the stats folder exist
yes
or actually, maybe theres a way to see the source the exp?
so if source is plugin itd b ignorable
doesnt look like it, rip
oh wait, interesting line in documentation
"Called when a players experience changes naturally"
so maybe it wont loop?
thanks md_5 for the help
Use PlayerExpChangeEvent#setAmount
wym?
i want to change it for every player
besides the one that the event originated from
i am trying to sync the xp of all players
so everyone has same level/xp
if i pick up an xp, it also gets added for everyone else
if i spend xp, everyone else also looses it
You can probably safely call Player#setExp and it won't trigger the event.
Not sure about giveExp, you'll just have to try it I suppose.
why wouldnt that trigger the event :o
oh, then setAmount also wont trigger it i guess
setAmount definitely would not
It probably wouldn't.
gotta get a friend to help me test
Hey, I was wondering if there's a way to get the translatable name from an item stack/material/etc that can be used in a translatable component? E.g. "item.swordDiamond.name" for a diamond sword.
Like, getting what the name of "Diamond Sword" would be in Spanish for example?
No, much simpler, like getting the literal string "item.swordDiamond.name" if like the current material was indeed a diamond sword.
sigh I was afraid of that. I was using NMS for it before, but with the whole remapping component to using server internals, I was hoping there was an API way.
Is there a serverbound packet for when a player stops using a spyglass? There has to be right? How else would other players see the original player put down the spyglass?
there is an api
?jd-bcc
anyone?
Yes I know about translatable component. The issue is I need the specific locale key for the itemstack/material (given an arbitrary item) to construct the translatable component.
you seem to not have the perms to write to that file
how/why though? its using a plugin
on what OS are you running the server
idk how to check
windows... linux... anything
um windows i think? its a host
can you somewhere adjust the permissions?
Well then do that?
How hard would it be to create a plugin that just prevents learning Recipes from the world (requiring knowledge books) ??
Its implemented in 3 commandblocks right now... is something like that an easy translation to plugin ?
@dry forum do u have ssh access to ur server
yea
ssh into it, and see what happens when you run uname -a
if it fails, ur on windows, if it succeeds, ur on some variant of linux probably
its linux
Hi, I have a little problem, I'm trying to change the spawner entity type, but it doesn't seem to want to be changed 😢
Does someone knows what I'm doing wrong here ?
ItemStack itemToDrop = new ItemStack(Material.SPAWNER);
BlockStateMeta itemToDropIM = (BlockStateMeta) itemToDrop.getItemMeta();
CreatureSpawner spawnerState = (CreatureSpawner) block.getState();
spawnerState.setSpawnedType(EntityType.valueOf(getProbabilityEntityType()));
itemToDropIM.setBlockState(spawnerState);
itemToDrop.setItemMeta(itemToDropIM);
does spawnerState need .update() ? I forget
Tryed the .update()
Just need it when it's an already placed block
otherwise, it shouldn't, or at least, here it doesn't seems to work
are you in creative/op. Usually you need that to place tile entity with data
Nope, the fact is that I get a normal spawner dropped, not the one with the actual entity in it
Always a pig spawner
I tryed giving to me a spawner with essentials for example, and it works well, I can place it and the entity is the correct one
So I guess, there's something wrong with my code :/
its EntityType.valueOf correct?
ie returning correct type
otherwise code looks fine to me so idk
ZOMBIE should be a valid entity (I placed some debug lines, cause I thought about the same, that the valueOf was incorrect)
Wait, am I stupid, just gonna check how essentials does it x)
Ok they do the same 😭
That's it... But the Essentials ones works, they maybe do it with nms ?
Looks good to me
I expected that a new folder would be created where the plugin's .jar file was located.
am I thinking about the folder location wrong?
yes
You just want to make a dir with the plugin name into the plugins folder to put some files ?
x)
🤡
With SQLite, should I keep the connection open?
Never keep a connection open
if you need to make more than one statement at a time, just use transactions
Not sure that’s true
I think with sqlite especially keeping the connection open is better
I'm having problem with saving multiple data at once with SQLite, connection getting closed etc, and sometimes I get SQLITE_BUSY error.
As it only allow one connection at a time, keeping the connection open, will just crash the whole thing
Making sure to close the connection and opening when needed, will just avoid any problem
So just store it in the field, and if the connection is closed or null, open the new one?
Pretty sure that’s what I do
Anytime you make a query, just get the connection, your connection getter should check if the connection is still opened since you can't open two connection at a time in SQLite
if it's already open, then just return the open connection
I already do that, but I still received error, saying that connection is closed
Well, you're doing something wrong somewhere
Could be, I'll try something
Maybe, you're trying to read a result while your connection is closed ?
When you read a result, the connection must still be open
I'm using hikari for the mysql
You can use it also for SQLite
yup
Just set the engine to SQLite
You have a lot of information about that on their doc
do i need to set it on the HikariConfig?
i guess so
lmck
yup, get the config, and change the JdbcUrl
That's what I use to check my connection
public Connection getSQLConnection()
{
try {
if (getDs() == null || getDs().isClosed()
|| getConnection() == null || getConnection().isClosed())
{
setConnection(getDs().getConnection());
}
return getConnection();
} catch (SQLException ex)
{
plugin.getLogger().log(Level.SEVERE, "SQLite exception on initialize", ex);
}
return null;
}
do i need to set the maximum connection too?
In SQLite, it's 1 max anyway
Okay, this is my HikariConfigBuilder, take a look at the buildSQLite, is that correct? https://paste.md-5.net/apalequtax.java
what are the required config?
I would set a leak detection threshold
The connection timeout, the test query
on SQLite if you use foreign keys, add an init sql such as "PRAGMA foreign_keys=ON"
how much should i set on the leak treshold?
10k should be good
alright, perfect
if youre using hikari, you should be closing your connections iirc
Oh, here you have your problem with the connection closed error then ^^
Don't use that while getting results if you have methods that makes the queries, the results need the connection to be open
slf4j sounds a lot like log4j... It's for database connection pooling. Could that also be vulnerable? I don't understand the exploit and it just reminds me daily that anything can happen, I wish I had the tools to fix this myself / secure the code. Ugh I do not wanna write my own connection pooling class though
theyre logging libraries, have nothing to do with database connection pooling
I was just sitting there after a brrrrutal quarter in computer engineering and I was like did spigot really just like use a random infected library? Like is this entire exploit just because no one looked at some code?
im also still stunned by the fact that a logging framework managed to create an rce exploit
this isnt just spigot btw, other online services were also effected including miencraft itself
Here's my SQLSession class, class that handle the connection basically, what do you think? https://paste.md-5.net/qawasanubo.java
@summer scroll You're using try-with-resources on results queries
It was just like so many discord @ notifications during finals week and I have to say, it was pretty alarming. Every server was like "we patched it" but some POM got updated and that was it? Literally just look at the code next time?
yeah i haven't changed that, is the getConnection correct tho?
That's a problem
You can't
yes because the vulnerability was in log4j not any of the server softwares itself
sol they just bumped the version in pom
i'm changing the executeQuery now, i'm asking about the getConnection
its a bit more complex than just "looking at the code"
i mean even apple has stuff like this from time to time
Looks good, but you should also check for you DataSource, if it's open or not
iirc IOS 14.7 and 14.8 patched 2 remote 0-click iMessage exploits
What should I do If it's closed?
open it
True in high school there was dumb stuff like sending some characters via text and the persons phone would just restart
By initializing datasource with the hikariconfig?
LMAO i still remember that my old school board allowed students to shut down the entire computer lab with 1 command
Actually, if the ds is closed, it means that you closed the pool, shouldn't happen, but yes, you can reopen it with the hikariconfig
Yeah, I never closed the pool really.
Here's the new executeQuery https://paste.md-5.net/ibuhanukot.cpp
well, close it on disable
Still nope
Don't use try-with-resource x)
closing the preparedstatement, will close the connection
like at all?
Just use your ResultSet, and then, close the connection
okay, what about this? https://paste.md-5.net/ahapomorig.cpp
what
Looks good to me x)
btw, closing the ResultSet will close the ps
Hey, can someone help me out with Streams? I've never worked with them before.
I'm trying to loop through a list that contains a list of commands and get the
respective subcommands but my current stream seems to only return the commands from the first list. I.e: it's not grabbing the subcommands from each object but rather the command from the main object. I saw something online about a flat map but couldn't really make sense of it. Is that what I need to use or...?
Regular map instead of peek should be fine
And no need to collect if your just forEaching after
Yeah, I was trying a map but I guess I'm doing it wrong bc its not bringing up the respective methods
Hmm?
I don't think so?
So I have a List<abstractCommand> (each abstract command will be implemented and has getName() and getSubCommands()). I'm trying to iterate through each abstract command and run the getSubCommands() for each
I know I can just use a regular for loop but I feel like it would be better to use streams for 1.) efficiency and 2.) practice/understanding of streams
if youre just trying to list them in console
u should be fine to just do "Found command: " + cmd
oh actually maybe it would be
abstractCommands.forEach(cmd -> abstractCmd.getSubCommands().forEach(subCmd -> Utils.msgConsole("Found " + subCmd)));```
Well, the list to console was more for debug purpose. I was going to run setExecutor on each
I tried something similar to that as well but nothing
because your getSubCommands() returns a List<String> ...
Ahh, hmm.
Okay, got it w/ java abstractCommands.forEach(cmd -> cmd.getSubCommands().forEach(subCmd -> Utils.msgConsole(Utils.INFO + "Found Command: " + subCmd)));
hm
persistent data is pretty chill, been using it to store some stuff for custom mechanics for me :D
is there a way to set the entire chat message in AsyncPlayerChatEvent without the string formatting?
because when using setFormat when players send a message with % it breaks
Anyone have a Util to save Player inventories?
Base64
what do you mean
are you on paper?
that doesnt work
still has the same error UnknownFormatConversionException: Conversion = '%'
im just testing it rn but
String foo = "foo";
String test = "test";
System.out.println(String.format("aaaa %s mmmm %s, eeee replace".replace("replace", "\\%"), foo, test));```
i want to make a custom chat format like event.setFormat("%s: %s"); which will do playername: message but if the player sends a message with % it breaks
It's worth noting that streams aren't faster
They are often cleaner but they are a bit slower than regular iteration
This is not really a good way to do it
It'd be better to use flatMap
im still not sure what hes trying to do anyway
@worn tundra
abstractCommands.stream().flatMap(c -> c.getSubcommands().stream()).forEach(s -> Utils.msgConsole("Found " + s));```
That means you only need to fix the message lol
Why are you working on the whole format
because it doesnt change anything
Take the message string and replace the special symbols in it
Though...
itll still translate to %
That is a really, really verbose way to do commands @tired dagger
no lol
The savings you're making in lines of code from using streams in iterating over them is lost tenfold in the verbosity of the actual code it takes to implement one command
Wdym? Only one line is needed to register a new command
Ok but look at all the code it takes to define a command
This is the screenshot you posted
That's insanely verbose
Reco then?
I've got a much better alternative, can I DM you
I hope its not ACF, Idk how to use that
It's not ACF
Continue
How about a little demonstration
Let's say you want to write a command like this:
It's run with /smite
mmhmm
You can run /smite to just smite yourself
But it can only be run as a player like that
Otherwise, you can run /smite <player> to smite a specific player
Which can be run from console
And it requires the smite.use permission to be run
How would you implement this?
Constructor overloading?
How so
You don't have to write up all the code
But it'd be a fair bit of code, right?
I suppose
I can do it in 4 lines of java
And 4 lines of rdcml
smite player:target?(context self) {
permission smite.use
hook smite
help Smites a player, or you
}```
@CommandHook("smite")
public void smite(CommandSender sender, Player target) {
target.getWorld().strikeLightning(target.getLocation());
}```
The top there is rdcml, my custom file format for command metadata
It lays out all the necessary information about the command: name(s), help message, permission, arguments
player:target?(context self) is the most complicated part here
But it's basically just saying "take a player as an argument, optionally, and if no player is specified then use the sender"
a ternary
mm
And (context self) tells it to use a context provider called self to fill in the default value
Interested?
what is this from?
My command library
It's my custom format, rdcml
(has an intellij plugin for error checking and syntax highlighting)
what's the overhead
Haven't really measured it but I've used it on big servers without issue
Yep that's the one
Skript is a command library too :3
Skript 🤢
Mine is very much not a scripting language, it's a markup language
All it does is try to minimize the amount of error checking and conversions you need to do, then pass the arguments off to your hook method which can do whatever
One of the reasons I did mine like so was bc I didn't want "partial commands" i.e. every command I create must have a name, desc, perm, etc.
Yeah you can very easily do that with this
Including for subcommands
basecommand,alias {
help This is the command description
permission permission.node.here
subcommand,alias {
help This is the subcommand description
permission another.permission.here
}
}```
Will create a command with a subcommand
plugin.yml with extra steps :3
It's really, really not
lol
It automatically handles argument type conversions, tab completion, permission checks, help menu generation, optional arguments and default values where applicable, and cuts through the boilerplate of writing commands like a hot knife through butter
You can't specify arguments in the plugin.yml other than saying the usage, and it won't make the checks and conversions for you
hey
why'd you delete that top tier message
But wouldn't you have to remember that syntax every time? Thing I like about mine is it forces you to implement all the methods. I.e. the IDE will throw an error so you don't forget
What do you mean
For the syntax of the command file there is an intellij plugin that will check errors and do syntax highlighting for you
It's very nice
👌
Does it support color codes?
What do you mean
Like
Do you mean for help messages?
uh huh
No need
The only thing you need to specify is the message
It handles everything else for you
Example
All of the messages seen here are configurable
So you can change the colors or format if you want
Individual commands shouldn't be specifying the colors for their help messages, it should be consistent
Though you can if you really want to for some reason
Interesting
what would be the best approach of creating a wither boss type of spawn (4 blocks, 3 heads, same positioning) but with different block materials and skull textures
You can read about it here: https://github.com/Redempt/RedLib/wiki/Command-Manager
I have done this exact thing before
It's pretty annoying
😔
I can show you the code if you want, but it uses lots of stuff from my library
anything would help i just need a step in the right direction pls and ty
This plugin would let you make configurable "crafting structures"
You could make them out of any blocks and use skulls with custom textures
And then set custom commands to be run when the player placed all the blocks
Would account for different orientations, mirroring, etc
And md_5, your thoughts on the lib?
Idk
Give it a shot and see if you like it
If you have any questions feel free to DM me or join my support discord and I'll answer them
Let me re-phrase: is my current method overkill and/or what would you do differently
It's overkill but there's not a great way to make it a whole lot better without some very high-level abstractions
Using an existing library is the best way
And if you want to practice streams there are plenty of other opportunities
My library makes pretty heavy use of lambdas and streams
See, the reason I'm reluctant is I didn't necessarily want to rely on external APIs for my plugins
Because you don't want a plugin dependency?
Essentially
RedCommands and RedLib can both be shaded
RedLib can be used as a plugin dependency and shades RedCommands
Right, but in the case I continue to build more complicated commands I know how to update the code I wrote. Comparted to if, in a future case, the RedCommandsLib isn't maintained
*compared
It's really not version dependent
It works for 1.8-1.18 with no changes because command logic really does not change between versions
And I have actively maintained it for almost 4 years now
And there's extensive documentation + a support discord if you need help building more complex commands
I have built all sorts of stuff, it's very flexible and powerful
hm, i got one 4 u i think
why should i use it over aikar
say i dont need the custom scripting lang, just annotation processed commands
It's much less verbose
rdcml is really easy to learn, since it's not a scripting language
Just markup basically
can u give a more complex example then, since this one is also pretty easy with aikar
lets say i am a masochist that likes annotations, dont wanna use rdcml
What command would you have me implement
idk, something that aikar couldnt easily and red has the verbosity to
I don't really know the capabilities of acf since I don't use it
I have several plugins on my GitHub that are good demonstrations of its capabilities
PlugWoman and RedClaims
would I be able to cast org.bukkit.block.Block to nms block or would i have to cast craftblock
There's the command file and command listener for PlugWoman
Why do you want to use nms
i found a method in nms that allows me to check the block pattern, i'm not making a multi version plugin it's version specific xd
I really wouldn't do that
The logic isn't hard to implement yourself
Don't lock yourself to one version and/or unnecessary maintenance effort even if you think it doesn't matter now
https://github.com/Redempt/PlugWoman/blob/master/res/command.txt#L34 mmm posix-y, i like it
it's for a commission, will only be used once then never again xd
they are more or less something i wish more things with "commands" had but i guess the average user would prefer arguments?
yeah
That one lets you specify any number of plugins to reload
And pass -c to not ask you to confirm
Also they can be combined like Unix flags
There's -c and -d so you can do -cd
now we just need piping
Lol
If you're interested you should check out the docs
They go over how everything works in detail
I'm going to bed now
Goodnight yall
Gn
what was that one prefix for player skulls where u could get mob heads
it was like something_MobName
i.e. Prefix_Villager
it was mhf
but mhf_axolol is taken
sad
is there a good way to store temporary player-related data?
A map?
):
how to use remapped version of spigot in gradle, do i need to shadow it?
Don't shadow it
will it work on non-remapped servers then?
You would need an alternative to the maven special source plugin
I'm not aware of one. So either use Paperweight or obfuscated names
There's paperweight from paper
how do i use it? i don't find anything in readme
Documentation wen
Can some one explain what PrintWriter pw does?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It writes to a file
Then it means pw will encode UTF-8 and possible to edit 'file'?
it has an UTF8 encoding and it will write to a file
Hello , i have a problem with buildtools
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
does anyone know a good library that can replace protocolib and i can just shade it inside my plugin?
why not protocollib
Does anyone want to get into a call and help me with my config file issue?
please help .
its the same problem for all spigot version .
Please
delete your BT and download a new one
https://dontasktoask.com
Just ask your question
I have a question about Java but I'm too lazy to actually formalize it in words unless there's someone on the channel who might be able to answer it
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
:)
no one will jump to help you if you don;t ask an actual question
Ok
Can anyone help me fix my code because It's currently not creating a config file, I've looked at several tutorial including the one on the spigot website but non of them work.
There is probably and easy fix but I don't know what it could be.
Whenever I ask a group they just give me the same reply so I would like someone to hop into a call and help me fix it.
:)
This is the same person who sent me the advertisement in private messages😒
Lmao I don't know who you are
Oh crap sorry that was for a voting chat for a server that I'm on
I think I accidently sent it to you
in your onEnable add saveDefaultConfig(); and make sure you have a config.yml in your jar
I did that but I didn't work
it can't not work
I must be missing something
either your plugin is not running at all, or there is no config.yml inside your jar
use an archiver like 7zip and open your jar. See if the config.yml is actually inside your final jar.
It's there but It's not working
?paste your main class
paste teh link it gave you in here
ok, now do the same for yoru servers startup log latest.log
thats not what I asked for
yes
your plugi is not running getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[XTC]: Friend Plugin has started"); is never displayed
to me it looks like you never put the plugin on your server
is yoru plugin called FriendTP?
Yes
add an @Override annotation to your onEnable and onDisable
I thought it would be that
kinda
java: method does not override or implement a method from a supertype
And I get this
Again
No, he's not
your code will also explode at the line if (!f.exists()) {
trying to save myself some directories/space, do u guys think/know if itd be possible to bundle a server-side fabric mod and a spigot plugin in the same project?
i feel like it should be fine since i think theyd only try to load if they are called by Fabric or Spigot
Should I have saveDefaultConfig(); in the onDisable(); ?
Ok
It probably depends on what annotations Fabric uses
im doing mixins on the fabric one, but i have a feeling that as long as something doesnt try to run something from a class not for that env (ex: fabric trying to load a spigot thing) it should work
i just dont want 2 projects for cores that im making essentially 1:1 for my fabric n spigot servers
like i am fairly certain that each side will only load in their respective enviroments, i guess i could https://tryitands.ee/ later when im on pc
im kinda thinking of it from how you can work on a bungee and spigot plugin in the same project and each will only load if bungee or spigot does it
Should I use a config.yml file to store data about the plugin to remember?
depends on what data
I have an ItemStack im getting from config, and its given to a player when i restart the server and trigger this action again, the items arent stackable is there any reason why this could be?
that is an awfully interesting texture u got there
sulfur 🤩🤩
its from rust hahaha
someone knows hahaha
How about stone and metal?
lmao
I actually have this plugin to generate random resources nodes as well, working on crafting as well but this bug is rather hindering
the itemstacks won’t stack if something is different about them
are you setting lore or anything?
Theyre both exactly the same and created the same way
Does paperweight support mc 1.13? Could not find io.papermc.paper:dev-bundle:1.13-R0.1-SNAPSHOT.
Lore, displayname, and some PDT Strings
wrong server
pdc might affect it - how are you making the itemstacks
let me see if i can get pieces of the code from github to show you
ok
i dont think this is the right server..
how do i use 1.13
Method wrapper for getting from config:
Method for actually loading from config: https://github.com/Burchard36/RustCraft/blob/b11f6a09705698006b10b29fc1073036561e9f06/src/main/java/com/burchard36/rust/config/DefaultYamlConfig.java#L169
On node break it uses those 2 methods above: https://github.com/Burchard36/RustCraft/blob/b11f6a09705698006b10b29fc1073036561e9f06/src/main/java/com/burchard36/rust/events/event/BlockBreakListener.java#L65
And is finally added to the players inventory here:
RustItem class (Recipe storage is messy dont yell at me pls)
ItemWrapper is basically itemMeta and itemStack stored, edits them and then returns the stack, its from my API im not sure if you need that or not
Its just basically to edit the item stacks easier
And in game they are the same item with F3 + H is enabled
Plugin#isEnabled does this return true when plugin is still enabling?
No, not until onEnable is finished
Im gonna use the /data command on these 2 items actually gimme a sec
shows them as identical..
Cant pretty print, its not valid json outside of mc but:
Item 1: https://www.toptal.com/developers/hastebin/izugoyahib.rust
Item 2: https://www.toptal.com/developers/hastebin/ezocilogas.rust
Player = valueOf(strings[0]); Would this check if string 0 is a player?
no
no you need to use Bukkit#getPlayer(String)
What would that look like?
Wtf i relogged and it works now
You use the Player variable to equal the getter i sent
And now new itemstacks created cant stack into each other.. why do i always have this issue with ItemStacks loaded from config
How do I know if the received String value is an existing EntityType?
Hello! I have a map with the following structure:
Key: Time (long) and Value: Map of potion effects and their count (Map<PotionEffect, Integer>)
I want my plugin to add these potion effects N times (count times) randomly before the next potion effects have to be applied (before the next time comes). If there is no other times - it should give me all the effects. My code: https://pastebin.com/Q7jAQyVB
My problem is that it gives me all the effects at the same time and it gives me them not randomly as I said before, but at the bound time
Config: https://pastebin.com/YpbK1ZXU
EntityType#valueOf(String)
is it throws error when valueOf(String) is not vaild?
IllegalArgumentException
how can i use spigot with mojang mapping with gradle without paperweight?
Thanks, i should use double try/catch
anyone have anything that could get me started on custom world generation? (note: i do not know too much java and spigot)
did you at least learned something about java from last time you were here?
i don't remember what happend last time
ok how much you know java?
https://www.youtube.com/watch?v=HBMoQmz1wlA
Heres a video on whats happening, would anyone know why this would happen?
do you know what is class or interface?
idk how to explain what i know about classes, and idk what interfaces are
?learnjava i mean you dont need to know how to explain, but you need to understand what it is
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
can you just learn some basic java before trying to write plugins on spigot? please
this is how i learn
please
no, sorry
learn java
the last one have some explanation for classes and interfaces
you can't write good plugins without deep understanding of java basic concepts
derp, do you understand classes and interfaces?
The channel description says "Serious" and you kinda need to know java to be serious
i dont care how you explain it, i just want to say if you think you understand it
i don't think so
without knowledge your maximum will be small shitty plugins
just learn java before using it
and along the way i'll learn more and make better ones
NO
if you don't understand basic OOP and java concepts you can't progress
if you don't know what is interface or class, there is no way you can do something better than simple hello world
oop is using objects to make more stuff happen with using less code, right?
do you know at least basic concepts
i've made some basic plugins before so i'd disagree
inheritance, abstractions, polymorphism, encapsulation, aggregation?
if those words don't say anything to you, you are not ready
im just gonna wait for someone that is a little more positive about my way of learning
that's just the ?learnjava stuff
you want to make custom worldgen without knowing basic java concepts, thats NOT POSSIBLE
wait hes wanting to make a worldgen plugin?
https://learning.oreilly.com/library/view/core-java-volume/9780137673810/cover.xhtml, i suggest you to read first 6 chapters of this book, it will give you knowledge that you can start making real plugins
Sorry but honestly good luck because on top of java you need to know how perlin noise/noise works in general on top of know your math
Theres reasons why not many world gen plugins dont exist/get discontinued
damn everyone so positive here! (sarcasam)
OH MY GOD
Just facts
DON'T YOU UNDERSTAND THAT YOU NEED KNOWLEDGE TO DO SOMETHING
I would be understanding if you were making a gui or something but... world gen? come on
don't you understand that there are more than one ways of learning
You can learn by doing, so pick somethign you might actually be able to do
yes, but that doesn't mean that YOU CANT DO SOMETHING WITHOUT KNOWING HOW TO DO THAT
can you make car without knowing how it works?
i'm not even gonna bother to continue this argument, if you'd like to help me in my way, lmk
Why dont you start with making simple plugins?
already done
i've made some guis and commands and stuff
L-E-A-R-N J-A-V-A
you can't write english books without knowing english, right?
so you can't write plugins without knowing java
just gonna bump this, any help here?
you can't write them, but you can learn trying and then one day you will be able to
yes, so LEARN JAVA
learn JAVA, JAVA, J-A-V-A
toxic boi
or KOTLIN
if you don't like java learn kotlin
you can also write plugins via kotlin
i have this simple code to autocomplete the first arg of the cmd /customgive, how would i add autocomplete for the second arg and so on?
Dev encourages people to learn java before making plugins: 🤡
Dev encourages people to learn java but they havent learn java: 😎
how can i use mojang mapping via gradle? (without paperweight)
no
that's wrong
not rly
you definitely can progress even with 0 knowledge of java, u can just learn it along the way but it will be very slow
plzzzzzzzzzzz
@lean gull so lemme tell u what ur doing
really really slow...
i used to do so, but i won't suggest it
I really feel better when i understand java
or installing a game, without a pc or a mobile
ps4
some here know gradle?
nintendo switch
how can i use mojang mapping with gradle but make it run on not-mapped servers
Good luck with that, if its possible. I use Maven for a reason. Its simple and it works.
hi i need help with maven , buildtools
did you delete it and download a fresh copy?