#help-development
1 messages · Page 2252 of 1
Also checking equals like that will randomly fail.
location.clone().add(location.toVector().normalize().multiply(5));, do i just add location.getDirection() or smt do the normalized vector?
i usually do
The issue is when bukkit/spigot do the look up of the class or more precise when it "look up the method via reflections" So don´t this way stop with only the method bu also read whole class.
vector.multiply(direction.multiply(whatever))
Check the diff between the inventory during and one tick after the event.
You can also go through all the click actions of the event and predict the outcome. This however is very labour intensive and error prone.
so like i.e. when u wanna send a player forward in the direction theyre facing
Thats wrong. java location.clone.add(location.getDirection().multiply(x));
do it please
it would be
player.setvelocity(player.geteyelocation.getdirection.multiply(...));
sorry parentheses too annoying on mobile
cba
😭
Ok thank you
Im currently indexing. Gradle being a slow poke again.
not moving the player @maiden thicket
well what are u trying to move
I'll try this
A position
just a location in general?
Just need for particle spawning, I got everything apart the movement for that lol
once the movement is done then yeah i am finished
Well and making a shape renderer :D
i used the tutorials all over spigot's page
theres this one guy
who has like so many helpful resources abt vectors and particles
ye it's been a while since I did vector maths
this broski
well I almost got it working
I am encountering some issues with my particle spawner, but that's fine
I know how to deal with it
This needs to be cleaned up lol
Never say that again.
Messed something up somewhere
declaration: package: org.bukkit.entity, interface: Player
Can I put the local file as url parameter?
It doesn't seem to work
p.setResourcePack("root/server/texture.zip")
I do not think so because that would not be recieveable by the client
If I were to set it to false would it just give them 5 hearts? I don't understand this at all. I just want the player to have 5 hearts.
I've done this before and I haven't had to mess with health scale at all.
just the attributes.
how would i set the drops of a entitydeathevent
I think you can manipulate e.getDrops
Im not sure if ProtocolLib has proper abstractions for this packet.
Its very convoluted.
Yea, I was right. There was a plugin conflict... Don't have to mess with the health scale at all.
so cant i change title of it?
:<
the client downloads it
Just created a direct download link and it worked
Ill do it in nms first and then ill see if it is even possible. If yes then ill see how to approach this using ProtocolLib
I'm still seeking potential solutions to this, should there be any takers 😁
ok. what is nms
Okok I fixed the part with the spawn location. Still seeking an event for entering the fountain portal though??
is there a way to simulate the EntityDamageByEntityEvent to get the final damage?
Technically you could call it manually altho that could be dangerous
entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() * 5);
why doesnt this work?
like the health doesnt change
believe you need to update it manually perhaps?
(basically use setHealth as well subsequently (if its higher))
How i can fix the issue between Mongo codec and shity Location object?
Im exausted because shity location doesnt use native types like double, int, it uses Double
Yeah, event constructors are not public API
For whatever reason
BungeeCord Setup:
Server 1:
[16:16:54 INFO]: WitheredToast lost connection: Disconnected
[16:16:54 INFO]: XXXXXXXXXXXXXXXXXXXXXXXXXXX QUIT time in ms: 1656778614347
[16:16:54 INFO]: WitheredToast left the game```
Server 2:
```console
[16:16:54 INFO]: XXXXXXXXXXXXXXXXXXXXXXXXXXX PRE-LOGIN time in ms: 1656778614198
[16:16:54 INFO]: UUID of player WitheredToast is cfc65be8-0293-468a-a8d9-c7a52202bb5f
[16:16:54 INFO]: XXXXXXXXXXXXXXXXXXXXXXXXXXX JOIN time in ms: 1656778614293```
Hey, is this just some inaccuracies with System.currentTimeMillis() or is the join even on the 2nd server actually calling before the quit event on the 1st server, when switching servers on a bungeecord?
I'm essentially just trying to figure out what the best way and event would be to save and load data again inbetween server switching, AsyncPlayerPreLoginEvent wouldve been my preferred option as it makes the other stuff wait while async loading the data, but that seems to call way before the quitevent, which kind of makes sense.
Now back then without thinking about it i had a redis - sql setup which was saving data to redis on quit and loading it on asyncplayerpreloginevent again but according to this logic, the data loaded from redis on asyncplayerprelogin event shouldnt have been the most up to date one, but it always was
OH lmao for one second i read redis is slower
😂
Yea i know that, that was the entire point of that setup back then, but if we're looking at this, the quit event is called after the asyncplayerprelogin event, which does make sense
Yep - join is called before quit
so how would the data have been up to date?
prelogin -> fetch data -> quit -> save data -> fetch data request received -> response
Catching it
I am not too sure if the PlayerJoinEvent is called after quit though
catching what?
what i did back then was loading the data on asynclogin and saving it to redis on quit
when switching inbetween servers like this, it was working without any issues.
But since quit is called after asynclogin this doesnt quite make sense to me anymore
Proxy:
- Join -> Load data
- Redis cache
- Quit -> Save data
Is there any recommended event to save/load the data in then? cause im honestly not confident in using any of the Quit/Login/Join events if quit is seemingly called after the joining ones
autosaves and caching data on other servers is ideal
Yeah its really diff and mostly when should be all up to update on less time posible
I have a cache that makes it so that all the connected servers receive the data and hold it for 30 seconds, so that it's pre-loaded when the player joins
I forward recommend something like Redis cache and pub-sub for doing that
hm, issue with that is low key, i would most likely only ever be saving any data to redis like every minute for redundancy, and when someone leaves after a save has been made but inbetween their data has already changed again, then it would still be off
No because you can use pub-sub for pushing updates
Save operation:
send packet to all servers saying: <player uuid> is saving
save data
send packet to all servers saying: <player uuid> is done saving, followed by the saved data
Load operation:
Check if the uuid is still saving, if so, await for the following packet and use its data
If it's not being saved, safely fetch
If we're still fetching, and receive the save packet, we cancel the fetch operation and go back to load step 1
Oh lol never seem that
It's kinda wonky but it accounts for delays and all
Hello, i have a question, im recoding my StaffMode plugin Items, i want create a class for all strings, i want to automatic add the lore in the same class without creating a "public method" (Im new to java and spigot api)
This all seems good and all, but i still wonder what happens when a save has happened, the other servers cache the data
the data on the server the player is on changes, now he switches servers, and the data on the other servers would be wrong, no?
the autosave isn't the only save operation
ive done something similar before with a standalone system, servers can "loan" playerdata from the system. where other servers can only get it when the system has it back
when do you save then
aaa
ehh
No no
yea i can account for the cancel tho, thats not really the issue, but i need some of my data on join already
then uhh
timestamp everything
your problem is that you're doing it too fast
You can delay it a bit on the proxy side or something to account for that delay
or you delay moving them from server a to server b on server a until write is done 🤔 not like they can get to server b without server a initializing it
since asyncplayerpreloginevent is called before quit tho, the save wont be happening until the preloginevent is done
Well you don't save on quit
when would i save then
before moving
you save when server a initializes a move to server b
is there an event for that?
wherever you start that ?
e.g. if you have a server selection gui
or /leave commands
or whatever
I don't, happens when they switch servers using /server or any GUI that might not even be from my plugin
does /server also call the PluginMessageEvent
uhh
Hmm, I mean PluginMessageEvent is proxyside
the only practical idea i could think of to make it "easier" is to save the data to redis everytime a change happens to the data
that would keep it up to date
but would also seem like a bit of waste
how to spam database 101
yes
all of that magic because you can't wait that extra tick
fucking hell uh
lynx
mhm ?
I mean yes and no, I would've tried doing it on login or anywhere else basically, but since the Join according to my timestamps in console is also called before the quit I'm heavily confused on what to really do
you are pretty familiar with the internals of craftbukkit arent you?
do you know a way how to access the palettedcontainer async?
on spigot ?
meh but thanks
Yea sorry I cannot help here
paper mangles around the paletted container a bit so eeh
don't think the code looks similar enough
how paper handles it and what we could try on spigot
iirc paper syncronizes the write access to the internal data ? Like synchronized
Where vanilla and spigot used to call a lock / error on double lock
so we have to take down spigot to do our stuff and then allow it to access it again
got it
yea, just have your plugin download paper 
I presume, you could hack your way into the lock ?
now that is geenious
btw @opal juniper the "accessing paletted from multiple threads" thing, is that on paper ?
can you elaborate on that a bit more
no lol, i didn’t realise that god was running spigot at that point
that’s what you get on spigot
Ah xD Yea I was looking through paper and was confused 😅
^^
i dev on paper so never encountered this issue lol
Well, let me open the forbidden texts, my spigot workspace
But yea, the ThreadingDetector is the lock used by the PalettedContainer to basically error on any access from multiple threads
instead you might be able to either completely yeet the lock or replace it with a waiting lock
with a bunch of reflection and a child class of the ThreadingDetector you write yourself
Could also just try to unlock forcefully
that sounds kinda aids
it will be
I mean, paper's synchronized will also just forces the thread that wants to write data to wait if the data is already locked
get to it god ^^^ :))
its your lib ¯_(ツ)_/¯
:))
I mean, in the end you can also just wait on the underlying lock
which might be better anyway
should have brought my school provided laptop away with me for the weekend
chrome book 
like, internally it just a Semaphore with a single unit of capacity
Tho
that won't work, minecraft would then error
🎉
i think getting rid of the lock is probably a bad idea, so yeah waiting is probs the only way
Yea, but waiting is kind of fucked too
think i finished it
you'd have to lock it manually again while you write off main thread
but if that shit is locked while minecraft wants to write, that shit will blow up again
but all of that isnt guaranteed to work, isnt it?
guys, i need a help in this logic
oh
you would want to not reveal neighbours if your field is already revealed
else your fields keep revealing each other
org.bson.codecs.configuration.CodecConfigurationException: Property 'x' in Vector, has differing data types: TypeData{type=Integer} and TypeData{type=Double}.
Please what i can do?
i will try again
Hi, has anyone here used Kyori? I can't find a solution for this...
example
String text = "&a&lExample text <gradient:#5e4fa2:#f79459>with gradient</gradient>" TextComponent serialized_message = LegacyComponentSerializer.legacyAmpersand().deserialize(text);
and send to player audience.sendMessage(serialized_message);
the problem is that it encodes the legacy text but doesn't send the gradient so I need to pass that to the MiniMessage.miniMessage()... but minimessage only accepts String as input.
How can I pass TextComponent (inherited from legacy) to MiniMessage (also encoding <> tags)?
Any recommendation?? Because i have been with this hsit more than 1h
Paper has specific support discord
Code ?
Yeah 1 sec
thank you!!!!!
👍
https://paste.md-5.net/coxevovazo.javaHere here you have
Please let me know if you understand what happening
Here is the exception:
org.bson.codecs.configuration.CodecConfigurationException: Property 'x' in Vector, has differing data types: TypeData{type=Integer} and TypeData{type=Double}.```
that is from bukkit?
That's also my question. If not please show us your class
hmm
Also wait i will see the location class
how are you reading the vector?
My Claim class, contains locations object references. So if i dont add Location to codec then i get an issue "that a codec for location is not found"
Let us see everywhere there is a variable 'x'
So once i add Location to codec i started to get tha exception
Maybe Location doesnt use bukkit Vector so that the issue
🤔
I ill check that now
Hey guys, is there a way to check if a block for example is able to drop xp or a mob? For example I would iterate through a list of entities or blocks and would be able to check if they would drop xp when I kill/break them?
I think you can use xp drop event
Location uses Bukkit Vector but it doesn;t store any Vector. The error is not from Location
unless you used a Vector in your TypeAdapter
?paste your type adapter for Location
mongo 😦
Yes
how is the class exactly called? Can't find it rn
I dont know if it exists i didnt find too
I've not used Mongo, but I do know for Gson to serialize Locations it requires a TypeAdapter
Yeah but im neither using Gson
Mongo uses Gson
But im using Mongo codec!!
org.bson.codecs.configuration.CodecConfigurationException: Property 'x' in Vector, has differing data types
BSON != GSON tho
ah I read wrong, sorry
Na dont worry
I just trying to discover what happens
Because i never using vector lmao
Claim contains references:
-> Location
-> Cuboid
Cuboid contains references:
-> Location (Corner 1)
-> Location (Corner 2)
So im really 🤡
I don't think it does..
?paste your two clases
Have you checked? Because im never using Vector on my pl
Claim contains references:
-> Location
-> Cuboid
Cuboid contains references:
-> Location (Corner 1)
-> Location (Corner 2)
Seams you can´t even have missing classes Inside that class you shall use #deserialize(). I think it have to do with the methods bukkit use to find #deserialize() method inside the class. #serialize() don´t have same issue.
Of some reason, don´t know if they add some ignore to that method so you don´t get java.lang.NoClassDefFoundError if you add classes some not exist in older minecraft versions in that method, because if you add other method in the class (you implement ConfigurationSerializable) you directly get java.lang.NoClassDefFoundError (don´t test if order of method matter).
Allright
Is this error when you make a query to Mongo?
Once it try to apply the codec to the driver
So anyone got an idea on that?
You'll need an expert with Mongo I guess
is your question how to check whether killing a mob or breaking a block would drop xp?
How do I set a player's sleep ticks so that the night doesn't skip??
org.bson.codecs.configuration.CodecConfigurationException: Property 'x' in Vector, has differing data types: TypeData{type=Integer} and TypeData{type=Double}.
at org.bson.codecs.pojo.ClassModelBuilder.validatePropertyModels(ClassModelBuilder.java:325) ~[Claims-1.0.jar:?]
at org.bson.codecs.pojo.ClassModelBuilder.build(ClassModelBuilder.java:294) ~[Claims-1.0.jar:?]
at org.bson.codecs.pojo.PojoCodecProvider.createClassModel(PojoCodecProvider.java:219) ~[Claims-1.0.jar:?]
at
org.bson.codecs.pojo.PojoCodecProvider.access$100(PojoCodecProvider.java:41) ~[Claims-1.0.jar:?]
at org.bson.codecs.pojo.PojoCodecProvider$Builder.build(PojoCodecProvider.java:119) ~[Claims-1.0.jar:?]
at dev.alex.net.manager.StorageManager.open(StorageManager.java:33) ~[Nasgar-Claims-1.0.jar:?]
at dev.alex.net.ClaimsPlugin.onEnable(Main.java:38) ~[Claims-1.0.jar:?]```
That the error Elgarl
If you save a vector, make sure to use doubles only. Done.
what is Main.java:38?
Transitively you do
StorageManager#open()
So what i can do?
is that all?
😂
yea that's the question
that can;t be the whole line
Smile im just keeping track of Location on my Claim class
So how i can solve it?
Show your code
like besides using entitydeathevent and bockbreak, some attribute to check. Like if material X or itemstack X would be able to drop xp
Which? StorageManager? Claim?
Every entity drops exp.
For blocks i think you would need to use nms.
I dont know of any property that is exposed by the spigot api.
Show Cuboid
Allright
but are u sure there is something with nms? otherwise I would need to make some static list where all of them are placed
Yes im sure this can be looked up in nms.
Why dont you use spigots BoundingBox?
Its for support reasons from 1.12x to lastest
Im just trying to understand why im getting that eception
which line is StorageManager.java:33
CodecProvider provider = PojoCodecProvider.builder().automatic(true).register(Vector.class, Location.class, Cuboid.class).build();
Ah PS: Location can not be serialized by the PojoCodec from MongoDB.
It contains a Reference<World> world which cant be serialized easily.
thats different to what you just pasted
I also try adding Vector to codec because i thought that was the caused
what is a bounding box?
Idk why it doesnt works like Mongoose :mad:
Is a class for working with cuboid areas and many things
so will block.getBoundingBox().getHeight() > 1 return true for something like a fence?
yes
i think so
alright
implement a simple codec for Location
didnt already do it? PS
Uhm any particular site for checking how this could be done / or could u tell me if you have any clue about it, which class this could be used on?
No you are trying to generate a pojo codec for Location. That wont work.
Ohh ok
So i need to implement a pojo for location
Allr
Already searching. I think i got something. One moment.
thank you
Simile do you have lot of experience with mongo?
Smile also what do you mean by a location codec?
This is really hard. The dropped experience is dependant on the ItemStack that is being used to break the Block.
You wont get any if you break the Block with silk touch for example.
yes
codecs are used for (de)serialization
Do you want to predict the experience of a Block or of a Material?
Like you did. But Location is not a pojo,
its possible to set the experience in the BlockBreakEvent, so in case other plugins are messing with exp for entities and blocks it would be hard to predict
For Location you need to implement
public class LocationCodec implements Codec<Location>
And register an instance of it.
Im this far:
But there is no easy way to get this unless you specify more information
@lost matrix For the blockfinder, do I instantiate a new HorseBlockFinder every time the horse moves?
Did you tried getting the NMS block ? In previous versions I know the existence of a getExpDrop
Oh as i thought
Nope. You constantly schedule N steps/tick until you either hit SUCCESS or FAILURE.
Afterwards you instantiate a new HorseBlockFinder.
But this finder should probably be inside a goal. If the Horse is already moving to a
source or doing something else then you dont need to tick the finder.
yeah its inside a goal
So on SUCCESS -> goal should change to moving. On FAILURE -> just instantiate a new BlockFinder.
alright
There are a lot of ways you can achieve this. Up to you.
oh ok yeah i get it now
Yes thats the nms block.
getExpDrop(BlockState iblockdata, ServerLevel worldserver, BlockPos blockposition, ItemStack itemstack)
And as stated: You would need to specify more infos to get the exp.
Oh my bad. nvm
Is there a big diff between Location#getX() and LocatioN#getBlockX()?
double and int
Oh ok
Something like this?
public class LocationPojo implements Codec<Location> {
@Override
public Location decode(BsonReader reader, DecoderContext decoder) {
return new Location(Bukkit.getWorld(reader.readString()), reader.readDouble(), reader.readDouble(), reader.readDouble(), Float.parseFloat(reader.readString()), Float.parseFloat(reader.readString()));
}
@Override
public void encode(BsonWriter writer, Location location, EncoderContext encoder) {
writer.writeString("world", location.getWorld().getName());
writer.writeDouble("x", location.getX());
writer.writeDouble("y", location.getY());
writer.writeDouble("z", location.getZ());
writer.writeDouble("yaw", location.getYaw());
writer.writeDouble("pitch", location.getPitch());
writer.flush();
}
@Override
public Class<Location> getEncoderClass() {
return Location.class;
}
}```
This is not a Pojo.
Pojo mean Plain old java object and refers to a very simple
class that only contains primitives and Strings.
What you just wrote is a Codec. So LocationCodec would be the right name.
Also: You need to start with beginObject and end with endObject.
Okay
how do you deconnect a variable form a file configuration.
public static List<List<Object>> oreList = new ArrayList<>();
oreList = FileHandeler.getFile().getObject("oreTypes", oreList.getClass());
the problem is when im editing oreList it also edits the file.
I didnt understand that
how do i use unicode characters?
?paste
@Override
public void encode(BsonWriter writer, Location value, EncoderContext encoderContext) {
writer.writeStartDocument();
// Your stuff
writer.writeEndDocument();
}
The rest looks fine
Hi, little question, there is my code ```@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
String nickname;
if (cmd.getName().equalsIgnoreCase("name")){
changeName(p, args);
nickname = p.getDisplayName();
if (dataConfig.contains("player." + p.getUniqueId().toString() + ".nickname")){
nickname = dataConfig.getString("players." + p.getUniqueId().toString() + ".nickname");
}
dataConfig.set("player." + p.getUniqueId().toString() + ".nickname", nickname);
saveConfig();
return true;
}
return false;
}``` this code drop an error : ```org.bukkit.command.CommandException: Unhandled exception executing command 'name' in plugin Valdara vBETA``` anyone had an idea ?
send the full errorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Allright, thanks would cause problems writing pitch to double and them parsing it, readin it as string?
This is a TypeAdapter (same thing) for Json https://paste.md-5.net/solocojewo.java
We have already been through this. You need to use getList() instead of getObject()
.
?paste
tried it but still doesnt deconnect
You can usually just throw the actual unicode char in two 'Æ'
Neither beginObject() nor beginDocument()
Hi, I'm sorry to disturb for something who look stupid for me but I wanted to know how I can make my plugin available for version who go to 1.8 to 1.19
make 2 chars?
what that mean
line 13, 51 and 59, 72
Your yml is absolutely fked. You should never end up with a List<Object> where each element is of a different type. Thats horrible.
In my case that methods doesnt exists
I dont know why
😡
shty mongo
whatever is appropriate for Bson
No understand
No i mean that you can literally just fill in the unicode char: '♥' '🔥' '👑'
BsonWriter has a begin from what I can see https://www.programcreek.com/java-api-examples/?api=org.bson.BsonDocumentWriter
?
it just converts to unicode3
Hmn
No lmao
its a bit difficult to do that for me but its still a problem with having the value linked either way
lol, no clue then. I've not used Bson nor Mongo
Smile BsonWriter doesnt contains that methods
Im using mongo 3.12.5
Sth mongo
Lmao i stay with javascript mongoose. That yes it amazing
No time lost mapping shit java things
If you want the dirty, hacky way: Just shallow copy your stuff into a new List.
public List<List<Object>> copyOf(List<List<Object>> original) {
List<List<Object>> cloned = new ArrayList<>();
for(List<Object> subList : original) {
List<Object> clonedSubList = new ArrayList<>(subList);
cloned.add(clonedSubList);
}
return cloned;
}
But that is literally so fking unclean its not even funny.
im new to java so its good for the begining
Why are not using the correct generic for the list?
His list contains not only one type. Its a bunch of different garbage.
I feel like a 2D-array would be better there but idk the context
Oh that why exists, ConfigurationSerializable
Ive seen the config. Its something else...
20 long = ?
On taskTimer
1 second...probably, depending on server performance
Where can I install the 1.8 R2 craftbukkit?
lol
you don;t you use Spigot
?bt
ain’t no way
I have already built the spigot 1.8.8 do you want it?
I do not
1.8 to finally die out
wrong person dude
How do I add an enchantment on an item higher than the normal limit
equipment.addEnchantment(Enchantment.DURABILITY, 100);
for example
set the flag that ignores the limit to true
thx
does anyone know how to apply another mobs AI to a mob
e.g. a zombie to a regular villager
Sorry wasn't there for some time. I want to basically just check if the block can drop xp, for example it would be enough to say like: stone doesn't drop xp, a coal ore instead could drop xp
Just write a set of materials and throw those in:
alright so make an own list which would need to be updated manually correct?
For what reason do you want to know if a block can drop exp?
I need all these blocks in a list. So question is if I need to create a static one or if I can generate it through spigot-api / nms just so it's dynamic and not based on a fixed version
Why a list?
how do I check if the plugin folder exists?
I ask because depending on what you are doing you may not need a List at all
I have custom amounts of xp for some blocks. To make the check simple I want to check if block X drops xp, if yes I will get the value just from a map where the custom xp for the block would be stored in
just get the Block there, see if it's in your list, if it is, get the value and set it
but there is nothing overall right? cause I maybe want to check for stuff like breeding xp as well
No
I made a reload command for the config file and i ckeck if the config.yml exists, if not it creates one but if the entire folder is deleted i get an error so i need a way to check if the folder the plugin is in exists and if not again create one.
File#exists()
I know how to check for the config file
i need to check for the folder thhe config.yml is stored in
Use the same method. A file can also be a directory. You can use the additional File#isDirectory() method to check that.
something like this?
File pluginFolder = new File(main.getDataFolder());
Yep. Then you just check if it exists.
okay
How do I apply a mob's AI to another mob
e.g. a zombie to a giant
as I already said, just getDataFolder().mkdirs(); will guarantee the folder exists. If they do it does nothing
Hey please give menu libraries name please
Giant does not have any AI by default
I need to find a library that fit me
how do I create a folder named Test in the plugins folder?
create custom entity with nms and change it around
how tho
I knew NMS was involved
but cant find any documentation
hmm
its either outdated or not relevant
File = new File(JavaPlugin#getDataFolder(), "folder-name");
file.mkdir();
okay, thx
guys im using so much statics, sets, lists and im getting confused for seeing so much sets and lists so it is being complicated how can i pass this?
I dont understand what exactly youre asking
I get this now...
[21:33:42 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'dw' in plugin DeluxeWelcomer v1.0.1
Caused by: java.lang.IllegalArgumentException: Cannot translate null text
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[commons-lang-2.6.jar:2.6]
at org.bukkit.ChatColor.translateAlternateColorCodes(ChatColor.java:354) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?] at me.krzheski.deluxewelcomer.Commands.dw.onCommand(dw.java:90) ~[DeluxeWelcomer.jar:?]
File pluginFolder = new File(main.getDataFolder(), "DeluxeWelcomer");
if (pluginFolder.exists()) {
// do stuff
}
else{
pluginFolder.mkdir();
}
hmm
could you show the full log pls
can you show us the full command implementation?
show this line
youre trying to get a color for a message from an empty string I believe
i forgot to set a permission message in the config
does java have something similar to canvas js?
You mean for swing components or for web frontends?
Dont use statics at all. Statics should contain constants or singletons. Nothing else. Having public mutable statics like normal maps, set and lists is
a very bad coding style and will lead to fragile code.
i just want to manipulate images
create canvas, set some background, some text all thru code
wdym by constants and singletons?
You can do all of this through awt.
String imagePath = "path/to/your/image.jpg";
BufferedImage myPicture = ImageIO.read(new File(imagePath));
Graphics2D graphics2D = myPicture.createGraphics();
and so on
Constants as in a "public static final NamespacedKey CUSTOM_ITEM" kinda thingy
Classes of which only one instance is ever created are called singletons.
All you manager classes should be singletons.
or private static final
This is a constant, not a singleton.
they did also ask about constants
Ah didnt read
can i force disable player gamma?
no
and with resource pack?
No
Also no
ok thanks
its not a cheat
yes but i want to disable
can't be done
purely client side
This statement is false
max*
Just reduce the damage they get in the EntityDamageEvent ;)
@lost matrix just wanted to say the blockfinder works flawlessly, thanks so much man
Oh really? Thats nice to hear. Didnt really test it...
Keep me updated on your progress.
alright
The max possible health on default is 2048
You can increase this in the spigot.yml
Health must be between 0 and 100.0, but was 150.0. (attribute base value: 100.0)
What version are you on?
Well... too bad i guess.
Did they already have attributes back then? I thought you would have to use nms for that.
no
they didnt
at least i think so
how do I set health in NMS
why do you do this to yourself
EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle()
Then see what methods you got there.
thanks mate
you need NMS to set the health in 1.8.8?
btw, weird thing with this is that it created the folder in the plugins folder but it also creates a folder with the same name in that folder it creates
anyone know why?
arent plugin folders auto generated once theres some config file?
they are
read this ^^
well you did call the file "DeluxeWelcomer"
and?
is that the name of your plugin?
it is
you are creating a folder inside your datafolder, which is named like your plugin
welp
the datafolder is not the plugins folder
its the plugins/YourPlugin
at least the plugin you are calling getDataFolder from
first is the folder the file is in, then is the file name in the File constructor
yes but i need to create that folder if it doesnt exist
File pluginFolder = plugin.getDataFolder();
File subFolder = new File(pluginFolder + File.separator + "subFolder");
if(!subFolder.exists()) {
subFolder.mkdirs();
}
File file = new File(subFolder, "data.yml");
// save to file here
mkdirs() creates all folders needed for the requested path
ok but this will create a folder inside plugins/MyPlugin/NewFolder, right?
Yes
I dont want it to do that though
then tell us what exactly you want to do please, I am also confused
i need to create the folder for the plugin where the plugin config is
in the plugin folder?
new File(getDataFolder(), "subFolder")
that should be where the config is
that gets auto created when making a config afaik
yes, in the plugins folder
yes but OMFG
now im confused and i just want help with my question 😵
read this
i feel like maybe learn a little more about java file stuff idk
ur not helping
¯_(ツ)_/¯
the getDataFolder() is the folder youre looking for. thats where the config file will be. I think youve been trying to go one level too deep
^
Do you want
/plugins
/YourPlugin
config.yml
somedata.yml
Or do you want
/plugins
/YourPlugin
config.yml
/CustomData
somedata.yml
your config should be made there
If your config gets deleted just call saveDefaultConfig() It will create teh folder if its missing and save your default config from the jar
this
first one
then your question was already answered
the default folder that gets created with your plugin that contains the config files
with this
File pluginFolder = plugin.getDataFolder();
if(!pluginFolder.exists()) {
pluginFolder.mkdir();
}
File file = new File(pluginFolder, "data.yml");
// save to file here
^
^
Unless you have a default config.yml because then you can just call saveDefaultConfig() and it will create the plugin folder.
^
anticheat question w/ speed check
how should i use Material#getSlipperiness() so i dont have to cancel the check entirely if the player is on ice, or a block that messes with the default friction?
finaly, tysm
Does your anti cheat have a heuristic, statistical or reinforcement learned approach?
it checks if they haven't done stuff that would make their movements normal and then flags them
so if they haven¨t jumped recently, or glided, etc. nto inside vehicle but they are in the air and their Y isn't going down
then fly (theres more than that, i simplified that a lot)
So statistical. This just means you need to find out how much faster they are on slippery surfaces and increase the threshold accordingly.
thank u btw bc i didnt actually inderstand what u meant lol
in that case, should i determine threshold on event
or get a threshold from sprinting, and adjust accordingly if they have a speed potion, etc.
Wait... you are writing an anti cheat on event level?
no it has handle()
handle(PlayerMoveEvent e)
if(booleans){ return; }
player.flag(check)
it seems to work?
im willing to improve it beyond 1000% if anyone has better ideas than just a handle() method
You wont come far with this approach...
A good anti cheat needs a very deep understanding of the protocol it is currently on and handle
the packet transactions between server and client. Relying on events wont cut it for many many checks.
yeaah, i'm adding packets for some checks that rely on them (blink, some exploits, teleport) but for now, Fly seems to flag awesomely and same with my current Speed check.. it's also for 1.19 and im not sure why but packets seem to have gotten vague after 1.13
should ibother making an anticheat for 1.19 or will Microsoft block hacked clients too because they want control? 🤣
No they wont. They really couldnt care less. They rather impose vaguely defined speech constraints.
😭
I got too much with anticheat... I prefer way more to rely on the other players to detect someone cheating and having mods
(while your server is < 150 players it's ok)
But I had really good time making anticheats back in 1.8
Every server with a half decent anti cheat i worked with had a dedicated team of at least 2 devs that did nothing else but
perfect their anti cheat. Its quite the task and you need a ton of knowledge beyond minecraft/spigot as well.
well thanks for the wisdom and advice because it does mean a lot and it helps, i think i'll try out some values while sprinting with various effects to see if i can make up some thresholds and mess around with .getSlipperiness()
lmfao
HI
I having Intellij isues
I doesnt show all the modules on the project
😡
The module exists, but isnt displayed on intellij
Did you import a project!
As you can see it doesnt detect the project Test
I have invalidated cache, reload all from disk
Everything
Neither re importing nor creating a new project
I just opened as usual
Is the test module added to your main project pom?
yes
I can compile it
All is perfect but is not display on the visual structure
Taken from parent pom
no clue if its a valid module with its own pom
Also i can add module Test as dependency and compile the project
turn around 3 times and turn your PC off and on again
Idk what shit happened
This is the most craziest thing
Maybe caused of git plugin?
🤔
Lmao its so crazy this
Is there a way to copy the config and save it in a different file path ?
For example:
File file = new File("path goes here");
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);```
If you mean copy you can get the parent file
Correct, copy the content inside of it.
Inside of the resources/config.yml
Path sourceDirectory = Paths.get(config location);
Path targetDirectory = Paths.get(whereto location);
Files.copy(sourceDirectory, targetDirectory);
got that from a quick google search
btw
that will not work
Files.copy does not copy directories
You need to walk the tree for that
what are you on about
Now that I think about it it could also have been an issue with Files#move that I had in mind
yeahhhhhh idk what ur on about man
Throws:
[...]
DirectoryNotEmptyException - the REPLACE_EXISTING option is specified but the file cannot be replaced because it is a non-empty directory (optional specific exception)
Got a little bit confused with the REPLACE_EXISTING option
ah alright
Though I believe it throws a similar exception if you try to move a directory into something that does not yet exist or something
But whatever
could just check if the file exists in the target directory, if it not then create. to counter that but sure.
- it doesn't throw the exception if the file doesn't exist, it just simply "copies".
although I am exception handling, so you are partly correct
public static void copyFile(String from, String to) throws IOException{ Path src = Paths.get(from); Path dest = Paths.get(to); Files.copy(src, dest); }
Ah I now get why you were confused
I thought you copied entire folders, but apparently you just copied a file-file
How could I use something similar to if (target.getAllowFlight()) { but using the Invulnerable method? Player#setInvulnerable()
Player#isInvulnerable()
Oh, thank you!
how hard is this to implement:
the horse can't seem to figure out how through the opening in the wall
instead it just stares at the wall indefinitely
it's trying to reach the feeder (brewing stand) on the right
Does the BlockFinder find the block?
yes, if i cover up the hole in the wall the horse actually walks away freely
So its a problem with the vanilla pathfinder you are using?
the thing is while the blockfinder can successfully detect whether a target is reachable, it doesn't really help the horse find its way
yes i'd assume so
Another thing, how would I set the durability of an item?
I see setDurability is deprecated
You cast the ItemMeta to Damageable (be careful because there are two different ones)
and set the damage.
Make sure to set the ItemMeta back on the ItemStack afterwards.
i've noticed that the vanilla pathfinding to entities is actually a lot smarter compared to blocks
I have a pathfinder goal which makes horses attack other horses, which uses the vanilla pathfinder
and it knows how to walk around walls and everything to reach the target
do you think it might be a good idea to spawn a marker entity on the target block?
man its been almost 3 days but I still cant believe technoblade is gone
its not as if I was a fan of him or something
its just that deadly feeling that such a disease can end person's life so quickly
i never really watched him either but i had mad respect for him
ok I've noticed the blockfinder actually returns a success here
but I figured out why
if I make the wall 1 block higher, it returns failure
I'm getting a NoSuchMethodError when using Advancement#getDisplay() - anybody know why??
the finder searches the block thats above, which passes all the checks in the filter
wrong channel
Same here. I didnt really watch his videos. Only occasionally. Its a bit weird...
agree with you
Anybody know before my question gets buried under talks about our mortality ??
well maybe you're using wrong api version
inside gradle or maven
or you're running older version of minecraft server
It compiles fine, and I'm using the latest version of paper
can you post the whole stack trace via ?paste ?
Yeah one minute
I wanted to copy it from the Resources file inside the plugin
i can’t imagine it being that useful 
well keyword NoSuchMethodException without any details is also not that helpful
just ctrl v
Hello, I have this code for a wild command: https://paste.pythondiscord.com/ukiyasiviw
I'm trying to make the Y value be 1 than the safe location and also have the X and Z value be 0.5 more as I spawn inside the ground in the center of 4 blocks right now.
can you show your code snippet
CommunityEventManager line 93
@EventHandler
public void onAdvancement(PlayerAdvancementDoneEvent e) {
for(Entity loopPlayer : e.getPlayer().getWorld().getPlayers()) {
if(e.getAdvancement().getDisplay().getType() == AdvancementDisplayType.TASK || e.getAdvancement().getDisplay().getType() == AdvancementDisplayType.GOAL) {
loopPlayer.sendMessage(ChatColor.of("#ffad1f") + "- " + ChatColor.of("#ffec42") + e.getPlayer() + " has completed " + ChatColor.of("#ffad1f") + e.getAdvancement().getDisplay().getTitle());
} else if(e.getAdvancement().getDisplay().getType() == AdvancementDisplayType.CHALLENGE) { // line 93
loopPlayer.sendMessage(ChatColor.of("#b22deb") + "- " + ChatColor.of("#ff88ff") + e.getPlayer() + " has completed " + ChatColor.of("#b22deb") + e.getAdvancement().getDisplay().getTitle());
}
}
}
I recommend going to the Paper discord or trying with Spigot
RankLoader.config.save("" + GioxRanks.getPlugin().getResource("asdf"));```
Would this save the asdf.yml copied from the resources/?
🤔 i see nothing wrong here
yeah i guess it could probs be a paper bug??
I know right
it seems like a linking issue
Wdym a linking issue
from paper's side
Owh
Your plugin tries to access method which does not exist at runtime
but it should
since its paper bukkit api method
Its possible to check a boolean condtion uisng Optional but when the result is true run something, if false run another thing
Maybe Predicate functional interface?
i have a question on how to implement the logic of something
Predicate<String> predicate = (string) -> {
return string.equalsIgnoreCase("yes") ? true : false;
};
boolean test = predicate.test("yes");
boolean testFalse = predicate.test("noooo");
im not sure if syntax is correct but that's how predicates work
they're mini blocks of code which can be dynamically allocated to test some condition
Dovidas i need the thing for my menu api, so if the handler contains the player -> open the menu if not stop execution
I'm trying to make a function to see whether a block is able to be stood on given only the Block object of the target (in this case, the diamond block)
on the right, it is possible to stand on top of the diamond block. So the function should return true
on the left, it is not possible to stand on top of the diamong block, so the function should return false
How would I go about doing this? I thought it was simple at first but its actually a lot hard than anticipated
What the heck are you building?
Looks like you are coding custom things
what do you have so far
its just a testing platform
Not much
I just want to optimize it a bit more
is it just me or is there no point to this ternary
there's no point
you can even remove code block braces and return in this case
:)
So its possible to do that code better?
except for the namings, what do you imagine?
what about (abs(block's y position) - abs(player's y position)) <= 1 block
Something more profesional
" given only the Block object"
and with that, what is "professional" for you?
Doesn't the Block object have a #getLocation() method?
in my opinion without knowing player's coords you cant know if you can stand on it
unless you're comparing blocks
I beg to differ. You could figure it out, it just depends on your criteria.
Using Optional, Predicate
well, "can stand on it" - do you want to know if there is any block in the way on the top or if the block is just a regular one you can stand on?
that doesn't make it professional. you just want to have something cool-looking. overengineering. you dont need those in this context
i would just create method which compares that block location to the anchor location you specify in the method args
Allright
so its not neccesary as you said
So its just me that want something well look
yes
Thanks
yeah but getting that other location will be difficult
Would it though? You can get the world object from the block and use that to get other locations.
its this pathfinding thing im working on
then just store block locations
it'll just make it a pain
if you're doing pathfinding you will still have second location which defines current pathfind location
its just the way its set up right now makes it difficult
go architectural refactoring go
if (isDouble(args[1])) {
}
How do I check if args1 is an integer?
Integer.valueof()? or Integer.parseInt() ?
i might be wrong
its out of my memory
if Integer.valueof?
Integer.parseInt(args[1])
If the string does not contain a valid integer then it will throw a NumberFormatException.
Integer.parseInt()
try {
Integer.parseInt(args[1]);
} catch (NumberFormatException exception) {
// If this code block executes, then its not an integer.
// Handle the error by either printing the stacktrace or sending back the message
}
ok
I have this code: https://paste.pythondiscord.com/ukiyasiviw
How could I make the findSafeLocation be Y+1 and X/Z +0.5
pythondiscord lol
SpigotMC => Its discord dedicated for minecraft
xd
'tis not python
I have a question
Why do you use static methods?
When its recommend to use DI (Dependency Injection)
I don't really have a good explanation besides for the friend I'm working on this plugin with started that :P
is factory class constructing concrete builders a good idea?
Before start programming on a language you should learn the basics of the language. If not its really diff programming
lets say i have a builder implementation that is dependant on the implementation classes i dont want for the client to construct them since it belongs to implementation package
i am decoupling interfaces and implementation as far as I can here
dovidas
?
They still can do it via Reflection
Well, what's the benefit of using DI?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
It lets you run tests of your code way much easier
since you dont have any static getters inside your class
Ah, okay, I use that for literally all of my commands lol
also it allows for the client to extend that particular class you're using
I'll alter my code to make it work with DI then
Also statics methods are heavy to proccess rather than DI
I call it plug and play 😄 since it does the same, you plug it, what you're plugging into class, you class will gonna use in runtime
Ahh, I see
(Confirm dovidas, maybe im wrong)
and by using static getter you're hardcoding that functionality
Is it quite easy to alter it to be DI or would I need to change a lot?
its annoying to deal with DI tho
you need to add the objects you're using inside constructor
and add fields for them to store inside the class
Do you know menu apis paginated?¡
Im needing diff menus apis that allow pagination for testing pupouses
Strategy design pattern is very great example of DI (kinda)
SpiGUI iirc
Allright i wil ltake a look
I have seen many menus apis but they are shity for me
Its like i dont like how they are coded
inventoryframework
This type of things should be banned from spigot
works great
oh thanks people
(bungeecord) how do i get a file in the \resources folder and add it to the plugin's dataFolder
getResourceAsStream()
You can use it on main plugin class
how would i create a duplicate file
Hi I think Packet UseItem can be spoofed. How check it?
How to validate this packet?
and is it possible that a player playing without any modifications without external factors will spoofed this packet?
he cant spoof packets if he didnt have any mods on
Vanilla minecraft client doesnt provide you a way to manipulate packets
I know xD
however, can ping cause something to break
No matter the ping, vanilla client sends packets correctly
even if gets delayed for the server
the worst case scenario would be that the server handled those packets incorrectly
and desync issues would occur
but that's very rare, unless you use some kind of plugins which manipulate packet handling incorrectly
protocollib (with its dependant plugins), viaversion, protocolsupport etc.
Oke but maybe do you know how validate this packet?
NMS ServerGamePacketListener class validates those packets
for modified versions of minecraft
do you want to modify protocol of minecraft by supporting mods or what?
I have problem with spoofed packet from modified Minecraft version
my server doesn't check them and it causes undesirable results
@mortal hare could say I'd like to do a little anti-cheat
Well you have to describe the issue and exactly what you think is being done.
how do I download the spigot-api jar and input it to jdgui
why do u need it in jdgui @ornate patio
trying to decompile and search for keywords in the entire jar
for reverse engineering nms
then ur not gonna get far with spigot-api i reckon
use buildtools and sift through the decompiled output
?bt
look in the work folder
its almost as if i predicted this would happen 😅
so how do i look through entire nms code then?
i do have a built in decompiler in vscode but I can only control-click on existing classes
i wanna search for a specific keyword in the entire project
iirc, run BuildTools with the --remapped argument, and then check ~/.m2/org/spigot/spigot/
pretty sure the jar i used is remapped
whats the full command again?
java -jar BuildTools.jar --rev <version> --remapped
the jar youre looking for will be in ur maven local repository
where is that
somewhere around this directory
'~' denoting your user home directory
like C:\Users\Username\
or /home/username/
not sure and not on pc to test
is it spigot-api-1.18.1-R0.1-20220228.150432-81-shaded.jar?
no
spigot-1.18.1.jar?
ahem
oh
uh
wait that wasn't supposed to happen
there is supposed to be a lot more there
yeah
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
oh it IS spigot-api shaded?
There is no uber jar