#help-development
1 messages ยท Page 2093 of 1
how to use better bees spigot plugin
when i want to use this: https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/
i get: [WARNING] The requested profile "remapped" could not be activated because it does not exist.
and i a lot of the things are not importable anymore.
How do i fix this?
this is developers chat, are you developing a plugin?
Well at least it classifies under "good enough" for me
bird
i did "java -jar BuildTools.jar --rev 1.18.1 --remapped"
i got [WARNING] The requested profile "remapped" could not be activated because it does not exist.
update your build tools
and maybe clean your build tool work environment
that seems like build tools is trying to do stuff on an outdated source
wdym exactly? sorry im not good.
like, when running that you should get a bunch of folders in the directly you run the command in
work Bukkit CraftBukkit etc
yea i got that
Delete those
download the latest build tools
from the website
and then try again
someone please help, how can i update my config to newer version while keeping custom values
thats what i did already but ill try again
if it still fails, please send the entire logs of the build tool
The player armor slots are 100-103 right?
alrighty
you can upgrade a config by basically having a version field in the config
and then run migration logic based on the version you find
"it doesn't work" is not really a thing anyone can help you with
it doesnt update the config
what doesn't update the config
this java reloadConfig(); this.saveDefaultConfig(); saveConfig();
what is that
but it should
how is that going to perform a version upgrade
it is config updating code
Or...
you reload the config, e.g. load all values from file, then call saveDefaultConfig which does nothing because a file already exists
and then you save it ?
how does that do anything
i have tried this, it doesnt work
You need to save the config after using it
yes and i do
AE does this so your doing something wrong somewhere
shouldnt it create new values that dont exist
ae?
no
saveDefaultConfig just writes the config in your jar to disk if the file does not exist yet
^
Hello &everyone.
Does anybody here know how to iterate over all possible block states ?
Btw kidney this only works for when fields dont exist
(also documented in the methods javadocs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/Plugin.html#saveDefaultConfig())
lol
https://prnt.sc/asyYhBcxUUNF
Does putting a value (in this case a player's UUID) in one hashmap automatically remove it from other hashmaps?
okay
also, quick side question, if you are just storing, I presume, a team, why do you need multiple hashmaps
a hashmap for each team, I'll do various things
just store the team keyed by player
instead of storing null
otherwise use a hashset per team or something
that looks good @proper pawn
hashmap doesn't allow duplicate keys
^
like
HashMap<Player, Team> teams = new HashMap<>()
public enum Team {
RED, GREEN, BLUE
}
okay but when i want to import the class "WorldServer", i cant.
Yea because it is mojang mappings
lemme grab you a page to translate between spigot mappings and mojang mappings
and maybe a
HashMap<Team, List<Player>> playersByTeam = new HashMap<>();
ah okay thank you
alrighty thanks @glossy venture
to insert do like
public void setTeam(Player p, Team t) {
teams.put(p, t);
playersByTeam.computeIfAbsent(t, __ -> new ArrayList<>()).add(p);
}
forgot to add the key lol
๐
@noble lantern how can i delete values that should no longer exist?
Set the path value to null iirc
ok
nothing happened
reloadConfig();
getConfig().getBoolean("back-enabled", true);
getConfig().getBoolean("kickall-exempt-enabled", true);
getConfig().getString("messages.permission-message", "You don't have permission to use this!");
getConfig().getString("messages.kickall-message", "Kickall command was used!");
getConfig().getString("config-version", null);
this.saveDefaultConfig();
saveConfig();```
should remove config-version and ass messages.kickall-message
but it doesnt
@noble lantern
not rip anymore
Is it possible to get a material given DyeColor?
the flaw you have is you are doing this.safeDefaultConfig()
should remove that
did not work
well you are getting the values
not setting them
so change all them gets to sets ๐
how to use mappings of the NMS files?
this doesn't help if they are changing the config
you need to save your in memory changes to apply
wont that reset custom values though
what is he trying to do
I am assuming set something in the config
Hes trying to manage configs between versions
yes
Ie plugin versions
Im not sure i dont really use yanl anymore
There move be a remove or delete method
ye i did that
Hello &everyone.
Does anybody here know how to iterate over all possible block states ?
bro ive been living with my stupid bug for way too long
basically it needs to download and unzip the minecraft assets, but the check to check if i needed to download them again always returned true, so i was waiting for 10 seconds every single restart
i finally fixed it
do you even have a config.yml in the jar?
yes
I find it odd in how many people have problems using simple methods
main/resources/config.yml
like, these api stuff don't magically just stop working ๐
saveDefaultConfig does only overwrite the config.yml if it doesn't exist yet
didn't we go over that already ๐ค
oh what are we doing then
this doesnt work
trying to set defaults per version and then saving them to config
your get calls do not change the values in the config instance
but wont set reset custom values
Well if you call set on existing configurable paths then yes
then how can i make sure it doesnt do that
there is a contains(String) method to check if it already exists
actually, can i just check if the key exists
isn't that exactly what the mentioned contains method would allow you to do ๐
no?
what ๐
it check if it contains a string
not if a key existss
hmm
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
would this be everything?
i dont have enough time and will to test all cases
what are you doing? o.O
idk im trying to implement all methods i might need
to a custom item stack wrapper thing
CompiledStack
but why do you need to change the hash in that way?
yes
idk i saw it in Arrays.hashCode(...)
wouldn't the nms item stacks have proper equals and hashing methbods
yikes
lol
mojang strikes again
yeah
its not hard to make your own
but I just don't know why you need to do it that way lol
does anybody know what this means? (its mongodb) Expecting replica set member from set 'Cluster0-shard-0', but found one from set 'atlas-8yanjy-shard-0'
lmao dyno is offline
tf
main class: https://paste.md-5.net/atidorocir.java
yamlconfiguration class: https://paste.md-5.net/equpasuwoj.java
placeholderapi class: https://paste.md-5.net/equpasuwoj.java
error in console: [13:42:39 WARN]: Exception in thread "Craft Scheduler Thread - 21648" [13:42:39 WARN]: org.apache.commons.lang.UnhandledException: Plugin Scoreboard-revision vR4 1.1 RELEASE generated an exception while executing task 10 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException [13:42:39 WARN]: Exception in thread "Craft Scheduler Thread - 21649" [13:42:39 WARN]: org.apache.commons.lang.UnhandledException: Plugin Scoreboard-revision vR4 1.1 RELEASE generated an exception while executing task 10 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException
there is something wrong with return String.valueOf(Disabler.instance.getKills(p));
one of the thing is null, either instance or getKills
looks like Disabler.instance is null
e
oh yea
show rest of stacktrace
its all of it
is the error produced in String.valueOf
is getKills a get method from HashMap?
e
look at your onEnable on Disabler class
(gearMap[inventory.helmet!!.type]!! + gearMap[inventory.chestplate!!.type]!! + gearMap[inventory.leggings!!.type]!! + gearMap[inventory.boots.type]!!)
What are the armor slot indexes?
you initialize instance = null on line 31
yes same i just copied the code
Would anyone be able to point me to a tutorial or document about unit testing w/ Spigot? I'm used to unit testing with things like PHPUnit and Mockery and a couple other web frameworks, but really getting tired of random PRs where people aren't testing their code ๐ so I'll test it for them.
you never called PlayerData#setup?
e
Does anyone know what the armor slot indexes are?
in join event
is there a place where i can ask people to join a server to help me test my plugin real quick?
i think i know the error
i didnt do PlayerData.setup in the getKills,deaths,etc
why not set up player data in onEnable
What do you mean? PlayerData#setup should only run once.
And do it inside onEnable
ok it works
can anyone join my server real quick to help me test my plugin
oh oof
Do armor slot indexes stay the same for all versions?
oh i found someone but thanks
ok
can't guarantee
they should but can't guarantee
just use getHelmet, getWhatever
or getArmorContents
0 is boots, 1 is leggings
for the most part yes, however there could be a time
where mojang decides to add more
Isn't it 5, 6, 7,8??
for (i in 5 until 9) {
lateinit var key : String
when (i) {
5 -> key = "HELMET"
6 -> key = "CHESTPLATE"
7 -> key = "LEGGINGS"
8 -> key = "BOOTS"
}
inventory.contents[i] = ItemStack(gearMap.keys.filter { material -> material.name.contains(key) }.shuffled().first())
}
depends
sometimes it's like 101, 102
but generally it's
int headSlot = 39;
int chestSlot = 38;
int legsSlot = 37;
int feetSlot = 36;
I'm not a fan of copy pasting the same code
I code in Java too, still doesn't change if I like copy pasting code lmao
On what does it depend?
the version
Oh, that's no good
Caused by: java.lang.NoSuchMethodError: 'net.minecraft.server.level.ServerPlayer org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer.getHandle()'
any idea why this occurs?
Is your server running 1.18.2
What is VaroCommand line 19
ServerPlayerConnection playerConnection = player.getHandle().connection;
yes
Are you using maven?
^
gradle
Paper userdev plugin?
If you're using mojang maps you need to make sure you're converting the JAR back to Spigots maps when you compile
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
mavenLocal()
}
dependencies {
compileOnly 'org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
}
how do I do it?
You need Paper userdev for gradle
is it a dependency?
It is a gradle plugin
That's the example repo on how to use it
Note tho, if you are running a spigot server and not a paper server, ensure you only use methods and classes available on spigot
Could not find method maven() for arguments [https://papermc.io/repo/repository/maven-public/] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
Cause: paperweight requires a development bundle to be added to the 'paperweightDevelopmentBundle' configuration, as well as a repository to resolve it from in order to function. Use the paperweightDevBundle extension function to do this easily.
I think I should learn more about Gradle, I never really learned it
If you want to use it, yea it is a fun rabbit hole to dive into
lmfao oops
gg
its doing it for a long time without errors so thats good I think lol
Could not get unknown property 'Charsets' for task ':compileJava' of type org.gradle.api.tasks.compile.JavaCompile.
gradle can be annoying from time to time
Gradle is a pain in the ass to setup but it's a godsend when it works
I got it, I commented out the things which didnt work and it worked lmao
I'm trying to change the default chunk generator to one that just makes a void world just to learn, shouldn't this be working?
1.18.2
you need to define the generator in bukkit.yml i think
like
# ...
worlds:
name:
generator: YourPlugin
or use multiverse
is there any where I can see it documented?
I appreciate it, hope I can get this working ๐
Could someone enlighten me ?
I'm trying to get the instance of the sign from a block location, which I used to do via #getState() and then casting, but that doesnt work anymore aparently
what do you mean by "doesnt work"
is there a runtime error?
like a ClassCastException
oh yeah should have clarified, indeed it's a ClassCastException
[15:09:01 ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - git-Paper-220 (MC: 1.18.2) ---
[15:09:01 ERROR]: The server has not responded for 45 seconds! Creating thread dump
[15:09:01 ERROR]: ------------------------------
is this normal when creating worlds?
No
Ask Paper and provide full log
Make sure to use the right import
I did, it's the block version not the material enum
Okay if you imported this: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Sign.html
Make sure the block actually is a sign
declaration: package: org.bukkit.block, interface: Sign
setFireTicks 0
yes found it but thank
Ok found the issue, minecraft wouldnt place the sign cause it had no block below it
wtf is your cursor?
just a cross
It looks like you're playing with a controller lol
idk i hated it at first but i wanted to use it for bw
and now im usedto it
i can aim better now
like in guis
lmao
how do i set player's yaw?
yes but idk how
Why does my packets not work? I have build tools installed|
https://cdn.discordapp.com/attachments/741875845089722499/964365543333318657/unknown.png
https://cdn.discordapp.com/attachments/741875845089722499/964365543635316786/unknown.png
https://cdn.discordapp.com/attachments/741875845089722499/964365543924719617/unknown.png
version 1.16.4
does it work on 1.8?
Yes
Use a paste site instead of screenshotting text
https://helpch.at/docs/1.8.8/ 1.8.8 docs
Just guessing since those images aren't loading for me
hmm one secondd
?paste
oh yea thats weird
ok imma post to imgur rq
is that better?
ill get a better solution later
run buildtools
Open 1.16.4 folder
And send contents
Also did you reload the project so it uses the latest pom
I have reset my computer between the time of creation
Alright try
File > Invalidate Cache
hey
Hello
so um, im using json to store player data, the data will be updated as long as the player is online
should i close the handle when im done writing the information or just close it when the player leaves
You should be caching that information and writing it at both a regular interval and when the player leaves.
Read on join. Save on quit and maybe an autosave once in a while. No need to keep the file reference
which?
huh, so should i have like an object to store the player data a variables?
did that image load btw?
yes it loaded.
ok good
Just that
Implementation would be up to you, but the idea behind what I suggested has two benefits. One, It is more efficient as write operations can be expensive/taxing for the CPU. Second, you are preserving as much recent data as possible by autosaving a cache every so often. It's just a precaution as if the server crashes, and you only save data on shutdown, then every bit of data that was going to be saved has now been lost.
tysm! I am sure all of your preferred gender come chasing after you, like dogs chasing some raw meat
Okay I see, but I dont see another way of storing data if not an object
I do this with my plugins, but I have use an interface as I have multiple storage options.
For your case, I'd recommend reading the file in on startup ---> caching the data ---> close the file.
You then work with the cache when you need to make changes.
Finally, when you want to actually write the data to disk, save the file.
also wouldnt saving all player data at once lag the server?
It might. Really depends on your setup, but there are ways you can split tasks up.
How?
Well, it would only start to lag if the amount of players is extremely large OR the amount of data that needs to be saved is extremely large.
But, it would be momentary.
gosh I always underestimate how powerful computers are
That being said, you would obviously mitigate that by only loading players that are online.
Also writing to a file can be done async
^
So no need to block the server when saving
okay
Keep in mind that JSON files are small. So if each player only takes up about a kilobyte of disk space, and you have 10K players online. You likely wouldn't even see a large drop in performance as you are only writing 10MB worth of information to disk. Even if you did that all at once.
how can I make my client entity dismount a boat
I mean I dont really need to read/write the information of every player
just the online ones
True, and you should be doing it that way. I'm just pointing out that even if you had the entire database, it probably wouldn't be that bad. (Ofc it the amount of data is larger, then it might be worse.)
and if i have 10k players online, writing files isnt my biggest issue
Yea. You'd likely be switching to another storage medium at that point.
I was going to use a sql database but then i was like i really dont need something that big
I mean, if you can, SQL or generally a DB is probably best
their indexing capabilities beat plain json files per user in a lot of areas
but would it really change so much
I mean, idk what data you store
but any form of "best" or "worse"
is pain with json
It likely would. Although you wouldn't see a whole lot of it on a small scale.
idk, player health, speed etc
I can tell you with certainty that it would help in some areas. Take YAML for example. The data within can be a number of things. Strings, Integers, Lists, etc. However, the file is saved and read as a String. Completely negating any benefit that would be gained by reading the data as it's actual type. You would't have that issue with a MySQL database, as it's designed to be compact.
Okay
I think I can switch to MySQL if I need to later on right?
How hard would that be
Depends on your codebase. I mentioned earlier that I use an interface for my storage solutions. Meaning that the end user can choose between YAML, MySQL, and whatever else I made available. If you are hard coding everything to work with JSON, then you will have to refactor your entire project to switch it over to MySQL.
there is a way to hardcore everything?
That being said. I recommend that you don't just switch it over completely, as you will be in the same boat when you want to switch to something else.
cant i just... switch the reading/writing methods
This is why I prefer using interfaces for things like this.
If you have a method called createPlayer() and you are using JSON. That method is obviously going to contain code for saving JSON. So now, you need to call that method every time you want to create a player.
What if you want to use MySQL instead? You now have to rewrite the createPlayer() method with code that works with MySQL. Consequently, you now lost all of the JSON code that you wrote.
So what if you could easily switch between them? In comes the interface.
You will still have the method createPlayer(), but this time, depending on a setting, it can switch between the JSON code you wrote, and the MySQL code you wrote.
Can I somehow change the name of the player above their head?
so like createPlayer(Type.JSON) Type being JSON. MYSQL and all that
and then switch them according to the type?
Hello! Why does my server stop responding when I use the placePlotOnNextAvailable Method? Here is code and error: https://gist.github.com/ItzJustNico/3e1e4806a18d14161969ca0880b7dd6f
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/fc460d1bb8d5f2bc9ff07dad1b7b402eed06d7c4
Villager#zombify() was merged last night, so if you're using 1.18.2, you're encouraged to use this method now

Kinda.
It would look more like this.
public interface DataManager {
void createPlayer(UUID uuid);
}
Player player = //however you get the player.
DataManager dataManager = new ImplemntationOfDataManager();
dataManager.createPlayer(player.getUniqueId())
Now, the ImplementationOfDataManagerClass would look something like this:
public class YAMLDataManager implements DataManager {
@Override
public void createPlayer(UUID uuid) {
// Your code for creating the player
}
}
In this example, I'm using YAML, but it can be for whatever you need.
Then the code above would turn into this.
DataManager dataManager = new YAMLDataManager();
@red sedge
Oh I see
That way, you can do things like this.
DataManager yaml = new YamlDataManager();
DataManager mysql = new MySQLDataManager();
DataManager h2 = new H2DataManager();
Interfaces like this are really flexible.
Actually made use of something similar relatively recently in VeinMiner ๐ So if you want a proper example,
https://github.com/2008Choco/VeinMiner/tree/2.0.0/VeinMiner-Bukkit/src/main/java/wtf/choco/veinminer/data
Gave the option of JSON, SQLite, and MySQL
What's line 45 of your BlockBreak class?
for (String commands : materialBlocks.get(Material.IRON_ORE).getCommands()) {
pls help ๐
where does p.hasPlayedBefore() get the data from?
https://paste.helpch.at/ikokoxokes.java Blockproperties class here
Well according to your error, one of the values in your materialBlocks hashmap is null. So my best guess is that the material you are looking for isn't actually in the map.
it is there
The user's playerdata file that's stored in the world folder.
k
Have you verified that? Print out the contents of the map to double check.
i manually deleted the world every time to check my database implementation of hasPlayedBefore ๐คฃ
how do i check if PlayerData.get().get("Players." + p.getUniqueId() + ".firstjoin")); exists?
use .hasplayedbefore()
Then do you have another plugin that was keeping track of first joins?
no
Then you aren't going to be able to get the first join date of players who have already joined.
go through the server logs and add them manually ?
Well rather automate the finding of them, but still
Why does my server stop responding when I use the placePlotOnNextAvailable Method? Here is code and error: https://gist.github.com/ItzJustNico/3e1e4806a18d14161969ca0880b7dd6f
That information isn't something that's logged. There is a method called #getLastPlayed() which will return a timestamp, but it updates every time the player joins and leaves.
If you want to keep track of join dates, you have to do it at the very beginning of the server.
It's blockOccupied() that's causing issues, placePlotOnNextAvailable() is just calling it
Line 42 in particular, if you could highlight it
Whatever it is that's on that line is taking a hell of a long time
With that being said, I've a feeling that a for loop almost certainly isn't the most effective way to go about finding an available plot. There's likely a mathematical way you can go about calculating it and doing an O(1) operation instead
does CraftItemEvent get called when you take the result item, even when the recipe is not 'valid'
like i dont have the recipe registered
because its for custom items
its a custom crafting system
It should be called when the item is taken out of a crafting table. I don't think it has to be a registered recipe
for (String blockName : plugin.getConfig().getConfigurationSection("Blocks").getKeys(false)) {
for (String blockNameProperties : plugin.getConfig().getConfigurationSection("Blocks." + blockName).getKeys(false)) {
List<Integer> percentages = new ArrayList<>();
List<String> commands = new ArrayList<>();
percentages.add(plugin.getConfig().getInt("Blocks." + blockName + "." + blockNameProperties + ".percentages"));
commands.addAll(plugin.getConfig().getStringList("Blocks." + blockName + "." + blockNameProperties + ".commands"));
materialBlocks.put(Material.matchMaterial(blockName), new BlockProperties(percentages, commands));
```System.out.println(blockName);```
}
}```
Do i print like this?
I'd debug outside of that logic first. Take the same for loop and copy it above the first one. Then only print out everything.
That way your code doesn't error out in the middle of the loop.
?jd
ignore this
Here is the whole thing cause line 42 is going through Json files basically.. : https://github.com/ItzJustNico/PlertanixPlot/blob/4d0089a3d18f5a4b3a9a6f855abfbe73ffe2c094/src/main/java/com/itzjustnico/plertanixplot/plots/PlotHandler.java
i think it has to be an official recipe
i guess ill try it with an InventoryClickEvent
what does this mean, I changed the player name with NMS and now I have this problem
Don't ever change the player's name with NMS. Modifying the player object as a whole can screw up everything.
Make the name shorter
Also this
yeah, I realized
I'm pretty sure there is a method available to change the player's displayname above their head.
Can I somehow reset the custom names in the server?
there isn't
I'm pretty sure there is, as plugins are able to add things like prefixes and suffixes to player's names just fine. Granted that might be done with Scoreboard teams, but it should be possible without having to delve into nms.
will resetting playerdata do it?
What kind of player data?
You could likely just restart the server.
ฤฑ am turkish
the playerdata which is in world
didnt help
Then yea, you might want to delete that. Make sure you are out of the world first.
aight, playerdata delete helped
alright, how do I change the name above head without breaking everything?
Searched in the following locations:
https://repo.dmulloy2.net/repository/public/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/spigot-1.18.2-R0.1-20220228.182956-1-remapped-mojang.jar``` why did this just stopped working?
getting a chunk dont necessarily load it, right?
Correct. You need to call #load() in order for it to load.
You can also check if it is already loaded with #isLoaded()
how do i run code every 1 second while the server is online?
?scheduling
get chunk iirc always performs a chunk load
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getChunkAt(org.bukkit.Location) for example
declaration: package: org.bukkit, interface: World
Well, there are two methods. There is #getChunk(), but there is also #getLoadedChunks().
on what object/class do we talk about getChunk
The world's getLoadedChunks obviously does not load any new chunks, but any getChunk method on the world will load the chunk if it isn't loaded rn
which also affects Location#getChunk and Block#getChunk respectively
how to use the ChatColor.translateAlternateColorCodes
final String sectionSignChatMessage = ChatColor.translateAlternateColorCodes('&', "&6This is in gold, but with an &");
ive seen some people do it with a method?
I keep getting "this.missile_manager" is null and it's odd cause i do the exact same code in a different class and it isn't null and my IDE doesn't say anything about it
so what does the &6 do?
It makes it gold
Legacy colour codes are like ยง6 for gold for example
but because people may not want to use the section sign for everything you can "translate" their ampersand usage to section signs
public class onBlockPlaceEvent implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) throws InterruptedException {
Block blockPos = e.getBlock();
TimeUnit.SECONDS.sleep((long) 1.5F);
blockPos.setType(Material.AIR);
}
}```
I want to break a block 1,5secs after it got placed. With this code it breaks only one block at the time...
NO NONO
see how to schedule actions on the server
your method is blocking the entire minecraft server for 1.5 seconds
or Thread.sleep()
Also, don't use #sleep() on the main thread. >.<
oh
anyone have an idea?
use a runnable
is mavenLocal() in your repo list
๐
if you are on gradle
is that the entire stack trace ?
else move the mavenLocal()up
idk if the dully repo is fucking something up
but gradle processes these in order of declaration so that could solve it
that worked tyvm
how to register the runnable?
Generally what I find useful is to define which artifacts to pull from repos
saves you from this
?scheduling
๐ค didn't I already link that
new BukkitRunnable( pubic void run() {}).runTakeLater(plugin, time);
it does afaik
or just use the java 8+ lambda style
But it does not break the block
on the BukkitScheduler
๐
the "basically never use Thread.sleep" part was ignored
How do I use packets?
don't sleep in your logic, define a proper delay when scheduling the runnable
no variable dont store it
probably because remapped is going to be in your local maven repo
just put the code you wanna delay within the runnable
I don't have these things like PacketPlayOutPlayerInfo
yeah, like said before, no idea about gradle lol
?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
Your PacketPlayOutPlayerInfo is ClientboundPlayerInfoPacket in pretty mojang mappings
oh ok
Plugin plugin is my main class, right?
the instance of your main class yes
I've read I somehow can change the name above head with PacketPlayOutPlayerInfo, anyone have an idea how?
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
Block blockPos = e.getBlock();
blockPos.setType(Material.AIR);
}
}.runTaskLater(BuildFFA.getPlugin(), 1500);
}```
runTaskLater returns you a BukkitTask
you will need to change it in a couple of areas not just one. For instance tablist for instance
which is kind of like "the running BukkitRunnable`
I changed it in: CustomName, DisplayName, PlayerListName
The general nick process iirc is: Destroy player entity, send player info with remove of their game profile, send player info with addition of the changed name game profile, spawn in their entity to players"
what LynxPlay said ๐
Well either change the type of the runnable var
or cal runTaskLateron runnable instead of the just created bukkit runnable
runTaskLater does 1 thing after a period of time
depends on what you need
runTaskTimer runs a task after each period of time
so you can think of it as a clock pulse
so first send a REMOVE_PLAYER packet to everyone
I'd recommend using the static method for scheduling if you need something quick.
Bukkit#getScheduler()#runTaskLater()
First yeet the entity with ClientboundRemoveEntitiesPacket
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
BukkitTask runnable = new BukkitRunnable() {
@Override
public void run() {
Block blockPos = e.getBlock();
blockPos.setType(Material.AIR);
}
}.runTaskLater(BuildFFA.getPlugin(), 1500);
}```
(still does not break the block 1,5secs after placing)
oh
1.5 seconds are 30 ticks
just send the packets to all online players yes?
all but the one nicking
Well you can send them the REMOVE and ADD
just not the destroy and spawn packets
else their client is fucked
oh
ClientboundRemoveEntitiesPacket packet0 = new ClientboundRemoveEntitiesPacket();
ClientboundPlayerInfoPacket packet1 = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, player.getHandle());``` first one send to everyone yeah, what about second one?
first one to all but the player you are renaming
second one to all
also first one needs the player's entity id
how do I get it?
the handle should have a getId method ?
Well next, info packet but with the changed game profile
and ADD
which is tricky
because there is no constructor for it
what Info packet?
ClientboundPlayerInfoPacket ?
ye
but it is tricky
because that packet contains basiclly the game profile with the changed name
oh
Player.gameProfile is public tho
should I just do a new Player.gameProfile?
the last time I changed the name in gameProfile i fked up my server lol
so basically:
var oldGameProfile = playerHandle.gameProfile
playerHandle.gameProfile = newGameProfileWithDifferentName;
ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(ADD, playerHandle)
playerHandle.gameProfile = oldGameProfile
it is ?
so do with reflection?
oh
yes
alright, at least I know how to do reflection lol
because the field is not going to be named "gameProfile"
at runtime
or well, might not
Yea, it is called cs in 1.18.2
ok
Field gameProfileField = player.getHandle().getClass().getField("cs");
gameProfileField.setAccessible(true);
GameProfile oldProfile = (GameProfile) gameProfileField.get(player.getHandle());
GameProfile newProfile = new GameProfile(player.getUniqueId(), name);
gameProfileField.set(player.getHandle(), newProfile);
ClientboundPlayerInfoPacket packet3 = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, player.getHandle());
gameProfileField.set(oldProfile, player.getHandle());
will this work @eternal night ?
I want to give the player items after he died, how can I do this? This is my current code:
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
e.setKeepInventory(true);
for (ItemStack item : e.getEntity().getInventory().getContents()) {
if (item == null) return;
item.setDurability((short) 0);
}
for (ItemStack armor : e.getEntity().getInventory().getArmorContents()) {
if (armor == null) return;
armor.setDurability((short) 0);
}
Player p = e.getEntity().getPlayer();
ItemStack blocks = new ItemStack(Material.SANDSTONE, 64);
ItemStack pearl = new ItemStack(Material.ENDER_PEARL, 1);
p.getInventory().setItem(8, pearl);
p.getInventory().setItem(2, blocks);
p.getInventory().setItem(3, blocks);
}```
PlayerRespawnEvent @torn vale
ty
I think the class is wrong
player will be a ServerPlayer
while the cs field is defined on the Player class
I don't recall if you can access parent fields that way
also getDeclaredField
you can get the player from the server player i think
i believe player is the entity (?)
concerning that Player is an abstract class
ServerPlayer has a gameProfile field
it does ๐ค
are you sure the field is defined in the ServerPlayerclass
pretty certain it lives in its parent class
oh no, it is in Player
wouldnt you just do getField
ignore it?
yes
aight
yeah is from mappings
intellij does not know you will run on re reobf server
also your last set call needs permuted args
old game profile is the value not the instance
Yea there is a PlayerAdd packet
ClientboundAddPlayer
and just throw the player in there
get the player connection its public
and send the packet
gou have to do this for everyone on the server and new players i think
the ClientboundRemoveEntitiesPacket should get sent to everyone right?
no
remove entities and add player to everyone but the player in question
if you send a client a remove entities packet with their own entity id, you will have some fun times
i guess i dont want to know what happens
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getUniqueId() != player.getUniqueId())
((CraftPlayer) p).getHandle().connection.send(packet0); // ClientboundRemoveEntitiesPacket
((CraftPlayer) p).getHandle().connection.send(packet1); // ClientboundPlayerInfoPacket REMOVE_PLAYER
((CraftPlayer) p).getHandle().connection.send(packet2); // ClientboundPlayerInfoPacket ADD_PLAYER
if (p.getUniqueId() != player.getUniqueId())
((CraftPlayer) p).getHandle().connection.send(packet3); // ClientboundAddPlayerPacket
}
could work
alright, let's see
last I tried it, I had to do some delay between the packets
how do I do it without suspending the server?
ok
your name seems too long
shouldn't it work with names which are longer than 16?
No
i saw names with over 50 characters on other servers
That's prefix and suffix
also without prefix and suffix
Not possible
^
the name was completely different
minecraft client simply does not handle that
that is resource packs and fonts
but still a prefix and suffix
so how do i do it?
Prefix and suffix
wasn't it limited to a maximum number of teams?
no
A player can only be in one team though. Keep that in mind
^ you basically do a per-player team
if I can dynamically create teams it shouldn't be a problem
you can
just, obviously means you are working with scoreboards
which, plugins like to fuck with
I have the code for this actually. Sadly I'm not home atm
so should I use a random name for team name?
If you want
I don't want to put an ItemStack field inside the ItemBuilder class. but I need itemstack in setTexture method. What do you recommend? should i put ItemStack field inside the class
would random uuid string work?
Yes
Was about to say
oh
good idea
by this way i can even modify it later
You can simply store ItemMeta
how do I put a player in the team?
declaration: package: org.bukkit.scoreboard, interface: Team
java.lang.IllegalArgumentException: Team name '6ab0e034-3296-4654-a6c2-12996dba537b' is already in use
this is a problem now
Don't create it if it already exists
^ pretty straight forward
nice, it works
thanks
I also saw on other servers that players have multiple name lines
How is this possible?
if (logger.getLastDamageCause().getEntity() instanceof Player) {
Player a = (Player) logger.getLastDamageCause().getEntity();
sender.sendMessage("attacker: " + a.getName() + ", combat logger: " + logger);``` why it do that?
no i meant
it just returns the same player
i hit meowcatto
and i did the command
logger.getLastDamageCause().getEntity() doesnt work
for that, there is just getKiller()
oh
or you instanceOf check the event against EntityDamagedByEntityEvent
pick your poison
๐ค well do the event thing
logger = // whatever
if (logger.getLastDamageCause() instanceof EntityDamageByEntityEvent event) {
event.getDamager(); // This is who damaged the player. Do with this what you will
}```
yes i did the same thing
hey so I have a plugin that starts a countdown in actionbar and I am trying to find a way to cancel it using args
there are no errors in my code and the error message when you dont use an arg sneds
but ntohing happens
Paste code
alr
public int PlayClock;
public int i = 25;
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(cmd.getName().equalsIgnoreCase("Pc")) {
Player player1 = (Player) sender;
if(!player1.isOp()) return false;
if(args.length == 0) {
player1.sendMessage(ChatColor.RED + "Incorrect usage. You must use an argument!");
}
else {
String word = args[0];
if(word == "start") {
PlayClock = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
public void run() {
if(i!=-1) {
if(i!=0) {
for (Player players : Bukkit.getOnlinePlayers())
{
players.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "PlayClock: " + (i)));
players.playSound(players.getLocation(), Sound.BLOCK_NOTE_BLOCK_BIT, 1, 0);
}
i--;
}else {
getServer().getScheduler().cancelTask(PlayClock);
for (Player players1 : Bukkit.getOnlinePlayers())
{
players1.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.RED + "PlayClock " + ChatColor.BOLD + "EXPIRED"));
}
i--;
}
}
}
}, 0L, 20L );
i = 25;
}
else if(word == "stop") {
Player player = (Player) sender;
if(!player.isOp()) return false;
else {
getServer().getScheduler().cancelTask(PlayClock);
i = 25;
for (Player players1 : Bukkit.getOnlinePlayers())
{
players1.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.RED + "PlayClock " + ChatColor.BOLD + "CANCELLED"));
players1.playSound(players1.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1);
}
}
}
return false;
}
return false;
}
return false;
}
}
also, try to reformat your code
this is horrible to look at
every modern IDE has an option to automatically do so
strings are also not compared using == but rather with .equals
discord usually messed that up, it's fine in hastebin usually
*if it was fine in the first place
yeaa I doubt this is fine in the first place
ahh ok
could someone help me with 1.18.2 nms?
i have buildtools and everything, im just not sure what to put in the build.gradle
maybe @simple silo can help you ? idk if they ended up using paperweight userdev
but spigot generally does not have gradle tooling
Where can I see how to do an event when an item is added to a players inventory from an NPC/Shop (non-dropped/direct to inv)
might be on close
pretty much depends on the shop plugin
if it is decent, it should have an API to hook into
RedLib has that feature
the server will not publish an event for plugins modifying your inventory through the API
Yes but that is for guis made through redlib
Hmmm ok, I'll have to look into RedLib
is the shop plugin using redlib ?
Maybe just make it yourself o.O
if it isn't, redlib has nothing to do with this
I understood that they have some shop plugin and want to listen to when a player grabs an item from said shop ยฏ_(ใ)_/ยฏ
idk
shouldnt minecraft have a feature for that already?
since crafting tables do that
The crafting table has its own logic to trigger events related to it
Well, I use DTLTraders (which as far as I can tell doesnt have an API/or isnt listed)
might want to ask in their discord
but generally, you are pretty out of luck when other plugins modify state through API
already on that
those usually do not trigger events
is there a way to fake sent a command by a player but the command is send using code serverside?
Bukkit.performCommand(player, command) or something
@EventHandler
private void portalEnter(PlayerPortalEvent event) {
ProtectedRegion cavernPortal = WorldGuard.getInstance().getPlatform().getRegionContainer().get(new BukkitWorld(Bukkit.getWorld("ul_plex"))).getRegion("cavern_portal");
ProtectedRegion lagoonPortal = WorldGuard.getInstance().getPlatform().getRegionContainer().get(new BukkitWorld(Bukkit.getWorld("ul_plex"))).getRegion("fishing_portal");
Location player = event.getPlayer().getLocation();
assert cavernPortal != null;
if (cavernPortal.contains((int) player.getX(), (int) player.getY(), (int) player.getZ())) {
Location loc = new Location(Bukkit.getWorld("ul_plex"), -96.5, 119, -9.5, 180, 0);
event.setCancelled(true);
event.getPlayer().teleport(loc);
event.getPlayer().getWorld().spawnParticle(Particle.PORTAL, loc, 25);
}
}``` why isnt this teleporting me when i step into the portal in the region?
i found it, ty
does anyone know how to make a plugin that would let you map out an area and if a arrow would hit there it would make something happen?
maybe like a message
Are there any good countdown tutorials that aren't outdated? I can't find any great ones
It is all hardcoded has i seen
I'm making a nickname plugin for my bungeecord network that writes to a MySQL database. What would be the best way to fetch from the database without making a million requests each time the player sends a message or should I just do async database requests?
Just cache data only when necessary :)
Just cache once and not more
Or only He changes Nicknames
How would I play the Guardian Effect when you get like mining fatigue to a player? I think this would be done using packets but how exactly would you go about this
p.getWorld.playEffect(p.getLocation)
Like this
Well isn't the effect a packet?
player.playEffect(EntityEffect.GUARDIAN_TARGET);
^
dispatch
bruhh
:Clap:
illusions commissions were an illusion after all

:(
๐
taah go back to your cursed emotes
buy me the $10 nitro so i can boost this server and use them then
no
smh
you don't got commissions?
youtuber manager guy
KDE, MATE, GNOME and CADE
youtuber manager guy
still no idea what you're talking about
anyone here good with packetevents?
me and taah are developers for a youtuber
cade is our middleman
ok, got it
surprised ghast
He's sneezing. We all know they're allergic to humans
man has been sneezing for the past hour
turns out that if you set a ghast's attack ticks to a value very close to the shoot tick, but not quite there
the ghast will just have its mouth open
Wow you monster. Haven't you ever felt that sneeze that will never go away
yeah those suck
I wonder if we can make an audio engine within minecraft
by doing reverb and stupid stuff like that
and sending packets on a rate above 20 ticks per second
why the heck do plugins think it's a good idea to "implement Player" instead of "implement HumanEntity" for NPCs?! Now I have to do weird stuff like this...
public class SentinelHook {
public static boolean isNpc(Player player) {
return player.getClass().getName().contains("NPC");
}
}
a PLAYER is supposed to be a PLAYER, and NOT a NON-PLAYER-character
I mean it's called NON-player-character for a reason
that's still bullshit
a NonPlayerCharacter is not a Player and as such should not implement Player. Especially since that's exactly why the HumanEntity interface exists in the first place
they can implement HumanEntity as much as they want, but a NON player should not be a Player
hence the word NON player character
lol
kids who think npc is an actual word:
one thing i dont get is why most of the inventory related events return a HumanEntity for their getPlayer methods instead of a player
can npcs click in inventories and stuff?
its generally not a good idea to make animated scoreboards create a new scoreboard everytime right?
if i dont make a new one tho, the previous line wouldnt be overwritten causing a headache to look at
https://media.discordapp.net/attachments/555462289851940864/964649700559040614/unknown.png
well in normal MC, CraftPlayer is the only thing that extends HumanEntity
you should just have 1 line where you change its prefix and suffix
so to allow plugins like Citizens to make NPCs behave "like" players, most inventory related stuff allows to use HumanEntity
i mean
well what is an actual word? is "InventoryClickEvent" a word?
other events that citizens npcs can do return a player as well
well if citizens really wants to make plugins think the NPC is actually a player. they should also make the server return their NPC object when doing Bukkit.getPlayer(String) or Bukkit.getPlayer(UUID)
but anyway, Player isn't an interface in the first place that should be implemented, that's explained on the front page of the spigot api docs
plugins should be safe to assume that a player is always a player and that if a player is online, that "Bukkit.getPlayer" also returns the same object while that "player" is online
hey so im trying to get a custom command working but it is saying value of main.getCommand is null even tho i have the plugin.yml setup correctly.
please show your plugin.yml and the full stacktrace you got
commands:
getprefixes:
description: get your prefixes
usage: /<getprefixes>
permission: yourplugin.yourcommandpermission
if I were to make an NPC api, how could I make NPCs reappear when they get out of render and then back in for a player?
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "LilUtilities.Main.getCommand(String)" is null
at LilUtilities.Main.onEnable(Main.java:11) ~[LilUtilities-1.1.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:559) ~[paper-1.18.2.jar:git-Paper-281]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:473) ~[paper-1.18.2.jar:git-Paper-281]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:664) ~[paper-1.18.2.jar:git-Paper-281]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.18.2.jar:git-Paper-281]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:316) ~[paper-1.18.2.jar:git-Paper-281]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-281]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-281]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[00:08:29 INFO]: [LilUtilities] Disabling LilUtilities v1.1```
what's Main line 11?
this.getCommand("getprefixes").setExecutor(new GetPrefixs());
you dont define getprefixes in your plugin.yml
open your plugin .jar file with winrar/similar programs, then see if your plugin.yml ACTUALLY contains that command
they did sent their plugin.yml above and it's included there
its not in there
then there's your problem
ohh shit i just realized plugin.yml is not config.yml xDDD
i know where i went wrong ๐คฃ
anyone?
I don't really get the question. when they're out of "render" distance, they "disappear" automatically, because that's what the render distance is for
the client doesn't "despawn" it, it simply stops rendering it. the NPC should be still visible if you come back
but then when the player gets close again the npc is meant to reappear
i'm asking how should I detect that
you actually don't have to worry about this at all. once you send a "my NPC is at 0|64|0" packet, and a player walks a thousand blocks, then comes back to 0|64|0, they'll still see the NPC
the client will remember that the NPC is at that place unless you tell it otherwise
ohh so it doesn't work like on other servers
so the client keeps track of every player's position?
even if they are not rendered
I am not sure how it works with "official REAL players", but I am 99% sure that when I spawn NPCs, I simply send a "Player joined packet" or however it's called ONCE to all online players, and once again to every player who joins later, and that it always worked
for "real" players, the server will probably stop updating the position to far-away players, but you don't have to worry about that for your custom players, since you have to manually send packets for them anyway when they move
does enchantment value start at 0 -> 1 or 1 -> 1
just tell every player once "npc mfnalex is at 0|64|0 in world_nether now" and that should be enough
meta.addEnchant(e , 2, true) - give 2 or 3
aight thanks
1 should be 1 IIRC
what if I wanted to do something similar with other entities tho?
alr thanks
should work the same. let me check my hologram api
i remember i did something with armorstands but when i got far and back to where the stand was supposed to be it was gone
okay for holograms I actually have a runnable, I am not sure whether it's needed or whether I only have that for custom "visiblity radius"

