#help-development
1 messages ยท Page 381 of 1
np gl with the plugin
thanks โค๏ธ
Yup fixed my copper error
Ah yes. Naming generics is hard...
What does K or V stand for
Key, Value
Oh
Which doesnt make much sense in a Pair if you ask me
Can it be more letters I've never tried lol
cool kids know its F and S
Pair imo should be left right
T, U is the standard
public static int randomNumber(int minInt, int maxInt) {
if (minInt >= maxInt) {
throw new IllegalArgumentException("Error: The maxInt is smaller than the minInt!");
// Or if you wan't to do it easy:
// return 0; // Will return 0, if maxInt is bigger than minInt
}
Random random = new Random();
int mynumber = random.nextInt((max - min) + 1) + min;
return myNumber;
}
What's T or U
just generic generic values
int chance = randomNumber(1, 10);
if (chance < 5) {
p.sendMessage("You are the winner!");
else {
p.sendMessage("Try it again :)");
Someone see the error?
Yes. Let me show you
Pair<X, D>
average mojang code
<P, D, W>
Use ThreadLocalRandom for that
It stands for
like
Greetings from jail
int low = 10;
int high = 20;
int randomNum = ThreadLocalRandom.current().nextInt(low, high);
wtf
yup
Anyone know how the clickedPosition value is calculated in PlayerInteractAtEntity event?
that is sent by the client
And if not? Do you know where in the stash repo I could possibly find it?
and how does the client calculate it then?
oh wait nvm
minecraft is not open source whoops
indeed xD
๐ฅ
I am still looking forward to when we start seeing open source games
I think its a relative vector within the BoundingBox of the clicked entity. Starting from the Location.
I mean the server is effectively shared source at this point
with mojang mappings
but the game itself is not though
I mean, still very readable
If you decompile the jar?
Random random = new Random();
int randomInt = random.nextInt(19);
randomInt++;
if(randomInt == 1) {
}
if(randomInt == 1) {
}
if(randomInt == 1) {
}
if(randomInt == 1) {
}
public static int randInt(int min, int max) {
// NOTE: Usually this should be a field rather than a method
// variable so that it is not re-seeded every call.
Random rand = new Random();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}
this will also work right
got multiple errors by this one

smiles code looks right
obviously with the implication that low is inclusive and high is exclusive
^
Could you give me an example? (I am not asking for spoonfeed, but I am though)
what do you need this for btw
I am doing a raycast and trying to figure out where on the entity the ray hit
and I need it in the same format as the position argument of PlayerInteractAtEntityEvent
spigot has raycasts build in tho ๐ค
Not the way I need, so I just took a copy of the source code and modified it
if(randomInt >= 1) and (randomInt <= 5) {
}
wat
and
c++ moment
๐
xD
thank you
@lost matrix sorry I think it is the last question, but where should I actually store the manager... I mean I had a problem where to store temporary data and you suggested the manager, but where should I store the manager itself... In the main class? But there might be a lot of players glowing everyone around, so it's not a good way I think...
I thought about making this class static and modifying it so I can store several players in it without actually creating instance of it
Managers are always singletons. You create a single instance of it when the server starts (onEnable)
then your distribute this one instance to where its needed (either by dependency injection or by putting it in a field and writing a getter)
And dont make it static pls
if(conditionOne && conditionTwo)
Just use the code ive provided. Reinventing the wheel will just lead to fragile code
Now I get the format of the clickPosition value, but I don't really understand how I can calculate it based on the world location the ray hit and the location of the entity
if(randomInt >= 1 && randomInt <= 5) {
}```
๐
AB = B - A
Vector A->B = B minus A
and then I round that to the closest point on the boundingbox?
No this is exactly the hit loc on the bounding box
cause I have tried B-A, but the result I end up with is close, but not the same as the PlayerInteractAtEntity
Then try using a corner of the BB. Might not be the Location but the low corner.
so lowcorner - rayhitlocation?
armor stand
Vector min = boundingBox.getMin();
Yes
that one should be fine
but that should not make any difference I think, because the values that I see are different is the height. And this does not affect the height? I might wanna do some further testing though just to be sure it does not work as intended
why?????
this has been bugging me for the past 2 days
i am either legally blind or acf is having a stroke
This is because of your OfflinePlayer target i believe
what's wrong with it though?
it's an internally registered context (registered by acf)
should be perfectly fine
Try setting it to a String and you will see
hey thanks for this, working fine. but i wanna ask can i add the "multi line" thing to this?
Yeah now it works..
is there any easy way to fill a boundingbox with particles?
iterate through every block in the box ig?
Iteration dear
Fill or do you want the corners?
you could get the size of the bounding box, halve it, spawn particles in the middlemost part of the box and set offsetX, offsetY, and offsetZ to their respective sizes
That would result in a elipsoid
oh
Fill or the corners, doesn't matter cause the box is real thin
For corners i would have a util method
What is the data argument of world spawnparticle
please help, for some reason the top part does not update and i've been trying to figure it out for a rather long time
https://hastebin.com/share/wufaroqowo.java (method used for updating: updateLeaderboard)
also it seems like the max streak ever part also does not update...
Whatever UnderscoreKillstreaks.killstreaks returns might not be updated
it's a static MutableMap that is updated everytime a streak is modified in any way
the code for updateLeaderboard is identical to that of createLeaderboard (probably should extract it to a separate method later), and creating a new leaderboard actually makes those values correct again
A static mutable map... doesnt sound fragile at all
xd
companion object {
var killstreaks: MutableMap<UUID, Killstreak> = HashMap()
}
there probably is a better way of doing it
You updateLeaderboard method has so much code which should absolutely not be in there
but just in case, i wanna make sure that i always access the same map
yeah, well i want to extract the identical code from createLeaderboard & updateLeaderboard
why don't i cache config values?
eh, i don't know
probably should do that too
but that doesn't seem like the problem cause
This design is almost certainly the origin of your problem
Not the cause but it enabled the problem in the first place
i guess that's true yeah
All of this sorting:
Should not be in there.
UpdateLeaderboard should have like 5 to 10 lines max.
- Request top list from manager
- Throw top list in hologram
alrighty i'll take that into account too
Hey guys, how could i add the totem animation whenever u die in a event
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/EntityEffect.html#TOTEM_RESURRECT
+
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#playEffect(org.bukkit.Location,org.bukkit.Effect,int)
or
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#playEffect(org.bukkit.Location,org.bukkit.Effect,int)
Thanks ๐
haha the refactor shoved 2 entire kilobytes off of the filesize
it's now 2215kb
about to test
unfortunately still does not work (executed command /uks setmaxstreak tester346s17 3252) , if you're curious this is my final result https://hastebin.com/share/oqetomahop.kotlin
indeed
probably will attract users
i'll brb, please ping me if you have any ideas on why this is happening
1.19.3 spigot
what's your pom or gradle file look like
ima getting crazy can anyone find out whats wrong with https://paste.md-5.net/emiguhokev.java#L20 on line 20 which returns null? I've already defined that as a new InventoryPages();
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>```
?paste your actual pom
not snippets
can you show me the whole dependencies list
can i change itemmeta's Material?
ItemMeta doesn't have a Material
oh my mistake
you gotta use ItemStack.setType
i mean ItemStack
Thanks, will try :)
nothing wrong with that pom. Screenshot your expanded dependencies list in your IDE
any idea with this?
?paste the stacktrace
Caused by: java.util.ConcurrentModificationException you are modifying the list you are looping over
oh?
use an iterator if you want to actively modify a Collection
intriguing
solved thanks
idk what should i fill in in the implemented methods in iterator
you get an iterator from the Collection
๐
settings = new ConfigManager("settings.yml", true);
Settings.load();
will read the settings.yml file right
no
settings != Settings
Settings.load() is a static accessor
settings is a field
random-ore:
ores:
- copper_ore
max-drop-count: 1
respawn-time: 5
Settings.RANDOM_MAX_DROP_COUNT
how do i use PlayerCommandPreProcessEvent
so the max-drop-count should be the settings.RANDOM_MAX_DROP_COUNT
Like any other event
well thanks didnt know that
with care, and don't unless you absolutely have no alternative
and i wanna troll them so whenever they use a command, the command willg etprintedf publicly out in the chat
get prindet*
printed
what should I do if I want to know how many keys JSONObject has ?
shitty js results on google
Doesn't that thing implement Map
then can I get JsonObject's key by index number?
or should I just change them into map
what are you trying to achieve?
if it does implement Map, you can just call .size() on it
I'm trying to find which key has null value
you could loop over the entries from the #entries() method
"Hello. I have a problem using MiniMessage, has anyone encountered this before? The issue is that I have a string that I want to parse: "<username> started stream on <click:open_url:'https://twitch.tv/<twitch_id>'>Twitch</click>", but when I try to do this, for some unclear reason to me, <twitch_id> is not replaced.
Here is the code: config.getMessage("stream.announcement", Placeholder.unparsed("username", username), Placeholder.unparsed("twitch_id", twitchUrl))
Here is the object: TextComponentImpl{content="omashune started stream on ", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TextComponentImpl{content="Twitch", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=ClickEvent{action=open_url, value="https://twitch.tv/<twitch_id>"}, hoverEvent=null, insertion=null, font=null}, children=[]}]}
will this work?
?tryandsee
oh thank you
The URL in that click is not part of a component tree
It won't be replaced by mini message
It isn't even parsed as a potential node (outside the value node of the click event obviously)
It's a literal string
so just replace value of obtained string from config? ๐คช
Sure or string concat
Or String.format
Then run mini message over that output
If mini message would make that replaceable what would happen if the replacement is a green "hello" XD
damn... Okay, thanks
everytime i hear concat i think of cats
i made the method like that but still the same error happens https://paste.md-5.net/ifoqagazec.cs
Hmm, can someone help me?
private Inventory inventory;
...
public class hvh() {
inventory = Bukkit.createInventory(this, 27, ChatColor.BLUE + "HVH Search"); // Unknown class: 'inventory'
initializeItems();
}
listIterator().add(element);
```like this?
since iterator doesnt have add or set so
ok i guess its now fixed
might want to learn some java about classes and naming conventions
it isnt a java code right?
It is
anyways you should do this.
inventory = Bukkit.createInventory(YourPlugin.getInstance(), 27, ChatColor.BLUE + "HVH Search");
notes :
YourPlugin must be the class that extends JavaPlugin.
if you do not have getInstance method in your main plugin class then create one
it should be like this :
private static YourPlugin instance;
public static YourPlugin getInstance(){
return instance;
}
public void onEnable(){
instance = this;
}
also try using better namings and also in pascal case ofc your class name in pascal case would be : Hvh but i recommend you to use better namings but its fine if its just a test project or training one
replace the YourPlugin with your main class name
Im learning how to use GUIs
hello.
ugh dont use singletons
please not an instance
use dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
thats the same?
no lol
wait i forgot di
thats not really better than instance one however if you really hate using statics then there's nothing to discuss
Singleton pattern and dependency injection are both viable approaches.
Which one you chose depends on your design strategy.
yeah they're almost the same when talking about performance
performance lol
if you have to choose between singleton and DI because of performance you fucked up somewhere
would
myArrayList.listIterator(index).set(element);
``` work to set an element in my arraylist? Im trying to modify an arraylist without receiving any exception
why would modifying an array cause an exception
idk it throws Caused by: java.util.ConcurrentModificationException
so you are iterating over the array ?
there is array.removeIf and obviously normal iterators
both support (in their own way) removal during iteration
yeah
Someone knows why my intelli is crashing?
then use either removeIf or an iterator
Whas running every time good until 3sec back
and we can smell what happens?
iterator doesnt have set or add method i think
no it has removal methods
If you want to edit your list while you're iterating over it you're going to have to make a copy of that list and add to the copy
You can't add to a list that you're iterating over
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/ListIterator.html#set(E)
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/ListIterator.html#remove()
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/ListIterator.html#add(E)
declaration: module: java.base, package: java.util, interface: ListIterator
CopyOnWriteArrayList my beloved <3
thats literally what im doing now
Still dont know why this collection even exists... Feels like a literal troll to me.
TIL ListIterator has addition methods
Concurrency
It is impossible to use ArrayList in a concurrent environment once you want to use write to it
PS: Best collection for removal while iterating is a LinkedList
But index access is O(n)
use hashset or hashmap, if you are trying to add elements in the middle.
or better yet, a balanced binary search tree.
not sure if java has one implemented.
probably not.
What the hell do you mean there?
I have a question: I used BuildTools do get the remapped-mojang version of spigot but how do I use it with maven?
You mean a Red-Black tree @quaint mantle ?
Scroll down to NMS
that would be an example of a balanced binary search tree, but there are many more balanced binary search trees.
Well then https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html - but I don't think there is any reason to use that class
why
red-black trees are better for more write-heavy operations probably.
Myes - but only because of the stupidity of the default ArrayList implementation
what is wrong with the ArrayList??
copies the array when an element is removed or inserted
It's basically COW but not truely
Instead of asking why COW exists we should ask why ArrayList exists
it resizes the array, i would assume it is implemented as a dynamic array, meaning it is meant to have an amortized runtime complexity.
"COW"?
CopyOnWrite
what does that mean?????
actually no, ArrayList doesn't copy.
I am confused
Ah it only copies if you add the element in the middle of the list
it probably does copy when it gets resized, presumably.
why would you add an element in the middle of the list?
Well not really copy - it just shifts the elements by copying the list to itself with an offset
Duplicates the array once written onto it
if you need to update the elements from the middle of the array, use a different data structure.
but still depends entirely on what you are doing.
I think I last looked at the implementation while I was too tired so I completely misremembered the implementation - sorry about that one
omg why this goddamn bullshit doesnt work
pages.forEach(pack ->{
for (int i = 0; i < pack.getSize(); i++) {
if (!pack.contains(i)) {
pack.setItem(i, button);
break;
} else if (pages.indexOf(pack) == pages.size() - 1) {
InventoryPage page = createPack();
page.setItem(0, button);
break;
}
}
});```
error:
https://paste.md-5.net/takozubide.php
I tried using iterators but it didnt worked really
Use a delegate list:
List.copyOf(yourList).forEach(element -> {
// change your original list here
});
ah thanks i got fucked up
why i dont have that method from what jdk version does this exists?
11 probably
I'm trying to find null values on json.
but this code in catch (line 27) does not catch null values
(I'm sure it is blank values on json files).
what did I wrong?
https://paste.md-5.net/cirunarehi.cs
alright it worthes to move to 11
???
new Gson() ๐ข
You need TypeTokens for Maps
Does anyone know how to use mcedit or minecraft region fixer?????
Probably a decent amount of people do here.
But this sounds like a question for #help-server
thank you ๐
Almost everything in paper moved to Components, but player.chat() did not. I'm trying Mini Messagess API, can i transform Component to String to send e.g gradient?
isnt there Component#content()
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
ok no
which packet would it be to update the data?
ClientboundSetEntityDataPacket
ty
is there a better way of doing this?
@Override
public void updateHologramLine(Hologram hologram, HologramLine line) {
LivingEntity entity = ((CraftLivingEntity) line.getArmorStand()).getHandle();
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entity);
ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(entity.getId(), entity.getEntityData(), true);
Location location = hologram.getLocation();
location.getWorld().getPlayers().forEach(player -> {
ServerPlayer plr = ((CraftPlayer) player).getHandle();
plr.connection.send(spawnPacket);
plr.connection.send(dataPacket);
});
}``` because like if there's like 50 holograms in the world with 25 lines wouldn't that cause a bit of lag
i could put it on async since its packets ig
Is every hologram updated every single tick?
no that's just when the player changes world, joins, or plugin restarts
wait maybe i may have to update them every 5 ticks ish
because i wanna add placeholderapi support
Then this wont even show in your timings. The server sends thousands of packets per second per player.
Even with hundreds of holograms you wont see any lag.
okay, im just worried about the loop
since if i wanna update all the holograms every second or so
like yeah
or i could make a thing so it'll only update the hologram lines that have a placeholder on them
could reserve some performance
you can do it async
I'd honestly keep track of spawned holograms for the sake of not sending duplicated spawn packets
My first approach to holograms was to map each hologram to the chunk they where in, then listen
for when the chunk is sent to the player and send the hologram afterwards. Completely overengineered.
Map<Long, Set<UUID>> chunkMap
Map<UUID, FakeArmorstand> entityMap
exactly
๐ค
Well but first Map<UUID, WorldHologramDomain>
ofc you gotta use world ids
and then the hologram domain
yeah that's overengineered
but worth it
can i ask for help here??
Then each world domain has a Map<Long, ChunkHologramDomain>
and those have a Set<Hologram> or something
?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!
The server you were previously on went down, you have been connected to a fallback server
you probably should refer to #help-server
whenever try to connect from bungeecord this come
ok so a bungeecord issue
making a class to wrap a set ehhh
yes
ok
Yes ofc...
this keeps happening (the top and the bottom still do not update for some reason)
however, creating a new leaderboard hologram will display the correct values, even though the code for fetching lines is the same: https://hastebin.com/share/conapiyeme.kotlin
please help me if you can
happens sometime
print out each line in
for (index in lines.indices) {
hologram.pages.first().lines[index].text = lines[index]
}
with me also
sure, 1 min
?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!
once again you're better off at #help-server , this channel is for those who have problems with developing
if I store an URL on the server startup, if i then call for that url will the server make the connection again? or will it get the response it got whenever i stored it on the startup?
Creating an instance of a URL does not create any connection
if you store a URL you don't make a connection
i think instead of trying to run async the connection for skins whenever a player opens the custom inventory, im thinking on gettign those textures right away at the beginning of the server startup
then how do i store the result of a URL connection?
Either that or you make the skins lazy
Not worth it.
its for the same "problem" as yesterday when i asked about the calling a function after an async connection was done
Just cache the skins
are you expecting the skins to change between startup and them opening the menu?
i dotn want to make the server have connections everytime a player opens that inventory
no, thats why i want to store it on the startup
then store them
so can I store URLs?
no store the skin
or it will do connection everytime i call that variable
it's just a string
setSkin(url) calls for a url
i thought u need to modify the profile and resend a PlayerInfoPacket or whatever to everyone
oh
its just "player heads" skins on inventory items
uh
but i feel like that calling for URL is a connection all the time and lags when performing it.
Cache the ItemStack and only call clone() on it
so i wanted to store that when server opens
caching ItemStack was my next option yeah
was curious about the URL on how it works
surround it with async task
it doesnt lag the server
you dont need a url
by lag i mean it happens after
thats so pointless
so i wanted to store so it would be smooth
fun construct(): ItemStack { val itemStack = ItemStack(Material.PLAYER_HEAD).apply { durability = 3 } val skullMeta = (itemStack.itemMeta as SkullMeta) if (texture.length < 16) { skullMeta.owner = texture itemStack.itemMeta = skullMeta return itemStack } val gameProfile = GameProfile(UUID.randomUUID(), null) gameProfile.properties.put("textures", Property("textures", texture)) val field: Field? try { field = skullMeta.javaClass.getDeclaredField("profile") field.isAccessible = true field.set(skullMeta, gameProfile) } catch (e: Exception) { e.printStackTrace() } itemStack.itemMeta = skullMeta return itemStack }
thats kotlin
Imagine still using GameProfile. Also this creates a new profile for every time an ItemStack is constructed which is bad.
i will store itemstacks instead
concept is still the same
ty for the help
is there a reason to not create a new gameprofile each time?
whats a player profile
Bukkit.createPlayerProfile(randomUUID)
idk
i sent on the code here
hey smile
i figured out why it wasn't updating
so, the self position uses papi so it's always updated
and my updateLeaderboard is in fact never called
๐
A simple print statement saved the day again
thanks for helping though, i applied your tips for refactoring my code and it was easier to figure out the source haha
yeah for some reason i didn't even think of it
tyty
i basically have a list of tasks where i added my task to, but i never started running the task
how are they gonna restore stackoverflow if there's no stackoverflow
but honestly fuck stackoverflow, it's the most toxic programming community i've seen
the server never queries that url
it can have at most two lines
Every programming community is toxic
well spigot is not that toxic
and so is very unwelcoming to newbies
yes but SO makes an effort to be toxic at some times lol
yeah
Because a lot of developers have the I am better than everyone else mindser
I literally will never post a question on there, i will only read whats already on it xD
like, the full code, what class' methods are you overriding
the only real programmers are linus torvalds and terry davis, others are just coders
Terry davis lol
who the fuck is terry davis
OH NO! Linux is going into ventricular fibrilation!!!
yeah
ah the dude who killed himself
also torvalds is a jerk
Yee might be based of what I've seen
well he said that himself
Hello, I never realized that, but should I use org.bukkit.ChatColor or net.md_5.bungee.api.ChatColor to display colors in chat?
both will work fine
xd
linus is known to insult people on github for pull requests, not exactly something I'd consider any nice person would ever do
thanks
linus is a popular persona so i'm sure that some people have developed a kink for being insulted by him
slightly offtopic
๐ณ
that might be true
anyway, I don't like him
even though he's a jerk, his contribution to the programming community overall is huge ngl
although I agree that he's probably an extremely skilled coder
yeah
still, I wouldn't want to have a beer with him lol
I would
I'd buy a bunch than leave while he isn't looking leaving him with a massive bill
and even though it'd happen, you'd get free beers
i don't see what's the downside here
yeah I admit, that's a nice idea
In conclusion, this is why I should be optics idea manager
Okay !
plugin.saveConfig()
plugin.reloadConfig()
how performance-heavy is this?
shouldn't be called too often, but maybe 10 times a minute

well if it is heavy i'll find a workaround
Its IO so depending on your hard drive speed and your config length it could be
anything from meh up to abysmal
none. or much. depends on your SSD lol
anyway, why do you reload after saving?
the config will be exactly what you saved it, all the time
there's no need to reload it at all
but anyway, you should only save the config in onDisable() or in an async task
Why is this adding a block with type AIR eaven if the broken block is air in the BlockBreakEvent? https://paste.md-5.net/abuzedisub.cs
You are adding a block. If you later place a diamond ore on the blocks location then the block in your map has the type diamond ore.
I there some way to duplicate it and save the broken block only?
Get the BlockData
PS: BlockData lacks a location so you need to get both the Block and the BlockData
The plugin is in legacy
Then save the Material or whatever.
hi, im trying to do a troll plugin and i want when "utils.blockDrops.get(uuid)" is equal to false it dont drop the block items that the player breaks.
Here is the code, someone help me please:
then just do "if(utils.blockDrops.get(uuid) == false") and if it is, not do anything?
I mean erm
you should know how to check a simple boolean value if you do spigot plugins
i know
then what's the issue
im doing that
if (!utils.blockDrops.get(uuid)) event.setCancelled(true);
and what is the issue?
it cannot be null if it returns a boolean?
oh it's a map, it probabaly returns a Boolean
yes but its returning null because the player.sendMessage("CHAMADO"); dont run
Map with boolean values is kinda useless. Just use a Set<UUID> and check for contains
ok ill do that
it still dont work
"usually" useless, I agree. but you might still wanna have a map so you could see whether it's "true", "false", or "null"
sure
however this doesn't seem to be OP's problem so yeah, you're right
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
also please do not combine 5 random files in one paste
otherwise we don't even know which line number is which
just do one paste per file
so what's the current issue?
itยดs still not cancelling the BlockDropItemEvent
but does it print your "CHAMADO" message?
(whatever that means)
just a future advice, keep your code and debug messages in english so everyone can understand it
no
print out the result of utils.blockDrops.get(uuid) and the event's uuid
ok
seems like your map simply does not contain this uuid
where do you actually save the UUID into that map?
i changed it to a set you can see the new link i send
Hello! I'm a little German YouTuber! I want to program my own Miencarft server with plugins, minigames etc.! I've been working on this for a long time! And now I came to a problem! I have created a very complex adventure map! So now the server is also for other minigames etc.! Is there a possibility to get a plugin that gets a separate clone of the Adventure Map for each player with MultiverseCore? Thanks for any help!
Use a AtomicBoolean
That's technically possible
and please stop using ! after each sentence
sry
can you help me? Im a noob. ๐
OptionalBoolean
hello can plesse help my
Do you have the bungee api on hte build classpath?
Anyone who can help me? If you want i can pay you!
hello little German YouTuber!. wdym with "separate clone of the adventure map"?
then add it to the classpath
you also shouldn't offer payments on this discord, this might get you kicked, see this:
Also why do you delete your messages?
?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/
How?
anyone has his own clone of the adventure map! Not all on the same map!
I was unsure
ohh ok sry!
and you now wanna introduce that "everyone has their own map", or you wanna get rid of this this today?
Maven, gradle or none of the above?
Maven
what's your issue?
Then find the bungee api artifact coordinates and add it as a maven dependency
also why is literally EVERYONE in this chat german lol
homework? I thought you're 20+ or sth lol
no! Everyone who joins gets a clone of the adventure map that they can play on alone! But all have the same map!
what's the purpose of this, then
Nah, 17.
Many people do that mistake though - even IRL for whatever reason.
oh you mean, everyone gets the same map, then they can modify it to their likings
yes
are you the one who made a thread in spigot forums about this a few days ago?
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.16-R0.4</version>
</dependency>``` I have it in
no im not
that is not the proper version
oh weird, someone a few days ago had the exact same question
can you send the link?
or rather said I'd be surprised if 1.16-R0.4 is the bungeecord-api version
lemme find it
?jd
https://www.spigotmc.org/threads/best-way-to-send-data-between-spigot-bungee.592772/ this @brave shadow
ok got...
(btw if you're looking to hire someone feel free to DM me, but remember it's actually not allowed to talk about this "hire someone" stuff on this discord)
still have the same error
did you refresh the maven project?
1.16? R0.4? where did you get this from o0
yes
i DM you
kk
bungeecord usually doesn't change between same versions at all, try to simply use "1.16-R0.1-SNAPSHOT" instead
as geol already said
Can you answer?
@quiet ice?
can you scale a spigot server horizontally
??
no i mean cmi has custom title
but when i tried it, i couldn't find a custom title thing
are they sending two lines for this or something different?
Is there a way I can prioritise the latest version of gson in maven?
for some reason my plugin isn't using the latest one and that's causing issues
hello with me always come
cannot find symbol
can someone help me
Gson is bundled with spigot so that version will be used
unless you shade/relocation, if it's possible with Gson
you keep talking about titles, while you actually mean toast messages
so what's the thing you actually wanna do?
send a title, or send a toats message?
i have relocated it yeah
if it's a title: spigot api got everything you need for that.
if it's a toast message: my library (jefflib) got everything you need for that if you're on 1.16.1+.
for everything else: you gotta implement it yourself
but I kind of need it to use the latest one tho
like in the project itself
even if it will use it when jarred
erm no, just do not declare that dependency twice?
?paste your full pom.xml pls
I haven't, there are a bunch of them bundled with spigot, and I'm declaring the latest one in the pom
okay so two things:
- spigot does includes outdated libraries, but they are all relocated
- if you use use the "actual" class path, (the ones that do NOT start with "org.spigotmc" or or "org.bukkit"), you shouldn't have to worry
3.: just put the dependencies that you use ABOVE spigot in your pom.xml file
Oh, the order of declaration matters? I see
yes, it does matter
maven basically does stuff like "ok, this guy uses example.class, where does it come from"? and then it goes down the list of your dependencies
so yeah, try to put your other dependency at the top, then it should work
It still doesn't work... for some reason
there's also another way, which is to exclude dependencies from dependencies
the toasts title. i want to set "goal reached" to something different. like hey you made it or something.
what's the error message you get?
i thought the image was clear lol
It's actually due to a very specific method call with gson that only works on later versions:
I can tell it isn't working because that is still not found
I cannot help you with that- I only know the basics of Gson and I always hated Gson and that's definitely something I can't answer
Yep, but this is a versions issue really
It has happened before, I'm not sure how I fixed it, but I'm 100% sure it's due to the version
But that was really long ago
how do you describe the "goal reached" thing, if you dont call it the toasts title
Actually one sec
Fixed it now: It was as you said, I just forgot to also put the module dependency where this is called before the spigot declaration in the module where it's being called
no clue what you are talking about. there are three builtin "goal types"
Future me, if "Gson is not working", or "there's a setObjectToNumberStrategy issue", just check the order of the dependency declarations.
did you checked the image?
which image?
this
so changing the order of dependencies in your pom.xml fixed your issue?
Yep, I just forgot to also change it somewhere else: My project structure has the "core", where version unspecific code resides, and gson was there. The actual code where it was being used is somewhere else, and that core was being depended after the spigot declaration
ah ok
Thank you!
no problem
how i can get the player that ate a custom food?
there is a consume event
what is it's name
?jd-s
search for consume
Hi i want to make a Revive System in my plugin. I am currently rewriting the old-version of plugin. It is supposed to work like that, u bind block to eliminated player, then place it, and it counts down for e.g 60 seconds, after that player gets unbanned, block changes into air. Revive-block have durability. which means 60 durability, 60 pickaxe breaks or so. In the old version I made dynamic config which created section like this:
reviveBlocks:
UUID:
Location:
time-placed:
time-to-break: (which time block should break and the player should get unabnned)
target: (who is going to be unbanned)
durability: (Health of the block)
Here's my question, there is a better way to make it e.g without config, like inside of plugin? Note: 1 and more revive block can be placed at the same time?
How should i start with it? Any tips where to store that data (if it's possible)
Well, I can always turn the system off, then schedule the restart, so i guess no
Then just make a class with that stuff as fields
?jd need bungeechat
is TextComponent(String) not a constructor anymore?
ig fromLegacyText (or just using ComponentBuilder) suffices but
https://imgur.com/a/Dr3Ddzj hello can someone help me? pom.xml = https://imgur.com/a/jVW6mk7
how i can give an effect when you eat something bukkit
oh fuck its because of lombok stuff that im not seeing it isnt it
ProxyServer not BubgeeCord
maybe it is you never know!!
I'm an optimist
run some code in this event https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerItemConsumeEvent.html
declaration: package: org.bukkit.event.player, class: PlayerItemConsumeEvent
Is ChatGPT down?
idk
Wooooo lombok
was that for me?
i am new in this, idk how to do this xd
both xd
i was getting so confused bc i had a huge mismatch in source view vs class view
then i would suggest learning some java basics first
tip learn java first ๐๐ฝ
after which u can check out that link
then why till happen that
Yes
Its doesnt make sense to hoppe making the best cake if you havent learnt the basics of cooking
How can I change this?
type ProxyServer instead of BungeeCord
with your keyboard
probably
push the keys
Are you new?
yes
?learnjava ??
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
the price id pay for the lombok'd methods to be builder-style
ComponentBuilder it is :P
What? I couldnt understand
You want to buy the lombook methods?
just trying to refactor some code that uses bungee chat
ih right
Is there any alternative to kyori but with less code?
have thanks
was hoping for like TextComponent theComponent = new TextComponent("Message").setColor(theColor); but setColor is void type
You're meant to use componentbuulder for everything
Also i have a question related to components, its bug or why when you send too much lines using components some of those lines colors arent apply ยฟ?
its interesting that its possible to send individual components then
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/command/CommandSender.Spigot.html#sendMessage(net.md_5.bungee.api.chat.BaseComponent)
but i guess its just something to do with the implementation and shouldnt be used by plugins
Don't put legacy text in components
.color
https://imgur.com/a/D3YSNph Can someone help me now I have the problem
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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
If md5 tells to learn java, you must follow his advice
He has lot of experiences and he wouldnt say that to bother you
๐
So please if you dont learn Java, we wont be able to help you. Because you wont ever understand what we refer to
that's when you have to rethink life
when u gotta learn java? yeah
I'll do it just
Not learning java = not getting helped
how i can give a player an effect if you kill a specific mob
me a couple years ago I started learning java straight away when using forge api learnt everything the hard way lol
no
once again listen to an event do a basic check for the entity & run some code
how can i remove armor from a mob's drops?
apparently clearing the drops list in the EntityDeathEvent doesn't clear the armor
I learn Java but I want to get on and I don't check what the problem is because I have put everything in and he takes over and he still gives me a mistake!
he?
You can pretty learn java in few months
Its a pretty easy task, just put to effor to learn it
mouth
Okay def i will not answer like everyone else has done, probably their best choice
๐
https://paste.md-5.net/eqoqorafav.java
hi, i dont know why the utils.blockDrops.contains(uuid) returns null in the OnBlockBreak class
- Utils classes should be static
- Dont get menus by title
Make it yourself
impossible, a Set will never return null on a contains
yeah, nothing about that code seems to even be able to lead to null where u described
yea
and tis a mess
Code from ohio
sorry
when asking for help, you must send the relevant code
Not whole plugin because you mix everyone
also, you are instancing yoru utils every time so yoru Set will always be empty
What i have said before
what if the relevant code is the whole plugin? 
Utils has to be static, as i said befoe
oh wait, by null, did u mean it wasnt making it past the .contains check?
The problem as said Elgarl, is that you instancing your utils class everytime so then the Set is alays empty
aka .contains was returning false?
yes i think he was refering to that
ah
yea sorry
then yeah what elgar and verano said are what to do
i was confusing with another thing
make TrollUtils methods and fields static :v and then dont instantiate the class
agree
okkk
Also that class should be a TrollHandler and instancing it on Main plugin class, finally pass the instance via Dependency Injection
. xD
could probably try setting the drops
yeah already tried totally clearing that list
it doesn't work
probably bukkit doesn't include armor drops in that
It should
do you guys use nullable, not null annotations?
I keep getting this issue whenever I try to package my plugin...
org.ageofsauron.AOSPlayerManagerReworked.v1_16_5.AOSPlayerManagerReworked is not abstract and does not override abstract method getDefaultBiomeProvider(java.lang.String,java.lang.String) in org.bukkit.plugin.Plugin```
Why is this? I've never gotten this before
Yes
yep
Yeah
Maven JB
"them"?
annotations
Yeah add it to your project
does jetbrains annotations generate assertion code?
while processing the annotations
No
or they're just simply guidelines in the ide
You can use NonNull from Lombok if you want assertion code
Intellij has an option to insert runtime checks
Tho iirc only works if you compile via idea
Which, lmao, what the fuck are you doing if you compile via idea
would it be best to put variables inside the interface or the class that implements it?
Class that implements it
I keep getting this issue whenever I try to package my plugin...
org.ageofsauron.AOSPlayerManagerReworked.v1_16_5.AOSPlayerManagerReworked is not abstract and does not override abstract method getDefaultBiomeProvider(java.lang.String,java.lang.String) in org.bukkit.plugin.Plugin```
Why is this? I've never gotten this before
Would this be the best possible way of doing this???
Map<Material, List<PlayerGeneratorHandler>> generatorMap = playerGenerators.computeIfAbsent(player, k -> new HashMap<>());
List<PlayerGeneratorHandler> generatorList = generatorMap.computeIfAbsent(location.getBlock().getType(), k -> new ArrayList<>());
generatorList.add(this);
playerGenerators.put(player, generatorMap);```
no
UUID
๐
but is this the best way?
of adding it to the data
just trying to add it to a map
its kinda lengthy but
Map<UUID, Map<Material, List<PlayerGeneratorHandler>>> playerGenerators = new HashMap<>();
;-;
that's what it does but i felt like this would be the best way
performance wise
so i can get all the generators with the material without looping all of them
Date date = new Date(System.currentTimeMillis());
System.out.print(date);
}```
'determine the time complexity' i think it is o(n) but it seems like way tooeasy of a question if it is?
there is no loops
like wtf
Yeah, nothing complicated about it. Just constant
me who forgot constant time was a thing
can someone explain to me how to schedule a task for later
I've watched 4 videos and read the sheduling page and I still don't know how
I want to make it so when I break a diamond ore it turns to stone
after 10 seconds it should turn back to diamond ore but I don't know how to do it
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
can someone explain it to me instead of sending a link
BukkitScheduler scheduler = Bukkit.getScheduler(); scheduler.runTaskLater(plugin, () -> { Bukkit.broadcastMessage("Mooooo!"); }, 20L * 30L /*<-- the delay */);
when I use this code it shows an error for plugin
and idk what I need to do
what error
whats the error
if you want people to help you, you have to be specific
you haven't just typed plugin without initializing it anywhere, have you ?
u need to pass a (non null, accessible) reference of ur plugin into where it says "plugin"
show how you initialized it
so pass main class instance using static getter or over the constructor
thatll do it
?di for constructor thingy
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
do I just need to do this for every plugin?
its called dependency injection
what version of java does 1.16.5 use?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
how can i code a mech?
do i make the model and set it as an entity?
and make player mount the entity?
if yes then how do i ensure player is in middle of the mech model?
so basically i coded a mech and the mech is just a custom modelled giant
but how do i mount the player at a specific spot?
and use the player direction to set as giant direction?
I'm not good at making plugins, but maybe it can help
- spawn the giant and mount player - It's possible but I dont know how to, use google
- make the giant facing the same direction(or block) as player
- setvelocity
this thread will help you a bit, but remember it is set to modify flying mobs
you can edit model files
Hey! I switched to a laptop recently and running compilation process on Gradle overheats the machine, this might sound right, but usually compilations on this project manager take long times, long times with the laptop at high temperatures scares me a little.
Is there any way to limit how much cores can gradle use? (Working on Windows 11)
from the onAsyncPlayerChat, I want to send a broadcast message if the message contains a specific word
but the Bukkit.broadcastMessage() is sent before the player's message, how can I tell him to send it after?
how do i set a player health permanently to a certain amount of hearts?
player.getPlayer().getPlayer().getPlayer().getPlayer()
Is there a way to get the weapon used to attack in an EntityDamageByEntity event?
#getCause() ?
hmm
nah I dont think that would work
im saying the item that was used when the person attacked
bcus for bows
if they switch items
and arrow hits
so I wanna get the lore basically of the item that they shot with
Sure. Get the attacket and check his equipment.
Ah i see what you mean
You dont want to do that. Rather add data to the PersistentDataContainer of the
Arrow when its fired. This way the custom hit still registeres even when the attacker
drops his bow or even disconnects.
-> So add data to spawned arrow in launch event
-> Check arrow data in damage event
how do you use pdc ive always been so confused and every time I ask someone sends me a useless javadoc website that doesnt tell me anything
?pdc
.-.
yes
ik
but still makes no sense
im kinda stupid :)
but yea ig i can try again..
PDC is just a key-value map.
The key is always a NamespacedKey and the value is whatever.
You just need to add a Type for every entry you add.
so items can hold variable's value..?
so you can like put a type and a random value and u can hold values inside mc items
Sure you can even store a whole inventory inside an ItemStack. Makes backpacks really easy.
You can store whatever you want in there.
Same for every Entity, Chunk and every Block which is a TileState
I pretty much was just trying to frickin give the boxes codes in their lore xd
so
can you store multiple values with different keys in a single item and its different for each item?
Yeah for custom items you should also use the PDC.
This way you can change the name or lore and still have the same custom item.
This has come up so many times now... I think its time i write a Tutorial for that.
