#help-development
1 messages · Page 2210 of 1
or "unlock" dropping for a single drop even if there was the drop click from inv before
There are ways.
This I guess
Looks like an error when deserializing a kit. looks like yoru code is calling itself
ItemStackManager#knightKit does something fun
?paste
this is the ItemStack that is apprently calling itself
It probably is calling iteself but haha
with the return method?
indeed
it does
return knight; not knightKit();
where can I find server version displayed on debug screen? (own fork)
Makes sense, will test out and come back!
yea
MinecraftServer#getServerModName
Thank you that worked!
CraftServer.serverName
thank you!
Give the correct permissions to use the command. But you should be in #help-server
hey Guys how Can I set my world to always night?
/time set night
/gamerule doDaylightCycle false
I know but Cant't I do that with code
lmao
there really gotta be some very easy way for devs to add fake players to test stuff
Yes, World#setGameRule() & World#setTime()
oh Thanks!
Oh It Doesnt Work
when are you running that code?
I have enum. I'm making minigame and I'm setting on if(getGameState().equals(STARTING){
}
I'm setting My Game State to STARTING but nothing changes.
You need to set the time properly
Is there a plugin that shows me the permissions to use to run a command?
no
if i have a number like 20 how can i turn that into .20
Math
for example?
1000L vs 1000
/ 100.0D
Time covers actual in game time. number of days, hours, minutes
Specify the type of number it is using the letters. L = Long D = Double
Oh Its Same
No, but they corrected it
D stands for double which are double-precision floating point numbers
You need to get the world time, then add to to move it to midday, else you mess with teh number of days
Generally the D can be omitted as that is the default type for floating-point numbers but I still do it anyways
how do i change the level of a light block
getBlockData() cast to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/Levelled.html
i forgot what getDisplayName gives and i cba to test one line of code
does it give the whole [Rank] name [Suffix] Whatever blahablah
or just the name
of the player
It should give the whole thing. Player#getName() would just return their username.
if a plugin modifies the player name will .getname return their real name or their modified name
im debating on whether to test it
You can't modify a player's username.
getName() always returns teh players exact name
aquacore seems to be able to
getName() completely changes when i disguise/nick using aqua
i guess its effective lol
getDisplayName() returns whatever it has been modified to be. That usually does not include prefix/suffix. Those are added by formatting in chat
alr
Hmm, well you could theorietically change the player name using NMS packets, but modifying the user packets are not only dangerous, but require knowledge of how the player packets work.
yeah i'm fairly sure he's really good at that stuff
Otherwise, #getName() should just return the name of the player.
alright thanks
so is there a condition where getDisplayName will return it with the ranks and prefix included?
because i want to avoid that
Well that's the point of getDisplayName. It lets you customize/format it how you want.
Lmao why
so what does it output
on a server
with ranks n shi
It outputs whatever the displayname was set to. Most of the time, displaynames are set by Vault since everything uses it. It should return nicknames and such, but I'm not sure if it would return rank prefixes. It'll really depend on what plugin modifies the displayname.
If you don't want any of that and just want the player name, use Player#getName()
u can use reflections to set the gameprofile name
i think thats what player#getname returns
Why is FallingBlock.getMaterial() deprecated ?
check the docs
What is the enchantment Sharpness in the lib Enchantment from Bukkit???
?jd-s
Oj thanks.
(I feel like it is easier to get the enchantments via their registry key heh)
package fr.program.pranction.commands;
import fr.program.pranction.Pranction;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
public class SpCMD implements CommandExecutor {
Pranction plugin;
public SpCMD(Pranction plugin) {
this.plugin = plugin;
}
private ItemStack createItem(Material material, int quantity, String name) {
ItemStack item = new ItemStack(material, quantity);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("sp") || command.getName().equalsIgnoreCase("sanctionplayer")) {
if (sender instanceof Player) {
Player plr = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
Inventory GUI_SP = Bukkit.createInventory(null, 54, "SP : " + target.getDisplayName());
ItemStack head_player = createItem(Material.PLAYER_HEAD, 1, target.getDisplayName());
ItemMeta head_player_meta = head_player.getItemMeta();
head_player_meta.setLore(Arrays.asList(
ChatColor.GREEN + "Information(s) sur le joueur " + target.getDisplayName(),
"Reduit au silence : " + plugin.getConfig().getBoolean("players." + target.getUniqueId() + ".muted")
));
head_player.setItemMeta(head_player_meta);
GUI_SP.setItem(0, head_player);
ItemStack triche_sword = createItem(Material.DIAMOND_SWORD, 1, "Triche");
ItemMeta triche_sword_meta = head_player.getItemMeta();
triche_sword_meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
triche_sword_meta.addEnchant(Enchantment.DAMAGE_ALL, 5, false);
triche_sword.setItemMeta(triche_sword_meta);
GUI_SP.setItem(1, triche_sword);
plr.openInventory(GUI_SP);
}
}
return false;
}
}
Btw why the enchantment is not visible?
I mean.
The "texture".
Whoever was behind the names of the fields of this class did a terrible job
The enchantment is there but not the glint?
^
Probably because of the HIDE_ENCHANTS flag, but idk
that flag should not remove the glint
It should usually still show the glint though, which leads me to believe that the enchantment was not applied
check the nbt to verify the enchant is there
Enchantment glint is hardcoded to enchantments. There should be no reason for it to not be there.
also if you have any client side mod to stop/modify the glint
like lunar client mods
Or VanillaTweaks resource packs.
It does not remove the glint.
Ah I am in lunar.
check if the noglint mod is enabled
Well, it is the only reasonable reasoning I have assuming vanilla
or try to launch with a vanilla client
Also, enchantments cannot be applied with ItemMeta. They get removed for some weird reason. You have to set your item meta first, then apply the enchantment to the ItemStack afterwards.
that is a bit strange
I have no mod whose name is "NoGlint".
I have never seen that happening
people still not using a command lib 🤤
@me lmao
Why would one use a cmd lib
It's just even more shit you cannot control but you still need to debug
makes it easier to handle commands without handling all the boilerplate code
I found the error about the sword.
Handling commands myself works (almost) flawlessly for me
Don't be denvercoder79
Thanks guys.
mhm i kinda hate the fact that i would have to do all prechecks before actually handling a command
and parsing them manually
Bro, that's all too real.
🤨
JedisDataException: ERR Can't execute 'publish': only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT / RESET are allowed in this context
Uhhh, no?
Loving jedis
How am I supposed to delete it then without causing a ConcurrentModificationException
Unless you know how to use pointers and can even use pointers in java, then I highly doubt it.
Well what's accessing it at the same time?
Like deleting an object from the map or the map itself?
Any idea?
plugin.getTrollManager().getTrolltable().values().forEach(Troll::stopTroll);
What does #stopTroll do? Code for that method?
public void removeActiveTroll(UUID playerUUID) {
if (hasActiveTroll(playerUUID)) {
trollTable.remove(playerUUID);
}
}```
I could be wrong here, but I think since you are already iterating over the map via a stream, trying to remove a player from that same map is what's causing the CME
the remove is the reason
otherMap.put(key, map.remove(key))
no need to check, just remove
public static void init(PlayerInteractEvent event, Pranction plugin) {
Player plr = event.getPlayer();
Action action = event.getAction();
ItemStack item = event.getItem();
if (item != null && item.getType() == Material.PLAYER_HEAD && item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
NamespacedKey key = new NamespacedKey(plugin, "playerhead-key");
ItemMeta meta = item.getItemMeta();
PersistentDataContainer data = meta.getPersistentDataContainer();
if (data.has(key, PersistentDataType.DOUBLE)) {
event.setCancelled(true);
}
} else if (item != null && item.getType() == Material.DIAMOND_SWORD && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase("Triche")) {
NamespacedKey key = new NamespacedKey(plugin, "trichesword-key");
ItemMeta meta = item.getItemMeta();
PersistentDataContainer data = meta.getPersistentDataContainer();
if (data.has(key, PersistentDataType.DOUBLE)) {
event.setCancelled(true);
}
} else if (item != null && item.getType() == Material.PAPER && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase("Chat")) {
NamespacedKey key = new NamespacedKey(plugin, "paperchat-key");
ItemMeta meta = item.getItemMeta();
PersistentDataContainer data = meta.getPersistentDataContainer();
if (data.has(key, PersistentDataType.DOUBLE)) {
event.setCancelled(true);
}
} else if (item != null && item.getType() == Material.WHITE_WOOL && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase("Construction")) {
NamespacedKey key = new NamespacedKey(plugin, "construction-key");
ItemMeta meta = item.getItemMeta();
PersistentDataContainer data = meta.getPersistentDataContainer();
if (data.has(key, PersistentDataType.DOUBLE)) {
event.setCancelled(true);
}
}
}
``` Why I can move my item from the GUI?
wtf
?paste
LMAO
That not event the api tho
and method names should start with a lowercase letter
I think its ?learn-java momment
It does not matter -_-.
it does
Look:
and now its public static void init :/
spam
Case for names matters. When anyone looks at your code and see's a capital letter they expect that to be a Class
Yeah, agree with you
Yeah what?
Idc.
Now thanks to help me if you can, thank you.
#remove returns the removed object. So you could take that object and put in another map. Like what he did.
Wouldn't I have to iterrate over all objects and do remove() on them?
and wouldn't that also cause a CME?
Have you learned java before creating plugins?
If you wanted more than one yes.
And have you learned the spigot api too? tho
Because that it is not event spigot-api listener
Using an iterator will not cause a CME
Have you read my code?
Yes
I'll try it then
Anyone else love jedis "ERR Can't execute 'publish': only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT / RESET are allowed in this context" !!!
Concurrency is nice even outside of multi-threaded code
What means concurrency?
at the same time
Yeah, multiple operations at the same time
And what have to do with his code? Sorry i cannot understand why remove generate that e
running stuff at the same time, like multithreaded programs
Class where I am create items with a key: https://www.toptal.com/developers/hastebin/tubiliwole.swift
Fonctions where the event is used: https://www.toptal.com/developers/hastebin/uvomukawuc.csharp
(I have the file to call the function so to manage events!).
But why I can move my items from the GUI?
So, like this?
LinkedHashMap<UUID, Troll> copy = new LinkedHashMap<>();
Iterator<UUID> it = plugin.getTrollManager().getTrolltable().keySet().iterator();
while(it.hasNext()) {
copy.put(it.next(), plugin.getTrollManager().getTrolltable().remove(it.next()));
}```
what are you trying to do? copying a map?
If you are looping over a Map and you remove one of those entries while you are looping over it, you are both reading the Map and modifying it at the same time. CME
ConcurrentHashMap also allows iterating over stuff while you perform removals - to some extent
I called it copy although I don't want to copy, but move them xD
So that map allow looping and removing at the same time
You get around a CME by using an Iterator.
ah true
It removes the current element
why not just
Map<> newMap = new HashMap<>(oldMap);
oldMap.clear();
also, only use it.next() once per loop. else you are skipping entries
im still wondering what you actually are doing
Myes, although ConcurrentHashMap does not fully allow for one thread to modify the map while another iterates over it
So as minecraft shit is not multi-thread it wont work tho
It won't throw an exception, but still may yield funny behaviour
Lmao jedis hatting momment
It amazing it generate an exception, when it was working before
(Such as newly inserted objects not showing up in the map or recently removed objects still being shown through the iterator)
https://gyazo.com/e4901bf4a91955f036b158b7e80285e8 why I am getting this error?
Why are you spamming?
do you have an api version in your plugin.yml? as it asks
put an api-version: 1.13 in your plugin.yml
Ah ok.
Ok thanks.
Btw can someone help about this please? :>
Blame beta 1.X bukkit for this
i guess you should cache that inventory
what is that listener? o.o Also why are you not using inventory click event?
My code: https://paste.md-5.net/janokeruzo.java
Exception:
[Redis] Successfully connected to
Exception in thread "Thread-1" redis.clients.jedis.exceptions.JedisDataException: ERR Can't execute 'publish': only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT / RESET are allowed in this context
at redis.clients.jedis.Protocol.processError(Protocol.java:96)
at redis.clients.jedis.Protocol.process(Protocol.java:137)
at redis.clients.jedis.Protocol.read(Protocol.java:192)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:316)
at redis.clients.jedis.Connection.getUnflushedObjectMultiBulkReply(Connection.java:282)
at redis.clients.jedis.JedisPubSub.process(JedisPubSub.java:135)
at redis.clients.jedis.JedisPubSub.proceed(JedisPubSub.java:125)
at redis.clients.jedis.Jedis.subscribe(Jedis.java:7891)
at dev.alex.net.core.redis.Redis.lambda$open$0(Redis.java:27)
at java.lang.Thread.run(Thread.java:748)
For every inventory GUI you wanna use inventory click event, yes
thats not even an event
Fabsi, have you seen his code? Is not even from spigot api his code
PlayerInteractEvent would be for interacting with blocks
I was also major confused but I guess he just tried to build a listener himself "around" the api
Any idea?
He meant EventHandler
Your @EventHandler annot appears to be missing unless I am not fed enough information
i mean theres so much wrong about that code
There is nothing wrong man :>, there is no way to code a plugin huh you know?
does InventoryPickupItemEvent get called when a player picks up an item or an entity does ?
Well it is more that you are violating many conventions set up by sun microsystems
Called when a hopper or hopper minecart picks up a dropped item.
ok thanks
:).
I have seen that happen because im subscribing and publishing at the same time sounds really ilogic. What do you think?
Hey there, i am listening to the BlockGrowEvent and try to get the Age of the seed.
But whenever i cast BlockData to Ageable, i get the error "CraftCrops cannot be cast to class org.bukkit.entity.Ageable"
As you can see, I check what Material the block has before, so it cant be AIR or something else
My code:
@EventHandler
public void OnWheatGrowEvent(BlockGrowEvent event) {
if(event.getBlock().getType().equals(Material.WHEAT)){
if(isFullyGrown(event.getBlock())){
...
}
}
}
private boolean isFullyGrown(Block block) {
Ageable ageable = (Ageable) block.getBlockData(); //error here
return ageable.getAge() == 7;
}
ageable is for entities
Also isnt getBlockData() deprecated?
Cant you cast it to CraftCrops which also has a getAge method?
Oh ok, my bad
wait so cast block.getBlockData to CraftCrops?
imma look
declaration: package: org.bukkit.block.data, interface: Ageable
u need this one instead
ur using the wrong import
how am i using the wrong import
ahh i see
lol
thank you
should i use
event.getNewState().getBlockData()
or event.getBlock().getBlockData()?
what are u trying to check
new state probably
alright thank you
just ((Ageable) block.getBlockData())
this was the issue, i got it now
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Is there a way to load in-jar yml files without copying them first? 🤔
Rn i copy, load and delete them again, but that cant be the only way right
plugin.saveResource()
the what? My question was answered? I dont have one anymore?
Plugin#getResource()
Is either of that without saving them to disk?
I just want the info, for default values. Not indending on copying the file
Well #saveResource writes to disk.
getResource() reads it as a stream
Ill try that, thanks
how do I check if a villager has a bed?
if i have a class which has static builder() method that returns A, and than i have another class which extends the first and it also has static builder() method which returns B, why would they clash?
does B derive A?
no
villager.hasPlaceToMakeLove()
well, i know about method overloading, but why the hell does it apply to static methods?
Likely because of how invokestatic works
hey, i'm making player statistics and I wanted to store them in a Map<Statistic, T> where Statistic is an enum constant and T the statistic value, that could be an integer, a string and so on. Is there a way i can do it with generics so I don't have to make the value an Object and cast?
If I am right it also searches in subclasses for the static method
how can i solve the problem then? i really want to have the builder method to be consistent with other builders
Cannot resolve method 'hasPlaceToMakeLove' in 'Villager'
Make B derive A perhaps?
hmm I could swear this worked back then
if i were you i'd make a separate factory class and put it in there
No you’ll have to do some unchecked casting no matter what if I read the issue correctly
how do gamerules work? I saw something similar to what i need there
Yeah, sadly the JEP that allowed for generics in enums failed to go through
So this is not possible
Oh they still cast, but their facade abstracts it away
ah i see
They have type aware keys (iirc)
anyone knows?
well the easiest way is just allowing to directly instantiate builder, like new SomeClass.Builder(), it's just pissing me off that it's inconsistent with other builders
well i guess i can blind cast too, not like i'll ever go poke in the database and change the type of stuff
is it possible to listen to custom events from a dependency you set for your plugin?
Myeah, well they just throw some assertive exception if an unexpected type is encountered
Pretty possible
good 🙂
yea that works, when i retrieve data i'll just listen for that and do something so the data isn't lost incase it ever happens
i can put the class the statistic is supposed to be cast to in the enum constant and make casts with that
can you cast if you have a class object?
Uh wym?
let's say i have an Object o and i want to cast it to an Integer and I have Integer.class
Oh yes
oh ye just found it
Class::isInstance and Class::cast
aight thanks
Altho for primitive types, check if the object is an instance of the boxed type and then convert using the specific methods like intValue() etc
so methods like Integer#parseInt() and so on
Oh if you parse from an input sure Ig
I was just saying don’t do:
var isPrimeInt = int.class.isInstance(obj)
if(!isPrimeInt)return
var asPrimeInt = int.class.cast(obj)
Instead use Integer.class and convert with intValue, Boolean.class and convert with booleanValue etc

Conclure do you know why jedis produces JedisDataException?
really
But send the stack trace + code Ig
Im burning my brains
here
You use the pool wrongly
are there any problems when mass cancelling spawn events?
Depends on what you define as a problem, but its usually not a great idea
Why when I do this when I have bad omen X I don't get the effect that's in the if statement?
PotionEffect effect = new PotionEffect(PotionEffectType.BAD_OMEN, 120000, 4);
player.addPotionEffect(effect);
Bukkit.getScheduler().runTaskLater(plugin, () -> player.removePotionEffect(PotionEffectType.BAD_OMEN), 2L);
if (potionEffect != null){
player.addPotionEffect(potionEffect);
}```
Dont higher amplified effects override lower?
yes but the player doesn't have any bad omen effects when the line that's supposed to give him bad omen is executed
Assume you are a tree planter, your job is to plant 50 plants and make sure they grow, that will consume energy. Now let’s say I come here and yeet those plants as soon as you plant them, now you will run around constantly plant new plants while I will be constantly yeeting them. It becomes an unnecessary fight ergo unnecessary energy/resource consumption.
so it will continue to try and reach a certain limit of mob spawns and when I cancel the event it will retry
Exactly
got it, thanks
no, people call what I do static abuse
Nah but people often mistake utility methods for clumsy static methods and helper methods
Yea but in regards to your original question
So what do i have to do?
Use the pool correctly
Hmn
try-with-resources when using JedisPool::getResource
How ould be corrected?
Ok, and them?
Wym?
try (Jedis jedis = pool.getResource()){
jedis.blah()
}
for the statistic thing i said above, do I have to create a class that looks something like this
public class PlayerStatistic<T> {
private final Class<T> clazz;
public PlayerStatistic(Class<T> clazz) {
this.clazz = clazz;
}
public Class<T> getValueType() {
return clazz;
}
}
and then create another class with all the constants? example:
public class PlayerStatistics {
public static final PlayerStatistic<Integer> XP = new PlayerStatistic<>(Integer.class);
public static final PlayerStatistic<Integer> LEVEL = new PlayerStatistic<>(Integer.class);
}
or is there an easier way?
YE
That doesnt fix it
Literally does
Im still getting the ex
public <T> T getStatistic(PlayerStatistic<T> statistic) {
return statistic.getValueType().cast(statisticsMap.get(statistic));
}
``` so i can have a method like this
Of course you have to consume the resources in a correct way
Look code please
I have alredy use try
I have added to my code and doesnt ork tho
n the new code i added
But happen the same exception
I also read because im pubkishing and reading the same time
Could be that?
Idk might be also
Anyway when you subscribe on a Jedis instance it’s gonna block
So iirc you cant publish
Hence why you should be using the pool correctly
You use getResource for every new command
one for publish, one for subscribe
And you enclose it in a try-with-resources to lend the resource back once used
Mnnn a library on github work perfect with 1 pool
How can I get the CPS of a player?
Server log error: https://paste.md-5.net/kahocusomu.sql
Code: https://paste.md-5.net/poceqoceku.java
You cannot
Yes but that’s not the fucking point
It’s the damn resources in the pool
Not the pool itself
If someone could help me cause I dont know what I did wrong
I found this but I am not sure if it can works. https://www.spigotmc.org/threads/player-cps-count.141362/
Altho yes the pool by default is badly configured
I thought that redis was NIO
If you use the pool lol
You just keep one instance around
That’s not what using the pool is
And no it’s not really nio
I dont understand the pool meaning so
It’s more able to be used in a multi threaded environment
google the pool design pattern then
bad formatting in your yaml
?
It doesnt work as i expect
No, you don’t know how to use the library
Server log error: https://paste.md-5.net/kahocusomu.sql
Code: https://paste.md-5.net/poceqoceku.java
Config: https://paste.md-5.net/evohekepej.sql
A good redis would be a NIO allowing to publish and subscribe at the same time
bad indentation
Once you have a connection registered with a subscriber it can’t do much else iirc
So redis isnt based on NIO?
So you need another connection if you wanna publish
Hence why being able to use the pool correctly is a prerequisite
Okay, looks shity the design be mye
What
Ho reade works
Do you know how I fix it to make it like its supposed to be?
A good one, will be able to publish/subscribe using the same connection
Idk
Basically a NIO (Non blocking io)
Redis didn’t do it that way
Yes but you can achieve nio if you use the library correctly
But how
I dont understand you
orry if sound im trolling, but really i dont undertand
Literally
try (Jedis jedis = pool.getResource()){
jedis.subscribe(blah);
}
try (Jedis jedis = pool.getResource()){
jedis.publish(blah);
}
YAML Error.
- The design pattern, object pool
- It says this in their documentation
why 2?
If you would have read the documentation you would have found an example of how to use it correctly
Ohh ok
I catch it
I need one Jedis jedis for publishing, and another for subscribing?
Myes altho I suggest using the pool rather than caching 2 instances
Sure they’re made to be long lived
But the pool can achieve some internal optimizations
what it a pool?
JedisPool
Maybe i dont understand that so then i dont understand anything
A pool manages several expensive objects, might reuse them if necessary
Just google what it is
Ahh that why i cannot publish and subscribe with same shit
I cannot open google
Literally doesnt update
and/or a different search engine?
win 10+ linux
edge
do you not have ie or edge
microsoft edge
I dont have any else, because it not either windows nor linux
It a mix of the two together
??
... what distro?
I dont know the name, i think its arch
Because i can install things as linux and windows
That’s probably how you gonna have to do it
I think arch comes with wget bundled
I would have several static factory methods for the primitive types tho
Just to make life a bit easier
Finally google opened
🙌
Conclure
Yes
yea i probably will make them just for doubles, ints and longs
Also why is blocking the resource, if im subscribing in another thread
Jedis poop design
Oh that why
Lettuce got it differently
One async view and a sync view, so you can choose if it should block or not (current thread)
I would use Lettuce but the listener oblise me to inherit all methods
I dont like that, having innecessary things
That’s a subtle reason to stay with the inferior alternative
Conclure if using lettuce in async() i cann publish and subscribe at same momment right?
Yeah idk why they chose it that way
No it’s redis
?not-working
It’s not the libraries’ fault
Yes
Yeah a bit clumsy perhaps but that’s how they do it, I believe they had a pretty solid reason as to why but I don’t remember it by heart
Im still trying to jump into spigot netty instance, but the spigot-jar is so amazing that doesnt have a getter for it
Which class?
Uh let me look that up for you once I get home
I need to jump specially into the Boostrap
Because i want to register a cutom channel handler
So as far spigot works on their channels, i do my stuff in another channel
And sorry for taking your time
No worries I’m not really doing anything rn
What's the best way to detecting when/where another plugin deletes a chunk? ChunkPopulateEvent?
Hey, whats the ebst way to create per player entities like armorstands
Are you doing an entity follow each player?
What exactly does worldedit do?
//delchunks is a lot faster than simply deleting all the blocks in the area
Actually, probably best just to dig into their repo for that answer
No but I need to make armorstands with things on their heads and animate them
isnt it just removing the blocks?
I think its doing something else
Basically NPC if im not wrong
possibly targeting a region file or something
checks its impl then
Nah no AI just animations like rotating
just an armorstand that a specific player can see
ohh ok
I mean... that's definitely one way to do it...
https://github.com/EngineHub/WorldEdit/tree/master/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil
Seems like a pain to detect though
Also, do any other plugins do stuff like that?
i guess just load the old world instead of the new one from time to time
so different world files
Seems they also do this
idk how to code it but probably messing around with world creators idk
i guess this is the basic thing
https://www.spigotmc.org/threads/how-to-load-a-world.79261/
I am trying to get mobs to stay within a certain bounding box or area
I have tried CraftCreature#getHandle#getNavigation#moveTo whenever they move out of the bounding box and gave it the center of said bounding box. its not giving me any errors and its not making them stay inside tho...
Is there a way to check if a player has his own inventory opened? I thought that if (!(event.getPlayer().getOpenInventory() instanceof PlayerInventory)) would be good, but as I understood, if you don't have any kinda of inventory opened, the method getOpenInventory() returns the player's inventory anyway.
There is no way to check
The client no longer informs the server when opening or closing their own inventory
Only for inventories not attached to the player
So there is no packet sent by the client to spigot that fires back like the OpenInventoryEvent?
Don't think so
Well, thanks btw.
you get Click and Drag events but no open
Yeah I said OpenInventoryEvent as example referring that Spigot knows that you don't have your inventory opened.
Yep, it has no Clue if its just the Player Inventory
It doesn't really need to know. It only has to action something if a change is made
an additional world to the 3 main ones, or one of the mains?
random seed, or reset back to the same world every time?
then unload the world, delete its files and createWorld
?paste
This should attempt to delete it async https://paste.md-5.net/okudujixuz.java
you just have to create the world if its successful
file locks
it keeps trying for 50 seconds to delete teh world
you can reduce that
but it's to allow everything to release any locks it has on any files
after line 16 you'd create your world again, or call a method in your plugin to do it
just be sure to not allow your plugin to attempt any access of the mining world while its being deleted
Hello, I wanted to create EventHandler that will make smth like this:
After right click with item in mainhand on the block Sand then change this block on to another one.
The problem is that i want to use oraxen(custom items/blocks plugin) item for this and to create that in code i need to create firstly item stack and how i can check if player have this item in main hand?
public class Archaeology implements Listener {
@EventHandler
public void SandBrushing1(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block block = event.getClickedBlock();
ItemStack pedzel = OraxenItems.getItemById("pedzel_archeologiczny").build();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || block.getType() != Material.SAND) return;
if (player.getInventory().getItemInMainHand().getType() == Material.SHEARS) {
BlockMechanicFactory.setBlockModel(block, "blok_srebra");
}
}
This is how I'd probably do it. This way you just check isOpen() before any attempted access of the world. https://paste.md-5.net/buruzebeza.java
essentialsx depends in plugin.yml? the name?
i thought it was just Essentials
or are essentials and essentialsx two different things?
i didd it with x smh
you might just want to look in their plugin.yml in the sourcecode lol
essentials without x is legacy
right here its just Essentials
https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/main/resources/plugin.yml
Hi! Can somebody help me with a question?
thanks
yes
?paste your code
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
only if you ask the question
Okay, so.. I'm trying to create an inventory menu
https://paste.md-5.net/ujalidofog.java
yes
you have to wait a bit until the files were saved
yeah, thats not going to work
everything works fine until somebody opens the menu too
and its not the same
like... not the same inventory
yes, your code is very different to mine. you are not waiting for the world to unload
i forgot but i guess you have to create a new one
ignore
static ItemsMenu itemsMenu = new ItemsMenu();
i tried to do something
How are you calling ItemsMenu? Because if you make a createInventory call in the constructor, then create a new instance of ItemsMenu, the inventory will be different.
Player player = (Player) sender;
ItemsMenu itemsMenu = new ItemsMenu();
player.openInventory(itemsMenu.getInventory());
?scheduling
you are just testing the world != null
i know what are u saying
You are not waiting at all for the world to unload before you try to delete it
?
You need to create it somewhere that won't have multiple instances. Or, keep better track of your instances by putting the inventories in a map that's tied to the player.
public static void
You need to look over this code and see what it is doing https://paste.md-5.net/buruzebeza.java
I have heard of this keyword before. I wonder why you are trying to avoid if the goal you want to achieve is basically ideal to make the field static
s a t i c
Is EntityDamageEvent called whenever EntityDamageByEntityEvent is called (not programatically)?
yes iirc
pubic satic void maiiine
string argsssss
makes main method final 🤓
classic jurvur
i'm sorry, i was wrong, the thing is even if the inventory is static, this method
public Inventory getInventory() {
return itemsMenuGui;
}
will not be static, i mean i will have to create an instance anyway
sorry for my bad english
^^^
Like, you want to make this "static" without it being static?
instance methods can return static members just fine. only the other way around won't work
You could add a public static "Class" getInstance() { return instance; }
if that's what you ask
just make "itemsMenuGui" static and that's it. and create the inventory directly in the field declaration, and get rid of the constructor
like this?
return itemsMenuGui;
}
no
like this
private static final INventory itemsMenuGui = Bukkit.createInventory(...);
@Override
public Inventory getInventory() { return itemsMenuGui; }
Uh oh... static is not the cleanest way to solve this. ngl.
ohhh, let me try this
well if its only one instance of the gui dont see why not
I really don't understand the point of the question
You're going to need the constructor anyways
thaaaank uuuu ❤️
they always want it to return the exact same inventory, so why not
if two people are opening the same inventory, they can move eachothers stuff or am i wrong?
like trading gui
yep
well... do u mind telling me how? 🥺
ItemsMenu menu = new ItemsMenu();
player.whatever(menu.getInventory());
player2.whatever(menu.getInventory());
Am I wrong?
from my experience; both players will be able to move stuff
if ItemsMenu#getInv is returning the same inv
well... im using a command to open the menu so every time someone used the command another instance is created
ItemsMenu menu;
public XCommand() { menu = new ItemsMenu(); }
pubic void onCommand(...) { player.openInv(menu.getInv()); }```
then just save your inventory in a field
instead of recreating it everytime
Because static objects are something thats more procedural then object oriented. Another problem is code Implicity -> You wont know when a static variable is instantiated and whether or not it will be instantiated before another static variable. They are instantiated when the classloader "touches" the class for the first time. And this could happen before bukkit is initialized, leading to a nasty classloader excepion that is really hard to debug.
but their inventory never accesses anything from outside
Bukkit.createInventory(...) might throw an exception if its being called
too early.
Imagine if another plugin would do classpath scanning early on for Guice or something similar. Then the class might be initialized before bukkit is done loading properly.
public class Test extends JavaPlugin {
static {
Bukkit.createInventory(null, 9);
}
}
Even this works. and I doubt you can create it any earlier
How woukd your class load before bukkit?
Well you may actually prevent that by busy waiting, but yep, it's not recommended to use static methods
Oh nvm
cuz the classloader loads your class earlier?
In this specific case it might work. But its bad practice nonetheless.
Also the class can be touched before bukkit instantiates it.
but how to do it without static?
but how? when I start spigot.jar then spigot decides what classes get loaded when. even when setting to load: STARTUP and creating the inventory in the static { } block it works. how would it ever get loaded even earlier?
@rain echo
I already told you. save your inventory in a field
also i need exactly the same inventory for events
and then simply use that field instead of recreating your inventoryholder everytime
ok ok
wondering myself now how a plugin could possibly get loaded before bukkit when its bukkit that loads the plugin
let me try
yeah I wonder too
Maybe by Unit Testing, or another executable loading the plugin, e.g. an automatic updater
Try creating a scoreboard there
well getScoreboardManager() is annotated with @ Nullable so noone expects it to work everywhere
Then why not use a code style that will always work instead of only sometimes?
I didnt say that it's super awesome to create an inventory in the static init block of the main class. I just said that it's absolutely no problem to do so in this case
and just because something else might not work doesn't mean I shouldnt do this
But it's a bad practice
it's bad practice to initialize a static field somewhere?
And it's also resource expensive
Yes
constants for example. We also have strictfp which is pretty much useless.
how is having class members more resource expensive than having instance members?
Because the static methods are always in there, they are technically never deleted by the gc
leading to, in some cases, memory leaks
it's also more difficult to debug when using static methods
.-.
so you think it's better to recreate the same object over and again? they said that they will need the exact same inventory for every player every time they run the command. how would it be better to recreate it everytime instead of just keeping the same thing around?
I am not
Well what's the use case in question then
someone else was doing something with inventories
and they needed the exact same inventory all the time
If it is literally always going to be the same
I told them to store it in a field but I also saw nothing wrong in making it static on their inventoryholder object
Hello
Having it be static isn't really an issue
How can I apply vine to a Block?
I mean the same goes for singletons.
question still is when that inventory is initialized
Set an adjacent block to a vine
I cannot appl yit to the current block?
And make it set in the correct direction
not obviously in your control
I have the direction
No, because that's not how vines work
Oh darn
You changed the whole point of the answer to sergiu
You can just create a non static object and you don't have to create it again and again, and it's not static
They're not metadata on a block
I have just tested to create an inventory in the main class' static init block with "load: startup" and even that worked
They're another block adjacent to it
I see
oh
But if you want to apply vine and you have the block and direction
that is neat then
It should be something like this
So I need the blocks to be in front
scoreboards won't work that early though
anyway some people hate "static" stuff for no reason, all the time. sure it's not always appropriate to use, but saying it's bad per se is stupid. anyway I'll continue my citrus fruit production in anno now
to whom?
Block block;
BlockFace face; // Assume these are populated
Block vineBlock = block.getRelative(face);
BlockData vine = Material.VINE.createBlockData();
((Directional) vine).setFacing(face);
vineBlock.setBlockData(vine);```
This should work
Sure. But for other cases (like scoreboards) this is not the case.
Static is ran indeterministically which is not something you would want.
I don't get the reason why I shouldnt do X just because Y wouldnt work
Okay anyone will make it for me? I need that block after right click with an oraxen item in hand will change on to another block.
Ofc i'll pay for it, because im too tired today of trying.
If someone is interesting then dm me
your world is only brewing up to 85%? Yeah I would be upset too. I think you wanna ask in #help-server instead?
on
no*
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
so how are you brewing your world?
It's not bad to use, it's a bad practice to create a singleton program when you can avoid it. It's a bad practice to use static for everything.
Yes, you can use static to create an inventory that it will be always used, but why using static when you can just use an object
You should know when and why to use static, again, for this inventory problem it's not bad at all, but I've seen horrible codes because of the use of static for everything. Did I explain well?
Because X and Y are in a Set S
So why not choose an approach that works for every
element of S instead of for only a specific subset of S.
Consistency is important here because it reduces the amount
of cases you have to think about.
noone said anything against that
i can't finde any that will be online for now and i can't post on spigot in forum because i'll not post 20 posts
noone said "use static for everything". I have said "use static for class members and non-static for instance members"
and that's exactly what it's for
you won't find anyone here either. you'll more likely get kicked if you keep asking here because that's what the forums are for
okay thanks for advice
oh i'm on 1.12 so I don't have blockdata
rip
any adjustments I can make
Do you use a custom chunk generator?
What would be the equivalent of BlockData?
MaterialData
nvm, my point is just don't overuse "static" and you don't so it's no point arguing hahahah😂
bro
yeah my point totally is "lets overuse static" lmao
I think you should learn to read a bit better
have a nice day 🙂
lol
To be fair you could dependency inject it
But unless the project is very large, dependency injecting it wouldn't make a difference
Step 1. generate random coordinates
vineBlock.setType(Material.VINE);
our last "conversation" topic was that static is for class members and that non-static is for instance members. i don't know how this obviously true statement (because that's how the JLS specifies what "static" is), leads him to the conclusion that I love to overuse this keyword.
I got amazed by ur rudeness lol, still, no point in arguing
I don't think I was rude
Choose one
b.setType(Material.COBBLESTONE);
Block vineBlock;
if (facing == BlockFace.NORTH) {
vineBlock = b.getRelative(BlockFace.SOUTH);
} else if (facing == BlockFace.SOUTH) {
vineBlock = b.getRelative(BlockFace.NORTH);
} else if (facing == BlockFace.EAST) {
vineBlock = b.getRelative(BlockFace.WEST);
} else {
vineBlock = b.getRelative(BlockFace.EAST);
}
vineBlock.setType(Material.VINE);
vines.add(vineBlock);
What would be wrong w/ my vine block?
500k? 10k? 30 million? doesn't matter that much
Why would you use a bunch of if statements like that
And what is vines
why don't you use BLockFace.getOpposite?
arraylist
don't have it in my version
For real
what version are you running
You do
are you on 1.4?
1.11.2
tf
then you have it
I wouldnt attempt to generate one outside of the ~30 million. Anything below should be fine
Why would you use 1.11
I just checked
better question, why the fuck are you running 1.11.2
BlockFace.SOUTH.getOppositeFace
And BlockFace#getOppositeFace exists in that version too
Im still wondering why you are running 1.11.2
yeah that's funny
like I expected 1.8
we keep it lit
you keep it weird
lol
whats the actual reason tho
1.8 is at least understandable because some people get confused by differentiating left and right so they prefer having only one hand
I mean some people are even using 1.15.2 or 1.16.3 like wtf
its the step before the new api change, so from what I know people think its the best performing later ver
https://cdn.rackdevelopment.tech/img/2QhposIvJO.png I was gonna point out on this
version after 1.8 with the features from 1.9~1.12 which is stable
1.11 isnt even on there lol
Oh 1.8 stepped down from 7.8% to 7% since the last time i checked. How delightful to see.
shared hosters
probably ltt
^
for example shitty hosters running openvz
that makes sense
I mean many epycs have 48 cores, so with hyperthreading itll be 96
what method should I use to change the BLock to having a vine on it?
I can imagine that the "free" hosts run like 4 docker containers per core on an EPYC. So one CPU and ~400 servers.
i wish we could see a difference from these graphs to like 3-5 years ago
yeah lol and then people wonder why their server is so shitty
are you sure you're even setting the correct block?
because if you use setType, there should be a vine. unless it immediately drops again because it "can't go there" for some reason
e.g. because it's mid air
Yeah. Would be nice to see the plummeting of 1.8 in a graph.
ya
for (Block b : blocks) {
b.setType(Material.COBBLESTONE);
Block vineBlock = b.getRelative(facing.getOppositeFace());
vineBlock.setType(Material.VINE);
vines.add(vineBlock);
}
why set it to cobble
So blocks contains the block I want to apply the vine to
oh i see
i'm building
ya
lemme print pos of the vineblock
ok
all the locations check out
so ig the vineblock.setype isn't working
Show the whole code pls
try setType(type, false)
that is all code
other part before is just doing a loop throuhg
and grabbing blocks
to apply wall to
whats "blocks", "vines", "facing" and how are they used?
Thats far from everything
if that's all the code, then you'd get many compiler errors
No. It doesnt matter. But your server will have to handle a lot of chunk generation.
What is your overall goal? Because i might have some suggestions.
wdym? you can drag all of those things whereever you want
do you actually mean gitHUB
fun fact there is an edit button so you dont need to spam the channel
or just git
you're running a third party git plugin when the ide comes with one?...
? why would that have it's own toolbar
you have notifications for this channel on?
no
that's the builtin github plugin I think
just spamming is annoying
I see, true
A few messages I dont care, but when you are getting like 5+ it can be annoying
As I said, that doesn't have its own tool window. It would be pointless anyway. You just use the normal git tool window
View -> Tool Windows -> Git
or Alt + 9
I would recommend to pregenerate a 10k x 10k world every month or a 3k x 3k every week.
That should be more than enough. Pregenerating prevents constant chunk generating when players scavenge the world.
Use a pregen plugin
let me guess. you haven't even created a .git repo yet
^
I would recommend mine but it doesnt have an api and im also too lazy to add one.
the "github plugin you installed" is the builtin default github integration by jetbrains
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
send a screenshot of your whole intellij window
iirc its default on the left
can you sometime in the future verify so we dont have to keep clicking these links
yeah prntsc is the worst screenshot site
custom for the win https://cdn.rackdevelopment.tech/img/lQ0J6E2a6A.png
just win+shift+s and ctrl+v
at the bottom, go to Terminal, make sure you're in the root folder of your project, then enter "dir -Force". does it show any .git folder now?
I like ShareX where I can just click print screen lol
it should look like this:
PS: If you use FastChunkPregenerator then you can set the world border and generate a world like this:
public void fullRender(final World world, final int radius) {
final FastChunkPregenerator plugin = JavaPlugin.getPlugin(FastChunkPregenerator.class);
final GeneratorManager manager = plugin.getGeneratorManager();
final Chunk mid = world.getSpawnLocation().getChunk();
final int midX = mid.getX();
final int midZ = mid.getZ();
world.getWorldBorder().setCenter(world.getSpawnLocation());
world.getWorldBorder().setSize(radius * 2);
manager.start(world, midX, midZ, radius);
}
I didnt know you made that 7smile7
Ive made it in two nights. Every semester break i have a motivation boost and write a plugin which i regret later because i feel the pressure of maintaining them 😓
I have a project that I'm just doing a small piece of every day
Sometimes it's a class, sometimes just one method, sometimes just a few lines of a method
Problem is that it's a massive project
If I did nvmnew Location(x,y,z).getBlock() and the block at that x, y, and z was air, would it return null?
Huge
Is there a way to set one's spawnpoint? like just a /spawnpoint command?
Sure
How?
I see a .setBenSpawnLocation, but what if they dont have a bed
ah ok
thanks
So I switched maven shade plugin to 3.3.0-SNAPSHOT and it seems to be causing config errors: Cannot load configuration from stream org.bukkit.configuration.InvalidConfigurationException: unacceptable code point '' (0x0) special characters are not allowed when i switch back to 3.2.4 the error disappears
Make sure to use utf-8 file encoding in maven
Also: Weird bug
already set
<properties>
<java.version>8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Why java 8?
for the plugin to support 1.8+
Then whats the reson to use 3.3.0-SNAPSHOT in the first place?
1.14
they were introduced in 1.13
.
oh
see the point of this was to add support for 1.8 xd
Backwards support is horrible. Future support is more reasonable.
So if you want to write 1.8+ plugins then your native version should be 1.8
well it supports things such as custom model data/itemsadder
That being said: I would drop everything below 1.13
Even below 1.16 for that matter.
80% of the playerbase is on 1.16+ anyways
7%
dropping everything before 1.17.1 is fine actually
not really
1.8 is dying out < 3
muh combat!!!!11
63% is on 1.18 or above
well your looking for the ease of it on your part 1.8 support is usually a pain in the ass it makes sense to pump out more plugins than spend the time you could make another plugin
rip whatever sad souls are still using 1.7.10
people do use 1.7.10
sadly
the 1.18.1 kids worry me more
what a random question
saw a guy on here asking about 1.16.1 lmao
I like to keep up to date and find new exploits its no fun to use the same old ones
well i can support 1.8 but like that wasn't the point of this at all so-