#help-development
1 messages · Page 741 of 1
plugin doesnt crash when starting i can still use other commands
Then show us your onEnable
dafuq
i removed the json import why does this still happen
instead of what you have remvoe the the throws ParseException and add ```java
try {
// line that calls #parse
} catch (ParseException ex) {
ex.printStackTrace();
}
i did it like this:
Date endMuteDate = null;
try {
endMuteDate = getDateTimeFormat().parse(DataConfiguration.INSTANCE.getData().getString(DATA + p.getUniqueId().toString()));
} catch (ParseException e) {
p.sendMessage("Error: DEBUG 31");
}
but i needed to add the endMuteDate = null; cause i need it in another function too
And pls start there before you add try catch blocks anywhere.
There is a fundamental problem with your listener that needs to be solved first.
ok so the throws ... is gone now
its only this: java @EventHandler public void onSpeak(AsyncPlayerChatEvent e) { e.getPlayer().sendMessage("Test works"); if(!MuteUtils.muteCheck(e.getPlayer())) { e.getPlayer().sendMessage("is false"); } if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return; if(MuteUtils.muteCheck(e.getPlayer())) { e.setCancelled(true); } }
Send the whole class and send us your onEnable pls.
?paste
Now the PlayerListener pls
That should not clash with your listener not being called
PlayerListener: https://paste.md-5.net/uqosuhimos.java
Anyone know why Player.getEyeLocation would return a different value every other tick while the player is in a vehicle? It's as if it doesn't acknowledge the player is in a vehicle
Do you get an exception when writing in chat?
If you dont get the message "Test works" then its throwing an exception.
Otherwise the information you gave us is faulty.
dont use plugmanx, and the command isnt in pugin.yml
takes 5 minutes
Throw this plugin right in the trash.
Never use plugman and never use the /reload command.
but it is
Very unfortunate
Now restart
The longer you don't restart, the longer it'll take you to do so
ok did it
this is my plugin.yml
commands:
ban:
description: Bans player
unban:
description: Unbans player
kick:
description: Kicks a player
mute:
description: Mutes a player
unmute:
description: Unmutes a player
warn:
description: Warns a player
unwarn:
description: Unwarns a player
i havent created warn and unwarn yet as a file, is that a problem?
What is the delta?
Where is "tempmute"
I don‘t quite understand how I get the data from a block using the CustomBlockData-API, can u tell me how, 7smile7?
PersistentDataContainer customBlockData = new CustomBlockData(block, plugin);
You create a new CustomBlockData for a block
Alright, then start the server, make sure you dont get any exceptions while starting, use the /pl command to check
if your plugin loaded correctly and write something in chat.
another plugin has sent exeptions so an error but not mine, still neither an exeption nor a Test works message, /pl shows green
That is hard to believe.
Add another EventHandler method in the listener for the BlockBreakEvent and check if it fires.
Actually after restarting the server it seems to have fixed the difference in the position, no idea why. It was ~1 on the Y axis in an empty boat + whatever the boat direction with a mob inside it. Though it now returns the eye position a bit higher than what it actually is while inside of a boat, about the height of the boat's hitbox
While riding on horses and camels the location is correct
added this
@EventHandler
public void onTest(BlockBreakEvent e) {
e.getPlayer().sendMessage("Test works");
}
still waiting for restart
i dunno what the server is doing, its restarting again
YES
it fires when breaking a block
But not when writing something in chat?
Well, did you mute the player?
wait a second
its firing 2 times but we can fix that
the message gets blocked tho
bon appetit
Need a ladder?
Does somebody know how I can get just the Player's message from the textcomponent?
I believe spigot has just AsyncPlayerChatEvent#getMessage no?
do you know how i get the message from the component?
yes
how do I spawn a silverfish and make it not attack a certain player
https://jd.papermc.io/paper/1.20/io/papermc/paper/event/player/AbstractChatEvent.html#message() @inner mulch
declaration: package: io.papermc.paper.event.player, class: AbstractChatEvent
isnt that what u're after
hello, I'm trying to make scoreboard teams with prefix and colour and currently using this code: ```java
public void register(Scoreboard board) {
this.team = board.registerNewTeam(this.name);
team.setPrefix(this.icon);
team.setColor(this.colour);
team.setDisplayName(this.displayName);
}
public void addPlayer(Player player) {
players.add(new TeamPlayer(this, player));
team.addPlayer(player);
player.sendMessage("mci team players:");
for(TeamPlayer p : this.players) {
player.sendMessage(p.getPlayer().getName());
}
player.sendMessage("scoreboard team players:");
for(OfflinePlayer p : team.getPlayers()) {
player.sendMessage(p.getName());
}
}```
scoreboard team players are me, but when I run /team list <name> theres nobody in there, also prefix and colour are not working. what am i doing wrong?
whats the difference between an abstractchatevent and an asynch one?
abstract one is just the shared one which both ChatEvent and AsyncChatEvent extend
there is still no #getMessage in both of them
the method is message() just
but if i send a player his own message it ends up looking not like his message
ofc
before the message is sent it goes through the ChatRenderer
thats how the paper api works for chat events
I'm currently creating a chatfilter and I want to send the player the offensive word found, as well as the whole text, so that if something get filters wrongly they got proof and can report it
wait u wna send the offensive words back to the player who sent them?
yeah i alr got this one figured out, but i want to send the full text too.
like this for example
found chat abuse: "😡"
your message: bla bla 😡
and do you still want the message to go through?
like should it still be sent for other players to see?
no i alr cancelled it
but i dont know how to translate them
if i send the #message component, it sends more than the acutal message
yeah
well
Id suggest using minimessage
and then you append or whatever the result of ChatRenderer::render
is there no way of getting only the content of the component?
the text?
yes
ig thats one way, Id just use the serializer
PlainTextComponentSerializer.plainText().serialize(component)
ok
.html
lynxplay
woops :>
lynxplay, you are developing paper, right?

yeah lynx in the dev team lol
lmao
and run
:,)
lynxplay why did you do this man :( please add a event#getMessage that returns the string of the text, that a player sent in the chatevent
WHY COMPONENTS
:(
like, litearlly just throw it full power at plain text component serialiser
and you are good
ok
you know, it just happens to be the case most text in minecraft is more than just a sequence of characters, for instance being able to click on text, hover over text, color text, style text and so on, for this to be possible and to work well in code using mere strings isn't a great idea, hope you have a splendid day
thank you
Is reflection needed on values that are public?
public fields?
Ye
ugh I mean no, you could just access it without
That's what I thought.
Wonder what I'm doing wrong then. :/
whats going on?
Trying to figure out why advancement toasts don't show up anymore in 1.20.2
The advancement map has apparently been converted to an ImmutableMap, so I set it to a normal hashmap and custom advancements that are loaded through bukkit don't want to show the toast.
ahh
hmm
the only thing I may think of is if something is caching the map before u're able to mutate the reference
The other thing with this is that if I set the chat message value to true, it will show. Even with both values (chat and toast) set to true, only the chat message shows.
Do any of you know how I fix this? 😣 https://prnt.sc/l-Uuof0ePr1t
I reckon you should restart your game
Not working xd
Try logging out of the launcher and logging back in
Already tried too
Make sure you're using the official launcher
I can enter any server except my BungeeCord server
ill have to check that out
havent look too much at 1.20.2
Could it be the #apply() method?
There's another mutation.
yeah
maybe, or perhaps you're passing an invalid json
idk
wait lme check changelog
This is the json I'm passing in. Verbatim.
https://paste.md-5.net/xekivamozu.json
AFAIK, that's the proper structure for advancements.
why are the booleans written as strings :thonk:
Would that be screwing it up?
Really stupid question, but is it possible to link both a Java and Bedrock server under the same ip?
Hub that goes to a Java server, and one that goes to a bedrock server (for world generation)
Idk if that makes any sense
in theory that is possible
Bedrock and Java does use different ports
as for the second part I don't quite understand what you mean
i assume they mean some sort of proxy server and then one server is java and one server is bedrock
I have a bedrock world and a Java world that I want to have under the same ip (3rd party host). I converted the world from bedrock the Java and the generation got all screwed. If I kept it on bedrock and added geyser it would fix that problem
The Java world is modified with custom plugins, but is separate from the bedrock world
Is there an easy way to check if the server version is above or below a specific version? eg. check if the server version is newer than 1.19 for example
there are so many utils for that
such as?
Server#getBukkitVersion()
or Server#getVersion()
format it a bit and check if higher/lower than your desired value
Or you can just use this lib and do stuff like
yes
Version.isVersion(1, 19, 2)
also get minor and patch versions
Yeahh this is what I am currently doing but didn't really want to make a list of the older versions even though it would work equally fine
plugin.reloadConfig()
doesn't work .-.
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
it works like always with no bugs
give me a second to send the code .-.
Why is the library screaming
#reloadConfig() pulls in changes from disk. Unless you saved your changes, it won't reload with the values you are expecting.
plugin.reloadConfig();
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&f&l[TheLogger] &aConfig reloaded! &fPlugin by Mjicio_"));
}```
I would like that when someone modifies the config, using the /test reload command the config is reloaded and the changes are seen without restarting the jar or the server
and what happens after your command runs?
nothing, the plugin send me the message without console error
are you editing your config with notepad++
but the config changes doesn't work in the game
no
which changes
show some code where your config is used
the changes I make on the config, for example change a message
I'm trying the plugin on a vps
anyways you might forgor to Ctrl + S
nop
How are you changing it though?
show some code bro
maybe you preload the stuff in onEnable() or on class inst
Ok
and that's why nothing happens after reloadConfig()
Again ^
MAIN
@Override
public void onEnable() {
// Plugin startup logic
System.out.println(ChatColor.BOLD + "[TheLogger]" + ChatColor.GREEN + ChatColor.BOLD + "Enable!");
//There is commands and events register
this.saveDefaultConfig();
config = this.getConfig();
}```
COMMANDS CLASS
```} else if (args[0].equals("reload")) {
plugin.reloadConfig();
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&f&l[TheLogger] &aConfig reloaded! &fPlugin by Mjicio_"));
}```
using hands
yes
why
Where are you changing the message though?
just why
why what?
from mobaXterm editor
- where is the code with getting something from config
config.get...()
- Why are you saving config to variable
there are 999 ways to access it anyways
can you show an example please
yesser
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("prefix") + ChatColor.translateAlternateColorCodes('&', config.getString("xrayOn"))));
and when you change the message and reload config
this code still shows old message
right?
well ig your config stores old FileConfiguration
If you're modifying the file on the disk manually, then you should see that reflected in your server as long as you actually saved the file.
no
Idk why
get rid of public static FileConfiguration config;
and config = this.getConfig();
yup
k but
Know how the other classes take the String : config?
I have to replace all config.getString with plugin.getConfig().getString()?
Shouldn't be that big a deal if you are using DI.
well then you need to add your own reload method
it was just a question of whether I should do this
which will do config = getConfig() again
You're going to have to if you remove the static variables.
Can I made something in main class like public config = plugin.getConfig()?
the issue is the FileConfiguration being public static
So, I have to replace all config.getString() with plugin.getConfig().getString()?
yes
what would be the best way to find out the color of a specific char in a string aka what color code is applied to it
shadow did u solve it?
Negative
kinda hard
I want to die :D
if you take colored string it would have different length cuz it will have a lot of §x shit
i know
you want to learn java
I thought there was a method in ChatColor to get the color?
i hate discord
same
the superior chatcolor
the chatcolorest chatcolor
i have a message where i highlight playernames and i want the part after the playername to keep going with the color before the name
split the name, get the color pre name, color name, set color after name
oh yh let me just write down all 1000 trillion possible combinations for messages
i mean it's your plugin no
pretext name aftertext »
split »
split space
and?
yh i got it thx
you are to lazy to add two symbols after name?
ig second
look
lets ay
say
a player times
Hey "playername" lets get some wood
i want to highlight the playername there
even
im pretty sure you can do that with components cant you?
Huh, bungee chat color does not have the #getLastColors() method for some reason.
whats that supposed to do
&aHey §b%playername% §alets get some wood. what's the prob
This is bukkit ChatColor
you want to do that for every single chance of that?
are you really really slow?
chance of what
getLastColors would fail so hard tho
chance not change
hex colors are not easy
there could be trillions of cobinations of words to format
they are though?
@fluid river IT WORKS
i love u
raided-countdown-bar-name: '&dВас скоро зарейдит город &e%town%&d.'
raider-countdown-bar-name: '&dСкоро вы начнёте рейд на &e%town%&d.'
raid-raided-bar-name: '&dВас рейдят.'
raid-raider-bar-name: '&dВы проводите рейд.'```
literally what i have
any prob with that?
what does get lastchatcolors return? just the colorcode as a string?
there you go nuker
took you long enough
That's what he meant
xd
have a message where i highlight playernames and i want the part after the playername to keep going with the color before the name
i thought it's message from his plugin
not from user input
anyone have a clue?
like it's just a word, no?
split at the char between prefix, name and suffix, split at space, get center word, color it, get color of 1st word, set color of 3rd word
if prefix is 2 words
i need to know what getchatcolor returns xd
cry
yeah that's what i mean
well welll
welllll
each time players sends a message
get all player names on the server
loop to find any of them in the string
erase it
copy the color
paste it again
What tests have you tried?
I tried using Bukkit#getUnsafe() and it throws the Immutable Map error.
I tried setting the map to a new hashmap and then using bukkit unsafe, but I crash when using viaversion.
I've changed the advancement format a couple times and manually added the values that should be auto filled.
I was originally trying to just update my nms packet, but it wanted something that isn't needed for the minecraft:impossible trigger.
I'm just stuck at this point.
this is not my problem i know how to solve that.... i just want to know what type of string get chatcolor returns man
thats all i wanna knw
no clue
the same advancement works pre 1.20.2?
I have a different system for pre 1.20.2. I was originally sending nms packets which were consistent up until this version.
Have you checked how its done in CraftMagicNumbers#loadAdvancement
In the older version or the 1.20.2 version?
1.20.2
I think I did, but let me double check real quick. I'm pretty sure it's the same impl as 1.20.1, hence the immutable map error.
Yea, the only difference I see is the null check being done first in 1.20.1, vs 1.20.2.
Same methods are used to add advancements.
I mean paper seem to be doing this as well
MinecraftServer.getServer().getPlayerList().getPlayers().forEach(player -> {
player.getAdvancements().reload(MinecraftServer.getServer().getAdvancements());
player.getAdvancements().flushDirty(player);
});
idk how necessary that is
Well, I think there is some difference as now there's the introduction of AdvancementHolders and that changed the format from a list to a map. Not sure why it needs to be immutable though.
Where is this called though?
CraftMagicNumbers#loadAdvancement
AdvancementHolder seems to just be an entry for namespace and an advancement
also when do you inject the map?
https://paste.md-5.net/ajiqagunal.cs
I inject the map right before I add the advancement.
in onEnable?
It's done every time a command is run. Probably should move it to onEnable though.
yeah try to move the injection to onEnable first and foremost
Uhh, let me get back to you on this. Gotta run an errand and I have to figure out how to make it run with my multi module project.
yeah sure take ur time ^^
Can you change someone's playerData while the player is in the game? like to replace their playerdata in the world folder, with something else. I want to make a profiles aspect, and I need to know if I have to kick the player to change their save, or if I can just do it there.
Player#saveData and loadData is a thing :)
Ohhh.. I was thinking I'd have to do this all my self 😅
Alrighty, welp thank you.
wdym
you are doing so many completely differents projects
assembley, webdev, spigot/java dev
well noone is gonna remake your site for free xD
this site from 2018 year
i'm not joking
ue4 game dev too
game dev not mine, i got this
hey, I've got some problems with my config and I can't get it to work.. Can anyone help me with that?
what kinda problems
So basically I am making a plugin that uses the spigot config and as soon as someone joins his name should be saved i the config.
public class JoinListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (!LaserTag.instance.config.contains("Coin." + player.getName())) {
LaserTag.instance.config.addDefault("Coin." + player.getName(), 0);
LaserTag.instance.saveConfig();
LaserTag.instance.reloadConfig();
}
}
}
how long does the spigot api take to update?
5
5 minutes?
no no just 5
5 breakdowns lol
anywhere between 0 and 100,000,000
eggs? whiteboards? discord actually adding good features?
uncertainty must be covered by an ambiguous range of numbers
its either 30 min to like a few hours
if you are uncertain about an answer you are bound to be more likely to give the correct one if you provide a large range
spiget is probably at the same limit
makes sense
for creatures, how can i make them not target one spesific player? id use the event system but i cant use it with what im doing
this is how im spawning them
Silverfish silverfish = (Silverfish) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.SILVERFISH);```
I have the feeling I've seen you somewhere
dbh
oh
Please reuse variables 🙏
Player player = event.getPlayer();
Location playerLocation = player.getLocation();
World world = playerLocation.getWorld();
world.spawnEntity(playerLocation, EntityType.SILVERFISH);
Well two of those are seriously unnecessary lol
i was just testing rn i was gonna make it look better after lol
@ivory sleet Same issue when moving the injection to the #onEnable() method.
hello again, maybe anyone new can help now. I am trying to set a command's permission message. The issue is that it will just give me "unknown or incomplete command" even though I registered the message via API, so Command#setPermissionMessage
who can help me? ```java
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("login") && sender instanceof Player) {
Player player = (Player) sender;
if (args.length == 1) {
String password = args[0];
if (password.equals("testpassword")) {
player.sendMessage("Auth successfully!");
player.setWalkSpeed(0.2f);
}
else {
player.sendMessage("Not your password!");
}
}
else {
player.sendMessage("Use: /login <password>");
}
}
return true;
}``` my code. i need make it working with jdbc, who can help with this and register command
??
i setting walkspeed, because i used: event.getPlayer().setWalkSpeed(0);
Are you expecting someone to make whole system for you or?
This is not really a question which can be answered
bruh, i know how to work with this, idk about SQL
Time to learn
I don't know what I should use to look up the password in the database
Sql query
ok, guys, let me try. If I succeed I'll show the code
i think, i need new class for database code
my friend says it's good, because my main file will be clean
youll want a class for a lot of things
what about security? maybe i need pack passwords?
ideally you hash them
i mean hash, sorry, my english too bad, i'm ukrainian
and why it's not working? @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { event.getPlayer().setWalkSpeed(0); event.getPlayer().sendMessage("Enter password: /login <password>"); }
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
ok.. i found my error
Why not use an existing login plugin
Have you registered for the listening event?
i forgot about getServer().getPluginManager().registerEvents(this, this); in onEnable
sorry guys
listeners should have their own class
it's bad code? ```java
public static String readPassword(String playerName) throws SQLException {
String playerPassword = "";
String query = "SELECT password FROM users WHERE name = ?";
try (PreparedStatement statement = conn.prepareStatement(query)) {
statement.setString(1, playerName);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
playerPassword = resultSet.getString("password");
}
}
catch (SQLException e) {
throw new RuntimeException(e);
}
return playerPassword;
}```
I pretty please hope that password is hashed
depends
in most cases no
now not hashed, because it's test version
tomorrow i want make it hashed
you should be running all io async
and to make it easier for yourself use completable futures
plugin.getCommand(name).setPermissionMessage(permissionMessage);
how to check if value exists in db?
statmt = conn.prepareStatement("select val1 from table1 where name = ?")
```?
execute query and check result set
Show us where you registered the command
how i can return error if value doesn't exists?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
else the result set check and there you go
the command works whenever I give myself the permission lol
String query = "SELECT password FROM users WHERE name = ?";
try (PreparedStatement statement = conn.prepareStatement(query)) {
statement.setString(1, playerName);
ResultSet resultSet = statement.executeQuery();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}```?
Exceptions are a wonderful thing. They can let your code recover from unexpected situations in a nice and clean way, if you use them properly. That does not mean that you should always rely on them though. For example, imagine this: Most highways have guardrails in the middle to avoid cars going into oncoming traffic....
any reason why those methods are static ?
according to this code connection is also static
I don't get it man. Why won't it just display the toast?
this is pretty much static abuse
you should have a instanced class that handles sql stuff
am I stupid or is the jar file just missing? https://github.com/deanveloper/SkullCreator
or should I self-compile?
jreefav
Can a dropped item have a velocity, ex to cleanly move across the ground
well you can use blockdisplay in never versions
what about pre 1.19.4
well i made some shit with dropped tnts
which rotated around the player
like magic orbs
so ig yeah drops can have velocity
Im tryna make a conveyer belt for items (not pickable) and tryna figure out how to make it look clean to the user
well you can try teleporting them each tick for sure
don't remember if you can actually apply velocity
I feel like that would not look clean
^
how does the attack speed attribute work? it seems like any value i put in its just super fast.
try using .0 values
i tried 0.0008 and its still fast
0.008
ive tried whole integers and its fast, like anything i put it registeres it as like half a second
Hell nah. Blud should use jitpack for this.
What is the path I should enter in my plugin for creating a File object and the file itself is in the resources folder
JavaPlugin#getDataFolder
It doesnt seem to get the resource folder but the folder in plugins
the resource folder doesnt exist as a folder, you would have to get the jarfile, use JavaPlugin#saveResource
you can;t access resources in your jar with a file object. Do ^
I am using getResource right now but I need to load nbt file
Yeah isn't that the right way? Use getResource and then loadStructure() from StructureManager?
are you getting a zip/zlib error?
It seems to work well now that Im using getresource
does JavaPlugin.getConfig() do Disk IO everytime it is run?
I am guessing it does not cache anything, it just goes to the disk to fetch info every single time?
no
How can I change how a variable is defined under different circumstances?
example:
int num = 1 + 1;
if(math = false) {
num = 2 + 1
}
print(num);```
console : (what i want to see)
3
I've tried it like this but it doesnt seem to work
or is the config file loaded on startup then cached?
its loaded on first access
ok, i was reviewing someone's code, thought they were accessing the disk everytime a listener ran.
its been a while since I have worked with the Bukkit API.
? what
i want to change a variable under circumstances
if the player has something then the variable isnt the default value it is something else
Is there anyway to bypass the distance requirement to open and edit a sign?
what are the prerequisites for modding in minecraft? I know java, the basic stuff and pretty much can do most things in java, but modding in minecraft is different, it has no official documentation so you really need to know everything. What are ALL the prerequisites for doing this properly?
I just got this project that needs working outside of what the Bukkit ecosystem provides.
thanks for the response, this is an example, not the actual thing, its just to showcase what i mean by my question
having trouble with grief defender if anyone has some insight haha any helps appreciated
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
i have a value, if something is true the value changes, but for some reason it doesnt in my case
ok
errors = new Errors();
if(command.getName().equalsIgnoreCase("r")) {
if(previousConvPartner.get(player) != null) {
targetPlayer = previousConvPartner.get(player);
} else {
player.sendMessage(errors.noChatPartner());
}
}
if(targetPlayer == null) {
player.sendMessage(errors.nullTarget());
return false;
}```
This here is causing trouble, I made sure that there is something in the hashmap "previousConvPartner".
thanks for the advice, but doesnt the hashmap get cleared once the player leaves either way?
the value is still in the hashmap
but not assigned to anyone
the class is implementing a /msg and /r is used to reply
wait
why listener?
How can I delete a world or make sure everytime a world is created the new world replaces a folder with the same name?
Should I unload and delete the folder?
ok, im using only a commandexecutor, no anything else
this was about the use of hashmaps
the problem in the command is, that targetplayer remains null even tho there is a player assigned to the other player via hashmap
when i use /r
i dont have any test players :( im doing it with my own acc only me, and i do stay on the server.
i think i got the problem, one second
okay so the line
if(command.getName().equalsIgnoreCase("r")) {```
doesnt activate when i use the alias /r
getName will return the registered command
im pretty sure its the 3rd param for alias
yes
ok
no
i registered the alias
it wasnt capital
thank you guys, looking for the aliases resolved the issue
can u explain why it would be better, if the hashmap clears after restart? (im just curios)
int num = math ? 1 + 1 : 2 + 1
wow
also you cause memory leaks holding old/expires players
i was really scrolled up
doesnt it stay with a uuid too? or is it only with players
oh
yeah
i will change it
uuid is forever, player is temporary
Did you ever find a solution for this? Looking to solve a similar issue.
(pls ping if you respond)
Trying to make a regex here how would I match any non digit besides /
I know to match any non digit you do [\D] but thats as far as I've gotten lol
ah! figured it out
[^\d\/]
am i the only one who struggles to work with build tools?
is there a good guide on how to use build tools properly?
what did you all use to learn using build tools?
i was using maven, it uses xml which I actually understand but was kind of confusing to work with if you dont know what some the xml tags are for.
then gradle uses a format called groovy or whatever that I am not familiar with and is even more confusing, could have used json, xml or yaml.
Never used buildtools in my life
Just use maven its the most easy
And Minecraft Development Plugin in IntelliJ IDEA
that is what i have been doing but now I gotta work with other people's projects and I need to know if i am missing dependencies or if the config files are not correct.
this groovy format only makes it worse for me right now.
i could at least read xml and know the structure of things.
Are you talking about using BuildTools to get NMS?
If so
?nms
no just build tools in general.
If you're struggling to use BuildTools in general, #1117702470139904020
If you have any questions about the GUI, either ask in that thread or just ping me.
Iris is a custom world generator. I want to use some of the trees from the plugin and export them as a schem. However the files in the generator are like tree.iob anybody know how custom generators work. is there anyway I can rip the object from the source as a schematic.
They are asking about build tools like maven or gradle - not BT in specific (what the hell do you mean with BT in general? BT is extremely specific)
Lots of people struggle with running it in general. Whether it be with the command line or directory issues or incorrect Java versions. Thought that was what he was referring to. :p
Hello I made a plugin in eclipse but how can i make lang foolder for plugin? The plugin it does not load the lang foolder and en.yml
How can i fix this?
Is it possible to create a location-bound BlockState without using NMS?
So I've tried around a bit but I don't quite get how I convert a PersistentDataContainer of an item in my main hand to CustomBlockData. I tried casting but that's not the way ig (am i missing a documentation or something?)
Iris is a custom world generator. I want to use some of the trees from the plugin and export them as a schem. However the files in the generator are like tree.iob anybody know how custom generators work. is there anyway I can rip the object from the source as a schematic.
Cant you just generate a world with Iris and use we or schematica ( the version that starts with l , i dont remember the name) to save it as a schematic
The leaves of the tree is merged with other tree around it.
For what I am doing it would be much more convenient to convert the iob file to a schem
Then you need to see the structure of the iob file and the schematic file, create a iob file to schem file converter.
I have know way of opening the iob files because it is unique to iris
What is an IOB file? Learn about the file formats using this extension and how to open IOB files. Download an IOB opener. At file.org we know files.
ping me plz if u have an answer :)
@EventHandler
public void onUseKeyOnDoor(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block block = event.getClickedBlock();
if (block.getType() != Material.IRON_DOOR) return;
BlockState state = block.getState();
Openable ironDoor = (Openable) state.getData();
ironDoor.setOpen(!ironDoor.isOpen());
state.setData((MaterialData) ironDoor);
state.update();
}
Upon clicking the upper part of the door the door breaks and drops twice and when clicking the lower part of the door, it works as intended, why does that happen?
oh- i think i just under stood that.
I create a new instance of CustomBlockData with the placed block and then add what I need. then I copy it to the block again.
now only this is a problem and i can't wrap my head around that
maybe you need to cancel the player interact event?
Is there an Enum that consists of all weapons or tools? And enum that consist of all armor pieces? I want to compare them to ItemStack
hmm, i don't think so. i feel like that has to do with the CustomBlockData API since the position of the door is the bottom part and the API saves the data in the chunk with the position as key or something
gradle supports more than just groovy
you can use Kotlin Script
and for dependency declaration use libs.versions.toml
right... and the breaking when using the code i sent is because the upper part can't be opened and it breaks (i guess), then each block drops into the respective item
that's why two drop...
but how to fix that with the CustomBlockData, no idea... maybe alex or smile can help me later or sum
declaration: package: org.bukkit.block.data.type, interface: Door
i.e. get the bottom part of the door and open it
hello everyone i am trying to put my serialized itemstack (as byte array) into a blob inside my SQLite database, upon retrieving tho i get a data mismatch error
@Override
public CompletableFuture<Collection<DatabaseItem>> readAll() {
String sql = "SELECT * FROM registered_items";
return database.asyncQuery(sql)
.thenApply(resultSet -> {
List<DatabaseItem> registeredItems = Lists.newArrayList();
try (resultSet) {
while (resultSet.next()) {
String name = resultSet.getString("name");
byte[] itemData = resultSet.getBytes("serialized_item");
System.out.printf("Name: %s, item data: %s\n", name, itemData);
if (itemData == null || itemData.length == 0) continue;
// String className = itemClass.getClass().getName();
// String classSimpleName = itemClass.getClass().getSimpleName();
//
// System.out.printf("Class name: %s, class simple name: %s\n", className, classSimpleName);
registeredItems.add(new DatabaseItem(name, itemData));
Bukkit.getLogger().info("[HydraStorage] Loaded item: [" + name + "]");
}
} catch (Exception exception) {
exception.printStackTrace();
}
return registeredItems;
});
}
i also tried getting the class name and it has indeed returned me byte[] but upon getting the column it drops an error
You might wanna base64 the array
Show the exception pls, and which lin it throws
Was about to suggest that. Thats the standard approach.
Ye
But i wasnt quite sure if this was only done because nbt looks like json/yml and messes with file structures
hello
Sounds like a question for #help-server
okayy
jree fava
sure sorry gimme a sec
btw the error is at the getBytes
id just base64 the itemstack then
I mean, what do you store in that table
what is the table definition
varchar!=blob
can you share the SQL to create the table 👍
Oh
sure
CREATE TABLE IF NOT EXISTS registered_items (name VARCHAR(64), serialized_item BLOB)
How does the insert query look like?
lemme get that for you real quick
INSERT INTO registered_items (name, serialized_item) VALUES (?, ?) ON CONFLICT (name) DO UPDATE SET serialized_item = ?
why that?
you might have to go over the #getBlob method on the result
that'll give me a classcastexception
lul

i also tried getting the class name and it has indeed returned me byte[] but upon getting the column it drops an error
How do you prepare the statement?
default void update(String sql, Object... objects) {
try (Connection connection = getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
for (int i = 1; i <= objects.length; i++) {
preparedStatement.setObject(i, objects[i - 1]);
}
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
Ive never used setObject like that. Are you sure it can properly infer a byte[]?
Might interpret it as a varchar.
when reading the value i tried just getting an object and its name
and it has returned me a byte[]
so that is the datatype
else it would have returned me something different
idk what prevents you from using getBlob honestly
a ClassCastException
how ?
idk it just explodes
what exception
ClassCast
Like you obviously cannot cast it to a byte array
sure but i should query it no problem then
Well that depends a lot on the driver you are using
and their implementation of ResultSet
SQLite
yea but you are using a cached result set
should i use a ResultSet instead?
String name = resultSet.getString("name");
Bukkit.getLogger().info("[HydraStorage] Loading item: [" + name + "]");
Blob blob = resultSet.getBlob("serialized_item");
if (blob == null) continue;
byte[] itemData = blob.getBytes(1, (int) blob.length());
registeredItems.add(new DatabaseItem(name, itemData));
Bukkit.getLogger().info("[HydraStorage] Loaded item: [" + name + "]");
ill try this approach
nice indentation by discord
or just getInputStream and #readAllBytes
most driver implementations of ResultSet would be fine with just calling getBytes for a blob
but the cached result set might very well not be
getBytes should work on the ResultSet...
Unless setObject explicitly added a Blob
i just moved to a result set
ah
instead of a cached one
Then you should be fine yea
I would have 100% just made scrambled eggs with base64 and thrown it into a varchar at that point
/**
* Indicates whether the given SQL data type is a binary type.
*
* @param type one of the constants from <code>java.sql.Types</code>
* @return <code>true</code> if the given type is <code>BINARY</code>,'
* <code>VARBINARY</code>, or <code>LONGVARBINARY</code>;
* <code>false</code> otherwise
*/
private boolean isBinary(int type) {
switch (type) {
case java.sql.Types.BINARY:
case java.sql.Types.VARBINARY:
case java.sql.Types.LONGVARBINARY:
return true;
default:
return false;
}
}
btw
is the implementation on the caached result set
which, well, does not include BLOB
VARBINARY is same as blob in sqlite afaik
i read it on documentation somewhere
now it just doesn't execute like the method is not getting called, some exception may be laying around
Sounds like CompletableFuture fun
yes
apparently resultset is empty
@Override
public CompletableFuture<Collection<DatabaseItem>> readAll() {
String sql = "SELECT * FROM registered_items";
return database.asyncQuery(sql)
.thenApply(resultSet -> {
Bukkit.getLogger().severe("[HydraStorage] Loading all items from database");
List<DatabaseItem> registeredItems = Lists.newArrayList();
try (resultSet) {
Bukkit.getLogger().severe("[HydraStorage] Trying resultset");
while (resultSet.next()) {
Bukkit.getLogger().severe("[HydraStorage] Resultset next");
String name = resultSet.getString("name");
Bukkit.getLogger().info("[HydraStorage] Loading item: [" + name + "]");
Blob blob = resultSet.getBlob("serialized_item");
if (blob == null) continue;
byte[] itemData = blob.getBytes(1, (int) blob.length());
registeredItems.add(new DatabaseItem(name, itemData));
Bukkit.getLogger().info("[HydraStorage] Loaded item: [" + name + "]");
}
} catch (Exception exception) {
Bukkit.getLogger().severe("[HydraStorage] Exception");
exception.printStackTrace();
}
Bukkit.getLogger().severe("[HydraStorage] Loaded all items from database");
return registeredItems;
});
}
No data = No problem 👍
Im wondering if there is maybe an EOF char in there messing with the entry
it whould have gone into the while loop at least once
but it hasn't
the ResultSet#next method has returned false
I hope you clear the DB and write a new item in there every time you change your serialization code
I meant that you should not try to retrieve old items when your DB code changes.
But if you use a new item on each startup then its fine.
oh nono i just deleted the database file, let the plugin create a new one and register some items, restart and then see if error pops up
I would stay with getBytes. Could you print out the SQL type after adding your objects to the PS?
you mean on the insert?
-> PreparedStatement#getParameterMetaData()
-> ParameterMetaData#getParameterTypeName(int param)
yes
does the param start from 0 in this case
or from one
I would assume 1 bc SQL is just extra like that
Hello, does someone knows if when cancelling a task, the task object is still usable?
yes it is
Sure, if you hold a reference to the task.
Ok perfect thanks 🙂
fuuuuuuuuuuuuuuuuuuuuu
why is intellij saying cannot resolve symbol pr and its in the location of the keyword "private"
apparently i need to specify types now, welcome to the good ol' Pair
Try to reload your project, sometimes it gets crazy
Restart your IDE
what the frick
String sql = "INSERT INTO registered_items (name, serialized_item) VALUES (?, ?) ON CONFLICT (name) DO UPDATE SET serialized_item = ?";
database.asyncUpdate(
sql,
Pair.of(key, Types.VARCHAR),
Pair.of(value.serializeAsBytes(), Types.BLOB),
Pair.of(value.serializeAsBytes(), Types.BLOB)
);
imma go get some beer wait
public void staticSpawnMethod(Location location, Player spawner){
LivingEntity entity = (LivingEntity) location.getWorld().spawnEntity(location, this.entityType);
entity.setCustomName(name);
entity.setCustomNameVisible(true);
stats.setEntityStats(entity);
customSpawnFeatures(entity, spawner);
}```
is this scalable enough for spawning custom entities? what can i change
You could rename it. Otherwise this is probably fine.
If you want to make it more modular, then you should make your surrounding class abstract
and allow additional functionality on spawn.
And making the class generic would also bring quite a few benefits
yes the class is abstract
me.
skinnyooonie.
characterwar.
character.
impls.
GuyOneCharacter.java
GuyTwoCharacter.java
Character.java(interface)
CharacterManager.java
config.
ServerConfig.java
ConfigManager.java
listeners.
ConnectionListener.java
CharacterWarPlugin.java
What do you guys think of this project structure so far? A Character here is basically a character, with its implementation; abilities, perks, etc
public void setObject(int p, Object v, int t) throws SQLException {
setObject(p, v);
}
the sqlite driver does not give a single shit about the passed type 
XDD
Its fine. With such a small project you cant really do much wrong. But the abstraction/implementation structure in character looks
like i would do it.
Kind of
holy fucking shit
what the fuck do i do then
idk. Throw hibernate at the problem? Probably overkill.
I mean, setObject should be fine
"should be fine"
jdbi
Honestly, just scramble the byte[] into a base64 string
yeah...
and use text or remain with blob?
Thats the standard for serialized ItemStacks
I mean, you don't have to b64
i mean its the last resort
sqlite should support this
"should"
Have you tried using an actual DB and see if it changes the outcome?
You can be sneaky and start a containerized SQL instance via java
how? never heard of that
Let me find the library. Ive used it in unit tests a few years back.
thanks much 🙏🏼
time to write up a minimal replication
Hmm. You might need to have docker installed for this to work.
afaik my environment is already dockerized
it definitely does, sqlite has only one real data type and that's basically "any" :kekw: even malformed data is valid lmao
But you can get yourself a free external mysql instance with like 10MB space

With a byte[]?
serializeAsBytes since when?

Ah
does it work for you?
Yea
Now remove the types and try again.
But this is what i would have expected as well.
I mean, again, types literally don't matter for the xenial driver
they literally don't lol

you can turn on "strict mode" but uh yeah no-one does that
ha
ok i kinda rewrote the entire database implementation
so now i just hope it works
kinda like this
if that doesn't work ill just try mariabd or mysql
I mean it's just the start
I forgot a command package and other stuff
Also how do you manage permissions cause I don't like dynamic studf
like people will use getString("stuff.stuff.permisions.idk") and I feel like that's so bug prone
IT WORKS
OMFHJIKEWSRVGFUJKHWESKFDS
I DONT EVEN KNOW WHAT I HAVE CHANGED
i rewrote the implementation by accepting the types directly instead of objects
its way cleaner now
Make the interface generic to allow other id types
If return a void future for the voids
wdym
i dont plan on using CompletableFuture methods but in the implementation there is the runAsync
with no return since i dont plan on using it
yeah i could migrate it but still
I would make everything sync and then call them methods from within a CF
CompletableFutute<Void> so you can do something when it finishes
public interface DataAccess<K, V> {
V getByKey(K key);
void save(K key, V value);
void delete(K key);
void update(K key, V value);
Collection<V> readAllValues();
}
Something like this maybe
More like 80%

the slippery slope of writing your own ORM half the time is one I'd suggest avoiding
beyond that, why abstract
why u no interface
XD yeah ive been there. I realized "wait... this is just a document mapper im writing, right?"
But it spawned one thing i liked quite a bit. A map that automatically gets synchronized locally 😄
trium ?
Trim I assume
That is a thing now?
Yeah
oh sorry i have this setup, can be made generic but it may need to remain an abstract class
Yes
hmpf
Aha
nah but that means you forked spigot 
How the fuck do you add stuff to 1.19.4 without forking 
bytecode edit via recaf ?
then you'd obviously have that method already
I mean
if you don't run spigot you run paper of one of its forks
which all have that method

best of luck
smart move
¯_(ツ)_/¯
A very non spigot take
@kind hatch yes my problem was that I had given the root Advancement a namespace for the parent and it seemed to work before (can't remember why I did it) but now I had to remove it. (Now as the first Arg for new Advancement I just have Optional.empty() or is your issue smth else I know a bit about the Advancement stuff in nms
?paste
https://paste.md-5.net/lefulanuka.java
Once I save a value, the value just gets lost after server reload/start/stop, can somebody help me?
declaration: package: org.bukkit.inventory.meta.trim, class: ArmorTrim
look at what armor the player is wearing, then profit
ArmorMeta i thinks
Is there something like a spawnprotection for bukkit created worlds?
not sure, you can try creating a world and if it does then it does, but if not you can make one
I would make a listener that checks the chunk of blocks
How can I put the same command in multiple different classes?
For example the command /test reload in one class, /test give in another and /test boom in another?
All this without there being any problems in the main
Implement subcommand class with CommandExecutor and save it in Map<String, CommandExecutor>
And have one main executor which will get executor from map and run it
Key would be subcommand name
One of the ways
I have git installed and it's also in the path, however buildtools still downloads their own, any idea how to fix this?
nevermind, i've added bin in the path and it works now
make a full command system for the sake of it
I did that actually
It's surprisingly nice to do so
then switched to my coworker's because it's just better
It's not that hard if you understand how a tree works
Well, first you plant a seed
is there a way to see the final name of an renamed item in an anvil
Get result get meta get display nsme
Can it be made so that the user can shoot with a bow without an arrow?
that changes every time i change something at the name not just when I finish it
then you water the ground
Yes iirc there's an actual event for when you use an anvil
I forgot the name of it
No you need an arrow somewhere
Is one command executor and then an if statement for all sub cases a bad way to do it?
Yes
You would maybe have something like
public abstract class CustomCommand {
private final Map<String, CustomCommnad> children;
// etc etc but you get the point
}
But why is it better? xD
its 300x cleaner as easier to maintain especially as you gain more sub commands
an if statement is technically faster initially but as you add subcommands a map becomes more realistic
just wait until annotations :pog:
i try use BukkitTask but this not work for scheduleSyncRepeatingTask
its so marginal it doesn't matter
Ok yeah I agree to that but should I also have more CommandExecutors as @hazy parrot said or just a custom class
true but I'm providing A reason. Also providing a reason you'd use that data structure it provides O(1) key value access which is perfect for sub commands
if you don't mind using the plugin.yml just go with a command executor
otherwise I'd construct your own custom class and register with the command map using reflection
granted it also depends if you want to associate other data with your command
Thx
What I'm trying to do is use advancements purely for the toast notifications. My problem is that they aren't showing up anymore (likely due to my original jank implementation) and I've been struggling to figure out why. I just tried using Optional.empty() as my advancement key, but it still didn't fix my problem. Are you able to get toast notifications with your advancements?
So the advancements are showing up in the manager? I'm not seeing any toasts but I forgot if there was a boolean for it 🤔
Not even that. They aren't showing up at all anymore. Even with chat messages and toast messages being enabled.
I'm back to packets because the bukkit implementation doesn't work due to immutable maps now being used.
Yeah there is a bool for toast let me test rq I might actually want toasts xD
My impl probably could use some work, but here's the before and after of what I have tried.
1.20.1 and below: https://paste.md-5.net/ojotasanuq.java
1.20.2 attempt: https://paste.md-5.net/fanabewade.js
Yeah the toasts work I'll try and see if I find smth
Hey! I am trying to check whether the block the player is standing in is a lava block AND a source block. A thread I came across from 2021 proposed this solution:
// Check if the block is lava if (block.getType() == Material.LAVA // block is a source block && block.getData() == 0 ) { // Turn lava into obsidian block.setType(Material.OBSIDIAN);
However, block.getData() is deprecated, is there a new syntax for this?
@kind hatch, sorry for the ping, but I wanted to ask you what has changed in 1.20.2 compared to 1.20.1 when it comes to spawning an NPC. I wanted to use the same method I was using in 1.20.1, but I can't; it gives me this error. Has something changed regarding the protocols? The error I'm getting is:
java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.PlayerConnection.l()" because "var0.c" is null
at this line:
listener.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this));
What is your root advancement that your sending? I only see the one in comments or is it the advancement one?
The actual advancement.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/Levelled.html
block.getBlockData()
declaration: package: org.bukkit.block.data, interface: Levelled
I'm not entirely sure myself. I only touch nms when I need to. I haven't needed to mess with player packets yet. My best guess is that some sort of information needs to be updated before you send that packet. I had a similar issue with the advancements I'm currently trying to fix.
That packet constructor requires the player to have a valid connection now
However there is another constructor that does not
Seems to be similar to mine. Do you actually want to instantly grant the advancement so the toast pops up? I use grantProgress() on my AdvancementProgress but not sure if it is needed...
AH grant should work
Seems to be the same as mine hmm
Yes, I want to instantly grant it so that the toast shows up, then remove it as it can happen multiple times.
Yeah I missed the line but you also grant it so that should be fine
seriously? Which one is that?
What's the easiest way of setting a player head owner?
I used to use before profiles for it but skullMeta.setOwner(name) was so much easier and I ended up using that all the time.
But recently when i updated the server from 1.20.1 to 1.20.2, this method is not working anymore, there's no error but the heads are showing default.
Have you tried sending an almost empty advancement (Criteria Empty Map, No requirements and checking if it then pops up in the advancement tab 🤔 )?
Without granting it just the holder
I can try that and see what happens.
That does show up in the advancement list. (I have a bigger advancement menu mod :p)
ok weird does it grant if you send a seperate packet afterwards? Would make little sense to me but you could try if that's a problem
I'll try both in the same packet and a separate one.
Neither method works. I'm assuming it's because there's no criteria tied to the advancement currently.
yeah you need criteria
Hmm, I think this is where it's starting to break down. Don't advancements with criteria usually have a number indicator? 1/12 or smth like that?
Separate packets didn't do anything either.
Criteria was added using
Map<String, Criterion<?>> advCriteria = new HashMap<>();
String adv = "{\"trigger\": \"minecraft:impossible\"}";
JsonElement jsonElement = ServerAdvancementManager.GSON.fromJson(adv, JsonElement.class);
JsonObject jsonObject = GsonHelper.convertToJsonObject(jsonElement, "advancement");
advCriteria.put("for_free", Criterion.criterionFromJson(jsonObject, new DeserializationContext(pluginKey.get(), new LootDataManager())));
Try if this works in a map:
"for_free", new Criterion<>(new ImpossibleTrigger(), new ImpossibleTrigger.TriggerInstance())
That works.
Don't really know what you're doing up ther but can you somehow modify it xD
Idk what the difference really equates to either, but hey, that's less json I have to worry about lmao.
The toasts are now showing up though.
I have one thing that could have been interfering with this. Gotta do some testing to verify though.
👍
https://paste.md-5.net/lefulanuka.java
Once I save a value, the value just gets lost after server reload/start/stop, can somebody help me?
Thanks for the help though. Would have still been stuck figuring this out.
¯_(ツ)_/¯
and if you ever try to position the advancements, keep in mind that the y coordinate is relative (I don't remember in what way)