#help-development
1 messages · Page 452 of 1
stands for function
lol
.itemMeta?.lore ?
ohh makes sense
kotlin
kotlin is a very funny language
xD
Yea, this is why we always shove the entire class when showing code ✨
Meh, makes sense to me
and also a piece of shit qua syntax (dont shout at me)
this and the code we tried
lesson absorbed
So simple solution: Dont call functions on objects which are null or you will get a null pointer.
but how can i check if there is this string in the lore
The lore is a list. You can just call contains(String) on it
map is one way
is there a tag for items that need silk touch to braek
My armor stand is rotating weirdly what is wrong? I want the armor stand to always be 2 blocks to the right and 1 behind the player.
https://paste.md-5.net/winisoxoci.cs
it's funny, because i literally did that and we got the error
Yes, because you are calling contains() on a null object
My guy we're going in circles
because bungee plugins have no notion of disabled/enabled
I talked about this yesterday with someone
Let me see
can you just snip the circle and tell me the solution
Here
Do. Not. Call. Functions. On. Null. Objects.
Check if its null or use the ?. operator with map.reduce
plushTeddy, if a variable can point to null, then that needs to be handled
can BossBar be used as key in hashmaps? does it implement equals and hashcode?
Conclure literally showed you the map.reduce solution
Or a method returns null
Well you’d use it as an identity key I think more like?
you mean that:
(event.currentItem.itemMeta.lore?.contains("Type: NPC") == true)
Let me guess, if a plugin fails or is disabled, it doesn't shows on ProxyServer.getInstance().getPluginManager().getPlugins() collection, right?
not awesome, but amazing
Lol ye
Yes that may work also
?tas
BUT IT DOESNT
(:
I would even do more checks because there is more that could be null
i am using it as key itself, the value is a resourcebundle, the map is for setting a different title for the single player in each bossbar
xD
if(event.currentItem?.itemMeta?.lore?.contains("Type: NPC")) {
Oh kotlin
bros gots stuck on a null error
I have a question how to change the nametag above the player's head
Packets (NMS)
Type mismatch
Type mismatch: inferred type is Boolean? but Boolean was expected
Add !! at the end
Wait no.
What was the default operator for nullables
Something ?! false
Alright anyway, it does not implement equals and hashcode
i heavily recommend you to use the NTE (NametagEdit) API if you aren't familiarized with NMS yet, take a learn before trying
intelij adds == true at the end of the if statement
Goofy intellij
if(event.currentItem?.itemMeta?.lore?.contains("Type: NPC") ?: false) {
This one
Ok, is there a way to check if every plugins is enabled on a bungee server? since there's no isEnabled?
no
yea 
as i thought 🥲 thnks
error
Plugins either exist on a bungee server meaning they were loaded and enabled successfully
Show
Or they get defenestrated out of existence
lol
bro used a hard wordxD
😅
show code
class NpcSelectMapInvClick: Listener {
@EventHandler
fun onInventoryClick(event: InventoryClickEvent) {
if(event.currentItem?.itemMeta?.lore?.contains("Type: NPC") ?: false) {
event.isCancelled = true
event.whoClicked
val clickedItem = event.currentItem ?: return
val player = event.whoClicked as? Player ?: return
when (clickedItem.type) {
Material.STONE_BUTTON -> {
val worldName = "Npc1_${event.whoClicked.name}"
gworld("NpcTemplate1").clone(worldName)
val spawnLocation = Bukkit.getWorld(worldName).spawnLocation
player.teleport(spawnLocation)
}
else -> { return }
}
}
}
}```
maybe the default implementation of hashCode at Object class is enough ._.
oh no
Yeah
Rest of exception pls
But if you use that you might also go with IdentityHashMap
To reduce unnecessary method calls
oh ok
sorry
at net.teammlg.clutches.inventories.npc.BlockSelectMapInvClick.onInventoryClick(BlockSelectMapInv.kt:36) ~[?:?]
[07.04 22:31:42.587] INFO: [Lobby-1] at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
[07.04 22:31:42.587] INFO: [Lobby-1] at java.lang.reflect.Method.invoke(Method.java:578) ~[?:?]
[07.04 22:31:42.587] INFO: [Lobby-1] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-21fe707-741a1bd]
[07.04 22:31:42.587] INFO: [Lobby-1] ... 15 more
Conclure, is there a way to get noticed when the bungee server starts to listening? (fully enabled)
Listening to what exactly?
Which line is BlockSelectMapInv line 36
i wanna to perform a method before the Listening on /0.0.0.0:25565
sadly yes
Wait i just noticed. You are sending us an exception for a completely different class.

i think we should ignore everything, because it would be to embarrassing for me
it's a copy of the old code ._.

xddddddddddddddd
Lol pain
Anyways... You could try reading the plugin list and doing some iteration shenanigans in a different thread until all plugins are loaded.
You might need to do some unorthodox things to achieve this.
Idk when permissions are called
But you could listen to the first permission event that gets fired
Very hack workaround tho
yeah, i tried to do the different thread one, but since it's not possible to check if a plugin is enabled or not, i cannot xD
i forgot what does char + char do? does it concat into a string or add the values
arithmetic operation
yeah so? str + any = str
but i guess youre saying the latter?
it adds the backing values
yeah
aight
why tf is a short the only type a char cant implicitly cast to
oh maybe because its signed
Looks very similar to the Number class btw
yeah dont want to box twice though
sorry to bother your but can you help me with the first option please
Sure.
- Load the chunk
- Find the entity
- Remove it
and how would I find the entity if the entities arent loaded yet
Use the entity load event
Oh right, the entities are now loaded separately.
Then you need to use the entity load event and register a callback for it.
Doesn getEntities or whatever trigger a blocking load
Never tried it out. Lets take a look at what CraftChunk does there
Hm no indication for loading the entities if they dont exist. There is a null check which just returns an empty array.
a short is a char
in terms of size yeah
but char is unsigned
you can specify a permission in your plugin.yml
if (!sender.hasPermission("a.b.c")) {
sender.sendMessage(ChatColor.RED + "No permission");
return false;
}
how are you creating your commands?
dynamically or through plugin.yml
shit i meant plugin.yml here
yeah how you doing it rn
cuz a char is an int
what
nah im pretty sure its same size as a short
but i guess since a short is signed it cant account for all values
so it cant be implicitly casted
didnt know a char was 16 bit lmao
I decided to learn how to actually use influxdb, this shit's cool
yeah its 2 bytes
but in the jvm everything is 32 bit basically
as locals yeah
on the stack everything is 64 bit i think
on the heap its compacter
but that is grafana :>
heap is a mess id say
Showing a graphana board named "MongoDB"
Much influx, very logging
bruh
lmfao
I use influx to store the data that's being visualized in grafana
the data just happens to be about how long my mongodb shit takes to run
No joke but we also had a meeting about using graphana and which DB we should use to
back the data. I found influx and prometheus really shit
So we just went with Postgres
u use influx 3.0 @echo basalt ?
I only prefer influx over prometheus
because influx is like "push-as-you-go" while prometheus makes a request every 10 seconds
Dont you have to write some weird string based queries for influx? I remember disliking the query syntax
so for locals you have one slot by default but 2 for long and double, 4 bytes/slot
on the stack everything must be at least 8 bytes as each entry can supposedly store a long
i assume that everything is sized as compact as possible on the heap (byte and bool being one byte) otherwise memory usage would be high as fuck
thats 3.0 indeed
did not like that either
I write it but only once
their api is funky
but I like abstracting things away
no
they are in the stack frame local area
Hm i just found the influxdb-java driver.
Doesnt look too bad honestly
eh
hmm
when i did it i did it like this https://paste.md-5.net/woyowixeta.java
I guess its time for a second meeting
also isnt the java heap weird as fuck with different areas
nah this shit
ah ye
Eden Space:When we create an object, the memory will be allocated from the Eden Space.
oo
Oh yeah you need to tune the jvm parameters so that big objects dont get transferred to the wrong heap space.
I remember that when i dissected aikars flags
i only remember that my raspberry pi nearly began to smoke when i used aikars flags
im guessing you have some kind of system setup to easily upload your data, care to share?
it's all built into my mongodb abstraction
lmao
wont that stop u from making uploading other stuff in the future?
well
8 gigs for the win
say u wanted to visualize player steps suddenly
it's just a TimeProfiler class that runs a lambda and profiles it
ah
but yeah for visualizing that
think i did about that same
I just make that timeprofiler
and then call .finish(TimeUnit.MS)
or something
because it profiles... time
or I can just make it write a "1" and set the graph mode to sum()
instead of average
ah it has to do with gc or smth
JVM developers smart as fuck
I hope you batch or average them and dont send them on every DB action
young space exists so the JVM can sweep temporary, quickly unused objects, like the event objects when an event is called in bukkit, fast
i used to do it like this https://paste.md-5.net/teveqalaku.java
pretty long time ago
anyways, gn
influx's driver can do auto batching
Is JRockit still a thing?
will this then only send when the batch has reached 1k entries?
we have a lil problem
flush interval
it flushes every second or until it reaches 1000
every second?, isnt that still a little quick?
only when it has data
i used to send every 10 seconds
well u can specify the data collection time
tehre's a builder if you want to fine tune the numbers
perhap
yea, loop over the blocks and delete em
And if I need to do that to thousands of chunks?
then you'll need to be smart about it
use nms
put air as a block in the palette
block 0
int[] v = new int[16 * 16 * 16];
for each chunk section:
System.arraycopy(...)
idk if its an int
?workdistro and this can be of some great use as well with this kind of stuff.
work distribution is what screwed up my world gen in the first place
then you probably did it improperly
what do you mean by the first thing?
I dont think thats possible
it is
well if you delete all region files
minecraft will just regenerate all chunks
dont even have to bro you can just stop the server, delete world files and start
It's not perfect
Worldedit makes a copy of the world and generates the chunk there
Then copies it over
ah well, dont know much about it other than its existance
Which is also why the regenerate chunk method is deprecated
Hm interessting it might be better than the api then
What have you made
World where generic types not exists
each thing needs diff behavior
flat packages view is clean asf tho
no need to horizontally scroll or look at ugly file structures
For context, I'm trying to create these sections of land because they are cool. It generates them with a normal chunk generator, then switches to a void generator when players can join the world, so that the chunks surrounding it are void. When the plugin generates these in a single tick, it works. When I use work distribution, two things happen. 2 extra chunks around the chunks I select get generated. TWO! And, the outermost chunk doesn't get decoration.
oh my days
well if you generate them before anyone is actually playing, whats the point of avoiding lagg by using workload distribution
The correct way to do this is to make your own chunk generator that handles the whole thing
But I believe they are using something third party for the default gen
Thats not how chunk generators work I dont think
well the vanilla chunk generator is hard to access i think
Not anymore
The server fills up with memory and I dont know how to stop that. I cant generate that many before the server crashes
More memory or slow down
havent done chunk gen shit with bukkit since 1.16 what changed
Those methods that let you delegate to vanilla
So you can simply delegate to vanilla for a while
And then once x or z are bigger than your boundary, start returning false
aight gn
How would I do that if I'm trying to generate hundreds in a world file, evenly spaced out?
Little bit of math on the x and z coord
Mod them by 100 and only generate terrain if the result is 0-5 for example
That will give you 6 chunks of terrain and then 94 empty
how do i make a compass point to a location?
Version?
1.19.3
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#setCompassTarget(org.bukkit.Location) is probably more appropriate
Well one is per item
Idk if setLoadstore requires an actual lodestone at that location
whats the difference between Inventory and InventoryView
Inventory represents an inventory that can be opened
InventoryView represents the view of an opened inventory
InventoryView is a container representing both inventories
Inventory is one or the other
Ah yes that too, since the player inventory and whatever is on the top are 2 separate inventories
I posted an image of this a long time ago on the forums and I can't find it
is there any practical reason for using inventory view?
and is there any practical difference
so if i open a custom inventory for a player, am i able to tell if that inventory is open when they do an inventoryclickevent?
inventory, not inventoryview
Yes
You can keep track of the open InventoryView and compare it with the one provided by InventoryClickEvent
getTopInventory should match your custom inv
InventoryView view = player.openInventory(inventory);
// In your event
if (event.getView() == view) {
// Your inventory
}```
Obviously very simplified, but that would work
Also an option
so im opening a custom inventory when a player clicks an enchantment table, im cancelling the defualt inventory and opening my own, but the player makes a 2nd "swing" when right clicking the e table
minor thing but do you guys know the fix?
how can i check that?
if(e.getHand() == ){
return;
}
Always use &k as much as possible
Well, what does getHand return?
a hand
Shhh
ah
People gotta learn to use their ides
if(e.getHand() == EquipmentSlot.OFF_HAND){
return;
}
im so good at this
or do i need .equals()
or instanceof
coolio
thanks
!paste
why it keeps giving me this error
Code: https://paste.md-5.net/diyazisiro.java
Error: https://paste.md-5.net/ludopanewa.md
Help
the ? in name dont count?
now i have this error https://prnt.sc/26CgljZFT1pD
i just added that
the code that i use to create it helps?
i use a code onEnable to create it
okay
Statement statement = conn.createStatement(); statement.execute("CREATE TABLE IF NOT EXISTS kppvp_stats ( name varchar(50) NOT NULL, kills int(11) NOT NULL, deaths int(11) NOT NULL, streak int(11) NOT NULL, coins int(11) NOT NULL , xp int(11) NOT NULL, PRIMARY KEY (name)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;"); statement.close();
6 cols
and now the code that gives an error
o yeah wtf lmao
thought that was common knowledge since like 1.8
do you guys need more part of the code to help me?
@young knoll I'm both happy and pissed off this is so easy to do with these methods. I wish I figured that out or someone told me 3 days ago. Thank you
he was asking for the value in parameter 7 but there is no parameter 7
I'm so far behind
show full line
yeah I'm blind
uhh
I'd rather do
INSERT INTO kppvp_stats (kills, deaths, killstreak, coins, xp) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE name=?
might be useful to specify the actual columns
I try to do an animated scoreboard but I have no clue what that error wants me to say https://paste.md-5.net/wimekolige.cs
so Bukkit.getScheduler().runTaskLater(Main.getInstance(), new ScoreboardTitleTask(animation, scoreboard, player, delayTicks), delayTicks);
to new ScoreboardTitleTask(animation, scoreboard, player, delayTicks).runTaskLater(Main.getInstance(), delayTicks);?
ok
but now the animation is screwed
nice ip
Like fr idfc if you wanna ddos me goahed
chocos method only takes lowercase input
Yep
Can just add || character >= 'A' && character <= 'Z' to the if statement and should still work okay
Was an educated guess I suppose ¯_(ツ)_/¯
I'm sure there's some other codepoint offset that displays the chars like that
I mean it absolutely could be
Yep. Also a good way to figure it out
Do you want a ballsack? ѽ
CYRILLIC SMALL LETTER OMEGA WITH TITLO (U+047D)
why it keep throwing that https://prnt.sc/Tm0MiTZ9W7NK
sir this is spigot
Too many ?s, not enough parameters passed to your PreparedStatement
bro I did some research
3.0 is not a thing
what i can do to fix
Provide the number of arguments that your query requires, ideally
it requires 7
uuid, name, kills, deaths, streak, coins, xp
Unsure. There's probably some website that shows English codepoint variations
I'm only aware of 0xFEE0 but I guarantee you there are others
Hacked clients use them all the time
what you trying to do?
If it's the insert one, there are 8
Your ON DUPLICATE KEY UPDATE also has a ?
(As an aside, I wouldn't rely on name as a constant identifier. Refer to the UUID where possible. It's constant)
Alternatively, you could alter your statement to do the following
INSERT INTO kppvp_stats (kills, deaths, killstreak, coins, xp, UUID, name)
VALUES(?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE name = VALUES(name)
That way you do only need 7 and you're avoiding re-assigning the same parameter
Okay so you'll need like a mapper for this
U+0493 is the unicode hex value of the character Cyrillic Small Letter Ghe with Stroke. Char U+0493, Encodings, HTML Entitys:ғ,ғ, UTF-8 (hex), UTF-16 (hex), UTF-32 (hex)
Yeah they might just have a set of characters they're manually mapping
you gotta look for em
All Unicode Symbols with Names and Descriptions on One Page
You can usually search for things like "F" and it should come up with similar-shaped letters
you only need 26
fun fact I failed my homework on 1st grade because the reading test said that the alphabet had 23 letters and I counted 28
then yeah 26
try and see
remove the last ,
Well, coins=? , xp=? UUID=?, WHERE name=?, this is a little mangled
This is where text blocks really come in handy
private static final String INSERT = """
INSERT INTO kppvp_stats (kills, deaths, killstreak, coins, xp, UUID, name)
VALUES(?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE name = ?";
""";
private static final String SELECT = "SELECT * FROM kppvp_stats WHERE name=?";
private static final String SAVE = """
UPDATE kppvp_stats
SET
kills = ?,
deaths = ?,
killstreak = ?,
coins = ?,
xp = ?,
UUID = ?
WHERE name=?
""";
The ability to indent and properly format SQL makes readability much nicer rather than having it all on one line
so what i need to do to fix
just make .sql files and load em dynamically 
it is mean to be a public plugin so people needs be able to use it
why this dude following me
You're missing a , between xp=? UUID =?, and you have an extra , after UUID = ?
in save?
Yeah
But in INSERT you're also specifying 7 column names but only 6 parameters
You really need to read up on some more basic SQL
private static final String SAVE = "UPDATE kppvp_stats SET kills=? , deaths=?, killstreak=? , coins=? , xp=?, UUID=? WHERE name=?";
this is correct now?
Yes
private static final String INSERT = "INSERT INTO kppvp_stats (kills, deaths, killstreak, coins, xp, UUID, name) VALUES(?,?,?,?,?) ON DUPLICATE KEY UPDATE name=?";
and the insert one?
?
private static final String INSERT = "INSERT INTO kppvp_stats (kills, deaths, killstreak, coins, xp, UUID, name) VALUES(?,?,?,?,?,?) ON DUPLICATE KEY UPDATE name=?";
the insert one is correct?
You ever get to the end of the MVP segment of a project and think "god damn thank god its almost done!" ? xD
no
fucking christ on a bike whate even is that?
project I've been working on for a while
Alright, now just do your lil if check - 'A'
characters are internally just numbers that point to their definition on the charset thing
'b' - 'a' = 1
type deal
so
yeah you're still comparing numbers
you don't really need to care about that
also change your mapping to use characters and not strings
so
public static String remap(String original, char[] mapping) {
char[] outputArray = new char[original.length()];
char[] originalArray = original.toCharArray();
for(int index = 0; index < originalArray.length; index++) {
char character = originalArray[index];
if(character >= 'a' && character <= 'z') {
outputArray[index] = mapping[character - 'a']; // lowercase
} else if (character >= 'A' && character <= 'Z') {
outputArray[index] = mapping[character - 'A']; // uppercase
} else {
outputArray[index] = originalArray[index]; // not mapped
}
}
return new String(outputArray);
}
something like this
yes
bruh
I might be idiot
but in theory my code makes sense
Yo, I have a plugin called "Generators" I'm saving all generators to a single file pr player. Saving the data in a HashMap<UUID, Set<PlayerData>>. The problem is when the server restarts I have to go through every player file to get all Generator locations, because if I don't everyone could destroy each other's generators. Is this ok as it's only when the server starts, or is there some other way?
yes, do it async though
originalArray.length is the same as original.length
What did you fix?
yeah I don't see much of a difference but sure
skip arrays entirely
Isn't that only usable in a Runnable?
make a runnable that runs your code
CompletableFuture.runAsync(() -> loadFiles(plugin)).thenRun(() -> {
// Files are done loading, feel free to print a message
};
Oh okay! Thanks 🙂
If you've never used futures before I suggest you read this
lol, creative to prefix your guides
It's so I can look them up faster
Will do
Figured as much
instead of having a little list of discord message links
It's my only guide though
send me that array for future reference 
don't you love when you're reverse engineering a library and you face a 20k line class
and the javadocs have fuckin images
last error i have: https://paste.md-5.net/wuwezivopu.md
Flowable
someone wants to help me finding out a fix to it?
yes but 20.5k lines
tf is Flowable?
Actual image of 99% of lands plugins xD
I think the biggest class I have out in this project
I was gonna say it's my redis impl but it's only 290 lines
I gotta find something bigger
I generally always stay under 250 lines
unless I document a ton
o
ItemBuilder's got 340
last error i have: https://paste.md-5.net/wuwezivopu.md
Someone can help?
hey guys, so a pdc is super convenient and way easier than a db so is there any reason for me to use PDC > databases to store most of my stuff for a player?
oh that makes sense then, would be pretty hard to order stuff and shit if i were to only store with pdc.
Databases are only really handy if you need to share data between multiple servers or even applications.
And they can be a bit faster (Which shouldnt matter if you do your IO async, as you should)
Was more referring to local files
so as the other person mentioned, i wouldnt be able to access stuff if players are offline, meaning i couldnt make like a baltop sorta thing without a databse right
You can with local files
You technically can with PDC too, but you have to manually load player files
Yeah PDCs are tied to sessions. So for chunks they are only available during the chunk session and for players
they are only available during the chunk session etc
ooh yeah thats slightly inconvenient. another question then, it is better for me to have a database that stores files or have an online server with mysql?
If your DB is on the same machine as your mc server then it will be faster. (If that is your question)
yep exactly that. i just worry itll be tougher to set that up over an actual server
yo @echo basalt
On Enable stuff
FileManager fileManager = new FileManager(this);
CompletableFuture.runAsync(() -> fileManager.loadPlayerFiles()).thenRun(() -> {
Bukkit.broadcastMessage("Generators - Player files has been loaded.");
});
File stuff
CompletableFuture.runAsync(() -> {
// Stuff
});
Is this correct? Cause i can't seem to get it to work :/
Not needed in onEnable. You should load all your stuff in there blocking
But generally speaking this is ok
uhh
What du mean by not needed?
well it's somewhat fine to do IO in the main thread
but given this is player storage, I'd still recommend doing it async
I've had cases where it took 5 minutes for a server to start because of this
but I also just switched to a proprietary format of that ever happened, or just use a database
In your onEnable you can take as much time as you want.
Hey everyone, I'm trying to develop a server hopper plugin where if a player clicks on a custom item it transfers them to another server however when using something like player.performCommand("server") it returns as unknown command anyone know why?
You're running bungee commands on bukkit
Dont use performCommand while coding.
Tell bungeecord to transfer the player by sending a plugin message to it.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
It’s good for like
Well this still doesnt work tho? :/
telling good devs apart from bad devs
Configurable rewards for a voting plugin or whatever
Not even getting the message
Incase you want to run the give command of another plugin
read the part on my guide where I mention it likes sucking away exceptions
Imme read it again
Slurp
gotta love having a midlife crisis at 18 and deciding to help people instead of sleeping
CFs hide exceptions. You need to handle them or you will come into devils kitchen
Hmm so not for things relating to bungeecord or spigot commands but for other plugins?
Wait i dont think this makes sense in english
or make your own class that extends CF and handles them magically
You should only use performCommand for running arbitrary commands
fun fact: .exceptionally() creates a new future
For example: something user configured
gotcha so like /help or something like that
If you know what command will be run, there is almost always a better way
sometimes I actually wish there was a secret option that a dev had to enable
to actually be able to use such methods
Wait so i can just Extend? and boom magic
like a casual HiddenFile.enableFeature(PERFORM_COMMAND)
extend and override a couple methods
maybe play a bit with Unsafe
inject in a cached threadpool
Oh message is now there 😮
How about a command line argument
ehh
no
it'd break plugins and generally not be well seen
but a hidden file is cool
and a warning
like
Shoutout to -IReallyKnowWhatIAmDoingISwear
Hey, seems like you're not meant to run this action. If you're seeing this for the first time, there's always a better way to do what you're currently trying to do. Regardless, if you're actually fetching commands from a config, look up how to enable the "hidden feature"
I feel that would be good for a lot of things
But I digress
“Oh you’re trying to use reflection? Write me a short persuasive paragraph on why you should be allowed to do so, you have 5 minutes”
and just have a HiddenFeatureManager.allow(plugin)
reflection is acceptable
but stupid features that aren't meant to be used... should not be used
Yes those are good reasons
or doing nms without a multi-module project
or fucking with internals
I've used Unsafe to replace spigot's command map
Is it static final
Then you don’t need unsafe
Dat don’t look static to me
Need some guidance on using a specific player-crafted potion as a MerchantRecipe ingredient. I see plenty on how to setup custom potions, but what counts as equivalent for the purposes of a MerchantRecipe ingredient? Do they have to just have the same effect? Same duration? Just looking for some guidance here.
indeed, not quite the question
I suppose the "hard coded" potions in the game are just setup using the same bits and bobs we have access to
so if I theoretically create a custom potion with the same effect and duration, they SHOULD be equivalent?
I guess trial and error it shall be...
the player is crafting one potion
like, the usual way
and I want to trade it to a merchant, so I have to give a recipe to the merchant, not sure what to give them
Make a potion ItemStack, get the meta, and use setBasePotionData
get the meta from the one the player has?
The one you are making for the recipe
they just compare tags
ahhh, PotionType, that's what I've been searching for
group effort, peeps 🙂 thanks 🙂
So I was looking over the plugin messaging channel and I've got a question. Would I put the pluginmessagelistener into an existing plugin for spigot or would i create an entirely new plugin for the bungeecord proxy?
and then how would I go about sending that message on a player interaction
?pmc
Yes that
Wait why wasnt it good having this in the onEnable?
FileStuff fileStuff = new FileStuff();
CompletableFuture.runAsync(() -> fileStuff.loadPlayerFiles(this)).thenRun(() -> {
System.out.println("Generators - Player files has been loaded.");
});
just make a method for it?
I don’t believe you need a receiver to use the built in messages
And it tells you how to send one
Thank you, I wasn't sure if it was requiring there to be something on the proxy side handshaking with the pluginmessage
I would like to spawn a FallingBlock with FallHurtMax in my plugin code without the command how to do that?
/summon falling_block ~ ~ ~ {FallHurtMax:1000}
You summon a falling block with world#spawnFallingBlock
You can use FallingBlock#setHurtEntities to make it hurt mobs
and how for players?
Players are entities
they dont get damage
It doesn’t seem there is an api method to set the damage it deals
Or set the max damage it deals
Yeah working on it as we speak lol
I think those have always existed
Idk how that hasn’t come up until now
Also FallHurtAmount is a bad name smh Mojang
It is, yeah
Anyway it seems choco has a PR for that stuff covered, you should see it in spigot build soon, probably a few days
Optimistic
Small stuff goes pretty quick in my experience
Assuming you don’t have any changes requested
MyPlugin.jar:
https://pastebin.com/raw/NWrz2XDd
Error:
https://pastebin.com/raw/ebnKgDUm
MyPlugin.yml:
name: MyPlugin
version: 1.0
main: com.example.myplugin.MyPlugin
author: Your Name
description: A simple plugin that greets players when they join the server.
commands:
mycommand:
description: My custom command
usage: /mycommand <player>```
The plugin doesn't loads...
my code is correct? https://paste.md-5.net/fumuwutawi.java
Looks fine on the first look. But dont use player names to identify them. What if they change their name? Everything will be gone for them.
?tryandsee
I'm trying to use the pluginmessage in an event would I just add ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Subchannel"); out.writeUTF("Arguments"); to the event being triggered? So in my case on inventory slot interaction?
Where can I find the code for the implemented book formatter?
The one that takes care of words not being wrapped etc?
I need it to check how much content I can fit on one page and when to put it on the next page
Or where can I find code mojangs server code in general? So I can search myself.
Or is it obfuscated?
That would be in the client. It's a client-sided screen
Probably ScreenBook or something in Mojmaps
Where do I even go to get the client code I have to search in? 😅
Forge, Fabric, or MCP
Though I don't think it's worth searching because it's going to vary based on the user's font
Hm that's also true. But I doubt that someone would drastically increase the font-size for books.
so for smaller fonts the page would be less full but that doesn't matter too much.
Still better than having the page sometimes half-full and sometimes completely full depending on the used words and letters ig
Word wrapping on a single page is handled automatically so you won't need to worry about that, but what you should do is try to restrict how many characters you insert onto a single page, which if I'm not mistaken is 256. I'm sure the wiki has the exact number
You'll never get a perfectly formatted book, unfortunately
Unless you employ the use of a resource pack with an additional monospaced font
I mean the character sizes are known (for the default font). And I made a custom formatter that would wrap words at the end of a line. But it clashes with the one from mojang
It's 14 lines with 114 dots. Space between each character is one dot and letter sizes are 1-6 dots.
But since they don't wrap words I can't do 14*114
Question, this might be a long shot. How possible is it to create a pop up kinda like this on screen?
Can't
Not even with like custom textures?
I didnt think it was possible, but i feel like iv seen it before maybe not
You can do pretty much anything with a resource pack and a dream
You can also make fake advancements to trigger the advancement get popup, which is similar
hm ok, i might just try something different. I imagined like a dialogue box thingy but idk if thats gonna be feasable
for ClientboundToastPacket and /toast command
do Iron Bars use the Fence BlockData ?
Tbh there’s a lot to <:PES_SadGePray:> for
yup, it's fence, and what a great resource. Never looked there before 🙂
ok I think I give up on writing custom brain behaviors
Is there a way to set persistent data (that can be read by a spigot plugin) inside of a spawn egg's nbt, so that when it's used, the entity has the tag?
no matter how I twist it there's always a further plot twist that makes it just not usable
Not with the api
could you do it with /give and the nbt tag you can supply to it?
is there somewhere I can go to find the format for adding this manually to an nbt tag?
Probably easiest to just add pdc to an entity and then use the /data command to print it
Hey, my plugin isn't loading:
Could not load 'plugins/MyPlugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.loadPlugins(CraftServer.java:428) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3670-Spigot-454acb7-bd29f41]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:219) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3670-Spigot-454acb7-bd29f41]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:973) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3670-Spigot-454acb7-bd29f41]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3670-Spigot-454acb7-bd29f41]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.util.zip.ZipException: zip END header not found
at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1469) ~[?:?]
at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1477) ~[?:?]
at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1315) ~[?:?]
at java.util.zip.ZipFile$Source.get(ZipFile.java:1277) ~[?:?]
at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709) ~[?:?]
at java.util.zip.ZipFile.<init>(ZipFile.java:243) ~[?:?]
at java.util.zip.ZipFile.<init>(ZipFile.java:172) ~[?:?]
at java.util.jar.JarFile.<init>(JarFile.java:347) ~[?:?]
at java.util.jar.JarFile.<init>(JarFile.java:318) ~[?:?]
at java.util.jar.JarFile.<init>(JarFile.java:284) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:166) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
... 6 more```
plugin.yml
version: 1.0
main: com.example.myplugin.MyPlugin
author: Your Name
description: A simple plugin that greets players when they join the server.
commands:
mycommand:
description: My custom command
usage: /mycommand <player>```
MyPlugin.jar:
https://pastebin.com/raw/NWrz2XDd
How?
How did you compile it the first time
ah
Im getting errors which makes no sense
idk
error: no source files```
javac -cp plugins/MyPlugin.jar plugins/myplugin/myplugin.java
error: file not found: plugins/myplugin/myplugin.java
Usage: javac <options> <source files>
use --help for a list of possible options
Can you help me with this....
how can you run your plugins with javac???
No idea
I'd just use a build tool like maven / gradle
how do you guys do versioning for multimodule projects? When I change the version I need to reinstall everything through maven for it to work but the parent can't install due to the modules not being found so I end up having to install without the modules first and then add them
there has to be a better way
usually i just use ctrl+shift+f to pop up the versions and change them all at once
then save and compile
mvn versions:set -DnewVersion=1.1.0 does all the modifying for me
but then intellij forgets where everything is and can't compile
it just can't find the modules anymore
seems like an intellij problem never had that with vsc
In Eclipse you just right click the pom and select update project
in IJ you probably have to clear caches and reboot
I find that usually works for intellij
Haven't had to clear the cache in a year or so
Is there a way to listen to structures being generated for 1.14 api?
declaration: package: org.bukkit.event.world, class: AsyncStructureSpawnEvent
1.14
I guess I'll have to then. Damn it
when you get the command from the plugin.yml you can choose to modify any of it's elements before registering it's executor
why?
val worldUuid = it.asJsonObject.get("worldUuid").asString
println("UUID: $worldUuid")
println("Worlds: ${Bukkit.getWorlds().map { world -> world.uid.toString() }} }}")
println("World: ${Bukkit.getWorld(worldUuid)}")
val world = Bukkit.getWorld(worldUuid) ?: return@forEach
i'm missing something stupidly obvious am i not
oh i got it
i forgot to turn the string to uuid
💀
reads the side where the player is looking, but does not move, I don’t understand why?
does the entity have AI?
or is it an actual Player?
also you are doing a lot of math there you simply don;t need
newLoc.add(0,0,-1);
ent.setVelocity(newLoc.toVector().subtract(currentLoc.toVector()));```can be replaced with```java
ent.setVelocity(new Vector(0,0,-1));```
actually you could even scrap your facing code, just use the Entity#getFacing
no, it doesn`t have
although that is cardinal not cartesian as you are doing
so you only want N,E,S,W and ignore NE,SE etc?
then your face code is fine, just scrap all the other
I'd probably drop using strings though
you don;t even need a switch if you make your getDirection method return a Vector
Is the problem in NoAI?
you could do it all in one line of code
no
its your vector is too small for you to notice
the whole of your code can be simplified tojava ent.setVelocity(getDirection(player));If you change your getDirection() to return a vector.
No switch or anything
Slime ent = (Slime) player.getVehicle();
ent.setVelocity(getDirection(player).multiply(2));```
adding the multiply so you can add a strength of the push
If your getDirection is changed to return a Vector
Should there be such a result?
a result?
you are already creating a variable for dir so use it
ent.setVelocity(dir.multiply(2));
you may want to add comments to your getDirection method so later in life you remember which vector is which
what are you trying to code?
I mean what for
for making a subcommand handler the best way is just by checking with ifs right
ask chatgpt
what did you expect when using kotlin
val val val
what does this have to go with kotlin
because in java you'd know what type a variable has, in kotlin you just say "val" and then have no clue whether it's a string or uuid or world or whatever
It’s not that hard to figure out tbh.
Either just hover over it or the functions will shit themselves.
in java you don't have to figure it out
nothing to "figure out" with Java
so mistakes like this couldnt happen in java
They do happen ahaha.
well if I did
UUID myUUID = someString;
then the compiler would tell me that a String is not a UUID
if however I just did
val myUUID = someString
then I would assume it's a UUID while it's actually a string
I am sorry. How is it not easy to view on righthand side that it’s a string in his exampel?
As well as yours.
It's easy, they are just hating kotlin as usual
ofc it's easy when you look at the "asString" part. But usually the type is on the left side. and here it's just "val" instead of a type
I don't hate it, I just think it's bad and adds nothing that's useful
Again. Don’t immediately put your java notions on top of a different language.
how did this even compile?
oh because getWorld also has a stirng method
makes sense
Cause ^
yeah anyway, using val is just prone to stupid mistakes
val is in Java now, never going to use it.
yeah very bad idea imho
I am gonna use it extra much just to annoy you.
btw can i use css for textures
Ok 🙂
do whatever you like
ReflectionSupplier
.NMS_BONE_MEAL_METHOD_ACCESS
.invoke(
null,
ReflectionSupplier.NMS_BONE_MEAL_APPLY_INDEX,
boneMealItemStack,
ReflectionSupplier.CRAFT_WORLD_METHOD_ACCESS.invoke(
block.world,
ReflectionSupplier.CRAFT_WORLD_HANDLE_METHOD_INDEX
),
*getBlockPosition(block)
)
applyEffect(block, player, config)```
The * do be weird
what does it do?
is it like in py?
I only know that it's for varargs methods
Simply converts a kotlin array to a varargs argument.
in python using a * before an iterable it unpacks all of it's values
Same
can you domsething like
a, b, c = [1, 2, 3]
?
Maybe? Can’t recall
okok np
Looks like it
hi, i am trying to make an inventory where every second a new item get put in the first slot, so basically, every second it gets replaced... some items in Material however cannot be put in an inventory and they just get replaced with air, how can i bypass that?
only use Materials which are isItem()
make a Set of materials at instancing you can pull from
how?
I'd just go with a static set created with a stream since it never changes
how?
Or maybe just an immutable list 🤷♂️
how?
.stream().filter(Material::isItem)...
Is there a way to get all positive/negative potioneffects?
Same way as the materials we just talked about above
Stream the effects enum and save it to a variable
like this?
You forgot this part
But how do i only get positives or only negative effects
its in the runnable, should i put it outside?
Oh I thought the api exposed that but apparently not... You can use NMS or hardcode it I guess
@pine forge who are u able to have external emojis without nitro??
yes, it should be a field in the class
i dont
when did i use external emojis
It worked in about me's without nitro some time ago
oh
i didnt edit my about me since then
cool
and discord didnt disable it on my about me
lucky 😄
is there some PreSpanerSpawnEvent?
SpanwerSpawnEvent
Is it a bug that I need to press tab twice too see the tabcompletion
Hi, pretty generic question; how can I remove the "<" and ">" from the chat when a player sends a message?
async chat event setFormat
Thank you
It shouldn't work like that.
Here is example from my plugin
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
if (Reflections.Version.get() == Reflections.Version.NOT_SUPPORTED) {
return Collections.singletonList("");
}
if (args.length == 1){
return Arrays.asList("create", "delete", "author", "skript", "info", "rename", "addline", "setline", "deleteline", "shiny", "glowing");
}
return Collections.singletonList("");
}
That wont work pretty sure you need to do the copy partial matches thingy from StringUtil class
Or well the result will not be as you expect it to be
Its not full method
i should not be messing with java when writing tokenizers
wtf
just use lib for commands lol
Well at least make it easier for urself by splitting up that giant function
its like also for vanilla commands
and use some early returns
Yeah its a bug then
There are some
and dont ever write "else" if your if already returns smth
probably also want to cache materials
refill the block
block.getData() or block.getBlockData() I think
How to remove 1 item from an inventory?
set the slot with air
removeItem
I was coding for 9 hours straight after school immediately and the deserializer was written at 1 am or something
I wouldn't make the mistake neither with java nor with kotlin under normal circumstances, which can be proven by other serializers in this project, most of which worked first try xD
item.setAmount
wha
if amount is 1, remove the item, otherwise decrease by 1
removeItem removes up to the amount specified
no
and find this item in for each loop?
ok xD
that method might change the input items too
for whatever reasons
Yuck.also lol at it returning a hashmap of int, aka an array
isn't the Integer key the index to the ItemStack that couldn't be removed from the varargs ItemStack parameter?
Constantly check if a value has changed and if it has changed, do something. I know this is more of a Java question and I will be considered a noob, but I need live support to understand this right now.
The integer key from ItemStack is for the amount of the item
And I'm sure you can assign an ItemStack without the Integer
if you have it in a class you made, have a getter and setter (i assume you already do) and do whatever you need to do in the setter
Okay, let me try that. Thanks
from the docs:
The returned HashMap contains what it couldn't remove, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all the given ItemStacks are removed, it will return an empty HashMap.
no prob, g'luck
yep no
lol
That’s what it says anyway
The returned HashMap contains what it couldn't remove, where the key is the index of the parameter
yes but that's the index from the given ItemStack varargs parameter, no?
Wouldnt make much sense otherwise so yeaa
Yes erdi
so i phrased it correctly
Lol
Hey guys, do I have to manually add some code so that command blocks recognise @/p, @/s, etc with my plugin's command?
Yes
yeppers peppers
uff
uff indeed
Is that done in the onCommand part or where?
Yes
there's probably some utility class someone made for it