#help-development
1 messages · Page 247 of 1
ideally you would be listening for quitevent
ye that's an option
lol
will have to wait till later when I am in a better position for math formulas and also to search back in the history
to refresh my memory in regards what it was I had given
oh right, exponential growth
i shouldnt have thrown my math book from prev year away
hmm if i put classes in the src/test/java package, those arent included when building the jar right?
also is a txt file supposed to be in the src/test/java folder?
has anyone here played with this before (can't make it run through vscode aldough other threejs stuff works) https://bs-community.github.io/skinview3d/
no they are not included in the final jar and are only used for the test phase
im trying to use a file with test cases, where should i put that? in the test folder too?
yes
it is the most ideal spot since it is for testing only
whats the formula meant to be
they have a cost for upgrades that increases the more it is used
currentCost + baseCost x amount?
but they need to know how much to subtract from the player or what is the most amount of upgrades the player can afford
ah
I gave the formula some time ago and I think they are having a hard time implementing it?
what formula did you give
yeah ive got no idea how you would impl that
math is confusing
just thought, if the price goes up by a set amount each time for the total cost of like 20 would be, might be wrong dont quote me on this
(baseCost^20) + (baseCost x upFactor)^20
the ^20 would be amount being bought
but then you have the issue of how many do they own
like this?
yeah that should work
well if you are only stuck on that part
then its easy
shouldn't need a loop?
from just skimming don't see why you couldn't
Anyways, if you already have it figured out how much it is going to cost for the amount
then you just need to get the players money amount they do have
and its just a simple minus equation and seeing if goes below 0 and how much below 0
how far it goes below 0, would tell you how much they could afford
easier way however is to incorporate into your function
PlayerInteractEvent is really broken in adventure mode, what should i do?
the amount they have, and as you calculate seeing if it goes over
then its just a minus equation then right?
if you know how much they can afford
just take that amount away from them XD
ok, but in order to know they can afford 30 upgrades
you would have to have calculated the cost
not sure why you are tossing away the cost to not then use it to minus from their bank?
well base cost is the cost of an upgrade without any increases
not sure what cost factor would be other then the amount of upgrades
has anyone ever wondered why paste is on md-5.net instead of spigotmc.org
because it isn't exclusively used for spigotmc
Any idea why nothing happends when I try to set resourcepack for player? Resorcepack URL is https://github.com/jwdeveloper/JW_Instruments/releases/download/0.0.1/instrumentpack.zip
that looks like cursed js
in a BlockDamageAbortEvent, will it call the event if they leave server or if they finish breaking the block?
try it. my bet is yes, but I also bet nobody here knows for sure
xD okay
all I know is that InventoryCloseEvent gets called when someone leaves the server while having the inv open
so I guess the BlockDamageAbortEvent gets called too
ah ok
isnt it PlayerInteractEvent?
yes it is
listen to PlayerInteractEvent, then check if the action == Action.PHYSICAL
e.g. this is how I cancel this in RePlant
well no, you should also check whether the "clicked block" is farmland
that should work
is there an intellij minecraft font
you can probably import it
@gilded knot if you want to replace existing commands, you have to get the command map via reflection from the SimplePluginManager
aight
here's how I usually do it
As you can see, I've already done it for bungeecord
seems like spigot is a tiny bit different
but sweet
the map will have two entries, one is e.g. "op" and the other one will be "minecraft:op" as key
aight
or, in your case, ofc "stop" and "minecraft:stop"
but @gilded knot you can also listen to PlayerCommandPreProcessEvent
mhm
then check if the message starts with "stop"
then just cancel it
that's probably easier
okidoki
Does this look good?
not sure if message contains the slash
I'll test it now
I don’t think it does
is that default font?
huh
how
its normal for me, I like it lol
man has a darker background
discord removed my darker build override and this man has a goddamn darker background lol
F
I mean
I don't use it but
You could look into betterdiscord
they have themes, you should be able to add a simple "darker" theme
bruh plz help
Use it at your own risk tho
too lazy for that
It works but only for players
I need it to disable stop command for the console
hmmm i wonder why PlayerCommandPreProcessEvent only works for players
op Ryzanite
[22:12:29 INFO]: Made Ryzanite a server operator
[22:12:31 INFO]: Ryzanite issued server command: /stop
[22:12:31 INFO]: Stop command detected, cancelling event
[22:12:34 INFO]: <Ryzanite> woo
[22:12:35 INFO]: Ryzanite issued server command: /stop
[22:12:35 INFO]: Stop command detected, cancelling event
stop
[22:12:37 INFO]: Stopping the server
[22:12:37 INFO]: Stopping server
[22:12:37 INFO]: [SDisable] Disablin
I know 😂 but what i meant was is there a console equivilent?
give me one moment and ill give you an answer
aight
ServerCommandEvent
In the EntityResurrectEvent, how do i check if a totem is being used by the player?
uh
In your event object
You should be able to get a bunch of functions
I'm not so sure
I'd imagine you could do event.getPlayer() and check if its not null
how does that check for a totem being used?
what is the best way to make my arrows get better homing
could i implement some basic path finding, how would i do that?
OH
I'd imagine you'd use a different event
Didnt get any other ones
Check the cancelled state of EntityResurrectEvent in the MONITOR priority.
So if the event is not cancelled in the MONITOR priority, the entity is being resurrected by a totem.
hmm k ill try that
its 10:24pm im tired lmao
Np tysm
@crimson scarab *
they are already homing, would path finding be visible
to go around obstacles and such
tried most of the ways provided by the event but it just provides null on player death or use of totem\
looking at the jd, you have a getHand() method which tells you the hand of totem
im pretty sure this will only get called if a totem is triggered
v
declaration: package: org.bukkit.event.entity, class: EntityResurrectEvent
tried it, just returns null even if i have totems
is the totem popping
yep
event would be called then
Caused by: java.lang.NoSuchMethodError: 'org.bukkit.inventory.EquipmentSlot org.bukkit.event.entity.EntityResurrectEvent.getHand()'
returned null
Plugin ver?
Server
hmm k
What version of spigot is your server?
Are you sure?
positive
it gives me an exeption
What exception
-_-
Check console
Pages start at 0 not 1
Ik java indexes starts at 0 so it's common practice to start indexes at 0
How do I get the items meta to constatly update
Yeah, but lets say Im trying to constantly get the location of a player
with a compass
I tried while loops
?scheduler
?scheduling
:d
i normally get that one right
to constatly add the location, but it only gets the location of the player when I run the command
do #runTaskTimer
update compass location on player move event
if your tracking a player
@modest current might be benefitial to check if the player has actually moved to another block for this
cuz that event gets called very, very often
even for mouse movement
yes
Whats the difference between saveConfig() and saveDefaultConfig()?
saveConfig(). saves the config, saveDefaultConfig() should take the default config from your jar and save it
^^
Does it create that much lag?
which
saveDefaultConfig is only rlly used on startup in most cases so
im guessing you mean saveConfig()?
well maybe with like 20 players it wont. but these events are called for every player
so it gets worse and worse
so i would just keep to good practise and implement a simple check
i used saveConfig() but after reloading the config the value (which i just updated) just gets reverted, tried using the saveDefaultConfig() and it worked properly
How would I actually check if he moved a full block
saveConfig() should be after any settings in the config
the event provides a from location and a "to" location
simply check if x or y or z is not equal
saveDefaultConfig() should just be on the default method
and use reloadConfig for reloading the config
any need to save the config before reloading?
if you save it when you set anything, no
ok
Anyone know if it's possible to make an itemframe ignore interaction events. I.e allow the player to break the block behind it ignoring the itemframe hitbox
Yeah I'm cancelling the event which just means it does nothing now.
Hmm maybe, but that would mean the block would break instantly
Since itemframes break after a single click
Yeah I think it's probably not possible from the client side
I thought I'd use ItemFrames to display items in front of a chest since it looks much nicer than using ArmourStands
How can i make this grass not disappear, when it is placed on ex. stone block? 1.8.8
https://medal.tv/games/minecraft/clips/KysQDajWIB_SJ/d1337iFVcCHd?invite=cr-MSxrN0gsNDI0MTk3Nyw
1.8 isnt supported
yeah, i dont know how its happening
How can I include an dependecy inside artifact with Maven?
can you give me some shade example?
<build>
<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>
<relocations>
<relocation>
<pattern>org.codehaus.plexus.util</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
whats the sourcee
what does nothing x everything = to?
also some people offer premium support to buyers
public class TestClass<E> {
public TestClass(String name){
Class<E> eClass = E.getClass();
}
}
why isnt something like this possible?
you might say because E doesnt have to be declared when creating an instance, then it should default to object
How do I make items drop right below the player (Im trying to simulate poop)?
depends on what you're doing
dropItem(player.getLocation, item) iirc
but you can create a data class that holds an entire row
when you get the data frm the database
oh well it depends on what youre storing in the db
But what do I connect it to
it would also be easier yes
Because when TestClass is compiled it doesn’t actually compile TestClass<E>, it just treats it as object and does all the type checking and casting automatically. You also can’t just do E.getClass() because E is a type, not an object, the same way there’s no String.getClass()
public class CommandManager implements CommandExecutor{
@Override
public boolean onCommand(UUID sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (sender instanceof Player && args.length == 1){
Player chest = Bukkit.getPlayer(args[1]);
Location chest_location = chest.getLocation();
chest.sleep(chest_location, false);
player.teleport(chest_location);
player.getWorld().dropItemNaturally(player.getLocation(), Material.COCOA_BEANS);
return true;
}
return false;
}
}
dropItem on'ly works for items they are holding in their hand.
this is what I have
or E.class
Right but it doesn’t know what E is
it really depends on the data you are needing really. In general most data in a db row isn't going to consume all that much data to be held in memory, but like lets say the row contains a BLOB, might not be wise to store that BLOB in memory as it could be quite large. So that would be an example of when it might not be best to cache it.
thats not the right format for the command either
I understand what you're saying but i also feel like since E is generic, you should be able to get the class
yeah it isnt
E is generic in that when the code is compiled it just treats it as Object
Ah ok
if I replace Player with UUID then .teleport() and .getWorld() get red outlined
How can I exclude directory from maven shade, this approach is not working
Yes I did that
?paste the method and ill fix it
Can someone review my code? https://github.com/EthanGarey/BetterServer
First issue. Do not call your plugins main class "Main"
💀
main class called main, making files(yaml configs) on other methods call them on onEnable, class names not following naming conventions relating back to main
Coding in Moo Language is Included in that
An ugly mess, that's what that is.
instead of checking if its what you want, check if it isnt and if it isnt return
Check the tools class 😛
so instead of doing
public boolean onCommand(command) {
if (args.legnth == 1 {
my code
}
}
DO
public boolean onCommand(command) {
if (args.legnth != 1 {
return false;
}
my code
}
WHAT THE FUCK
=== checks the equality of the object and its contents at the same time
my eyes
probably, but it won't work for some things though lol
they hurt
C++ Java
not sure what type rank is
I wonder if you stuffed d into an object it might work, but yeah for string literals it doesn't really work
Wait, that's not a Major Update, is it?
the version number hurts my eyes
whose code are we roasting right now?
3 is the best, 4 is a meh but 5 just smooths my brain
this
Thays too easy kinda low
ye
at least they asked for it
thought you guys were just randomly picking on someone for their code lmao
doesit have an update checker
also glad this isn't like a random code roast on someone either
my fucking god
the version number isnt even in pom
<version>1.0-SNAPSHOT</version>
what is that versioning standard
Well, it's not even Version 1
The pom looks like a copy paste pom
it's 0.0.3
0.0.3.4.6 wth
1.8.8 api 
main package is 'BetterServer'
no wonder cartography tables, smithing tables and that dont work
anyone got a lighter with them, we could keep warm off of this
Correct me if I'm wrong, but I'm pretty sure you can use ChatColors in Console, and even then this aint the way to use colors lol https://cdn.rackdevelopment.tech/img/IFWaojU3ZX.png
oh god he uses that replace thing everywhere
well if they are new I don't blame them for not knowing about the chat api having translatealernatecolors()
This might be a nitpick on my part, but instead of stuff like if (player.hasPermission("betterserver.permissions.back")) { for permissions I generally try to describe it a bit more, like pluginname.commands.back etc, would still totally work but yk
sadly bot is stupid
public fields 😟
i would change the permissions to betterserver.command.commandname
public static field 
I usually follow the convention <pluginname.command.<commandname> <pluginname>.<some feature>.<some feature specific thing>
public class CommandManager implements CommandExecutor{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (sender.isOp()){
if (sender instanceof Player && args.length == 1){
Player chest = Bukkit.getPlayer(args[1]);
Location chest_location = chest.getLocation();
chest.sleep(chest_location, true);
player.teleport(chest_location);
player.getWorld().dropItemNaturally(chest.getLocation(), new ItemStack(Material.COCOA_BEANS));
return true;
} else if (sender instanceof Player && (args.length == 0 || args.length > 1)){
sender.sendMessage("You must be a player to execute this command!");
return false;
}
} else {
sender.sendMessage("You must be an operator to execute this command!");
return false;
}
return true;
}
}
for some reason
it says it had some internal erros
please
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
sorry
Either paste it, or atleast use codeblocks
Im trying to lay someone down and drop cocoa beans on him
also a note on the above 'review', permission capitalization is not the same compared to commands and the events
lay them down?
array indexes start at 0, you are checking if the length is 1 and then indexing 1
How do I use codeblocks
-_-
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Alright
sorry, I learned how to do codeblocks
for some reason my keyboard doesnt have that symbol
should be under the escape key
Ohh thanks!
HAhahahaha!
public class CommandManager implements CommandExecutor{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (sender.isOp()){
if (sender instanceof Player && args.length == 1){
Player chest = Bukkit.getPlayer(args[0]);
Location chest_location = chest.getLocation();
chest.sleep(chest_location, true);
player.teleport(chest_location);
player.getWorld().dropItemNaturally(chest.getLocation(), new ItemStack(Material.COCOA_BEANS));
return true;
} else if (sender instanceof Player && (args.length == 0 || args.length > 1)){
sender.sendMessage("You must be a player to execute this command!");
return false;
}
} else {
sender.sendMessage("You must be an operator to execute this command!");
return false;
}
return true;
}
}``` For some reason now the player wont be forced to lay down. Does anybody know why?
ops sorry
you can edit the above message, don't need to resend it for the update to apply
The current version works fine, just adding java after the 3 ` formats it with the Java syntax
Im so sorry, Im very new to this!
Got to start somewhere
else if (!(args.length == 1)){
sender.sendMessage("You must be a player to execute this command!");
return false;
}
like this?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Alright
way to hard to read
!= 1 is cleaner and easier to read.
Understood
I still need help trying to make the player lay on the ground. Im trying to make it force sleep, but it ends up doing absolutely nothing.
lol
is there a way to add a countdown to a command (messages) without freezing the plugin ?
?scheduling
I dont know how a scheduler would help me.
A scheduler runs things in the future
you can scedule a task to run every second to countdown
added a scheduler thanks
na I get it lol, the reason it was broken is I didnt check if the homes.yml file existed until someone pointed it out
I haven't worked on my plugins in ages haha.
Hey, so I'm trying to create a land claiming system, where when player place a block it will automatically claim a 10x10 square area, what would be the best way to approach this?
Maybe I can create a bounding box but I'm struggling to get both corner of the area.
A 10x10 area using the placed block as a center or will the place block be a corner?
anybody here know the reason why bstats is down, maybe offtopic
The place block is the center.
well 10x10x10?
Ignoring the y level.
just subtract 5 from the x and z
and add 4 to the x and z
and you have your 2 corners
@summer scroll
Alright, imma try that.
@summer scroll https://muhammaddaffa.com/minecraftfolio/playercosmetics.html is this just a texture pack?
Yes texture pack.
Yeah it's from resource pack too.
resource pack and texture pack is the same right?
It's the same
https://paste.md-5.net/wuqisubuhe.java
In game its just not waiting and going straight through..
thats not how a scheduler works
wdym
By the way is this a typo or not? Should I add 5 instead of 4?
it wont care if the scheduler is complete before moving on, it just runs the method and done
Please learn Java lol
Atleast basics
..
oh okay
also btw i've been using java for like 3 years so don't pull that thread
Then you should beable to apply basic scheduling basic on simple documentation
You should also beable to do your learning from mostly online quick overviews
You can but your code logic exposes your inexperience
I simply reccomend you learned how java works and how to code
so youre saying i should relearn java?
You should learn how threading and task scheduling works if you already have 3 years of experience should only take a few minutes for the basic idea
..
You should be used to the basic patterning of programming concepts tbh 3 years os quite a while. You have much more experience than me
okay fine you're right ill consider reading the documentation more often
You should jsut read docs it's easier from a dev perspective I almost always read docs when it comes to learning basic concepts now
5 on 1 side, 4 on the other
remember, the block itself is 1
if you add 5 on both sides, you get 11x11
for even numbers, you do num/2 and (num/2)-1
for odd numbers do (num-1)/2
and thats both ur values
@summer scroll
Alright, thanks a lot.
you can set them to be a passenger
of an entity
Why doesn't PlayerInteractEvent work when i left click blocks in adventure mode?
?paste your code
https://paste.md-5.net/nuzolirahi.java (look at playerMouseInput)
dont think it registers for players in adventure mode
yo.. so some of my plugins are messing up with bedrock plugins any way to get that fixed?
also ill pay if anyone helps me im a bot at this server stuff XD
is there any other way?
Ask geyser
hi
i want to petrify a spectator, in 1.19
but there is no event like PlayerStopSpectate to use .setCancelled
What does petrify mean
disable move x, y, z, pitch, yaw
it occurred to me that if the spectator is spectating something inmovile like a boat, i can do this
but the problem is that the spectator can stop spectate the boat
are hex codes allowed in the ProxyPingEvent version setName?
is it just me or is https://bstats.org offline?
Yeah, it's down.
in Players setSample too as i see
is there a way to make chat preview validation.... quicker?
not an XY problem really, just wondering since it seems to be relatively slow and ends up still having messages be marked as not secure
"not an XY problem" i say as i state my problem
anyone know why intellij can't find some of the bukkit imports?
it worked until i uninstalled / reinstalled intellij
Try closing the project and opening it again, if that doesn't work, try building the project, might pick it up
Also try to invalidate caches.
how can i detect when player click button in demo screen?
How do I detect if a mob spawns when a chunk is loaded? I did this but those that spawns when a chunk is loaded isn't being detected, any fix?
public void onEntitySpawn(CreatureSpawnEvent event)
check if a chunk is loaded for the first time, and if yes, check all entities in it. afaik only on generation can mobs spawn without triggering that event
can some 1 help me?
It says that getting the entities in the chunk will force load it, the method is supposed to cancel the spawn event of the entities
Sorry I'm new to this
why cant you just despawn them
Hmm actually not a bad idea
Ykw I'll just despawn them, makes my life simpler
Thanks btw!
the simplest, stupidest solution is usually the easiest
Hi, so I want to change my config.yml a bit this is what it looks like right now (logFreezes: true logReFreezes: true GUIItem: ==: org.bukkit.inventory.ItemStack type: PAPER GUIItemName: You have been frozen by staff, please look at your discord! ), Currently GUIItem is just an item stack, but I want to change it so that it is just a list thingy like what it looks like now (So it is more readable), but I also want it so that it loops through the different items in the list for different items to show in my GUI, how would I do this? (If this makes no sense I will try explain it more)
Ideally I would like it to look like this ```logFreezes: true
logReFreezes: true
GUIItems:
item1:
type: PAPER
amount: 1
name: You have been frozen by staff, please look at your discord
(More items here)
item2:
type: FISHING_ROD
amount: 2
name: You have been frozen for {reason}
cant you override the serialize method?
wdym
I want to make a list I don't want to serialise an ItemStack into it anymore
just write the serialisation stuff yourself?
Thank you
why doesnt this work?
hey, what happens when i uncancel an previously canceled event in the same code block? will the event do, what it normally does so it just continues or is the event canceled once it got canceled?
so when i cancel the ExplosionPrime event and then i wait for an confirmation of the player in chat, will the event then just continue and the explosian still happens?
?tas
YO why tf does no body respond to me
Does anyone know how I can hide the player name tag ?
i have NameTagEdit API but it doesn't work
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
?
There are no errors. I think the error is from the API
just add all players to the same team, then set the option NAME_TAG_VISIBILITY to ALWAYS or however it's called
Pls update spigot for minecraft 1.19.3
How can i create a scheduler based on Real time like executing a command tells how much time is left, and it doesn' t stop on the plugin reload
no
Why :v
it's not released
just save timestamp in some kind of file/database
Why
ask mojang, we dont control when they release 1.19.3
and when you want to calculate how much time is left just do System.currentTimeMillis - timestampYouSaved
bruhh
Caused by: java.lang.IllegalArgumentException: Invalid page number 1/0
at org.bukkit.craftbukkit.v1_19_R1.inventory.CraftMetaBook.setPage(CraftMetaBook.java:424) ~[paper-1.19.jar:git-Paper-81]
at com.zushee.zmp.commands.Profile.onCommand(Profile.java:62) ~[ZMP.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
... 17 more
it just doesnt make sense
or maybe you're not making sense ?
c is a string not an integer it needs to be integer to set amount of pages of a book
That method can also receive varargs
It wouldn't even compile if it accepts only integer
ikr but his variable does contain non-number letters
Ok ?
declaration: package: org.bukkit.inventory.meta, interface: BookMeta
pages - A list of strings, each being a page
Its alright 👍
nvm i changed the code to this but now it throws an invalid number exception
bookMeta.setAuthor(player.getName() + "'s Profile");
bookMeta.setTitle("About Me");
bookMeta.setPage(1, "profile");
book.setItemMeta(bookMeta);
sender.getInventory().addItem(book);
sender.openBook(book);```
Caused by: java.lang.IllegalArgumentException: Invalid page number 1/0
at org.bukkit.craftbukkit.v1_19_R1.inventory.CraftMetaBook.setPage(CraftMetaBook.java:424) ~[paper-1.19.jar:git-Paper-81]
at com.zushee.zmp.commands.Profile.onCommand(Profile.java:62) ~[ZMP.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
... 17 more
the docs said that the pages are 1 indexed
lmao do you actually download your server software from this shitty illegal website?
why don't you just compile a trusted version yourself lol
that's like buying your groceries from some weird drug addict at the train station
because kids love downloading viruses
yeah I see lol
apparently buildtools is just too difficult for them
so where should i download?
nowhere
you cannot legally download it
you have to read this and build it yourself
?bt
?paste
ah nvm i think i found the problem
what the hell
how the fuck can my plugin contain EVERYTHING except for the plugin.yml file lmao
depends
on what
a normal loop is ofc a bit faster
however if you want to filter things etc, then streams already optimize do lazy evaluation and stuff or however it's called
what i wanna do is iterate thru a list until certain element is found
no
so if this is a general question, the answer is "it depends on whether you just wanna loop over everything, or if you want to do sorting / filtering / transforming / whatever too"
nope i just wanna find one item and stop
loops compile to an iterator
and what are you doing with the elements you loop over?
Stream#anyMatch
yup thats what im using
but why don't you just check whether List#contains(yourElement)
i need it to startwith
(a loop would still be a bit faster though)
then don't worry about it, it will maybe take 2 nanoseconds lol
how do i benchmark it
there are libraries for that, or you simply get the current time before running your loop, then get the current time again after doing it, then print out the difference
when I worry about performance, I usually do a for(int i = 0; i <= 1000) (I do the same thing 1000 times) and if it still doesn't cause lag, then you are totally fine lol
i want fancy stuff hehe
streams are fancy
still wondering how to use it for my parser
what, jmh?
ye, wrote a benchmark but dont what im doing
usually you simply write a test method, and annotate that with @Benchmark
looks good I guess
however no
random.nextInt takes quite long
you should generate the random numbers in a @Setup method
and store them in some array
otherwise you also measure how long nextInt takes each time
I'd just create a new int[100] in setup()
and then in your for loop, just do firstOperand = myArray[i] etc
is it possible to check blocks without loading the chunk in?
the only way this is possible is if you look in the region file yourself
a region file holds 1024 chunks, so if you mess it up thats 1k chunks corrupted/gone lol
hence why it is generally recommended not to do it
wheres the spigot server implementation
ty
did a benchmark?
what the heck are you doing
show your code pls
it should be much much faster
even my parser is faster
I love PluginUtils.whenInstalled
oh hell no
a tower of cables
Hi, can you please help me, I have a lens : https://minecraft-heads.com/custom-heads/alphabet/55583-monitor-1-green
and I have an url : http://textures.minecraft.net/texture/21d859e8b14f62646859cf3804a64f1060d6879341b4c3385b46a0ec40faf73c
I wan't in my code create a head with > http://textures.minecraft.net/texture/21d859e8b14f62646859cf3804a64f1060d6879341b4c3385b46a0ec40faf73c
please help me, can you give me the code please!!!
is there any easier way of storing a package name inside the source code than to use a char[]? :/
if it's a normal string, then maven-shade will relocate it so it becomes useless. maybe there's some annotation to tell maven to stop this?
what version?
hello?
Thanks
what is profile line 62 ?
if PlayerDeathEvent() would allow me to setDeathMessage(), but not let me check for specific entities as would PlayerDamageByEntityEvent, which doesn't let me setDeathMessage(), how would I go at setting a death message based off of specific entities?
since i'm not trying to check if its just been damaged, im trying to check if its killed the player
I don't think so
declaration: package: org.bukkit.event.block, class: BlockFromToEvent
this one
but note, it also gets called for dragon eggs
so you gotta check if the "from" block is water before you do anything
okay but it also gets called for lava
and raspberry juice, in case this will ever get added lol
I just made that up because I'm bored lol
its the setpage
you have to start with 0
the first page is 0
you cannot add page 1 if you don't have page 0 first
hmmm
are you creating a new book from scratch?
If so, try to use setPages("my first page", "my second page", "etc")
pretty colors
hm yeah that should work. just try to use setPages(String...)
BUT IT DOESNT
also, if you haven't tried restarting and make sure its not reload fucking something up id do that
it's a varargs method
?paste
you can also just toss in just one string
you still call setPage
no, the profile should only be one page
please, as I said, try to use setPages
alr
myBookMeta.setPages("my only first page")
?
bruh that works
oh ok goood
goofy ahh spigot
I think setPage only works to replace alrd existing pages
otherwise you could have used addPage
yes, but it is still an array
i didnt say that on the docs tho
any way to detect when player closes sign?
true
SignChangeEvent or sth I guess
alr yall tysm for helping FINALLY!
What event do I cancel to stop concrete powder turning into concrete?
⁉️
Check if the damage dealt would kill the player in PlayerDamageByEntityEvent
BlockFormEvent ig
yep @subtle folio
np
if (p.getLastDamage() >= p.getHealth())
?
Yup
either way i still wouldnt be able to .setDeathMessage
no..
idk wym then!
@EventHandler
public void playerDamage(EntityDamageByEntityEvent e) {
//send custom death message
}
@EventHandler
public void onDeath(PlayerDeathEvent e) {
}```
what's stopping you from doing either of these?
i have both i just dont know how to use them together to send a death message
if all you're gonna do is send a death message, make a custom one in PlayerDamange
Bukkit.broadcastMessage();
would it show the same way as a death message would?
if it was j a normal one
and what about the message that would send on top of the message id add? how would i cancel that one
.setDeathMessage(null)
in the onDeath
like that
oh cool
thank you guys!
I love how copilot sometimes suggests invalid code lol
but it cannot reach the last return statement
does anyone already know whether 1.19.3 has big NMS changes?
return switch
I am having an issue where whenever I add the 1.19 or 1.18 spigot api as a dependency, my project fails to build saying it cannot access my main package
anyone got any ideas why?
Also how did you add the dependency
how can i check if a player can see a chunk
the error is literally just cannot access dev.sirarchibald.<package name>
Are you using Intellij
yes
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Any buddy Know how to create plugin
Do you know Java?
don't think this is the place to ask for a tutorial mate
Plesss create plugin Naruto
'-'
I'm guessing you don't know Java
🤨
Just judging by your behaviour
Lets create plugin naruto
I know
Yes
this seems odd
asking developers to create a random plugin
is naruto that fortnite thing
?
No
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@tender shard optimized a lot and now its 0.2milisecs per 10k entries
😁😁😁
go download this
Thanks
but that also includes String.split so perhaps its a bit faster without that too
What did u say
im wondering if String#formatted slows my parser down with 200µs lol
how can i check if a player can see a chunk
i would be only worried about maybe 2 milis per 10k entries?
but no server will ever have 10k random teleporters lmao
lol
getting this on a completely clean project, for some reason I cannot build with 1.18 or 1.19 spigot api versions, but 1.17 works fine?
no, its the only package in my project
we'd need more verbose log
isnt it saying to look into Manhunt.java?
its saying the error is the first line, which is
package dev.sirarchibald.manhunt;
but I don't see how the spigot version is affecting it
the error only appears when I am using 1.18+
666
what
you are in help-development, so do it yourself
also wtf is "plugin naruto" lol
your java version is too low I guess
on the right side, click the uppermost entry, then ?paste the full log
Hi, anyone has a good packet tutorial?
for what? nms, plib, packetevents?
nms
thank you
doesn't really matter as i just wanna understand the bases
yeah i'll use protocol lib
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
https://github.com/MrMicky-FR/FastBoard try using this
someone should try jordan osterbergs scoreboard framework for me
yes thats good too
FastBoard doesn't deel with teams if thats what your talking about
its only packet scoreboards reccomended you just store them with a Map<UUID, FastBoard>
thats just dumb FastBoard is super nice
your loss
if you want to make your own just make a packet Scoreboard like fastboard
which would require NMS so pick your poison
I usually resort to APIs as that part of the API is nasty 🤷🏽♂️ not sure a great one for tab, but for your scoreboard FastBoard is super light and nice to use
even async wont save 10kx10k particle box 😦
I saw your message
iirc it got removed
i forget why
what is the best way to save dates to json files? How can I convert them from string to date then add 7days and convert it to a string again for example
can you compare BanEntry with ==
As an timestamp, but don't save to json files
just store it as milliseconds
^
Date date = new Date();
date.getTime();
So like this?
But how can I add days to it then?
store the ms and construct it back using new Date(ms)
you can get the ms from a date using ::asEpochMillis iirc
How? I could set everything but days somehow
I'd recommend using the java.time API instead of Date
^^
LocalDateTime is probably what you want, which actually boils down to epoch seconds, not millis. Though that should be fine for your use case
LocalDateTime now = LocalDateTime.now();
long seconds = now.toEpochSeconds(); // You can serialize this into JSON
LocalDateTime then = LocalDateTime.ofEpochSecond(seconds, 0, ZoneOffset.systemDefault());
LocalDateTime thenPlusSevenDays = then.plusDays(7); // Add 7 days```
(I'm using ZoneOffset#systemDefault(), but if you plan on storing data across systems, you should really specify ZoneOffset.ofHours(0) to get GMT)
Oh thats amazing thank you!
There is technically String serialization which is a little bit smarter and does include the time zone, and again, if you're serializing across a network, probably ideal to use that instead
would Instant work for that too?
It could but Instant is generally better used for times less than a day
I somehow need an argument here...
Oh you probably need a time zone
See this ^
I think ZoneOffset.ofHours(0) is probably better just in all situations in case the system time changes
oh yeah that works thank you!
I never understand whether 0 am is midnight or midday
Doesn't matter. It's the offset relative to GMT
e.g. EST is usually GMT-5, so ofHours(-5) would be EST
oh I was talking about real life
Or I guess UTC. GMT doesn't exist anymore lol
e.g. sometimes you see in american TV that something gets aired at "12 am"
is that midnight or midday?
Oh, yeah, I usually have to sit for a think about that too lol
24 hour time fixes it because it's either 0:00 or 12:00, but am/pm fucks with your brain a bit
exactlyyy
I mean we also say "5 o clock" although it's actually 17:00 but usually someone knows what you mean
e.g. noone would meet in a restaurant at 05:00 (am)
do your wall clocks have 24 hours ?
Guaranteed those exist, but I think all wall clocks have 12 hour time on it with 24 hour time below them
Like this
Right, are there any issues with storing ungodly amounts of data in PDC? Just realised that the method I'm doing things as is won't work, so i'm exploring new solutions, and i'd like to know the downsides of storing base64 encoded strings into a string pdc.
no
watches also only have 12 hours here
Meh. I'd avoid it if you could. At one point or another the NBT will be too big to serialize across the network
Nope, I'll be storing it inside an entity, and the string can get big, but won't necessarily
wdym with "ungodly amounts"?
a few megabytes?
a few gigabytes?
Oh I see.
and also, WHOSE pdc?
on a player, it should be fine for whatever amount you store. on a chunk, not so much
Theorically infinitely sized... realistically it won't ever surpass even 1.5mb
It would take a lot of data to reach that point because vanilla stores all discovered recipes on the player's NBT and it's fine if all recipes are discovered
An entity's PDC, specifically a boat's
1.5 mb is TOTALLY FINE
I have checked it once, using 1gb of data
Oh wait what? I thought that was ungodly sized
it was slow on shutdown, but otherwise it worked totally fine
1.5mb is nothing, don't worry about it
Oh my sweet christ, I see, I massively underestimated the capabilities of PDC
Thanks!
np
pdc is life
pdc is love
if lynxplay'd be gay, I'd make out with him for inventing it
Hi, how can i create an entity and then only show it to certain players? I know how to do the packet part but i don't know how to make the entity part, can someone help me?
How old is pdc?
1.14
1.13 had CustomItemTagContainers on items
pretty much same concept, just different name
1.14.1
for entities and itemstacks
1.16.3 for chunks
and 1.18.1 (not exactly sure) for worlds
i need some advice ragarding data saving.
im making a "minigame" and for that im planning on having userdata saved on mongodb. but this minigame has multiple game servers. and if the player switches from server i need to make sure his "old" server saves the data before the new server attempts to load it. my first idea is to just have a boolean saved in mongodb acting as "lock" is this a good idea. or is there a much better approach to this
intercept the change server, make it wait an arbitrary time, then make them switch
thats possible?
from bungee yes
but you don't need the bungee server to know anything, just that it should make them wait however long before switching the server
which should give your db enough time to save
you could do it from the mc server side, since switching servers is done with a command
true
hopefully that makes it easier then what you were planning 😛
well tbh i think i might still need to implement a lock
unless i have a callback to know when its done saving
and then make the change
Reids
Redis
and how would i use redis for this
basically redis just holds the data in memory
if nothing accesses for a period of time, redis can commit it back to the DB
Let redis have up to date data while the player is online
do the servers modify data directly on redis?
you can if you want to
right
If it doesn't have it, get from mongo
And cache on redis
Keep redis data up to date
but like whenever something about the player is changed i would directly commit that to redis?
Make sure redis data is time stamped
Yes
another alternative is just to let your servers talk to each other
Yep you can also just use bungee
I wasn't referring to bungee
how would you implement that alternative
not sure why everyone likes using pluginmessage channel, personally I dislike it. You can just make your plugins talk to each other...
You can create a bungee plugin that talks to the servers and relays info
Or even sockets
cant i just use redis pub/sub?
certainly
Yh
just was giving alternatives if you didn't want redis
not everyone is a fan of setting up another piece of software lol
well i alrdy have a good system for redis pub/sub so
Is this for anni?
that's cool