#help-development
1 messages ¡ Page 486 of 1
They used to all be in a package called net.minecraft.server
Im probably being an idiot here but I'm using config.yml to store a balance for each player but the number doesnt go down in the config when i change the value
public void removeAugmentCount(Player player){
int oldValue = config.getInt(player.getUniqueId() + ".augments-left");
if (oldValue == 1){
config.addDefault(player.getUniqueId() + ".augments-left", 0);
config.options().copyDefaults(true);
saveConfig();
} else {
int value = oldValue - 1;
config.addDefault(player.getUniqueId() + ".augments-left", value);
config.options().copyDefaults(true);
saveConfig();
}
}```
Use set
that adds a default you need to use config.set
Not addDefault
oh right..
you can also remove " config.options().copyDefaults(true);"
Hello, I'm looking for help with prefixes. I would need, for example, if I put in LuckPerms: prefix.1.<g:FFFFF> Test </FFFFF> so that one more color runs through the text. Does anyone know please ? Thank you for your willingness.
you can use &#rrggbb with luckperms iirc
Okay, but that's only the first color of the text
I would need the second color to "run" over the first color
This page cannot be found
Thank you very much, only I would need animated text đ
Animated text as a prefix đ
Does anyone who knows about the bungeecord api know how to do this? Thx
What does that mean? String is from general Java...
If event priority on bungee is similar to spigot then itâs an enum
So you use valueOf
he wants to assign a priority to a listener dynamically from a string
you can't do that with an annotation because they don't work like that
Canât do that with annotations
They are not enum as in spigot.
What I wanted to do is to set a priority according to this set in the config as I do in spigot, but after seeing that in bungee that's not possible :/
Looks like they are just static fields that correspond to bytes
You can always just recreate them
Yes, but bungee doesn't have other methods to register events like spigot which gives you more customisation in that aspect, you can't set a priority on bungee events as the user sets in the config, as it only accepts final fields in the annotation
how I can disable saving world (no only autosave)
what do you mean?
if you disable autosave, and noone calls save(), it won't get saved
when chunk unload world (chunk) save
can you please try to rephrase that into a normal sentence
how to disable chunk saving?
chunks are saved during autosave, server shutdown, and unload (when the player leaves them)
how can I summon 2 item frame in the same place? because I'm getting this,
Caused by: java.lang.IllegalArgumentException: Cannot spawn hanging entity for org.bukkit.entity.ItemFrame at Location{world=CraftWorld{name=world},x=0.0,y=0.0,z=0.0,pitch=0.0,yaw=0.0} (no free face)
You'd have to make it sit on a different block face
world.spawn(location, ItemFrame.class, itemFrame -> {
itemFrame.setFacingDirection(BlockFace.NORTH);
}```
but if im in the air and i want them both in the safe rotation...
You can't have them in the same rotation
hmmm
no, when they are Fixed:1 you can put both of them in the same place
If that's the case in vanilla, I suppose you can try spawning two item frames next to one another and teleport one of them
how can I do that?
or try setFixed() in here just to double check
that's what I'm doing rn
but how can I teleport it?
ok thx x)
Can't guarantee that would work but that would be my only guess
from my experiments
they snap directly on the vanilla client so you can spawn them with a decimal offset iirc
you can also play with yaw/pitch to have weird issues
Yay weird issues
I feel attacked
it doesn't teleport :/
Hi i'm using PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER in 1.19.2 to remove a player from another player's tab but the player is not only being removed from the tab the player also becomes invisible in the game
Well, yeah. You're removing the player
seems like you're not using mojang maps?
Player#hidePlayer() does this by the way
but yeah, the player entity and the tab list is pretty much linked
almost 95% that requires slughorn in 1.8 can be done without slughorn in 1.19
wtf is slughorn
Iirc the tab list and entity are no longer linked
A slug with horns
no bro, tab and entity are not supposed to be linked
this is supossed to hide entities
Protocol
The network protocol now supports adding player entities to the world without being added to the 'tab' player list.
As of 1.19.3 ^
i just realized, that players become invisible to each other when they are teleported to another location
yep i'm using netty pipeline
is there a way to get the path to the world folder?
what info do you have about the world the name of the instance of the World?
you mean the world name?
I mean if you have the world name probably you can do smth like this new File(plugin.getDataFolder().getAbsoluthPath() + "/../../" + world.getName())
i doubt that the bukkit World have a method to return the folder
đ¤
Or if you want the folder of one world
You shouldnât hardcode it to your plugin folder as the world container can be changed
so what is the difference between Folder and Container?
is container the parent directory?
bump, it only happens when they get teleported to far distance, whe they teleport to a near distance this doesn't happens, any reason?
Container is the parent directory that holds all the world folders
and uh... i hate to ask but how do you import it? cause clearly i'm doing it wrong
cause all i can access are the Nested Classes says by the documenation
wait i think i'm being dumb
is it just <player>.getWorld().getWorldFolder()?
or is there like a globally main world object?
I don't think that's guaranteed, is it?
Technically no
But I canât think of any situation that the main world would not load first
i mean in ideaIC you can set a plugin to start before world loading
but most plugins like mine are set to load after world
Hey
I'm trying to make a indexer based on a percentage block
Example,
percentage is divided into 5 blocks. So the max for each percentage block is 20%.
I want to get the equivalent number for the block between 1 and max
https://paste.md-5.net/jasajisoda.java
Hey, I followed the online tutorial but there is a problem that it only registers new commands, not unregisters the old ones, does anyone know why?.
If the percentage is 0% return 1
If the percentage is 20% return max
If the percentage is 21% return 1
If the percentage is 40% return max
...
...
If the percentage is 80% return max
If the percentage is 90% return max / 2
If the percentage is 100% return max
Is this possible just with math or do I need to spam ifs...
Yeah whatever your input % is
Ohhhh
And then just put (value % max) + 1
In a normal min-max range number
int index = (int) ((percentage % max) / 100.0D * (max) + 1);
No way it's as simple as just int index = (value % max) + 1
plugins {
id 'java'
}
group = 'de.degurne'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
dependencies {
compileOnly "org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT"
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
plugins { id 'java' } group = 'de.degurne' version = '1.0-SNAPSHOT' repositories { mavenCentral() maven { name = "spigotmc-repo" url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/groups/public/" } } dependencies { compileOnly "org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT" } def targetJavaVersion = 17 java { def javaVersion = JavaVersion.toVersion(targetJavaVersion) sourceCompatibility = javaVersion targetCompatibility = javaVersion if (JavaVersion.current() < javaVersion) { toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) } } tasks.withType(JavaCompile).configureEach { if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { options.release = targetJavaVersion } } processResources { def props = [version: version] inputs.properties props
isn't the artifact id missing?
nvm it's gradle lmao
normal there
gradle ÂŻ_(ă)_/ÂŻ
@remote swallow does gradle allow you to set group id and version without any artiract id?
i doubt so?
what
where I addings that in pom? left or right?
Does integer division with return as float round to lowest int?
50 / 20 = 2.5 -> 2?
What do you mean return as float
Integer division always rounds down because itâs doing remainder division
Integer divide to get big number and then modulo to get remainder
Thatâs the idea at least
Ok the way that choco told me doesn't work
I'm trying to make a indexer based on a percentage block
Example,
percentage is divided into 5 blocks. So the max for each percentage block is 20%.
I want to get the equivalent number for the block between 1 and max
If the percentage is 0% return 1
If the percentage is 20% return max
If the percentage is 21% return 1
If the percentage is 40% return max
...
...
If the percentage is 80% return max
If the percentage is 90% return max / 2
If the percentage is 100% return max
the range of the return should be between 1 and max. example. 1 - 17
if percentage is 10% it should return 17/2
if the percentage is 20% it should return 17
If the percentage is 21% it should return 1
So on
better way of doing this?
@Override
public void load() {
JavaPlugin plugin = MobCore.getPlugin();
YamlConfiguration config = ConfigUtils.check(new File(plugin.getDataFolder(), "config.yml"), "config.yml");
/*
* Loading the config
*/
final String prefix = checkType(config.getString("prefix"));
final String noPermission = checkType(config.getString("no-permission"));
ConfigImpl.prefix = ColorUtils.colorizeHex(prefix);
ConfigImpl.noPermission = ColorUtils.colorizeHex(noPermission);
}
@Override
public <T> T checkType(T type) {
if (type == null)
throw new IllegalArgumentException("There was an issue loading config file!");
return type;
}```
i dont like bloat so
and the interface:
public interface Config {
/**
* Loading function for the config
* @return
*/
@Contract(pure = true)
void load();
/**
* Checks if the config contains a key
* @param key
* @return
*/
@Contract("null -> fail")
<T> T checkType(T type);
}```
Youâre misusing the IllegalArgumentException
i was just wondering if there was an easier way of doing this?
Yea DRY and KISS are 2 programming principles one should consider
I mean if you always want those config values to not be null, Iâd write another config class that extracts values from a FileConfiguration instance and asserts non-nullability eagerly
That makes it less âline-yâ on the spot but does stretch the systemâs amount of classes
i see
that method is not pure?
Oh that too ^
yeah đ
new asynchatformatter++++ annotation just dropped
Void methods are by definition never pure
wrong
Since itâd be no use calling them if they do not have a side effect
how?
When is a void method pure?
public void wrong() {// Pure}
heh
Yeah but thatâs pointless
:3
you are pointless
Rude
Life's like a road that Conclure travel on
When there's one day here and the next day gone
Sometimes Conclure bend,s sometimes you stand
Sometimes Conclure turn your back to the wind
you know
I replaced "you" with "Conclure"
đ§
Lol
lmao I really have nohting to do
Lol dw same, well maybe im pointless now
does getDataFolder() return like, the folder at ./plugins/MyPluginName/?
yea
ok cool
99% in cases it does
100%
99%..??
Does someone knows how can I change the InventoryHolder of an already existing inventory?
100
but some servers configure a different name or path than ./plugins/%plugin_name%
so then it can differ
but this is spigot
even if you could, why should you
which is why u always wna use getDataFolder and not sth else
ok cool thx
exactly, the API does what it's told to, whe're not paper
Easier Event Handling thatâs why
easier? by changing stuff? naah
paper is w e i r d
^
But it is actually gonna be easier for if I change the InventoryHolder because Iâll be able to recognize it more easily
Yeah, but I donât know where is the field located
Why?
Ngl reflection feels like cheating
because others might cast it to CraftInventory
Why someone would do it
it is
I love it
Reflection is made to cheat
^
Plus some other stuff obv
that's their issue. some people do it
the acutal question is - why do you wanna do that in the first place
inventories are Namespaced, aren't they?
Very strange because when I get all the declared fields I still donât see an InventoryHolder one
What class are you calling it on
Namespacing⌠what?
that is because getDeclaredFields() only returns the fields of THAT class
not of superclasses
I tried on the base class and the superclass
I know I know
iirc inventories iplements Keyed
I use reflection for custom enchants
That's about it lol
I use it for NBT data
nbt data scares me lmao
?stash
It is scary haha
It's just JSON with extra steps
I'll leave dealing with raw nbt to the fancy shmancy peeps
my bad, Inventories do NOT implement Keyed
i largely have a bad taste in my mouth because of NBT-API XD
?xy
Asking about your attempted solution rather than your actual problem
As I said itâll help me to check if the inventory is a custom one
This is why PDC was invented
đŽ
you can either store all the inventoryViews you create in a Set or sth, or use a custom InventoryHolder
this shall be looked up
?pdc
not suggested, but everyone does it although it's "not allowed"
but yeah, rather use a Set or whatever
"API interface with 1 easy to implement method"
"plugin developers: It's free real estate"
Yeah thatâs very true, but I use both xD
Disgusting
md, everyone's been using InventoyHolders since 10 years
it even only declares one method
but yes, dont do it
store the inventories you create in some kinda collection
that's the proper way ^
Ngl seeing all of you talk ab programming things I do not understand makes me want to start coding
What do you mean by that? When opening the inventory add the view to to a set and then check if the set contains the view from the event one
kinda, yes
Whyy? You can do some more things like that
not the view, just store the inv directly - not its view
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Yeah ik @frail gale is my irl friend and he tells me all about it lol
Yeah, Iâll try that, but why inventories didnât had NBT data
But again is there still a way to change the InventoryHolder of an existing inventory? Just for curiosity
n oidea who that is tbh
Maybe some nms way or reflection lol
only using reflection
Exactly what Iâm trying
Damn good idea, kinda would be good having that one
But the value could be stored also in an NMS class
get the field, set it accessible, change it, done
Can it update while in Inventory?
should <:
Messing with NMS is so fun sometimes haha
sure, but every other plugin will still use the "old" reference
why not? It's gonna look cool animating that one n shit
if they already caught any InventoryClickEvent or whatevever
I can only repeat myself:
?xy
Asking about your attempted solution rather than your actual problem
even md told you it's a shitty idea
the question doesnt make sense
an inventory holder represents something that holds an inventory
ie, a chest or mob
So you say itâs bad when creating inventories to change the holder to a custom one for checking if the inventory in the event is your custom one?
you cant just reassign a chest inventory to another random chest or mob in the world
Oh nvm I actually mean the title
yes
you should, if at all, create the inv with a custom invholder, in the first place
the title can be changed on creation, but can it be changed while in the inventory?
and you should not even do that, since InventoryHolder is a class that's not meant to be implemented by plugins
Hello, I'm looking for help on how to make an animated prefix using rgb colors, would anyone know please?
wdym with prefix?
Yeah thatâs what I do actually for my inventories, but I have an Anvil NMS one which seems not easy to change the holder
I have no idea, I'm talking about an animated prefix without textures, code to luckperms on prefix.0.
HAST DU ETWAS ZEIT FĂR MICH
still, ?xy
angry German noises
people think that the german language is funy
meanwhile english has words like "snorkel"
like wtf
snorkel wtf lmao
As a Bulgarian I agree
Moist
MoistBukkit when?
i mean
makes sense
buckets are usually moist
moist-y
moisty?
idk
fuck off

by now, you should've somehow realized what you're gonna do
Btw does this server help w fabric development bc I wanna do a fabric mod
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
just ask
TL;DR not many people here use fabric - but some do. you won'T get any answers if you don'T ask your specific question, though
Ok ty
ok so i need help with something. Let's say I make my plugin run an ingame command that returns text that gives a bunch of info on the player, and one of the infos is money: 1000 Is there a way to get this number? Ill give an example. Let's say I run a command from another plugin called /player <player> and it returns something like this in chat or console:
Player: <name>
Money: <value>
Time Played: <value>
etc...
I want to be able to get the money value by the return statement even if it's not in my plugin already
If I'm following correctly, you're wanting to parse info from the server log into a usable piece of data?
Oh no I was just asking if ppl help for fabric on this server
Probably an easier way to get the data than to read the console
exactly
i can't unfortunately cause it's not from a plugin it's from a mod (since we're using archlight) so the only way this will work is if i read the console
what about you just ask your question, and see if there someone who can help, instead of desperately asking for if you can ask something
Hey there. How can I loop thru inventory.addItem(new ItemStack(Material.CHEST,10)) list?
amount = (amount - overflowItem.getAmount()); invItem.setAmount(amount);
}```
oh it just returns the items that couldnt be added, i remember
yea that seems fine to me
Well, it always remove 1 item when it adds 64 items to my inventory
no idea
Like I multiplying items from my farming rod. That is not normal at all. 64 seeds = 512 seeds, need a fix
Use some debug messages to see what it's giving the overflow item and the amounts
I see, its the addItem(). The loop is not functioning right for this purpose
Removed ".values()" and got this error```
Can only iterate over an array or an instance of java.lang.Iterable
Error is pretty self explanatory
You can't iterate over something that doesn't implement Iterable interface
I know, I asked about this
What do you want to achieve
I just want to get the first overflow item of the addItem() so I can remove the amount from the inventory of my farming rod that went into my inventory
First ItemStack in addItem()?
I see what happened, I needed to clone the itemstack
Hey
If I want to allow a specific block to be broken
From blockBreakEvent
for (Block block : blocks) {
if (block == e.getBlock()) {
}}
Is it getState?
Otherwise as soon as I start mining technically it cahnges
don't compare objects with ==
Did you store it? It isn't guaranteed that spigot will return you the same block instance
Logs
[09:09:50 INFO]: Event block: CraftBlock{pos=BlockPosition{x=590, y=65, z=78},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=hat,note=7,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@7cb73050}
[09:09:50 INFO]:Block: CraftBlock{pos=BlockPosition{x=590, y=66, z=78},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=hat,note=24,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@7cb73050}
The note...
That is... lol
How should I compare them? To allow just the specific block to be broken
Location?
Why do you loop them instead of using contains tho?
But still
Well if it's the same instance your code should work. Does it get past the if?
I know something happens when a block starts getting broken
So idk if I need to to getState
Or what was it
I'm not sure what you're asking here. You want to loop over your array and then cancel the event if your block is the same as the broken block. Did you ask about the cancel event part or is it not going inside your if statement?
I'm just asking what's the correct way to check if the block being broken
Is a block in my block[]
Since I know blocks have states
And no, instances aren't the same
Well if you wanna be sure you could use locations.
Especially for noteblocks I suppose the state would change when someone right clicks it
Indeed
Testing rn
Worked like a charm
But for some reason, it's calling the event before the block is broken at all
Itâs generally a pain to implement restoration logic
Hmmm
What are you trying to achieve by doing it after it was broken?
Make it not spammable by starting to mine
But instead
I implemented a cooldown system
Listen to the BlockBreakEvent with Monitor priority
And see if the event was cancelled
It's not called before a block is fully broken
It is
No
Huh. No it's called the second (or tick to be exact) the block breaks (or would break, if cancelled)
We just talked about this. I tested it
It's called before the block is removed from the world
But not before the player has fully broken it
Not what I just tested
Are you sure you are using the BlockBreakEvent and not the interact event? The block break event doesn't get fired by left-clicking a block but not breaking it
Conclure missunderstood what you were saying. He said the same thing that I just said
It's called after a player has broken a block but before it's removed from the world
I guess he misunderstood. He meant to say that the internal logic is something like
onBlockBreak {
event = callEvent(block);
if(!event.isCancelled) {
removeBlock(block);
}
}
^^
Obviously in creative it will trigger instantly on left click
Well yeah
I would go into a deeper dive with you but I don't know your code, neither the way you tested
Hello ! I'll make a Jobs plugin and today i program the datasave part but i got some errors and i don't know how to solve them ^^ Somebody can help me ? I speak french sorry for my bad english đ
How can i join a file
or the error code
?
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
No it doesn't. It kept recommending me to use the ?? operator in java (which is only available in c#). Even after asking it whether it's available it said "yes"
ChatGPT will always say that it is right and never makes mistakes
That being said if you call it out it will come forward with a preprogrammed response
Well this time it didn't at my first attempt lol
AI is like the dumbest thing ever
Instead it decided randomly that it was added in java 14
Could be. But yeah that shows it can't code, unless you can verify what it did - don't trust it
wdym?
for the server
there's thousands of plugins
like the ip to this serer
I really don't know what you're asking for. The invitation link to this discord server?
yea thanks
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Dev problem
Default args, coroutines, higher order functions without funct interface
Operator overloading
why World.Environment.getId() is deprecated?
what it means?
It means the id is just a meaningless number and shouldnât really be used for anything
A "magic value" is a string or number used in a program that is essential to its proper function but provides no context or explanation for why it is what it is.
modded dimensions?
?jd-s
Modded how?
i mean dimensions that mods adds
Spigot does not support mods.
Cries in janky hybrids
?basics
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
How do I send an Action Bar title to a player?
`player.sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("String"));`
doesnt work anymore with 1.19.4
how to use NMS on maven on 1.19.4? I dont want to use gradle
?nms
where did you copy this from?
it's Player.Spigot#sendMessage(...)
player.spigot().sendMessage(...)
np
Need someone with bytecode manipulation experience.
Given the following example method:
public boolean check(String variable) {
if("Example".equals(variable)) {
return true;
}
return false;
}
My goal is to change the anonymous variable "Example" to something else.
What would be the an appropriate tool do this? Ive tried using ByteBuddy but i fked up
the class beyond repair on runtime.
Do you want to modify at runtime?
I'd probably use something to hold all those slots. Be it a different class, a map, an array of pairs - your choice. Just not that many parameters
Yes ofc. Changing some classes in a jar is not something i would fail on.
I need runtime manipulation
do you wanna replace any "specific" string?
or all occurances of that
Why do you have to hand them over as single elements then?
r u the one running the jvm instance?
if you wanna replace all occurenes of that string, check out this source code https://github.com/JEFF-Media-GbR/JarStringReplacer
There is only one occurrence of this this String
Yes
I never registered a custom recipe but if that's a function that you created and not an internal one, you should swap from 9 times itemstack as a parameter to a list or array or whatever you prefer
how are you adding the glow effect?
yes that looks cleaner
from what I know, it requires an enchantment
Is there even a ClassNode representation of a class which was already
loaded by the classloader?
you have to enchant it then hide the enchatments
is it possible to get the world seed in the getDefaultWorldGenerator function? When I do getWorld(worldName) it says the result is null. I'm not sure what else I could do.
you got the WorldInfo object
How do you hide enchantments? o.o
I think so?
why would it not be there
addItemFlag(ItemFlag.HIDE_ENCHANT) iirc
yes
Whomst dared to ping me?
oh cool, didn't know that
I did
I need a bytecode helper
7smile wants to replace some strings in a .jar
he also wants to cuddle with you
#yeshomo
my bad, I'll go there instead
No. There are a few workarounds but none of these workarounds are guanteed to work in all scenarios
oh wait, you don't have the .jar, but wanna replace things in already loaded classes, now I understand what you're trying to do
To my understanding i can use instrumentations to intercept method invocations
usually you can just construct a "same" string, then just change the char array
With ASM you can replace the LdcInsnNode constant
the better question is, why do you even need that
For a totally harmless gimmick

i.e.
for (AbstractInsnNode insn = method.instructions.getFirst(); insn != null; insn = insn.getNext()) {
if (insn.getOpode() != Opcodes.LDC) {
continue;
}
LdcInsnNode ldcInsn = (LdcInsnNode) insn;
if (!ldcInsn.cst.equals("example")) {
continue;
}
ldcInsn.cst = "Replaced constant";
}
then write the file back
For such a change I recommend to not recompute frames and maxs and make the class reader read debug info
but I thought they wanted to change stuff in "loaded" classes, not just change the .jar file
Ok im not sure how a "file" looks like during runtime.
Changing a class inside a jar which was already loaded seems kind of pointless to me.
For a already loaded class you need to register javaagents
HOWEVER if the class is loaded by the bukkit plugin classloader you can use an approach similar to https://github.com/Geolykt/EnchantmentsPlus/blob/4xx/src/main/java/de/geolykt/enchantments_plus/compatibility/hackloader/Hackloader.java
I think you might be able to register javaagents at runtime via dynamic agents but there is JEP 8306275 that plans to remove them
I can start one via jvm params
how do you get the WorldInfo object? The first time I see it being used is when it's passed to generateSurface for the first time
Well if you have that option it is the best ofc
If you have the option it is adviseable to use the jetbrains runtime
It implements DCEVM and thus has the -XX:+AllowEnhancedClassRedefinition option that allows improved class redefinition capabilities
Let me check that out. Im starting the jvm through my IDE anyways.
it gets passed into the generateWhatever method
or are you on 1.8 or sth?
if I was you, I'd just use my RecipeUtils class to load recipes from configs https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/RecipeUtils.java
Is there a builtin option for the JBR in intellij or do i need to download it from their github?
no, 1.19. But I'm saying I want the world seed ahead of time to I can create my noise generators ahead of time so I don't have to keep reconstructing them
WorldInfo#getSeed()
the WorldInfo object gets passed into every world generation method
I know but I want the worldinfo in the constructor of the chunkgenerator
or just the seed, I don't need the world info even
Hey,
is it possible to create a new world in which the bioms are smaller?
with a custom chunk provider thingy, sure
ah I see. i dont know if that's possible. why do you need it? wouldn't it be enough to just save that worldinfo / seed in a field, once the first actual method gets called?
Is there mabye a doc to this method?
wdym? no, it's just there to load recipes from a yml file, so people can declare custom recipes, etc
what are you trying to do @quaint mantle ?
that's what I was doing before, but I started using the noise generators from the ChunkGenerator in my BlockPopulator so that I could generate terrain and structures that matched each other
and because the block populator is only constructed once, I can't really retroactively change the fields very easily unless I use a bunch of hacky static fields
is it possible to grab the "seed" setting from server.properties?
It should be the default JDK under IntelliJ
For newer JDK versions that is.
For JDK 8 it probably isn't available but in that case TravaOpenJDK might work but I doubt they list it there given that that project is dead
in theory yes, but IIRC it's only there for the default world
but ofc you could just "reuse" it for your world
you could ofc also just generate a random seed, then store it in your custom world's spawn chunk's PDC
Also note that paper might allow the option to use different seeds
Since there are 7 or so seeds in total iirc
However I am not too sure whether it is paper or another fork that allowed to change the seeds individually
Just trying to figure out which startup params i need for my run configuration to start
the agent. Usually -javaagent:agent.jar is appended to define an agent. But in this
case im a bit lost on where to the the IJ agent from.
Should be added as a jvm option
can't you just use maven lol
so I guess the upper field?
||that is a Application run config|| disregard my stupidity
You can use <section>.getKeys(false)
Recursive
If you want to get all the children keys too
If I had to guess? Hell no
you normally want to handle each config section seperately
here, ```yaml
key:
key2:
key3: true
key4:
key5: true
key6:
key7: true
always corner of a Block
middle is +0.5 on each x, y and z
+0.5 to all axis to get the center
kinda
after destroying block, block continues working. The breaking event passes, and if you repeat it, it gives an error
"furnace" is null
your stacktrace doesnt match the code you've given
oh wait
or furnace.getInventory() is null
what even is "furnace"?
a spigot blockstate furnace?
custom block
and what does getInventory() return? null?
but when the block breaks, it is removed from the data. then why does this occur? Furnace must be null, and then there will be no error.
I delete Furnace itself, so the inventory in it should go with it.
furnace is not null, furnace.getInventory() is null
a block.getType() will never be null
Hello everyone, how can I hide the health bar of the horse I'm sitting on?
Press Left shift
is there a way to change the messages from acf? It says to enter one of (1,2,3,4,5,6...) but i want it to say "between 1 and ...")
in custom command completion contexts
i want it to say "Please specify a number between x and y"
cuz the list may get too long
There probably is
i cant find anything on the wiki
jordan6131 â Today at 2:33 AM
ok so i need help with something. Let's say I make my plugin run an ingame command that returns text that gives a bunch of info on the player, and one of the infos is money: 1000 Is there a way to get this number? Ill give an example. Let's say I run a command from another plugin called /player <player> and it returns something like this in chat or console:
Player: <name>
Money: <value>
Time Played: <value>
etc...
I want to be able to get the money value by the return statement even if it's not in my plugin already. Essentially I want to parse info from the server log into a usable piece of data
whatever plugin is providing that data likely has an API
What have you done sofar?
The million dollar question is: what plugin and what command from said plugin.
it's not a plugin that's why lol
not a plugin
nothing xD I don't know where to start
In this episode, I give you a brief overview of what you can expect in this MC Plugin coding series. #Spigot #MCPlugins #PluginTutorial
Java Tutorial: https://www.youtube.com/playlist?list=PLfu_Bpi_zcDPNy6qznvbkGZi7eP_0EL77
How to Setup a Test Server: https://www.youtube.com/watch?v=58MZ4THF73g&ab_channel=KodySimpson
Discord: https://rebrand.l...
You literally say in your message "let's say I run a command from another plugin"
that was an example
to make what im asking for help with more clear
the first sentence doesn't say that
@indigo frost the link i provided should be very helpfull
my guys that's an introduction, I know how to make a plugin already
lol
Your best bet is that another plugin is providing api, parsing data that yo don't know what would look like is bad idea
it's not a plugin
What is it
it's cause it's a mod
???
that's what makes it tricky
Lmfao
so I want to parse from the console log
No you don't
What mod?
mine mine no mi
Also don't know if it's possible to get result of command event, there always might be another message between you executing cmd and message appearing
So it would be pure guess
he maybe could read the log
No bad 
There always might be some random message between
How about instead of trying to read the logs or whatever nonsense realize that the data has to be written to somewhere (probably the players NBT) and you can just read it yourself without needing the log


I think it is in the player's nbt data actually
you can pass in an int to a place where it expects a double you know
i didn't even think of that

ur a genius ty
ItemMeta meta = item.getItemMeta();
meta.addEnchant(enchantment, level, true);
List<String> lore;
if(meta.hasLore()) {
Logger.log("ma");
lore = meta.getLore();
} else {
Logger.log("nie ma");
lore = new ArrayList<>();
}
lore.add(TextFormatter.color("&7".concat(loreDisplay)));
meta.setLore(lore);
item.setItemMeta(meta);
}
```
why my lore is null even when it has some lines?
But can I put a player on the armor rack and make it so that hp isn't visible?
How would I write a comment for a CraftBukkit contribution that fixes a decompile and changes the access level of a field from private to public?
Currently I only have // CraftBukkit - decompile error there so instead should I use something like this: // CraftBukkit - decompile error / PAIL private -> public
Or how should I comment on that?
I'm impressed with them being able to generate a heapdump of that size
is that 1.8GB of cfs lol
its 16gb lol
what would be the best way to handle saving itemstacks in config file?
yml , json, sql??
also confusing question
geol would probably just make a binary file and throw them in
some people use base64, theres no best way
Im doing anty-logout plugin and i use BukkitRunnable to do a timer from 30 to 0, but i don't know how to cancel the Runnable from another class when player leaves or punches another player again or something. How am i even supposted to do it
i never used BukkitRunnable before
Hello there, can I put a player on the armor rack and make it so that hp isn't visible?
hello, any ideas why armorstand-tps are so laggy?
Don't need to use a runnable per player. Rather, you can just make a runnable per 20 ticks or so. Then, whenever a player is hit you add them to a hashmap with a long for current time + combat time. Then you can check the time stored < current time to know if it has expired.
but i want to display the seconds left
Tf 16gb object
every 20 ticks (1s) you can update all players.
Again, using a HashMap
?
wait
Every second you iterate through all the players, if they are within the HashMap you update w/e (scoreboard, message, etc).
You can schedule a bunch of runnables but that's 30 runnables/player
that you'd have to cancel
if 1 player gets antylogout, and then 0.5 after some another player gets antylogout arent they gonna end their antylogoout at the exact same time?
because they get it in the same second
No? The runnable runs forever and all it does is checks their time in the map
How can i add a Worldborder to a world?
/worldborder no plugin required
But i want that the plugin sets the worldborder for a minigame..
i mean that player doesnt end his antylogout in exact 30 seconds but 30 runnables later
if i understand
Create world border using createWorldBorder method
Sure, it's not 100% accurate. If you want that run it every tick and it'll be better.
Or get worldborder object using getWorldBorder method
but isnt it gonna be laggy?
World class
Compared to having hundreds if not thousands of runnables constantly queuing/de-queuing?
1/20ticks compared to 1/1ticks
I mean you can do some mock tests. Just run it on the same player 100 times/t. Emulate it with fake data
most servers start to degrade around 200-300 players. So test it with that
50ms
It's how the entire game operates. Everything occurs at 50ms intervals
dam I wish there was a video like that then i started out developing plugins
it seems very helpful with how he is informing people to know java and certain aspect of java
oh
why is there no boolean persistent data type?
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
yeah but couldn't hurt to have a native PDC type I guess
I talked to choco about it a few months ago
?paste
What did chocolate say
the crack cocaine smoker said that a boolean data type would be fine to add
then I said I'll pull request it and then I never did
I also wanted to pull request maps, collections etc, but people told me it wouldnt get merged anyway
so I instead bugged conclure to add ?morepdc instead
and here it is
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
idk why this does not work (it should but its not.)
so i made a Storage system for players (Insted of normal EnderChest and only 27 slot , now there are 5 (can add more) types of storage)
so what a player can do is click on the one he have permission to access and add the items there
but here is the problem it does not save it
no erros and the class with the close event is registered.
and the file is created :
Do they get all saved as null or do they get saved correctly
all as null ..
Instead of going through each slot, loop through inventory.getStorageContents()
hmm?
That's the first tip
alright
I am trying to create a new world, but the server keeps crashing.
Here is the code:
WorldCreator wc = new WorldCreator("BingoWorld" + worldNumber); wc.environment(World.Environment.NORMAL); wc.type(WorldType.NORMAL); world = wc.createWorld(); assert world != null; WorldBorder wb = world.getWorldBorder(); wb.setCenter(0,0); wb.setSize(2000);
Here is the error:
https://hastebin.com/share/jofokuzula.makefile
I would be thankful if somebody could help me.
cuz its done sync
ideas?
pretty sure that's just delay between server and client?
Hi, I have coded some plugin in 1.16 and lower with eclipse, but today i'm trying to code a plugin in 1.19.4 with eclipse but I failed to import org.bukkit.java.JavaPlugin can somebody know why i get The package org.bukkit is not accessible ?
I mean it looks pretty ugly and is not normal
use maven or gradle and now you need to depend on a different jar without
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
so i c'ant continue on eclipse ?
you can, you just have to depend on a different jar
ho ok, and how can i use gradle on eclipse ? đ
@young knoll how do peopole gradle on eclipse
Just like any IDE
You don't really need an IDE at all to use Gradle
ok, i'll try to solve that ty and see you later
For kotlin gradle: We don't.
Using kotlin gradle as a build tool of yours is the best way to get rid of me
It probably is a lot nicer to groovy (especially decompiled groovy-compiled buildscripts are instant death), but eclipse doesn't recognise kotlin buildscripts
I guess we could use the gradle eclipse plugin but I think they got rid of it
use maven.
unfortunately maven is rather lackluster for more specialised tasks
In witch cases is more optimal to use CompletableFeature in MySQL?
anytime you query or update the database
But, is this what i should do for void methods?
return CompletableFuture.supplyAsync(() -> {
try (PreparedStatement statement = getConnection().prepareStatement("UPDATE " + SUBWAYDATA_TABLE + " SET subwayEnterButtonLoc = ? WHERE subwayName = ?")) {
statement.setString(1, BasicFunctions.locationToString(location));
statement.setString(2, subWay.getName());
return statement.executeUpdate();
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}, MetroSubway.getInstance().getCustomLoader().getDatabaseExecutor());
}```
And when i call it is correct to do this
if (throwable != null) throwable.printStackTrace();
}).thenAccept(integer -> {
MetroSubWayData.reloadSubWayInCache(StationCreateCommand.getStationCreator().get(player.getUniqueId()).getName(), StationCreateCommand.getStationCreator().get(player.getUniqueId()));
});```
idk why you have a whenComplete then a thenAccept
handle both in the whenComplete
Its correct like this?
public CompletableFuture<Void> setSubWayEnterButtonLoc(SubWay subWay, Location location) {
return CompletableFuture.supplyAsync(() -> {
try (PreparedStatement statement = getConnection().prepareStatement("UPDATE " + SUBWAYDATA_TABLE + " SET subwayEnterButtonLoc = ? WHERE subwayName = ?")) {
statement.setString(1, BasicFunctions.locationToString(location));
statement.setString(2, subWay.getName());
statement.executeUpdate();
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
return null;
}, MetroSubway.getInstance().getCustomLoader().getDatabaseExecutor());```
This should fix problems like the server crashing if i do something to quickly?
if its async the server shouldnt crash
Hi, I'm looking at developing a boss plugin, is anyone able to suggest a few open source boss plugins or plugins with custom enemies that are well made which I can look at for inspiration. I wanna see particular uses, like where developers have given mobs or bosses particular attacks that are unique, and uses of particle effects.
Use jooq or any type safe sql query generators
public void saveElection() {
try {
// Serialize election ArrayList to JSON
String electionJson = gson.toJson(election);
// Write the JSON to file
Writer writer = Files.newBufferedWriter(electionFile);
writer.write(electionJson);
writer.close();
} catch (IOException e) {
// Log the exception
logger.warning("Error saving election: " + e.getMessage());
e.printStackTrace();
}
}
Error: Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @30e85cb1
Tryed updating java
Show that election class
?paste it
Should i use CompletableFeature for INSERT to?
Never run SQL on the main thread
anything that interacts with the db should get a async future
Or any web requests
For INSERT I'd not use CF if possible
Need the election class
elaborate
At best a non-blocking void method should be used but chances are it is going to use a CF under the hood
package Me.Sebbe.President.Commands;
import java.util.ArrayList;
import java.util.List;
public class Election {
private List<String> players = new ArrayList<>();
public List<String> getPlayers() {
return players;
}
public void addPlayer(String player) {
players.add(player);
}
public void removePlayer(String player) {
players.remove(player);
}
}
It's not going to work
i use a cf for inserts to just notify the user the operation succeeded
You'll need to serialize the players on your own
shudders
For example store their uuids
removing a string player hmm
So all this error are caused because it is runned on the main thread https://pastebin.com/0a1B00jy
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Don't store the entire player
sqlite rolling in it's grave
So insted of cheking for name I should check for there uuid?
Yeah
correct
request timed out after 30003ms đ
But how should i fix this https://pastebin.com/dcyG45Rh
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
are you properly returning your sql connections to the pool ?
e.g. closing them after using them
are you not using hikari or similar?
The completablefeature should close them. Do you mean statement.close() right?
Im using hikari
not statement, the connection
No?
you have to close a connection you grab from the hikari pool
that is what releases them back into the pool
you do?
yes
if you keep using futures for everything, you don't have to worry
(well unless you need that data "right now", ofc lol)
What should i do to close them?
hello when i connect the hub to proxy chat ''goes off'' when its not connected it works someone knows how to fix?
id abstract the futures away from the actual impl but whatever nobody listens anyway
looks ok to me
How should I fix it so it gets stored in the json?
Right now when I try to save nothing happens, it dosent get saved or anything
https://paste.md-5.net/dihuvecozo.java
Sorry, still pretty new to this
But it is a good idea to save a list has id1,id2,id3 in a database to after split it and put in a List?
If its valuable data like player coins.
No nothing like that
you don't want to be splitting data in your DB
that kinda goes against the concept of having a proper DB
How should I fix that?
:)? its bungee 100% cuz it works with bungee off
Hello. Where I can find bukkit libs?
what is bro writing
write in google Spigot API
and click first link
Is the Spigot API now a Bukkit API?
The spigot API contains the Bukkit API
im scared what mfnalex is writing..
Is there a clean Bukkit somewhere?
I'm sure at your local Home Depot
How should I fix it so it gets stored in the json?
Right now when I try to save nothing happens, it dosent get saved or anything
https://paste.md-5.net/dihuvecozo.java
Personally I'd use sqlite. I find it to be a lot nicer than having one giant file
I get that
hello when i connect the hub to proxy chat ''goes off'' when its not connected it works someone knows how to fix?
its bungee 100% cuz it works with bungee off
This is a normal question, I just need a clean Bukkit, without spigot, paper, etc.
uhh
Why?
An unofficial explanation of the DMCA can be found here: https://www.spigotmc.org/wiki/unofficial-explanation-about-the-dmca/
Provide bukkit into my forge mod
you most likely cant do that without serverside access
Any problems? I already did it on 1.7.10 and 1.12.2, now I'm only stopped by the lack of pure Bukkit on 1.16
Anyone know why the data isn't getting stored in the json file?
https://paste.md-5.net/dihuvecozo.java
its all on stash now
I know for the server and I do so that mods can be compatible with the same WorldGuard
mans got no idea
static {
Method getBukkitEntityMethod = null;
try {
getBukkitEntityMethod = Entity.class.getDeclaredMethod("getBukkitEntity", (Class<?>[])new Class[0]);
getBukkitEntityMethod.setAccessible(true);
}
catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
getBukkitEntity = getBukkitEntityMethod;
}```
```java
@Nonnull
public static org.bukkit.entity.Entity getEntity(@Nonnull final Entity entity) {
try {
return Objects.requireNonNull(BukkitUtils.getBukkitEntity.invoke(entity, new Object[0]), "Entity.getBukkitEntity() result must not be null");
}
catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}```
U can use reflection to convert Forge entity to Bukkit entity. That function from CraftBukkit. Nothing limits you to call bukkit events in the same WorldGuard, if you need to make compatibility with it
Questions?
Also there is no "clean" bukkit anymore
I don't need any additional library to call reflection
On the ForgeBukkit Server that method is available
That bukkit died alongside with the bukkit project and is a relic of a past long bygone. While spigot continued to ship them until 1.16 or something I wouldn't use it in the first place.
The next best thing is the spigot-api
Uh is that your project or another
No, but I am the technical administrator of the project
itemFrame.teleport() does not work
Problem with creating unique ItemStacks. I'm trying to create a backpack system but I can't figure out how to get the ItemStack unique every time. Can anyone please help?
https://paste.md-5.net/ekavecuxiy.cs
Do you at least know why you are using Reflection
Because chances are a checkcast works just as well
I don't integrate it into the core. Its modification
The modification just allows you to use the full Bukkit from Forge
I'd still do it as a coremod
Sure, perhaps not full MCP style like other projects do it - but also not as a plain mod
All the mixins
@Override
public boolean cantBreak(@Nonnull PlayerEntity player, @Nonnull BlockPos pos) {
Player bukkitPlayer = BukkitUtils.getPlayer(player);
Block block = bukkitPlayer.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
BlockBreakEvent event = new BlockBreakEvent(block, bukkitPlayer);
Bukkit.getPluginManager().callEvent(event);
return event.isCancelled();
}```Usage example for WorldGuard (or other) compatibility. If some mod can break blocks in region - this method will help
That reminds me: Have fun with the material enum!
I'd just implement the bukkit interfaces and redo all the logic myself honestly
That might have side effects...
Yes, it is possible, but practice has not yet shown any problems
That code is just a bad idea
It's fine if you know how every installed plugin works
but if you don't then don't use that code
We have been creating servers for over ten years, we know where we are going
I`m not trying to be aggressive, discussion in similar topics is normal
can I have an answer?
?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.
i2.setItem(new ItemStack(Material.STONE));
i2.teleport(new Location(i2.getWorld(), 0, 0, 0));```
I have an API I'm providing multiple database support to, however it seems Class#forName is a bad way to load them this is my structure I say Class#forName is bad because of the easy possibility of injection. If its not a huge deal I suppose I could throw caution to the wind and just go with my current setup
Raven
|-> api
|-> core
|-> database-providers
|-> MongoDB
|-> MySQL
Each database-provider has an entry class
Hwoev
hwoey
You shouldnât need to inject anything
meant an attacker could inject malicious code much easier
tbf though it is java you can inject code anywhere
so probably not a huge deal
he y how do ifix chat off in the hub?
I already told you its likely a plugin interfering bungee doesn't natively fuck with your chat like that
if it still occurs with all plugins gone make a report on the jira
buddy
i tryed with no plugins on
make a report ig idk
because both would need no plugins to verify its actually a spigot/bungee issue
yes
all servers work exept the hub
both hub and bungee had 0 plugins? and chat was broken?
if so make a report
?jira
ooh wait 1min the hub ye proxy no ill try
if it aint work ig ill make it
