#help-development
1 messages Β· Page 2107 of 1
no, it gives you the block that's been hit.
where?
Or if you dont want that then your register method needs both register(Class<T>, GameType<T>)
i already sent you the link.
ik
right
what does that function return? think for a second.
oh I mean how do I check which block is hit
if(event.getHitBlock() == )
I'm guessing type erasure or smmin
well that's the hit block
you can check its type, location etc
lol, learn java
whats the code
you're not just gonna get all the answers
well shit you got some really bad guidance
I'm not here to babysit you and tell you what you want
π₯£
gotta check if the arrow even hit a block first, as the function can return null
you remind me of someone
who would that be
I mean my b jgeez
I mean you can also do that if you want to.
But then you need the Map to have different types
Map<Class<? extends GameType<?>>, GameType<?>>
yeah that's what I've tried to do
but apparently I'm providing a 'capture of' of the required type?
isnt it ? extends T?
You need the method to be generic
like this?
Alse the getType method will always return null
fixed?
Nope. Game is completely abstracted away in your class. You dont need it anywhere.
how do I make the method generic then
sorry, I'm not too experienced with generics
Okay so, I have a question.
Let's say that I want to have a 0.5% chance that a player gets an item upon mining a block.
How would you do it so it has a 0.5% chance.
are you providing the item?
The item can be whatever.
or just an item in general
like the normal break item
I'm confused about the "chance" part.
check if it's below 0.005
Use one of the random classes Java provides and use a method that returns a decimal.
Thereβs Random & LocalThreadRandom.
the chance that a random value between 0 and 1 is less than 0.005 is 0.5%
Oh yeah, forgot that part lol
But thank yall for the help!
π
?
This would be the approach for your GameType registry
@SuppressWarnings("unchecked")
public class GameRegistry {
private final Map<Class<? extends GameType<?>>, GameType<?>> gameTypeMap = new HashMap<>();
public <K extends Game, T extends GameType<K>> T getType(Class<T> gameTypeClass) {
return (T) gameTypeMap.get(gameTypeClass);
}
public <K extends Game, T extends GameType<K>> void registerType(T gameType) {
gameTypeMap.put((Class<? extends GameType<?>>) gameType.getClass(), gameType);
}
}
What event should I use when I want to see when a leaf disappears when I break the trunk of the tree
I tried using the BlockFadeEvent, but It didn't activate
declaration: package: org.bukkit.event.block, class: LeavesDecayEvent
the javadocs do wonders
But a better approach would be to have a method for the typed class:
public abstract class GameType<T extends Game> {
public abstract Class<GameType<T>> getTypedClass();
}
To reduce one cast:
public class GameRegistry {
private final Map<Class<? extends GameType<?>>, GameType<?>> gameTypeMap = new HashMap<>();
@SuppressWarnings("unchecked")
public <K extends Game, T extends GameType<K>> T getType(Class<T> gameTypeClass) {
return (T) gameTypeMap.get(gameTypeClass);
}
public <K extends Game, T extends GameType<K>> void registerType(T gameType) {
gameTypeMap.put(gameType.getTypedClass(), gameType);
}
}
oh I can literally just cast
anything wrong with this?
why do I need to pass in generics to specify the Game?
Hello. Why is the list empty?
private static List<Long> adminRoles;
public static void setupAdminRoles() {
System.out.println("adm: " + Main.getInstance().getConfigManager().getConfig().getLongList("Discord.AdminRoles"));
adminRoles = Main.getInstance().getConfigManager().getConfig().getLongList("Discord.AdminRoles");
System.out.println("adminRoles: " + adminRoles);
}
public static List<Long> getAdminRoles() {
return adminRoles;
}
[22:11:58 INFO]: [DiscordUtils] adm: [905508941230915684]
[22:11:58 INFO]: [DiscordUtils] adminRoles: [905508941230915684]
public static boolean isAdmin(Member member) {
if(member != null) {
System.out.println(BotController.getAdminRoles());
System.out.println(new HashSet<>(BotController.getAdminRoles()));
System.out.println(new HashSet<>(member.getRoles()));
return Sets.intersection(new HashSet<>(BotController.getAdminRoles()), new HashSet<>(member.getRoles())).size() > 0;
}
return false;
}
[22:12:01 INFO]: []
[22:12:01 INFO]: []
[22:12:01 INFO]: [R:Admin(905508941230915684)]
messaged should be pinned here
Mostly gonna be valueOf
@ivory sleet, can u help me, pls π
no clue
But scatter out some breakpoints or print statements and debug your software
but ye
adminRoles = Main.getInstance().getConfigManager().getConfig().getLongList("Discord.AdminRoles");
feels like a good point to start with
how does your config look like
Discord:
AdminRoles:
- 905508941230915684
well obviously, something goes wrong as your config doesn't fetch those values
how do I check if a player has a certain potion effect?
it does... but when I get it from the getter, it doesn't
Player#hasPotionEffect?
lmao
look at the docs
setupAdminRoles();
System.out.println("adminRoles: " + adminRoles);
[22:33:50 INFO]: [DiscordUtils] adminRoles: [905508941230915684]
nah, I posted it in the first message
literally not
Anyhow, for beginners, how about you sharing a larger proportion of your code base, it is fundamentally needed for anyone to assist you, especially when you ask us to debug state of your code
?paste
and where's setupBot invoked
@Override
public void onEnable() {
if(Main.getInstance().getConfigManager().getConfig().getBoolean("Discord.AsyncBotLoading")) {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> BotController.setupBot(configManager.getConfig().getString("Discord.BotToken")));
} else {
BotController.setupBot(configManager.getConfig().getString("Discord.BotToken"));
}
}
and your ConfigManager looks like?
how would i remove an nbt tag? I specifically want to remove the PublicBukkitValues tag
if(((LivingEntity) entity).hasPotionEffect(PotionEffectType.GLOWING)) {
any reason this wont work
if(member != null) {
System.out.println(BotController.getAdminRoles());
System.out.println(new HashSet<>(BotController.getAdminRoles()));
System.out.println(new HashSet<>(member.getRoles()));
return Sets.intersection(new HashSet<>(BotController.getAdminRoles()), new HashSet<>(member.getRoles())).size() > 0;
}
return false;
}
where is this invoked from?
pretty much impossible with bukkit
damn
but essentially get the nms stack, yeet the nbt entry and put it where it needs to be
pls help
Yes i have defined the entity
nvm it does
Do you need to actually remove the NBT tag server side or do you just want the client to not know they are on the ItemStack.
serverside
i want it gone from the item
Then NMS
fuck
Why do you need them to be gone?
triumphgui
well
the mf-gui is different each time
i believe matt has an option to avoid that
Using nbt tags to determine a button. Fking stupid.
no lol
i just have a specific item on display
and it gives that specific item to the player
im not even modifying said item
it just magically appears
To me it just looks like a PDC entry. You can easily remove those.
how do i do that
One moment
You just would need to store them in the give command with the format bukkit stores them, which is under PublicBukkitValues
Then each key under that would be your NamespacedKey value.
/replaceitem entity @p armor.chest minecraft:diamond_chestplate{PublicBukkitValues:{"yourplugin:foo": 42}} 1
found this at https://www.spigotmc.org/threads/tutorial-storing-custom-data-on-itemstacks-in-1-13-2.354283/
private static final NamespacedKey MF_GUI_KEY = NamespacedKey.fromString("minefallsbazaar:mf-gui");
public static void removeKey(ItemStack itemStack) {
if (itemStack == null) {
return;
}
ItemMeta meta = itemStack.getItemMeta();
if (meta == null) {
return;
}
PersistentDataContainer container = meta.getPersistentDataContainer();
container.remove(MF_GUI_KEY);
itemStack.setItemMeta(meta);
}
or that
mye, well getting rid of the entry requires nms iirc
i'll go with @ivory sleet's idea
because i dont wanna call the removekey method each time
try smiles idea
Because you said you wanted to remove the whole PublicBukkitValues section
private ItemStack itemStack;
public GuiItem(@NotNull final ItemStack itemStack, @Nullable final GuiAction<@NotNull InventoryClickEvent> action) {
Validate.notNull(itemStack, "The ItemStack for the GUI Item cannot be null!");
this.action = action;
// Sets the UUID to an NBT tag to be identifiable later
this.itemStack = ItemNbt.setString(itemStack, "mf-gui", uuid.toString());
}
public void setItemStack(@NotNull final ItemStack itemStack) {
Validate.notNull(itemStack, "The ItemStack for the GUI Item cannot be null!");
this.itemStack = ItemNbt.setString(itemStack, "mf-gui", uuid.toString());
}
@NotNull
public ItemStack getItemStack() {
return itemStack;
}
(default)
Why does this gui api add keys to their ItemStacks?
supposedly to identify the items later
"to be identifiable later"
i really dont
wait why is it adding it to the itemstack
Sry but again: Thats so stupid
it really is
i hope my entire plugin doesnt shit itself after ive done this
its just a massive pile of spaghetti
I would suggest using another GUI library to be honest...
Unless the wheel is an existing spigot plugin/api. Because those wheels are out of concrete and triangle shaped at best.
the only reason to reinvent the wheel is to get a round one
wheres the joke
i think this is smart
where if the item is the expected item it'll run certain callbacks
besides the nbt part, use pdc
So you mean outside of GUI usage in case it fails and someone moves the ItemStack out? Or what does "later" refer to?
bruh it uses inventoryholder
Interesting idea. Implementing IH and setting it as the holder of custom GUIs. But this prevents other IHs from obtaining the Inventory which is kind of important.
Why does everyone say it shouldnt be used?
i never understood that
because it may brick implementation
Is there a better way of handling checking inventories other than IH then? Cause my lib currently uses it, would be nice to change it
apparently you have just ::equals
well, users on the end of my API wont ever see that
so that's the only deemed disadvantage, mye
the backend of this looks nothing like normal java lmao
But front end for users is nice
the gist if abstraction init
https://github.com/Burchard36/BurchAPI/wiki/Creating-an-inventory
Finished docs for it last night actually
yeah its a FunctionalInterface api, same with commands too
?learnjava momment
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.
such that if you wanna change the implementation of your actual behavior, consumers wont (likely) ever get affected by it
I'll challange your puny API one day by writing an API with pure java bytecode. Provided I have enough time
lol
otaku detected hahahaha
yeah i do the holder check manually, so me setting the holder i never really would of saw something a end user would of needed from it
Most people use IH's to compared inventories anyways
mye
and do it
What does the Functional annotation?
FunctionalInterface?
Yup
just makes sure the interface annotated with it must only have a single abstract method
else it wont compile pretty much
Hmn
It's just something for the compiler like @Override
Didnt stand but ok
Only that the functional-interface annotation is actually visible at runtime
theyre nice tbh
been playing with them a lot lately
just played with annotations too last night and added em to the command lib
pretty much a must have imo :3
Yeah functionalinterface is incredibly nice for lambdas
Yeah I really love the flow of everything, works really nice with commands and inventories in spigot
Wonder what else i could transform ngl
Basically it guarantees that any interface which has the annotation can be represented as a lambda
Someone helps me to understand that and help me make a method to create a currency get player money and give/take money of a specific currency from a player https://github.com/lokka30/Treasury/wiki/Treasury's-Economy-API.
I don't recall that you can create a currency with that plugin
it is like Vault
Or well API, you must actually implement that currency in vault-style stuff
Don't recite the deep magic to me, I was there when it was written
Why not like
use vault
https://github.com/lokka30/Treasury/wiki/Treasury's-Economy-API
Anyways the project has a guide for the economy
Vault is kindof a pice of shit
because Vault dont support multiple economies
but its standard sadly
But after implementing Treasury for two of my eco plugins, it isn't that great either
What is so bad about vault apart from using doubles
that is extreme hard to understand and give strange errors in my compiler. i need the methods to give/take/get money of a specific currency i created
this maybe but i thought you could of registered multiple tbh
Oh that is straightforward
?paste
this is the class i have created to attempt to register XP custom economy
but i have NO IDEIA
on how i get currency from that class
and start to do things like giving xp to players
Oh you want to register an currency? That is not possible last time I checked - I am afraid
Or well actually there is a really stupid hack that would allow that but uh it's a hack
this plugin API in my opinion is very bad documented
yes but idk how i register my currency with that clas
time to add an economy system to my API and overrun vault
Only issue is that you have no control over the currency
Yeah, I think you'd have to go with my hack
make it public please
i really need a api like Vault that supports multiple economies
is the author of vault even around anymore
Basically you'd need to implement EconomyProvider which will basically redirect any calls to your currency and otherwise passes through the original impl
you could PR additions to that repo
I have https://github.com/Geolykt/EasyConomyAdvanced/tree/geolykt-prod/API/src/main/java/de/geolykt/easyconomy/api however it is a bit dusted
Technically yes, but you won't see many changes to the repo
Right now only really small changes will see the light of the day
Use Java 15
It does not, but it helps me indefinitely given that I can say "lol, xyz is null"
so what are the line numbers?
1.7.10 π
the snippet
bruuh
π€¦ββοΈ I can read you know
wtf is bSpigot
Punishment.getPunishment(x, y) is null
lowkey that that stood for bstats or some shit
nah just joking
I just got trolled
That being said without context I would think that you would refer to the site that offers premium plugins at a moral cost
what does data.getPunishments return?
pls help me
Also you should crank up your IDE's pedantricness to the maximum when you have nullabillity annotations
World#dropItem iirc
and if you want it after a listener is executed
run it in a bukkit task
then you should get a StackOverflowError
world.dropItemNaturally(loc, Material.SPECTRAL_ARROW);
so why wouldnt this work?
because thats a material
not an ItemStack
oh ok
only on mobile
they need to show more love to discord mobile
anybody have any ideas on how to make it so that enderpearls can go thru fence gates if they are opened
might be of help?
i would assume you could raytrace through the fence gate
and get the block on the other side
Have you tried just cancelling the hit event?
I have not
if you cancel teh hit event, you shoudl then be able to take the pearls velocity, normalize it and add it to the pearls location
?paste
So I would get the pearls current velocity then make the velocity higher so it goes through the fence gate as projectile.enderpearl hits the fence gate, smart
no
You are adding a nomalized Velocity (Vector) to the pearls Location, putting it the other side of the gate
Okay that makes sense
How can I get the title of an inventory created in InventoryClickEvent?
how can I create my dad with spigot?
I tried with Inventory.getTitle()
event.getView()
But getView what do
it has a title
get mouse inventory?
event.getView().getTitle()
And what means with view
π€¨
can I at least create my brother with spigot
Ok i will try
hey, does anyone know a way to change whats on top of the tab and whats down the tab?
i cant seem to find anything
How do I get the location of an enderpearl
its an entity
for wherever it hits
check when an enderpearl is thrown
thanks
and when it like dies
NullPointerExcpetion at line 1 world is null
event.getEntity().getLocation()
but I tought nobody would be that creative lol
onEntityDeath
u check if its a pearl
get location

he will just drink milk
what he went to get...
SO
anyone knows how the change the top and the bottom of the tab?
like that for instance
how do I add potion effects to a player?
Cme?
Ohh
Its thrown when you try to modify a list by removing elements in a for loop
Yep, you can just have a toRemove list, then in your for loop add to that list what you want removed
Then call thatOtherList.removeAll(toRemove)
Or you can use iterators, either or
First solution is slightly more simple
like this
you can use iterators in a for loop
thanks I think I got it so far for a startup getting velocity vector will be hard since I have never done that before but I can manage to figure it out
this is kinda confusing
for (Something something : thatIterator) {
if (iterator.hasNext()) {
iterator.next(); // your object
iterator.remove()
}
}
List has a iterator() method
wait my for loop was fucked
sec
ignore toRemove warning
wtf
its just bc its a empty arraylist
are u using intellij and which plugin to have a picture as a background
Oh thats built into IntelliJ
Backgrounds are a feature of the IDE itself.
sec
how does one get the name of a group in luckperms
Hi I'm trying to make a custom .yml file but I can't I already looked on google I also asked for help yesterday on this channel but I always find errors, can you send me a guide?
I'm quick with it
just do note
it takes a while to get transparent png's working
took me a while to figure it out
I dont need transparent image
youll want one trust, its rather annoying having the full screen be a picture
this bg kind of matched my theme too
spigot has a guide
sec
it really did
Using theyre API?
Hi. I know this is super long ago, but did you ever figure this out?
What does the getKeys(boolean) does?
Allr thanks
key1:
key2:
key3:
say you have a file like this
if you use true
it will get ALL of those
You might be able to compare the #getFrom() and #getTo() values to calculate direction, but I'm pretty sure there is a simpler way.
thanks
if you use false, it will only get one
EG: getConfigurationSection("key1").getKeys(false); it will only provide you key2 and not key3 as well
but if you used true, it would return key2 and key3
This won't tell me if they are walking backwards.
#getKeys(false) returns all subnodes that belong to that parent.
#getKeys(true) returns all subnodes and their children.
It can if you compare the value relative to the direction they are facing.
like i just need to check and see if a player is in a group
yes
So here if using getKeys(false) will return just test-1?
Items:
test-1:
Display: "&6Test"
Material: Compass
Lore:
- "&7This is a test item."
- "&7It has a lore line."
- "&7It has another lore line."
Slot: 1
Command: ""
test-2:
Display: "&6Test"
Material: Compass
Lore:
- "&7This is a test item."
- "&7It has a lore line."
- "&7It has another lore line."
Slot: 1
Command: ""
and test-2
^
Oh ok
should just be a name() or getName() method for the luckperms group object no?
Yea, but keep in mind that they all get added to a list.
Items.test-1
Items.test-1.Display
Items.test-1.Material
Items.test-1.Lore
etc
Items.test-2
Items.test-2.Display
etc
That what getKeys does. It returns a list of strings which represent a path.
now if only i could get the keys for my house that i lost last night
tried both true and false, but the path to find my keys never returned a valid value
That's because you used the wrong house as the path. π
getConfigurationSection("my-house").getKeys(true) instead of getConfigurationSection("my_house").getKeys(true)
That what does if getKeys(true)
Yea, I meant to edit that message but didn't. :3
it is stupid question i doubt there is an easy way but is there maybe easy way to tell if right clicking the target has any action?
I made custom scroll thingy and i dont want to to active when i right click say button or open the door
getPlugin().getItems().getConfigurationSection("Items").getKeys(false).forEach(name -> {
getPlugin().getLogger().info("Loading item: " + name);
ConfigurationSection section = getPlugin().getItems().getConfigurationSection("Items." + name);
section.getKeys(false).forEach(value -> getPlugin().getLogger().severe(name + " key " + value));
});
So that will display every node and sub node? Shadow
Idk if my brain is working right, but I'm not used to writing streams/lambda. If you give me a few I can write out an example.
Allr
or maybe actually it would be easier to prevent default right click action if i try to use my scroll
there is a function for preventing default event action right?
i vaguely remember that
@sterile token
for (String section : getConfig().getConfigurationSection("my-section").getKeys(false)) {
// For simplicity's sake, make the full path a variable you can use later.
String path = "my-parent-node." + section;
// Access whatever variable you need with the path variable you just created.
getConfig().get(path + ".whatever-i-need-to-access");
// So if you need to get an integer
getConfig().getInteger(path + ".my-inner-path-to-my-integer-value");
}
Objects.requireNonNull(getCommand("store")).setExecutor(new LinksCommand());
Objects.requireNonNull(getCommand("discord")).setExecutor(new LinksCommand());
Objects.requireNonNull(getCommand("club")).setExecutor(new LinksCommand());``` how can i allow aliases of a command? this is npe-ing on load
Wdym by action. You can check if a player right clicked another player. Regardless of if they are holding an item or not.
i dont mean just entity, i dont want my scroll to activate on right click if i hold it and press on door, button, switch, trapdoor, etc. anything that has some action when i right click it
In your plugin.yml, you can do it one of two ways.
commands:
mycommand:
description: Give hugs to people!
aliases:
- myalias1
- myalias2
OR
commands:
mycommand:
mycommand2:
mycommand3:
description: Give hugs to people!
either that or the other way, cancel those actions when i right click scroll. so it either does default action or only my action. now say it opens door but also immediatly teleports me too
Then you'll want to check if the action was RIGHT_CLICK_BLOCK.
If so, cancel the event.
If they are holding a scroll.
How would I check to see if a thread is already running or not?
Also, you probably don't want to make new instances of the command each time you register it. Make a variable and pass it through.
Thread#isAlive() or maybe Thread#getState()
oh so i could cancel any right click default block action with this. noice, thank you
well I will do it tomorrow but i will note that down. I made some nice progress today partually cause of nice help i got here today
what about threadPool? ExecutorService
ExecutorService threadPool = Executors.newCachedThreadPool();
Future<String> futureTask = threadPool.submit(StartUp::doUpdates);
I'm executing this in my onPlayerJoin event, so I don't want this thread multiplying I only want to check if its not running then allow it to be used once
If you only want one thread, why not use Executors#newSingleThreadExecutor()?
you can do that?
Yea
so if another player joins that method wont be called because theres already an instance where it was called, and it wont work again until the thread is cancelled right?
Well, if you are calling the creation method in the onJoin method, then it will likely create another new thread. But, you could always call the #shutdown() method at the end of the method so that it gets deleted afterwards.
what do you mean?
If you wanted to route all extra onJoin logic to one thread, create it outside of the onJoin method and have an way to access it inside the scope.
yeah im not sure tbh
wait
ExecutorService threadPool = Executors.newSingleThreadExecutor();
if(threadPool.isTerminated()) {
Future<String> futureTask = threadPool.submit(StartUp::doUpdates);
}
Cant I just do this
So, you'd create a global variable either in that class or the main class. Executors#newSingleThreadExecutor().
Then you'd access that instance with the name you gave it.
ExecutorService threadPool = Executors.newSingleThreadExecutor();
public void onJoin(PlayerJoinEvent event) {
threadPool.whateverYouNeed()
}
if its terminated make a new thread else continue with on join
how do i use kyori minimessages to make a link with text
I mean sure, but wouldn't that potentially prolong the login time?
What logic are you trying to offload?
its supposed to be running a thread to look for changes from a mongodb changestream
then it recursively recalls another method that makes a new thread
however for my permissions node, when I join the server the players data is taken and put into mongodb cluster, the issue here is that the user gets no output of changes being made if they were just created, instead they have to rejoin
and I can freely make it as threads after so it works just fine but the issue is
whenever another user joins
a thread is made
so its going to keep stacking threads on the same method
Well Executors#newnewSingleThreadExecutor() runs tasks in order, so concurrency shouldn't be an issue. https://www.javaguides.net/2018/09/executors-newsinglethreadexecutor-method-example.html
But I feel like there is a simpler way to get a recently created value from mongo.
Yeah I'm not quite sure, hopefully newSingleThreadExecutor doesn't create multiple threads
It doesn't, but it will create a new thread if one of the tasks given to it fails. So that it can finish the remaining tasks.
Shadown im really confused with nodes and sub nodes
What about?
Do you remember my yaml?
The error is ocured because the file path you want to load not meet Regex pattern [a-z0-9/._-].
Yes.
Im creating an object based on each node and im still geting NPE
getPlugin().getItems().getConfigurationSection("Items").getKeys(true).forEach(name -> {
Configuration node = getPlugin().getItems().getConfigurationSection(name);
getPlugin().getLogger().info(name + " display " + node.getString("Display"));
});
Yes
oh omg
because a "spawnX: 15" is not a configuration section and will give you nle
npe
that's a value
I think you misunderstand what things are being returned.
.
Im rlly annoyed with sections
is "name" not already a configuration section?
I don't usually work with lambdas I don't know
A ConfigurationSection is really just a path. Paths in yaml are separated with the period symbol. (.) So if you have a node that exists under another node (aka a subnode), then you will need to add the period to the path.
rootnode.subnode
What #getKeys(false) does is return a list of subnodes that are under a parent node.
So in your example. You would have a list of sections that would contain test-1 and test-2
So which will be the code?
Yes that the first looping im doing here
You can iterate over that list with a foreach using a String.
for (String section : #getConfigurationSection("path.to.my.section").getKeys(false)) {
}
Why dont use lambda
clearer
I dont know why people doesnt use them
Didn't care to jump on the bandwagon.
what's the NPE complaining about
depends
well lambdas don't have type declaration do they?
Dont worry
yes they have
Jsut help me
node.get returns an object I think
I know but just to explain
That means that your path isn't correct.
Its correct lmao
getKeys(true)?
Apparently not.
My config its 100% okay i checked 10 times
what does the boolean actually do I never knew
Yea, it may be in the config, but the way you access it in the code may be wrong.
So how i can fix it?
Are you adding the dots to your path? (.)
If you want to access a subnode, you need to have them.
for (String section : getConfigurationSection("Items").getKeys(false)) {
ConfiguractionSection node = getConfiguractionSection(section);
node.getString("display");
}
you have to do
That its what i did without lamda
Wouldnt string section contain: "Items.each-array-node"?
Maybe find some library that mapping Yaml file to object, I would be more stable and faster solution
yes
A ConfigurationSection is really just a string. At least it can be converted to one with the #toString() override.
i dont have time
i have to finish it today
it says Configuraction
In your case, node is equal to the first element in the for each loop which is just test-1
is that in the code or a typo on discord?
Then, when it iterates to the next element, node will actually be test-2
So what can you do with that?
The following.
"Items." + node + ".Display"
Use that as the path.
That's the whole point of YAML
wait no i was right
Dealing with paths.
But why doing that if im getting the section?
"name" doesn't include the Items section
Because ConfigurationSection is just a complicated middleman for what is actually a String.
Literraly 2 line of code
getKeys(true) doesnt return Items.test-1 and Items.test-2?
Why if i want to get each node and sub node?
π€
#getConfigurationSection() takes a string as a parameter. That string that you give it is the path that leads to a list of sections.
That way, you can use #getKeys(false) to get each name from the list.
You can use that name to complete the path.
you can think of the "Items" section as a list, when you loop it, it only returns the subnode name, not "Items.test-1"
as does a regular array list
No, it only returns the names of any direct children within the path. IF you wanted the full path of all children, then you would use #getKeys(true)
What im doing lmao
π
I think personally using false is better
root-node:
subnode1: # This is a child of root-node
sub-subnode: 1 # This is a child of subnode1
subnode2: # This is also a child of root-node
sub-subnode: 2 # This is a child of subnode2
using a change stream how can you get one field from whatever table was updated in mongodb
you have more control and can directly see what the subnode name is without any extra steps
having to remove the prefix "Items."
Look code here and yaml file
List<String> playerNames = p.stream().map(e -> e.getName()).toList();``` You mean something like this?
im doing ConfigSection#getKeys(true)
just try to print "name" and see what it is
@sterile token
Items: # This is your root node.
test-1: # This is a child of Items
Display: "&6Test"
Material: Compass
Lore:
- "&7This is a test item."
- "&7It has a lore line."
- "&7It has another lore line."
Slot: 1
Command: ""
test-2: # This is also a child of Items
Display: "&6Test"
Material: Compass
Lore:
- "&7This is a test item."
- "&7It has a lore line."
- "&7It has another lore line."
Slot: 1
Command: ""
What getKeys(false) does is return a list of section names based on the path that you give. So #getConfigruationSection("Items").getKeys(false) will return a arraylist that contains "test-1" and "test-2"
If you had more sections, the name of the node would also be in that list.
It shown "Items.iterated", so "Items.test-1" and "Items.test-2"
π
did the code work
I say it im getting NPE when doing section.getString("display")
Because you aren't separating it with the dot
But using getKeys(TRUE) doesnt return the full path?
π‘
Why do you need #getKeys(true)?
I mean like this :
MongoChangeStreamCursor<ChangeStreamDocument<Document>> cursor = col.watch().cursor();
System.out.println("Watching stream");
ChangeStreamDocument<Document> next = cursor.next();
assert next.getUpdateDescription() != null;
System.out.println("Database has been updated! --> " + next.getUpdateDescription().getUpdatedFields());
BasicDBObject query = new BasicDBObject();
I get the updated fields that get updated but what I want to do is get the table that was updated, you can do that by just using getUpdateDescription() method, however, it returns all of it as a json and I cant compare an entire set of json objects with a player that is currently on the server, I need to get the single string text found in "name" for whatever was updated and then I need to compare and see if the name in the updated field is equal to a user that is online on the server,
https://paste.md-5.net/uqesaquwuq.cs
Just use #getKeys(false)
And then take the value that's given to you and put it as part of the full path
I dont want to have harcoded code using "Items.blabla"
How else do you expect to get a value from your config? You need to provide a path.
If you don't want to rewrite it, make it a variable.
So you only have to change it once.
verano you know that you won't get a npe from the GetConfigSection method even if it's null
it's only until you use the section
Listen please:
for (String name : getConfigurationSection("Items").getKeys(true)) {
// When debugging to console name is shown as: "Items.test-1" and "Items.test-2"
}```
That's cause your using #getKeys(true) >.<.
USE #getKeys(false) PLEASE
anybody know?
What the reason? I want to get each master node and node
overcomplicating
Holy mommie its diff to explain
you complained about hard coding as if you would change it in the future, but you would need to come back anyways for the getKeys() line?
Because #getKeys(true) returns all paths. Unless your subnodes are all the same type, it wouldn't work. You have Strings, numbers, and a list. How do you expect to iterate over different types of data like that?
You don't.
Especially with a foreach
You need the same type of data to begin with.
does true loop children as well?
Yes
ah that's it
That's why you use #getKeys(false) and use the string it returns to make the full path.
So code be:
getPlugin().getItems().getConfigurationSection("Items").getKeys(false).forEach(name -> {
ConfigurationSection node = getPlugin().getItems().getConfigurationSection("Items." + name);
getPlugin().getLogger().info("Loading item: " + name);
getPlugin().getLogger().info(node.getString("display"));
});
?
yes
you are discussing this issue over 1H XD Plz use https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml to save your time
Well hold on
Oh lmao i didnt see the time
You're close
he did put "Items."+name?
Yea, but if he wants to access the subnodes, he'll have to add onto the string.
So "Items." + name + ".whatever"
Also, I already did. #help-development message
no but if you have the ConfigurationSection object you can call #getString() and that doesn't require a .
In the config as well?
yes
yes
Then it should work.
so now the code should work?
yes
this right?
anybody know a solution? would adding the updated description to a list be something that could work?
ye
Be paciente you are not paying for instant help
Try it and see. π
free the guy they just want some help
you're just calling getPlugin().getItems().getConfigurationSection("Items." + name); on the wrong ConfigurationSection.
it's as simple as
ConfigurationSection parentItemsSection = getConfig().getConfigurationSection("items");
for (String key : parentItemsSection.getKeys(false)) {
ConfigurationSection childItemSection = parentItemsSection.getConfigurationSection(key);
}
what i was doing lmao...
well my message is like 100 messages up nobody is going to see it anymore so I will pay for instant help, got cashapp?
Look the photo on top
you weren't doing that
open a thread
Holy yeath look on first photo
you weren't doing that.
look closely
at Theones example and your code
they were using the parent configuration section (Items) when getting the "node" object
Yea, turns out that the implementation for ConfigurationSection literally uses Strings.
Just use strings ffs.
whilst you were just getting the "name" section from the entire file, which doesn't exist
MongoDB Updated Field
Holy shit still getting NPE when doing section.getString("display")
Im so fucked stressed
Any real reason why you need to use lambda for that? Like, wouldn't it be beneficial to understand how it works in "normal" java first. Then convert it?
I understand how java works
Then why can't you just use that then?
Because im having section issues
Performance difference isn't that significant.
Then refer to the example I gave before. #help-development message
Still getting NPE
what's your code now?
getPlugin().getItems().getConfigurationSection("Items").getKeys(false).forEach(name -> {
ConfigurationSection node = getPlugin().getItems().getConfigurationSection("Items." + name);
getPlugin().getLogger().info("Loading item: " + name);
getPlugin().getLogger().info(node.getString("display"));
});
is the npe because node is null?
Its giving me npc when getting any value from node
Im so annoyed
And my code its exactly the same as yours
Literally just read my example. Like is it so hard?
It's not lambda, but holy fucking shit at least it works.
I cannot understand non lamda
But you said that you understand java????
Holy shit
I discovered the issue
I was always using the old items.yml file
π€‘
1 fucked hour
unfortunate.
Yes lmao
you could reuse some code
How do i compare itemstack with displayname and lore?
Its possible to do that on Interact event?
PDC is also another way
What? What version are you developing against?
when i do npm install module, does it install the dependency globally or >> ONLY << locally?
also, how do i disable this
im using the latest version of intellij
Pretty sure locally. I think you need the global flag for it to be installed globally.
Would appreciate some feedback on this.
single responsibility programming
i forgot the name one sec
SRP, SOLID
How can I remove an NPC from the tablist while keeping the skin
in fact theres been a few articles about it even being slower than for in some cases, still by minute amounts though thats not noticable
worldCreator.generator(new VoidGenerator());
final World world = Bukkit.createWorld(worldCreator);
this.world = world;```
This doesn't seem to be working...
Not sure why there is so much hype around them. Sometimes it's even more complicated to read. Sure, in some cases it can be way faster and far slower in others, but I care more about readability than performance most of the time.
System.out.println("worlds - " + Bukkit.getWorlds()); prints [20:49:36 INFO]: [Prison] [STDOUT] worlds - [CraftWorld{name=world}] (no void world).
most the times i only use them for one line method referances
eg
something.forEach(Something::doSomething);
Same. If it can produce the same results, still be easily readable, and is faster. Then why not right?
are you loading the world after this
Loading it how?
Does it not load after creation?
Also i think i needs a type of chunk generate to actually generate that world, not sure
No worlds dont get automatically loaded either to my knowledge
That's what this is
@Override
public boolean shouldGenerateNoise() {
return false;
}
@Override
public boolean shouldGenerateSurface() {
return false;
}
@Override
public boolean shouldGenerateBedrock() {
return false;
}
@Override
public boolean shouldGenerateCaves() {
return false;
}
@Override
public boolean shouldGenerateDecorations() {
return false;
}
@Override
public boolean shouldGenerateMobs() {
return false;
}
@Override
public boolean shouldGenerateStructures() {
return false;
}
@Override
public Location getFixedSpawnLocation(final @NotNull World world, final @NotNull Random random) {
return new Location(world, 0, 175, 0);
}
}```
There's no load world method though.. only unload?
did you try loading that world with multiverse by chance just to see if the worlds not invalid?
any1 knows how to make a player Invulnerable in 1.8.9
i used to do isinvulnerable
but apparently it aint a thing in 1.8.9
Multiverse Core loads it but it bugs out
I don't want to use any external API's or plugins for this- just the inner VoidGenerator and the world creation by itself.
IIRC youd have to cancel all damage events if that method doesnt exist
Cancel damage
o okay
How does it bug out?
any errors in console?
No errors, it just loads like 20 center chunks empty- then the rest have normal biomes.
I assume it has something to do with Multiverse-Core not getting the generator.
how can i open a powershell inside a phone?
What does this have to do with Spigot lol
can anyone answer my thread please? Been waiting a few hours
are you overriding the generateChunkData method in that class too, i dont see it
Is it possible to how-swap plugin code while server is running?
also you should be able to just teleport that player to that world once its created
player.teleport(thatWorldsSpawnLocation);
That method no longer exists I thought?
I made similar solution by myself. But by hot-swap I mean hot-swap without unloading plugin
Then no, not really
Yeah was checking java docs, i think i know the issue
You could potentially have classes that are dynamically loaded from a folder or something
But that's just a bad solution
What is it?
Why do you need such a thing?
Just use Skript (joke please don't)
because now I need to type /disable <MyPlugin> everytime I want to build my code
Literally just restart the server
.-.
Takes no longer than 8 seconds
I just type /plug reload -c <plugin> and it's done in milliseconds
but i need to type this
Not really
you understand my pain?
Your pain LOL
You could just have it as the last command in console
Click console, hit up, hit enter
Try adding that worlds name to your bukkit.yml
worlds:
world:
generator: PluginsNameInPlugin.yml
I know when i tried a world generator in the past, i had to add this to the bukkit.yml to get the generator to completely work (You can edit the file via your plugins code if it does)
And try just teleporting the player to that world when the worlds dont creating, should work just fine (i think)
What's the issue
Just detect if a file changes in your plugin folder and use PlugWomen's API (or a console command it if doesn't have it) which then runs the reload command
My Idea Is to just click build button in IDE and have new verison of the plugin on my server
World generates but doesn't seem to be recognized in the Bukkit.getWorlds() list
Everything looks fine, the world generates, the folder is there, yet it's not there.
Well, this is what I'm trying to figure out. Right now the PlayerDataManager updates player data and player preferences. The reason they are in the same interface is because my implementation.
The interface was originally going to be just player data. So I created classes like YAMLPlayerDataManager, MySQLPlayerDataManager, etc. I then added user preferences because it was easy.
Now that I think about it a little more, if I were to separate the preferences into its own interface, I would have two interfaces that nearly function in the same sense. The point of this interface is so that server owners can change what storage type they want to use and everything about the plugin will adjust accordingly.
So If by default, the storage setting is yaml then all user data and user settings will be stored in a per player yml file.
If the owner changes the setting to mysql, then all user data and settings will need to be stored in the mysql database.
If I were to split up my interface, would it really make it easier as I would now need a YAMLPlayerDataManager and a YAMLPlayerPreferencesManager as well as a MySQLPlayerDataManager and a MySQLPlayerPreferencesManager.
Would that really be a benefit? It seems like a weird form or redundancy or double work in a sense at least at the moment.
It's it's own world
Right I know
And that world is not loaded when you start the server, right?
But it's loaded when you first generate it?
or maybe would it be possible to send command to server console from IDE, what do you think?
Yeah
Worlds should get loaded when you teleport a player to them
You can add the world directly using Bukkit.getWorlds().add(yourWorld) iirc
Create it the same way you did initially
If the world already exists it will be loaded rather than overwritten
So you just act as if you're creating it
How do I load it?
Same way you created it
Oh fr?
Like I just said several times
world creator wont override when you use it if the world exists^
Whoops let's try that then
also dont forget this if the world generator stops working past the spawn chunks, i think this was changed in later versions of spigot though so might not be needed
I never had to use that
^ I don't remember that
You guys saved me, thank ya so much.
Is it possible to trigger java code before Application build in Intelji?
every single person really be making private mines these days
Ehh it's a commission
Not my fault :(
Oh also how do I make a player face towards a block?
Block block;
Player player;
Vector v = block.getLocation().add(.5, .5, .5).subtract(player.getEyeLocation()).toVector();
Location loc = player.getLocation();
loc.setDirection(v);
player.teleport(loc);```
#967923523148472370 anybody got any ideas
https://paste.gg/p/anonymous/3eef389dfc644d2faa1a916a3e7f0d3f is there any reason the spawn location is not being set?
[04:03:48 INFO]: [Sunburst] Teleporting to: {
"worldName": "world",
"spawnLocation": "42600.28573334319, 69.0, 27752.98790673437, 0.0, 0.0"
}```
prints correctly
it should be setting the spawn location but it does not
[04:06:13 INFO]: [Sunburst] Location: Location{world=CraftWorld{name=world},x=42600.28573334319,y=69.0,z=27752.98790673437,pitch=0.0,yaw=0.0}```
^when i add java Logger.log("Location: " + loc);
maybe it is, but it may be the spawnpoint
you might have to use the #teleport method
and you might have to wait a tick to do so ^
sadge
ill try, i did player join event and waited even 20 ticks and it didnt work lmaoo
did not work.. so weird loll
i am being teleported by something else on spawn and i have no idea whyyy hahaha
nvm figured it out
Does anyone have some input on this?
anyone can help me pls to craft an invulnerable item frames ?
public void Recipe() {
ItemStack i = new ItemStack(Material.ITEM_FRAME);
ItemMeta meta = i.getItemMeta();
ShapedRecipe shapedRecipe = new ShapedRecipe(i);
shapedRecipe.shape("BBB", "BLB", "BBB");
shapedRecipe.setIngredient('B', Material.BLAZE_ROD);
shapedRecipe.setIngredient('L', Material.LEATHER);
getServer().addRecipe(shapedRecipe);
}
does anybody know how to get the entire colletion of an updated document using change stream?
I have almost solved my solution
ah I think getFullDocument() will solve it :DDD
u know how to set an attribute to an item with a craft exemple (to craft an invisible item frames)
dont think you can just craft invisible item frames
you would have to implement that feature yourself
You can in the ItemFrame interface.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/ItemFrame.html#setVisible(boolean)
^
just craft something with nbt and then set it to invisible on hangingplaceevent or whatever its name is
well there's missing api there. cause you should be able to craft the item with the right EntityTag nbt and itll set it automatically on place.
Can you set player's attack cooldown time?
It's an attribute
What happend If I only change the attack speed of the player?
Only affecting hand or items will be affected too?
Items will also be affected
Perfect, thank you so much
Is there an easy way to remove %placholder_here% from a string?
ig replaceall
Sorry
No it needs to be for any placeholder
Like with placeholderapi?
Im thinking regex, but im not sure how to really make a regex string for that
You could use regex to match between 2 % signs
You would have to specify
every placeholder
and what you want to replace them with
You could look up more general examoles
Google "regex to get text between @
or use placeholderapi
"
No you can just match with regex
yes you can
?
Was trying but couldnt find anything yet
so you want to replace anything contained in %%?
got it
Google "regex to get between quotes" and replace the quotes with @
\%(.*?)\%
Or like %deaths% replace with 5
@noble lantern
or
are you replacing anything contained in %%
No i needed to strip them from the string entirely and it needed to be with any placeholder anyone could ever think of
its not a specific placeholder im needing to replace
idk why you didnt respond to me earlier
just ignored me
kinda rude
Β―_(γ)_/Β―
lol no it's not
couldve stopped me from wasting my time
dies of death
yes
indeed
I will mourn you
π
I will bring flowers to your grandma
i did kind of say it here :p
i just saw on the spigot website that its "owned" by Facebook (Meta) is this true?
yes
gross
Look at the date and then come back to us
like
yeah its 8 years ago i realise that. :)
no?
check the date
like
the specific day
π€¦ββοΈ
oh im a dodo buttface that doesn't realise things.
is that the second facepalm youve given me btw?
oh, well ive gotten two now. i think its a sign
i beleived it for a second too then i looked at the date
how can I make a specific armorstand uninteractable
like I mean, it cannot be broken whatsoever and a player cannot change anything about it
store it and cancel the respective events
and what events would those be?
more specifically the breaking one
The Marker tag does this