#help-development
1 messages · Page 924 of 1
Where do you set the lore?
What if you just remove days
its never more than 24hours so the first tick could just be 24 hours right
i want it to count down .. and its constant
But its 1 day so you don't need to display the days
Dump the unix time and check which time it represents (plenty of online tools exist for that)
some are random
Alright, check if it does work if the time is multiple days. Maybe the issue is just cause its 0
if thats the case, your hours will probably break too once it reaches 0
the package i claimed is daily , so it should be 24h .. 23h , 59m , 59sec ..
etc
and go down from there
I'd unit test getNextClaimTime
Although it probably works from very rough manual testing
The reason why it's doing that is you need to subtract System.currentTimeMillis() from it if I'm coprrect @twin venture
However, I'd say the Duration#between has the arguments flipped, as @floral drum mentioned
As System.out.println(getNextClaimTime(LocalDateTime.now().minusDays(2).toEpochSecond(ZoneId.of("UTC").getRules().getOffset(Instant.now())) * 1000, "DAILY")); returns PT-42H-25M-49.782S or -152749782
Leading to negative numbers, which may break your math
Actually, in that case it would say it is expired?
What if you change the if(days > 0) to if(days >= 1)
Meh, I still recommend to unit test everything left and right, especially those neat standalone methods that could very well be static
because 1 / 10 is 0.1 which is greater than 0 so you're never getting negative numbers calculating the days
just numbers between 0-1
That is not how longs work in java
I feel that
Then how do they work
longs, by definition are integers
(though longs are 64-bit integers where as ints are 32 bit)
Isn't it obvious that a number will never become negative unless you subtract or multiply by a negative number (i mightv missed some i'm not a math pro)
long integers
hmm
The only floating-point primitive units we have are double and float.
And there are no fixed-point primitives in java land.
Now there are a few other numbers such as BigDecimal, but they are not primitives
I'm still convinced the problem in this screenshot is that they're checking if amount > 0
it should be if (amount >= 1)
amount > 0 is better compared to amount >= 1 due to performance reasons
but the amount will always be more than 0 because dividing the millis will turn it into some small number between 0 and 1 but not negative
strings are not primitives
Well I am purely talking about bytecode primitives. How the compiler treats them is another story I am not qualified to argue about
despite string literals being a thing
What integers lie between 0 and 1?
and string template literals in the future 🤔
I am genuinely curious
they're using long, or are you saying long is made by int
(excluding 0 and 1 if you are willing to treat between as that)
longs are 64-bit integers, yes.
And integers are whole numbers such as -1, -2, -3, 0, 1, 2, 3, etc.
But most notably they cannot represent all rational numbers - so 1.5 or 3/5 or 3.14 or 2.72
Ah I see i'm confusing the datatypes long can't have stuff after the comma
all ints are signed ints, java does not have unsigned types
I have no clue what the actual definition of whole numbers are, I am not english
@quiet ice then how does this code decide if it wants to round down or round up
because for the code to work it should always round down to 0 if its less than 1
yeah then I have no idea what is wrong with killer's code i give up gg
yeah but the returned long will still ever be treated as signed, that's just going to set up the bits correctly, the arithmetic in the language will be signed
In the reference implementation, BigInteger constructors and operations throw ArithmeticException when the result is out of the supported range of -2^Integer.MAX_VALUE (exclusive) to +2^Integer.MAX_VALUE (exclusive).
However, that is an implementation detail
not too bad?
Though idk what the first four fields are used for
what if they used longs instead of ints
BigBigInteger
It's prob some 32 bit jvm limitation
most likely not
Some 32 bit CPUs support some 64 bit operations, just like some 64 bit CPUs support some 128 bit operations
i mean
What? if it works it werks
anyone know how to set a translation in bungeecord
because noone wrote it
Or noone deemed it to be a usecase that requires it to be present in the java language
the only thing you'll be able to run on it is stupid web apps on windows given that electron is basically the only thing that has 32 bit builds
anyone?
idk
Does anyone know how MongoDB works in the background? If so, will the eq in collection.find(eq("fieldName", "value")); search through the entire database and cause lag or will it magically get that document without reading everything
mongo is confusing
Didn't electron ditch 32 bit recently (which is why steam stopped providing them at the start of this year)?
Ah yes, magic.
If in doubt, consider a method to be blocking.
Yeah I do my queries in CompletableFutures
Yeah it's a blocking method
Never used bungee so I cannot tell. Especially given that your question is rather ambiguous
pretty sure the returned cursor is blocking actually
discord seems to be running under wow64
and I'm running a 8-bit machine
meaning set a value in messages.properties
set for what?
wdym
Your plugin or bungee?
a value in the messages.properties in bungee
In the former case - what exactly do you struggle on? In the latter case: #help-server
Bear in mind I never used bungee, but what the hell is this file coming from is my question (and what do you need it for?)
its like setting a value in server.properties
kinda
alert=\u00a78[\u00a74Alert\u00a78]\u00a7r
already_connected=\u00a7cYou are already connected to this server!
already_connected_proxy=\u00a7cYou are already connected to this proxy!
already_connecting=\u00a7cAlready connecting to this server!
command_list=\u00a7a[{0}] \u00a7e({1}): \u00a7r{2}
connect_kick=\u00a7cKicked whilst connecting to {0}: {1}
current_server=\u00a76You are currently connected to {0}.
fallback_kick=\u00a7cCould not connect to a default or fallback server. Incorrectly configured address/port/firewall? {0}
fallback_lobby=\u00a7cCould not connect to target server, you have been moved to a fallback server.
lost_connection=\u00a7cProxy lost connection to server.
mojang_fail=\u00a7cError occurred while contacting login servers, are they down?
no_permission=\u00a7cYou do not have permission to execute this command!
no_server=\u00a7cThe specified server does not exist.
no_server_permission=\u00a7cYou don''t have permission to access this server.
outdated_client=\u00a7cOutdated client! Please use {0}
outdated_server=\u00a7cOutdated server! I''m still on {0}
proxy_full=\u00a7cServer is full!
restart=\u00a7cThe proxy server is restarting
server_list=\u00a76You may connect to the following servers at this time:
server_went_down=\u00a7cThe server you were previously on went down, you have been connected to a fallback server
total_players=Total players online: {0}
name_invalid=\u00a7cUsername contains invalid characters.
ping_cannot_connect=\u00a7cCould not request status from target server.
offline_mode_player=\u00a7cNot authenticated with Minecraft.net
secure_profile_required=\u00a7cA secure profile is required to join this server.
secure_profile_expired=\u00a7cSecure profile expired.
secure_profile_invalid=\u00a7cSecure profile invalid.
message_needed=\u00a7cYou must supply a message.
error_occurred_player=\u00a7cAn error occurred while parsing your message. (Hover for details)
error_occurred_console=\u00a7cAn error occurred while parsing your message: {0}
click_to_connect=Click to connect to the server
username_needed=\u00a7cPlease follow this command by a username.
user_not_online=\u00a7cThat user is not online.
user_online_at=\u00a7a{0} \u00a7ris online at {1}
send_cmd_usage=\u00a7cNot enough arguments, usage: /send <server|player|all|current> <target>
player_only=\u00a7cOnly in game players can use this command
you_got_summoned=\u00a76Summoned to {0} by {1}
command_perms_groups=\u00a76You have the following groups: {0}
command_perms_permission=\u00a79- {0}
command_ip=\u00a79IP of {0} is {1}
illegal_chat_characters=\u00a7cIllegal characters in chat ({0})
kick_message=\u00a7cYou have been kicked off the proxy.
reject_transfer=\u00a7cYour transfer was rejected.```
thats what i mean
What is the dev aspect of it all?
Okay. That narrows it down a little bit more
does anybody know if there is a way to get the player's gameprofile during the AsyncPlayerPreLoginEvent event?
Use the uuid and getOfflinePlayer
The contrary: It means that when you call a method you can expect the Thread to say in that method for a while
So I have made an error making a plugin and have no backups of the code, and the server opens in 3 hours - can anyone write it again for me that actually understands plugins??
I need it to let people on three teams (firstlife secondlife extralife) have keep inventory, but then make peole on the thirdlife team drop all their items on death.
The problem I have right now is that while keep inventory works for the main group and the thirdlife drops right, on the keep inventory side they both keep items and drop them, meaning its a dupe
I would guess
I can't
why not
because I have to modify the field id
?
Where as non-blocking methods instantly return (though they may have side effects after returning, for example through scheduled futures, network I/O, etc.)
:c i thought it workeddd and I barely know how plugins work anyways i had to get someone else to compile it and now I have no time again
how to optimize websites for large resolutions
should i add more content visible if lets say i have a carousel menu, it should expand more "cards" or leave it as it with maximum width
I need to get the gameprofile because, by using a reflection, I need to modify the field id of player's gameprofile
So, why can't you plainly write to that file in the onLoad?
this good?
return CompletableFuture.runAsync((Runnable) collection.find(eq(fieldName, value)));
}```
ok how abt this. does anyone know how to set a value in a properties file
uh that casting looks like it's gonna blow up
What does find return?
That cast seems very strange
Field field = gameProfile.getClass().getDeclaredField("id");
field.setAccessible(true);
field.set(playerProfile, newID);```
FindIterable<Document>, idk how to use this but I will probably make methods to updateOne
See java.util.Properties
read this
any1?
ty for pinging me
Yeah, then it doesn't work that way. You'll likely want to use a lambda here.
So:
.runAsync(() -> {
code
});
ok but how do i get the specific file
do what coll said
if it doesnt work you cant do it on pre login
.
did you try what he said
java.io.File or java.nio.file.Path?
oh
Paths.of() (J8+) or Path.of (J9+)
explain
I need to do it in pre login, because another plugin loads playerdata during joinevent, so it isn't able to find the id and kicks the player
what are you actually modifying in game profile
What is there to explain? They are the equivalent of a path constructor (java.nio.file.Path is an interface)
what do i put in the builder tho
Jesus, what is with my english today?
not builder
the path
What constructor?
so like
the id
messages.properties
Depends on where that file is located in
hold on maybe I just found a solution
Path.of(".") is the current working directory
Use Properties.load instead
You can't cast anything willy-nilly
I don't know who told you that that is acceptable behaviour
But that guy (or gal) belongs handled
Wouldn't this work? or what do you mean
public CompletableFuture<Void> mongoAddInt(MongoCollection<Document> collection, String fieldName, String value, String fieldToUpdate, int numberToAdd) {
return CompletableFuture.runAsync((Runnable) collection.updateOne(eq(fieldName, value), (inc(fieldToUpdate, numberToAdd))));
}```
```java
mongoAddInt(collection, "testField", "testValue", "something", 4).thenRun(() -> {
//something to run
});```
Read my last three messages
sorry i casted cause it gave an error
Your IDE is fucking stupid, okay
including the old value
IJ isn't much smarter than eclipse when it comes to some of its suggestions
it's programmed to fix errors, not prevent future errors or bugs
what
It is programmed to resolve compilation failures at all cost. But while the syntax is correct, the semantics are not
is it acceptable now 😔
return CompletableFuture.runAsync(() -> collection.updateOne(eq(fieldName, value), (inc(fieldToUpdate, numberToAdd))));
will that access that file
idk i just copied what i used with configfiles
Anyways, you'll probably want
return CompletableFuture.runAsync(() -> {
collection.updateOne(eq(fieldName, value), inc(fieldToUpdate, numberToAdd));
});
ngl I never really did something with when its finished other than sending how long it took and adding a command cooldown while its saving async to prevent unexpected things
no. It will throw a ClassCastException.
Use new Properties().load(Files.newInputStream(Path.of("messages.properties")) 🥄
Yes I had that then I get intelij suggestion Statement lambda can be replaced with expression lambda
nvm doesn't work
cause it's 1 line
i need sneaky throws for that
hi!
I need help for creating Custom enchantment does anyone could help me ?
thanks
So don't. Use try-catch
also why do i need that if im not loading
Perhaps even try-with-resources. The approach I gave isn't the best one, it just happens to be a solution
Could you elaborate?
bc its #load
Could you also elaborate?
I would create a HARVESTING enchantment but I dont know how to register it. I use 1.20.4
the Enchantment.register... doesn't exist.
Well to write it back you use #list or #store (I'd go with the latter)
Yes, registering enchantments via Spigot API was never endorsed
Use PDC and lore now yes
ok I'll try thanks
bro i just wanna set smthg in it. its already in my main dir
I mean if you want to you can also append to the file via Files.write(Path, Iterable<? extends CharSequence>, Charset, OpenOption...)
the PDC is clear after reloading ?
No, it's persistent
ok yeah🙄 haha
But that way can blow stuff up if you are not careful (e.g. duplicate entries in the properties file)
Hence, you generally want to read the file in order to write it back after modifying the java.util.Properties object
Also, if you want to go with the append route, use StandardOpenOption.APPEND in your open options
Otherwise you'll delete that file
💀
properties.setProperty("no_permission", "§cYou do not have permission to use this command.");```
cHeCk ThE rEtUrN tYpE
yes?
Beware that it will not magically write the file back afterwards. Use store for that
so i shouldnt use this?
no?
wth
WHO THE FUCC TOLD YOU YOU CAN CAST STUFF TO WHATEVER YOU WANT
?
I want to strangle them
Figuratively, of course
load returns void, so you'll have to put that as a separate statement
we both know that isnt true
W
wow thats almost exactly what you were told to do here
damn
yeah
But spoonfed via gpt
https://docs.oracle.com/javase/tutorial/essential/environment/properties.html
Is there even a tutorial for this?
This Java tutorial describes exceptions, basic input/output, concurrency, regular expressions, and the platform environment
I think that was a rhetorical question
I made this real quick in 1 class as an example, does this look like it won't cause lag even if the player was getting kills every second?
https://pastes.dev/DpMTnRsI40
Reuse your Document in login
uh, how do I return something in a completable future 💀
public Document findDocument(Document filter) {
CompletableFuture.runAsync(() -> {
Document doc = collection.find(eq(filter)).first();
return doc;
});
return null;
}```
return the future
the whole point of futures is that they're going to complete later
but now I still can't get the document from it or I atleast don't know how
public CompletableFuture<Void> findDocument(Document filter) {
return CompletableFuture.runAsync(() -> {
collection.find(eq(filter)).first();
});
}```
```java
findDocument(document).thenRun(() -> {
});```
thenAccept
Also supplyAsync, not run
Thanks I think I got it
anyone know other encryption methods that arent b64 with a cipher
or keypair stuff
What are you trying to encrypt
Know symmetric and asymmetric
A data string
Look at asymmetric
so i need help i want to add this image to the gui but i dont know how to make the picture lineup
when i tried the 33 112 it give me []
and ascent just make it go up and down
so far i have 七七七七七七七 as the spaceing
eh that looks like the legacy neg space font
Ascent must be less than the height
icky
will i need more
kk
I'd also make your image semi-transparent so you can actually do alignment well
ah yes, docs
Why the fuck does bedrock run so poorly on consoles
I can't be the only one who thinks javadocs looks ugly
[21:00:01 ERROR]: #!#! java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock cannot be cast to class org.bukkit.block.Sign (org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock and org.bukkit.block.Sign are in unnamed module of loader java.net.URLClassLoader @5ce65a89)``` why is this happening
```java
Block tempnewblock = p.getLocation().getBlock();
tempnewblock.setBlockData(Material.OAK_SIGN.createBlockData().createBlockState().getBlockData());
Sign newblock = (Sign) tempnewblock;```
Oh my gosh did a jet engine just start in my room (oop didn't notice wrong chanel)
?? what are you even trying to do there
set a block to a sign
settype only?
Is there an easy way to get the Mojang mappings for the snapshot release? I just want to look at the deobfuscated names, not actually compile anything.
The mappings url is in .Minecraft/versions/<version/<version>.json of your client
if you like $$0 $$1 $$x1 yeah xD
But that has links to other jar files?
you can find the mappings file in the MC wiki page for the version
on the panel on the right
Ctrl + f .txt
it's just easy
There's a client.txt and a server.txt
Yeah
OK, found it. Thank you.
is there a way to place full set of armor in the smithing table?
That's even easier. Thanks!
i cant get it to work still get []
hey
can PDC be set on a Lever
any block with a TileEntity has a PDC
nvm was thinking of modeldata
How would I approach loading data from a file/database when a certain chunk gets loaded?
- If done async players might interact or enter that chunk before the required data is available that might prevent them from doing so
- If done sync and the database or connection performs poorly it will cause lag.
How is worldguard doing it? Or do they keep all regions in memory?
Alright, in memory it is then. Thank you
yes i did
nope its not set on itemstack
if I want EntityDamageByEntityEvent to only be triggered when a player is still alive after it, should I check for:
if(potentialDeathPlayer.getHealth()-e.getDamage() <= 0) return; ?
is this event triggered on "the final damage" of the player?
Yes
use getFinalDamage
Inventory firstEmpty
null
EmilyInventory.setItem(0, DIAMOND) 
Nice until you realize you deleted her shulkerbox of stuff
Hey, I have this code and cs is returning null, could someone help me?
ConfigurationSection cs = plugin.items.getConfig().getConfigurationSection("Items");
cs.set(args[1] + ".material", item.serialize());
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.ConfigurationSection.set(String, Object)" because "cs" is null
Does that section exist
Yea
Show us
it doesnt contain anything so it's not a section
just do getConfig().set("Items.something", something)
I mean
I've tried making it a section by setting numbers below it
like
Items:
1:
and still it returns null
can't do 1:
have to do '1':
have you ever saved the config?
done that
works for me
it'd have to explicitly be whatever: {} if you wanted an empty section
have you used ConfigurationSections cs = getConfigurationSection?
(simplified)
yes, as shown above
println(config.getConfigurationSection("Items"))
putting it in a variable won't change its null-ness
have you maybe only changed your included config.yml but not the actual saved one?
I mean, I'm not using config.yml
but I have another custom file with the exact same code
and that file works
how help me fore creat royaume in my srveur?
what
what
He's asking something about a Kingdom on his server?
Probably factions type gamemode
is it possible to make different regions have a different weather and time
You would have to maintain that yourself by selectively sending packets.
Unless a "region" as a whole world.
Well the weather can be set via the spigot api at least
The time as well
In that case its easier
hello i started programming today and got an problem when starting the plugin
Error occurred while enabling TestPL v1.0.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "de.itsemse.minecraft.TestPL.getCommand(String)" is null
``` i googled it and it say that it was an problem with my plugin yml but i think i did everything right can someone help?
yml:
```name: TestPL
version: 1.0.0
main: de.itsemse.minecraft.TestPL
description: Test
author: ItsEmse
api-version: '1.20'
commands:
testcommand:
description: "This is a command"
usage: "/<command>"
aliases: [test, testcmd]
permission: testpl.testcommand
permission-message: "You do not have permission to use this command"```
how is the command registered
@Override
public void onEnable() {
// Plugin startup logic
this.getCommand("testcommand").setExecutor(new commands());
}
packets wouldnt do the job
i wanted to to have eg different chunks have different weathers
but if thats impossible
too bad ig but
have to live with it
You just can tell the client if it rains or not. So listen for when he crosses a chunk border and change his weather/time.
na but
i need it to actually be server sided
so mobs spawn/burn lightning strikes what ever
doing that manually would be so much pain
why is it saying Player aabss just tried to change non-editable sign
int r = new Random().nextInt(1, 10);
Location l = new Location(p.getWorld(), p.getX(), p.getWorld().getMaxHeight()-r, p.getZ());
Block tempnewblock = l.getBlock();
tempnewblock.setBlockData(Material.OAK_SIGN.createBlockData(), false);
tempnewblock.getState().update(true, false);
Sign newblock = (Sign) tempnewblock.getState();
p.openSign(newblock, Side.FRONT);```
?jd-s
seems like a bug, open a bug report
ok
Inb4 old version
code works for me. Player#getX and #getZ dont even exist in spigot, so I think
?whereami
my bad
thanks for wasting my time
hello i started programming today and got an problem when starting the plugin
Error occurred while enabling TestPL v1.0.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "de.itsemse.minecraft.TestPL.getCommand(String)" is null
``` i googled it and it say that it was an problem with my plugin yml but i think i did everything right can someone help?
yml:
```name: TestPL
version: 1.0.0
main: de.itsemse.minecraft.TestPL
description: Test
author: ItsEmse
api-version: '1.20'
commands:
testcommand:
description: "This is a command"
usage: "/<command>"
aliases: [test, testcmd]
permission: testpl.testcommand
permission-message: "You do not have permission to use this command"```
What's your code look like?
package de.itsemse.minecraft;
import org.bukkit.plugin.java.JavaPlugin;
public final class TestPL extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
this.getCommand("testcommand").setExecutor(new commands());
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
package de.itsemse.minecraft;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class commands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("123");
}
// If the player (or console) uses our command correct, we can return true
return true;
}
}
this.getCommand("testcommand") is returning null for some reason
its valid
decompile your jar and see if the yml is updated
how i do that
clean before packaging aswell just incase
^
Decompiling a jar isn't hard. There's tools for it, but jar files are also just glorified zip files. You can open them with any archive tool.
I mean... what version of spigot are you running?
Is there a way to filter which packages FernFlower decompiles
There are some shaded dependencies I don't really care about the decompilation of as I'll add them back later with gradle
?whereami
Paper has its own plugin loading system.
have you tried a clean package yet?
It's supposed to have a legacy compatibility layer for regular spigot plugins, but I guess it's not working.
how
maven clean package
How have you been compiling your plugin before?
instead of maven package
Paper is trying to do some new thing?
They've been doing it.
They didn't like the spigot classloader so they went and made their own version.
There's a separation of plugin types when you do /plugins on paper.
the clean buttoon in lifecycöe?
Oh, great...
that works, yeah
still same error
probably a paper thing then
Can you test it on spigot?
inb4 it's called "paper-plugin.yml" instead of "plugin.yml"
i know
whats a default behaivor if I want to add an item to players inventory but all of the slots are full
does the added item "fall out"? on the ground
the returned Map will contain the items that couldn't be added
you can throw those to the ground or do whatever
Pretty easy to make a give or drop utility method with that ^
Yep
how could I make a plugins name customizable via config file?
for what reason
well i'm making an anticheat, and some people like to rename it or just make it "AntiCheat" so players can't figure out the original plugin
doesn't matter lol
You mean the message in chat
Or the name in /plugins
Easiest way to solve the later is just not give people access to /plugins
No, I mean the plugin name
try {
PluginDescriptionFile object = getDescription();
Field field = PluginDescriptionFile.class.getDeclaredField("name");
field.setAccessible(true);
field.set(object, this.config.get("PLUGIN_NAME"));
} catch (Exception e) {
e.printStackTrace();
}```
this is what i'm currently using but it returns to null
pl
[21:15:52 INFO]: Plugins (1): null
the config
@ConfigAnnotation(path = "plugin_name")
public static String PLUGIN_NAME = "Royal";```
Set it to a hard coded string first
That will narrow down if the problem is your config
You might also want to put that code in the onLoad() method instead of the onEnable()
this
i'll try that after hard coding
But yeah I don’t see the point of this if you can just not let players use /plugins
okay so hard coding it works properly, it shows the custom name
Well then your config get is retuning null
^
config shouldn't be returning null, i'm registering it first
What's your config look like though?
/*
*
* @author: az76
* @project: AntiCheat
* @website: insidious.cc
* © This project belongs to Insidious Development. Redistribution of this project is not allowed.
*
*/
import cc.insidious.config.Config;
import cc.insidious.config.annotation.ConfigAnnotation;
import org.bukkit.plugin.java.JavaPlugin;
public class MainConfig extends Config {
@ConfigAnnotation(path = "license_key")
public static String LICENSE_KEY = "XXXX-XXXX-XXXX-XXXX-XXXX";
@ConfigAnnotation(path = "plugin_name")
public static String PLUGIN_NAME = "Royal";
public MainConfig(JavaPlugin plugin) {
super(plugin, "config");
}
}
why we using reflection?
I mean the actual config file. Does your plugin not generate one?
it generates it, yes
Show the contents plz
you know implementing licensing system in java never works
Maybe your @ConfigAnnotation is flawed
There's the problem.
No idea since we can’t see it
Config paths are case sensitive.
shit
You were trying to get PLUGIN_NAME instead of plugin_name
i cant get this to show up i did everything
Easter bunny
yes
no errors if i copy the texrure to another custom gui image and save it as a copy it works as that image size that the other texture is could it be the saved size not working
so say i copyed this image here
and replaced it with this
it works but not the whole texture
show your code
and have you verified that your unicode is mapping properly
How would one "lock" a message to the bottom of chat. I've seen it done before but not sure how
Without it being sent over and over again
Any alternatives to creating a custom anvil gui with Bukkit#createInventory to where it can trigger PrepareAnvilEvent or is there another alternative to fetching and altering the anvil inventory?
NMS
Bukkit#createInventory won't work for working anvil inventories
its like 5 lines of code dw
well NMS atleast
or you could just use the AnvilGUI Api
I prefer NMS myself, but to each their own
i downloaed a texture tempalte and uploaded the image but how do i make it not dark like
^^^^
256 I think
&f the title
https://www.spigotmc.org/threads/custom-inventory-uis-updated.635897/ i made a resource on this if you want to check it out
so remove it
oh ok
ok fixed but how do i move it to the left it moved over when changed the name
read my resource
OOOOO would i be able to use this to make another off hand slot
nah that would require an extra actual game slot
i mean you could do it and make it look like it but it wouldn't be interactable
ah how would i add a extra slot
would require a lot of trickery
and you would have to make every single item in the game's slot icon a unicode texture
more effort than it's worth, if it works at all
you could definitely make an inventory with extra slots like origin does
ah ok
when a player re-joins, the new player object is created?
what does AsyncPlayerChatEvent#setFormat() actually do?
nvm found this https://www.spigotmc.org/threads/chat-format.274355/
player.getInventory().addItem(plugin.items.getConfig().getItemStack(String.valueOf(rank)));
Why is this returning null even if I have the items set in the config?
'0':
type: LOG_2
amount: 64
'1':
type: LOG_2
amount: 64
'2':
type: LOG_2
amount: 64
they are
but seriazable
or how u write that thing
what serializer
LOG_2 is not a valid material
ItemStack item = player.getItemInHand();
plugin.items.getConfig().set(args[1], item.serialize());
plugin.items.saveConfig();
It is an old version, id have changed ig
Hello. Im having an issue where the bossbar doesnt update and the clock doesn't count down at all. /pauseclock, /resumeclock and /final do not work at all
Here is the code:
https://pastebin.com/pvNbQhD7
There were no errors
/startclock - will start the countdown on the bossbar. it goes for 361 seconds. That is the countdown variable
/pauseclock - should save the bossbars progress, save the seconds remaining (pausedCountdown) and is supposed to pause it (Doesnt work)
/resumeclock - uses the saved variables from /pauseclock and resumes the countdown
/final - makes the bossbar title Final and displays each teams name and score. those are in other classes. it also sets the bossbar progress value to 0
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
is '0': at the root of the config?
If you mean at the start no
getItemStack(String) needs teh full path
show the full config
and that's already the itemstack
I just asked if it was at teh root of the config
oh
like yea
firstime: false
enabled: true
'0':
type: LOG_2
amount: 64
'1':
type: LOG_2
amount: 64
'2':
type: LOG_2
?paste the config
so we can see indents and all
looks fine to me
sysout the rank you are trying to read
Not really
he currently can;t even read a config entry so changing to an array or some other format is unlikely to help at the moment
sysout your rank
My IntelliJ went rabid and turned every class with generics into a normal class in every library
e.g. Collection<File> listFiles from Apache IO into Collection listFiles
Program-time type erasure lol
damn
Well I get more time to procrastinate while it re-indexes everything
yo i have a problem while building a gradle plugin im a beginner so yeah
Could not determine the dependencies of task ':services:application:shadowJar'.
Could not resolve all dependencies for configuration ':services:application:runtimeClasspath'.
Could not find gg.scala.commons:store:3.5.1.
Searched in the following locations:
- https://repo.dmulloy2.net/repository/public/gradle-release/gg/scala/commons/store/3.5.1/store-3.5.1.pom
- https://repo.maven.apache.org/maven2/gg/scala/commons/store/3.5.1/store-3.5.1.pom
- https://repo.dmulloy2.net/repository/public/gg/scala/commons/store/3.5.1/store-3.5.1.pom
Required by:
project :services:application
Could not find gg.scala.commons:serversync:3.5.1.
Searched in the following locations:
- https://repo.dmulloy2.net/repository/public/gradle-release/gg/scala/commons/serversync/3.5.1/serversync-3.5.1.pom
- https://repo.maven.apache.org/maven2/gg/scala/commons/serversync/3.5.1/serversync-3.5.1.pom
- https://repo.dmulloy2.net/repository/public/gg/scala/commons/serversync/3.5.1/serversync-3.5.1.pom
Required by:
project :services:application
Could not find gg.scala.commons:serializers:3.5.1.
Searched in the following locations:
- https://repo.dmulloy2.net/repository/public/gradle-release/gg/scala/commons/serializers/3.5.1/serializers-3.5.1.pom
- https://repo.maven.apache.org/maven2/gg/scala/commons/serializers/3.5.1/serializers-3.5.1.pom
- https://repo.dmulloy2.net/repository/public/gg/scala/commons/serializers/3.5.1/serializers-3.5.1.pom
Required by:
project :services:application
Could not find gg.scala.store:shared:0.1.8.
Searched in the following locations:
- https://repo.dmulloy2.net/repository/public/gradle-release/gg/scala/store/shared/0.1.8/shared-0.1.8.pom
- https://repo.maven.apache.org/maven2/gg/scala/store/shared/0.1.8/shared-0.1.8.pom
- https://repo.dmulloy2.net/repository/public/gg/scala/store/shared/0.1.8/shared-0.1.8.pom
Required by:
project :services:application
Could not find gg.scala.aware:aware:1.1.9.
Searched in the following locations:
- https://repo.dmulloy2.net/repository/public/gradle-release/gg/scala/aware/aware/1.1.9/aware-1.1.9.pom
- https://repo.maven.apache.org/maven2/gg/scala/aware/aware/1.1.9/aware-1.1.9.pom
- https://repo.dmulloy2.net/repository/public/gg/scala/aware/aware/1.1.9/aware-1.1.9.pom
Required by:
project :services:application
- Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
- Get more help at https://help.gradle.org
all src here https://github.com/tropicserver/tropic-practice
I doubt you get to build this
Hello
you need the "scale repo"
whatever and wherever that is
presumably some of their internal stuff
FurnaceRecipe recipe = Bukkit.getRecipesFor(input).stream().filter(r -> r instanceof FurnaceRecipe).map(r -> (FurnaceRecipe) r).findFirst().orElse(null);```
this is not getting any recipies, I'm doing a fake furnace to make it smelt faster/slower ect, like a normal furnace but custom
any fixes for it?
alr ty
wtf
Ok I manually deleted every single folder on my pc that had to do something with commons-io and let it be reimported and now it works lol
i code with nvim
I code with a background ||music||
Nope*
For me it's not noticeable at all because I got used to it
i need the background music too
and either a cocacola
or an energy drink
which is like a booster
coffee and a cigarette before coding is even better
I need the background music to code and not get distracted with other stuff.
i only allow my cat to distract me during coding
I need a piece of gum to code properly
I'm using a lib that depends on Commons Compress 1.21, which is vulnerable to CVE-2024-26308. If updated to 1.26, it's no longer vulnerable. Is it possible in Gradle to change a version of that library somehow?
Other than forking the lib, changing it and building it for myself lol
I get too distracted by coding will start at 9am and next minute I look it’s 8pm and I forgot to eat anything all day
Samee
exclude it from the dep and shade it urself
Thanks
how can i make sure my plugins onenable runs after my softdependencies?
as long as it has the soft depend it will run after them
it didnt
and how do you know that
new placeholderexpansion().register();
papi = true;
}```
i have this in my onenable
papi is a public bool
i got it by using ```commandSender.sendMessage("" + FantasyLevels.papi);``` in my command
and it said false
Show your plugin.yml
version: '${project.version}'
main: me.lars.fantasylevels.FantasyLevels
api-version: '1.19'
load: STARTUP
authors: [Blockbuster_287]
softdepend: [MythicMobs, PlaceholderAPI]
commands:
Stats:
Description: Shows the stat screen
Aliases:
- statistics
- level```
what should i change?
remove that line
do the getters and setters in an hibernate entity get replaced by getters and setters that directly modify to sql? or is this in memory?
No, getters and setters are invoked and their values inserted into a prepared statement
Afaik
do you know how i can create a hibernate session im a complete newbie? or is there a good video on how to get started?
Hello. Im having an issue where the bossbar doesnt update and the clock doesn't count down at all. /pauseclock, /resumeclock and /final do not work at all
Here is the code:
https://pastebin.com/pvNbQhD7
There were no errors
/startclock - will start the countdown on the bossbar. it goes for 361 seconds. That is the countdown variable
/pauseclock - should save the bossbars progress, save the seconds remaining (pausedCountdown) and is supposed to pause it (Doesnt work)
/resumeclock - uses the saved variables from /pauseclock and resumes the countdown
/final - makes the bossbar title Final and displays each teams name and score. those are in other classes. it also sets the bossbar progress value to 0
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
fuckin' hate java
can't use SharedSecrets
can't use reflection
the fuq do I do?
cuz java base class
what are you trying to do
what exactly is the purpose of this?
Throwable#setCause
to prevent PacketEvents from printing an error
Uh wha
So why not filter the logger instead
both of which tell me to fuck off
it only prints it
And why hide PacketEvents errors
it doesn't actuall throw it
cuz making a netty guard
??
Have you tried using the sun Unsafe?
But I am not entirely sure why you wanted to use the SharedSecrets class
oooh
can I use that?
like can I fully override an object?
like I mean
Yeah, the sun Unsafe can set fields arbitrarily. It is much more complicated (and dangerous!) to use, but it does work
That being said, the sun Unsafe won't work for all too long, but it is the final vestige before you start thinking with portals
void yes() {
Exception e = new IndexOutOfBoundsException();
ex(e);
//now the e is RuntimeException
}
void ex(Exception e) {
Unsafe.getUnsafe().someFunnymethod(e, new RuntimeException())
}
can I do something like this?
I meant this
uh, that might be too psuedo-source for me
nope
it's exactly what I wanna do
change what the variable points to
in a void
Well, what I understood is this
void main() {
Exception e = new IndexOutOfBoundsException();
{
/* "ex(Exception)" inlined for brevity */
e = new RuntimeException();
}
}
Which doesn't make any sense
exactly
or just changing it's cause
both are fine for me right now
it's just that
the e = new new RuntimeException();
should also affect the caller argument itself
You can't manipulate the stack of the caller methods without some incredible amount of mind games (unless you go with ASM transformation)
here's what I'm doing right now
and here's what PE does
thus, I'd need to override either the cause or the object itself
I need to prevent this from printing
However, the cause can be changed rather easily. So you'd have something like this
Throwable t = getThrowable();
t.cause = myCause;
(of course, I inlined everything for brevity here too)
I
know
but
no fucking method
allows me that
java is too much baby-sitting
Well, cause is a field
it just throws InaccessibleObjectException
if you try to use reflection
Hello, how can we use sonic boom from warden in the versions below 1.19 ? In 1.19 + We can use Particle.SONIC_BOOM but not in 1.18 for example
Unsafe#putObject(Object, long, Object) exists which should do that to my knowledge
The only complicated part is obtaining the correct offset
Because here, java doesn't babysit you at all
wtf do you mean?
yes it does
you need to get this mfo with reflections
Yes, but once you have the unsafe instance you can do whatever low-level shit you want. With not babysitting I mean not providing any high-level ways of accomplishing what you want
well I guess
what's the offset tho?
ooh
it's simple
got it
but won't this result in a lazy set?
The field you want to set, basically
I think it does a store fence already? Otherwise you can unsafely do a store fence yourself
what does that mean
I never understood what a lazy set was
It's multi-thread semantics for all I know
Or more specifically, how the state of a variable is updated to other Threads. Could also influence the same thread, but I am not too knowledgeable in that. Conclure might know though
Well the store fence probably can be rather invoked via VarHandle instead of the sun Unsafe
is there a way to get a TrimMaterial from Material without many if, else blocks?
switch case
well, ok
IT WORKS
YOU GREAT MAN
Forever indebted to you
Well that code won't work for all too long anyways
what
I think it'll break with Java 21 or something
WHAT
The sun Unsafe class won't exist for all too long unfortunately
I believe they want to get rid of it with the full release of FFI/Project Panama
--add-exports moment
no
your issue
Yeah, the JDK maintainers believe that everyone is willing to use --add-opens and --add-exports so it isn't a great deal
but it'll throw an error if I try to access it
Which honestly is a braindead stance but what can I do
what is that
?
Runtime flags that patch how JPMS works
add exports and add opens is how you "access" internals
just like SharedSecrets
tis
SharedSecrets is a hack used by the JRE, it isn't anything that special and follows the laws of java
I know
you won't get any errors by using the appropriate flags
I understand perfectly how it works
You just need to add the flags at runtime, not at compile-time
those flags are specifically to expose that stuff
wassdat mean
what're flags
what is life
this error got thrown for this code
is there a way to convert image to a map?
how?
You need to execute the server like follows: java -jar myJar.jar --add-exports java.base/sun.security.util=ALL-UNNAMED (of course I just copied something from the internet, not sure if that works if used 1:1, but the idea is the same)
do you want to only spoof it or actually have the map change pixels?
uhh wym spoof?
hmmm, so as a plugin dev can't do much
like nothing actually changes but the client thinks it did
Yes, because server admins are expected to have those flags anyways
i just need it to be same
Blame Ron Pressler for everything getting worse in this regard
well the slower but probably more appopriate option would be
using MapRenderer
it'd be creating a packet object
and flush it down
32x32 pixels
it would be faster cuz you could also do it async
pretty smol
yup
no need
also never use this
always use PacketEvents
much better
I guess i have never used them tho
well for starters
you could do it the intended way
where no bugs will occur
you create a filled map
is it fast?
list and remove all renderers
takes a bit of time
how much for 32x32? like estimate
1.5-3ms?
thats not that much
1 questionn does it take 3ms to render map ?
yeah
If i give every player the same map will it take 3ms per player?
I mean it takes less
well yes
but not 3 ms
less
like 0.8ms
Ah lets try intended way
(packets would have pretty much no impact tho)
3ms is quite a lot for 32^2 values
why 32^2
Was too lazy to use a calculator and figure out that it is 1024
Hmm i guess we can try packets then?
well then allow me
can it put all 32x32 pixels on 1 map?
1024 is like nothing
okay thats good
Maps are 128x128
raw if possible
then I can just send you my github impl
sure
You can pack the same map id for everyone and send it
it's quiet a bit of classes
oh shoot
:)
oh wait no
tis
Can someone please help me with why when the sword-type in the config is set to example "abc" and the sharpness in the config is set to 0 it skips the sword and gives the next item (exactly as it should) but if the sword-type is set to "abc" and the sharpness is set to ex. 1 it cancelles the sword and everything else. I need help to fix so that it skips the sword if the sword-type dosent exist
code: https://pastebin.com/UWAwcDMf
(its with 1.8.8)
should i just resort to a library?
so you do this:
get the channel with this
like you copy the newer and older impl
and part of ReflectionUtils for that
whats? netty
then the constructor classes for item and map packets
netty
is like
what the server uses for client-server connection
do i need to get it?
nope
it's built-in into spigot
as one of it's libraries
you just want me to copy all these
ye
https://github.com/ShadowOfHeaven-Me/AlixSystem/blob/master/src/shadow/utils/holders/ReflectionUtils.java#L556 and the neccessary stuff from this
oh
i think i mentioned it a bit too late x(
in that case you can just reference the classes themselves
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.34.Final</version>
</dependency>
spigot uses earlier version but don't care
will it shade it?
well it should be defined as provided
I don't use maven so dunno
lemme quickly import it
hey can you vertically rotate a block? eg. player's head
ok imported it
when you need to send a packet then
get the Channel with this
so the stuff we copied is useless?
we wanna be efficient^
createMapView -> MapMeta -> set to an itemstack
unless thats efficient
As for efficiency you want to do things your way
not as fast as packets
efficient enough
do you know exactly what you're talking about
maybe
but yes
also it invokes the bukkit event
Can someone help?
Parsing colors does take longer on the bukkit side
it's decently fast
But so does it take long on the nms side
It all depends if you're using a color lookup table or not
ye
@quaint mantle is the image constant?
If the image is a constant then you can just do the bukkit route
if you're sending like 20 images per second or want to generate images on the fly, or generate multiple images and batch send them then it's whatever make your own parser
then packets are the way to go
here
yes
or in performance-sensitive environments
image is constant
PRetty sure you can create a map view async
nope
image is saved in /resources
you cannot
So yeah let's not over-engineer and stick to bukkit for now
This isn't performance critical
mm maybe packets are a bit out of my head
you aren't sending a board of 16x16 item frames and need the extra 1ms per player
well I did so I used packets
but I guess you can just stick with bukkit
so create a filled map item stack
remove all renderers
I made an interactive board that displayed fun quizzes and games
add your renderer
and then rewrote it all on minestom
it was pretty optimized
I also had raycasting and some other magic
what engine
or just the general minestom api?
general api
I'm thinking of making my own server impl
I don't have time for that
how?
neither do I
for(MapRenderer r : meta.getRenderers()) meta.removeRenderer(r);
alr
public void mapCreate(){
ItemStack map = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) map.getItemMeta();
for(MapRenderer r : meta.getMapView().getRenderers()){
meta.getMapView().removeRenderer(r);
}
}```
like that?
now how do i add tha render
What about mojangs NativeImage
Can someone please help me?
I would but this code is ugly, doesn't follow any sort of conventions and is on 1.8
hard pass for me
Don't be so cruel
:((((
he isn't wrong tho
Your code looked about the same when you started come on
well yeah but back then 1.8 was new
Well like minecraft, people still use old phones... and they work
barely
?1.8
Too old! (Click the link to get the exact time)
it might be "ew" or whatever, but if it works it works.. all falls under the personal preference thing
i mean yeah 1.8 works.. works with all the dupes and crashes and exploits it has xD
what even is the point of playing MC in a version without goat horns?!
should i just steal a class from a plugin
1.8 oh no
it's like 5 lines
I mean, bugs vs crash exploits are two different things
isn't the goal of minecraft to collect all goat horns and then stop playing?
oh u fr
goat horns are goated
dont fucking blame this on me, ask the guy whos using 1.8
sure, but less now than then
Its to place 1 of every painting in your home
i just pointed out a few things
xD
wait why does MapRendered want player as argument
Shoutout to that one goat horn with a missing subtitle
people still use 1.8 due to pvp ... no hit delays and such