#help-development
1 messages · Page 804 of 1
for spigot
Why does that matter
yeah
thats what i was saying
so why would you need to add for spigot
¯_(ツ)_/¯
you can, if you want the compiler can keep the actual names
hi , uhhh for some rason the Win Dance is running the wrong one
not the one that in the user data
do i have to do anything to update the bukkit inventory?
its not setting the updated items
Nope. Usually setting an item in an inventory should update it.
weird
hard to tell as no code
public interface InventoryWindow {
static InventoryWindow wrap(Inventory inventory) {
return new InventoryWindow() {
// ...
@Override
public InventoryWindow setItem(int slotIndex, ItemStack stack) {
System.out.println("set slot(" + slotIndex + "): " + stack + " in inventory: " + inventory);
inventory.setItem(slotIndex, stack);
return this;
}
};
}
// In InventoryButton
@Override
protected void render(InventoryWindow window) {
if (constantStack != null) {
window.fill(constantStack);
the rest is just calculating slots and propagating calls
but it eventually reaches the method above
in the wrapped inventory
with the correct slot
then no, it looks fine so long as your stacks/meta are good
weird
Are you sure you ware calling this wrap method on the same inventory?
PS: What you are doing is very, very weird.
protected final InventoryWindow inventoryWindow;
public InventoryGUI(PlayerGUIState state, Inventory inventory) {
super(InventoryBounds.cover(inventory));
this.state = state;
this.inventory = inventory;
this.inventoryWindow = InventoryWindow.wrap(inventory);
}
that field is reused by everything
What are you mapping the InventoryGUI to?
wdym?
each player has a PlayerGUIState which contains info about the current GUI and properties of the online player which also holds the current open GUI which is in this case the InventoryGUI
thsoe objects are just in a weak hash map by player instance
its calling setItem on the same inventory
looking at the identity hash code in the debug statements
so idk why it doesnt work
Force an inventory update
yeah thats what im trying to do now but idk how
theres no update() method on the view or the inventory itself
Player#updateInventory()
oh k
I never needed this for guis...
What version are you on?
-.-
but its just using api so idk
Yeah but 1.8 has a ton of weird behaviors and bugs which will never be resolved.
Regardless of the API.
true ig
i wouldve used nms and done the updates all in one if nms wasnt complete aids in 1.8
i might just do it with protocollib at this point
updateInventory() doesnt do shit either
pretty easy to swap out the inventory impl
Dont. This behavior indicates a fundamental problem with your code.
Print out the inventory content after placing the items in there, and then
call getOpenInventory() from player, and print out the inventory content of this inventory.
and compare inventory hash of your inventory and the open inventory
i did
i confirmed it was setting the items in the same inventory at least
and the first page shows fine but it doesnt update
Is the second page a new inventory?
nah it replaces the existing items
at least thats what it should do
public static void printContentsCompact(Inventory inventory) {
System.out.print("Inventory(" + inventory.getSize() + ")");
System.out.println(Stream.of(inventory.getContents())
.map(stack -> stack == null ? "none" : stack.getType().toString())
.collect(Collectors.toList()));
}
[11:50:31 INFO]: inventory before click event call:
[11:50:31 INFO]: Inventory(27)
[11:50:31 INFO]: [WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, none, none, none, none, BARRIER, none, none, none, ARROW]
[11:50:31 INFO]: inventory after click event call:
[11:50:31 INFO]: Inventory(27)
[11:50:31 INFO]: [WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, WOOL, ARROW, none, none, none, BARRIER, none, none, none, ARROW]
And you checked, after updating your inventory. Not just when opening.
it set the arrow
as you can see
System.out.println("inventory before click event call:");
InventoryUtil.printContentsCompact(inventory);
onEvent(new ClickEvent(
this,
slot,
slotX,
slotY,
event
));
player.updateInventory();
System.out.println("inventory after click event call:");
InventoryUtil.printContentsCompact(inventory);
its being called ..
also the elements are registered n shit bc when i click the slot where the arrow should be it goes to the last page
still doesnt update but in code it does
1.8 bug then
i fixed the loading , my problem now its Running the wrong cosmetic !
sad
idk. Call updateInventory one tick later.
so this is how i have it in the database :
call an openInventory after updating contents
it send the correct cosmetic name that i selected but it run the wrong one :
that works
resets the cursor tho
kinda sucks
ill try updateInventory a tick later
You can prevent that by opening in the same tick as the click. (At least in newer versions)
Sounds like your cosmetic impl just copied the other impl
Or you mapped it wrong
can this be the problem?
I dont understand the purpose of this method.
Anyways, how do you retrieve a Cosmetic instance after loading its name from your DB
didnt work here
This is how iam getting it from mysql .
Check the name field of your cosmetics
and this is how iam loading it :
ill try with packets lol
i checked the name of the field , its correct :
This looks like an exception was thrown
oh wait
I meant inside your classes
where?
yeah i changed something and that broke it
i didnt record the first time i tested tho it didnt work either
some weird bug
Each of your classes has a name field or a getName method.
Make sure they are right.
does removing a plugin jar whilst the server is loaded cause any issues
I want to replace my jar with the updated build rn, so it automatically updates during the daily automatic restart
always stop start
It should be fine swapping the jar out before server restarts.
spigot/bukkit has an update feature
i finally found the bug 🙂
create an update folder and put your jar in there. It will be copied into plugins upon a restart
Yeah if you create an updates directory any jars placed in there should cause the server to update the corresponding plugins automatically
how to convert class org.bukkit.entity.EntityType to https://mappings.cephx.dev/1.20.2/net/minecraft/world/entity/EntityType.html ?
Would need NMS then getEntityClass and get teh NMS version from there
EntityType#getEntity.Class().getHandle or something
after casting of course
There is probably a namespaced key in EntityType which can be used in some registry or sth
it is keyed but thats probably only Bukkit names
🤷 would have to dig
getting the CB class shoudl then have a Handle you can then get the MC type
They should be the correct keys
How do you ensure that the classes of Floodgate are on the server when it starts?
Did you try to build an artifact?
Hey there, is it possible to listen for bungeecord handshakes in older versions without use of protocollib?

Because i dont understand your question.
But i interpolated the problem. (Probably)
You cant just build artifacts when using maven. You need to run maven
goals, which build the jar for your. Which IDE are you using?
Im just gonna guess that you mean IntelliJ. Also you are a suppliant (asking for help) and i find this condescending line of conversation out of place.
Anyways, go to your top right side. There should be a maven symbol. Click on it, and run the package lifecycle of maven.
did you follow this
He did, but he didnt use maven before. So there is a more fundamental problem.
oh lmao i thought he just added the jar to intellij without actually including it in maven
scroll to the bottom section
<repository>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/main/</url>
</repository>```
well to be fair you might not want to use maven but still want your ide to know your dependency
bro speaks in ks
You should never manually add any dependency to your project if you want to use maven.
Only through your pom.xml
is there a way to fill a hashmap when creating it as a field?
Only to a certain limit
Or with a builder
I've tried Map.of but i did it either wrong or it doesnt work because it was all red
Map.of only works for a few elements. And it doesnt result in a hashmap either. Its an immutable map.
Do you need the map to be mutable?
i dont really know what mutable does
If a map is immutable, then you cant add/remove elements to/from it.
so immutable = unchangeable?
what if i'm manually adding them to my pom.xml
checkmate, atheists
-.-
Install them to your local maven repo then 🙂
Yes
In which case you could
private final Map<String, UUID> someMap = ImmutableMap.<String, UUID>builder()
.put("A", UUID.randomUUID())
.put("B", UUID.randomUUID())
.put("C", UUID.randomUUID())
.build();
Map builder
Never thought I'd see it
?
You can also just use
Map.of(...) to create an immutable map out of key and value pairs when you know your entries on map allocation
thank you :)
The keys in entitytype should match the internal keys
how can i add a entity limit for an specifc entity in an specific dimension?
?paste
https://paste.md-5.net/opesewiyuj.java this is my code
Doesnt spigot have a config for this?
yeah but not for an specific entity in an dimension
Well, then keep track of the entities or count them before spawning.
bro
hi question , should i regenerate the whole world?
for a minigame ?
or only regenerate (breaked blocks) , (placed blocks)?
i need there to be a limit of 200 whiter skeletons in the nether so it doesnt lag
You could also use a zip file or folder as a template and reload the world.
Or you can disable chunk saving for the world entirely.
Well, then keep track of the entities or count them before spawning.
bro how tf can bukkitTask stop if I count them?
interesting
I would remove the BukkitTask variable entirely because its not used anyways.
But you can cancel the BukkitRunnable by simply calling cancel() in it. Bro
wasn't there a better method of canceling?
bro
But keep in mind that you need to keep all chunks loaded while the game is running, or else the chunks might unload and load again, removing all changes.
bro, in my code if i place a nether brick they spawn a whiter skeleton but if i destroy the block they keep spawning, however with BukkitTask i can stop them from spawning on air
What scale are we talking about. Meaning what exactly does better or worse mean in this context.
you need a break event listener and stop the task in that
but can i use it while im using BukkitTaskTimer?
create the task in Place event and store teh block in a Map with the running task.
it would reroll again and again
?
when the block is broken, fetch the task from the Map, cancel it and remove from map
it would cancel spawning but the game then keeps looking for a new location to spawn
i use it in the GameEndEvent , after all players moved to the lobby world correct?
thats how i think it shouls be used :p
First of all: Delete your BukkitTask variable.
org.bukkit.scheduler.BukkitTask task = new org.bukkit.scheduler.BukkitRunnable() {
@Override
public void run() {
if (block.getType() == Material.NETHER_BRICKS) {
world.spawnEntity(block.getLocation().add(0, 1, 0), EntityType.WITHER_SKELETON);
} else {
this.cancel();
return;
}
}
}.runTaskTimer(this, 200l, 1600l);
->
new BukkitRunnable() {
@Override
public void run() {
if (block.getType() == Material.NETHER_BRICKS) {
world.spawnEntity(block.getLocation().add(0, 1, 0), EntityType.WITHER_SKELETON);
} else {
this.cancel();
return;
}
}
}.runTaskTimer(this, 200l, 1600l);
His impl should already cancel the task if the block is no longer of type nether bricks, right?=
and what about the 200 entity limit in the nether?
Keep track of the entities or count them before spawning.
Which part confuses you?
only if the block is not there the tick it repeats
I should count the whiter skeletons?
so if he breaks it and places again, he's got two tasks running
Sure
uhh
Ah he doesnt check every tick. Just realized that.
thats excatly i dont want
a Map of tasks would be best canceling/removing on block break
One brute force example:
int witherSkeletons = 0;
for (LivingEntity entity : block.getWorld().getLivingEntities()) {
if (entity instanceof WitherSkeleton) {
witherSkeletons++;
}
}
Or in short
long witherSkeletons = block.getWorld().getLivingEntities().stream().filter(WitherSkeleton.class::isInstance).count();
this does not work :L
You need to wait a bit after unloading a world. Its a bit cringe.
Or use a different name for the loaded world.
We should make a CompleteableFuture for unloading
ME?
Noo
You wish
Lots of things happening sync in the world
And loading as well please. There is IO being done on the main thread.
Ive tried it for half an hour but it went really deep at some point so i kinda lost interest
Yay deep
That’s what she said
Get to work
hi , uhhh iam trying to unload the map -> load the backup -> but iget this error
its not the same world in server-proprties , i changed it to Lobby
how can i add an command to my code?
this is my code, if i try to add an command to my code it just wont work!
me.uwunugget.uwunugget_plugin;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.block.Block;
public class Uwunugget_plugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
World world = block.getWorld();
if (block.getType() == Material.NETHER_BRICKS && world.getEnvironment() == World.Environment.NETHER) {
org.bukkit.scheduler.BukkitTask task = new org.bukkit.scheduler.BukkitRunnable() {
@Override
public void run() {
if (block.getType() == Material.NETHER_BRICKS) {
world.spawnEntity(block.getLocation().add(0, 1, 0), EntityType.WITHER_SKELETON);
} else {
this.cancel();
return;
}
}
}.runTaskTimer(this, 200l, 1600l);
}
}
}
provide your code with the command
Iirc there is some bukkit utility for it
are you making custom command with @s ?
or changing the cmd block
I think Bukkit#getPlayerTarget or sumthing like that works for the first one
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
There is Bukkit.selectEntities
?
also why do you use task
it's kinda overingeneered
when command activated in coomand block
get nearest player to that block
and replace the @s in the command block with the retrieved player
i want to have an /info command
bro
yeah?
great
but we need the source code
what the event use
¯_(ツ)_/¯
how detect when player activate cm block
ig playerinteractevent
I have a player as a passenger on a slime and then I have to spawn in a new slime every tick with it looks like the slime kind of shakes then it can be solved so it runs more smoothly
serverCommandEvent just return interact
here you go
@EventHandler
public void CommandBlock(ServerCommandEvent e) {
if(e.getSender() instanceof BlockCommandSender) {
// do whatever
}
}
maybe something like this?
is that a question
found it on this threaD
https://www.spigotmc.org/threads/command-block-execution-event.50554/
yes
i don't get it then
I think hes spawning lots of slimes and moving them every tick
and he wants to smoother the movement
its choppy rn and he wants to smooth it?
I spawn in a slime that a player is a passenger on. Every tick I spawn a new slime and remove the old one, when you look at this slime that is now "moving forward" it looks like it is shaking
well, you can try disabling ai/gravity and so on before spawning
maybe it will help a bit
just teleport the entity
spawning and removing doesn't seem like a performance beneficial thing
also idk if it's possible to also set direction for spawned mob
It is not possible when a player is a passenger
oh aight
well, detach the player, tp the entity and reattach
tho in player's perspective camera would shake
for other players it would look fine
never tried something like this
but it could be due to the player falling before setting him as pasenger again
"falling"
just some small amount
thats my thought
i mean i coded Pen-Is-Ban
which basically set player as passenger to invisible armor stand on top of giant wool pen-is
and well, armor stand had to teleport upwards with the player each tick
for second player everything looked fine
but for the one on armorstand camera was like:
So you mean I should use armor stands instead?
Tried a gif but it doesn't show
record with windows recording tool?
Can record with obs one sec
what i can suggest is using invisible armorstand + display entity
and well, working around velocity of armorstand
and teleport display to armorstand position
Here is the recording:
well ig this can also be because your moving interval is too high or your moving distance is too big
so you can notice every small move as separate long frame
not sure tho
I wish mkvs actually embedded properly in discord considering it's a pretty popular format
can turn it into an mp4.
mkv is mostly popular in piracy
its fine I downloaded it
also might be cuz of interpolation
and OBS :P
skip to 0:26
how to change player's name only for one player?
use packets ig
i need packet tutorial..
@tender shard @echo basalt
or ?google
Bing your question before asking it:
https://www.bing.com/
Just look at using protocol lib or PacketEvents
Documents the packets
^
is it possible to manage through several world files?
in paper atleast there is a method
teleportWithPassenger or somethigng
?
like can I have several folders for each world and manage through them
like teleport player to another world
Worlds are their own folders already
am i dumb?
i don't crash but get kicked out
[16:26:04 INFO]: LividX lost connection:
[16:26:04 INFO]: LividX left the game
error: No matching static constructor: ClientboundPlayerInfoUpdatePacket.<init> called with (net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket$a$a (JavaType), EntityPlayer['LividX'/265, uuid='b32bbf5d-a9f0-4d77-b8f1-258c20fd396c', l='ServerLevel[world]', x=9154.74, y=79.00, z=10402.82, cpos=[572, 650], tl=2501203, v=false, removed=UNLOADED_WITH_PLAYER](LividX at 9154.735701495267,79.0,10402.823517153784) (EntityPlayer))
If I want to get an item from an item frame, should I use Item or ItemStack?
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
also how come getRightClicked exists but getLeftClicked doesnt?
bc left click destroys it
yes
hey ! how can i increase the item view distance ? in spigot.yml noting of entity-tracking-range or entity-activation-range works (or i may not know what's the good field to change)
so thats prob a different event
Hmm, any clue why there's a discrepancy in how 1.19.4 -> 1.20.1 processes § color codes specifically in titles?
In both screenshots, these commands are used: (plus /title @a times 0 1d 0 so the title stays)
title @a title { "text":"§x§f§f§1§1§0§0TEST" }
title @a subtitle { "text":"§x§f§f§1§1§0§0TEST" }
title @a actionbar { "text":"§x§f§f§1§1§0§0TEST" }
On 1.19.4 it works fine (first screenshot)
On 1.20.1 (maybe 1.20 too, didn't test), it apparently only takes the last color code (in the above case, §0 which makes it black)
You dont use paragraph for it
I have a character-limit sensitive use-case which suffers from having to (during a gradient for example) create a text component with a different color for each letter.
how are you displaying the titles then
I mean you dont have to use the commands right
Sending a packet with the same exact json that goes into the command
You really shouldn't be using legacy text in components at all
These types of discrepancies are inevitable
Especially if you're using RGB because there's ways to do that better, {"text":"TEST","color":"#FF1100"}
how could I make an item stack air? i tried both AIR and Material.AIR and ItemStack.AIR
nothing seems to work
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
AlertObject alertInfo = new AlertObject();
alertInfo.griefer = player;
alertInfo.block = block;
alertInfo.material = material;
alertInfo.frameItem = ;
alertInfo.type = 0;
alerts.put(blockNumber, alertInfo);
doAlert = true;
what do I put in the frameItem
its an ItemStack
and I want it to be AIR in this case
hey guys, i need help. I want to override the Minecart logics for collision and some other things. so i need to use nms for that, can anyone show me how to do such a thing cuz i have never touched nms before...
@rotund ravine why are you crying?
We don't know what AlertObject is
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class AlertObject {
Player griefer;
Material material;
Block block;
Byte type;
ItemStack frameItem;
public AlertObject(Player griefer, Material tool, Material material, Block block, Byte type, ItemStack frameItem) {
this.material = material;
this.block = block;
this.griefer = griefer;
// Fyi, 0 = break, 1 = item frame, 2 = block place
this.type = type;
this.frameItem = frameItem;
}
public AlertObject() {
}
}
I mean if this is your plugin and you just want air, you can either opt to use null or new ItemStack(Material.AIR)
ok thanks
or is there any good tutorial on yt for nms overriding
Whenever I use null in my object it keeps throwing stacktraces
?noerror
No not really
What you'd do is extend the nms Minecart class and override the method that handles collision
yea thats what i want to do
and then use nms to spawn it
and how do i do that?
?nms
Is a start
okay
Well if you're using null you have to actually account for the fact that that value can be null. You'd have to check for it any time you want to use the field
ItemStack itemInFrame = itemFrame.getItem();, currently this gives ItemStack{GOLDENSWORD, 1x}, how could I make it just be GOLDEN_SWORD? getMaterial seems to not exist
nvm
getType
nvm that didnt work
nvm I just had to make it a string
...WHAT'S WRONNG
oh...
really...
I'm sorry
I'm so sorry... I was trying to solve problem about 30 minutes..
It's ok but nothing has changed..
ok so i installed the remapped version, whats next?
FileConfiguration config = plugin.getConfig();
config.getConfigurationSection("languages").getKeys(false).forEach(el -> {
if(el.equals(chatName)){
System.out.println(config.get("languages."+chatName));
System.out.println(config.get("languages."+chatName+".suffix"));
}
});
Now make a new class extending the nms Minecart
kk
ok
?paste your config
Anyone have experince with world loading , unloading for a minigame plugin?
i cant find one...
it told me to implement some super methods
try wrapping your suffix in ``
but i put it using command config.put(..., args[1])
ah
then you are modifying and not saving
but then it wouldn't work fine
must save after making changes to config
it works if you are loading a clean config on startup
No
My guess you are breaking the config while running
maybe
and not saving changes
i save using plugin.saveConfig()
well it doesnt have any overridable methods
after every change?
Yeah
somewhere you are removing the suffix entry
I see changes using VS code or note
if it works with a fresh start
@chrome beacon
nvm i got it
software users have a special kind of lead poisoning at times man i swear
me: are you using <this command>
them: yes im using <this command>
me: can you type out the command you're using
them: ok its <not that command>
me: ok please use <this command>
them: but the plugin documentation said <not that command>
me: please try it anyway
them: ok it worked it was <this command>
but what about the super thing
and now that over the course of 20 minutes
i found out what can be problem... Maybe because i'm saving hashmap not the configuration section
do i need to implement all?
That's the constructor
Yes you need it
okay
ah, if you JUST set a Map in your config it will still be stored as a Map until you save/reload the config
its a Bug in the Bukkit SnakeYaml wrapper
So how to change it?
ok so I made everything that i could find containing 'collide' to false... what should i do next @chrome beacon
always reload after a save, if you are using Maps
Read the nms code to see what's actually being used to collide with other Minecarts
how
Ctrl click the Minecart class to open it
I think i can do it without map... Soo... What other ways are there?
i know root like a.b.c.d...
its just this
theres no documentation @chrome beacon
This is what I use when working with Maps```java
/**
* If loading from file the Maps in the data
* will be stored as a MemorySection not Maps.
*
* @param entry MemorySection or Map to check.
* @return Map containing the serialised data.
*/
@SuppressWarnings("unchecked")
protected Map<String, Object> castToMap(Object entry) {
if (entry instanceof MemorySection) {
return ((MemorySection) entry).getValues(true);
} else {
return (Map<String, Object>) entry;
}
}```
I think there is an easiest way with what i want to do
You could try using (instead of set) https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/ConfigurationSection.html#createSection(java.lang.String,java.util.Map)
I've not tested if that correctly translates the Map
unloading world -> remove world -> replace or add the world template -> load the world
Couldn't save chunk; already in use by another instance of Minecraft?
net.minecraft.server.v1_8_R3.ExceptionWorldConflict: Failed to check session lock for world located at ./Lobby, aborting. Stop the server and delete the session.lock in this world to prevent further issues.
"select count(name) from enemyStats" <- how can I retrieve list of names from this query in SQLite?
you can;t from that query. You'd need a seperate query
@chrome beacon can u help?
Why would there be documentation
well u said it
so this query would just give me number of things in it?
yes
oh okay that can work too
No I said there would be code to read not documentation
Most of the code is in AbstractMinecart so open that
ok
ideas :-?
why not just SELECT * FROM x
Ok, so whats next?
I have the class
This is done via client side armor stands right?
now time to read code
idk someone gave me this statement here and told me to use it
bruh I want every collidion to be turned off, not only with minecarts...
so i guess its good
I just want to get list of all things from certain column
so do select *
wouldnt it select everything everything?
it would select everything from the collumn you specify
or just select name from table
@chrome beacon
so?
Or just regular server-sided armour stands, yeah, probably
yea so i have that class
choco did you see the poutine rasputin remix
that overrides the nms minecart
but it allows me to only input table
select * from enemyStats
@chrome beacon WHAT DO I DO WITH THE NEW CLASS??
i have never used nms. sorry
Imagine lowercasing SQL keywords 
Yes
opinions?
Fire
have you ever had these
I haven't but they're probably great
whats so wrong about it
what do you want more programming socks or 1 bag of poutine crisps
well fetchall() method just doesnt work for me
guys can somepone help me please, olivo told me to make a class and extend nms Minecart and override some methods. idk what to do next...
did you look at the screenshot i sent
i already overrided some of the methopds
iim not talking about statement
it works
use executeQuery and use the result set
im doing that
so what doesnt work
theres no fetchall
a method fetchall?
guys plz help
you loop the data
Hello Guys,
i have programmed a player object (UPlayer) in which I load all the data from the player asyncronously from a mysql database (loadDatas). Creating a new account and saving works without any problems. However, this unfortunately gives an error in which all strings and integers are null. Unfortunately I can't explain what the problem is, please help me.
https://paste.md-5.net/zalecelehe.java- playerManager
https://paste.md-5.net/filofiwasu.cs - UPlayer
https://paste.md-5.net/cozucesede.java - registerAccounts
https://paste.md-5.net/bunolasabu.cs - Output from Loader
ignore the @cleanup
correct
what
@chrome beacon or someone plz help
create a list and populate it with data that you fetch instead
instead of fetching the list that is nullable and operating onto it (causing the nullptr)
this.enemyList hasnt been initiated
its there
its not instatiated
meaning it is null
leading to a null pointer exception when trying to operate on it
That variable is just declared, you have to assign something to it
do
List<String> enemyList = new ArrayList<>();
and when fetching data add it into the list instead of reassigning it to avoid null as a value to be set
plz just SOMEONE
thats so fucking confusing
it is not tho if you know how java works
btw. depending for what this list stands for I'd recommend going with a Set instead (if the values should be unique), HashSet is the one you may initialize with
what exceptions are produced
that has nothing to do with assigning it to a new arraylist
you assign null to the list at some point
that's what I meant
instead of directly reassigning the list to a fetched value, add to the list instead
Now spawn your Minecart
and ConcurrentModificationException is because the list was modified while it was iterated over
brb
you can fix this by creating a synchronized list or CopyOnWriteArrayList
@storm crystal
or just don't remove/add to a list you are iterating
ur trying to modify the list asnyc
wait
no ur modifying while looping
or use a list iterator with which you can actually remove values while iterating over it
yep, or removeIf
but easiest fix is a synchronized list
still can;t remove while iterating
well duh
that will only add one entry
then how the fuck do I loop through that god forsaken result set
should I put this in a seperate class?
all it does is loads a Config, and checks if there are null values
thats being ran async
while(resultSet.next())```
and if a config doesn't exist already it makes a new one
whats enemy stats manager line 60
so your question is how you could optimize this source?
it works
can you send this in as formatted text please
yes I can show you how I would refactor it
try {
if (!configManager.isSavedInDatabase(StartUpConfig.class)) {
StartUpConfig freshNewNiceConfig = new StartUpConfig();
configManager.registerToCache(freshNewNiceConfig);
configManager.saveFromCache(StartUpConfig.class);
printNullFieldsError(freshNewNiceConfig);
return;
}
StartUpConfig startUpConfig = configManager.loadFromDatabase(StartUpConfig.class);
if (hasNullFields(startUpConfig)) {
configManager.saveToDatabase(startUpConfig);
printNullFieldsError(startUpConfig);
return;
}
configManager.registerToCache(startUpConfig);
} catch (Exception e) {
e.printStackTrace();
}```
just without making new classes, too much abstraction isn't needed
I want abstract rn cause this is gonna be a big project
this wont just be "startUpConfig" btw
i think ill just put this method in the configManager class
just make a method that takes in a generic of type <T extends Config> with a Class of type T and use the above code
Call the constructor that takes a level
then use level.addFreshEntity to spawn it
oh and run setPos before spawning it
how work EntityChangeBlockEvent&
what this event do
and how player can be in this event?
static <T> T getOrCreateConfig(Class<T> type) {
try {
if (!configManager.isSavedInDatabase(type)) {
T freshNewNiceConfig = new T(); // invoke default constructor of `type`
configManager.registerToCache(freshNewNiceConfig);
configManager.saveFromCache(type);
printNullFieldsError(freshNewNiceConfig);
return config;
}
T config = configManager.loadFromDatabase(type);
if (hasNullFields(config)) {
configManager.saveToDatabase(config);
printNullFieldsError(config);
return config;
}
configManager.registerToCache(config);
return config;
} catch (Exception e) {
e.printStackTrace();
}
}
ima put them in my manager class
i've got like 16 log files of this shit
okay but I want to basically make all minecarts like that
so also minecarts that players place
well it means that a memory access violation has happened, i.e. a memory address has been written or read from which the program has no access to
:(
yo may want to reinstall java
it's a hard to debug thing, can have many root causes
- try reinstalling
- try a different version
- check your administrative permissions
Then listen for when a Minecart is spawned/loaded
or make a Spigot fork 
i mean the "easiest" solution is to cancel a block event and break/place it manually and play the sound to the player
but im sure there are more elegant ways of replacing sounds
hm yea
but i think
maybe someone have better idea?
honestly I think this is your best solution
unless there's a sound event that you can interact with
@upper hazel
int taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
PlayerEffects.applyEffects(player);
}
}, 0L, 2L);
is this a valid way to setup a scheduler ticking per each player in my plugin enable
Yes
question, what can we do with the ID of the task
i dont think we use it to close the task on shutdown
You can
I don't remember how tho
So do
runTaskTimer
Instead
It's the exact same thing
But returns a BukkitTask
?jd-s
Is there any efficient way to check if a player has been hit in the past 20 seconds (in combat)
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitScheduler.html#cancelTask(int) it's straightforward really
is there any way to get the SlotType of a slot using only the inventory type and the slot index
i only have access to the type of the inventory its not an actual bukkit inventory instance
put a player into a list when he was attacked and delete him from the list after 20 seconds
ok i think i might make an updater class and an update result
fuckin mint
A colleague has the following sql error when performing a java insert query:
Cannot add or update a child row: a foreign key constraint fails (project.loan, CONSTRAINT loan_ibfk_1 FOREIGN KEY (UserID) REFERENCES users (id)).
But when doing the manual query through mysql terminal it works perfectly well
INSERT INTO loans (user_id, book_id) VALUES (1. 11);
asking for a friend
are the input slots in an anvil, enchantment table and other such inventories classified as crafting or container?
and are the workbench slots crafting slots or also container
how should I proceed when trying to make additional AI to an enemy, as in make it lets say stop and spawn something at player's location as a simple example?
https://paste.md-5.net/xiwobuneba.java
utility to get the slot type for most 1.8 inventory types if anybody needs it
i probably have some shit wrong and im too lazy to implement beacon and brewing but yeah
i think this is based on the raw slot index you get from a click packet idk the official terminology
I want to make this class work for each animal. the problem: it extends Squid and id need to pass the animal type in in the constructor
any idea how i can resolve this
i dont want a class for each creature type
ah yes
dude
thats such a good troll
set fake like diamonds in someones invneotry
and when they click it it disappears
should I rely on the jetbrains @NotNull annotation to handle null params for me
🤷♂️ it doesn't really matter its a markup annotation for intellij
ultimately it means nothing
r u sure
I also use Google's Preconditions API
if somethijng needs to not be null
I did not make that error
the annotation doesn't handle nulls rather just informs that it shouldn't be null
well it handles them when using junit tests
I know, but who runs tests 😛
if your running it inside of intellij I presume that intellij also handles it in that scenario too
I do for math
the actual annotation does nothing it really matters what the IDE does with it. In intellijs case they use it for information when coding and as it looks, errors during runtime and testing within intellij Itself
if you were to compile the jar I don't think anything would happen
I thought I did all those preconditions for nothing lol
and then you also have lomboks @NonNull
I think it can enforce the checks on 3rd party annotations even
doubt it, annotations are only as good as the processor that uses them
yep its in the settings
but only specific types of 3rd party annotations
for example it only really handle third party annotations that jetbrains already provides you can't add some custom annotations that aren't related
How do I implement several nametags on an enemy?
TextDisplays* that follow around the player would probably be the best method
need some invisible entities and make them passengers or have them near the entity in question
or go with Y2K's method 🙂
Okay
If I want an armor piece to give potion effects on equip should I make like 10s periodical scheduler to loop through players?
Or is there a more efficient method?
don't use a scheduler??? What is wrong with listening to events
give the effect when they put it on, remove the effect when they take it off
keep track of the armor piece with PDC
pretty sure they do though you'd have to check
I think that's something saved in NBT
otherwise you could log off and rejoin to remove poison
u would have to check for death too actually
and you would have to check if the player drank milk
I just saw it being refreshed on one server like that and wanted to replicate it
Lol
so there are still a decent amount of events u have to listen to
I guess im supposed to know the most efficient way out of the blue
didnt expect cancelling an inventory interaction to be this difficult
(with packets)
i recall trying to do this in fabric and it was a nightmare because u had to check for like 8 different itemstacks
cursor, inventory, whatever
at least this is 1.8 so i think all i have to do now is send the contents of the player inventory (?)
again
very inefficient but ill optimize later ig
why are you using packets? just for funsies
nah bc the bukkit inventory didnt work
for what
If Bukkit Inventories aren't working it should probably be a jira report
@river oracle
this issue
so now im doing my own wrapper with packets
for osme reason
its prob a client issue tbh
setting an item doesn't update it?
yeah
try Player#updateInventory
already tried
It's likely because it's 1.8 api and it's whack
also tried doing that 1 tick later
just use a library
how do i get a nms entity type from bukkit entity type
guh 1.8 moment
packets fun then ig
for real if only it could be standardized without breaking API contract
I can only fix so much of this stuff in One PR :P
it did not fix it
its why i switched to fabric :p mixins
lmfao
this is so fucking weird
why does every packet use a different slot indexing
aye you did it
LMFAO
ohhh wait getContents() doesnt account for the goofy arrangement of the crafting and armor slots
the bukkit one
this screenshot goes so hard
argh at this point im gonna ask here, so i have this right, im trying to implement a damage system on top of this that breaks the block when it reaches 10, i have no idea what math i should return from the function to do this
for example I have damage: 8.0 ticks: 188 seconds: 9.4 but im not sure how i would return the damage in the form of a damage increment from 0-10
is it just me or are records kinda ugly
like the only time I like records are for primitive data classes only
just u records are awesome
idk why
i just dont like that
when I use @NotNull and then check it in my own constructor
whats the best way of adding mutli-version support? If i used 1.20 spigot for a pl, how can i add support for 1.18-1.19?
I've seen people use modules
but idrk how people combine the modules to add support
you shade them
another use is to use them create different jars
use viaver / viarewind @median bronze
that would be the right answer if this was #help-server 😄
Look at Emily keeping up with the right channels
you can use NotNull on the default record constructor and instead of using preconditions just assume failure at some arbitrary point
what does asserts != null do?
pretty much tells the code to assume everything is good? i've learned in my youth never assume things
assert is something you shouldn't really use
What event fires when a person presses numbers to change their equipped item?
They're disabled by default but it helps clear up some very obvious warnings from IDEs. I use it a lot for item meta from a fresh item stack
ItemStack itemStack = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta itemMeta = itemStack.getItemMeta();
assert itemMeta != null;
itemMeta.setDisplayName("Hello world!"); // If not for the assertion, my IDE would say "potential null access" despite it being impossible
If I cancel this, would the gui update for the client? Like would it still highlight the item they pressed even though it's cancelled
iirc it would show on the client then immediately flick back to the previous slot
I don't think the server cares. As far as it's concerned, it went from slot a to slot b, doesn't care how it managed to do that
i mean w packets
Where do you think the event is fired from? :p
We expose all that we can there. Client doesn't tell us how it changed slots
hmmm
this guys rpg testing server
has abilities binded to 1 2 3 4
which i can see flickers when i press the number back to the original slot i was at
but if i use the scroll function i can still scroll thru my hotbar
Not sure how that would be done. The packet only sends the slot that it wants to set, https://wiki.vg/Protocol#Set_Held_Item_2
hmm or maybe he doesnt
oo simple solution chrck if the person is shifting to use abilities 😎
Really don't get the point of throwing an Error outside of testing seems wild to me. Unless a real critical error actually occurred
Think of an assertion less of an error thrower and more of a "I promise, this is actually impossible. If this happened somehow, something else is seriously broken"
In an ideal world you write assertions that will always be true
You don't want assertion errors
Idk especially in plugin development I guess I can't see a reason you'd want everything to crash and burn once your assertion fails I feel like most things can be handled by exceptions and safe fall backs or reattempts
Unless I'm wrong with my assumption assertions just kill your session basically correct? Ig a better way to say it is it'd terminate your program
It doesn't terminate the application, no. It's just an exception that happens to extend Error
💀 why that makes it seem scary
Because in theory it should be impossible
^
Ahhh
That case would just seem redundant though ig if you want to ensure absolute memory security it could be useful
Since your program would fail assuming memory was tampered with
Not redundant, makes your IDE happy :p
I just tell me ide to stfu lol
ItemMeta is nullable but only when the type is air, but we very obviously did not pass air to the constructor
IDE doesn't know that though
Question abt something with datapacks. Would it be possible to make it so that datapacks actually register things when enabled? Like when a datapack is enabled, mc doesn't register things in the pack, meaning new things in there like damage sources aren't registered. How would someone go about making the datapacks registered? I tried cmds and that doesn't work. Is there an api or a devBundle or fork way of going about this?
Interesting I thought mojang would allow this but maybe not idk when along data packs are loaded but if it's after when a plugin could theoretically be loaded you could manually unfreeze registries with your plugin
But given mojang probably doesn't support adding damage sources with data packs I assume you'd need to do this with a plugin
Damage sources can be added with datapacks. After looking at the code the datapacks seem to be loaded A LOT earlier than CraftBukkit, or even plugins. Meaning any datapack provided by a plugin would be useless until the server restarts and mc loads the pack
It seems that the datapacks are coded into the world on generation, so it would be unmodifiable during runtime
I may try and modify the source a bit to try and see if you can load packs on the startup, right once plugins are loaded, inside the gray area of "plugin repository start and figure out stuff" and "ok you can join and RIP u can't add datapack now"
Datapacka and plugins dont work well together
arent data packs loaded along with the world? maybe if you set your plugin to enable before the world loads with load: startup
idk
They're before
I'm trying to get a map from a yaml file and i'm getting an "unchecked cast" warning, can i fix that somehow?
Map<String, Location> playerWarps = (Map<String, Location>) WarpUtils.getInstance().getConfig().get(sender.getName());
or is casting ust wrong? lol
can i make a block that only the player can see?
i mean a player will have a diamond block in front of him and only he will be able to see that block.
Hi , uhh iam trying to get the block that is under the player?
i tried this but the code is not being exetued , its must a chest
Use block.getType
and i do == Material.CHEST ?
Yeah
that worked :p
Any way to make client sidr things for player
What things
Shit like particle
declaration: package: org.bukkit.entity, interface: Player
Okay great i know how to spawn a particle
It was just an example
How to do things for a certain player client side
So that only they can see it
Depends on what the thing is
yes its from diffrent or package
Blazingly fast world manipulation for artists, large networks and developers: https://www.spigotmc.org/resources/13932/ - GitHub - boy0001/FastAsyncWorldedit: Blazingly fast world manipulation for ...
its this one
how can I get the memory usage of each thread trace elements?
the memory each thread stack uses?
yes
hmm im unsure, since java also introduced virtual threads
it could be hard to track it properly
according to AI the JVM doesn't segregate memory usage per thread
there are some jvm flags iirc that allow u to do some interesting stuff regarding this
but i think its mostly for testing and debugging
?xy
Asking about your attempted solution rather than your actual problem
the forbidden jusu
is it possible to set rename text on AnvilInventory?
it has a getRenameText method , but no setRenameText.
should I convert it to nms first?
anyone got something on that?
supress warning
huh okay then
you could check the type before casting it and throw another exception if you want to get rid of the warning entirely but to supress it just add @SupressWarnings("unchecked") to your method/class
i mean yeah i've added the @SuppressWarnings but I just thought that's bad practice
there's no other way really
it might be idk but its also annoying to have that warning everywhere
wait let me see how much i use it in my code
not that big of a codebase
alright then i'll do that ig lol
intellij looks at //noinspection <inspectiontype>
(as well)
but yeah dumb type erasure
Global suppress warnings when
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getVersion()
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getBukkitVersion()
declaration: package: org.bukkit, class: Bukkit
Try one of these
might need a regex to isolate it
hi @chrome beacon I cant figure out how to spawn the minecart. Can you help me?
Sure what part are you having problems with?
So i have the class, now I need to spawn it whenever a player places a normal Minecart
Do I need to create this CustomMinecart object?
yes
okay
I believe I told you this yesterday
.
and what is the Level param?
I believe you'd get handle
OceanMinecart oceanMinecart = new OceanMinecart((Level) Bukkit.getWorld("world"), event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ());
like this?
wdym?
There's a method called getHandle
in CraftWorld?
if i create a new craftworld then there is a gethandle
oh i see
oka
and the other args are positions?
or what are they?
Check the nms code
there are 2 constructors
the top one is only if you are doing shit before spawning it
i see
wdym there is no documentation
in teh NMS class
you are workign with NMS now so look at teh decompiled class in BuildTools work folder
why would there be documentation
Read the code
okay
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world, double d0, double d1, double d2) {
this(entitytypes, world);
this.setPos(d0, d1, d2);
this.xo = d0;
this.yo = d1;
this.zo = d2;
}```
Ctrl clicking in Intellij will decompile the class for you
and which class do i need to read?
ElgarL already gave you the code you need
so yea it looks like the other args are coords
that means i dont need to call setPos, right?
not unless you are setting a direction
oh so setPos is a vector??
well its the same as Vector in bukkit
just spawn it and see
ok but how do i spawn it?
or addEntityToWorld, Its NMS so I can;t remember
then spoawn
which one tho?
there is no Bukkit entity yet
okay
ok
what should i do for the itemstack?
have you added your Minecart to the world yet?
ItemStack itemStack = ItemStack.EMPTY;
no?
i just createdthe class
nmsWorld.add...
((CraftWorld) Bukkit.getWorld("world")).addEntity(oceanMinecart, CreatureSpawnEvent.SpawnReason.CUSTOM);
?
try it and see
ok