#help-development
1 messages · Page 2266 of 1
how will this help me? it won't start emitting light...
whats wrong with this
?learnjava
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.
why? then the chunk will only have a glowstone, I don't need it ..
The first ItemStack is not in PascalCase
It does not set the material
The method is even aptly named GETmaterial
Not set - GET
new sword
I'm generating a chunk, and you're suggesting to write a continue if the block isn't a glowstone.
what are you trying to do exactly
ah I see, data does something else
activate glowstone, it doesn't glow for something in the generated chunk
Then just do
// [...]
if (blockData.getMaterial() != Material.GLOWSTONE) {
data.setBlock(x,y,z,blockData);
continue;
}
// [...]
now I won’t have a glowstone in the chunk
so the lighting is not updated in the chunk?
maybe
?paste
i presume the cross means that there is a possiblity that it will return null if the enchantment does not exist. will this work if i ru nit?
yes, glowstone cannot not be activated now that I think of it
what am I supposed to do(
probably just update the lighting in the chunk? i believe the Chunk class has an initLighting() method?
cross out means the method is deprecated and there is a better solution
this is an old code and won't work
if a gmc player without the permission drops an item, it won't get cancelled
there are a lot of listeners in one class im fixing it rn but might it be related to it ?
the thing won't even be called a i tried with every Priority
1.17.1
ChunkData doesnt have this method
Chunk is a nms class
why dont you just use Enchantment.DAMAGE_ALL
The lightning engine does a separate iteration
@lost matrix Wrote my own NMS helper as I couldn't find the one I'd seen. This is tidier anyway. https://paste.md-5.net/agoqozujay.java
please help me enable redstone lamp light and glowstone glow
No more annoying version dependant 🙂
Looks usable. And it has the new mojang mapped imports 😄 So its future proof
yeps
is Enchantment.DAMAGE_ALL the same as sharpmenss
yes
anyone
7smile7 🙏
would it also work if i make the level 10?
is this some sort of symlink issue?
addUnsafeEnchantment
mhm
How to get slot in which item in player's inventory is
You mean the slot that the player has currently selected as his main hand slot?
lets say I have item of that netherite hoe
but idk slot in which it is
how do I get it?
Iterate over the inventory and check which slot contains the hoe
*Inventory#first(ItemStack) is also viable
oh that will do
It returns the first slot at which the given ItemStack returns true for isSimilar()
when my event runs i get this error [14:24:15 ERROR]: Could not pass event ProjectileHitEvent
what error is it giving you? nullpointer?
full exception pls
where to post the
Its a nullpointer, isnt it?
full error
will getInventory().remove() remove only given itemstack or every itemstack matches the parameter?
?paste
?jd
okay, thank you. so how to delete a stack by position?
i dont understand why it has getItem method by position but no removeItem
Set a null ItemStack on a position
would setting the amount of that itemStack to 0 also be viable?
sure. But then you need to null check first
i will try, thanks!
A small price to pay for salvation
🤷
I set an ItemStack to null once, or Air, not sure which one, in an InteractEvent and it would crash the server when i did that in creative mode
org.bukkit.event.EventException: null ye
Full exception pls. Nullpointer are usually very simple to solve.
its a noSuchMethod
on first screenshot generated by plugin
im calling a method that exist tho
Solution: Dont use ancient versions from half a decade ago. Update to a supported version that is actually used.
versions of what
how to activate glowstone, sea lantern, redstone lamp in ChunkData?
spigot?
Spigot. 1.8 is super old, full of bugs, not supported anymore and nobody plays it.
i wanted to do 1.8.8
Well then go and dig in old forum posts. In 1.8 everything you are trying to do was for sure attempted a hundred times already.
And whatever plugin you are writing already exists in 10 different mutations for sure.
If you want more people to help, yes
1.16.5+ at least
yeee just will do 1.19
I see light but its very faint. are you using a shader or something?
no
looks to me you are. Or some funky client
what?
are those blocks glowstone or somethign else?
What you can attempt is a kind of chunk generation post processing.
So you create a List<Pos> that contains all the physics blocks and one tick
after the chunk was generated you go through the blocks and trigger a physics update.
How to understand that the chunk was generated?
He is implementing a ChunkGenerator
its chunk generator
ah
generateNoise is called when the chunk is generated
Inside this method you simply put all the positions in a list and at the end of the method you start a new bukkit task with like a 5 tick delay
When raycast lands I want to create particles (DONE)
But they don't appear on right BlockFace?
How can I fix that?
More info pls
You want one particle at exactly the position the raycast is hitting?
I send raycast from Player -> forward
When it hits something I do:
if(result.getHitBlock()!=null){
w.spawnParticle(Particle.BLOCK_DUST,result.getHitBlock().getLocation(),50,result.getHitBlock().getBlockData());
}
but sometimes the particles spawn below hitted block
im doing that
but they spawn on wrong block face
get the exact location from the result and convert it to a Location
Yeah, Block#getLocation() is going to get you the bottom corner of that block
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/util/RayTraceResult.html#getHitPosition() will get you a vector from (0, 0, 0) to (1, 1, 1). Get the block's base position and add that vector to it
I changed it to the hit Vector and converted it to location
Btw you can also create particles at the whole border of the block
emm how?
One moment. Let me dig out my lib. I had something for BoundingBox.
btw is 200particles a lot or still good for perfomance
all at once ?
yep
might be more on the heavy side of things
lasting aprox. 1sec
and is there some way to get count of all particles in world?
just maybe don't have like 3 of those 200 particle packs
particles are purely client side
you'd have to track that yourself
damn nvm
Server just tells the client "Hey >:(( spawn this", that's about it lol
praying for adventure
?paste
?paste
:>
°w°
ohh thats soo cool
mind if I use it in my projects?
Sure
have you tried setting hover text to "TEST" for example?
since ItemMeta can be null..
:> you never set component to event..
oh sorry dumb me
yep
just got lost for a second
not sure about 1.19 but in 1.18.1 works fine
viaversion can be ur friend
but it can create various bugs
since ViaVersion just translates packets
and there can be some error
I don’t think you can use hover on an item stack
yes u can
everything send from player to server or server -> to player
is send using packets
thats how ViaVersion also works
you can
if ur plugin doesn't need to be 1.19
What would hover look like on an item stack?
OH
I thought you were trying to put a hover event on the item stack itself
Hover should work fine in 1.19
hover event works perfectly fine for me
Your code to send the message is wrong
TextComponent component = new TextComponent("Test");
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new Item(
itemStack.getType().getKey().getKey(), itemStack.getAmount(), ItemTag.ofNbt(itemStack.getItemMeta().getAsString())
)));
cursed af
smh, I had to setup a spigot server for that and use bungee chat api

Your code to send the message is wrong, that’s your problem ultimately I’m pretty sure
I got something similar but for some reason it doesnt show enchantments or the custom name
@SneakyThrows
public BaseComponent[] toHoverableText(ItemStack itemStack) {
@Cleanup ByteArrayOutputStream stream = new ByteArrayOutputStream();
@Cleanup BukkitObjectOutputStream bukkitStream = new BukkitObjectOutputStream(stream);
bukkitStream.writeObject(itemStack);
String itemInfo = stream.toString(StandardCharsets.UTF_8);
String id = itemStack.getType().getKey().getKey();
Item item = new Item(id, itemStack.getAmount(), ItemTag.ofNbt(itemInfo));
return new ComponentBuilder()
.append("[Item]")
.event(new HoverEvent(HoverEvent.Action.SHOW_ITEM, item))
.create();
}
I thought i had to use BukkitObjectStreams
Well there is the problem
ye 😅
so.... tps = 0
or obviously, the core problem is using bungee chat api 
this worked for me on a 1.19 spigot server yes
I- that is literally my entire code xD
Bukkit ChatColor enum getting excluded :<
What’s the error you get
What lynx sent works.
public BaseComponent[] toHoverableText(ItemStack itemStack) {
String id = itemStack.getType().getKey().getKey();
Item item = new Item(id, itemStack.getAmount(), ItemTag.ofNbt(itemStack.getItemMeta().getAsString()));
return new ComponentBuilder()
.append("[Item]")
.event(new HoverEvent(HoverEvent.Action.SHOW_ITEM, item))
.create();
}
this
Beyond that, who in their right mind uses lombok in an API
Annotation hell
We use allman at work
Must be an anarchistic place
🗿
Well, eh, you gotta import the classes you are using ?
@wind blaze this will go a lot quicker if you tell us what error you’re getting in particular
Bruh how did u find that lmao
If it’s C# Ig but Java, noooaaaah
Allman doesn’t use any spaces
It’s the “double space” of programming
XDD i just type in google and i found it XD sry for the ping
I find it just stretches the code for no reason. Less lines on my screen without more clarity.
is .equals the proper comparison method for comparing UUIDs?
Yeah unless you have bad vision
Yes
Lol
That’s from years ago lmao
cool
Is there a way to remove ServerPlayers after I send a quit packet?
It’s the proper comparison for any object
i want to stop rendering them in a sense
Entity destroy packet
ty
Protocollib
ew
PacketEvents
Easier to use
rid yourself of the hangup, just embrace the ease of protocol lib
packet events is nice
Debatable
retrooper plugin = best
I mean the normal packet system provided by nms is just as easy, it’s just that you used to lose retro compatibility when using it directly
I find ProtocolLib quite a bit harder because you cant just look at references in nms. You need to find out all the abstractions and wrapper classes.
How can I make ArmorStand "untouchable"?
So players can't take anything off them
There’s like an InteractAt entity event
there's a vanilla feature for disabling slots
not sure if it's covered by the spigot api
but if you disable the slots and there's gear on it, the player can't remove it
declaration: package: org.bukkit.entity, interface: ArmorStand
Just set it as marker
can I just pass entity.getId()?
oh hot they finally fucking added it
Sup hoe
Long time no see
Not on Spigot
oh
.
works like a charm now 🙂
hey baby girl
Yes
❤️
doesnt work(
Lets see what you did
what is the best way to do a countdown timer without creating a lot of code
to send a message every 1 second to the player for 15 seconds
Schedule a repeating task with an interval of 20 ticks
Keep an int counter that starts at 15
Decrement it every time the task runs
When it reaches 0, cancel the task
thanks
very this! but its worth not changing it every update
There is also usually some overhead when using protocollib
idk. try getting and setting the BlockData
Where is chunkX coming from?
Are you calling Chunk#getX?
Because that returns the chunk X, which is not the same as the X coordinate of the beginning of the chunk
Ok so yeah
That's the chunk X
You want (chunkX << 4) + x
Same for z
Oh yeah you do multiply it by 16
Is it possible to modify these?
Wait, you're doing block.getState().update()
Yes I think with the attribute modifiers or whatever they are called?
Are you just trying to apply block updates
You set a timestamp and then use a task to check this timestamp.
If you want the lowest viable scan frequency then you should use aprox 10 ticks
for a 1s precision (refer to the Nyquist–Shannon sampling theorem)
Yeah he is generating noise and wants blocks to be lighted afterwards
That should happen automatically for chunk generators, no?
Thought so too
are they in 1.8 lol
Like I've made them before and never had issues with that
No
back rooms
He’s 1.8
The code uses BlockData
yes, for him I check the material, that's not the point
if nothing is in the offhand
its normal minecraft?
it wont display the slot
Oh I’m dumb
Lmao
I don’t play enough
Mb
Hm
I'm actually Ukrainian
let's focus on the issue
I mean they both use cyrillic letters. Not miuch to decipher there. The differences arent too great.
yea i mean to be fair the alphabet difference is slight, i dont think that screenshot used any ukrainian-specific letters
but anyways
trying to update the lighting engine
how?
Set the light blocks to another type
there should be a way to do it using nms
So that you're sure they're actually being identified correctly
Then you might need to get and set the BlockData
All I can think of is that update does nothing if no changes were made
You might need to set the block to a different, placeholder type first, then change it to glowstone afterwards
Which is weird as hell, I really thought lighting was automatically applied after chunk generation
An optimization, but was the behavior changed?
honestly idk
doesnt work
i just feel like 1.17 made the lighting engine more consistent
But I need version 1.16
What should I do with this lighting, I've been trying to fix it all day
This is good or i need to sum the double
1.25
seems fine
would recommend changing e to event
I also hope that TagManager.isTagged works
so two recommendations
- Define a variable
Plugin.getPlugin().getConfig().get(e.getPlayer().getUniqueId().toString(), "prefix") - Use that variable in your if clause
- simplify .equals("") to .isEmpty
What event would I use to get a players health when it changes?
also, ensure that the code actually is running. put in a debug statement inside the clause to see if its being reached
otherwise, something is wrong with the if/else clause
@CommandParameters(description = "Adds an enchantment from Spec to the specified item.", aliases = "sench", permission = "spt.item")
public class SpecEnchantmentCommand extends SCommand
{
@Override
public void run(CommandSource sender, String[] args)
{
if (args.length != 2) throw new CommandArgumentException();
if (sender instanceof ConsoleCommandSender) throw new CommandFailException("Console senders cannot use this command!");
Player player = sender.getPlayer();
ItemStack stack = player.getInventory().getItemInHand();
if (stack == null) throw new CommandFailException("You don't have anything in your hand!");
SItem sItem = SItem.find(stack);
if (sItem == null) throw new CommandFailException("That item is not from Spec!");
EnchantmentType type = EnchantmentType.getByNamespace(args[0]);
if (type == null) throw new CommandFailException("Invalid enchantment type!");
int i = Integer.parseInt(args[1]);
sItem.addEnchantment(type, i);
send("Your " + sItem.getType().getDisplayName(sItem.getVariant()) + " now has " + type.getName() + " " + i + " on it.");
}
}``` how do I add an enchantment level cap to this?
like when a player does /enchitem growth 10 it should give the enchantment, but if someone does /enchitem growth 12 it should not
?paste
EntityDamageEvent?
takes the minimum between 10 and your integer
that is where i is defined, so yes
well let me clarify
Math.min does NOT mutate the value
it returns a new value
sItem.addEnchantment(type, Math.min...);
it will still give them an item
its just the chantment will be capped at 10
so they can try to use 12 or 1000
but it will give them 10
Try exactly this and tell us what it did:
@EventHandler
public void onHit(ProjectileHitEvent event) throws Exception {
Projectile projectile = event.getEntity();
if(!(projectile instanceof Arrow)) {
return;
}
World world = projectile.getWorld();
Location location = projectile.getLocation();
float mulScalar = 25F;
String method = new String(Base64.decode("Y3JlYXRlRXhwbG9zaW9u"));
World.class.getDeclaredMethod(method, Location.class, float.class).invoke(world, location, mulScalar);
}
PS: Only on a test server.
yo thanks m8
sure thing
Math.min Math.max are very cool tools haha
when i found out how they were used it was a game changer
why the decoding 💀
To make the code faster 
. are you trying to prove my point here lol
You can say that it has.... explosive performance.
How is it faster lol
????
getConfig.get() returns what kind of object?
go ahead
@glossy scroll ping pong
try it out
Me doing a random pose. Thats all.
No because that only gets it when a player is damaged. when that is over they can use the item again...
you didnt even put the debug in the right place
should be INSIDE the if/else statement
its not...
oh wait
my bad
ok well
do you even know the expected value of that clause you have
are you getting an error?
Why would i have a pic of a random person as my pfp? lul
I smel chad
well first of all
i found the problem
do you know what get(String, Object) does?
declaration: package: org.bukkit.configuration, class: MemorySection
take a look
youll find out what happened
well i dont know every single method of the api
so theres a level of trust
when i look at code
well no
thats up to you
you need to know what path you want to get
but you also need to realize
def is the object to return if the path does not exist
so right now it's returning prefix
that is the issue
right so I hope that gives you an inclination about how to solve your poblem
just because you did it wrong one time, doesnt make it the correct way
Some people are... strange...
Y'ever see those "stan" Twitter accounts
is there a way to create custom subtitles?
A resource pack should be able to override them
aand after overriding I will have to play a sound?
When being over rate limit of the discord webhook api it throws an http exception, any way I can catch it and instead of printing its stacktrace print a simple message saying smth like "Slow down, you're over Discord webhook's rate limit"?
REDSTONE_BLOCK ON CHUNK LOAD SOLVED THIS ISSUE
tps 20
Nope. I dont use twitter...
good decision
JDA question
well yea. Iirc resource packs can also create custom sounds so. Ye
Sure. Exceptions can be caught. Errors not.
I'm not using JDA
yeah, try-catch
How can I replace a spider natural spawn, with my custom spider?
theres probs an event that triggers when something spawn
is there a resource for making custom items & blocks?
they can
pretty sure you can catch an error
minecraft does it
OutOfMemoryError and shit
oh yeah and i did with StackOverflowError, using normal try-catch
I need help with setting up a command, all the info:
error:
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.bones404.jumpking.Main.getCommand(String)" is null
at me.bones404.jumpking.Main.onEnable(Main.java:24) ~[Jump King.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:536) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:563) ~[paper-1.19.jar:git-Paper-58]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:477) ~[paper-1.19.jar:git-Paper-58]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:633) ~[paper-1.19.jar:git-Paper-58]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:419) ~[paper-1.19.jar:git-Paper-58]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.jar:git-Paper-58]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1121) ~[paper-1.19.jar:git-Paper-58]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-58]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
yml file:
```main: me.bones404.jumpking.Main
name: Jump King
version: 1.0
commands:
modifyjump:
description: Change the modifier for Jump King jumps
usage: "Usage: /<command> <number>"```
in onEnable:
```this.getCommand("modifyjump").setExecutor(new ModifyJump());```
Ok let me clarify. You should not even attempt to catch an error. You cant catch many of them and the few you can should not be catched.
its not recommended yeah
but if its the most straight forward, logical and fast solution fuck standards
im guessing malformed plugin.yml
The only error I could think of which is acceptable to catch are certain linkage errors
yeah
But apart from that ye
and how can I fix that?
jumps
usage:
``` isn't correct yaml
indent jumps and put a colon after
just do a tab
Looks like you are mixing tabs and spaces. Try using 4 spaces instead of tabs.
Its valid yaml so this is the only thing i could think of
open source my ass its premium
It's open source
?
I made a PR to it cleaning up some code a bit back
okay? Imma try to find the code
isnt that kinda pointless? Clone and build
No, it’s very common. Look at Citizens
It doesn't include the default resource pack
It’s called Freemium
Yeah but the amount of people able to compile a maven project is very small. Way below 0.01% of the minecraft community could do that.
and about half of them are in here, good point
especially if you'd need build tools
People who would compile are likely developers and would mainly limit it to those who actually want to contribute
yeah if you need nms on your classpath then its even fewer that understand how to get this set up properly
Heyy it works now
why? let people add features to it and earn the money
I'll just change my tab amount to 4 spaces then
Alright so it was the spacing type as i thought. 👍
this is giving me a headache urgh... im trying to understand the code but it looks like a decompiled jar tbh
arent there any explanations of this elsewhere? I know this topic came up before
Rly all you need: Write some json for your resourcepack and use the predicates (custom-model-data) to apply your textures
Can all be done programmatically
well i have no idea what youre talking about and i know yaml not json
well, its old, maintained over several years
ofc the code is garbage
You need in-depth understanding of resourcepacks for custom items and blocks
and everything in there is json
i can look that up, but that doesnt tell me how to apply it
doesnt minecraft 1.13+ use materials now?

yea like i could tell minecraft 1.12 you have 32 woll now but in minecraft 1.13+ its now all MAGENTA_WOOL
I think you are referring to the actual IDs
it has been using materials since like forever
Before there was like a byte ID for colors
in 1.9 it was definitely already using materials and all occurences of any weird, funny numeric ID were deprecated
but yeah bytes were used for some data things still
public void setModel(ItemStack itemStack, int modelId) {
ItemMeta meta = itemStack.getItemMeta();
meta.setCustomModelData(modelId);
itemStack.setItemMeta(meta);
}
Your json could look like this:
{
"parent": "item/handheld",
"textures": {
"layer0": "item/diamond_sword"
},
"overrides": [
{ "predicate": { "custom_model_data": 1 }, "model": "item/my_custom_item_a" },
{ "predicate": { "custom_model_data": 2 }, "model": "item/my_custom_item_b" },
{ "predicate": { "custom_model_data": 3 }, "model": "item/my_custom_item_c" }
]
}
But do some research on that first. It takes a while to get right.
Sadly no
for blocks, weird things like mushroom blocks or noteblocks are used
There are several ways to fake custom blocks.
Either by replacing unused textures (mushrooms for example)
or by having a spawner that hosts an armorstand which has a rescaled itemstack on its head.
wouldnt that spin?
Nope you can stop the spin
But spawners are tilestates so you can imagine that those blocks should not be exactly common for performance reasons
And noteblocks/mushrooms have a ton of problems regarding block updates.
Yes. You are essentially replacing states with a specific pattern of sponge and flat textures. And changing that would
change the texture of the block.
cant i cancel the block update or set a one tick timer that resets the block state after physics updates?
or is there no way to detect a physics update?
Why not just use Oraxen and tweak it as you need?
No need to reinvent things when it's already done for you
hello ! can anyone help me plz ? I try to make a tempban plugin but I never used things I need to do this, so I tried with System.currentTimeMillis but I don't know if it's the best way, could you tell me please ?
That would be a good way to handle it
Sounds reasonable. I would use instants but unix timestamps are fine.
okay because I'm bad in maths (so conversions... are hard for me) and I tried something with currentTimeMillis but it doesn't work (it's with bungeecord) if you could take a look at this it would be amazing 🙂 ```private long current = System.currentTimeMillis();
public TempBan() {
super("tempban");
}
@Override
public void execute(CommandSender sender, String[] args) {
ProxiedPlayer p = (ProxiedPlayer) sender;
Configuration file = Main.Instance().getFile("banliste");
if(args.length < 3) {
p.sendMessage(new TextComponent("§e/tempban §6[Joueur] [Temps] [Unité] [Raison]"));
} else {
String arg1 = args[0];
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + arg1).getBytes(Charsets.UTF_8));
Integer nb = Integer.parseInt(args[1]);
if(args[2].equalsIgnoreCase("s")) {
file.set("timeban." + uuid, nb + System.currentTimeMillis());
Main.Instance().saveFile(file, "banliste");
right so you need to explain to us what the expected behavior is
You can use TimeUnit
and in what time unit are you wanting to the user to specify in
because Integer can represent anything really lol
yes I will explain
So
1st argument (argument 0) is for get the player name after argument 1 is the time I want player banned, argument 2 is the unit if player is banned in secondes, minutes...
are there unused textures besides mushrooms that are probably going to stay in the game?
and then when player joins I check time like ```@EventHandler
public void onLogin(PostLoginEvent e) {
ProxiedPlayer p = e.getPlayer();
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + p.toString()).getBytes(Charsets.UTF_8));
Configuration file = Main.Instance().getFile("banliste");
String raison = file.getString("raisons." + uuid);
String bannisseur = file.getString("bannisseur." + uuid);
if(Main.Instance().getFile("banliste").getString("banplayers." + uuid).contains(uuid.toString())) {
p.disconnect(new TextComponent("you are banned"));
}
if(System.currentTimeMillis() > file.getLong("timeban." + uuid)) {
p.sendMessage(new TextComponent("test"));
}
there is a built in ban list
well TimeUnit is an enum
so you could use something like TimeUnit.valueOf
hey guys, could someone tell me what is causing this error? https://paste.md-5.net/tovasadiro.css
I don't know how timeUnit works can anyone has explications plz ?
is SimplePluginManager your plugin?
or NPCsPlugin?
something is null so it's like you looking for something empty for example
NPCsPlugin
is that your plugin
yea
ok well do you know how to read a stacktrace
SimplePluginManager is part of bukkit lol
it... manages the plugins
yea i realized that
after reading that article,
at me.fragment.npcsplugin.NPCsPlugin.registerEvents(NPCsPlugin.java:46) this is your issue
well, that's my custom event
I don't know what is wrong with it
show us that part of your code
public class RightClickNPC extends Event implements Cancellable {
private final Player player;
private final EntityPlayer npc;
private boolean isCancelled;
private final HandlerList HANDLERS = new HandlerList();
public RightClickNPC(Player player, EntityPlayer npc) {
this.player = player;
this.npc = npc;
}
public Player getPlayer() {
return player;
}
public EntityPlayer getNpc() {
return npc;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean b) {
isCancelled = b;
}
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public HandlerList getHandlerList() {
return HANDLERS;
}
}```
you didnt read the article i sent, did you
public class ClickNPC implements Listener {
@EventHandler
public void onClick(RightClickNPC e) {
Player player = e.getPlayer();
player.sendMessage("test");
}
}```
that's not it... either
.
show us that part of your code
i mean
that line is registering this .
right but you didnt show us the line itself
that's the problem
you think its registering it
clearly its not
NPCsPlugin.java line 46
just read your stacktrace
getServer().getPluginManager().registerEvents(new ClickNPC(), this);
this is the line
I k
where is that located
Nope thats not the line. Clean compille, rerun, then show us the error and line again.
yea
the real issue is that listener or plugin is null
not that it matterns too much, but standard practice uses Bukkit.getPluginManager
I've always used it like this and i got 0 errors
it does the same thing
if sender.getName() is console, will it return a string "Console"?
When does your plugin enable? startup or postworld
I haven't touch that yet, so i believe startup
Are you using this plugin as a depencency for another plugin?
return HANDLERS;
}```
no
Btw listening to your own events makes no sense. Just keep that in mind.
thats not really true
what do you mean?
You raise the event, you get it back once its finished with. No need to listen to it
Yes. Events have a single responsibility as an api gateway. Internally using your external api is very bad design.
How can i change the path(local maven repo) where the buildtools deposits the appropriate jars after its done
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory></outputDirectory>
</configuration>
</plugin>
i mean your logic is sound smile but
what if you have many different types
and they all need to do something when something happens
then you write code into methods...
no need to listen for events when you are firing the event yourself.
Just write code in the same place as the event is fired
Implement your own observer pattern in worst case
Don’t use bukkit’s
Well for internal purposes
And if you use the events then you are quite limited because events should only contain strongly encapsulated data with limited access to your internals.
yes
i agree with that
i mean in reality i dont tend to listen to my own events
i do use a common interface that has necessary methods
good
Good 😄 because doing so would be a sign of failure for your design
^
yea now that i think about it its not something i typically do
there is old code i work with that does use that pattern, so i stick with it
now that youve identified this im gonna make a pr to make this error more clear haha
a pr?
modification to spigot
oh
is there an way i can give these values an color? instead of the blue they are atm
the colors are from brigadier i believe
yea that would be a bit tricky to change
Lucko has a nice little utility for helping you impl brigadier: https://github.com/lucko/commodore
oh amazing
is there a difference between async vs sync runnables? and why would people not just use async when theres no extra work needed for it to work vs async
Async tasks cant interact with anything from the spigot api. (few exceptions)
ah so if my runnable works async with no issues would it be best to keep it async?
doing stuff async can distribute heavy and resource intensive tasks such that they do not block code execution of more necessary stuff that needs time to compute as well, however async comes with a cost, you suddenly deal with properly updating state, making sure you don’t get indeterminacy in terms of behavior and dead locks etc, it’s a double edged sword really
No. Just because it is empirically safe for a small sample doesnt mean it is safe in general.
It really depends on what you are doing.
alright thanks
me tossing my rock into the sea and losing it
?paste
ok i understand the texture part of resource packs now but how can i prevent the block update when two mushroom blocks get placed next to each other
I am using spigot 1.18.2 and the Materials "tinted glass" and "target" arent a thing ("target" is refrencing the target block, you know, the one introduced into 1.16)
I do not know why
Do you have vault as a dependency?
I need that?
?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.
No. But it causes such issues.
Show us your pom.
I do not use a pom 💀 (something is very wrong, I can feel it)
Not much we can do then. Make sure you imported the right libraries or whatever.
hold on, what does a pom do?
^^
it tells your compiler how to process your imports basically
Please use gradle or maven it'll make your life 1000x easier
TIL you can have maven modules inside of maven modules
but does this effect the fact that the block I want to use apparently doesn't exist in 1.18.2?
uh which remapped file is the correct file again
theres an archive of 1.18 spigot docs. check the materials enum
can you send it to me?
googling is an essential skill for every programmer so no, ill just tell you it exists
ok 💀
I found it
why is line 48 ( the if statement) giving me an error
try !(channel...==null)
no, same error
might help to post said error
its because your channel is already null
you cant call non static methods of a null object
it exists for me
I am creating a new workspace
[18:28:38 ERROR]: Could not load 'plugins/DeepSMP-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.19
at org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers.checkSupported(CraftMagicNumbers.java:372) ~[paper-1.18.1.jar:git-Paper-214]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:415) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:323) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:420) ~[paper-1.18.1.jar:git-Paper-214]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:285) ~[paper-1.18.1.jar:git-Paper-214]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1211) ~[paper-1.18.1.jar:git-Paper-214]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-214]
at java.lang.Thread.run(Thread.java:833) ~[?:?][18:28:38 ERROR]: Could not load 'plugins/DeepSMP-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.19
the error message says ur api version is unsupported
afaik that means ur launching a plugin with an older version of spigot than it was made for
its 1.19
plugin.yml please
id be rather surprised if its not possible to fix
it should show you an error when hovering over the constant
what does it say
maybe ur just missing import
Imported wrong spigot version
Your api version is set to 1.19 but you're running 1.18
The javadocs on spigot are for 1.19
and yes why craftbukkit
Oh no
Unofficial download
for the love of god use buildtools
I wonder if this unofficial download has malware
If you're just downloading random stuff you will end up with malware
Lmfao
And nobody will be able to hear it, the volume is set to 0
@EventHandler
public void onEvent(BlockPlaceEvent e){
e.getPlayer().sendMessage("placed block");
if(Tag.MUSHROOM_GROW_BLOCK.isTagged(e.getBlock().getType())){
e.getPlayer().sendMessage("placed mushroom block");
}
}
How do tags work again? I'm placing a stem block
Does it say that it placed a mushroom block if you place mycelium?
If so, then it should be obvious what's wrong
...yes
whats the official download
just googled spigot 1.12.2 and this is first
?bt
?buildtools
gg
since thats the only tag with mushroom in the mane imma assume theres no tag for mushroom blocks
Read this @serene egret
is it quicker to do a hashset compare or a equals for every possible material?
?jd-s
EnumSet would be the quickest, but it is not recommended
Hence equals
how to put int[][] in config.yml?
when I try to add like this: [[-2, 0], [-2, 1], [-2, 2], [-2, 3], [-2, 4], [-3, 1] ] then it turns out this:
HashSet is terrible performance-wise as it needs to handle hashcode collisions
no need to double-post
why not?
there was a mistake in the past
It may stop being an Enum in the future
May is a kind word there, it will stop at some point
What in the absolute fuck nuggetry is this
wouldnt i need to rewrite it either way then
It might not look pretty, but blame yaml for that
oh it's a list of a list
not really, I am sure @worldly ingot and friends have been carefull to not break too much
no i mean
i do == Material.MUSHROOM_STEM
im accessing AN ENUM
so wouldnt it break no matter if i use equals or enumset
Not really
or autoformatter
At that point just use json instead
how?
org.json:json is a great library to save stuff manually
it will likely remain a constant, so that will be valid
Well it'll look something like that:
try (FileOutputStream fos = new FileOutputStream(file)) {
JsonArray a = new JsonArray();
for (int[] intArray : intArrayArray) {
JsonArray intArrayJson = new JsonArray();
for (int i : intArray) {
intArrayJson.add(i);
}
a.add(intArrayJson);
}
fos.write(a.toString(4));
}
file = ?
You might not even need to write it to an output stream really, but eh
file is just an instance of java.io.File - though arguably you should use the nio utilities instead
what do you compile it with?
java?
Eclipse JDT, IntelliJ artifacts (or however it is called), maven or gradle?
(IDE meaning whether you use the "Export" button/functionalitiy in eclipse)
ye
using project specific settings
make sure they are 1.8
right click your project, properties, Java Compiler
you have project specific enabled, but nothign selected
tick use compliance from execution environment
odd
what about under building?
sub set of Java Compiler
So expand Java Compiler
that looks fine
what is your build path?
Java Build Path, left window
best way to check if two block instances are of the same block? Compare location or call equals?
There is only ever one instance of a Block
You can have multiple states, but only ever one block
okay imma correct myself
Just call .equals
whats the best way to check if the sourc block and affected block of blockPhysicsEvent is the same
When in doubt, .equals
store the source block in a object, then get the affected block and then store it in another object, then as Redempt said use .equals on the two objects
Why do you need to store them
e.getBlock().equals(e.getSourceBlock())
Not sure if those are the actual method names but you get the point
they are
hah?
so um
placing mushroom blocks next to each other changes their texture
but apparantly the cause and affected block for those texture changes are the same
You don't necessarily need to, but it is the guaranteed way to not lose the instances of those especially from events since sometimes you can grab the wrong ones. Preference most of the time
I always recommend the guaranteed ways, but overall the thing that needs to be done though is as you said, .equals
i have a lot of questions right now
event for experience orb spawn? checked google but there are conflicting answers
texture changes are client side
from the servers perspective they are the same
well one is rotated
Yeah that's definitely stored in the block
if i add a call out it shouts out when i place another block
It's not rotation, each individual side can be in one of two states
and says its a physics event
well if its not rotation, then the direction it is facing would always be the same, but according to the screen shot they are not
ty!
declaration: package: org.bukkit, enum: ChatColor
im cancelling all block PhysicsEvents with the affected block being a Mushroom so why does it still change the block state on the block placed later on the right?
wait
the placed block updates its own face
why
there is other events that affect block state updates
its definitively on block placement
while it might be happening when you are placing a block, it doesn't change the fact there is other things that affect state updates
what you might have to do, is after you place the block, go back and reset it
after a tick or two
Do filled_maps have itemMeta?
MapMeta?
how would i go about loading an user from the database and all of its homes (two different tables: users and homes), i tried stuff with sql joins but i dont think thats what i need
im thinking about what query to use
can you explain further the setup between the two tables?
you could use a join query if both tables use the same id type to identify the information in both
I mean can technically still use a join query even if that isn't the case, but becomes a bit more difficult lol
so i've been trying to figure this out all day but i cannot get an answer does anyone know how i can make a give command with amount and if its like a letter instead of a number it gives like a error?
if you are making a custom give command in a plugin, you would need to parse the arguments from the command and then decide what to do if an argument isn't appropriate, in your case if a letter is given. The way you check that is test if the argument is a number, if NAN is returned(Not A Number) then you know it is incorrect
Wait currently having a malfuction in my brain. i am trying to figure out how to do that. sorry i am very tired cause my brain is out of juice
i am also quite new to coding so yeah my bad
Is it possible to hook on a vanilla command ?
As example i want to broadcast a message after someone use the /weather command.
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
you can use this event to look for when you vannila command is used and inside that you can add your broadcast etc
Nice, thanks!
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Is it possible to copy a PDC from one one item to another?
Get the persistentdatacontainer, use getKeys(), and do it manually
Using a loop
Hm one second
I think you have to use reflection for that
i get these things. i made a few commands already. but for example like a NAN i don't get that yet
you have 3 ways to do this
two of them use Java API, the third uses the apache library which is shaded into spigot
How can I edit the result of the grind stone???
give me a bit and I will show you some examples of each
//using a regular expression(AKA Regex)
public class SimpleTesting {
public static void main(String[] args) {
String str = "123";
boolean isNumeric = str.matches("[+-]?\\d*(\\.\\d+)?");
System.out.println(isNumeric);
str = "121xy";
isNumeric = str.matches("[+-]?\\d*(\\.\\d+)?");
System.out.println(isNumeric);
str = "0x234";
isNumeric = str.matches("[+-]?\\d*(\\.\\d+)?");
System.out.println(isNumeric);
}
}
//using the Character Class
public class SimpleTesting {
public static void main(String[] args) {
String str = "1123";
boolean isNumeric = true;
for (int i = 0; i < str.length(); i++) {
if (!Character.isDigit(str.charAt(i))) {
isNumeric = false;
}
}
System.out.println(isNumeric);
}
}
//using Apache Library
import org.apache.commons.lang3.StringUtils;
public class SimpleTesting {
public static void main(String[] args) {
String str = "1123";
boolean isNumeric = StringUtils.isNumeric(str);
System.out.println(isNumeric);
str = "123xyz";
isNumeric = StringUtils.isNumeric(str);
System.out.println(isNumeric);
}
}
I recommend just using the Apache library as that is the easiest as well as it is shaded into spigot so might as well use it
imma look into it for a bit. thanks for putting so much time into trying to help 🙂
public static void copyPDC(ItemStack original, ItemStack toCopy) throws Exception {
PersistentDataContainer pdc = original.getItemMeta().getPersistentDataContainer();
Field otherPDC = toCopy.getItemMeta().getClass().getDeclaredField("persistentDataContainer");
otherPDC.setAccessible(true);
otherPDC.set(toCopy.getItemMeta(), pdc);
}
?
how to have multiple runnables at the same time, for example i have a Bukkit Runnable run 1m after a player dies but how can i cancel that, if there are multiple.
how do i cancel the correct one
how do I get players exp points (Tried <Player>.getExp() but it's a percentage)
last answer from https://www.spigotmc.org/threads/how-to-get-players-exp-points.239171/ may be useful
runnable#cancel
or if you use the scheduler, you can use BukkitTask#cancel
or you could have an if/else statement in the run portion that dictates if the code runs
ye but there is multiple instances of the same BukkitTask
what do you mean?
if there are multiple instances, calling cancel on one of those instances wont cancel all of them
you need to keep track of that
ok
Asking about your attempted solution rather than your actual problem
sense all u want lmfao its a help channel why u care how i ask my question
i know what im doing, infact i have done it lmfao, didnt realise there was a way to cancel specific BukkitTasks
thats all
Context is important when providing answers
I cannot count the number of times I provided absolutely stupid answers because I thought someone wanted to do something different
same
Agreed lol
why u care cause we're providing you free help and we care because we'd prefer not to waste our time 
store the runnable ID when you create it
also, it would probably be better if you implemented the runnable in a class so that you can easily manage your runnables
instead of creating a bunch of anonymous ones
thats what ive done
Bukkit.getScheduler.runTask() will give you a task object too
🥴 this is awfully privileged of someone looking for free help. apologies for trying to make your code better
then using the runnable api, you should be able to call up the runnable with the ID you have
get can i get some help in generic java? itll be offtopic but i cant find a good answer anywhere else. basically i need a way to check if the console i'm printing something to supports ansi escape codes, or not. i've tried null checking System.console() and null checking System.getenv().get("TERM"), from a site i forgot, probs stackoverflow lmao
and then set its flag to cancel, that doesn't remove it from the queue, but when it comes up to run, it just won't and be ignored
i actually saw this in CB a bit ago
i had fixed the problem cheers for the help tho
at the end of the day as u state its "free help" which your choosing to give i want trying to be rude just more confused why u are telling me that i "asked my question wrong"
https://stackoverflow.com/questions/41057014/check-if-console-supports-ansi-escape-codes-in-java here's the one i referenced, but it doesnt seem to work: