#help-development
1 messages Β· Page 959 of 1
just use spark
if u want advanced memory info, u need to use JDK mission control, mat or visualVM
Yourkit
with spark u can get info about plugins processer usage
what exactly is the problem anyways
Why reinvent the bicycle? Use existing programs
We're using lossy hashing for culling
so basically - rounding?
Yeah but encoding a whole location in a long
So not something like Objects.hash((long) x * c, (long) y * c, (long) z * c)?
Nope
Because we want to fine tune exactly the losses
So we can define how many "steps" are in each axis
And keep the pos xyz the same
The whole point isn't to avoid collisions
But to use them in our favor
Force a collision if it's within a certain range
so something like
fun hash(x, y, z, c) {
xi : int = x * c
yi : int = y * c
zi : int = z * c
ret xi & ((1 << 26) - 1) << 0
| yi & ((1 << 12) - 1) << 26
| zi & ((1 << 26) - 1) << (26 + 12)
}
ok, for some reason I can't save persistent data using my setup
so while the server runs im saving it into a hashmap, and then onDisable I save all of that to each players pdc
however when i restart the server it doesn't load the data
anything wrong with this on first blush?
Yeah but xyz are encoded too
I mean surely the MSBs aren't required?
still doesnt working
- even your algo culls them at 0x3F_FF_FF_FF (=
(1 << 30) - 1) for x and z and 0xFF (=(1 << 16) - 1) for y
Oops, forgot the bitshifts before OR'ing them together in my pseudocode
private static final AttributeModifier attackSpeed = new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 0, AttributeModifier.Operation.ADD_SCALAR);
``` if I want to add attribute item, will it set attackSpeed to 0?
and than that:
idk, I feel like it won't do anything whatsoever
I'd go with https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/AttributeModifier.Operation.html#MULTIPLY_SCALAR_1 and -1 as the scalar instead of 0
As soon as you add a modifier the base modifiers are gone
So adding 0 to 0 should result in 0
Althought now that I think about it that'll be apllied to the players base attack speed
Which is 4
So you probably want -4
I mean multiplication with 0 will defo get you to 0 so you'll completely avoid everything else
True
Depends if you want to cancel our attributes on armor ig
And attributes on the player itself
Also note that at 0 attack speed the player will never raise the item when switching to it
tool-assisted speedrun
Hello !
I'm designing a plugin to "freeze" the state of blocks, i.e. prevent them from growing, and I'm trying to cancel the growth of cactus, sugar cane and other plants.
These trigger BlockGrowEvent events, which offer two methods:
getBlock(), which returns the block before the growth.getNewState(), which returns the new block
The problem is that these two methods concern the block that has just appeared, i.e. just above the block I've frozen, so I can't carry out my check on the stored blocks, which shouldn't be growing. For example, in the case of the cactus, getBlock() will return air, and getNewState() will return a cactus. And there are no other methods. Of course I could use the getRelative(0, -1, 0) method to retrieve the block below and that would work for the cactus and the sugar cane, but that would cause problems for the wheat, which stays on the same block and calls the same event.
It's a shame, because the BlockSpreadEvent, which works in the same way, offers a getSource() method... Why isn't this the case with the BlockGrowEvent, or why don't the cactus trigger the BlockSpreadEvent instead? So, does anyone know how to efficiently retrieve the event's origin block, the one from which the extension is added, without having to check the item's previous type and add conditions?
Thank you very much!
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
I guess it's a good challenge
well good thought. you could just PR it as olivo said. but if you dont want to PR, you will have to distribute your system over the two events
not sure how its handled serverside, but my first thought would be that it could be a challenge to get the source of melons f.e.
maybe its clearer than i think it is
I'm not sure I have the required level, but I can always try π
But as you said, it might be complicated to find the origin of plants that can spread horizontally like melons, especially if there are several side by side
i need to use com.github.koca2000:NoteBlockAPI:1.6.2, it's not in mvncentral, only in jitpack. is there any way to use the libraries plugin.yml feature to do this?
like can i add an additional repository somewhere?
exactly, but maybe you find the origin just in the code
you'll have to see
From what I've read, it's a good way to make your server explode π
just stay lightweight
Oh wow, to contribute to Spigot I really have to give my physical address and phone number? That's pretty intimidating π³
yeah because you have to sign a contract
I'll add that to my CV
could be the beginning of something great π€·ββοΈ
I mean to contribute to libGDX you have to print out a text file, sign it, scan it, send it as a PDF inside an email and then send the piece of paper via snail mail.
So spigot certainly is not the worst one out there
yeah, I was like "okay?" when I first read it. Seems like it is only for larger contributions though
oh libgdx is java, i thought we were talking about some niche c library
https://github.com/libgdx/libgdx/blob/7c6db62bdc8d39989be3ad7e06cac641fdb268b4/CLA.txt#L12-L15, well it is optional but I did include it anyways for the giggles
there's a different CLA for corporate entities, which is something I haven't seen before either
???? why does the actual folder disappear?
im trying to upgrade from ecplise to intellj
and the folder shows up for a sec and then goes woop bye bye
id say remove that eclipse nonsense
which folder?
src
they seem to not be using maven or gradle from the looks of it
this shows up for a split second
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
nope, go use maven or gradle
im trying to follow this tutorial
Using either maven or gradle might be best practice. I'd say you have your visibility options wrongly set up
But since I am a hardcore eclipse enthusiast, I cannot help you beyond that
what even is maven
I mean at the end of the day it usually boils down to whether you hate having lots of lines or not
this tutorail that says "create a blank spigot file with maven" doesn't rly say much about it
whether you want to have an awful lot of gradle files
unless im missing something
have you heard of make? It's that for java, but 1000 times better
I wouldn't recommend that tutorial, there is a tutorial for maven and spigot and IJ though
literally the exact one im using
just copy the pom.xml, change it and call it a day
oh you previously linked to a different page earlier
tbf idk what any of this is
In that case you are all set!
but thanks
its just a build system, like for dependencies and stuff
it worked
kinda
is there a way to generate a proper pom.xml file
cuz idk what to put as the headers
headers?
what did you get?
well just create something along the lines of
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>project</artifactId>
<version>1.0.1</version>
</project>
it needs like a project thing which I could add but I assume theres a better way than manually adding that and making sure its all right
just copy my project tag, never seems to change
lovely bunch of chickanery, but if it works
please also use a gitignore, well if you put it on github atleast
meh, it's only required if one does version control
true
i just make a template once and use gh repo create name --template=path", github cli for the win
how do I make it so that it outputs the jar directly into my plugins folder
I only create a repo once a month or so so I never bothered to streamline the process - but I also have enough repos that I can copy & paste what I need and know where to find what I need
I think mfnalex might have a guide for that somewhere
google for <outputDir> or somth
see
did any of you guys tried to get the generic type of a list in this context?
fields carry generic info assuming nothing deletes the attribute from the class
theres type erasure
Why
i'm upgrading my config system
ArrayListMultiMap π«Άπ»
wheres my intellj code highlighting?
Are you saving empty lists?
nope
Empty like it has string but no values
there is value
could call getClass() on an element if you're lucky
After compiling, this will be literally a
Map<Object, List<Object>>
->
Map<Object, List>
->
Map<Object, Object>
->
Map
You end up with a Map with completely unknown types
actually it's not true for Field
Just do nothing if empty otherwise pretend itβs a List<Object> and save individual keys as their respective types
field.getgenerictype returns the class type
that's a solution, it's just a bit slow
isnt Field::getGenericType() for the field type itself
yup
Whatever it is querying with getGenericType is probably slow too
you cannot ask a Map what its generic type parameters are
i guess it doesn't matter hmm
i mean this works
π
Or use kotlin, it probably has something for this
you know something we dont know?
is my dependency not setup right? I dont get autocomplete or anything
:o ParameterizedType is a thing? ig it just asks the jvm
Why are you manually importing stuff
thats what it said to do
Idk I just used what redlib had :p
if I know switching would be such a pain in the ass I woulda just stayed with ecilpse π
its a good thing to get rid of eclipse
You have summoned the wrong person
people will probably start throwing stuff at me now
especially geol
Well pretty much only geol and perhaps elgar
eclipse is good, otherwise our intellij overlords would think that community edition shouldn't exists
dude I know
dunno how good eclipse is now, ive only used it in the very beginning like 3-4 years ago
its just not doing that
Take a picture of ur full IJ window
Is your classpath even set up correctly?
Eclipse hasn't changes a bit over the last few years - at least not in a capacity that I'd be praising it for
maven uses src/java too right?
src/main/java yes
π€·ββοΈ
This is an issue with using the wrong source directory as JanTuck detected
do I have to change the folder
create a proper package structure
Yeah, just dump everything in your "src" directory in "src/main/java"
unrelated.
ok that worked
ty guys
why does intellj not like when I use var
eclipse was totally chill with it
Check ur java version in project settings
event.getEntity() ALT + enter + enter
?
yeah ik I can change it but I dont wanna
wait a moment
What is ur java version at
Booo var
You'd need something like https://github.com/Geolykt/EnchantmentsPlus/blob/0d1a07d2a1454673dfe5a5711b6ec70f8a516389/pom.xml#L287-L295 in your pom
Maybe java 8 was better
ew
U need jdk 10 or newer for var
yay it worked
var is big problem
Wanna see my Java 6 project?
or switch to kotlin and get var and val for free π
maybe im built different
val > var
I ... don't want to know what you all copied
idk if you considered that
as in?
the part that was highlighted
uh ye..
whats val
People are usually not smart enough to figure out it belongs in the plugins block that they need to create
final var in kotlin
Just a final var
guess im super smart
i already had that tho
i believe lombok also has val but that would work with a compiler plugin
gif not working
she
real developers use real variables
U can write getter and press ALT + ENTER + ENTER
Yeeaaaaaaaa
Option + Enter for Mac
im above the average programmer
real developers dont write types twice
go use python
real developers dont need to use good principles
nah go or c++
Be C# and do it backwards
real developers don't spend their entire day on the spigot discord
Real developers use keyboard shortcuts
MyObject object = new();
real developers go touch grass once in a while
guess we aren't real developers then π
new MyObject() ALT + ENTER + ENTER
or var object = new MyObject() π
yes I know
c++ just be like MyObject object, i love it
i believe i scared everyone away by mentioning
Yeah but that feels less cursed than new();
i use it on fields, quite reasonable
i'm starting to like it over java
YOU SAY WHAT
wouldnt ever touch c# if i didnt have too but i just like it
I was boutta say...
Some things do be kinda nice
it has structs
i can sleep happily if i know i didnt waste time on a heap allocation
Getting those fancy $ββ strings up in here
meanwhile we getting weird ass string templates
cuz they cant alter the lang too much
string and double and something?
no like placeholders in text
whadda hell
be glad you dont have to use printf
Cool
$βMy name is {name}β > whatever java is getting
i have no idea what the problem is
since it wont even have the common decency to give me an error
Muh cpu cycles
string processor would still have to do it at runtime
wouldnt be surprised if it generates the code for it at runtime
lambdas do that too but anyways
string concantenations do that too
"a" + "b" could turn into StringConcatFactory.concatSomethingSomething
~~ C# operator overloading also kinda nice~~
AtomicInteger largest = new AtomicInteger(0);
json.keySet().forEach(key -> {
String str = stripKey(key);
if(!str.equalsIgnoreCase(p1.getWorld().getUID().toString())) return;
largest.set(Math.max(largest.get(), Integer.parseInt(key.split("\\.")[1].split("\\.")[0])));
});
return largest.get();
look at it
it so lovely
well this wouldnt, but it would if youre using variables
it saves so much space
Yea
largest
the Atomic stuff is annoying af
in kotlin, it works fine with Int but wraps your int in the background π
new AtmoicInreger() is equal to new AtmoicInreger(0)
Congradulations u save 0.0001 seconds
singleton array or effective final w var
Man let me define my Atomic Integer
Ok
int[] o = new int[1];
//or
var b = new Object() {
int ref = 0;
};
b.ref //access
fr
wondering what rust does
explodes
huhhh
Wait canβt you just use Integer
Is it your problem?
is that effective final?
Ah right because itβs immutable
yes
MutableInt when
never
(this is supposed to be HELP development right?)
Actually thatβs probably a thing
used to
just click implement methods
No one really cares unless someone is asking for help
ask away yk :P
im the one asking for help
Click on CommandExecutor
Then click alt enter
Select implement methods
but it worked before
thats the tutorial I followed
intellij is smarter
alright uhh
I hit implement methods and I just created a copy of what I had
I deleted that and now it works
very smart intellj
Cool, so problem solved
Or indentation
Anyways @ivory sleet , Completeable futures, yay or ney?
idk
so intellij just fixed it
Sure
obviously yay
Well thatβs less yay
cf everything
they're cool I suppose
i mean structured concurrency api is gonna be neat also
I still remember the guy who thought he could use CFs whenComplete or whatever to have it run on the main thread
it simply looks a bit weird, might also want to try out virtual threads
if im saving data using onDisable theres a chance that it wont save in the event of a crash right? Or do I not have to worry about that
I mean look at this, its epic, lambda + completablfuture is epic
Depends on ur data if u want to worry or not
I just wasn't sure if usually it gets called anyway
It doesnβg
alr
I wish there was a CompletableFuture#join that also deal with exceptions
You wish
Yes ik try catch but blah
add an .exceptionally first before joining? or doesnt that work?
Exactly!
Is completable future equal function?
get()?
Idk I just made a janky wrapper that adds a join(BiConsumer<Exception, T>)
makes him deal with an interrupted ex
Get throws a checked exception
yea
ive never found that exception to be useful
its useful
The only reason i used completable future was cus i wanted it async β οΈ
because it allows for async things to cancel appropriately
anyway
hmmye..
get() throws ExecutionException
anyways good night
Everything throws an exception
event good night
Exception in main thread: Couldnt sleep
I believe so
Wouldnβt this run async as well then
why u checking valid 2 times
use else
boilerplate ftw
probably
implicit else then
Smh
Just put a return in the first if
How i can do it initialize on plugin start and only one instance
private static ScheduleManager instance;
public static ScheduleManager getInstance() {
if (ScheduleManager.instance == null) {
ScheduleManager.instance = new ScheduleManager();
}
return ScheduleManager.instance;
}
private ScheduleManager() {
}
????
or just init it in ur onEnable?
yea
Look here for an even simpler one
then call initialize in your plugin onEnable()
How would i keep a specific item in a specific slot? (basically a menu item)
It`s for classes without parametres ?
cancel the move events
what event would be best to actually put the item there
initialize inventory when u get it
write class which contain inventory
Maybe even the drop event
sorry idk enought about bukkit to understand what ur saying
You need to put things in your inventory once?
We donβt like inventoryholders
I just need to make sure its always there
why
ig i could just do it on player join
Heres all the inveory events
Future Reference
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/package-summary.html
public static void closeAll() {
Bukkit.getOnlinePlayers().stream().filter(p -> p.getOpenInventory()
.getTopInventory()
.getHolder() instanceof MSInventory)
.forEach(Player::closeInventory);
}
?gui
i got grilled for using em to
Click and drag are generally all you need
That said I never use drag and things work fine
so much text, im dying
read it i will help you design proper gui
Yep
here comes the article
holy embed
Is it a memory leak problem?
Itβs a cpu time problem
Oh
not sure if thats possible
i mean to drop if you already cancelled the other events
Hotbar π€·π½ββοΈ
I need to rewrite my code xd
hotbar yes, but the topic was menu items
()
Yes
A slot can be in the hotbar
And can be clicked as a menu item if setup as such
oh god
i have to pay
fck
man
why didnt i go to bed
i wouldnt have thought avout the server bill
is there an nbt data library
yes but why
?pdc
no I want to change the nbt data of something
Yes
not just store data
What NBT data
What data?
Everybody be askin the same question
in this instance the player of a player head
but id like to know how to do it in general
Use the API method for that
in general you don't touch the nbt directly at all
whats the api method
block or item?
Yeah
SkullMeta for skulls
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
cast the item meta
ah
not sure what the point of sending that was
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,...
^^ this is what you should send for custom skulls
it's also what the thread above links to
I c
Man Alex should be paying us for all this advertising
Alex to make official docs when
fr
mfw wiki pages 
Also, wow, really? A rainbow skull as an example. Even Alex has gone woke. Unacceptable
Thanks, I had a great laugh. Unfortunately that won't happen here
I haven't seen him in a while, is he already banned?
var data = PlayerData.getPlayerData(player);
var stack = new ItemStack(Material.PLAYER_HEAD, data.soulPoints);
var skullMeta = (SkullMeta)stack.getItemMeta();
skullMeta.setOwnerProfile(player.getPlayerProfile());
player.getInventory().setItem(44,stack);
player.sendMessage("Updated player menu");
I know this code is running on the right player, but its not doing anything. Do i misunderstand what the .setitem command does
im pretty sure soulPoints is not 0 but could that be it?
Nope. Should work fine. Though a couple things to note:
- Is
data.soulPoints> 0? - You didn't call
stack.setItemMeta(skullMeta)before you set it in the inventory
That's probably the only thing I can think of tbh
Aside from just that code not getting invoked at all
Time for debug statements
Actually, wait, what is slot 44? If you're trying to set the head slot there's a setHelmet()
Definitely not
idk what the slot ids are tbh i just looked up it for vanilla
You might also want to check that the slot isn't already filled with something
Yeah Bukkit's slot ids differ from the protocol ones
Slot 0 would be the first hotbar slot
so it would be 9
0 - 8 from left to right, then 9 - 35 for the inventory slots, top left to bottom right
Oh, sorry, last slot, yes. 8
8
ok it worked with that
where are the real slot ids
https://www.spigotmc.org/wiki/raw-slot-ids/ this is wrong
^
Smh bad wiki
strangley theres nothing on google
ChatColor has constants for those
is it just chatcolor.italic?
Yes
weeird it didn't show up when I first tried it
how do I ensure its NOT italic
bc usually custom item names are italic by default
is there no way to just use the datapack json method then id know what im doing
You can do the generic chatColor.(color), I prefer the translateAlternateColorCodes, as to make the messages easier to configure (when it comes to color and what not)
You could "reparse" the message to ensure it's not italic
huh
Just make a new string objext
Technically yes
like color and italics
Colour first, then format I think
translateAlternateColorCodes
thanks!
Does this not apply to the situation? Just use generic mc color codes and it should be fine
is swapping hands (swapping with offhand) just a item drag event?
I thought there was a playerSwapHandItemsEvent
alr
how would I stop a player from moving an item from the inventory? Im cancelling the drag and click event
but it like
lets me pick it up with the item staying in the same place
it duplicates it basically
EntityPickupItemEvent and playerDropItemEvent
I dont think thats it
Wdym by moving an item from the inventory?
send your listener code
@EventHandler
public void onItemClick(InventoryClickEvent event) {
if(event.getSlot() == 8) event.setCancelled(true);
}
@EventHandler
public void onItemDrag(InventoryDragEvent event) {
if(event.getRawSlots().contains(8)) event.setCancelled(true);
}```
Creative mode is jank
Oh
Replicate in survival first
That's why haha
OH
it works in survival
how would I get it to work in creative? is it not possible
Creative likes to mess with inventory events
its ok if I doesn't but id rather it worked
Yeah, you're a bit shit out of luck when it comes to creative mode inventory handling
Mojaaaaaang
nw
tbf
ok so
You could prolly detect what gamemode the player is in and not allow them to do whatever it is you want whilst in creative
when I hit a number key it moves the item still, what event is that
but that's like your best fix tbf
can somebody explain
how does server know that entity should be in this exact position and state next tick
I think it's the same event, you just have to detect what sort of click it was
like server doesn't know what blocks are and that entities are stepping on them
why can't entities drop through the blocks then
The server knows what the collision shape of a block is
so server stores collision shape of all blocks in all loaded chunks at runtime?
why wouldn;t the server know that?
since server is more about packets, not like spawning stuff
server doesn't like "see" what's going on
I mean the blocks are all on the server I assume
it just receives and sends packets
where else would they be
yeah, true
entire rendering is client-side
but like on server each tick each entity updates it's position, right?
hmmmm
players are not taking part in it at all
like in force-loaded chunks entities should still exist like around spawn?
and do smth like fight against each other
so the item drop event doesn't know what slot its from
well, that probably can be arranged in the api
but it's not possible yet afair
sooooo
.
at least entities which are near players
Yes
and some kind of code does the ground check for that each tick
and if there is no ground, entities are pulled down by simulated gravity
am i thinking in right direction?
I'm quite sure you could fine a simple workaround for this
Yes
im jsut gonna do this the right way and store the fact that the item can't be moved in its pdc
isn't there some kind of playerdecidedtothrowstuff event?
It is crazy code?
Probably for the better haha
seems fine to me
so well, players are not taking part in this calculations
Correct
cuz i mean some games which have a host-clients multiplayer model, host player does the physics
and just sends packets to all connected guys
now i only need to find the code which can help me with this ground-check task
i'm doing a multiplayer shit for like 4 players in total for lobby
What
and using the minecraft system where everything is counted as a multiplayer(even a singleplayer world)
im coding a game basically
with npcs which are gonna walk around
i only need them walking(no dialogues or actions yet)
Have you considered using mythic mobs?
if that's to me, then i'm not coding minigame
I think they are making a stand-alone game
im coding a game from scratch
Craftmine?
yeah
and that's not
I guess you all got the joke, i'm a bit frustrated right now
sorry for that
Do you mean this in the way like if you paused the game in singleplayer, thr world around you will still continue?
Minecraft runs on a server in both single player and multiplayer
also that yes
The single player server is internal where the multiplayer one is dedicated
well, in my game server just stops, saving data if possible when anybody is not responding for too long
it's kinda like not letting game progress when you lose second player
in splitscreen games
Intentional? Seems a bit unorthodox
wdym?
Why would the server stop when players stop responding / interacting or wtv
i mean it's like a hard coop for not more than 4 players
you ever played for the king?
there are 3 players in total, and when any of them loses connection, game stops
i just had a dream for a long time to create some kind of RPG but also with coop
like imagine playing DnD or Munchkin, but players are in open world and meet each other like randomly
one of 4 players can, for example, never meet other 3
Dont get me wrong rpg is fun, but I'd like to see a sandbox / rpg style come out... as in something where the story doesnt actually end, just keeps building from player input
well, why should game "end"
rpgs are mostly freeplayed
with no end
i mean sure you can beat all questlines
"end" in the sense of the storyline for most games
but that doesn't stop random fun encounters
Or like random activities
and the bangerest banger -- game can have mods
with new quests and location
Yeah but imo those activities/objectives will never be as fun as the "main" goal of completing the storyline as it were
I mean i'm almost 600hrs in skyrim
and when guys released their first multiplayer mod like 6-8 years ago, this idea came to my mind
I think this is one of the best things you can do, randomly induced events
yeah like some random town decides to start a war because of circumstances which are not fully controlled by the player
well now you get what i wanna do
Yes I believe I am understanding the goal
Be sure to include me in the alpha
and beta for that matter
yeah i'm currently adding devkit and mod support
How much of the foundation is done?
so well, i guess this week i would have working map for multiplayer
for the goal i want to achieve, which is a pure preview(only several quests and small locations), i guess like 15%
Not bad
i need to make devkit extra powerful
How's the world generation?
well, it's using cell(chunk) system
basically when you get to play, game spawns grid of 5x5 cells around you with events happening
So essentially you're using mc framework for the I guess what you could call backbone?
I know that, just in the idea of their multiplayer impl / world generation / etc?
Not that cell system isn't common
rn the multiplayer impl is just udp and tcp for establishing the connection
so when host hits Play, he and his lobby-mates are getting loaded into the game
hold on
is the Player object only for the spawned player? Does it go away when they leave and go back?
yup, player dies when you leave
So before entering a game/save, the host has to "party" up with the other group members?
or you mean in my game
so I should store data in playerprofile
yes
in mine
how do I store data for a specific player
PlayerData should be stored/gathered on their join
Uh
modifying the world .dat i guess
it's moved to playerdat now tho
sounds overcomplicated
when all guys are ready host hits play and game creates a new multiplayer world with first save
PDC is supposed to save it when the server restarts... right?
pdc is saved when pdc is applied iirc
yeah, but you can't store a pdc on disconnected player afair
what are you trying to do
You cant?
yeah i once made a marriage plugin and encountered that
but it was long ago
I mean flat file would probably work fine for this matter then
that also seems overcomplicated
then save them when player is in the game
like I might as well jsut store it in scoreboard
which stats are you counting?
Store/save can mean a lot of things
here it spawns guys somewhere and lets them create characters with race, skintone, gender, name and other stuff
and when all guys are ready, game starts and lets them walk and do stuff
The spawns are random for all players right?
Well if you're doing a square shaped map, would the best approach be 4 corner spawnpoints?
sure why not
i can also probably have predefined spawn locations
like in some beautiful places
scattered across the map
I'd assume so in the sense the map is squared, however you could do randomized spawnpoints based on a quandrant as it were
also base spawnpoint on race player picked
Ooo thats cool
tho races are pure text rn
they don't do anything
don't even change appearance since players rn are just capsules
If i'm allowed to steal, i can probably have the lizard, catman and smth similar
as well as humans like black and white since one race is from desert and second from mountains
Or perhaps og star trek races :p
you can add them with mods
when devkit is done of course
well, base game is literally empty with tons of scripts attached
Sure sure, but that's where it starts eh?
yeah
base game assets are all packaged until game starts up
so firstly i unpack default "records" which are like object datas
model records, texture records, worldspaces and cells records and so on
then modloader comes in play overriding records or adding new ones depending on installed mods
and then you get to main menu
Whats the primary language?
c#, with tons of reflection in order to provide an api
since it's c#, i use .dlls
not jars
and well, i got rid of plugin.yml for plugin manager
Man if there's one thing I never want to get into... its c#
it's literally java but with weird camel case and event keyword
myclass.DoShit()
i swear class.getDeclaredFields is doing the same thing
tho in c# it's type.getFields()
Yeah but imo java is more modern in the fact of I suppose "sctrictness"
Easier to manage as well since in the case of being so sctrict, it's almost hard to mess things up that bad
And also c# is more into event handling
Well that's probably better for a game from scratch for sure
well, i still declare tons of abstract stuff so i don't forget to override smth
I think that's just good practice tbf
so well, along with mods which are just records-based shit
which is higly data-oriented
i also provide the plugin system
for runtime stuff on the server
here is where reflection comes to play
public class MyShitPlugin : DoTPlugin {
public override string Name = "MyShitMod";
// author
// description
// api-version
// mod-version
public override void OnEnable() {
}
}```
I mean I understand why reflection is a thing buttttttt.... it just shouldn't be imo
why not
why?
its a tool, good in the right scenario
most serialization librarie would not exist if not for reflection
it's there for a reason
That's my point
well, then how are you gonna load a plugin from jar if you don't have reflection
It's only ever used for niche purposes (in most cases) and I feel like there should be better or rather cleaner methods of doing so
DoTPlugin plugin = assembly.CreateInstance("MainClass") as DoTPlugin;```
this is not true at all
Maybe I just dont use reflection enough then
well, you mostly never use it in minecraft development
and what other 'cleaner' methods would there be?
since bukkit guys created api for you
^
but if there is no api, some random modder would spend a year messing with reflection, to bring it to you
I say niche in the fact most modern plugins have public api's
Hence the cleaner method of just using their api
are you just talking in the case of spigot
Yes
i guess even case of bukkit
Reflection is very powerful and useful, I just don't think it's very useful for spigot dev
if you mean that, yeah I thought oyu meant reflection is a bad thing as a whole
like ai
but either way even in plugin dev, theres still some cases where its needed
Oh no no, reflection is an amazing concept, like I said I just don't see the appeal for spigot dev... I see a lot of people using reflections for no reason
well, generally it's more leg shot and pain in the ass than a solution π
Well I think the proccess of making a good api just comes with time of that application being released
Ie: user input for better optimization
well, i decided to start with modding(devkit), api and multiplayer and only after finishing these topics, move to creating locations, quests and npcs
Also using a devkit i made
alr good night guys
Take care!
so what is the best way to store player data
people keep saying a config file
but idk what that means exactly
can you edit config files
Yes
Config file just means flat file unless specified as a config, ie: .yml file would be fine for storing that sort of data
config.yml (config) is just the name more or less a descriptor of whats contained within that .yml file
I think imma just serialize it
serialize the data, then store it in a flat file. When needed, deserialize and take whatever data you need
how would I get the filepath of the plugin folder
Plugin.getDataFolder().getPath() ?
public static void saveKits(Map<String, Kit> kits, JavaPlugin plugin) {
config = plugin.getConfig();
config.createSection("kits");
ConfigurationSection kitsSection = config.getConfigurationSection("kits");
for (Map.Entry<String, Kit> entry : kits.entrySet()) {
Kit kit = entry.getValue();
String path = entry.getKey();
kitsSection.set(path + ".name", kit.getKitName());
kitsSection.set(path + ".cooldown", kit.getKitCooldown());
kitsSection.set(path + ".cost", kit.getKitCost());
kitsSection.set(path + ".permission", kit.getKitPermission());
List<Map<String, Object>> serializedContents = kit.getKitContents().stream()
.map(ItemStack::serialize)
.collect(Collectors.toList());
kitsSection.set(path + ".contents", serializedContents);
}
plugin.saveConfig();
}```
Yes that works
But iirc that will return the path of the file not the path within the file
I may just be cooked
Oh wait
so if its not the data folder im gonna have a talk with whoever made that api
In hibernate, is it possible to somehow make the setters of an entity auto write to the db? (All the changes should be sent to the database automatically) Preferably asnyc? Maybe even just certain methods if possible?
You'd have to write out the async logic, otherwise I'm pretty sure the changes are persisted when the commit occurs
Im not using transactions currently only to save the objecg fully not while using its setters
Is there a different way?
mmm not that I am aware of unfortunately... might have to ask illusion or someone like that haha
some APIs have attached objects which are attached to the db and save auto
I wonder if hibernate has tjat
I'm pretty sure hibernate only process through main thread
So they probably wrote that logic out seperately?
Okay
I'd keep in mind the load you're trying to work with async as well... I've seen a couple of operations that absolutely cook the server
Yeah i usually dont write instantly to the db but there is some crucial stuff that should be saved instantly
Yeah just gotta be cautious with your session management, otherwise it's probably fine
You mean opening and closing?
Yes
I keep a singleton for every entity
Ah then you're good
So open on start close on stop
I'd certainly test it, but that sounds fine
Okay, thanks for you help
For sure! I hope it helped more than it didnt haha