#development
1 messages · Page 126 of 1
o alr
Like it's a library that's also a plugin
Sure, that's fine
But it can only support one connection?
What is this
What happens if you have multiple plugins trying to use it?
It boasts "used by spartan anticheat" but it's made by the same guy lol
And spartan is also hot garbage
wait are connections per-database?
i needa learn more about mysql lmao
have any recommended resources where i can?
Connections aren't exactly per-database
One connection may interact with multiple databases, though that is rare
A connection is just something that lets you interact with a sql server
You may have multiple per plugin
Or you may have only one
for some reason age on beetroots is 3 not 7 like carrots, wheat and potatoes
HikariCP 🤤
isAdult(); is for Entity not crop blocks
For crops you need to cast the meta to Ageable
done that but to check you need to check age and some are fully grown at 7 or 3
^ that's why you need to check that
Is it possible to stop a server from the bungeecord? (in a plugin)
d;bungee ProxyServer#stop
public abstract void stop()```
Gracefully mark this instance for shutdown.
^^
lol
mot sure why this happened https://paste.helpch.at/igoqitigaw.sql
I guess best way to do it then would be plugin messaging?
pretty sure timings are no more.
you have to host your own instance
If you use PluginMessaging like blitz said or you can use subservers and run the /sub stop <server> command.
what is subservers?
More of a bungee instance.
<repository>
<id>central</id>
<name>Maven Central</name>
<layout>default</layout>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
I have both of these in my POM.xml, it isnt finding the LuckPerms API for whatever reason
Any idea? The LP API Wiki says repo is in Maven Central and to use that exact snipet for the dependency
You don't need to add the central repo, maven already does that
And what do you mean by "it isn't finding it"? Do you have a log error somewhere during build or something?
Did you hit the reload button in IJ?
You should be getting an error log somewhere if you're hitting the reload button but try restarting IJ I suppose
It's IJ's doings
how can i get boolean for if a value exists in a sql table
Select count of the table you want where the value is the one you want, if 0 it doesn't exist
@EventHandler
public void onBreak(BlockBreakEvent e) {
Block block = e.getBlock();
if(block.getType() == Material.TNT) {
e.setCancelled(true);
block.setType(Material.AIR);
Player player = e.getPlayer();
PlayerInventory playerInventory = player.getInventory();
playerInventory.addItems(new ItemStack(Material.TNT, 1));
}
}
I want it to come when I break any block
but i don't want it to give tnt
want what to come? and wdyem by "come"
if it doesnt exist it'll return 0 instead of the usual null, correct?
If you do count yes
I don't understand, can you send the code sample please
this is my code can you write how to do it?
bruh what... lmao
here's "my" code, can u tell me how it works
If you do SELECT name FROM table WHERE value = ? and the value isn't there then the resultset will be empty
If you do SELECT COUNT(name) FROM table WHERE VALUE = ? and the value isn't there then the resultset will have a 0 in it
can you edit my code?
@lyric gyro nobody even knows what you’re asking for help on
What do you want to happen when you break any block
my problem is that when i break a block it should come to my inventory automatically
I want tnt not to come
In the code I wrote, when I break the block, tnt comes to my inventory.
.
But it’s only happening when you break a tnt block
no database connection
When I break any block, I want it to come directly to my inventory so I want a code sample that works
public void onBreak(BlockBreakEvent e) {
Block block = e.getBlock();
if(block.getType() == Material.TNT) {
e.setCancelled(true);
block.setType(Material.AIR);
Player player = e.getPlayer();
player.getInventory().addItem(new ItemStack(Material.TNT, 1));
}
}```
translation: i want someone to spoonfeed me code

what does the ? mean?
@lyric gyro
should i try this
Mhm
The value of you're checking the database for
i don't want it to give tnt so when i break any block i want it to come to my inventory
what would empty look like? is that null or something else (like if it was in an if statement)
people arent gonna code ur plugin for u
i don't want it to code my plugin i'm learning java so i need help
He wants to get the block material on block break and place it in the players inventory
Essentially
No one is stingy like you
... what
Chill…
Thats litterly what that code is supposed to do?
ResultSet#next will return false
yes, but when you break a block, it should come to your inventory automatically, it already comes to my inventory, but I don't want it as tnt, I want it for all blocks
Okay, so try coding that
you can get the type, store it and then use it to give it to a player
but i don't know how to do it so i need help
You obviously have it set up right now to give tnt on the break of tnt
So when a player breaks tnt, they get tnt
can you help me how to do with this code
But if they break other blocks it won’t do that
- cancel event
- set block to air
- get broken block material
- add material to player's inventory as an itemstack
i think thats right
This is basic java-knowledge
i need code sample i can't code so i asked for help
i can't code
ok you don't
?learn-java
Online Courses:
Online courses are also great for learning java. Some websites that offer them are:
- Coursera - Free unless you want a certificate
- PluralSight - Great courses from what I've seen. Mostly Paid
- Udemy - Never used them myself but they seem to all or at least most be paid.
My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.
Oracle Docs:
Oracle docs can help a lot at learning and understanding java:
- Start with this,
- Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
- Hit this.
They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff
Other services:
Some other cool services that will help you learn java are:
As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!
@lyric gyro i suggest you take a look at this
just get the block and material onBreak and save as variables
then in your if statement change the tnt to your material variable and same for the itemstack
Obviously if you only check if they break tnt, give them tnt, you will have to replicate that code for every single block in the game
how will the code layout be i can't do it
why does no one want to help i am turkish i don't understand english very much
Literally IntelliJ or eclipse will do all that for you just hit enter
Read the Java docs for onBreak event
I really don't understand thanks
srnyx litterly explained what you have to do
2. set block to air
3. get broken block material
4. add material to player's inventory as an itemstack```
I don't know how to edit the code
You already cancelled the event using e.setCancelled(true);
You already set to air and added a material to the players inv as itemstack too
You just have to get the broken blocks material
Get the material of the block
yes but when i break any block i want it to come to my inventory i don't want tnt just
You already have the block, now get the type
Yes that’s what we’re saying
you can write the code
Instead of tnt, you use the variable that contains your block’s material
yes we can, but what would you learn of it?
In your code the material is not “block”
That’s the block object
You need the material
So use that
And get the type
ok how do we do this as code

@lyric gyro
I would instead recommend at least the basics of
Yes I did mean that thank you
?learn-java
Online Courses:
Online courses are also great for learning java. Some websites that offer them are:
- Coursera - Free unless you want a certificate
- PluralSight - Great courses from what I've seen. Mostly Paid
- Udemy - Never used them myself but they seem to all or at least most be paid.
My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.
Oracle Docs:
Oracle docs can help a lot at learning and understanding java:
- Start with this,
- Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
- Hit this.
They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff
Other services:
Some other cool services that will help you learn java are:
As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!
I want to store a date (year, month...seconds) in a cfg file, then read it again later. What is the best way to do this? I've tried ZonedDateTime and Calendar but have not gotten it to work. Is this a good approach or is there something better?
I prefer storing System.currentTimeMillis
that's your epoch time
humans don't like reading epoch time though, 1647134642 being the current epoch time is quite meaningless to us
but computers can easily convert epoch back to a date
Is it capable of storing years though? Idk how many millis in a year but I assume a lot lol
9,223,372,036,854,775,807 is long max value
that's definitely long :^)
292,471,208 years
That's definitely a lot
I'm creating an user script (JS) to slightly modify a page's behavior. There are some buttons on the page that I wanted to set their href to the actual link, but currently they have no link, instead what they have is a Laravel backend function that is called through wire:click HTML tag. This is an example of a button that is present in the page.
<button class="btn btn-primary btn-control btn-md mr-1" wire:click="generateDownload('free_fhd')">Get FHD File</button>```
So my plan was to, for each button on the page:
- Get these buttons through CSS Selector and call `click()` on them, one by one.
- Somehow listen to redirect, grab the generated link (of `window.location.href` or something), and cancel the redirect.
- Remove all click listeners for that button.
- Set that grabbed link on the buttons as their `href`.
I would like to know if that is possible.
I got this error spammed for each table and not I get no errors when I run command but data still will not transfer I changed nothing in code for the error to go away https://paste.helpch.at/lihilakedu.sql
I have tried Spigot and Paper each does the same
Is this a plugin you've made?
no staartvin did and trying to update it
i dont know who that is but
it looks like you arent creating the tables in the database
cant help more without seeing code
sqlite has the tables, and if you start with SQL it works fine, just when you try to transfer data from sqLite to SQL it don't transfer says it transfered 0 db records
please show me where it has the tables
this is so cursed
could be why I don't understand it
how can i make this work with multiple conditions (instead of just one)? https://paste.srnyx.xyz/ukokekulej.java
that code works, not sure why the sqLite name needs to be the same as SQL db name
Why do i get this when selecting java 17 openjdk ?
you need gradle 7 for java 17 iirc
anyone know how?
AND...?
also please do not make queries like that, you're leaving yourself vulnerable to SQL injection
you should be using ? and then setting the parameters later
Matt u there? I want to add an event to method parameter for asGuiItem() in your GUI API, but not sure how
public void addItem(Gui gui, ItemStack item, int slot, GuiAction<InventoryClickEvent> action) {
GuiItem guiItem = ItemBuilder.from(item).asGuiItem(action);
gui.setItem(slot, guiItem);
}
would it just be that?
If so, how would the addItem method I created, be used?
well that seems like it can just be a static util method
since it doesn't use any variables/method besides the parameters
True, ty
Ah yeah, thanks
or you could pr ```java
public void addItem(Gui gui, int slot, GuiAction<InventoryClickEvent> action) {
GuiItem guiItem = ItemBuilder.from(build()).asGuiItem(action);
gui.setItem(slot, guiItem);
}
// ItemBuilder.java
What's build()?
converts ItemBuilder -> ItemStack
Ah, but the method should work with different kinds of items though, that will be specified
alr
just suggested that since u mentioned asGuiItem
Not sure what you mean
how do i use '?'? cause when i put the '' around it, it says it cant resolve query parameter
thought about that, but it would have to be a set number of conditions and not "dynamic" or whatever
hm maybe i could append AND
whats that a reply to?
this
no ik that, but when i sorround the ? in '' it says Cannot resolve query parameter '4' (4 being whatever the parameter index is)
what is your query
...
?paste
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
"select ? from ? where ? = '?'"
you dont need them
if it works it works
o alr
public boolean valueExists(String column, String value, String[] conditions) {
StringBuilder result = new StringBuilder(30);
for (String condition : conditions) {
result.append(" AND (").append(condition).append(")");
}
}```alright so i have this ^, but it requires one of the conditions to be specified separately (`column` and `value`), how can i fix that by just having the `String[] conditions` parameter?
so basically i dont want the result thing to affect the first string in conditions
well actually i still wanna do something to the first string (add () around it), so how could i do that?
you shouldn't build such dynamic sql queries normally. Writing the exact queries you need is recommended, otherwise you're running in a lot of issues with sql injections and stuff
prepared statements 😌
I think that it's not an sql query
even if it was, why would you want to make something like this
it doesn't even run any sql code
💀
So i am working with a @Getter & @Setter in my code but i can't build my plugin, it will just give this error (see screenshot below).
I have this in my main: private static @Getter @Setter HashMap<UUID, Integer> kills = new HashMap<>(); and i have this in a other class: int currentKills = KitPVP.getKills().get(p.getUniqueId());
Could I see your shadowJar configuration/ as that means it cannot find the method/variable, or misspelling.
@formal crane If you haven't solved it yet.
it also doesnt work without shadowjar
I presume you are being dependent on another project that has getKills() and the other methods? I can't exactly help without more information.
As you didn't provide any classes, except a screenshot regarding the error.
My presumption was that based on KitPvP [shadowJar]: failed and compileJava there is misconfiguration in your build configuration.
The hashmap is in my main and i am trying to acces (read & write to it) the hashmap from a other class called PlayerData
It would be much better if you share the code....
This is the playerdata class:
https://paste.helpch.at/tokapanixe.cs
This is my main:
https://paste.helpch.at/uqokenubuw.coffeescript
Looks to be a lombok issue
Forgot about this, and Matt seems to be on the spot about the issue. As I suggested, if you could link your build configuration (the build.gradle, or pom.xml) It would be helpful as you are using Lombok, meaning you aren't including the dependency into your shadowJar.
Possible issues: lombok not configured in the build tools correct, missing the lombok IDE plugin, just lombok being lombok
My main recommendation is to not use it, but if you want to, make sure it's sertup correctly
ok
got it
Hey guys, how can I store custom data for an ItemStack? So e.g. I want to make a specialized hopper behavior, and store some extra data in the hopper object, is that possible?
You want to store the data in the hopper item or hopper block? As in only inside inventory or after being placed
You need to add lombok as annotationProcessor as well
annotationProcessor 'org.projectlombok:lombok:1.18.20'
so an implementation & a annotationProcessor?
Yeah
ty
How would I get a specific player from the playerdata collection?
This doesn't work
public PlayerData deserializePlayerData(UUID uuid) {
// Deserializing - getting an object from json in the database
for (Document playerDataDocument : database.getCollection("playerdata_" + uuid).find()) {
PlayerData dbPlayerData = GSON.fromJson(playerDataDocument.toJson(), PlayerData.class);
return dbPlayerData;
}
return null;
}
Not sure why
public class CancelUnload implements Listener {
@EventHandler
public void onChunkUnload(ChunkUnloadEvent e){
for(Entity entity : e.getChunk().getEntities()) {
if (entity instanceof Horse) {
e.getChunk().load();
Player owner = (Player) ((Horse) entity).getOwner();
Bukkit.broadcastMessage("Unloading");
assert owner != null;
entity.teleport(owner.getLocation());
Bukkit.getScheduler().runTaskLater(instance, new Runnable() {
@Override
public void run() {
e.getChunk().unload();
}
}, 40L);
}
}
}
}
So im trying to teleport the players horse to them when the chunk is unloading, it says "Unloading" when a chunk with a horse gets unloaded, but the horse doesnt teleport to me. Any idea why?
Does it make it under unloading?
How do I print a color formatted message using Component?
getServer().broadcast(Component.text("&8[&aACH&8] &1Hopper1"));
This broadcasts the text as it is.
(the value comes from configuration so I can't use the color overload or .color() and so on.)
If you're using legacy format you need to use the LegacyComponentSerializer, but I recommend you use Minimessage instead of legacy
what would be a decent way to update the block type of around 775k blocks without lagging every time the for loop ran?
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
Block b = world.getBlockAt(x, y, z);
switch (new Random().nextInt(2) + 1) {
case 1 -> b.setType(Material.STONE);
case 2 -> b.setType(Material.DIORITE);
}
}
}
currently im doing this,
but ive updated it so i do it like this
int counter = 0;
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
if (counter % 5 == 0) {
int finalY = y;
Bukkit.getScheduler().runTask(LunixPrison.getPlugin(), () -> {
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
Block b = world.getBlockAt(x, finalY, z);
switch (new Random().nextInt(2) + 1) {
case 1 -> b.setType(Material.STONE,false);
case 2 -> b.setType(Material.DIORITE,false);
}
}
}
});
}
counter++;
first of all, reuse a Random instance
and if you only have two cases, use nextBoolean and a simple if else
wouldnt reusing the same random instance make the blocks just stone or just diorite?
i wanted to have random mines that have random blocks.
well a random spread of blocks
He meant to create a single Random object.
i just realized that
Also, what about worldedit?
Also, Random.nextInt(int) can return 0. So check for that 😉
i wasnt sure that worldedit would be more efficient then this method
But then it can return 3...
according to intellij it cant and its not a massive deal if a few blocks are air or not
Since he doesn't check for it no block would be set.
the upper bound is exclusive
d;jdk random#nextint(int)
default int nextInt(int bound)
throws IllegalArgumentException```
Returns a pseudorandomly chosen int value between zero (inclusive) and the specified bound (exclusive).
bound - the upper bound (exclusive) for the returned value. Must be positive.
IllegalArgumentException - if bound is not positive
a pseudorandomly chosen int value between zero (inclusive) and the bound (exclusive)
With that +1 the result will be 1 or 2
my current method seems to have reduced lag from 80% tps loss to 20 then down to 4-5% tps loss on reset.
and resets would probably not be so often in 1 second.
ill have a look at the first or second nms methods
i want to implement graduel resets so that lag doesnt hit so hard
With the ChatEvent event in Bungeecord, is there a way to get the player who sent the chat message?
Yes, here is what you should do:
@EventHandler
public void onChat(ChatEvent e) {
if (e.isCommand()) return;
if (!(e.getSender() instanceof ProxidedPlayer)) return;
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
}
Thank you! For some reason I just didn't see it in the documentation :)
How to fix?
[18:51:40 WARN]: Unexpected exception while parsing console command "dm help"
org.bukkit.command.CommandException: Cannot execute command 'dm' in plugin DeluxeMenus v1.13.3-Release - plugin is disabled.
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:761) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(CraftServer.java:746) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.DedicatedServer.handleCommandQueue(DedicatedServer.java:426) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:395) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1127) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:966) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer$$Lambda$3168/623059508.run(Unknown Source) [spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
i had the idea to schedule a task to run after every 3 y levels have been reset, so it would be setting 30k blocks every tick, not sure if it would actually be better or not.
but not sure how to actually get it to run
and i crashed my test server
what a suprise
you can also measure the time spent placing blocks and only do like 40ms per tick or something like that
Possibly use FAWE? or decrease the amount of blocks at a period of time.
i tried that and ended up crashing the server
I usually broke placements up to make it easier for the system.
decreasing the amount per tick
Well how many blocks are you trying to place per tick
As there is 20 ticks/second
i tried to decrease it to do around 30k in a tick
With or without FAWE.
Decrease the amount of blocks.
i tried and crashed the server doing it
I assume this is for a prison mine?
yep
i also looked at what other plugins did, they are all doing the same thing as i was originally doing
Let me see if I can find my old code for a old project that could do 500k/4s in a prison mine plugin I made.
im currently trying to implement an nms method of doing it
that i found on the spigot forums
Be careful as you'll need to update the light for the individual blocks, or update it on the server end first and then update it for the clients.
im not updating the light levels
dont really need to
or atleast im not doing that rn
What version of Minecraft.
1.17.1
thats what the version of the server im working for is using
EntityPlayer apparently had a chunkX and ChunkY value somewhere yet i cant find any reference to it
and trying to figure out what the obfuscated variable names mean is something else
You'll still have to update the light levels at some point, otherwise players need to relog if you use NMS.
i sorta just assumed that i wouldnt have to touch light levels rn atleast
Well if you read the second method they specify it is best for stuff such as minigame regeneration, where you would usually expect it in a server that may restart in my opinion.
As it says Does not send updated blocks to player (requires a relog)
So you are currently just trying to get the method to work I assume and don't care about the light levels until you get the placement towork itself @proud pebble?
basically
i just needed something faster then block.setType(Material);
something that wouldnt break the server
Well it won't break the server if you don't place that many blocks that quickly.
That's why plugins on the forums have stuff such as "timed" where it takes a period of time before it places blocks.
and im completely out of my depth when it comes to nms 😅
So how many blocks are you trying to place per tick again? out of the 101x101 (height 50) mine I presume it is measured for?
i was going to place atleast the first layer, so atleast 10k in a tick
Reduce man that's too quick.
so then it doesnt look weird when updating
That means you want to place 200k blocks/second.
Which is over 3x even what the thread mentions as there is 20 ticks/second.
ive seen other servers do it that fast
I'd expect them to implement NMS or a system to help reduce the amount of TPS drop.
then again they have many devs and devs that probably know their way around nms
If you want it to look somewhat nice, then do it from the top to bottom layer if you are using strictly setType.
im guessing thats probably why not many private mine plugins exist publicly
?
because of the restrictions of how many blocks/second can be updated with just settype and setblock
without going into nms
i had considered setting blocks in chunks rather then setting them all at once
why dont you just use nms?
yea
that too, but i thought they wanted dependency free because it was suggested a long time ago
what would be the best way to store a Player, a String, and an integer, and be able to increase or decrease the value of the integer?
depends on the context
My first instinct is Map<Player, PlayerData> (handle Player properly)
public class PlayerData {
String something;
int somethingElse;
// .. getters/setters/etc
}
i dont want to touch fawe, its buggy from my experience.
and thats what im doing, using nms
id somehow use AWE if it has an api
nah AWE isn't good either
huh, resetting the 101x101x50 mine doesnt lag.
well it doesnt lower tps
it didnt lower it before either
maybe i can edit that many blocks a second
FastAsyncWorldEdit Skript tho
/s
Anyone know if it’s possible to assign ItemMeta to a Material.AIR ItemStack using packets?
I’m trying to utilize the Item Name line that appears underneath the Action Bar by using the EntityEquipment packet to send fake item renames
The issue though is I want it to work when the player is not holding an item
Interesting
I wonder if there’s another way to do this
Actually it might work
If I just send the packet with a normal ItemStack
Because the physical item should never actually appear in the hotbar
Hopefully it’s able to fool whatever controls the text under the action bar though
please don't give alexis ideas
Is that not just client-sided?
question is, why? lol
cant you simply use action bar?
there must be a really good reason to use something no one else in the world would use
I believe it is, but I think it can be manipulated by making the client believe that it is holding something
I’m trying to have more space for text
My plugin already uses a lot of chat messages and uses the action bar a lot for other things
And I don’t really have the time to code my own bossbar API, even though it doesn’t seem that hard
It wouldn’t really be appropriate for the data I’m trying to display
unless you are in 1.8, you dont
1.13 has method to create boss bar
anyways
Yup, 1.8 lol
Well it’s skywars
The chat is used for a lot of kill messages/perk proc messages
Action bar is used for damage indicator
I’m implementing a gold system
skywars = text
hit indicator = action bar
that's it
no more text fields are required
honestly, no more
I’m adding a system where players get gold from chests that they can use during the match
And I need a good way to display that
You need to be able to easily see how much you have left while attacking
Which is why bossbar/scoreboard wouldn’t work
I guess I could append it to the end of the damage indicator
Would look a little unclean though
thats what
normal people do
dont get me wrong but
overcomplicating simple stuff
is bad
I mean code wise it may be over complicating
But not with the final product if it ends up working
I wonder if that would looks aids with a subtitle
indeed
it will
thats why normal people use action bar
for everything
or even scoreboard
adding a (+5 gold)
as ThePit used to do
i think
i dont remember
Haha that’s funny
My entire server is a pit parody
The pit used chat for kills and assists
But this is something that’s going to be subtracting gold on a per hit basis
I don’t know, I’m going to give the item name thing a shot
And if it doesn’t work I’ll just append to action bar
dont send packets to client without a good reason, always causes issues
if you plan to give real items, then be ready to intercept and prevent players from throwing and do stuff with it

Pain
@west socket why not just send an actionbar message?
public String[] getAll(String[] columns) {
StringBuilder result = new StringBuilder(30);
if (columns.length < 1) {
for (String column : columns) {
if (!Objects.equals(column, column.split(",")[0])) {
result.append(", ").append(column);
}
}
}
}```why am i getting this? https://srnyx-needs.to-sleep.xyz/IzrituE4n2.png
i think ik y but im not sure how to fix it
Yapper read ☝️
@dark garnet because columns
is always empty

**Clue: **||do u know any number lower than 1 has is greater than 0?||
Ah thought the item name showed in the actionbar.

here's an example of what im putting in: new String[]{"UUID", "USERNAME"}
there are 2 strings, "UUID" and "USERNAME", right?
do you understand
what i said?
"columns" is always
read: always empty
if columns.length is lower than 1
get the idea?
its like saying
if(integer < 1) {
if(integer > 10) { //IDEA will say: "statment is always false"
//this will never run
}
}

what?
like if used result.toString() later what would that come out to if columns.length == 1
result is a StringBuilder
with the space or without? (i assume without)
alright and what about Arrays.toString(columns).split(",")[0] (if columns.length == 1)?
here's the whole method: https://paste.srnyx.xyz/ejedofuyic.java
im trying to get all values in all of the columns
so i have to append , to each column for it to work in the mysql statement
but i cant append it to first string or else it'd be SELECT , column1, column2, column3 FROM ? which would be invalid syntax
so i only append it to every string except the first one
but then result doesnt include the first string, so i have to input it manually which is what ps.setString(1, Arrays.toString(columns).split(",")[0]); is for
but i also want the method to support single strings (ex: new String[]{"PLAYER"})
so if there is only one string, i want result.toString() to output (nothing)
and i wanna know what Arrays.toString(columns).split(",")[0] would output if there is only one string
cause if there are is only one string, there are no ,, so im not sure if it'd be able to split
oh also another question, is new String[]{"PLAYER", "UUID"} the same as new String[]{"PLAYER","UUID"}?
or would i have to account for the space in Arrays.toString(columns).split(",") (so it'd have to be Arrays.toString(columns).split(", "))?
So I’m attempting the item name stuff lol, so far the issue I’ve ran into is that despite the documentation saying that slot 0 is your main hand, it puts it on the boots lol
How are you setting the item into the inventory?
public static void sendItemName(Player player, String text) {
ItemStack item = new ItemStack(Material.SIGN);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(text);
item.setItemMeta(meta);
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), (short) 0, CraftItemStack.asNMSCopy(item));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}```
According to this protocol, slot 0 should be the item in your hand
It seems that 0 is boots though
That's some outdated documentation. What MC version are you running? Also, I'd look into using the API as it can do the same with less of a hassle https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#sendEquipmentChange(org.bukkit.entity.LivingEntity,org.bukkit.inventory.EquipmentSlot,org.bukkit.inventory.ItemStack)
1.8.8
:/
Thanks for telling me about that
Oops, not a 1.8 method. Funny 10 year old version of minecraft moment
Can't help you much then other than telling you to consider to upgrade to a newer MC version or play around with it until you get what you desire, but expect support for old versions to be scarce
How come I can't get the color after creating this try statement?
Yeah sorry about that. There are reasons why I'm not upgrading. Thanks for the help anyways.
You're creating the color variable inside brackets above. Anything outside of those brackets can't access that variable
Try monad 😌
Thank you, I should have realized that 😅
another question lmao
when i use ps.setString (ps is a PreparedStatement) it always surrounds it with '' when setting the string, how can i prevent that?
example:java String name = "hello"; PreparedStatement ps = Main.SQL.getConnection().prepareStatement("?"); ps.setString(1, name);would come out to 'hello', but i instead just want hello
well yeah because a string is defined by quotations
that's how the sql engine handles it
how do i fix it?
there is nothing to "fix"
how do i remove the '' around the string then
you're telling sql "I want a string with this content" and that's what it produces
what are you trying to achieve here?
why do you so need it without the quotations?
cause with the apostrophes it makes the statement invalid
What is the original query?
create table if not exists ? (id int(11) not null auto_increment, ? primary key (id))
And what would be the parameters you would need to add?
here's the entire method (u need it to know the parameters): https://paste.srnyx.xyz/ubiliyeqis.java
Table names are not values, ? is a value placeholder for things like insert and update
In any ways …you can just hardcode those values..no way there would be an SQL Injection gonna happen there if you know what you are doing…
+1
Table and column names go as-is or surrounded by backticks `
name is set with new GetSQL(name) (ex: new GetSQL("trusted").createTable(new String[]{"PLAYER", "TRUSTER"});)
Also please don’t complicate things by using StringBuilder…while you can just add it by normal queries
wdym?
There is no need of using the StringBuilder There to just add them to to table name…you can just do it regularly….
its meant to like be dynamic
so if i wanna create a new table i can just do new GetSQL("table_name").createTable(new String[]{"POINTS", "XP"}) or something
Then instead of setString() concat it directly…as u know what would be the use case there right….
Bcs as Emilly said, table name isn’t a value there
Everything that needs to inside quotes….
so instead of something like this:
PreparedStatement ps = Main.SQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS ? (ID INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID))");
ps.setString(1, name);```it'd just be this?```java
PreparedStatement ps = Main.SQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS " + name + " (ID INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID))");```
Yeah
what about sql injection? when should i be concerned about it?
You are the one creating those tables…right? So if u know what you are doing…then you are good to go
who else would be creating the tables...?
When I right click on the sign
[Exam]
Exam1
It is not sending my debug message in chat. Anyone know why this is happening?
Config is as follows:
Exams:
Exam1: # // You can name each exam whatever you'd like \\
permission: 'cityrp.exam.take' # // (Prerequisite) - Set this to "cityrp.exam.take" to not require a prerequisite permission. \\
Questions:
question1:
a: 'Answer 1'
b: 'Answer 2'
c: 'Answer 3'
d: 'Answer 4'
Correct Answer: 'a'
@grim oasis maybe you know, im pretty sure you made my old old exam sign plugin?
are you opped? cause ur checking for a perm, and i think ops get all perms
Yes I am opped
try deopping
So, it works if I put that line of code in my ExamCreate listener
just not if I right click the sign, which I find odd
@dark garnet
worked?
No, thats if I put the loop into my sign create listener
oh
It shows the debug there, but it doesn't show the debug when I right click the sign
looks like its failing here
if (sign.getLine(1).equalsIgnoreCase(key)) {
Yeah, line 1 would be the name of the exam
No line 0 is [Exam]
right?
unless it switches up lol
before that if statement put e.getPlayer().sendMessage(sign.getLine(1).toString()); or whatever it'd be
e.getPlayer().sendMessage(e.getLine(1).toString());
if (!e.getLine(1).equalsIgnoreCase(key)) {
Message doesnt send
o might be cause of if (sign.getLine(0).equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', sHeader)))
so put before this ^
ok wait nvm javadocs literally says 0 will return first line
so dont think its cause of that
yea thats what im thinking
(ChatColor.stripColor(sign.getLine(X)).equals(Y)) i think?
not exactly sure where the "boolean" is coming from considering "key" is a string
if (sign.getLine(1).equalsIgnoreCase(examNameColor + key)) {
I will just try this lol
ur providing a boolean (cause of the .equalsIgnoreCase(key)) for ChatColor.stripColor, it needs a String
so u just need to put .equalsIgnorecase(key) outside of ChatColor.stripColor()
Oh
yeah parenthesis were wrong
if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(key)) {
still failing
it looks like there is a space before Exam1, is that cause of the debug msg?
if its not cause of the debug msgs u could use .trim() to get rid of it
My god i'm glad your eyes work
Alright that worked.. I don't even know why I put a space between the exam name color and the text
Is there a way to only get the 1st key from the config?
I want to only send them one question at a time, after they answer the question, it sends the next one
this is probably the most ridiculous way to do it and there is probably a much better way:
convert keys to array and get first value in array then convert to string
(ex: Main.config.getConfigurationSection("database").getKeys(false).toArray()[0].toString())
same lmao
Oh wait, but I need to be able to add as many questions as I want, not define it to a set amount of questions
That example would only give me the first question, then if I changed the 0 to a 1 it would give me the 2nd question -- But doing this I would have to manually code this for a set amount of questions
Loop
I need to remember to use loops more ig cause I’ve been running into the same issue lmao
Either that way..or you could get the iterator of ConfigurationSections#KeySet()
oo..lordd xD
yes, this was quite a few years ago when Drew asked for this 😂
I couldnt remember if it was you or another guy who made it
==>
lol
hello people
I'm trying to add my own placeholders to my plugin
is there any good tutorial out there?
Hi, when i try to import PlaceholderAPI libraries it drops me this error:
The import:
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
The error:
The import me cannot be resolved
I am using eclipse IDE with a spigot 1.18.1 jar, java 17 and I have set up the placeholder api external jar
Oh NVM I instanced DoubleChestInventory not DoubleChest
The others tabbed the correct DoubleChest instanceof tabbed DoubleChestInventory for some reason.
Any idea if using a PermissionHolder, permissions will also be set on plugins like LuckPerms?
I think as long as its registered through bukkits permissions you should be fine.
is not
PermissionHolder?
I can't speak for other plugins but LP will preserve Bukkit's behavior and include it but it won't be saved
yeah, I need it to be saved, will use vault
using streams would be cleaner ig
Hi having issue with maven
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
always prints me this message no matter what java version I'm using
command I use is "mvn clean package"
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
Iirc that's caused by the shade plugin version not being updated for latest Java versions
Search for the versions of "maven shade plugin" and use latest
I think that’s what I did but then IntelliJ told me to change it to that
weird
how do I update it ?
On your pom, find where the plugin is declared and change the version, I think latest is 3.2.4
Either that or the compile plugin version
Don't remember exactly, sorry I'm not used to maven 
already the latest and yeah me too I'm not used to maven I prefer gradle
Hmm, can you send the pom?
Try changing the compiler plugin version to 3.10.1
Line 18
I know the code of the plugin isn't great (it's just a fork i made to add a few little things, i'm learning java so I will try to improve it soon), but can someone tell me why every fishing rod is a grappling hook on my main server, but on my test server only the correct ones are grappling hooks?
https://github.com/lucian929/GrapplingHook/blob/master/src/main/java/net/maploop/commands/MainCommand.java
I have a feeling some plugin is messing with the meta the plugin uses to check if an item is a grappling hook, but I'm not sure what a better method would be to store the data
Are you using lore/display name to check it or what?
My bad, here's where it checks for a grappling hook https://github.com/lucian929/GrapplingHook/blob/f716983f65fb6f890c63898d2687b950d08935d5/src/main/java/net/maploop/GrapplingHook.java#L62-L63
Will do
still getting that erro
r
hate maven
Yeah I don't know then 😦
And same
Is moving to gradle not an option?
is there a way to replace a items texture with another if the same equals something without optifine? (using a resource pack)
Not really, you could use custommodeldata though
Guys, I want to make text animation. How can I make the text blink in colors?
@sudden sandI have noticed that some errors don't go away unless you make the change in your pom then close IDE and open it again
Where will the animation be displayed?
in lore of the item
Is it a item in a player inventory or a GUI
^
I want to make animation with one line of the lot of the item
can you give me the example of that?
Lot?
no
Do you know how to make an ItemStack?
No, I don’t
what
You should learn spigot first
I'm not going to spoonfeed you the code, can you provide whether the item will be in a inventory or in a menu.
wab you learn how to do that first?
I would highly suggest getting an atleast basic knowledge of Java and Spigot before attempting to code a plugin.
Here’s a course you can buy that goes over all that:
https://www.udemy.com/course/develop-minecraft-plugins-java-programming/
3 people trynna help a single person, poor dude
in menu
Is it possible to implement this in DeluxeMenus?
Hi, for the configuration related to DeluxeMenus, I suggest going to #general-plugins, or #general-plugins-2.
Nothing to be sorry about, it's perfectly fine. EDITED: People make mistakes and it happens.
String[] chars = new String[]{"a","b","c","d","e","f","1","2","3"}
ItemStack i = new ItemStack(Material.COBBLESTONE);
ItemMeta im = i.getItemMeta();
for(int i = 0; i < chars.length(); i++) {
new BukkitRunnable() {
public void run() {
im.setDisplayName("&"+chars[i]+"Cobblestone");
i.setItemMeta(im);
}
}.runTaskLaterAsynchronously(<JavaPlugin>, i*1);
}
why async
If used properly animating inventories can be done async.
Since they (custom inventories) don't affect the world.
Thank you!
but like async wont make it more performant really, it hurts both performance in this case, and it makes the code not thread safe
Its pseudo code so adjust accordingly. Also its just something to read to know what to do. I wouldn't recommend copying it exactly.
Doesn't need to be thread safe. Its an itemstack that was just created. Unless its spawned in the world which in this case it isn't
the problem isnt the code itself, but when you start creating abstractions you'll forget the implementation which can cause severe issues. but as said its totally redundant and unnecessary to do every little thing async
like, ::runTaskLaterAsynchronously might have to allocate a new thread and start it
which is everything but cheap
since it uses a cached thread pool in the end
Well the above code is in mind of keeping unnecessary code off the main thread.
main thread?
server thread I suppose you mean? that code will have negligible impact if anything
Yes spigot still uses a main thread
I love how you guys are arguing over a piece of code that was given to a guy who doesn’t know what an ItemStack is
there's no concept of a main thread, just the server thread where the majority of the server logic gets executed on
🤦 what do you think a "main thread" is
idk
You literally just defined it yourself.
main thread is relative
Server thread/ main thread == same thing
server thread is not
no not at all if we're being pedantic
anyways you really have to stop using async for every little thing, it does not help performance whatsoever, merely a premature optimization, good bye
You need to stop using sync for everything lmfao.
Spawn over 1k particles sync 😉
that will make literally no difference lol
particles only exist to the client, it's just a packet being sent on the server's end
and 1k is nothing
tell that to your TPS xD
hey so this isnt rly a spigot question, more of a computer anatomy question. i want to try programming led strip lights and i dont have an arduino and my raspberry pis not here. can i connect it to my computer until i can get one? i just cant find a good tutorial if someone can point me in the right direction ty
Having a ton of packets sent will absolutely kill tps
Only if sent sync
Have you ever had a hologram displaying placeholders to over 200 people at the same time
That's the nature of sending too many packets, packets are always sent sync, when dispatched async they get put in a queue that is flushed on connection ticking (ticked by server thread)
^
"send async" doesn't mean anything
it might be understandable if you got some particle animation calculation you wanna do, but even then, java and the jvm is fast, it knows a lot of tricks, by using async you're hindering certain jvm and jit optimization stuff from being invoked
(well if used erroneously which is 80-90% the case of all code I have read so far on spigot)
I wish I could somehow have citizens run async
for what purpose?
I have a lot of bots on my server with custom attack events and movement patterns
And they tend to be really hard on the main thread
well, thing is chances are they would be even harder if you'd split it up and push it over to a thread / thread pool
Hmm yeah maybe
like you need to implement proper locking mechanisms
which, yes affects performance in terms of speed
I would also need to use my own citizens fork I assume
mye
and then you'd also pretty much have to setup some annoying tests to test atomicity (to make sure you didnt write anything wrongly)
mye
Async means it runs later then sync. So it runs everything on the main thread that needs to be ran before moving on to queued threads
async usually isnt an optimal solution
fawe moment
well problem is, if you dont test your code that is multithread-implemented you have 0 way of telling if it will run into some concurrency update problems
especially when the software is supposed to scale
Yeah
And this all stems from a use case where it is optimal
what do you mean by this
I mean even if async is a viable solution, its rarely ever an optimal solution, especially in object orientation where you really try to abstract away implementation
hey so this isnt rly a spigot question, more of a computer anatomy question. i want to try programming led strip lights and i dont have an arduino and my raspberry pis not here. can i connect it to my computer until i can get one? i just cant find a good tutorial if someone can point me in the right direction ty
sorry what
running on another thread means the jvm doesn't optimize code
???
you don't optimize code
from my experience, Player#spawnParticle works just fine with thousands of them. No TPS drain afaik
Depending on the strips, they're just a light. No brains. You'd need a controller capable of accepting commands,unless you already have that
I believe World#spawnParticle might hurt fps significantly
Myes, if you for instance split up a big computation task into smaller ones and send them to a work stealing pool
Some of the optimizations may not be invokable (like generally when it comes to concurrency, things become a lot less predictable for both us and the jvm, and to some extent jit)
i have a controller just dont know how to connect the lights to my pc and change them w code
Is it a programmable controller?
i dont think so
I'd assume without a programmable controller, then there isn't too much you can do. (You could probably make something that might work with RGB interfaces if your motherboard supports it)
What exactly does these signs mean? I wanna update to Master branch
It does, but not as hard as someone might think, the client doesnt render all of the particles
im getting a syntax error with this mysql statement: [WORLD_XYZ_BLOCK] FROM v_locked (cause of the [])
[WORLD_XYZ_BLOCK] = Arrays.toString(columns).split(",")[0]
i tried doing (Arrays.toString(columns).split(",")[0]).replaceAll("\\[]", "") but that didn't work, any ideas?
it tells you where the conflict is from my understanding
u have conflicts
everything between <<<<<<<<< Review_branch and ========= is from Review_branch, everything between ======== and >>>>>> master is from master
you need to choose which code you want to use, i think there r buttons to choose
Yeah I knew it was a conflict, just not what exactly was from where, but it kinda makes sense, it just sometimes duplicates some stuff
its cause u didnt merge upstream before making changes
so u made changes to master and then edited old code and tried to merge that old code into the new code
im dumb, needed a | between the brackets for the regex
Day7: Still dont get what are you doing that lol
-
i input a
String[](columns) [ex:new String[]{"WORLD", "XYZ", "BLOCK"}] -
if
columnshas more than 1String, it will append,to eachStringexcept for the first one to makeresult[ex output:", XYZ, BLOCK"] -
then it will run this statement:
"SELECT " + Arrays.toString(columns).split(",")[0].replaceAll("\\[|]", "") + result + " FROM " + name
Arrays.toString(columns).split(",")[0].replaceAll("\\[|]", "") = WORLD
result = , XYZ, BLOCK (empty if columns only has 1 String)
name = table name put in via constructor
and it returns new String[]{ps.executeQuery().toString()} (not sure if this part actually works)
yeah just realized that return statement probably doesnt make any sense
cause its literally converting to a single string (how does that even work lmao, this gets all the values in each column specified) then putting it into a String[] (ex: String[]{"entire output"}) lmao
so im gonna have to figure out what ps.executeQuery().toString() outputs
anyone got tips for doing async io? I have a plugin where I use the BukkitScheduler#runTaskAsynchronously to do a mix of parsing Files into JsonObjects and writing JsonObjects to Files, I wanna be careful to make sure data doesn't get corrupted/synchronization problems don't pop up
welcome to concurrency
it sucks, now you have a problem, enjoy the ride
it's not an easy topic that can be covered in a paragraph and anything anytime can get out of hand
https://www.baeldung.com/java-concurrency https://www.baeldung.com/java-thread-safety
to get all the values in (a) column(s)
anyways, another issue (with same method):
ResultSet rs = ps.executeQuery();
List<String> fResult = new ArrayList<>();
if (rs.first()) {
while (rs.next()) for (String column : columns) {
fResult.add(rs.getString(column));
}
return fResult;
}```if there is only one value present it wont return it cause of the `rs.next()` (i think thats why)
i tried doing `for (String column : columns) while (rs.getString(column) != null)` but that just made the plugin hang on start
i dont get what you wanna do tbh
i mean, whats the reason lol
not what you are trying to do to achieve that
the escape analysis checks whether an object escapes a) the method and b) the thread. If an object escapes a thread, it can't be allocated in the TLAB and there are some other memory operations required. So yeah, it kinda makes it harder for the jit to optimize the code
from what i've heard JVM escape analysis isn't super great as it doesn't have too many options since there aren't like stack allocated objects or anything
that hasn't to do much with stack allocation, but the analysis is somewhat conservative. Graal for example can do partial escape analysis
Anyone recommend a good obfuscator?
You'll most likely find people here will push for open source
none
Open source is poggers
None of the ones spigot allows LMAO
Open source is best obfuscation
Not knowing the language is the best obfuscation
lol
open source is the best DRM and obfuscation
No. No its not.
Yes it is, people can't steal your code into a proprietary plugin if everyone has access to your code
People will notice that it's stolen from X open source plugin
Open source is literally "steal this code to use in your own projects" xD
wow, I think I should really start decompiling + cracking your project to check for stolen code then
open source licenses are a thing, y'know
My code is my own. Hence the obfuscation, so it won't be stolen 😉
so you trust that no one will deobfuscate and steal your code?
They can try. Only 1 person removed my blacklist but they couldn't deobfuscate the code.
obfuscation is utterly useless
look at minecraft
nothing stopped the community from completely reversing it
That’s not completely true lol
Minecraft’s obfuscation is shit
Minecrafts "Obfuscation" just changes the variable names. They aren't trying to hide their code.
My Obfuscator makes what ever I want I's and L's; Strings, methods etc.. And remapps.
so.. renaming
Not even the best obfuscation will prevent that
All depends on your situation, if you’re selling your product idk why you’d open source it
Nobody would buy it then
Cause they already have it
Citizens, Guilds, VoteParty
• Removed 50 messages.
We have a plugin os and another coming soon, both are paid and the selling point is textures and support
If a plugin.yml contains depend: [<pluginname>] will this plugin run onDisable() before or after the plugin its depending on?
Probably before
I thought so. I'm gonna need to debug it cause I feel like its not
I don't see why it would
I gotta debug more then just that lol
don't see anywhere in the code other than startup where it references depends
well seems like it unloads based on depend order. So I don't think thats my issue then which kinda sucks cause I was hoping it would be that easy lol
but it probably just unloads based on the order things load...
Either way the plugin that depends says unloaded before the depended on plugin
yeah, it does. Unload order is based on load order
The issue was I forgot to add the object to the list that is checked onDisable
This should work right?
public static boolean isFull(Chest chest) {
for(int i = 0; i < chest.getInventory().getSize(); i++) {
ItemStack itemStack = chest.getInventory().getItem(i);
if(isAirOrNull(itemStack)) return false;
}
return true;
}```
Keeps returning the wrong value
What does isAirOrNull do exactly?
try chest.getInventory().firstEmpty() == -1 (-1 = full)
probably checks if the material type of the item is air or the itemstack is null.
sorta makes sense
ive already said:
to get all the values in (a) column(s)
locking system
it stores the world, x, y, z, and block type in WORLD_XYZ_BLOCK, the locker in LOCKER, and the person that placed it in PLACER
and on start it checks each location in WORLD_XYZ_BLOCK, if the block type at the location isnt the same as whats stored, it will set LOCKER to null
so to do that i need to get all values in WORLD_XYZ_BLOCK, and for each value it gets the world, x, y, and z, which is put into a Location
public void check() {
List<String> list = new GetSQL("locked").getValue(new String[]{"WORLD_XYZ_BLOCK"});
if (list != null) for (String key : list) {
String[] split = key.split(",");
Location loc = new Location(Bukkit.getWorld(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2]), Double.parseDouble(split[3]));
if (!loc.getBlock().getType().name().equalsIgnoreCase(split[4])) {
new GetSQL("locked").setValue("WORLD_XYZ_BLOCK", new LockManager(loc.getBlock()).getId(), "LOCKER", null);
}
}
}```
why?
why what?
i doubt you create a column
every time you save a new location
that would be simply dumb
you probably insert a new row right?
(but column is not the same as row)
every time a block is placed it creates a new row with the block's WORLD_XYZ_BLOCK and PLACER, LOCKER remains null
PLACER is used to check if the person trying to lock the block placed it, but it only saves blocks which are lockable
i know that
o
I hope you do a lot of caching as without caching this code will perform terribly
uh oh, how do u cache 
that was just in general, as the method can be used be any amount of columns
not columns, right?
why columns
thats my question
idk if you get the difference between
column and row
thats why im confused
why would you have more than 4 columns
i have 3 columns
ok
why you need to "loop"
those 3 columns
if you already know
the name of the columns
you "loop" when you dont know how many you have
if you have 3 with names
locker, type, owner
then you simply get them
which leads to my question again
WHY you need to loop all columns
if you have only 3
you probably meant "loop rows" instead?
that's what is confusing me
i dont understand what you trynna do
and why you would loop columns
you get my concern?
hm
yeah
thats the question
why would you loop columns (of the database)
if you have only 3
i wonder why
if its a locked system
you simply load all rows on start
and check on diff events like break block, interact, etc etc
and save on stop
but i dont want all rows
i only want the values in WORLD_XYZ_BLOCK
oh i thought u meant like entire row
irrelevant
Have you thought about using Terry's Ring0 Columns hashing mechanism @dark garnet ?
you can simply set it to pick only WORLD_XYZ_BLOCK column
but why would you need to loop all columns
if you only have three
you probably made a mistake
and meant "loop rows" all this time?
we know
question is why he wants to loop "columns"
not rows
tahts my question, since yesterday
ik y i put it but i dont know how to explain 😩
i dont think you know what you mean with that
but like also whom care if hes looping cols
The only reason why u'd loop columns is if you don't know the column's content
i mean, you have 3 columns
but now that i think about it, it doesnt make any sense y i put it
yes yes i do
its a dynamic method, meant for any amount of columns
@dark garnet Let me ask you this do you know what are the columns you need to get the info from?
yes but the method is supposed to be able to take any number of columns with any names and then output all of the values (rows) from those columns
why
huh
lmao





