#help-development
1 messages ยท Page 1944 of 1
Nothing changed there for quite some time now
.world isn't going to work
It worked in 1.15.2
1.18 is either unmapped or using Mojmaps
Neither have the .world
Mojmaps should be calling it level
Why Bukkit have only 4 branches? https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse
why not
why need more?
Do you guys know why is that? ```
C:\Users\Paweล\IdeaProjects\Pinecraft-Core\src\main\java\me\plytki\core\api\APICommand.java:13:18
java: cannot access org.bukkit.Bukkit
bad class file: /C:/Users/Paweล/.m2/repository/io/papermc/paper/paper-api/1.18.1-R0.1-SNAPSHOT/paper-api-1.18.1-R0.1-20220205.195405-118.jar!/org/bukkit/Bukkit.class
class file has wrong version 61.0, should be 55.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
wrong java ver
You should also be asking Paper
Stupid question but is there any plugins using MiniMessage so I can get an idea how to get going? ๐
There is a pretty detailed wiki
I must just be stupid then? I'm finding it a bit complex
Is there anything specific that you don't understand?
I just can't understand how to create a new string what I can send to a player
I can send u a snippet
I mean, the most basic one is just ```java
final Component parsed = MiniMessage.get().parse("<red>A red piece of text");
I'm someone who likes to see how things are done at first
tho afaik the wiki is outdated af
adventure docs are horrible lmao
They are just outdated ye
So I'm not just dumb?
Well the docs are not optimal but the concept of mini message and the java interface is pretty straight forward
Exactly what Lynx said
I was worried that it was just me being dumb finding this confusing
no, adventure is just confusing on the first go around
Took me a few days to figure it out lol
thanks for making me feel better by confirming it's not just me
Let me know if you need any other examples, I dont have many but anything can help lol
this sort of code doesn't seen to work for me ๐ค
What version of mini message are you using
it went through a bit of changes here and there
Or what ver of Paper
I think i got it
Assuming you are using Paper, otherwise it might be a nightmare lol
e.g. MIniMessage.get was replaced with MiniMessage.miniMessage()
String test = "hi";
Component component = MiniMessage.get().parse(test);
?
Yes
Should work ye
when did this happen? Im running the latest paper api and still use the old one
Nope, not in my pom
no, paper also does not use mini message as an impl detail
If not I got no idea lol
something is pulling it in and it definitely isn't paper-api ๐ ยฏ_(ใ)_/ยฏ
Sorry, but how do I send this message to the player? ๐
I got a component and I don't know how to use it
With Paper you should just be able to pass it through Player#sendMessage
Spigot would be not so much fun lol
is it better to import paper over spigot or?
Well thing is you cannot publish a plugin that only works on paper to spigot
Will it mess up any of my other code?
no
Ah..
Is this a public or private plugin?
paper does not break spigot plugin compat
Public ๐ฌ
lmao thanks
you basically need to also include the bukkit adventure platform
which basically links bukkit servers to adventure (e.g. allows you to send messages etc)
please excuse me when I go scream. ๐
lmao
understandable xD
"this'll be a easy 5 minute thing to add hex colors" *TAKES 20 COMMITS TO SET IT UP"
Is it obvious i'm going crazy yet?
Technically legacy format does support rgb colours :>
So if I add this adventure will the plugin still be useable on spigot servers or just paper?
You will have to shade (or use the library loader) both adventure and the bukkit platform
but yes
so i can just shade it?
yes
I wanna curse my life away
how I can set branch on Bukkit for other version then 1.12.2 and the latest version? https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse
BuildTools.jar --rev <version> will check out the appropriate commit
and then I should copy created directory? Bukkit
just use the directory
you can also check the commit hashes eg https://hub.spigotmc.org/versions/1.8.8.json
is the first or the last commit for 1.8.8?
oh good thanks
yea but this is longer ๐
World myWorld = Bukkit.getWorld("world");
Location spawnLocation = new Location(myWorld, 0, 10, 0);
Entity spawnedPig = myWorld.spawnEntity(spawnLocation, EntityType.PIG);
i know how to spawwn an entity, like above
but how do i add no ai to them? Thanks โค๏ธ
spawnedPig.setAi
ty
please next time to source use this ๐
hm it sets unresolved reference
World myWorld = Bukkit.getWorld("world");
Location spawnLocation = new Location(myWorld, 0, 10, 0);
Entity spawnedPig = myWorld.spawnEntity(spawnLocation, EntityType.PIG);```
thanks
1.8?
yeh
how would I get a creature spawner's default properties? say I'm changing a spawner's properties like the timer and max spawn count, how would I get the default values back?
Iโd just hardcode them somewhere
that's what I was thinking and was wondering if there's a better way but I'll go along with that, thank you
No idea what that is
I mean you could make a new spawner and get the values from that
install this as a dependency https://www.spigotmc.org/resources/nbt-api.7939/
at that point i might as well use summon command as console onEnable
then new NBTEntity(yourentity).setBoolean("NoAI", true);
nah
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/LivingEntity.html#setAI(boolean) is just not cool enough ๐ญ
declaration: package: org.bukkit.entity, interface: LivingEntity
Is it possible to get the exact coordinates where an arrow hits a player?
I opened a server, but when I use spigot, useful mobs spawn, but creatures do not spawn, how can I solve the problem?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityDamageByEntityEvent.html check the damage cause if its of projectile, then check that the entity being damaged is a player if so get the cords of the player
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
if you meant like the arrows cords
I assume you could get the Arrow entity involved and get its coords and just use some math with player information like we know how tall players are
so use the player coords, along with their height, then you can measure where it hit the player
So I suppose the answer to your question is, yes you can
How would I test if a tripwire is disarmed?
declaration: package: org.bukkit.block.data.type, interface: Tripwire
thanks
how do I get the location of a nether portal that the player made?
As in when they made it? Or some arbitrary amount of time after they've made it?
Because the latter is not possible
But you can always listen to a PortalCreateEvent
like the actual location of where the portal is
Yeah if you want to get the blocks when they've made the portal, PCE is your friend
but can I find the location of the portal that is built?
some arbitrary amount of time after they've made it?
Because the latter is not possible
oof
Unless you keep track of that yourself
PCE, save the location in memory and in a file or something, load up on start
how would I do that?
Well, you can getBlocks() in the PCE. That gets you all the blocks that belong to the portal. (You can just select one if you want, I don't know what location you want, exactly. Calculate the center, whatever). Then just add that location to a Multimap<UUID, Location> or something that you can refer to later
(multimap because they might create more than one portal. If you only care about the most recent, you can just use a regular hash map)
ok because I was trying to make a type of manhunt plugin so yea that helps a lot thx u :)
Oh then yeah, if it's temporary, a simple Map will do then
If you need it across restarts as well, you have to write that Map to a file as well. Keep that in mind
If needed, Google has a bunch of resources on how to read/write from files. Standard Java for that
does #setVelocity work on 1.18.1 for armorstands, I've already tried updating it per tick but the armor stand is not moving. #setGravity is set to true
will it work to cancel a bukkitrunnable then start it up again later?
no
Just add a boolean in the runnable.
Or make the state of the runnable serializable.
so youre able to cancel the tripwire from being being activated while you step on it, but that would create a large loop of it being activated from you stepping on it, then it being deactivated through the blockphysics event over and over, is there a way to prevent this?
The serializable interface just lets you serialize the class
I'm trying to serealize this class
private static ArrayList<Report> _allReports = new ArrayList<>();
private int _questionsIndex=0;
private UUID _creatorUUID;
private String _creatorUsername;
private ReportType _reportType = null;
private List<String> _answers;
private String _creationDateToString = "Non-specified";
private int _reportId = -1;```
ok but how do i use it
All u gotta do is then pass it as an object when writing it to a file
https://www.spigotmc.org/wiki/introduction-to-serialization-section-2/
Did you read this?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i used this
file.getConfig().set(data.getPlayer().getUniqueId() + ".PlayerData.ActiveReports", data.getActiveReports());
this should be correct
but the fetching from config part is what i'm stuck at
Oh youโre trying to serialize in yml format. Nvm
i'm making a really simple discord-minecraft link using jda, but whenever i call Bukkit.broadcastMessage() with color codes in the string, it sends strange characters like "ร". here's my code: Bukkit.broadcastMessage("ยง9Discord > ยงe" + event.getGuild().getMember(event.getAuthor()).getNickname() + ": ยงf" + event.getMessage().getContentDisplay());. it's not a jda issue because when i remove the color codes everything actually works
Use #getConfig#get(String path)
So if ur getting by UUID pass the UUID as a string into the path
So I have to make the serialize method
that @Override the one from ConfigurationSerializable?
That depends if you want it to be readable or not
You could probably serialize the object into a byte array then store it into the UUID index. OR create a method to serialize all the primitive values into a string.
because ur using Lists and ArrayLists you should probably just serialize the byte array of the class then save it into the UUID index
It might, im not sure how they handle those kind of arrays
if it does then you'd serialize those two object however ConfigurationSerializable does
just make sure ur serialize method is consistent with ur deserialize method
like the order and placement of each data value
use ChatColor#translateAlternativeColorCodes() and use &
May I ask what is the reason why entities cause a lot of lag?
Like, bounding boxes, behaviors, etc?
or something else?
Probably cause entities have dynamic states
they can move and stuff while most blocks for example are pretty static
They dont. Its all a matter of quantity.
If it was just a matter of quantity only memory would be affected, wouldn't it?
๐
No?
The CPU has 50ms to process a tick
if it has to tick 20 entities vs 500 that is a difference
unless it's iterating them what would make a difference
it is tho ?
may I do something for they not to tick?
I don't need them to tick
Every tick the server iterates over every single entity and calls its tick method.
Over every ITickable even.
don't think spigot has a way for you to stop stop ticking completely for certain entities
You could just disable their AI.
Disabling the whole tick would mean that they are just displayed statically hanging around.
yes I don't mind that
Just as a heads up, disabling AI will not reduce the tick to just a method call
the server will still do stuff and throwing a crap load of entities onto it might still have a noticeable impact
What are you trying to do?
Because this sounds like you dont need entities at all. Just packets that tell the player that an entities is at a certain position.
can I load a structure without it updating the blockstates once loaded
I cannot tell too much, but I need entities just to exist, they don't need to do too much because I will be handling their behavior/movement internally.
And yes, I thought about that, but I think It will add an extra layer of complexity when I need to move the entities
This will require custom NMS implementations
sounds like redoing citizens for fun
haha no and no. I have other plans in mind ;p
I mean yeah, but that still leaves me with the question of how well it will perform
while ticking I mean
pretty much a tryitandsee
How many entities do you plan on adding?
Im looking for skripters
that are good
like at least a 6 month experiance?
this is not the place for service requests
Im new so idk anything
your clients will have fun
also @prisma salmon https://www.spigotmc.org/forums/services-recruitment-v2.54/
This will lag the clients way before the server notices it when NoAI is enbabled.
haha, now you know why I'm asking
I mean, there is nothing for you to do on the client side of things
they will be not all together in a single point
But all potentially loaded at the same time ?
yes
Well, with those numbers
I still love that video :p
Are you planning on having hordes of mobs?
Because ive done this and this is best approached with a hive AI which can get quite complicated.
No, but that sounds very cool
parallelization is key there ๐
If you are only planning on doing armorstands for example, paper would have API for that
but beyond that, NoAI it is
are ArmorStands laggy at all?
Yes
Well they still tick around
They still collide and are interactable
๐ collisions
MrTommy
yes?
create an account
and then you click the
what does this error mean ? @w@
09.02 21:38:25 [Server] INFO org.yaml.snakeyaml.constructor.ConstructorException: could not determine a constructor for the tag tag:yaml.org,2002:java.util.UUID```
there is @w@
Are you serializing something?
I have this --> please note that in order to be able to post new threads in this section you must have an account with at least 20 posts and at least 1 week of age. Upon reaching these amounts you will automatically be promoted within a few hours.
I think you forgot to put the entire stacktrace
Just need help
there is a discord for skript
dm me it then
What i dont understand is why someone would bother learning skript?
You have a way more powerful tool when just learning java. And its a
also a great skill outside of Spigot.
it is right there
E X A C T L Y
does java work on a mc server??
does it tho

@eternal night Just dm me the dc server
The entire Spigot Server is Written in Java
and so are Spigot Plugins
Jesus
I DID
this is why children should not have internet access
Lmao yeah
Im 13 idiot
case in point
I still think is a good way for kids to customize a server with their friends tho
That makes you a child by technicality.
13 year old can't read these days ?
How?
You're a minor.
does configurationserializable not work with UUID??
basically an infant
does it not allow to store it
Like just because you're an adolescent doesn't mean you're not a child.
uuid does not implement configuration serializable
(Even then, 13 is like "barely teen")
Ive been through this. I would recommend you to skip spigots serialization and go straight to Gson or Jackson.
Gson is not difficult to use.
I managed to just figure gson out on the fly
does Gson store in the ylm file?
No it stores json
Which is preferred over yaml
anyone have any idea whats going on here?
ProxyServer.getInstance().getConfig().getServers().containsValue(config.getString("TargetServer")``` im trying to detect if a server exists on the bungee config yet it just constantly says the server does not exist despite it existing
which is really better for your purposes
yaml is designed/used for config, not storage
okay
it's not needed, is way too easy
nope json. Jackson has a module for yml.
You can also translate json into yml at any time.
json is valid yaml anyway
YAML is a scary language
any tutorial on how to get started on json?
real devs just store json in yaml files
don't real devs use dbs?
real devs just write stuff into .bin files
^^ nah tommy
I actually do this
I actually serialize to binary
sorry, very old fashioned
psychopath
UUID gets saved to Gson?
DataOutputStream and DataInputStream are very easy to use :p
also where do i start
a database is for people just don't know to save all of your data into a single huge binary blob
any docs?
who needs a text editor when you have a powerful hex editor right?
jarvis go to google.com and type gson documentation
Well I shouldn't need to modify my serialized data in any editor
and this is the warning my editor gives
Map<String, ServerInfo>' may not contain values of type 'String'
i am genuinely confused
just go type Gson tutorial and click on the first baeldung tutorial you see lol
Quite clear. Your map may may not contain values of type 'String'. Not much to add there.
containsValue checks if a value is in the map
You're checking if a String is in your values
When your values are only of type ServerInfo
You want containsKey iirc
microsoft word is the most powerful
Just gotta remember all the alt codes for each byte value
exactly, easy stuff
when I get the Gson.toJson
how do i store it to the file?
a yml or json file is better
You want to pass a FileWriter or FileOutputStream to it
If you don't know what those are
Go learn Java IO
thank you. this worked
yeah
It can be anything as long as you keep it consistent between read/write
You should go for a descriptive name
you can also name it data.xyzabc123 if you feel like it
Yeah
you should be promoted my g
Its only for the OS. The binary data is unchanged
Yeah file extensions are kind of an illusion
They exist just to aid programs in detecting the type of a file
But in reality they're just another part of the name
I recommend you do the following:
- Have it end with
.jsonso people aren't (more) confused - Make sure to specify the plugin name so people know where it comes from
- Make sure to specify what its for so people know why it exists
e.g. if you're converting something like a bunch of User objects to a file
you might want something like <my-plugin>-users.json (replacing <my-plugin> with your plugin's name)
Simple shit honestly
or make a folder and store each user in their own json file like a gigachad
You can do that too
Although it makes me wonder whether or not it's faster to read a big file or a bunch of files
I think it depends on how much you'll be reading at a time
this is spigot minecraft game server
I don't think there is any major difference in efficiency between the two
Well file IO does perform native calls
It's gotta open the files
(Plus it's all synchronized since java.io is thread-safe)
It shouldnt really matter if it takes .01 or .1 second because it should be done async anyways.
True
Unless like
It's at the start of the server
Then it's negligible imo
I'm kinda lost tho once u got the fileinputStream how do you get the json object or string?
Are you looking at fromJson?
You need to use toJson when serializing.
Unless by "json object" you mean Object
In which case you pass your instance in
gson.toJson(myData, inputStream);
okay but i can't store multiple different json things in a single file?
You can store a list
so one file means one list?
Just one instance in general
e.g. you could store an array, a list, a map, a single object, a primitive (int, float, etc.)
Converting from JSON is easy too
Also wait
You need an output stream for toJson lol
?
So
OutputStream = Writing
InputStream = Reading
toJson = Serializing to JSON
fromJson = Deserializing from JSON
yeah that's my point
you need a FileOutputStream
Can you show your actual method call
FileOutputStream is what you're looking at, If you need something to store there just put the bytes of the string the toJson method returned
with the ByteArrayOutputStream I think
Nope, notice Appendable?
That's the supertype of Writer
I am terribly sorry for misleading you @sly trout You actually need a FileWriter
My brain isn't working well :p
there it is
I'll just give you an example
no problem you tried to help ๐
// This is a try-with-resources statement - It closes the writer after you're done using it to free up resources.
try (FileWriter fw = new FileWriter("myfile.json")) {
gson.toJson(object, fw);
}
Btw if a type implements Closeable
You should always make sure to close it after you're done using it
either via .close() or a try-with-resources
okay ๐
There's actually some types that will fail to write correctly if not closed (e.g. ZipOutputStream)
no need to save?
What, with Bukkit's methods?
Those are only for the plugin's YAML configuration.
Writing to a stream or writer means that it outputs the bytes immediately (or at least after a .flush(), although most types auto-flush on close)
So yeah you don't need to save.
okay
still, make sure you're writting into the file every time you make a change
and a type
try (FileReader fr = new FileReader("myfile.json")) {
Object o = gson.fromJson(fr, Object.class);
}
(I recommend generics here)
thank you you've really been of great help !
If you don't know generics/type params
Learn them immediately
You will be glad you did.
I'm french sorry I don't really know every term in english
Fun fact: Most programming terms don't even make sense in the context of English
Anyone know how i can do this function in another class? i cant make the function static and i cant implement the main class or create a new instance of it. ive run out of ideas. even tried referencing it by itself manually the other class but that doesnt work either because i cant do GetDataFolder() in a class that isnt main
lol
why would that even be useful in that case&
we just get Object
Pass the data folder to the function
e.g. myFunction(getDataFolder())
wouldn't that work : ArrayList<PlayerData> data = (ArrayList<PlayerData>) _gson.fromJson(fileReader, Object.class);
It actually probably wouldn't
Gson needs to know the type so it can find the correct fields
Gson's generic types are...
not easy to work with
cant reference the function in another class because it is not static
for complicated reasons you can't do List<PlayerData>.class
Then make it static
Just make a util function :p
what should i do then
I don't think he can, cuz the function is already defined
Btw what version of Gson are you using...?
the problem is i cant make it static otherwise i get errors
Ah so the one that comes with Minecraft? That's probably older then
no the Google. something
but you can create a static function in other place and then call that function is that what you're looking at?
Yeah Gson is a Google library, but Gson is bundled with Minecraft since Minecraft uses it.
create a variable in the Main class and then you can the instance of the main class and then get the methods thats what i do
except i cant instance the main class
why not
if i do that is says plugin is already initialized
i'll show u
side note i am working with the bungeeapi
private static Main plugin;
public void onEnable() {
plugin=this;
}
public static Main getPlugin() {
return plugin;
}
this should work
to get the instance of the main class
Type type = TypeToken.getParameterized(List.class, PlayerData.class).getType();
That's how you get the type List<PlayerData> ^
Java is fucking great sometimes no sarcasm intended whatsoever
Because Java is complicated when it comes to type parameters
See
To explain why
I have to walk you through what type params really are
They're basically like method parameters but for a type
Meaning you can safely say a List contains Strings
e.g. List is declared like uhh
public interface List<T> implements ...
T is then specified when you create a new List (or ArrayList)
like List<String>
Don't ya hate it when you find your dream api but you can't import it due to the gradle thing being broken? :/
What's the API?
okay but you can't specify directly with Gson? bruhh
You can't with Java
It does exactly what I want, but I can't import due to the gradle thing being broken
that's stupid
List<String> list = new ArrayList<>();
list.add(""); // The compiler knows that we must pass a String to 'add' because it's a List<String>
// Before Java added generics, it looked more like:
List stringList = new ArrayList();
list.add("");
list.add(0); // Oops, we just passed an integer in a situation where we want *strings*
Now
Since Java didn't start with generics
adding them broke some backwards compatibility or smthn
so they had to figure out a way to make it compatible
and because of that
Type parameters don't exist at runtime.
List<String> compiles down to just a raw List
Which is why we can't state List<String>.class bc there's no way for the compiler to make that work
TypeToken is a hack that allows us to keep that type parameter information
I don't really know how it works so I won't explain it.
This is called "type erasure" btw.
Download it, import it as a files dependency.
That's all I can offer since "the gradle thing is broken" isn't descriptive enough.
i got that error
09.02 22:44:18 [Server] at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
09.02 22:44:18 [Server] at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)```
So, when I click the refresh button for it to import it says it can't find the import anywhere
What's your code
public static void saveAllDataToConfig() throws IOException {
Data file = Main.getPlugin().getDataFile();
try {
file.saveToFile(getPlayerReportData());
}
catch (Exception ec) {
ec.printStackTrace();
}
Have you tried invalidating your IDEA cache?
What's saveToFile
Show me that
Tbh, nah I didn't think of it ngl...
how would I go about loading a structure without updating the blockstates
If that doesn't work, try deleting your project's Gradle cache (.gradle), then if that doesn't work, your Gradle cache at $HOME/.gradle/caches/<your Gradle version>
It's always the caches lol
Thank you. This is the solution i have been looking for
I assume it's trying to access the fields on Object but Object denies access to those fields
(You'd benefit more from DI)
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
bruh what
You're passing in player report data, right?
Actually y'know what I'm probably wrong about that specific type part hm
I don't know why that's doing that gimme a sec
This looks like an incomplete stacktrace
Send the full error
09.02 23:00:34 [Server] at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
09.02 23:00:34 [Server] at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
09.02 23:00:34 [Server] at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
09.02 23:00:34 [Server] at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
09.02 23:00:34 [Server] at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
09.02 23:00:34 [Server] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
09.02 23:00:34 [Server] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
09.02 23:00:34 [Server] at com.google.gson.Gson.getAdapter(Gson.java:458)
09.02 23:00:34 [Server] at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
09.02 23:00:34 [Server] at CoolReports-1.0.jar//me.alexandre.files.Data.saveToFile(Data.java:27)
09.02 23:00:34 [Server] at CoolReports-1.0.jar//me.alexandre.playerdata.PlayerData.saveAllDataToConfig(PlayerData.java:54)
09.02 23:00:34 [Server] at CoolReports-1.0.jar//me.alexandre.Main.onDisable(Main.java:106)
09.02 23:00:34 [Server] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266)```
Oh I was actually kinda right.
It was a hashmap and not a List
so i just changed things to a hashmap but still doesnt work
hg
How could I stop commands like /fill or things like loading structures from sending block updates? I already have a physics listener thats supposed to stop them but doesnt work on /fill or structures
Or
Maybe I am
I honestly don't know what could cause that error
...well I do, I just don't know how it was caused.
bro im lost im really trying to save that data but i don't have a clue how
Hashmap<UUID, PlayerData>
Okay
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
``` anyone know what this mean in gradle im not sure what happned
I'm wanting to place a block roughly once every 5 or 10 ticks, but anywhere I put a runnable within
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
String blocks = chunkFile.getString("blocks");
for (Iterator<String> it = Arrays.stream(blocks.split("/")).iterator(); it.hasNext() && (placed <= count); ) {
String[] balls = it.next().split("(?<=\\D)(?=\\d)");
mat = Material.valueOf(chunkFile.getStringList("palette").get(CharIndex.charToIndex(balls[0])));
count = Integer.parseInt(balls[1]);
p.getChunk().getBlock(x, y, z).setType(mat);
placed++;
if (count == placed) {
placed = 0;
}
}
}
}
}``` doesn't change my outcome, what is the best way to approach this?
how to sort advancements from recipes in event PlayerAdvancementDoneEvent?
or how to get a advanvement name like minecraft:story/root ?
is there a way to get the command line arguments unparsed as a string
so lets say i call it with java -jar myjar.jar a --o="b c" i want to get a --o="b c"
right now im concatenating all arguments passed in with a StringBuilder with spaces
but i dont think thats the best way to do it and i havent tested it yet
Not afaik
How can I stop players from removing items from an inventory by shift clicking and closing the inventory really fast
I already try to cancel it by doing this
because iirc i coded an agent using a premain which passes in the command line arguments as a string (void premain(String, Instrumentation)), but i dont want to use the premain mechanism in a simple program so im wondering if theres another way
Does the item stay even after rejoining?
does it still occur when you remove "sender.updateInventory();"?
if so then maybe add a delay to it by 1 tick
If you're just cancelling you don't need to force an inventory update
yeah id guess updating the inventory is updating it with the added item somehow
I'll check
Someone told me it was useful to stop people getting ghost items
I'll remove it since it didn't seem to do anything
pretty hard to stop ghost items
ghost items arent really problematic cause they usually appear from doing wonky stuff on purpose. And since they dont exist they arent exploitable
To my knowledge they have a bigger chance of emerging given low tps
why blockplaceevent calls when the block is not placed in 1.8
for example you place a block under yourself
and it calls
is there anyway to find out that if the event is valid ?
I mean 1.8 is ancient so that doesnโt surprise me the least
maybe try version = 1.18
youre cringe
the event get called
Not implying you should change, however it does not go without saying you will have to deal with the bug yourself
Imagine asking for support for a version old enough to go to school
listen im getting payed for a 1.8 plugin
and i have my own reasons
if you can, help
1.8 bug so good luck
If you want to use 1.8 there is, was it taco spigot or smth?
There are some forks at least that are maintained for 1.8
Yuh, maybe they could assist you further
Yes but why ask here then
ask them why the bug happens

we are not maintaining 1.8
If you use a maintained 1.8 fork they should be able to help and maybe fix your issue
Anyhow pmzhero sounds like you should switch dev env to the production jar perhaps?
what
Use the same jar youโre using in production for testing basically
for example i cannot set the item in main hand to null, air or ANYTHING
in the block place event
why is that
Maybe use the scheduler and do it a tick after
done it
ask the maintainer of your fork
not working for some materials
im currently using paper
tested on spigot
tested on fork
Latest paper ?
we are not supporting it
Like. Unless you are using a fork that is maintained for 1.8 you are out of luck
Itโs very unclear what youโre using to test your plugin on
Neither spigot nor paper are
all 3 forks
spigot paper tacho
the last update was from 6 years. why shall we fix bugs for ancient versions?
which are long outdated
Yes, no one has an answer for you
if you cant help
no one is forcing you to chat
and mock me and 1.8
i have my own reasons maybe ?
this is a help channel
You do you but I think it was rather clearly stated that spigot discord in general does not support 1.8
not 100 reasons why 1.8 is trash and you should run a server with 1.8 pvp on 1.18.1
sure sure sure very stable
not buggy at all
ocm opm not buggy
very stable
exactly copies 1.8 sure sure
๐
more stable than 1.8.8๐
i shouldn't ask for help in a channel full of these idiots i guess
I donโt think 1.8 is bad itself
But it turns into an awkward situation when the software for that very version is no longer supported
Especially now since youโre coming to us complaining about a bug which to some extent is probably patched in newer versions.
excellent copies of 1.8 pvp tho
Also I don't see the point of asking here. Why not ask in the help channel of the maintained fork you are using. The developers there work on 1.8 code a lot more then people here :/
i have the problem also on spigot
and i ask for a help or a workaround or anyway to detect
Yes but again, the likelihood of people knowing 1.8 code and quirks here is so so so much lower than asking people that actively maintain a 1.8 fork
last 1.8 version built is a few years ago
last was log4j exploit
Fixing a remote code execution exploit does not make a version maintained XD
It's more of a "we don't want to be complete devils and have everyone not on latest be vulnerable to a pretty devastating exploit"
just let 1.8 servers burn
Too old! (Click the link to get the exact time)
still ugly af
but they do the job at the expense of no buggy af 6 year old not supported versions
Cool people just use 1.9 pvp
Just flame Mojang to overhaul PvP in 1.20
๐ฅฒ
my hero
guys i really need to know where (and when) do the MapRender.render(...) trigger
i know its when the player tries to render a map, but its too vague, i need more context on this
Yeah, that doesn't change anything
Oh wait hold on
I didn't try the new version
Peak dumb right here
Hmm, I think it's only occurring in creative mode now
I think it should be ok
Thanks
The general updating occurs in the ServerPlayer's doTick method
which sends update packets for every complex item in the players inventory (which rn is just maps xD)
the update packet for maps is only send every 5 ticks or if the map palette is dirty (e.g. a pixel was set)
@eternal night thank you! and what if the map is not in players inv but on an item frame
Eehh I think it loads the map from the server based on id ?
and from there on it is just static
at least I don't recall any map item ticking for item frames
Yeah it should be from id
hi guys, ages ago someone taught me how to listen to incoming packets without protocollib (i think it involved a custom playerconnection class) does anyone know how?
i'm making a pvp server so it's only on 1.8.9 so version dependence doesn't matter lol
delving into NMS is super interesting
After further testing it appears to be a real item only half of the time
but like when & where does it happen?
@chrome beacon xd
I'm not sure. If you remind me in an hour I could take a look at the source and see how it's done
alright tysm
Generally if you want to dive deep into NMS, setup a server source locally
makes this a lot easier
yea fair enough
i could've sworn the way that someone taught me to listen for packets ages ago was much simpler
maybe my memory is just bad xD
Maybe you just used Protocollib
yeah maybe lol
i don't know tho
i would've remembered installing another plugin lol
If I were you I would use it. Many servers have it installed anyway
trueee
but NMS is interesting haha
i recall that i had used packets to spawn in a PlayerEntity and then on right click i made it print a message in chat lol. time to go work out how to do that xD
thanks for the help btw guys
have a good day ๐
no
Hey, so I wanna allow people to either use WorldEdit or FAWE in my code, I currently have WorldEdit as a depend can I just set them both as softdepend or??
from how it seems ye i can use softdepend
Hi, I am having an unknown problem when trying to load the Bungee config and I was wondering if anyone could help me with this if possible.
Make sure your config.yml file is valid
I thought about this, and this is exactly what I am wondering, since no error message is generated, as it should be.
np
.
you didn't send line 55
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
How do I get and check if world has thunderstorm?
so uh i'm trying to get top values from a hashmap when a player does /topmoney <page> they get 10 top richest ppl on the server here's my current code
public void execute(CommandSender sender, String[] args) {
int page;
if (args[0].isEmpty()) {
page = 1;
} else page = Integer.parseInt(args[0]);
if (page < 1) page = 1;
final int[] place = {((page - 1) * 5)};
sender.sendMessage(Formats.DEFAULT + " Richest players on the server (Page " + page + "):");
AsyncPlayerData data = new AsyncPlayerData(Insidious.getInstance(), dataSource);
data.getTopBalance(place[0]).queue(result -> {
if (result.isPresent()) {
HashMap<Player, Long> map = new HashMap<>();
List<InsidiousPlayer> list = result.get();
for (InsidiousPlayer info : list) {
map.put(Insidious.getInstance().getServer().getPlayer(info.getUuid()), Long.valueOf(info.getValues().get("balance")));
}
}
});
}
i don't know how to return top values from the hashmap
Hashmaps arenโt sorted
oh any alternative way of doing it?
@EventHandler(priority= EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent e) {
boolean rain = e.toWeatherState();
if (rain) {
e.setCancelled(true);
}
}
@EventHandler(priority=EventPriority.HIGHEST)
public void onThunderChange(ThunderChangeEvent e) {
boolean storm = e.toThunderState();
if (storm) {
e.setCancelled(true);
}
}```
what is this for actually
As far as I can see, it is just another method for verification.
But there is a difference between what you want, in this case, if you want it not to rain anymore or if you want to check if it is raining or not.
You could get the entries as a Set, add them to a List and sort that list.
You can also just stream the entries and get the highest N elements.
because I just want to check if the weather and time are night or thundering... im quite new to this
To check if its thundering in this world...
thunderstorms count as thundering?
Everyone has experienced this, rest assured. Use the event below this image.
.
Yes thunderstorms are thundering
yes but when you enterbed event in daytime and it kicks you out it stills runs
why reinvent the wheel
else if (world.getTime() > 13000 || world.isThundering())
//action;
return;
ahh thanks a lot of the clear explanation!
:)
Do you have any idea what it could be?
cant u just instantiate a YamlConfiguration directly
Same error :/
hmm
Looks like you have broken your yml file somehow.
Paste it into some yaml verifier online.
^ online parsers are goat
Hm. It could be a problem regarding your special characters like accent aigu.
Make sure every String is quoted.
Ok, just moment
Same error
After doing what?
I did it, I can't believe I didn't see it before
It turned out that the jar generated a faulty config file within config, so no matter how many times I tried to change it in the code, it could only be changed in config
are you trying to read an empty YAML @floral flare ?
because the stacktrace suggests that
since it says length is 1 (only EOF)
They fixed it
Yeah you have to remove the config in your servers folder if you make changes in your plugin XD
ah this
is it safe to use Chunk object as key in hashmap?
Could lead to a memory leak if you are not careful.
You can actually represent a chunks location (x and z) as a long.
um I do need also consider world
Paper has it
You probably want something like a Map<UUID, Map<Long, Data>>
public static long hashPositions(int x, int y) {
// We make use of (y & 0xFFFFFFFFL) as otherwise y values such as -1 would completely override the x value.
// This is because `long | int` automatically casts the int to a long, where as the cast is by decimal value
return (((long) x) << 32) | (y & 0xFFFFFFFFL);}```
x = (int) (hashed >> 32);
y = (int) (hashed & 0xFFFFFFFFL);```
So i have a set of values per player where almost every value is null.
Should i do a HashMap<UUID, HashMap<Enum, int>> or a HashMap<UUID + Value_Name, int>, then null check, or is there a better solution than either?
I wouldnt add null values to a HashMap
no
null check after calling get
so that i know if it should be 0
bc it aint there
thats what the null checks for
map also has getOrDefault
that'd do it
the issue is that i need a simple way to map two keys to one value
how to do that
(String, Enum all probabilit afater)
you mean two values to one key?
I#d just create a data class that I'd use for the values
two keys to one value
that's no problem at all?
I'd rather not have a map inside a map
Mapping two values to one key sounds like you should create an extra class for that
If you want two keys for one value then you should use a Table
my brainded arse googled table and was surprised to see tables
Table<UUID, Enum, Integer> dataTable = HashBasedTable.create();
wait do you want to use something like <Object1,Object2> as key? or do you just want Object1 -> Value1 and Object2 -> also Value1 ?
I need some different values for different interactions, which apply to the same values. Like interaction + HEALTH_CHANGE for example
and I'd rather not read in the config every single time
Config is stored into a map when read
what's the O(n) for FileConfiguration.getInteger(two_layer_deep_path)
if its small that might be a solution
if i grab that map
Dont read configs on runtime. Just read them once the server starts and use properly named variables to store the data.
so
FileConfiguration rcfg = Bukkit.loadResource(config_path)
...
rcfg.getStringList(path).contains(value)```
?
He means store the string list itself into a variable
isnt FileConfiguration also extending Collection<T> ?
No
Its a MemoryConfiguration
Which is basically a glorified HashMap
But not quite
hmm given two location x1, z1, x2, z2, is there any good algorithm to find all chunks which contain blocks within the rectangle form by that two location?
bit shift em to the right then grab the chunk coordinates. Difference between the x1/x2 and y1/y2 shows you how much you have to go east/south
Not much of an algorithm: You just iterate using two nested for loops
im unsure if bigger values take longer to compare
x1 >> 4; x2 >> 4; z1 >> 4; z2 >> 4;
for(int x == x1, x<x2, x++){
for(int z == z1, z<z2, z++){
Bukkit.getChunkAt(x,z);
Something like this:
public List<Chunk> allChunksBetween(final int x1, final int z1, final int x2, final int z2, final World world) {
final List<Chunk> chunks = new ArrayList<>();
final int minX = Math.min(x1, x2);
final int maxX = Math.max(x1, x2);
final int minZ = Math.min(z1, z2);
final int maxZ = Math.max(z1, z2);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
chunks.add(world.getChunkAt(x, z));
}
}
return chunks;
}
iirc he is using coordinates, wouldn't that trigger 256 times per chunk
I thought he meant chunk coordinates
'to find all the chunks that have blocks in that rectangle'
but thanks anyway
public List<Chunk> allChunksBetween(final Location a, final Location b) {
Preconditions.checkArgument(a.getWorld().equals(b.getWorld()));
return allChunksBetween(a.getBlockX() >> 4, a.getBlockZ() >> 4, b.getBlockX() >> 4, b.getBlockZ() >> 4, a.getWorld());
}
huh
lol
imma copy that
ya I may over complicate the problem
Maybe. What are you trying to do?
but btw should use Set instead of List for the internal use I guess
wait
nvm it should be fine
I wanna know ๐
Maybe its a xy problem
similar like res plugin
I want to map location to an area object
so I can know which area player currently inside
Oh. Then you should def not touch any chunks. You need to think more abstract for this.
to avoid O(n) iteration, I am currently decide to use chunk as bucket
This makes a bit more sense.
so map location to chunk first, then iterate over areas in the chunk bucket
Thats also what i did for my regions.
BoundingBoxes with chunks as buckets
ya otherwise it could be slow when too many area or region