#help-development
1 messages · Page 678 of 1
or just use selectors
can't use name if they are offline because MC doesn't store player data by name but by UUID
the name is only relevant if they are online
It’s offline right?
yea
Where did you get that uuid
from the join message
Ah
think you need to add entity in there?
data get entity uuid just prints out 'entity not found'
do you know if i can fake the command using the offlinePlayer -> player copy of the player?
I'm interested in the data printout @wet breach
What
Can’t u use @p?
offline
does using storage instead of entity work?
An offlineplay is still a player yes?
dont think so
via the api yes
Then think again
native mc has no concept of an offline player
the storage thing prints out {} for everything i give it btw
so i dont think thats linked to uuid
interesting
well, if you want you could obtain most of that info you want via the api
using OfflinePlayer or reading the player dat file in question
player dat files are named by uuid
yes
thats how that "_ joined the game (previously _)" works if uve seen that before
Won’t get that on offline
the name they last used is stored in the dat file until they join again and if their name is different it will upate upon a world save or when they disconnect
well yeah
so, that means as long as they are still offline you have at minimum last known name
but offline mode is a special case because its wierd as hell
It does on offline
no it doesnt
Are you fumb
I think you are confusing offline mode with offline player
they are not doing anything in offline mode
offline mode it does
Ohhh
rather offline players
I just don't support or implement offline mode in anything 🙂
exactly
All i know is that the uuid is like UUID.fromString(“OfflinePlayer:” + name) or smth on offlinemode
if the plugin breaks because of offline mode fucking with shit oh well
all I know is that it eats your inventory
Haha it does cause uuid changes
I wonder what’s the changes of a player having the same uuid online and offline
UUID in offline mode is derived from parsing their name as string into the UUID constructor
this is not possible
offline UUID uses version 3 of the UUID where as Mojang uses version 4 for online mode
isnt that still the same format
no
Ye it’s UUID.nameUUIDFromBytes(("OfflinePlayer:" + player).getBytes(UTF_8))
its not, it has a big difference in how the UUID is calculated
https://stackoverflow.com/questions/20342058/which-uuid-version-to-use
same format, different way of calculation
so technically if you got stupid lucky MC's uuid V4 could be the same as ur offline uuid
so it isn't possible for an online player to have the same UUID if they are in offline mode. This was done purposefully to avoid collisions in the event the server was put in offline mode and had online mode players
its not possible
statistically unlikely != impossible
it is literally impossible
^
like actually, literally impossible, not mathematically unlikely, mathematically impossible
Well that seems false
Just cause there is an infinitely small chance for it to happen doesn’t mean it can’t
v4 UUIDs, which contain 122 bits of randomness is very much equal an 1/(2^122) chance to have the same uuid online and offline
thats what RANDOM means
V4 incorporates a time element
V3 does not have this
Guess you just gotta be blessed by the time god too then
even then, the version of a UUID is determined by a specific byte, if it's version 4, it is set 4, if it's version 3, that byte is set to 3, i think we can agree that 3 cannot collide with 4
they literally cannot collide when the version byte is always different between the two
not unlikely, but impossible
there is that, other then that both calaculate UUID's significantly differently
not even a byte, but half a byte lol
so a nibble
you can easily load the .dat file of offline players
funny word
yea i since then realized, thanks tho
Pros here
Yo alec
Alex*
I was just stuck how to get an speicifx player head in itemstack
Or if there is any other way
look at the item meta
this is how to load a player .dat file https://github.com/JEFF-Media-GbR/JeffLib/blob/master/nms/1.20.1/src/main/java/com/jeff_media/jefflib/internal/nms/v1_20_1/NMSHandler.java#L420
By specific I mean there texture
basically you just do NbtIo.readCompressed
Like an iron golem head
SkullMeta#setOwningPlayer
or do you mean base64 textures?
Yes
Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. I’ll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...
Ty
man you have everything dont u
well a good portion of us have probably done many things most come here for help with 😛
lol I needed it to get offlineplayer's PDC
chip away at making plugins for long enough and you'll eventually have done everything
getPlayer() returns null on offline players
im pretty sure you can cast it
sure, you can cast null to anything
🤦♂️
i meant
trust me, you cannot get a Player object from an offline player just by casting it
im fairly certain Player player = (Player) getOfflinePlayer(uuid) worked in a plugin i did like 2 years ago
no
It works for online players
yes
But not for offline players
if it'd actually work for offline players, there'd be no point in having an OfflinePlayer interface in the first place
you have to do some fancy magic to get a Player object from an offline player object if they are not online
its doable, just a pain to do
public Player getOnlinePlayer(OfflinePlayer offlinePlayer) {
while(!(offlinePlayer instanceof Player)) {
offlinePlayer = offlinePlayer.getPlayer();
}
return offlinePlayer;
}
^^ very useful
I don't even know why I'm making a python interface to poke at chatgpt
just remove the l there and its a good name
nah
mhyeah makes sense
shame api calls are so expensive
this is me not even using it, just poking the api to test responses as I make software around it
I'm trying to use nms to make player spectate entity, but when I use this code I get an error for playerConnection. Am I doing it right?
and version is 1.19.2
add parenthesis
im pretty sure playerConnection is supposed to be a getter
any reason why you need to do this via NMS?
declaration: package: org.bukkit.entity, interface: Player
oh really? I didn't find that, thx
just make sure to set the player to spectator mode first before using that method
the field is called "connection"
?switchmappings
seems they didn't realize there was an api method for what they want 😛
or just didn't find it
alex, do you have support for multi modules in aliatory?
like support for classes per module?
aliatory?
classes per module?
I really have no clue what you're asking about tbh lol
Hey, I have a plugin there which is extended by another class, in core plugin I load this plugin but it is not instance of that another class, any ideas how to fix this? It worked though
I don't understand your problem
What you don't understand? I load plugin (addon) with my core plugin, but it is not instance of another class which extends it
I know support for older versions is not given but something to ask about Durability, with damage i can make a texture linked with an item if i use a pickaxe, damage will not damage and show up on the item, or its separate? im talking about 1.12 so custom data model do not exist (found out yes)
So you have Class B extends A
and when you do
if(bInstance instanceof A) it returns false?
i saw a method really good by a Core (Mechanics) that loads the addons like a plugin normally but only make sure it gets run by the core so the dependency is respected
I have AbstractAddon extends JavaPlugin, in that addon I extend AbstractAddon class
where you can apply certain libs over certain classes
but it is not instance of AbstractAddon
?
https://github.com/Wuason6x9/mechanics/blob/master/src/main/java/dev/wuason/mechanics/Mechanics.java look a this code and its really simple their system for addons, the only thing it make sure its like the plugin loads so it has the classes to use (addon example: https://github.com/Wuason6x9/StorageMechanics)
seems like something bit different
damage and durability are two different things
I have these addons in pluginName/addons/
Hi, does anyone know how to get the ICrafting instance of a player starting from the EntityPlayer? In 1.16_R3 the EntityPlayer class implements the ICrafting interface, but in 1.17_R2 it does not.
inside the wiki there's a page that explains, how to use older textures and the problems with that the items gets damaged to show it, but another way i round i think i found its by using optifine
damage value is just another way to state extra data
unless you are not talking about damage values
and instead actual damage
the same applies in older version for the glass / glass_panels
ah then I think you are talking about damage value then
reason we call it damage value for those interested is because the item doesn't change and looks like the rest but it isn't treated as being different as if its damaged 😉
or it slightly changes
and thus now damaged lol
but its just a fancy way of saying extra data values
Cit (Optifine system) works inside server uses names (i know the client doesn't know nbt from other users)
Maybe would it be useful get the player's container?
Hi, I just need to change inventory title in my plugin. But problem is there is not method for that in 1.18.2 (I think). How can I do that properly? Im just making kit plugin and after every click (probably) I would like to check if some items in inventory are same as items in kit. If not change title. But something is canceling InventoryClickEvent for me every time even if I set setCancelled to false.
Code:
public void handleMenu(InventoryClickEvent e) {
ItemStack item = e.getCurrentItem();
Player p = (Player) e.getWhoClicked();
int slots = getRows()*9;
int slot = e.getRawSlot();
if (slot > 8 && slot < slots-9) {
p.sendMessage("not canceled");
e.setCancelled(false);
}
if (!e.getView().getTopInventory().equals(e.getClickedInventory())) {
p.sendMessage("not canceled");
e.setCancelled(false);
}
saveKitItems();
inv.clear();
open();
public void open() {
inv = Bukkit.createInventory(this, getRows()*9, ChatUtils.format(getTitle()));
setDefaultItems();
setMenuItems();
owner.openInventory(inv);
}
Or is there anothrey way where I dont need to open another inventory for player?
I think you can change the title via the respective view?
One more question, how would I get the 3x3x3 area surrounding the minion?
InventoryView? Nah you cant in 1.18.
I have been thinking of this all day but I just can't seem to get any solutions
I may be dumb
Do I have to use a for loop or somethiny?
Can anyone explain what 'display' is, in entity-tracking-range, for spigot.yml
how can i fix this?: https://paste.md-5.net/povifabiha.sql
with a 3 nested loop?
for int x = -1; x <= block.getX() + 1, x++
same for y and z
how do i add subtitles to a player and only display it to certain players?
then block.getRelative(x,y,z)
I was right
I just dont know how to implement it lol
Im so bad at math
Hello,
I've ran into one issue with my world creation method, which is simply creating a void world for islands to be created. The world is used for different tasks and it always shows "null", I can't teleport to the world as well, it just throws an error (null, couldn't find the world). Will appreciate any advices.
private fun makeWorld() {
val wc = WorldCreator("world_island")
wc.type(WorldType.FLAT)
wc.generateStructures(false)
wc.generator(main.generator)
wc.environment(World.Environment.NORMAL)
wc.createWorld()
}
(WorldCreator wc = [...]) for Java users
sth like this shuold do. in this case, radius would have to be 1 for 3x3x3 (because the center block is always included, so it goes +/- 1 into each direction which results in 3)
public static List<Block> getBlocksInRadius(Block origin, int radius) {
List<Block> list = new ArrayList<>():
int startX = origin.getX();
int startY = origin.getY();
int startZ = origin.getZ();
for(int x = startX - radius; x <= startX + radius; x++) {
for(int y = startY - radius; y <= startY + radius; y++) {
for(int z = startZ - radius; z <= startZ + radius; z++) {
list.add(origin.getWorld().getBlockAt(x,y,z));
}
}
}
return list;
}
you could accomplish this with a single loop btw
The name of the world is everywhere the same, the world is taken from just 2 sources (config and manager in which the method mentioned is)
you only have to interate half as the other half is just the inverse
and since its an equal square only one iteration is needed
technically a cube, but regardless still applies the same lol
that should definitely work
are you using paper?
try it on spigot. createWorld() should be blocking IIRC
Yes, I'm programming in spigot but using paper as the engine
try to run it on spigot
Just FYI, Any#apply exist
maybe on paper the WorldCreator does async stuff or sth so the world isn't "finished" when you try to use it?
Sounds about right
Do someone now how to rename (change title) of opened inventory?
I've tried restarting the server, the world is indeed being created but that's all about it
[17:02:25] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.World.getBlockAt(org.bukkit.Location)" because the return value of "org.bukkit.Location.getWorld()" is null
The same thing
you have to call your "create" method again after a restart
I don't know kotlin syntax but maybe add sth like this in your create method, but before the return statement:
Bukkit.getScheduler().runTaskTimer(myPlugin, new Consumer<BukkitTask>() {
public void accept(BukkitTask task) {
if(Bukkit.getWorld(worldName) == null) {
System.out.println("World is not laoded yet... waiting...");
} else {
System.out.println("World is now loaded!");
task.cancel();
}
}, 1, 1);
then see if it actually says "World is now loaded" some time
maybe start the plugin before worlds loaded?
wasn't it an option in plugin.yml? (haven't followed the whole issue)
declaration: package: org.bukkit.inventory, class: InventoryView
oh this was added?
I've added the method to the main class and still the same thing
who the heck wrote those shitty javadocs
It used to work... Used to...
its always been a thing for like a long long time
no.
it was added very recently
it was added in may
it used to be setName
as I said, it used to be SetName
no
ok, well go look at old apis
declaration: package: org.bukkit.inventory, class: InventoryView
there's no setName
IIRC Inventory#setName() or sth existed but that was back in 1.8
unless it used to be in inventory holder
and just moved to the view
instead
either way, setting the name of an inventory has always been a thing
just where in the API was changed
it was definitely not possible in 1.16 and 1.19 without NMS
to set the name of the inventory?
to change the name of an already existing inventory
e.g. for animated GUI titles or shit
oh, yeah to change an existing inventories name that is true
@tender shard I just sent a string to the player with the world name and it works, so I think the issue is with generating the world for some reason... But why .-. It used to work perfectly fine
Thats fine... But I want plugin to be suported from 1.18.2. Its only in 1.20.1. Im not sure what canceling my event or just why I cannot move anyitems in menu and not even in my invnetory. Thats issue for me now
I just want make notification in inventory title to dont forget to save the changed kit, if its changed.
Need to figurate out some other way of reminder. Prorably with some item. Looks like in title is not possible
no cue. I really suggest that you return a CompletableFuture instead
and that future only completes once the world is "done"
why not make a custom notification for the player in question in the chat?
Just when he close the inventory? Maybe I should do it that way.
well chat is visible while in the inventory
My goal was this
well you can update the title of an existing inventory via NMS
I dont think someone will read it chat while chaning the kit
not overly difficult to do it
public static CompletableFuture<World> createWorld(WorldCreator creator) {
return CompletableFuture.supplyAsync(() -> {
World myWorld = creator.createWorld();
while (Bukkit.getWorld(myWorld.getName()) == null) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return myWorld;
});
}
this would probably work but it's pretty shit
depends how you make your notification
you could use buttons
also to continue with your idea on closing
you could make a notification in chat with buttons if they wanted to save it
If someone close inventory open another with save option? That will be anyoing xD
Oh you mean in chat
can the metrics class be obfuscated?
maybe? but why would you want that to be obfuscated?
sure
There is no point to make no option probably, he can just ingore that message. Just You didnt save your kit. Click here to save! whould be probably enought
saving a few extra bytes
you can obfsucate any class you like
idk why you are so obsessed with saving bytes
not just that, but literally no one is using a 56k modem either
or connection
well none that are playing MC
maybe they are making a plugin that's being used on the ISS
they have slow internet
they actually have decent speed on the ISS
People like to think larger file size means worse server performance
last time I checked they used remote desktop and couldnt actually access internet directly
meanwhile my plugins are all 1 or 2 MB 🥲
🥲
the internet has to be relayed yes, but this isn't relevant to the speed of the connection. The main reason is that internet is typically beamed to earth, not out into space
hm idk I read something on quora and IIRC an actual former ISS dude said the internet is horrible, at least couldnt be used to stream videos
Btw. thats remind me another question. If I want to link someone with player (some settings or what ever) and save that to HashMap is problem if I do HashMap<Player, String> or its better to do HashMap<UUID, String> ?
hence he brought a collection of DVDs
but that might be outdated, idk
but they live stream videos all the time
hmm you're right
maybe that dude was full of bullshit then, or the answer I read was from 2007
No, not really
you should always use UUIDs
No idea bout this worlds, it's really weird
you can also just use the Player object directly but you will have to listen to PlayerQuitEvent and remove them from the map then
in any case, you'd ideally use an IdentityHashMap and not a normal hashmap if you wanna go for using Players
oh and it'll break on shitty forks such as mohist
UUID will however always work
Thats what Im doing currently. I dont need that data if player is not on server so.
TL;DR whether using a player works depends on server software, it will not work on mohist
I'd use an UUID
it is quite possible that their personal computers are not allowed to use the same connection and or have lower bandwidth access then the government computers do
and this is probably where they didn't clarify
that might be true
I dont even know what is mohist xD Okey, gonana change all Player to UUID. Thanks. You every day learn something nuew
@tender shard I just teleported myself to this world and it actually actually works .-. But the plugin is thinking it's null: https://paste.learnspigot.com/heqatobone.rb
Mohist is a shitty software that allows to use both forge mods and bukkit plugins
and both only works half-assed
show your code pls
Anyway, I should use UUIDs so thats need to be changed
IntelliJ has a feature to replace every occurance of Player with player.getuniqueId() btw
It's kinda hard, but I'll try to show methods which are responsible for that
somewhere in the refactor menu
Thats perfect I will need to use that 😄 That will save some time
you need to wait a tick after teleporting
?
No, it's been working just fine before. I suppose to start the server and be teleported to this world once I join the server...
Ctrl+Shift+F6 i think
yeah you need to wait a tick for them to fully join
No idea why it doesn't work now, it just broke
yeah
but maybe it's only possible in IJ ultimate
I will take a look on that. Thanks a lot.
does anybody know if it's possible to use "variables" in javadocs, i.e. so that I don't have to write the same docs twice and be able to say "pls reuse the same javadocs as from the following method: ..."?
@link
doesnt actually copy the JD, i dont think thats possible inside the same class, but it points to the jd of the other method
Mby 🤔
Type Migration
but I don't remember if this actually works lol. maybe it doesn't haha
Not look likese what I want it 😄
Nwm, I will just change the type and I will get errors and just fix them
that looks correct. You can change org.bukkit.entity.Player to java.lang.UUID and then there should be an additional field that lets you say "what used to be player now is player.getUniqueId()" or sth
if I have this config.yml:
group1:
entry1:
message: "Hello"
entry2:
message: "Hello"
whats the best way to iterate through all entries?
will getStringList("group1")
return a list like this: ["entry1", "entry2"]
and then I iterate throw the keys?
watch out for "contains" as it takes in an Object, that means your code still compile if you check contains(somePlayer) but it just won't work
no, entry1 and entry2 are treated as path parts
you call getKeys on group1 and iterate through the configurationsection starting at group1
you need to know your config structure
ah ok thanks
getConfigurationSection("group1").getKeys(false) will return a list "entry1" and "entry2"
Thats perfect thanks a lot.
if you use "true" it'll return "entry1", "entry1.message", "entry2" and "entry2.message"
ah ok good to know :D
@tender shard
Example error:
https://paste.learnspigot.com/edudujotup.php
Method responsible for that:
https://paste.learnspigot.com/enafuvaxum.kotlin
yeah but that won't copy the description, does it?
"home.world?.getChunkat..." is getting the world. "home" is a home location, it is using Location class as a location so there is world saved in it
like i said i looked into it. It doesnt copy the description, and afaik it's not possible to copy the description of methods in the same class. it does just copy the JD of parent class methods if it's a @Override of a method without javadoc itself
sad
think ur out of luck
thanks anyway
I will just add a comment to remind myself to always update both
yea, id just forget, so thats not an option for me
my solution was to figure out a way to do it with varargs lol
but that doesnt always work
@tender shard
https://paste.learnspigot.com/enefasonoy.csharp
Here is some java code, should be easier for you to read
I will need to fix this manualy anyway xD
UUID p 💀
Event e 💀
It's got a world XD I can teleport to this world and all but my plugin for some reason can't see the world
what is wrong with that? 🤔
https://www.spigotmc.org/wiki/intellij-debug-your-plugin/ assuming intelliJ
shortening the variable name doesnt have any advantage, it just confuses the people reading your code
e is the standard name for event and p is the standard for player
some short forms are 100% acceptable
i usually use unicode for my vairables
I just learned to use that from some tutorials. But ye, it will be maybe better to make like player insterd of p.
my compiler breaks at anything beyond ASCII-8
final Player $@! = Bukkit.getPlayer(*test");
yep
i only name my unused lambda parameters
idk how to do it with the new one nvm
wym 'new one'
you are a human, you should use human friendly naming
It's old intellij in the tut lol
shorter var names dont make your plugin faster
Or mac version
ah it still works the same
how to make a mob my pet
just go edit configuration -> remote JVM debug, copy the line in the 'command line arg' part, and paste it in your start.bat
start server, wait for load, press the bug looking button
done
Yeah, I got it
good
just place a breakpoint
works like normal
btw
edit spigot.yml timeout
or server crashes after 60 seconds
vanilla mc dcs after 30
theres a mod but idk the name that makes client timeout longer
What about this thing:
yea thats good like that
thats just the hook for the server
tells java to listen for interrupts
Yeah? But where should I paste that? xD
wait how do you start your server
Windows batch file
Like from the folder
Can I use paper with it or not really?
Hmmmm can someone verify something for me. I wanna stop the breaking of an ArmorStand when the player has a permission asedit.disableCreativeBreak and when they are in Creative Mode (hence the permission name). Is the below snippet of code a good start?
@EventHandler(priority = EventPriority.LOWEST)
void onArmorStandBreak (BlockBreakEvent event){
//Disables breaking an ArmorStand in Creative Mode ?
if (ignoreNextInteract) return;
if (event.getBlock().getType() != Material.ARMOR_STAND) return;
Player player = event.getPlayer();
if(player.hasPermission("asedit.disableCreativeBreak")){
Block block = event.getBlock();
if(block.getType() == Material.ARMOR_STAND && player.getGameMode() == GameMode.CREATIVE){
event.setCancelled(true);
}
}
}
why dont you try it...?
how can i prevent a player from death?
who pays for ai nowadays lolbruh
you can literally cancel die
totem of undying
cancel the last damage event
just do a basic check
wrong
copilot student license 
That's funny xD
im a student and im not below using copilot
gpt and pilot are kinda useless the second you want something with more than 1 moving part
i tried once and never again
copilot is a good dev tool imo
it learns with you
so if you write shit code
it writes shit code with you
^
i just told yall im not using it
cause i ran out of memory
copilot is awful at resolving maven repos n shit
i was considering it
yep
but if it's still bad not sure i'll try it yet
AI will only write a part of code and not even correct
At least it makes a decent attempt at code
but you have to correct it often
Still faster
like what the fuck is it thinking
@smoky oak ummm
200% certainty
No idea how you did it but you've got some magic powers lol
I honestly think knowing regex helps more than using copilot
I can now create islands and everything with no issues xD
🤷 ui didnt change much
you can do some crazy stuff
what it does
im def jealous of your 1440 px screen
playerinearct
They're affordable
or smh
yea not for laptops
I think I paid like 280 bucks
PlayerInteractEvent
my laptop has a 1440p screen and it was like 1k
got no gpu though
ah well
but it's an lg gram 17 inch
i think PlayerInteractEvent is even cleaner or what are u making smh
this ain't spigot
mine is like 2kg and is like a mid range pc in my pocket lol
i cannot stand not having to do anything
what are u making lol
1.5kg at most
playing with minestom
i mean 2060-equivalent GPU and 12 core at 4GHZ
something tells me you have a weird power config
mine can't run warframe with everything on min
because of the resolution
and that game can run on a potato
but it's a good coding machine
ive got a 1920 by 1080 at 144hz
ddr5 ram, 1440p screen
really nice color calibration
backlit keyboard
huge battery and shitty thermals 
oh yea im going to get a better color screen next time
also supports 2 nvme drives
That's exactly why I bought this monitor
I had a shitty acer aspire
you dont get to talk shitty thermals to my 95°c GPU tho
with a 6-bit screen
cpu idles at 80C
I think they used spit instead of thermal paste
Yeah I got an lg gram 17z90q
Gigabyge 5
@smoky oak No idea how debugger works but now it's creating islands in the normal world? Without debugger it doesn't work lol
thats not how a debugger works wtf
So wth
something tells me you're having inconsistencies with world load speeds
honestly @echo basalt im surprised my cpu's not cooked yet. I do get the occasionally BSOD when im running UE5 games for some reason tho
Now it's not working at all, debugger is empty, even tho there is a huge amount of errors in the console
I've ran my desktop ryzen cpu at 120C a couple times
im more surprised that for some reason games brick my os
when booting minecraft 
like why the fuck do you bluescreen if and only if im in deep rock galactic lol
I had a defective AIO and the thermal paste was dry
Any ideas how I could fix that?
I'd boot the game and like 3 seconds later my pc would just shut off
ouch
You'll need to measure and add tolerances to your code
no clue exactly what you're doing
but when playing with worlds, there are tolerances for everything
I barely have any timing tolerances on my skyblock core because I'm not using .mca files but there's still a lot of tuning when managing worlds
intolerances to be specific
well
When playing with paper, world IO is done async and there's no way to know when it's done
The event fires and then IO starts
cant you run both and print out timenanos before and after?
@echo basalt I can share my repo with you on github so you can have a better look if you'd like to. There are just 2 classes responsible for creating the world (IslandManager and IslandCore(main, which is simply calling IslandManger)), would it be okay?
containsKey before get -> get & null check
if i spawn particles using a parametric equation and a bukkit runnable, how can I account for the direction of the player?
https://paste.md-5.net/zegamunive.cpp
something something multiply with player location direction vector
been a few years since i touched vector math
put xOffset, yOffset, z in a vector and rotateAroundY by the player yaw
hm i tried that but maybe i didnt do it right
no clue what effect you're trying to make but there's probably an easier way
yea now run it a few times then check the other variant
btw for easier readout, subtract start time from end time before displaying
by the way
do not spawn more than 25k particles at once
otherwise it'll get hacked up
ik ive learnt that the hard way
new Vector(xOffset, 0, z).rotateAroundY(Math.toRadians(player.getYaw()))
yea now for my question
type deal
crashed my test server a few times lol
oh i was rotating using the yaw in degrees
just needed to make it radians
So I should add some timing to the code so it delays the creation of the world? Or am I understanding that in a wrong way?
ye
Hm
socketKeepAlive(true) is what I found on SO
So the world works now, but it works only after creating it and restarting the server (if I try to use it after the first start and creation of it - it won't work). How can I solve it?
sorry to say its just me being invis with armor on
nothing special there
lemme check
in f5 it makes you transparent to yourself I think
look pretty cool though
Hello, i have a question, i would like put "serial number" on items wich will allow me to trace them. Do you think NBT Api is the best option te create NBT tag in items (server 1.8.9)
in 1.8.9 i would say so yea
yes, on 1.8.9 you'd use NBTAPI
on 1.14+ you could use the included PersistentDataContainer api
okok thx for your answers 🙂
Could I get support here for maven? I have a plugin, common and v1_8_r3 module. For some reason when compiling I get a build failure (see image). In my IDE I have reloaded the maven project but it does not give any errors (see second image). These are the dependencies in my plugin module pom:
<dependencies>
<dependency>
<groupId>dev.bloedarend</groupId>
<artifactId>common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>dev.bloedarend</groupId>
<artifactId>v1_8_r3</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
Am I missing something?
cant seem to find the new way tho
pretty sure u just need to do it without try-with-resources
like how was said
its closing it right away
no
If it helps, removing those lines and compiling the plugin, the opening it in winrar, only the plugin module is actually there
sounds like they are just not being shaded then
How do I shade them?
I have that
Have tried this too
well with the shade plugin & scope on compile it should work
build and show build log
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
log sais its included
this is inside the jar that was compiled
just a plugin folder
not the other modules
I am having some issues with line endings in the craftbukkit project. When I write code normally, there doesn't seem to be any issue, but when I run makePatches.sh, it changes the line endings of every single patch file.
It looks there is code to handle these line endings in the makePatches script but I'm not familiar enough with patches to know exactly what is wrong. Of course I don't want to make a pull request with 500 changed files when I only changed 3 or 4.
hm can u see ur's pom's?
sure 1 moment
mongo looks pretty good
how does creating a database look like?
by just getting it
its create on demand type stuff
tbh in most plugin environments an rdbms would probably be better than like
a document db
😭
that's cool
i really like this but also i don’t because i always have a typo somewhere and it doesn’t error out, it just makes a new collection
yup it does xd
i like it as well though
aint gotta worry about creating it
Children
- https://hastebin.com/share/eyoyonogen.xml (plugin)
- https://hastebin.com/share/qozovudeme.xml (shinobistriker-api)
- https://hastebin.com/share/kogakuxuze.xml (common)
- https://hastebin.com/share/nuqoxuqama.xml (v1_8_r3)
firsly i'd clearly add scope: compile to every dependency thats supposed to be shaded. just so its clear. pretty sure its not absolutely requiredbut its a good thing
id also move all the shading to ur plugin pom
and only keep provided shit in parent pom
cuz rn whats happening i think
ur shading alll this kotlin shit into all the modules
which u then all shade into plugin
causing all these overlaps
which should be cleaned up nicely ofcourse. but i think something might be going wrong there
I don't think it's shading anything into plugin either. Also I'm using a library called BoostedYAML (which requires shading) in multiple modules, so I have the dependency and do the shading of that in the main pom.
why
in the end u only need the shading into ur plugin
the other modules can just have it as provided
I've put the shading into the build script for the plugin module
and set my own dependencies as provided in every module other than plugin
and I can add provided to kotlin libraries too?
i dont use kotlin. but i assume so yea
can u show the log again?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
sure
is it possible to remove all bossbars from a player? for example from the wither / dragon?
https://hastebin.com/share/xacozakoqe.lua still not shaded
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
https://hastebin.com/share/enolugiyit.ruby still not working
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
do you have the shade plugin?
it's named like this
I do
<!-- Maven shade plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<relocations>
<relocation>
<pattern>dev.dejvokep.boostedyaml</pattern>
<shadedPattern>dev.bloedarend.plugin</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
protected String enchant;
protected int enchantLevel;
public EnchantFuncs(String fullEnchant){
String[] split = fullEnchant.split(":");
this.enchant = split[0];
this.enchantLevel = split.length > 1 ? Integer.parseInt(split[1]) : 1;
}
public String getEnchant(){
return this.enchant;
}
Random question, at getEnchant() is this even required anymore as since ive already called EnchantFuncs
or should I still use this.enchant for safety
Yeah I was thinking the same, I wanted to double check however just incase
I shouldnt run into issues tho as im not using same variable names
Also I don't know if this is helpful but it only says dev.bloedarend for the parent and the api module
Fair
speaking of, what does final actually do
Ohhhh, gotcha
I was thinking that it entirely locked it or smth
Where lets say its a hashmap, you cant add onto it
You cant call .put()\
Thats actually useful
So then lets say:
final int a;
a = 0; --now its 0
a = 1; --still 0
This would be correct then right?
Since the variable wasnt assigned yet
Yeah ide would cry, this was just a question
I like learning lol
how i can set a player like hes swiming? (i already did it with player.setSwiming(true) but it changes immediately, how can i prevent that? iirc it has an event)
this is cause you're actually assigning it after
no, you can either use an immutable wrapper, or Map.of(elements);
but final only means you can't modify that field or you can't override or extend final methods and classes
Gotcha
Also, random issue, Named my plugin something dumb
Wanna change it
Now IDE is freaking out cause I renamed files
And I tried editing the pom as well
Am I missing something
Lettme reload
Oh nvm it fixed lol
just look into .idea for deleted modules
so you don't have problems later on if you wanna rename onto that
@tall dragon the shinobistriker-api module was empty and after adding a class into it, it was also shaded but with a different name
I originally copied this project over from another plugin which only had a plugin and "discordo-api" module. Maybe something went wrong because of that?
honeslty no clue in ur case lmao
rip
^
nvm, its EntityToggleSwimEvent
hey, any ideas here? To fix my line endings problem?
so this is gonna sound really dumb
but renaming the sources folder from kotlin to java fixed it
😄
lol
I would really like to use ServiceManager but this makes my code kinda untestable, Bukkit.getServicesManager throws an exception
anything I can do about it?
?paste
Can someone review this class I created for enchants, and tell me how I can improve it if needed
put spaces before your { s 💀
why do you have nonstatic methods interacting with a map in a static field?
that enchantmentList should just be an instance field, not static
I have 0 clue actually
Thank you for porting that out
Hold on wait I remember why I did that
lets say I initalize all the enchantments, and try to call new EnchantManager from another class
Are the enchants still gunna exist in enchantmentList
don't call new, just create one
Wdym create one
why would you create a new one? if
create a single one, and use it in multiple places
or if you want to abuse static, just make all the methods static
So should i just make a static method inside of a setup class, called public static final EnchantmentManager
god no
This way its callable outside of the class, without using new
also, why does that inner class extend the EnchantmentManager
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
so it can run getEnchant, to obtain a Enchantment base
?paste
why isnt the EnchantmentBase a field there instead of the string identifier?
IDE was screaming at me for it
No enclosing instance of type 'me.emerald.plugin.resources.main.EnchantmentManager' is in scope
I would have kept it in the same clas otherwise
where is Enchantmentbase? is it a nonstatic inner class?
abstract class
for the enchantments themselves
a top level class?
Yes
shouldn't have any issue with putting it as a field in EnchantFuncs
For some reason it does
screenshot pls, I want to see where the issue is
k
Now IDE is saying Found problems related to 'me.emerald.plugin.api.EnchantmentManager.EnchantmentBase'
With 0 information
I assumed it was
is EnchantmentBase inside EnchantmentManager?
Oh wait I see what you mean now
and its not static?
No its not a top level class, I thought you meant my new version of it
the seperate class for it
EnchantmentBase should be a static class if its inside another class
That seems to have fixed it
I am writing a plugin like skywars, and I have the distribution of players by their islands and the issuance of a gamemode spectator, but some players do not have bodies and hitboxes
?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.
is there a way to keep your sqlite connection alive after a .execute?
save it on a field
wdym?
DATABASE_CONNECTION is a private static variable
but after 1 executeUpdate() it'll disconnect it
I just use
for (Player player : playerlist) [
player.setGamemode(Gamemode.Survival);
]
Only head, without legs and body, without hitbox
any errors? what do you expect the code to do?
because they are in spectator mode
are you using paper or something
no, I have some kind of bug when I put players in survival mode with my plugin, some players have no body and hitbox
?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.
if(gameManager.getGameState() == GameState.Active){
for(Player player : playerList){
logger.info(playerList.toString());
player.sendTitle("Одиночный режим", "Тимминг запрещен!");
player.setGameMode(GameMode.SURVIVAL);
player.getInventory().clear();
player.teleport(spawnloc.get(indexloc));
indexloc++;
}
RandomItem();
}
is linkedlist faster than arraylist for iteration?
@Override
public void onDisable() {
ChatBridge.sendMessageToDiscord(":octagonal_sign: The server has stopped");
discordBot.shutdown();
}
RestAction queue returned failure
I assume this is shutting down my bot before the queued message is sent to discord?
The message still went through but I don't like this error. How could I fix this/make sure the message goes through before shutting down the bot?
my assumption is correct?
ok
can I just paste this in my discordbot.shutdown() method?
currently I just have jda.shutdownNow()
ok thanks!
yep, onDisable calls discordBot.shutdown() and that snippet is now in discordBot.shutdown()
xd ?
i never saw your await shutdown
and complete is totally fine if you are running something on application shutdown
as it will block the thread for request (it doesn't matter as application will be killed anyway)
ok well my project has been fully tested. should I push to github now or wait for a consensus here? lol
oh cool
posted it
thanks
I've been suffering for an hour now, why is the text not displayed in the bossbar? it updates the bossbar and sends a message to the chat, but for some reason there is hi in the chat (for testing), but not in the bossbar
Component result = Component.text("");
List<String> strings = new ArrayList<>(){{
add("ɱ");
add("ɤ");
add("ʥ");
}};
// generate horizontal offset
result = result.append(createHorizontal().font(Key.key("minecraft:default")));
Component offset = Component.translatable("space.-1").font(Key.key("space:default"));
Component newLine = Component.translatable("space.-1025").font(Key.key("space:default"));
for(String string : strings){
Component text = Component.text(string);
result = result
.append(text)
.append(offset)
.append(text)
.append(offset)
.append(text)
.append(offset)
.append(text);
if(!string.equals("ʥ")){
result = result.append(newLine);
}
}
player.sendMessage(result);
return result;
}```
String text = "space.";
if(horizontal < 0) {
text = text + "-";
}
// was "hi"
text = text + (16 * Math.abs(horizontal));
return Component.translatable(text).font(Key.key("space:default"));
}```
hi, i use a like this system for my guis. https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
i want make a confirmation gui with completable futur. How i can do?
let me rephrase that
can i call a constructor as the not-first instruction in another constructor
Could you provide an example please?
"not-first" is a bit off putting
basically i want to do this
constructorA(Player, someStaticData){}
constructorB(Player, CommonCasesEnum){
switch(CommonCasesEnum){
case EMPTY: this(player, null); break;
case JUMPER: this(player, List.of(Abilities.DOUBLE_JUMP); break;
...
}
}
Neither do I, youd have to make a check with an inline statement or create a function to parse the static data
actually i might have an absolutely aboniable idea
laughs in sith lord
yea that was my idea
just cuz its the first argument doesnt mean i cant do stuff inside
wait a moment
i dont even need a helper function :D
welp time to copy down 200 effects
im not looking forwards to this
by the way, is there a way to generate pairs of values somehow?
like so that they're close in source code?
the first entry is a list of effects and the second a list of their strengths
i mean i could do something absolutely cursed a la
object secondary_values(God patron, boolean effect){
switch(patron){
case 1: return effect ? List.of("String","String") : List.of(1,2);
}
}
but
you know
put the abiltities in the CommonCasesEnum maybe?
basic coding principles
that'S not a bad idea, any simple example coming to mind?
public enum Abilities {
JUMPER;
}
public enum SomeEnum {
EMPTY((Abilities) null),
JUPITER(Abilities.JUMPER);
private final List<Abilities> abilities;
SomeEnum(Abilities... abilities) {
this.abilities = List.of(abilities);
}
public List<Abilities> getAbilities() {
return abilities;
}
}
public static class SomeClass {
private final List<Abilities> abilities;
public SomeClass(SomeEnum someEnum) {
this.abilities = someEnum.abilities;
}
}
something like this
pretty sure thats still normal java there
oh not using enums at all you mean
took a moment to register
I... just realized all those would be static and initialized when first accessed, wouldn't work with my approach
I need a reference to player
i can probably work around that but its gonna be a pain
You can have it as an interface / abstract class / a factory of some sort
This is my constraint class
yea similar idea, but i need more than 20 minutes to call judgement if i want to do it like that
Not the best but I properly sanitize stuff
ah I'm clearing out my values on the playerLeave event
and init on playerJoin
the instances are interchangeable, the player is the lynchpin
You can have an AbilitiesProvider interface that's just a factory then
and a registry for those
I'll see if i can do it like this, seems cleaner. Thanks for the advice, Illusion
I can just do a mapping player->abilityProvider
yeah something like that
public interface AbilityProvider {
Ability provide(Player player);
}
I'm keeping a singletron in my plugin main class cuz some bukkit stuff requires it, easier to access there
icky
i mean
So yeah convert to an interface
its not getting lost lol
my reasoning is that since plugin's a singletron anyways, i dont need to keep references to it
Is this the correct way to connect to a sqlite database and then create a table?
// Database
try {
connection = DriverManager.getConnection("jdbc:sqlite:" + getDataFolder() + File.separator + "data.db");
try (Statement statement = connection.createStatement()) {
statement.setQueryTimeout(30);
statement.executeUpdate("CREATE TABLE IF NOT EXISTS Reports (reportID INT, reportedPlayerUUID TEXT, reporterUUID TEXT, reason TEXT, timeStamp TEXT)");
} catch (SQLException e) {
getLogger().severe("Error executing SQL query: " + e.getMessage());
}
} catch (SQLException e) {
getLogger().severe("Error connecting to the database: " + e.getMessage());
getServer().getPluginManager().disablePlugin(this);
}
it would be more or less the same for mysql right? just replace the connection url with the sql database credentials
well
That results in duplicate code
Time for an ✨ abstraction ✨
For example, what would your "database" class look like?
could you elaborate please
This is just in my main class in onEnable
We're going to write a more.. generic way of handling data, so that implementing a new database doesn't require a ton of effort
yup, you can make a custom class that handles pairs
Alright
So let's just start by writing an interface that serves as a template for how we're going to handle this data
like i know youre talking to snow but it feels like youre talking to me cuz i just thought how crap my code is lol
public interface ReportDatabase {
CompletableFuture<Boolean> tryEnable(ConfigurationSection section);
CompletableFuture<Report> fetchReport(int reportId);
CompletableFuture<Void> saveReport(Report report);
CompletableFuture<List<Report>> getReportsBelongingTo(UUID reportedPlayerId);
CompletableFuture<Void> deleteReport(int reportId);
default CompletableFuture<Boolean> contains(int reportId) {
return fetchReport(reportId).thenApply(report -> report != null);
}
}
This is my guide on completablefutures if you'd like to see
Anyways we can then create an SQLQuery enum and an abstract sql implementation so we can later just implement our drivers
man you should start ur own blog
public enum SQLQuery {
CREATE_TABLE,
FETCH_REPORT,
SAVE_REPORT,
GET_PLAYER_REPORTS,
DELETE_REPORT,
}
And a basic impl
I'm going to need my hand held 😂, I'm only 2 months into java
public abstract class AbstractSqlDatabase implements ReportDatabase {
private final AtomicReference<Connection> connectionReference = new AtomicReference(null); // You can switch to a connection pool if you'd like
protected abstract Connection createConnection();
protected abstract Map<SQLQuery, String> getQueries();
protected abstract boolean enable(ConfigurationSection section);
@Override
public CompletableFuture<Boolean> tryEnable(ConfigurationSection section) {
return CompletableFuture.runAsync(() -> enable(section)).thenCompose(unused -> createTables());
}
...
}
And implement our methods
I can't bother writing a full driver
but your final driver will look something like this -> https://github.com/IllusionTheDev/SkyblockCore/blob/2.0/SkyblockCore-Common/src/main/java/me/illusion/skyblockcore/common/database/fetching/sql/impl/MariaDBSkyblockDatabase.java
public ItemBase(String key){
this.key = key;
this.item = generateItem(null);
this.recipe = createRecipe();
}
Since this.key and this.item is running first, can createRecipe() access them or no
sure
alr
If I wanted to create pagination, what is the best approach for keeping track of the current page? I can store it in an item's name, lore or pdc but I think, although haven't tried, I can save it in a custom inventory holder. Is there a preferred approach? I was initially thinking of using a custom holder with a hashmap of metadata that I add to it, not just limited to current page number of course.
I created my own inventory framework for this so ill tell you what I did
I just made a new class for each gui to store information on that gui
And for pagination, pretty simple, just a protected int variable called page
public InventoryFW(int rows, String name){
Bukkit.getServer().getPluginManager().registerEvents(this, Main.instance);
inv = Bukkit.createInventory(null, rows * 9, name);
}
Old code mind it
But it works like a charm
Otherwise, your best other approach is just creating a class for each ui seperately, and making a call for it, and doing the same thing
i would use pdc
Wait pdc works with inventorys?
I never knew that
Only thought it worked with itemstacks, and entities
It doesn’t work with inventories
Oh welp :P
Pagination works with items, so if you clicked previous or next, it's clicking an itemstack.
that pdc 😛
Gotcha
In my oppinion however, why set pdc for an items page instead of just a variable
Just seems quite odd
Do i use Hex Color Codes for a Custom Color?
Custom color for what
Chat maybe...?
You can, sure