#help-development
1 messages · Page 2133 of 1
How can I easily turn a list of these:
into a list of Location?
I could iterate over each element of the list and convert then add
but I'm guessing there's quicker syntax
stream them
list.stream().map(c - > new Location(someWorld, x, y, z, yaw, pitch)).collect(tolist)
im waiting for the time two varargs parameters are possible
this is stupid lol
im still not sure what to do for this ```package com.tuwtle.TorchHandler;
import com.tuwtle.testplugin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class TorchHandler implements Listener {
public TorchHandler (testplugin plugin){
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void TorchBomb (PlayerInteractEvent e){
Player p = e.getPlayer();
Action action = e.getAction();
ItemStack item = e.getItem();
if (!item.getType().equals(Material.TORCH))
return;
if (action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR) {
World w = p.getWorld();
w.createExplosion(e.getClickedBlock().getLocation(),100,false);
Location explosionLoc = p.getLocation().clone().add(p.getLocation().getDirection().multiply(1));
}
}
}```
nothing happends when i try this
why returning after you made local variables?
idk
what did return do agan
that works
the issue i have rn is that im trying to make my have "reach" with the torch
so pretty much i want to get an explosion whereever the player left cliks
but to do that you need reach
so im trying to make the torch cause an explosion wherever i left click
how do i get the name of an enchantment?
probably the second part of the key
Works, thank you
I want to add and remove minecraft recipes from recipe book, is there a way to do it???
Also I want to add custom textures to custom items, but not checking the name, checking the Persistent Data Container
How can I send actionbar messages without legacy Texts in 1.8
I said without :(
1.8
?
legacy does that mean old?
yes
oh do you mean how to do it in modern spigot
Yes
player.spigot().sendMessage(MessageType.ACTION_BAR, new TextComponent(text)) and use a runnable to keep sending it
or it will be gone after a few ticks
man I've never thought having two classes shown at the same time on a 2K screen was so useful
also im a weirdo who uses light mode
on an ide
I feel like dark mode makes me sleepy
af
and in daytime my eyes have a hard time focusing on dark elements
can you send me your github link please!
Player#performCommand("/command") | Bukkit#dispatchCommand(player, "/command") | Bukkit#dispatchCommand(sender, "/command")
thankyoiu
One of them should work
heh
isnt it on my profile?
there isnt much on it
Heya guys, does anyone know a good replacement or if it works https://www.spigotmc.org/resources/itag.342/ ? Some reviews says that the skin can break
I want to see the sourcecode of the core you where doing
Because i want to take ideas to design some things
there isnt a lot of good stuff in it
can someone explain in simple terms what a daemon is in terms of threads? ex Thread#setDaemon(boolean), I thought daemons were to do with docker exclusively 😅
basically means background process
in Java, setting a thread daemon will make sure that the java program can terminate w/o having to await termination of the thread
(ofc the thread will terminate afterwards)
but well, in the background
(daemon isnt java specific though)
so its the equivalent of calling cancel on a bukkitscheduler task?
not really
oh
Threads run seperately to the main thread of execution but all fall under one java process, so when the main thread terminates these other threads will prevent the actual ending of the java process.
Setting the daemon to true tells the jvm that it is safe to just end that thread once the main is done so that the java process can finish
@dense geyser
so those other threads will finish their job in the background?
not in the background, they will just be terminated
alright, so say if daemon = true and I were using Thread alongside redis pub/sub, if the thread managing redis closed, would that also close any lingering pub/sub threads?
ah like that
Yep
interesting, thank you ❤️
noob question: how do I get the nametag of a mob (not the default name)?
so in a normal situation those threads will prevent the process from stopping but if they are daemon threads the jvm knows that it just can kill those in order to terminate the process?
myes jvm can pretty much end them whenever its plausible
alright, so I should just not worry about daemons rn then lol
it doesnt care about code statements such as finally
so lets say you do have a connection, then you might risk to leave it open
mye
well I use daemon threads for my pubsub implementation, but thats mainly for event processing and not the pub sub itself
mye a similar event bus to the bukkit one
since thats basically getting some data, process it, and invoking relevant observers
and can be completely isolated from any redis stuff
i see
so daemonising something like this would be a bad idea, since its just a publish?
public void publish(String channel, String message) {
Thread thread = new Thread(() -> {
try (Jedis jedis = getResource()) {
jedis.publish("channel", "msg");
}
});
thread.setDaemon(true);
thread.start();
}
thats probably a less good idea
alright
since it may not complete that try block fully (aka calling close() on the getResource()) to lend back the connection to the pool
if we're post finish state
thats a good point actually, thank you
tho I'd assume that you close the pool during termination in which it might be fine 
yes, but better safe than sorry ¯_(ツ)_/¯
yeah
idk much about jedis, but I do know its blocking when invoking subscribe, so using subscribe might be worse of an idea than simply publishing, and you're only publishing
so daemonising subscribe is a defo no no?
guys why is managing block states in Spigot 1.8.8 so difficult.
probably, unless it uses some internal thread that isnt daemon
but its nothing Id rely on honestly
interesting, alright, thank you
public int setCoin(FileConfiguration config, Player player, int number) {
config.set(player.getDisplayName() + ".money", config.getInt(player.getDisplayName() + ".money") == number);
coin = config.getInt(player.getDisplayName() + ".money");
return coin;
}
number is my args[1] and its doesnt setting money to my arg. Its setting to 0 Why?
cheers
I can give you a hand if that is your life
because I map NMS, and I can confirm bukkit over complicated the states systems in 1.8.8 or legacy versions 😂
(I map NMS for compatibility purposes, never for the purpose of replacing bukkit)
I mean I can do it now, its just there are a lot of things in 1.8.8 which don't have the honour of being made easier in 1.12+
also
the lack of pdc in 1.8 x-x
it's called NBT.
if only I knew how to implement it myself
you don't need to
yeah but NBT clears itself on entities
unlucky.
oh well..
Someone Know What should I do
save it
I would actually suggest you store the data in memory,
and when the server is shutting down save it to the file..
I had this experience where it was super slow to set values in-real-time to files in bukkit
idk why
a fileconfiguration is basically in memory
yeah but would you really like to specify every string?
#save is saving it to the file
like "player." + uuid + ".money"
everywhere?
instead you could have an Object like
"PlayerData"
that stores the money, status, rank (for example)
But I have addCoin,DeleteMoney too and they are workin
And I saved config on another class
why setting it to a bool too
oof
better than writing plugin: this
that's not java tho?
Is there a way to enable/disable pvp for a certain player?
block the damage event for that player
O
I see
There are no other ways?
I want to see the one that best suits what I want
what would you do otherwise
Idk lol
Hey. Does anyone know why I can't access my library's methods even though they seem to be loaded in properly?
I'm using Maven for both projects and I exported the library using maven & added it as a dependency. I've reloaded both projects, clean installed the library, and even restarted IntelliJ. What's wrong?
First image (top) is of the library when you ctrl+click on the import, and second is of the plugin itself
why this happening
Don't use static methods
is that the issue or is that just a practice
Just ignore
ignore
Because your code that's using your library is not in a method
it says that because you might of not registered the commands in plugin.yml
but after this shit commands are not working
Using a lot of static stuff causes lag
???
So something other than that is wrong
The code of the library itself looks like this:
Yes, the library is okay
?
Yes, that's decompiled
since when do static methods lag servers?
But the place where you try to use it is the issue
forever lol
class names starts with an uppercase character, the compiler thinks youre referring to a variable called main i guess
I said
NO?
excessively
Uhhh. proof?
Not always
.
got it, forgot you can't run code inside of a class (outside of any methods), only define variables
Yes, a lot
even excessively it won't cause lag.
it does
did you do the test?
static methods don't lag the server, they're just usually not really good for writing reusable code modules
exactly.
The server does not, but your plugin is less optimized
You clearly don't know what static is used for then. :/
@wind tulip you saw what i wrote?
statics are utilities for example.
why can it be
or singletons
yes
The person who taught me and 3 others
but
well I feel bad for you.
this still doesn't explain why I can't import the method
the import statement itself is also giving me an error
What about oracle themselves?
also method names starts with a lowercase character
but also I've renamed the class and before it was uppercase and still didn't work, so idk
Yes, because importing a static method directly needs an import static
oh
or just use <class of the static method>.<static method>(<parameters>)
always works
not that import static won't work ofc
I just think it's more organized, since it actually says the class before the method.
I looked for information too lol
I feel like I should keep it static then
This says nothing about performance
yeah...
It gives the other valid reasons for not using static, but it does not explain why it would lag a server
static methods are actually faster to invoke
This thread says nothing about performance impacts. It just reiterates what everyone else here knows about the static keyword.
for things that are not utilities*
I would add
yea
You're right that overusing static is not a smart idea, it just doesn't have the performance impact that you claim
I said in plugin optimization
Not the total server
What kind of optimization are you talking about?
response times
wait what?
I don't think that is related to static
indeed
I will search more then
well statics are loaded when the JVM is started and end when the JVM stops.
If I am not mistaken
correct me if I'm wrong
provided the class is referenced somewhere
when the class is loaded
iirc
I'm not sure about that, but that is possible, however that would be a microoptimization . I'm not sure how that would compare to creating a new instance of a class to use the method
well there's gotta be a point to using static.
if there's no point in using static, it wouldn't of been created.
utility
or it would of been long removed..
initializers
Utility is one. Another is to have something that needs to be shared between instances of the same class.
Statics have their uses
But I talked about its excessive use 😿
the point of static is for stuff that doesnt belong to a class
Not just a single variable
I guess you got a point
i like to think as static as a floating variable
it doesnt have a base, it just exists
you could explain static by saying its global
exists once
I understand that the static things are loaded into memory at compile time and not as the lines of code in the program are executed.
||Correct me if I'm wrong||
are loaded into memory when the class in specific is loaded*
loaded into memory at compile time that doesnt make sense
That's why I was told that its excessive use can lead to less response time or poor optimization.
Im not, but I understand that it works like that (That's what someone taught me lol)
||hope it wasn't a school|| it definitely wasn't.
Nope
what about static utility classes
shush
but yes,
oh lol, right does py still not have static when it comes to class declaration?
or global thing within a type
i’m basically certain you can’t
could use lombok as well but its incredibly buggy
@quaint mantle am i right
and inefficient
mye
wym
Doesn't Lombok just generate the code?
like static variables in python?
yes
ye
yes
Why would it be inefficient then?
hence its evilness tho Sansko
lol
didn’t realise
Yeah, I don't like it either, don't get me wrong 😂
wait
i don’t see this done ever
I rather use records nowadays
because theres no reason to
intellisense is broken + its not really executed great with having to do @extensionmethod(class1, class2) for every extension method you want to use
so a singleton would just be
class Config:
__instance = Config()
@staticmethod
def get_instance() -> Config:
return instance
?
@staticmethod as well
^
does the annotation even do something?
yeah
yeah
cause if not it will try and pass the instance as a param
lol
wait will it?
i’m on mobile
so predictive swipe typing goes brrrrr
I remember googling on stack overflow how to declare a singleton and I literally got 0 answers... and it was this simple all along
i can type with one hand efficiently
exactly
it’s cause no one in python knows what a singleton is
i’m yet to find a use for @classmethod
its useless
just gotta use kotlin where objects are technically singletons
even though they act like static in kotlin
@classmethod
def a(cls) -> None:
cls.__iter__ = lambda: SomeIter()
@opal juniper theres like no use for it
idek if that runs
@JvmStatic deotime :3
yea
its jvm
is that ferris in your pfp
its a crab
boring
I mean companions are great apart from the fact that you cant write them inlined
companion object const X = 5 would be so nice
true
the amount of times i strugged writing a main function when i started kotlin was unreal
weird
rip
ah so you can use class method for a factory function - but i see no difference between that and init
yeah its dum
isnt there getHook?
because it doesnt always have one
declaration: package: org.bukkit.entity, interface: FishHook
i literally just showed you how
🥲
i fully understood you
yeah I believe there might be missing api for this
md_5 hates fishing rods confirmed
lol ye
i have three hands
sounds a bit Illuminati
yeah ik
yes I just concluded it
zacken, you have your golden ticket to become a primary spigot contributor here :3
i mean theres like no way to do it
theres no point
because it would have to store the item and the player in a map
whats the best way to check if a player has a list of permissions?
just loop through them
sorry i meant if they dont have any of the permissions in the list
check if they dont have them
bruh
declaration: package: org.bukkit.permissions, interface: Permissible
no i mean the code would be shit for it
and dirty
no yes i know the hasPermission
but if there's 10 permissions im testing for, using if perm1||perm2||perm3||perm4||perm5 wouldnt be the best yes?
!?!
for (String permission : permissions) {
if (player.hasPermission(permission)) {
return;
}
}
this is just java dude
thats horrible dude
:*
player::hasPermission :3
;*
dude why can i never type things why do yall take my words
whats ur wpm btw
else if you're not trying?
like 110
looks way better than what Id perform so nice
i dont try that kind of tests cuz im soo bad at it
Player::hasPermission *
stupid question, but if I return something from inside an autocloseable try/catch, does it still close
well in my case it refers to the variable player but ye
yes
thats the point of it being extremely safe
a little bit yeah
I don't see it tbh
might be last time you see me with this pfp then 
It's hard to decipher
i mean i kinda see a dogs arse
I see an upside down dog
^?
You said the banner
pfp not the banner 🤔
right right
I thought you were saying the banner looked like a dog dick
possibly
What's the best way for me to trigger code for when a player walks into a specific area?
I'm making a boat racing game with checkpoints
easy enough to find whether the person is in the area or not
but the question is when to perform the check
every tick?
seems intensive
but I don't see an alternative
PlayerMoveEvent?
it can only be called once a tick though (per player)
so pretty much the same if not less intensive as a repeating runnable
a friend told me to do it lioke this but this keeps erroring this... what do i do?
?learnjava
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.
bruhs need to atleast know contructors come on
it says
again
learn java
clearly not
how do you have a year of experience yet have no clue why tf the super keyword is throwing you an error
look
I highly doubt you have more than a month of java experience constructors and inheritence takes a bit to get the handle on but don't say you know something you don't
i was told to put this into the constructor, what am I supposed to do with Main then?
I know how it works, but I don't know how the command system works here
i do know
so you have a year of java experience and still don't know that an interface can't have a constructor
bruh, can you just tell me why my friend told me to implement .setExecutor like that and what the correct way is
or just tell me the correct way
your using the setexecutor fine this issue is your arguments and your lack of ability to figure out basic constructor mechanics
super keywords calls the super constructor which can't exist for an interface because interfaces can't have constructors
your friend is showing you basic dependency injection since you have a grasp on java given 1 year of experience you should beable to properly use dependency injection to pass important objects at this point
ohh i see
I reccomend learning more java clearly your a bit slow to learn given you've already been learning Java for a year Spend some time working with inheritance and don't think any JS experience translates java and JS are very different
so i didn't understand that immediately
guys, how can I access player data using NBT, at the moment I'm doing it like this, but it doesn't go beyond 0 (XP is just an example, I'll get another data later)
apparently not 🤷♂️
I reccomend using Persistent Data Containers for this
I'll try
its super easy
thanks
how to set a players prefix via bungeecord?
is there a better way to add potion effects than addPotionEffect? it works initially but then stops when someone dies (even when i try to reapply it).
is it possible to make items like armor go over the 20 cap for generic.armor?
i want netherite armor to have double diamond and have 40 in total when all pieces are on, but i cant because of minecraft's cap.
again, is there a way to bypass this?
(i'm not in a position to code this myself tho :(. )
would making a run task later for 15 minutes to forcefully end a duel in my duels plugin affect performance hugely
no
anyone have any ideas on the best way to force a player's client to re-request a chunk?
or, alternatively force the server to send an entire updated chunk (rather than individual blockChanges) so the client reloads the entire chunk?
there are methods to send chunk updates in the api
declaration: package: org.bukkit, interface: World
ah, perfect... that solves one of my problems!
the other is that I'm sending a decent number of block change packets to players... I notice some of the world methods allow you to request changes and have them queued (like unloadChunkRequest(...) instead of unloadChunk(...)... does anything like this exist for block change events? I'm trying to spoof a pretty large structure and would prefer to queue these events instead of sending them all at once
When did they add the ability to send plugin messages just through Bukkit.getServer()? Literal blessing lol
you will probably have to create your own mechanism that prevents sending it all at once. The reason a queue exists for unloading chunks is because MC caches recently loaded chunks as well as a chunk could be valid still in being loaded. So the queue exists for the server to recheck if it can unload it.
gotcha, that makes sense
what's the easiest way to make a config folder like the one viaversion has?
By using #saveDefaultConfig()
reloadConfig() overwrites the current config file with default right?
Also, if the file doesn't exist, does it just make it?
#reloadConfig() updates the cached version of the config by reading what is on the disk.
Yes, #saveDefaultConfig() will create the file if it doesn't exist.
how often should I do reload config
and does savedefaultconfig have a different file than saveconfig?
Depends on your usecase. Normally, you would only need to call it if you are making changes to the config file manually. Usually implemented with a reload subcommand.
#saveDefaultConfig() will look for a file called config.yml in your plugin jar and then write it to disk if it doesn't already exist. That's all it does. It's the same exact config that's returned with #getConfig().
What are bungeecord plugins?
Thanks
is there a github repo or guide anywhere on how to get started with bungeecord plugins
plugins that run on a bungeecord proxy as opposed to a spigot server
how do you make them
very similarly to how you make a spigot plugin
and all the documentation is in the same place as it is for spigot
What is bungeecord and why bungeecord over spigot
it's not an either-or
bungeecord is a proxy that can be used to link together multiple spigot servers
you can't just have a bungee
the guide is in maven
is there any gradle guides
or at least any tips on what to watch out for
all right thank you
Can you send a plugin message async?
what content is given to saveDefaultConfig? the docs doesn't show any arguments?
The contents in the config.yml that is part of your plugin.
oh, what's the path to it? src\main\resources?
?
The path #saveDefaultConfig() uses is the parent directory of the compiled jar. So maven will take all of the resources from /src/main/resources and put them in the parent dir of the jar. (This can be changed of course, but it's default behavior)
ohk
Is there an event that is executed when the player puts on an armor piece?( I just searched the javadocs and didn't find one, does anyone have an idea how to do something like this?)
There's not. You'll have to check for a few events in order to cover the full functionality.
InventoryClickEvent - Check to see if the player shift clicks armor in their inventory.
InventoryDragEvent - Check to see if the player manually moves the armor to the armor slots.
PlayerInteractEvent - Check to see if the player equips the armor piece from the hotbar.
Alternatively, you could use this resource: https://github.com/Arnuh/ArmorEquipEvent
weird
i right clicked an entity and it triggers the left one
how come it would trigger the one :/
kind of weird that there isnt
all the others use some weird methods as well
i would honestly just think someone would have made something with nms
What event are you listening on?
Player interact event and Player interact at entity event
picture above is PlayerInteractEvent
It is a little weird. I'm surprised that it's not a thing as it could be done all the way back in 1.8
yea
If you want to check if the player is right clicking an entity, use the PlayerInteractEntityEvent
If you want to check if the player is left clicking an entity, (effectively damaging it) use the EntityDamageByEntityEvent
I'm not damaging it
i left click the staff after right clicking an entity
but then it triggers both at the same time when i right click an entity
so entity damage event is not applicable here
I see
theres a lot of them as well
honestly would probably be better off just using that resource
as theres also a ton of blocks that dont equip the armor when you right click
Well it's likely that you aren't using the right event or that your checks are slightly off.
What version are you using? Because the player interact event can fire twice if you don't check the hand the player uses. Since we have two hands.
have u checked the 2 pictures above?
I'm explicitly checking the action and hand there
player interact at entity event only has hand checks unlike the player interact event
Sorry, I thought the names were MAIN_HAND and OFF_HAND, not just HAND.
Maybe that's for inventories.
isRightHand for player interact event, the second picture is not reference inside a variable
entityinteractevent gets fired twice for some reason
a lot of servers have that bug
based from the checks it shouldnt be even triggering left click when I right click an entity
or maybe its intentional with how clicking it works
so it might be the case with player interact at entity event not having appropriate #getAction checks
i dont think thats the case
would gladly accept a reason why if its not
so its a server side?
no
Doubt it.
dont think we're talking about the same thign
Also, for clarification., Are you using the PlayerInteractEntityEvent or the PlayerInteractAtEntityEvent?
I'm using the first, to be honest I didn't event know the latter exist
HELP ME
PLS
"Cannot send chat messages" in multiplayer (chat settings are already on SHOWN AND CONSOLE NO ERROR)
pls
im using the parent class then
Alright, so let me see if I understand fully.
You have a staff that you need to right click an entity with first. (That's covered by the PlayerInteractEntityEvent)
The player can then left click on either a block or in the air to activate the ability of the staff. (PlayerInteractEvent)
Is that correct?
correct
Ok, so then it comes down to how you check for things.
when right clicking the entity it then triggers the left action in the player interact event
these doesn't happen on some servers but on my local one it does
Then you probably need more checks in your PlayerInteractEvent.
Like, staff state and whatnot.
It may also help to break up your if statements.
if (!(stick instanceof AbstractStaff)) {
return;
}
if (!(event.getRightClicked() instanceof Player)) {
return;
}
// etc
ok so
you are never left clicking
and somehow it ends up firing a left click action playerinteractevent?
yeah
exactly
its damn weird
but since they are both interact events idk why though
It's likely an issue with just one of them.
Something unaccounted for.
Can you share the code for both events?
?paste
dont you only really need actionright or actionleft
seems redundant to have both of them
That's true.
wdym
He only needs left click for the player interact event.
actionRight, !actionRight
fair
That, but also he stated that players will left click with the staffs.
yea
I'm just making it more readable though but ill take that
Well, are there different types of staff implementations? Because you could make another event and just check if it's a different staff. A little redundant, but guaranteed to work.
only have entity staff implementations
Well you may want to split your logic up like this then.
if (!(stick instanceof AbstractStaff)) return;
if (!(stick instanceof EntityStaffImpl)) return;
if (!isRightHand) return;
if (isRightClick) {
// do right click things
} else {
// do left click things
}
then any staff that doesn't implement entitystaff aint gonna work
But you said that's all you have to work with. :3
but thats good for a seperate listener
Not sure if u mean staff implementations but entity staff is just an interface
Yea, I was asking if you had other ones that you were going to check for.
Cause if that's the case, you could just copy the listener and change the one check.
no actually, thats why I have instance of check in the if conditions
So what's the issue with just checking if all staffs are not an instance of EntityStaffImpl?
It would still meet the criteria would it not?
I would have to move the #onClick method above for abstractstaff only
if im using ur code above
cuz I dont have in mind of making seperate listeners for this
when the checks are on time and should not be even triggered when i right click
Appreciate your time though ill be heading out for now
so i am working on a plugin for a sub server that i host and im trying to make it so u can walk up to any living entity shift right click then pick them up into ur inventory but when it comes to villagers how would i say collect the data needed so if they have a job when they get spawned back into the world that they still have that job
store it as pdc in whatever item you're using to identify
then read the pdc and do w/e when they place it back down
well i have looked through things but i cant seem to figure out how i get the profession they have as im using the PlayerInteractEntityEvent
I thought i was alone
right clicking will trigger the offhand interact aswell iirc
its not just right and left theres also offhand
Check if the entity is a villager then cast to the villager class, then you can get all the needed stuff https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Villager.html
declaration: package: org.bukkit.entity, interface: Villager
how peculiar
very peculiar, but I'll adjust add a workaround for that
okay i will look into thanks for the help @ancient plank
Is there a way to send a player to another server while the server is shutting down?
Like a pre-disable event or someethhinggg because plugin messages don't work when the server is shutting down :(
its an error not an exception
use catch (Error e) or catch (Throwable t)
if i increase the atribute of strength by one will it double the damage?
you are using a different api version to server
how is public static Object obj; static abuse
context?
Its public, static and non-final. Which should never be done for several reasons. One would be that you always want to have some sort of encapsulation.
class X {
public static Object obj = new Object();
}
class Y {
void x() {
X.obj.toString();
}
}
another reason?
Prime example of static abuse
Some person I know
well, thats reason enough
is really experienced however he still static abuses
anyone here good with python xd got an assignment due in a bit 😂
"experienced dev"
} catch (NullPointerException e) {
// This will be thrown when/if the API server is down. Ignore it and act as if the uuid is valid
// until the server comes back up.
}
Because thats how you handle connectivity problems...
Lmao
xdd
Or this:
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
return sc.getSocketFactory();
} catch (Exception ignored) {
}
Do you want to get bugs that need to be tracked down over a week? Because thats how you get them.
Wait why does it keep doing mojang lookups on the player UUID?
Anyways thats static abuse what hes doing
he kept saying
that its a singleton
and that nothing that makes it static abuse actually applies to his case
api = new Hypixel();
auctions = new AuctionHouse();
why don't he just declare them right away and make them final
Making a class a singleton doesnt mean you can make everything static in it. That defeats the whole purpose of a singleton.
and whats the purpose of all those new threads
You fool. Experienced devs dont use executor services. They just throw new threads into the mix to make everything fast and cool.
ah yes lets trust all certs and not validate with a CA
always a good to ignore the security of https with MITM 🙂
dont use a what? im always on the main thread
has anyone found a solution to this?
I am currently moving around an armor stand using that packet but it seems like I am getting the same desync issues
Whats the desync issue?
o
embeds dont work?
the positions of certain bones start clipping in-game but in blockbench they arent
How do I shut down ma server without flagging Pterodactyl as crashed?
This smoothing out looks like you are using move relative packets instead of only concrete teleport packets with position and rotation
o
the protocol specified that I should use move relative packets for movements < 8 blocks
should I just be using teleport packets then?
Actually na I figured it out
Yes try just teleporting packets. Move relative lets the client interpolate the movement between two positions.
are the xyz absolute in this packet? https://wiki.vg/Protocol#Entity_Teleport
Yes
will there be any downsides to me using this packet? since in the past I was told to not use it when movements are < 8 blocks
It might look a bit more like a discrete movement and the packet size is slightly bigger.
Make a new branch and test it out 🤷
I see
thank you for your advice
I've looked across the internet and couldnt find anything, but youve helped me :)
Is there any useful tools for creating a regex? I keep struggling with it.
please dont use generic exception
your possibly hindering your plugin of handling other unchecked exceptions
You need to modularize your project or use something like XMaterial
I cannot seem to figure out how to set the result of a grindstone when a certain item is used, does anyone know a way to achieve this?
braindead question but the docs aint that well in that category
how to get the kind of player respawn?
worldspawn, bed, anchor causes?
or does the anchor also use the bed spawn loc?
I think the docs are pretty clear on that...
How can I disable an item drop? (not done by the player I mean when the block breaks)
There are 2 ways. Either listen to the BlockDropItemEvent and clear the list or listen to the EntitySpawnEvent if you want to disable the type of item overall.
I will try the BlockDropItemEvent, thanks !
How can I check what version was something added in? because I don't see this event and I think it was added after 1.8?
1.8 is ancient and support for that version was dropped literally years ago... Update to a version that is actually used by people.
Yeah but I have to use it for this plugin because of the PVP
I agree that it's harder coding in this version but I dont have much choice
why can a switch statement not be used with a double 🤔
1.8 is used
Because a double is ambigous.
You should never do something like
double x = ...;
if(x == 0.0165) {
}
You should always have an epsilon value.
private static double EPSILON = 1E-12;
double x = ...;
if(x - 0.0165 < EPSILON) {
}
Yeah sure. By like 7% of the playerbase (constantly shrinking)
🤷
what does this actually do 🤔
I'm guessing it's needed cause of rounding errors
but how does the epsilon help?
it dictates how many places from the decimal is acceptable
the ambiguity comes in when you have CPU's that support varying levels of floating point values
I see
I guess I could store an int and just the number of ticks instead
I'm working with time
I only need it as a number of ticks
Making a racing game
Using a runnable for number of ticks is probably more accurate for timing anyway
cause server lag won't be counted then
probably a separate thread would be better but again depends how accurate you need it to be
runnable won't guarantee accuracy. Runnables are affected by lag
ik, the point is they are affected by lag
if there is lag, the longer it takes to get to the task for the runnable. Unless the runnable is running in a separate thread
say the server is lagging and a player goes around the track
it will take longer for them to get around than if the server wasn't lagging
so if the rate at which the runnable counts is also effected by the lag, and is just counts the number of ticks, it takes the lag into consideration so is more accurate
effectively the time isn't affected by the lag as the player also lags
at least that's my theory
How can I remove lore using a grindstone
because there doesnt seem to be a PrepareGrindstone event like there is for anvils
When creating a potion effect, amplifier level 0 is effect level 1 right?
let me check
^
check if the inventory is grindstone
what if my client sends 2 block breaking event requests within 1ms, will those 2 requests be reckognized with 1ms or 20ms
with the next gametick
its ticks
events are queued
since theres 20 ticks in a second
50ms
The issue with that is than as soon as the event finishes, the grindstone will replace the "result" item with the vanilla item
so if someones cheating by breaking 9 blocks at once, theres no way to determine it by delta timing
?
there is
how
yea thats what i do
but if the requests being queued with 50ms
how can i determine <1ms
good point
hm
?
how to practically determine a cheater then
whos breaking blocks spherical around him
automatically without actually mining them
just sending requests to the server
the docs 90% of the time is what I see in my ide
how to remove ai form mob
you can create a class extending the mob u want
thats complicated tho

https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/LivingEntity.html
Check the setAi(boolean) method
declaration: package: org.bukkit.entity, interface: LivingEntity
This may not be possible, but is there a way to get the InventoryType of the Inventory that an item is shift clicked into?
getClickedInventory() returns the inv that it was clicked from, not the one that it went into
and I cant see and other method that would find it
exactly
the event will be called when you click the inventory
and you have both top and bottom inventories
so you can check if the below inventory have enough space to store that item
It seems that I have misdiagnosed my error, thanks for the help
you can check the current item
its the item thats inside the player's hand
if there is one inside the hand, that means it was taken
if there's not, it was placed
@faint harbor
i suspect thats a noob question but anyway ```java
public static HashMap<String, String[]> anticheatParams = new HashMap<String, String[]>();
ArrayList<String> list = new ArrayList<String>();
list.add("test")
main.anticheatParams.put("", (String[])list.toArray());
getting a typecast error
You'd need to use List<String> instead of String[] in your HashMap declaration
An Object[] is a primitive Array in Java. List<Object> is a data structure that internally probably uses []
yea ofc its just a wrapper that re-declares its primitive array internally
with the new size
but the return type of .toArray() is Object[]
so i thought i could upcast the object array to a string array
sec lemme check
ill prob just declare my own array with the size of the arraylist then if thats not working
just use toArray(T[]) or use a Stream.toArray(IntFunction)
Oh ofcourse, I missed that part. Yes, the toArray() returns an Object array because Java removes the generic (<String>) information while compiling. This makes it impossible for the JRE to know the actual type of the Array it should build during runtime
as @tender shard said, toArray(new String[0]); will probably give you the right primitive array type
You can just create an array with an empty size in this case. It will only use it for the type lookup
kk ty
if those aint working ive written a simple alternative
if (parser.jumpToHeader("Config"))
{
parser.setSeperatorValue(',');
while (parser.getNextLine())
{
ArrayList<String> list = new ArrayList<String>();
int i = 0;
while (!parser.getValueString(i).equals(""))
{
list.add(parser.getValueString(i));
i++;
}
String[] arr = new String[list.size()];
for (int ii = 0; ii < list.size(); ii++) arr[ii] = list.get(ii);
main.anticheatParams.put(parser.getKeyValue(), arr);
}
}
like that
but prob wont say much to u since the parser is my own custom ini parser
so theres no documentation xD
while (!parser.getValueString(i).equals("")) and this works because ive written the parser that incase the value is null to return ""
cause i prefer ini, its data structure isnt as complex
to be fair, i serialize most of my stuff anyway, i only write those files for config files that are supposed to be edited later on as plain text
anything backend only is stored as serialized objects anyway
I don't know why but my command doesn't show up ingame
Did you register it in your plugin.yml?
my command is registered in plugin.yml and in the main
version: '${project.version}'
main: com.ytg667.economy.Economy
api-version: 1.18
prefix: Economy
permissions:
economy.*:
default: op
description: Allows you to use all of the economy commands!
permission-message: You not have have permission to use this command.
commands:
getCoins:
description: Lets you collect any coin
usage: /<command>```
getCommand("getCoins").setExecutor(new getCoins());
Where are you executing that line?
in the main
Where in the main?
onEnable
That should be fine. Does the server show any exceptions?
when I try to use it, it doesn't try to autocorrect me
it doesn't show up
no
Does the server log show any errors on startup?
the command is also not executed
let me check
there is nothing in console
it only says unknown command ingame
@fossil lintel
is the plugin loaded?
Could you share more of the server log?
Like, the whole log since startup?
ohhhhh
i got it
i have & in the name
try to execute the exact command /getCoins
the problem is that i have & in the name
@fossil lintel @tender shard works now with declaring the null sized primitive as param like this
list.toArray(new String[0])
teye
np
isn't there just .toArray(String[]::new)
no, that's for Stream.toArray
oh rip
Collection uses toArray(T[])
probably not 😄
im using an arraylists method to typecast itself to a primitive array
that's invalid
Ahh, Method references
btw since Spigot includes Apache commons, you can also just use ArrayUtils.toPrimitive
List<Integer>
ik
alex you lied to me
how?
Ooooh it works
oh well java 17
new ArrayList<String>().toArray(String[]::new); is possible 😄
I always answer questions for java 8 because that's the most common one
it is ? 👀
people who also support 1.17 for example
1.17 was java 16 wasn't it
Those poor 1.8 souls
yep
Yes, but everyone should be using Java 17 anyway since it is the LTS release
yeah maybe for MC. If you install any linux distro, they either have java 8 or java 11 included by default (well, at least 90% of them)
yeah which is good, but unless java 8 has disappeared, I won't use java 17 since tbh it doesn't really add anything you can't do with java 8
They're going to speed it up to every 2 years instead of every 3 years
sure, it has some nice convenient features, but nothing that one would really need
I would die without records
Running Minecraft 😄
I just use @Data
lombok 
I'm working on a bedwars plugin and I want to make it so players won't be able to break blocks of the map but will be able to break player-placed blocks
I thought about saving the player-placed blocks in a config file and then in the blockBreakEvent check if the block is in the config
Is there a better way to do this?
i odnt think so
I mean, you don't want to do IO
I'd store the coordinates of player placed blocks in the chunk's PDC
a config seems useless
ye
PDC is probably better here, maybe there is a cool lib for that
🤔
alternatively, which is probably the easiest way: hook into coreprotect or similar
Yeah or just allow players to only place a specific kind of block and allow destroying of those
i'd probably create a custom data class that implements configurationserializable that represents chunk coordinates (three shorts/ints) and save those as Set<ChunkLocation> inside every chunk's PDC
Thinking about it, maybe I can just color the name of the blocks and check if the block placed has this name
but player placed blocks should be breakable too
Block lose their name data after being placed
I thought ONLY player placed blocks should be breakable?
Yeah
so just store a List or Set with the chunk coordinates of player placed blocks in the chunk

