#help-development
1 messages ยท Page 367 of 1
just move the eventhandling methods to the class that extends gui
and the registering
why?
it should work if you do that modification I stated ๐
Yes that is true, but I'd rather have those events in the abstract class, since I have many more menus extending from GUI, and otherwise I have to duplicate so much code
BUt if it turns out it's the only way, then I will do that for sure
I have one more trick up my sleeve
lol ok
Vault was never giving me issues before
private boolean setupChat() {
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
chat = rsp.getProvider();
return chat != null;
}
Just glimpsed over here. I am hoping nobody here registers a new Listener for every GUI they have...
Its a work in progress ๐ ๐ ๐ ๐
is this what is at line 153?
always 1 listner with a map of inventories
yeah, I'm doing something else rn 1 sec
need to ensure vault loads first
I will change it
which just add a depends to your plugin.yml
Yeah one listener and then delegate the events to every inventory handler
It is there
Which is why I'm confused
depend: [Vault]
softdepend: [PlaceholderAPI]
did NTE have something for vault? o.O
OOoooh
what are you using for chat?
The plugin Im making xd
so betterprefix is for chat
Yes
and you are trying to obtain your own service provider for chat from vault?
which would ultimately fetch yours
why is that necessary if your plugin is for chat o.O
My plugin just adds prefixes
what other chat are you trying to get it from is what I am asking essentially lmao
And was working perfectly without these nte shenanigans
Well I was using it before and it was working correctly tho
Just having nte as a jar is the difference
Well and all we've done to it
maybe you are making it getting invoked more then once? lol
have no idea
but something is accessing it even though it returned null
I am accessing it it should just never return null
ok, but you shouldn't be assuming it isn't null either
otherwise pointless to return a bool
But regardless it shouldn't be null
That's because it checks that it can register first
I use that
OK
Fixed it
Obviously there was something missing...
We have a chat plugin that gets prefixes
Using vault to get them
Where was the permissions plugin XD
the permissions plugin doesn't have an api?
which is where I am assuming you are pulling prefixes from
Yes
I just never added the permissions plugins jar
lol
To the test environment
Now I need 1 more thing and Im done here frost
How can I reduce the size of this massive jar
It went from 30kb to 4mb
Holy shit it works btw โค๏ธ
why does it need to be reduced?
ok 1 thing i didn't do is :
- if player join arena : save his inventory -> and remove any item from his inv and armor
if he leave the arena or leave the server
give him the items back
you essentially have two plugins compiled as one
well NTE is probably the larger of the two
most likely not, but still not sure why it is a concern lol
It isn't I just liked having a 30kb plugin
There is so much
remove it
"why is my jar so big I just shaded nms so that I can use it on spigot"
- Someone, probably
lmao
you need to add <scope>provided</scope> to any dependencies you don't want to get shaded in
included in spigot
^
What is HikariCP
And google guava
provided ๐
What is scope system?
you want it shaded or not
<dependency>
<groupId>ninja.leaping.permissionsex</groupId>
<artifactId>permissionsex-parent</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/PermissionsEx.jar</systemPath>
</dependency>
basically that
means the dependency is only found on the system
lol
oh
basically makes it so you also add a path to the .jar
so you can have .jar dependencies
it is as I said, the dependency can only be found on the system, with the path provided
Bro pex is dead, getting removed
it won't be found in a repo thus it tells maven to not try to find it there
Essentials group manager ๐
bro what pom do you have
why do you need so many dependencies
lol
nah you got the whole of the central repo as a dependency
lmaoo
LOL
They were set to system
But I'm straight up removing them
6gb jar incoming tho
because most of those dependencies
can't be found no more
but someone wants to maintain compatibility
yeetus deletus hide that fetus
not that it would anyways
because like who is running those old economy plugins that wouldn't work anymore anyways
Ok
bet you it has a dependency for Iconomy
how can i make a menu like this?
Economy plugin is so old it's still using bartering ๐
lol
done , but i think i need to add the inventory in a yaml file for each player join the arena , or i dont need to do that?
lets say if server restart and player in arena , would'nt that remove the hashmap? and he won't be able to get his items back?
exactly
so make persistence
you should have a backup in case of a server crash
so just store their inventory in a PDC chunk
or
temporarily
frost
?
store it on the player itself
when a server crashes player info doesn't necessarily save where as the world data saved already
That would be a mod. Or if you're willing to use resourcepack trickery you can open an inventory with custom character name that has the texture and then use items for the button
like a command that opens the menu
if the server crashes in the exact moment that you save
hell iirc there is a saveplayer
ah nice
more like this
then they should use that right after
mods
yep
ok
ill just stick with the inventory gui
There is no war in Ba Sing Sae
i forgor how to type it lmao
fr
like literally the ending is like the best bit and that is it
if you want spoil it, won't watch it anyways
don't spoil legend of korra, still watching that one lmfao
lol
player.setDisplayName(colorize(prefix + " " + player.getName() + " " + suffix + ChatColor.RESET));
Why does that line not include spaces
show what colorize does
which line?
the display name
I assume the display name is what gets displayed in tab correct?
they likely want ADMIN NTSans_
TabListName is
try setTabListName
hm?
setPlayerListName()
close enough lol
indeed
we can't always remember every little thing, I mean its impressive as is that most of what I help with I am not even using my IDE ๐
like your little project
I gathered all my knowledge from looking at the API when I was trying to get fabrigot working lol
all of that was from just me remembering ๐
TIL there is updateCommands on players
lol
so much useful shit fr
there is so much shit in the api
though there should be a more clean way of doing things
mm is this good way to save player inventory in yaml file when he join the arena :
and load it after he leavearena
(such as I'd prefer getLevels().getCurrentLevel(), getLevels().getCurrentExp(), getLevels().getTotalExp(), getLevels().getRemainingExp() would be nicer tbh)
there is
there is a way better way
That's honestly really impresisve
Considering it worked
And you had to instruct someone else, not even do it yourself
?pdc
ItemStack[]::new
Basically use PDC to store an array of item stacks, then right after call saveData, once a player exists re-load from PDC
player.getAddress().sendCake();
Lol yeah probably the hardest bit was going off what you were saying
but otherwise I been playing my games all this time ๐
I am, 99% spigot help-dev and 1% essay
I like that dragon software for such things
dont write stuff about games on your essay
pretty decent
I remember seeing this dude in 2015 with a stt phone
It was stunning how well it worked lmao
(I didn't realize it at the time, but it was making like no mistakes)
well it probably missed out on punctuation marks
then it had to be using an online service
like "COMMA, DOT, EXCLAMATION"
well that is what I meant
"Hello COMMA how are you doing QUESTION MARK"
that is how the dragon software works for the most part
Can I force a specific java version to be used on startup.bat?
no
well
actually yes
specify the full path to the java binary of your choosing instead of using the shortcut name
it can be used like a loading screen
this
yes
you can re-name it so that it shows yes and no
nice
niche stuff people forget are there or don't realize
like the conversation api
for example
and some other stuff
I even forgor about the convo api
hi, i want to remove the usages of IntellJ, i already disable this and it still have the usages
isnt that supposed to be 29? (a+b)^2 -> aยฒ+2ab+bยฒ
5^2 is 25
lol
well idk but i learnt years ago that (a+b)^2 is aยฒ+2ab+bยฒ
Shoot your teacher
Man why the f do I need a oracle account
Which has the most insane password requirements
To download a old java version
imma leave it like this then
it won't
๐
yeah the first binomatic formula
binomic*
whatever it is in english
maths go brr
it's much simpler
It is but when you have an actual value inside the bracket you can simplify to make it easier
How can I check when something like setPlayerTabName() was added to the spigotAPI
Like what version
help chat has all the javadocs
wym
hi, i want to remove the usages of IntellJ, i already disable this and it still have the usages
uncheck "Usages" there
ok thanks
Hey, is it possible to change the tablist for only a specific player?
What is a WorldBoundingBox??
Sure
a boundingbox that belongs to a certain world
how?
Ah
Depends on what you want to change. Player names or the list header and footer
yeah i want to change the player names
And why are your cached blocks not in a Set?
so I can sort them
then you'll need packets
LinkedTreeSet with a Comparator ๐
Then you dont risk duplicate entries
how do i send packets manually then
nms or protocollib
i already checked out protocol lib but i couldn't understand how i'm supposed to use it
isn't it SortedSet ?
It can be a bit complex at first but take a look at PacketWrapper and it should contain what you need. Might be a bit outdated though... depends on what version you're targeting but you can learn from it
no idea where that is supposed to be from
Wait its just TreeSet
Hey guys, getting a random maven error xD
My pom.xml https://paste.md-5.net/adefirajuz.xml (ignore the system dependency, its temporary)
Then show it...
yeah, apparently it's only up to 1.8
I don't want to sort the blocks by something that's inherent to the block
right now i'm trying to target the latest version so i'm hoping it'll work
wdym?
It's up to 1.15.2
basically I just shuffle the collection once and then keep that order
am i looking at the wrong repository then?
I mean you need to show us the error if you want us to help...
I see i see
im running with -e flags, give me a sec
Just click on more details pls...
the readme says up to 1.8 lol thats weird
outdated readme
PacketWrapper is outdated af. Half of it is broken.
True but you can learn from it
this is enough? https://paste.md-5.net/ujerawaneh.sql
You get the general idea of how to read and write to packets
Are you using the special sources plugin?
what you mean with special sources plugin?
maven special sources. To get mojang mapped nms
no
ngl this looks like a pain in the ass
im not even using the NMS on the maven
what java version are you using?
using the spigot-api dpeendencyu
to run maven
8
jre1.8.0_361
give me a sec
is NMS any easier than protocol lib?
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment JBR-17.0.5+1-653.25-jcef (build 17.0.5+1-b653.25)
OpenJDK 64-Bit Server VM JBR-17.0.5+1-653.25-jcef (build 17.0.5+1-b653.25, mixed
mode)
A little bit
send the full maven log. first you claimed it was java 8 but a jre, now it's java 17?
what is it actually that you are invoking maven with?
just see the very first lines of the maven output
forget the jre one
codes/laivy/npc/LaivyNPC.class
is this from your plugin, or a dependency?
mvn package -e
my plugin
I wrote a full lib where you can edit every slot by index. Feel free to ask stuff if you try your luck.
Thats cool
oooh that looks fancy
does it have any documentation?
paste your entire pom.xml pls
erm why do you shade jetbrains annotations
also get rid of the <finalName> and <outputDirectory> in your maven-shade-plugin, that's prone to break things
Hm you could try updating the maven shade plugin to the latest version 3.4.1
Probably not the cause but worth a try
stuff like that belongs into the maven-jar-plugin
also I've read stuff about java8 type-annotations breaking the maven-shade-plugin when using certain java 8 versions
jdk1.8.0_202
maybe that's th eissue
just try to run it using java 17 and see again
Imagine being 11 major java releases behind
it was fixed in jdk 10, this issue says https://issues.apache.org/jira/browse/MSHADE-243
i need to use the java 8 sadly :C
Couldn't
aaaaaand, just like you, they were using java 8 type annotations
why not? it's not that hard
you go to File -> Project Settings and set the JDK to 17
If i change to java 17 i will need to change a lot of code lines
how that
wait, let me see
Who forces you to use java 8?
You can still compile for source compatability but use a newer java version
im developing on 1.8 R1
That too
doesnt matter, just do what I said
rn
File -> Project Sturcutre -> JDK 17, compile again
it'll still work on java 8
alternatively, not shading the jetbrains annotations will probably also fix the problem
compiling...
it's useless to shade them anyway
Well thats my cue
now that
i really doesn't like particular using Maven, its... slow and so complex
remove the jetbrains annotations from your shaded .jar
set its scope to "provided" and remove it from the <includes> in maven-shade
Have you tried โmvn cleanโ before running package again?
Otherwise, i also dont have any ideas anymore
let me see
it performs all good apparently
๐ค
yeah clean cant really fail
what did i do
it didnt work before because you didnt "clean" after doing changes to your pom, so there was still bullshit around in your "work" folder or however it's called
usually you run clean after doing changes to the pom
it was a bug in ASM, not in maven, btw - and yeah, probably related to the issue I linked earlier about java 8 type annotations
not 100 % sure, but as long as it works now, all good
if you wanna find out what exactly the issue was, try to use java 8 again to compile, then if it fails, remove all those Nullable and NotNull annotations in your class, if it works now it's related to the bug report I sent
ok i really couldnt remove all the @urban grotto, @Nullable, @Experimental and @Internal annotations xD
wait, did you ONLY run clean now? You are supposed to run mvn package after that again
its more than 1k
i will try give me a sec
still
i've done mvn clean, and mvn package in the order
still working, or still broken? ๐
broken xD
then I am out of ideas
do you know any other compiler? im sick of using maven, its so much problems
if you're using java 17, and are NOT shading jetbrains annotations, then no idea what it could be
maven just calls javac
but ofc there are other build systems. gradle, ant, ...
Is your project in a cloud drive?
yeah
...
i dont think its a problem, i use that way for months
just send a link and let us try to compile
just today it started to happen suddenly
what do you mean?
Yeah but you have no idea which parts are cached (And when they suddenly get uncached). I have seen so many problems with cloud drives. Especially when the maven repo is not on the same drive
i will try to compile another plugin on the cloud and see what happens
apparently its just with this plugin, others runs ok
95% sure its a problem with your local dependency
<dependency>
<groupId>codes.laivy</groupId>
<artifactId>LvMultiplesLanguages</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../LvMultiplesLanguages/LvMultiplesLanguages.jar</systemPath>
</dependency>
Put the dependency on a concrete dir on your system and change the systemPath. Then try again.
using systemPath in the project.basedir is deprecated anyway
i will try removing it, not sure if it is, because im using that for months
why don't you just let maven handle that dependency? or is LvMultiplesLanguages not a maven project?
If so you can still manually install it with mvn istall:install-file
Im on the way to create my own hosted repository
not done yet
im using that system scope then
why would you need system scope if you have a repository?
the whole reason for a repository is there to avoid using any hardcoded paths
not yet
yeah anyway, systempath isnt the problem, still it's nasty and and should be avoided
its not
Show your new pom
ok, i will paste the new pom and the error
i've tried invalidate all caches, restart the computer, and still with that
Try not to shade gson in
Try not running in what I assume is a google drive folder
and not using the systemPath dependency
hi
ok, i will try
<build>
<sourceDirectory>
src/main/java
</sourceDirectory>
<testSourceDirectory>
src/test/java
</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>
${project.basedir}/src/test/resources
</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
and provided scope.
ok so I am still on the performance-issue with the multiblock-changes(fake-block-packets). I have not even been able to find anything why the client would lag out on such a small amount of blocks
What mc version?
I've been using massive amount of block changes without any major lag
1.19.3
Thats a bit weird then
its only 100/t
I can as well send a ton of blocks without any major lags
same
do you think its just my CPU is absolutely getting demolished by server + client?
I have a 10 year old CPU with an 8 year old GPU
it worked
removed all relocations and compile scopes
worked
uhm im running an overclocked i5-9600k and GTX 1650
I was running IJ + Server + 2 Mc instances
im running eclipse + Server + 1x Instance
Well then there is a problem with this gson version. Gson is included in spigot so you should be fine.
i need the latest gson version
i need to shade then
xD
how can i change this to 3 blocks? like > 10% Gold, 20% Coal & 70% Iron
i5-3470 GTX 960 16GB DDR3 RAM in system
Several approaches. Naive one: create a scale
| 10 | 20 | 70 |
Then generate a number from 1 to 100 and see in which section it lands
Googles range map is decent for this
like this?
are you doing that outside of a code block? o0
no
I'm sending random blockchanges for about 3x3 chunks with random blocks for every already occupied block, and not even that causes huge lags
I mean you can do that but using a RangeMap is more scalable
private final RangeMap<Integer, Material> materialRangeMap = new ImmutableRangeMap.Builder<Integer, Material>()
.put(Range.atLeast(10), Material.GOLD_ORE)
.put(Range.openClosed(10, 30), Material.COAL_ORE)
.put(Range.greaterThan(30), Material.IRON_ORE)
.build();
public void something() {
int random = ThreadLocalRandom.current().nextInt(0, 100);
Material material = materialRangeMap.get(random);
}
I believe this lag could be caused by light updates below
can you show your code, please?
ok it DOES cause lag, but not because of the blockchanges itself, but because of rendering all these funny blocks
thanks
public class TestSpigot extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getCommand("test").setExecutor(this);
}
private static Material[] blocks = Arrays.stream(Material.values()).filter(Material::isBlock).toArray(Material[]::new);
private static Material getMaterial() {
return blocks[ThreadLocalRandom.current().nextInt(blocks.length)];
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//Set<Location> locations = new HashSet<>();
Player player = (Player) sender;
for(int y = 0; y < 100; y++) {
for(int x = player.getLocation().getBlockX() - 10; x < player.getLocation().getBlockX() + 10; x++) {
for(int z = player.getLocation().getBlockZ() - 10; z < player.getLocation().getBlockZ() + 10; z++) {
Block block = player.getWorld().getBlockAt(x,y,z);
if(!block.getType().isAir()) {
player.sendBlockChange(block.getLocation(), Bukkit.createBlockData(getMaterial()));
}
}
}
}
return true;
}
just some funny stuff I made to test this quickly
hmmm im using Player#sendBlockChanges which should even be a lot faster
when just using stone, it still takes a while for 20x20x100 blocks, but it doesnt cause any FPS drops
when using single block changes, its lagging less but still speaking of a LOT of spiking
Just out of curiosity, could you send the player a message like "done" after the execution of your three nested loops? I'd love to know whether the client debounces individual block updates, as the whole thing appears at once. getBlockAt and createBlockData are probably pretty expensive, which is why that may cause a few milliseconds of processing delay.
using sendBlockChanges, it works almost instantly btw
k one sec
uhm why does it lag for me then?
Try injecting the netty channel of the receiving player and check if you're really only sending what's necessary. I still believe that you spam these packets.
idk, I'm running vanilla 1.19.3 on an i7 9700K (which already runs at 100%) with a 2080 RTX Super
i also just checked on my m2 macbook and there it's even faster
then it would lag for alex too
I mean that you spam multiblock updates. That's far worse.
Still wouldn't hurt to check, now would it
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//Set<Location> locations = new HashSet<>();
Player player = (Player) sender;
for(int y = 0; y < 100; y++) {
for(int x = player.getLocation().getBlockX() - 10; x < player.getLocation().getBlockX() + 10; x++) {
for(int z = player.getLocation().getBlockZ() - 10; z < player.getLocation().getBlockZ() + 10; z++) {
Block block = player.getWorld().getBlockAt(x,y,z);
if(!block.getType().isAir()) {
player.sendBlockChange(block.getLocation(), Bukkit.createBlockData(getMaterial()));
}
}
}
}
Bukkit.broadcastMessage("Done");
return true;
}
How interesting, most of the lag is actually serverside, xDD
well "injecting the netty channel"
yeah probably the createBlockData part, since just changing the existing blockstate's type is instantly
that does not sound like something to do real quick
I could quickly create a minimal logging plugin around my reflection library and send that to you in private chat, then you can post these logs in here and we can analyze your situation further.
alright
ok, brb
ok I fucked up and accidentally started recording way too early lol
anyway, on the macbook it keeps at ~400 FPS (fast forward to the end of the video)
I acidentally started recording when I started typing instead of when I started to test lmao
coding with mfnalex episode 1
note, I set "suppressLightUpdates" to false, so it even also updates the light client side without any FPS issues
(on the mac I got sodium installed though, on windows I tested it with vanilla)
Made it async and only replace surface blocks... for whatever reason
theres the packet-log
Also good job discord
Lol
Hmm, you send bursts of multiblock-changes of size 40 at times, don't know if that's actually intended
But i sent 20x20x100 block changes without problems
Thats a lot of multiblock sends for just one second
PacketPlayOutMultiBlockChange is basically a chunk slice, right? So you're updating way too much for your little slice of grass there
its one for one chunk
It still was 40/s there at times, so 2/tick, xD
uhm idk why MoveEvent kicks off 2/tick then
oh nvm
its because of air
Move event... oof
What size is that schematic? Looks like 32 in depth, but what is it's width?
That should be doable with around 8 packets then, shouldn't it? 2 chunks depth, around 4 chunks width. Of course there could be more, if it's not aligned (which it likely isn't), but 20? Hmm, maybe, not sure right now.
How do you generate these packets? Still with the API?
Could you fix that spam by now? Whatever you do, 40 packets per second is very likely just too much. Does it get any less laggy if you constrain yourself to 20/s?
imma limit it to 10/s rq
im kinda surprised that String#formatted doesnt return early when the args.length is 0 :/
Bukkit.getScheduler().runTaskLaterAsynchronously(LoopCityScript.plugin, new Runnable() {
@Override
public void run() {
onCooldown = false;
}
}, 4);
``` like this?
when doing this, it still lags the same
is there any Player instance which would be not null even if no player logged in before?
where lambda
Nope. You need to implement the Player interface yourself for that.
damn i seriously need an offline player to send plugin message
it'd also break up many plugins if i implement Player by my own or either i have to use CraftPlayer
idk
Yes for that you not only need a Player object, it needs to be a connected one
hm
should i use sockets for that then?
since i need to get some data from bungee on plugin load (getting server names)
Is it a public project?
Is it possible for me to check if a player has clicked an item in a chest inventory while holding CTRL?
sounds ridiculously over complicated
I always use Redis for cross server/proxy communication
Because there is a bug were players can hold ctrl + left click and it gives the item to their inventory
and players can easily steal items from gui's
i think inventorymoveevent handles that?
were they are not suppose to
I'm not sure though, the inventory api is so fucking awful I can't express it enough
ahmed also told me to use redis but i seriously don't know how i gotta read it docs then but can't i do that without making a new database?
Such a bug doesnt exists. Only in very old minecraft versions
since we're currently using SQL
so what can I do to fix my bug?
Write stable code
well I don't know what its from
do you mean shift + left click
what version
1.12.2
Redis is not really a database. Think of it like a hashmap in memory that can be accessed by multiple programs
Cancel the InventoryClickEvent
which stores the data forever?
But you can't nothing detects when u are holding ctrl and click
I tried debugging it
No... its in memory
are you sure it's not a ghost item
damn but its cool i gotta use it
If you cancel the InventoryClickEvent then the player can press whatever he wants. Nothing is gonna happen.
I can show you a minimal setup with redisson if you want
oh okay
is there a way I can check if a certain gui is open?
by a name or something
can't you check the inv type
I'd be thankful if you could
Inventory#getType
Put your open GUIS in a Set<Inventory> and check with contains()
on close -> remove it
RedissonClient redissonClient = Redisson.create();
// Gat a message channel named "comm"
RTopic topic = redissonClient.getTopic("comm");
// Register a message listener on the channel
topic.addListener(String.class, (channel, msg) -> System.out.println("Message on comm: " + msg));
// Send a message on the channel
topic.publish("Hello World");
If you just use java classes then you can simply send messages like this.
You can also send json Strings ofc. If you have a decent codec then your Topic
can also send complicated objects of any type. But this is as simple as it gets.
wow thats nice
why did minecraft use io netty instead btw
Everyone listening on the "comm" channel will receive an event when anyone sends something in there
Redisson also uses netty
As a backbone
Netty is just a framework for networking. Abstracts away a lot of boilerplate and provides
templates for a lot of protocols like http ssl rtsp etc
You need to shade in some redis java framework. I personally think Redisson is by far the best out there:
https://redisson.org/
But there is also Jedis which is more light weight in terms of size:
https://github.com/redis/jedis
And Lettuce. But never really used this one.
RedissonClient redissonClient = Redisson.create();
RMap<String, Integer> globalMap = redissonClient.getMap("name-of-the-map");
But it doesnt get simpler than that. Any program can basically put data in this map
and every other program has the same view. (High consistency or high availability depending on your settings)
still no idea why its lagging
Sending updates too often?
40 what per tick
40 packets
40 multiblock packets per tick? This sounds like a gigantic schematic then
its not gigantic, but it needs to get updated often
Update it twice a second
https://paste.md-5.net/afagupoham.cs
No, 40 (or 70? lol) packets per second. Still too much in my opinion.
Every 10 ticks
oh vnm
btw, when setting a tick-cooldown of 10 ticks, it still lag-spikes
40 didn't lag
oh nvm 40 still lags
there we go with more logging
what's a kotlin map that I could use to retrieve an entry's position? i think it's a treemap in java but i'm not sure about kotlin
You mean by index?
At first glance it doesn't look wrong to me, as you're sending 256 block updates at a time, which in essence is a 16x16 slice, so exactly what you have to send. I guess you're only going to minimize lag by only sending the blocks that actually changed. I don't see any ways to optimize this further, apart from accepting slower update rates in order to reduce traffic.
things is that you gotta update ALL blocks in this case
since when you change it in the Y-Axis, it is gonna need to update everything
I guess you've reached a limitation of the game then. Just debounce updates even further, there's not really a need to have smooth and live movement of huge structures.
yep
so if the schematic has structures above like 50 blocks, I cannot have live previews?
There is no such collection. Neither in java nor in kotlin.
You could use a linked map and iterate while incrementing an index.
ah that's upsetting
And there is generally no need for such a map at all
well what i do is i sort a map of killstreaks and try to find a player's position there
One multiblock update provides a x,z slice of 256 blocks already, so I guess you can have a hand full of those. But if you're literally sending 20-40 of these packets a second... what do you expect. The client has to render these blocks.
then I gotta ask why its lagging when sending it every 2 seconds?
Is it possible to have multiple HoverEvents and ClickEvents in one message?
Have you had a look at your logs? You're not only not sending it every two seconds, you're sending a bat shit crazy amount of them.
yes but I tried it every 2 seconds and it still spiked
Don't believe that until I see a log.
copilot suggested this and it seems pretty believable
val pos = killstreaks.keys.indexOf(player!!.uniqueId) + 1
(killstreaks is sorted)
yeah i think i'll go with that
Does FileConfiguration support UTF-8? FileConfiguration.save(File file) keeps converting my files to ASCII
cant you provide a charset?
Yeah this is the O(n) approach. There is one with O(log n) but you need two collections for that
stuff using utf8
i think it's fine for now, if it affects my performance too much i'll look into it further
there we go, everyone 2 seconds
Okay, that looks a lot better. What does the game look like? Can you provide a short video again?
it works fine with UTF8 for me since like, forever
ye 1sec
Try it in a normal world
Interesting, then it must be something else
dunno what version you're using tho
maybe your file was initially created in ascii and it won't overwrite the charset for some reason?
idk why that would work. The actual world is gonna be superflat too
If it works in a normal map then its for sure the lighting. Try it out.
hey smile, do you know what this will return if there's no such entry? just 0?
im using supresslighting but ok
-1 + 1 = 0
tyty
indexOf returns -1 on no entry
Doesn't look like it's working, haha
player.sendBlockChanges(states, true); supress is on :(
I know, but I'd say that this flag should suppress re-calculating lighting for all of these blocks, and it clearly didn't in this case.
hmm how do I prevent it then?
in what method does it say that? thenAccept?
thenAccept takes a consumer
you cannot return in a future cuz that defeats the point of futures
you can return a CF<RankResult>
then let the calling code hook in the future by putting the code that would handle RANK_ADDED in the thenAccept etc
i want to take a moment to appreciate how supportive this server and community is
thanks yall
Ofc you can return in a future...
CompletableFuture<Void> cf = CompletableFuture.supplyAsync(() -> {
return null;
});
But you cant return in a Consumer<T>
You've just joined the wrong day. Say that again in some hours when Verano comes back.
haha i've seen verano around here
i still do think that spigot is really supportive
uuugh
with some exceptions maybe xD
oh ye
.exceptionally(t -> PremiumRankResult.ERROR); should work just fine
I thought you needed a CF<RankResult>
Wait let me check the code...
final long millis = System.currentTimeMillis() + expiry.getExpiry();
return luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
user.data().add(InheritanceNode.builder("premium")
.expiry(millis)
.build());
return PremiumRankResult.RANK_ADDED;
}).exceptionally(throwable -> PremiumRankResult.ERROR);
Whats the error
or is that only for switches
No idea tbh. You could try dispersing the updates and adding a bit of delay between the packets, but I'm not sure whether that would help the situation. One would have to check out how the client actually handles these packets.
what does modifyUser return?
Ah i see. luckperms uses a non generic CF<Void> return
maybe do something like
CF<Void> cfvoid = luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
user.data().add(InheritanceNode.builder("premium")
.expiry(millis)
.build());
return PremiumRankResult.RANK_ADDED;
})
return cfvoid.exceptionally(throwable -> PremiumRankResult.ERROR);
to not chain returns
ah
Well then:
CompletableFuture<PremiumRankResult> future = new CompletableFuture<>();
final long millis = System.currentTimeMillis() + expiry.getExpiry();
luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
user.data().add(InheritanceNode.builder("premium")
.expiry(millis)
.build());
future.complete(PremiumRankResult.RANK_ADDED);
});
return future.exceptionally(throwable -> PremiumRankResult.ERROR);
it's not i don't think
Ah missed the return
You need to append a .thenAccept(rankResult -> {}); on the CF
This will be ran after the CF is completed. If you want to do something
spigot related then inside this consumer you need to use the bukkit scheduler
i always used my cfs wrongly :((
Yes
cant you do smth like this
return modifyUser(() -> { ... })
.thenApply(unused -> SUCCESS)
.exceptionally(t -> ERROR);
Right thats a better approach
if you dont need to use the result, thenRun is also applicable
they need the status returned tho
When i click the player head it won't open the other inventory. Its not complete wet i just want help with the inventory not opening
?paste it
oh god
<insert itembuilder here>
omg
and dont nest your code
hi , is there a way i can make bots test my plugin?its a minigame? i dont have player base to test with
or friends to join my test server :#
Mineflayer possibly
what is that :?#
it still dont work, here is the code in paste.md:
Troll.java: https://paste.md-5.net/icarecaqeb.java
OnMenuClick.java: https://paste.md-5.net/imitoxiyus.js
using titles to check for custom inventory is not a good idea
is OfflinePlayer supported out-of-the-box as an ACF context, or do I have to register it by myself
how do i do it then?
just get collection of onlineplayers and foreach
tip
next tip is to read up on itembuilder
but why it isnt opening the inventory??
Any exceptions in your console?
oh i just figured out
im so dumb
im not opening the inventory
i think the event is not firing, i put this "player.sendMessage("HI");" after i set the variable player and it dont send me a message
when i click the inventory
is it registered
Gold, you should take your time to carefully look your code, some minutes
i can do this right?
if (e.getView().getTitle().equalsIgnoreCase("Lista de Jogadores")) return;
Because if not its realy easy i just have an issue and ask for help, without atleast looking what is the issue
Dont use title pleases!!!
thx i forgot it
how do i do then?
You must be comparing the inventory via their equals() method or via InventoryHolder
right, so only equals, mainly comparing the whole object?
Perfect thanks morice, i will keep your update
== is also fine if you are making the inventory and always sure there will be one instance of the inventory
can you give me an example?
Not wondering to be rude, but you must learnt the lang where you are coding before using an api or library
Im seeing that you are really new to this and the reason of having many issues not elarning first Java, what i told you is from bad personal experiences that i have had
ok
So i would straightly forward suggest Java and then yes start by working with apis or libraries
It will be much easier for you, its just a suggestion you follow it as you want or not
ok thanks, im just doing this for fun, to me and some friends play, i dont want to learn java because to what i want to do i dont think java will be very necessary
Oh my gosh ๐ , so please if you want learn Java dont code plugins, what more i can say
Its the same when you cooking, you cannot cook good recipies without you first learning the basics about cooking
Okay this is the reaosn why i dont compare whole object when using player as argument
And many peple will discuss me saying you should compare whole player object, instead of their name or uuid
This issue happen while comparing using the whole player object, but i dont really understand the why
then you are making a mistake when comparing
Im using equals(), is it right? In theory player object overrides the equals
There is only ever one Player object for a player when they are logged in, UNLESS you kept a stale reference when they relogged
What? Im confused, im just getting a Player target input from argument, and then comparing against Player player
But the question, is why would tell me message, when the name is written correctly and also when written wrongly
Depends how you are getting the player object
if you are not using the exact method you will get the close match
right the Player player, is the casting of CommandSender, and the target via Bukkit#getPlayer(), and im using player.equals(target)
you could use == as its an instance
player objects have reference equality
not after they rejoined
just see if it works when comparing uuid, if not there is something else wrong
you shouldnt work with players instances that are not online
that happens to all ofus
Should never be used on a Player object. Its inherited from OfflinePlayer on which the method makes sense.
public class Main {
private static class Person {
private final String name;
private Person(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
return Objects.equals(name, person.name);
}
}
public static void main(String[] args) {
Person person1 = new Person("John");
Person person2 = new Person("John");
System.out.println(person1.equals(person2)); // True - both have the same attributes (name is "John")
System.out.println(person1 == person2); // False - they are different objects
Person person3 = person1;
System.out.println(person1 == person3); // True - they are the same object
}
initialization order error causing null
Do you need the provider? If you just depend on LuckPerms then i would suggest simply using the static access.
Never never? I once used it on a weak collection to check if the player went offline before the GC hit. It's not always viable to run through all your datastructures to ensure there's no reference to a player at the QuitEvent.
If you need to check the state of a WeakReference object to detect its viability then a WR is probably the wrong tool.
But i would let that one pass.
and did you declare the dependency?
did you do somethign silly like not set teh dependency to provided?
-.-
yep
classic
you shaded LP ๐
Always double-check your jar size
why do people always assume that "provided" is the default lol
A humongous jar probably has a reason for being humongous
if it was the default, then nobody would need to add "provided" to spigot-api
Conventions son
brain farts happen often
Even for compile dependencies I always explicitly add the scope
same
it feels wrong to not specify it
Right, and what happen when its returning true while using equals() method but the player names are the same but replacing the last 2 letters from the in put one?
Because in theory it shouldnt return true, if the input player name is different the sender
what?
equals() is true whenever equals() returns true. == is only true if it's exactly the same object
if you are using an invalid name you are comparing to null
No, because i already added a null and online check before
equals() checks if the objects look the same (property wise)
== checks if they the exact same object in memory (as in same memory address)
oh right. now makes sense, thanks to all
for players, equals() only compares the UUID btw
(and if it's an OfflinePlayer, so a normal entity with the same UUID will not be equals)
and entity id
oh yeah
Let me send code 1m please, maybe its my code issue
?paste
This looks like a dirty hack to get some GOTO logic going
looks so
did they change the hastebin domain?
hastebin is selfhosted service
hastebin ๐, Paste md4 ๐
Ah i see what they did here. They tried reducing the nesting without having to extract additional methods
to spare a few stack calls...
I love this part:
R rr = (R) r
sounds like an angry cat
and the second line, an angry snake
XDDD
๐ค
I'm just trying to find out whether I actually misused the WeakReference. The concrete case was: A brewing stand block has an object mapped to it, which contains three WRs, one for each of it's output-slots. If the player puts an item into the slot, they're the initiator for it for the next brewing session. I didn't really see the need to manage the reference myself, as I'm only interested on brewing events which player initiated which slots. I know that I could also use a UUID, but then I'd have to resolve those IDs and check for whether the player's online anyways, so it's about the same from the perspective of efficiency. Is there a better solution to this? Seems like this pattern often comes up if you're trying to track player actions.
thats called obfuscation lol
a weakreference value shouldnt be gced when the value is still in use right?
that's the source code of CompletableFuture in jdk 17 lol
r u serious_
yes
obfuscating open source >>
cf internals is the worst code ive ever seen
the worst or the least understandable
ok this is actually from openjdk 18 but I guess it's the same in most versions
cuz i have a candidate for that
the worst to figure out how everything works
uuuh
the only thing i know is that it works with a stack
Sounds fine. But what happens if the server restarts? Wouldnt you have to store UUIDs in the brewing stand either way?
How does the mapping look like?
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
dont have my ide open atm
was this on quora again today?
oh yes from quake right?
sec
your code != Java
there's a quora post about it like every second day
quora has gone to shit in the last 3 years
i only go to quora when I click on a link accidentally when googling
actually i learned about it because the ieee 754 standard made some math operation in it trivial
@smoky oak https://paste.md-5.net/yeguhiloyi.java
theres an interesting yt video
math.pow
I jsut read Quora to see the stupid things they post on the blog
maybe better that its an intrinsic
maybe its just lack of my C knowledge, but this code doesn't make any sense
exactly
just look at it lol
I wasn't really interested in loosing that information when restarting, so I didn't think about it. You're probably getting at persistent data containers, right? I guess that would be even better, I just never worked with them this far. It was just a very little and quickly written library to get something done: https://github.com/BlvckBytes/PlayerBrewingListener/tree/main/src/main/java/me/blvckbytes/playerbrewinglistener
Still happy to hear that you think that it sounds fine so far, and don't call me an absolute idiot for doing it this way, xD.
oh parameter is float, not long
it does, check out the youtube video
i trough parameter is long for some reason, nvm
Its using the bits of a long and interpreting it as a double. They manually shift the bits and work with the mantissa
it copies the bits directly instead of converting
so you can do the bitops
thats what the line with all the stars does
damn FdLibm.Pow.compute(double, double) is... "interesting"
star
told ya
im wondering whether id use a fastmath lib for my parser
as most of those methods are intrinsics
youre getting addicted to the wrong thing
Yeah i had the pdc in mind at first. But if its a utility and only needed for firing events for online players
then this approach is ok. Saves you a bit of cleanup on join/quit. As long as no other plugin holds a hard
reference to players this is fine.
try getting addicted to tea it soothes your nerves better
Now that i think about devs holding hard refs to player objects... i need to take a look at some of the recently released plugins.
Always something amusing there
Alrighty, thank you for the feedback! :). The way of using PDCs is a lot smarter, as it supports a wider range of use-cases and could even fire for offline-players (quest-systems, etc). I will revise my lib soon.
Memory-leaks galore, lol
i mean i still use player refs sometimes
but usually i do only so in event handlers
not in any long term variables
It's so funny that this is actually kinda the number one issue of all game mods, game engines and the like. How to handle disappearing entities. And they all solve it by IDs, because everything else is ending up in an unmanagable ratsnest, xD. Jon Blow talked a lot about this on his own engine.
i mean i use it cuz the uuid doesnt change
and its taking up less memory
not cuz its the correct solution
It's because you need to ask a centralized entity manager about the ID, and then are forced to handle the null-case.
And you don't keep the reference counter of the object up, xD
It's a crutch, kinda.
I have now partly recovered after looking at this pow code
the javadocs are already a gem lol
better look at the c++ pow code
that is IJ being IJ judging by the lines numbers
** NAN is NAN 4. NAN **
smh
now idea why the inline rendering is so weird
Not using <li>in conjuction with <ol>
Because HTML
You need <br> for line breaks
doesnt <p> work
Or explicitly create paragraphs. Either way, that is the wrong way to create a list
I didnt write that mess, it was the openjdk people who committed that crime
Wait, they use list items outside of an enclosing list tag?
You said <li> without <ol>, xD