#help-development
1 messages · Page 2057 of 1
ah okay, but MultiMap returns a collection
isnt it multiple values for one key?
so a MultiMap is nothing more than a Map<K,Collection<V>> I guess
multiple same keys multiple values as i remember
idk
seldom used it
yes exactly
bump
is the registerintent and completeintent in bungeecord async or sync?
but it doesn't implement Map anyway so I can just ignore it
but for real, why would someone store null<>something in a map
did you ever see that in real life?
I mean I understand null as values, but null as key? why?
null as key makes no sense lol
yeah exactly lol
just like the whole idea of NFT ooooooooo
I'll just throw a RuntimeException when someone uses null as key
and if they use null as value and the map doesn't support it, so be it, then it's their problem
can just use an optional wrapper for it?
nah you don't know what I'm doing, one second
this allows you to pass any kind of Supplier<Map> to use it inside a PersistentDataContainer
people might now save a HashMap which allows null into a PDC
then later they read it again using aTreeMap, which does not support null
I don't know whether the map they passed supports null as values, though
since everything's 100% generic
someone above mentioned that it doesn't
I haven't checked it
but yeah if someone saves a map with null and then loads it again as a map that doesn't support that, it's their own fault anyway, so I shouldn't worry about it
does someone know whether I can get rid of the ugly (Class<C>) cast in the 4th line from the bottom?
public class CollectionDataType<C extends Collection<D>, D> implements PersistentDataType<PersistentDataContainer, C> {
private static final String E_NOT_A_COLLECTION = "Not a collection.";
private static final NamespacedKey KEY_SIZE = getValueKey("s");
private final Supplier<? extends C> collectionSupplier;
private final Class<C> collectionClazz;
private final PersistentDataType<?, D> dataType;
public CollectionDataType(@NotNull final Supplier<C> collectionSupplier,
@NonNull final PersistentDataType<?, D> dataType) {
this.collectionClazz = (Class<C>) collectionSupplier.get().getClass();
this.collectionSupplier = collectionSupplier;
this.dataType = dataType;
}
any idea how to supress this specific warning? how does the minecraft dev plugin do it when it creates all the boilerplate?
@SupressWarnings("unused")
you can just ignore it
mmm that sounds like what i want, where is that entry points stuff?
i know almost nothing about java in general so
but once you have a plugin.yml referencing that class, IntelliJ should be able to detect it itself
it doesnt
start Code Inspection (Code -> Inspect Code)
then click on Add as Entry Point
my eyes
it adds this <pattern value="io.github.misdocumeno.test.Test" /> inside a component tag in the .idea/misc.xml file
so thats what i need i think
thanks
how do I make two checks at the same time with Player interact event, mainhand becomes air when off hand check is being done during the second fire
NVM I was consuming the item in the mainhand
I think above method is correct
I only want it for that statement though, and the javadocs say "@ SuppressWarnings" can also be used on local vars, so I am confused on why it's not working
yeah, they also say it should work, that's why I am confused lol
bruh maybe problem with IntelliJ
it works for me
weird
restart IntelliJ 😄
oh wait
it's probably
because I am not assigning a local var
it's a field assignment
yea
not working
working but still showing a warning
think its because using this.thing = thing isnt technically a local variable
yeah I'll have to use the ugly //noinspection
oof
white mode is actually better for your eyes, but I still will use dark mode
I switch between light and dark mode every other day
sometimes I like the light mode, sometimes I don't
ugh FML
I just spent 20 minutes adding "null" support to my lib for PDC stuff
intellij light mode has got the be the worst sight ive ever laid my eyes upon
then I realized it's not needed to keep track of null values
wait nvm there is visual studio light mode
I just must not save them, reading non-existant keys returns null anyway >.<
is there a better way of doing this check?
if (Math.max(abs(loc0.getBlockX()), abs(loc1.getBlockX())) - Math.min(abs(loc0.getBlockX()), abs(loc1.getBlockX())) == 1){
what is that even supposed to do?
get the diff of the absolute values of two X coordinates
public boolean locsAreAdjacent(Location loc0, Location loc1){
if (Math.max(abs(loc0.getBlockX()), abs(loc1.getBlockX())) - Math.min(abs(loc0.getBlockX()), abs(loc1.getBlockX())) == 1){
System.out.println("diff is 1");
}
// same for Y and Z if theres two 0 and one 1 then block is adjacent
return false;
}
something like that
int x1 = block1.getX();
int x2 = block2.getX();
int distanceX = Math.abs(x1 - x2);
this?
yea thats the same
nah nvm im just gonna keep what i did
y
it just looks ugly
your version is so complicated
I don't even understand what you're doing there
just do x1 - x2 and then turn it positive if it's negative
done
just do:
if (Math.abs(loc0.getBlockX() - loc1.getBlockX()))
that would fail if locations are -20 -21
no
no
what abt -20 21
and -21 - (-20) = -1 and Math.abs(-1) = 1
it would return 40
that would return -1
that's why we put it inside Math.abs
so it would also return 1
-20 - 21
guess what: also 1
your code is bloated and prone to error, the code we sent will work 100% guaranteed
-20 - 21 = -1
yea it would return -41 because the diff is 41
into Math.abs = 1
oh he meant x1=-20 and x2=21?
yea, still works
it will work in every possible case
I also don't get why they ask "is there a better way", then we tell a way better way and then they just say "ugh I'll just stick to my weird version"
why did they ask then, anyway
😄
yea normal
How can I make spigot show the entire exception, and not 21 more......
What do you mean?
Spigot cuts of a part of the error message
thats how java works everything should be displayed that you need
But i need that below
Yes sadly
send stacktrace
TestParticleCommand.java:20
at.theduggy.deutsch_diewolke.TestParticleCommand.onCommand(TestParticleCommand.java:20)
Yes but ther I use the instance of an class and where the error in this class is isn't shown
code?
package at.theduggy.projekt;
import at.theduggy.projekt.Animation.Animation;
import at.theduggy.projekt.npc.NPC;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Random;
import java.util.UUID;
public class TestParticleCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
return false;
}
}
is NPC your class?
Yes
have you checked latest.log
There is the same, isn' it
Normally it is
no harm in looking
I am not at home lol
maths
(-20) - (-21)
lua is strange lol
lets you use -- on a literal
Oh wait
I know why
It's because -- is for comments in lua lmao
So it interprets -20 and then the rest of the line is seen as a comment
xD
Still my favorite repl for doing math
Because
In python you gotta use ** but in lua it's ^
^ in python is bitwise xor I think
It is
Same in java
Which is fine for programming but when I'm doing math I want ^ to be exponentiation
A mob drop a custom itemstack. and I added a NBT to that itemstack. but when I pick that itemstack, NBT removed
lua is weird indexing starting at 1 is evil
how to fix it?
oof thats weird
But I actually like it more than python because it's at least got consistent design and is significantly faster
Dynamic typing and arrays starting at 1 are both still bad though
But technically lua has no arrays, only tables
I really don't use it these days except doing math in the repl
anyone can help me?
oof also bad
Say what you want but lua is a very easy language to implement
I never used lua or
It's got very few keywords, very simple syntax, and is very fast compared to most scripting languages
It has easy interop with C/C++
And it's pretty damn flexible for what it is
It's not OOP but you can recreate OOP behavior with it
is there a way to hide a command from autocomplete and make it look like its an unknown command
Commands should act this way if the sender doesn't have permission by default
how do i make a command have permissions?
Or at least, they shouldn't appear as a tab completion if the sender doesn't have permission
commands:
example:
permission: permission.node.here```
I watched this one: https://www.youtube.com/watch?v=jytF-6WD2Eo&list=PLfu_Bpi_zcDNEKmR82hnbv9UxQ16nUBF7&index=10
In this episode of the Spigot Tutorial series, I show you how to work with permissions. It is actually super simple and will allow your plugin to have some more functionality. With this feature you can limit players to have access to certain commands.
This episodes code: https://snippets.cacher.io/snippet/b1f557dd90cdd2502bf3
⭐ Kite is a free...
I wouldn't bother with the default commands though
They suck
I guess if you're a beginner you should learn how to use it
But as soon as you understand it and feel comfortable with it you should abandon it in favor of a framework
I tried this. still same
Ok again you're adding the original item, not the modified one
.-.
rename probably returns a new item rather than modifying the instance you gave it
If LivingEntityHead.BEE is a static field, then it’ll use the same itemstack every time this happens
I don't know where Itemstack is defined though
VERY poorly named since it's easily confused with ItemStack
is ther away to have permissions but ignore them if its a certa in player?
Why would you ever want that
Just set up a proper permissions plugin
Set up luckperms
Or op yourself lol
Itemstack.rename working fine. problem with NBT
Don't make backdoors
No it's not a problem with NBT
It's that you're creating an NBTItem and then doing nothing with it
You're applying a property and then you don't even use it
the owner wants me to make this :/
ok
There is no reason to create user-specific backdoors
waht is a backdoor
@warm light can you show where the code for LivingEntityHead.BEE is?
A hidden bypass
oh like popbob
That's not the issue here
Already fixed. I am dumb
The issue is that you are creating an NBTItem, setting a property on it, and then doing nothing with it
have to use getItem() there
Yes
I'm not familiar with the NBT API
But it makes sense that you have to get the modified item from it
I wouldn't expect it to mutate the item it's constructed with
Well yeah, but if it’s trying to use the same itemstack everytime that’ll also end up being an issue
It won't if you're creating copies
Doesn’t look like it is though
It looks like rename might
But NBTItem doesn't
I'm guessing Itemstack.rename is something they made themselves because it's poorly-named with bad default behavior
Even if rename does though it’s not getting stored in a new variable
I would recommend renaming it to something like ItemUtils and having it return a copy of the item with the new name rather than renaming the instance that's passed
okay
Yeah if you change this behavior then you'd need to call rename and then store the return value
it don't return anything just get itemstack from input and rename it
Yeah and I'm telling you to not do that
public static ItemStack rename(ItemStack item, String name) {
item = item.clone();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}```
Then you'd do something like this
ItemStack something; // assume this is populated
something = ItemUtils.rename(something, "name here"); // creates a copy of the item with the given name```
Pure function
okay. thanks :D
👍
In general you should try to write your utility functions so that they take in values and return other values without modifying the input
If a function doesn't modify its input or any sort of internal or global state, then it's called a "pure function"
They're preferable because side effects (modifying parameters and state) make things more complicated and are harder to test
Is it wise to save every player who ever entered the server into my cache (concurrent hashmap)? I'm debating whether I should load every playerdata from my database on server startup or just retrieve them at the time they're needed or called
Retrieve them when they join
Yea, that's what I'm doing, then I save it to my database after a specified amount of time. Then in the next startup, should I preload their data from the database or just retrieve it again on their join or when it's called (used in commands and such)?
Join
how do I make a data folder for the plugin?
plugin.getDataFolder().mkdir()
tysm 😄
ohk
Anyone know how to integrate a cache for playerdata with mongodb. I want to have easy access to variables but I can't seem to find anything that looks remotely correct.
If you know how let me know or send me in a direction so I can learn myself. (@ me if answering to me tia)
Create an inventory and save the contents so the items doesn't disappear.
can someone give me a example of how to use the set_contents and get_contents of an Inventory?
why does this not work?
ItemStack minerHead = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) minerHead.getItemMeta();
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString("4e94f45c-759c-4293-af16-fdf219237a5d")));
minerHead.setItemMeta(skullMeta);
The head just defaults to a steve or alex. The player never joined the server I dont know if thats an issue
The only way it works is with
ItemStack minerHead = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) minerHead.getItemMeta();
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer("Miner"));
minerHead.setItemMeta(skullMeta);
but getting offline player by string is depreciated
idk u sure you have the right uuid?
yeah got it right from name mc
https://namemc.com/profile/Miner.1
weird what version are you on?
Im in 1.18 but developing for 1.16
API version is 1.16
idk why it happens then
Yeah, I just tried to get the name of the player by doing
Bukkit.getOfflinePlayer(UUID.fromString("4e94f45c-759c-4293-af16-fdf219237a5d")).getName();
And it just returned null
Running Multiple MySQL Statements slowing down server
is there anyway to find var with name from another class?
public class BigBalls {
static class balls {
public static String A = "";
public static String B = "";
public static String C = "";
public static String D = "";
public static String E = "";
public static String F = "";
public static String G = "";
static {
A = "true";
B = "true";
C = "true";
D = "true";
E = "true";
F = "true";
G = "true";
if (Boolean.parseBoolean(A)) {
if (Boolean.parseBoolean(B)) {
if (Boolean.parseBoolean(C)) {
if (Boolean.parseBoolean(D)) {
if (Boolean.parseBoolean(E)) {
if (Boolean.parseBoolean(F)) {
if (Boolean.parseBoolean(G)) {
System.out.println("Hello!");
}
}
}
}
}
}
}
}
}
}
someone rate the code
thanks
Guess I have class name a and in that class, I have a public static var named RRS. now I have to access that var in b class. but not like a.RRS. something like a.valueof("RRS"). how to do that?
Why do you want to do that
yes
it's not a variable
create an enum
Man it all started 8 years ago... I have been developing that for so long. It's my masterpiece.
💀
Nah wanna see something ACTUALLY cool though?!
Igh hol' up I'mma send you a friend req
lucky man
better than NMS
always am :)
when a command is added by a different plugin from yours, can you still call it with the dispatchCommand()?
Yes
nice thanks
Why would ou want that...
hot
i bet intellij will cover that entire block in warnings
0 warnings
Not a virus since it doesn't spread. It's just malware
lmao
yes you cant do that through a plugin
just make a program, send it to them, and tell them to run it.
You can do it through a plugin
System.exit(0) lol
We won't help you with that
explode their cpu
misread as "turn off server"
all good
List<Double> list = new ArrayList<>();
double i = 0;
while (true) {
list.add(Math.sin(Math.sqrt(i));
i += new Random().nextDouble(0, 3);
}
explode cpu
That will just cause the server to freeze and kill itself
"ArrayList<Double>" 😡
oh yeah too fast
what
"CPU Ouch" i believe its called. run it asynchronosly
now it has to look up the methods in the vtable
List is just better practice
i mean that using the implementation allows for non virtual calls
which mean they dont have to be looked up in a vtable
i mean it might still need to do that because ArrayList is not final
The Liskov Substitution Principle states that any subclass object should be substitutable for the superclass object from which it is derived. This semantic relationship often called behavioral subtyping, is applied to develop more correct, extendable, and reusable software.
I mean ArrayList can be pretty fast as long as you’re not using millions of elements
yeah yeah yeah i know
ArrayList -> if you need to access something via index
HashSet -> if you need to check if an element is contained in the collection fast
LinkedList -> basically everything else
i like to do
ArrayList<V> linear;
HashMap<K, V> mapped;
Yes but HashSet presupposes few hash collisions as possible if you want it to be truly fast
for anything that needs to be iterated over but also needs quick lookups
I know
ArrayList is slower than a LinkedList
appending
yes.
no lol
an ArrayList needs to free up space in the array for an element
like if i need to iterate over something but also need fast lookups
usually derive the key from the value
like an identified object
If you set the initial capacity, no resizing has to be done as long as the initial capacity isn’t exceeded
then why wouldn't you just use an array?
But even then resizing is extremely fast since it uses system::copyarray which is natively implemented
If you know the size there is no point
Because ArrayList allows you to resize the array
wat
no that’s not what it’s about
iteration, getting by index
Initial capacity is a good pre-optimization
anything that needs to be ordered
oh for hashmaps getting by index?
If you know approximately the amount of elements the array list will have on average
and then do
public void register(Identifiable it) {
mapped.put(it.getIdentifier(), it);
linear.add(it);
}
Then setting initial capacity can reduce conceivable resizing operations you might have to go through
neglecatble and if i need to iterate over something its much faster
LinkedList internally maintains doubly-linked lists which store the memory address of previous and next object, so there will be no kind of structure which will keep memory address of the previous node and next node. There is no initial capacity defined for LinkedList, and it is not implementing a RandomAccess interface. LinkedList is faster than ArrayList while inserting and deleting elements, but it is slow while fetching each element.
@faint sage would do better in this conversation than I would but he's offline atm.
sorting is technically fetching
Yes but we were talking about add/prepend specifically
LinkedList is faster than ArrayList while inserting and deleting elements
that exists?
Bruh
ah lmfao
Like, I already told you
ArrayList can be faster than LinkedList if you have set the initial capacity
Literally
and when it goes past that initial capacity it isn't
Yes but to some extent if you’re reasonable you’ll be able to predict it thus array list is reasonable even if you add and remove elements frequently
And also insertion by index is quite fast for ArrayList
it stores the nodes anyway
so it really doesnt save memory
saves like 4 bytes per pair
for the size
for linear, ordered access and fast lookup access
I agree with deciding the initial capacity, but in most cases you won't be able to predict that. So you should use a LinkedList
just sort using stream?
thats not possible with only a hashmap
u can sort a hashmap iirc
I disagree but sure, thing is for small matters LinkedList is gonna be slower than array list even tho time complexity might hint something else
you really dont want to always use a LinkedList for everything
otherwise each time i want to iterate over it i have to resort the entire thing in a stream
its maybe more painful
it really depends on the usecase which one you should prefer
Use a TreeMap
no you dont. but you can use a different impl of the Map
isnt that O(log(n))
100% I agree on that last part.
but whatever the memory 'save' is neglectable
never said for everything.
LinkedHashMap is sort by value with a linked data structure order (can be both by access and by insertion), TreeMap is sort by key with a tree structure order (ofc it’s possible to still sort by value)
Actually it might be the other way around
ive never touched linked anything cus tbf ion know how they work loll
or why u would use them
Mye it’s the damn other way around
yes i dont get why that has to do anything with the fact i dont use linked shit
manager
i think theyre Arrays which get extended or something like that
Nah 2Hex
All the integer keys in an ArrayList must be positive natural numbers where each number is consecutive
and it uses int not Integer :3
They are very different structures
ArrayList is an array which gets copied over into a bigger one when it is full, HashMap uses linked list buckets identified by the hashcode of entries to store its values
I mean HashMap also has a backing array
is there any method for Arrays to count the null values, like stringArray.count(null); smth like that
Yeah but it serves a different purpose to storing the literal values like in an array list
Likely with streams
I couldnt find it
Collections.frequency also exists
How can I check if an element is in both lists,
For example:
List<Integer> list1 // 1, 3, 6, 2
List<Integer> list2 // 7, 9, 5, 3
it should return true because 3 is in both lists
.contains on both lists?
not really I dont want to search for a specific value, I want to know if there is any Integer in both lists
so the number of duplicates
if(!list1.isEmpty() && !list2.isEmpty())
no thats not what I want
You want a list of the numbers that appear in both lists?
I gave you a solution to what you described, you will need to explain better
yes but not the numbers that are duplicates, instead I want the number of duplicates, so in the example 1 because there is one duplicate
So you want to check whether there's at least 1 duplicate?
yea
It's a helper method in java.util
ok let me test that
Returns true if the two specified collections have no elements in common.
from the docs ^
ok thats what I wanted 😄
Bump
how do I set custom texture for a custom item?
ItemMeta#setCustomModelData
How can I make stationary water in 1.18.2?
and then use a resource pack
setType(Material.WATER, false)
thanks
why this is a string -_-
i think it returns for e.g. "r1.18.2"
idk
but how to get server version then?
What are you trying to do with server version?
Hey,
How would I overwrite the bukkit permission system?
In java 8 times, I'd just replace the perm field with a custom one, but I can't do that with Java 17, because it's final
if (server version >= 1.14.4){
register a event
}
You can use String#contains, so Bukkit.getVersion().contains("1.14")
You could take a look at how LuckPerms does it
but event wouldn't register in 1.15+
Oh you want to check If the version is greater or equals than
Yes
There is no easy way, you need to get around with the value from Bukkit#getVersion
thats also string
However I found a lib created by mfnalex, here's how he did it.
https://github.com/JEFF-Media-GbR/JeffLib/blob/89dfd7941e6ae879d4af70f9ba1c5fe8790d4ac8/core/src/main/java/de/jeff_media/jefflib/McVersion.java#L62
And there's the confusion... Even though the field is final, it just uses setAccessible and is done with it
And the example usage
public static void registerBlockTracker() {
if (McVersion.isAtLeast(1, 16, 3)) {
Bukkit.getPluginManager().registerEvents(new BlockTrackListener(), main);
} else {
main.getLogger().info("You are using an MC version below 1.16.3 - Block Tracking features will be disabled.");
}
}
umm, I guess I can replace the r with null and cast to long. then check?
Final is fine to replace with reflection
As long as it isn’t static final
Wait, what? 😅
That would've made so much stuff way easier ._.
Is it possible to create a miniature player npc?
Would I have to create a baby zombie NPC and then like apply a skin to it somehow?
you cannot change skins from certain mobs without a resource pack
Gotchu. Could I create a player npc but just make it smaller then? I'm just wondering if this is possible at all.
No
😭 damn
?jd-s
or using existing stuff for it like ModelEngine 😛
uhh how do I create a boss bar that shows an entities health
Bukkit.createBossBar
then use repeating task to set the progress to (mobCurrentHealth / mobMaxHealth)
Ye
I usually use EntityDamageEvent or something like that
sure, that works too. doesn't really matter whether it's an event or a runnable as it doesn't do anything besides dividing two numbers 😄
true
if i wanted to display a actionbar longer than a few ticks, would i need a runnable?
or is there another way?
You gotta keep sending it
alr
i was reading this and was thinking if i couldnt let the value of the bossbar change when an event happens
would still need a runnable ;-;
How mysql
Is so trash
At creating double instances
Fuck you mysql
No one uses you anyways
🗑️
What a waste of time
Only flat file
double instances?
how do I set the max health on the bar
wdym? setProgress(1) and the bar is full, 0 and it's empty
oh
Yay floats
im confusion
Ye but if I set progress to the current health
^
currentHealth / maxHealth will always be a value between 0 and 1
e.g. 50% health out of 40 max health will be 20/40 = 0.5
Hi! I'm running a paper server and I want to make new entities that behave like villagers (namely a villager that has the model of a pigman and a villager that looks like a player character but without replacing any original villagers). How would I achieve this the easiest? I'm not sure if this can be done with some /summon shenanigans but so far I'm stumped. Could this be easiest done as a plugin? Should I make a forum post instead?
so u dont need to set the max?
no, you always set the bar to (currentHealth / maxHealth)
bossbar.setProgress(currentHealth/maxHealth)
I would recommend using LibsDisguises for this tbh
packet hackery
Damn, I've been thinking about if such a plugin existed but couldn't find one
Create new entity and change its goals to villager ones
If only it was that simple
there are a lot of instanceof checks and villagers have a weird goal controller
Plus goals don’t cover the trade system
I mean the easiest way is to intercept spawn packets
Eh
You can always create a new goal
ReplaceEvent replaceEvent = new ReplaceEvent(this, replacementType, message, player);
System.out.println(replaceEvent);
Bukkit.getPluginManager().callEvent(replaceEvent);
System.out.println("After " + replaceEvent);
The server keeps hanging at callEvent, "After" is not getting print
[15:50:30 INFO]: me.tvhee.advancedreplacer.api.event.ReplaceEvent@35c1b15
Good luck with that
villagers still act normal even if you remove their goal controller
they have routines and "conversations"
do you call the same event as the one you're listening to?
if you kill one, they will snitch to each other and make a bad reputation
increasing their trade prices
No I am not listening for the event anywhere, just an API event
And currently no other plugins are listening for it
show your code for ReplaceEvent
I wonder if you're calling your event async and it throws an exception because async events need a param saying they're async
and multithreading often hides exceptions
okay then it's most likely async
super(player) -> super(player, !Bukkit.isPrimaryThread())
should fix it
Ok I will try
Method not found
Oh T is capital
Packet listeners are async
how to fire an entity towards the player so that it is random from the right or left, but towards the direction player?
if I use #getPlayerDirection().add(new Vector(randomx, randomy, randomz)), it will make it go in any direction
@echo basalt That seems to work fine, thanks!
yeah my shift key has been failing lately
:despai
bruh
I will name it AsyncReplaceEvent, better I guess
That also have the boolean for async
subtract the player’s position from the entity’s. Add random motion. Set that displacement as the velocity
Vector entityVec = entity.getLocation().toVector();
Vector playerVec = player.getLocation().toVector();
Random random = ThreadLocalRandom.current();
int angleOffset = 10; // 10º left or right
double angle = random.nextDouble() * angleOffset*2 - angleOffset;
Vector direction = entityVec.clone().subtract(playerVec);
direction.rotateAroundY(Math.toRadians(angle));
entity.setVelocity(direction);
rotateAroundY fuck off if player look tô ground
I don't see how the pitch matters there
I'm rotating a random angle
and rotateAroundY messes with X and Z
wait
example, I have a method that returns the barrel of the gun, based on some values of the player's direction, I use rotateArounsY but if the player looks up or down this happens:
If they look up or down then rotating around the y axis is not what you want
but the way i need to make it look like in the corner of the gun and rotating around the y-axis
it would look so much better with the texture lol
for some reason boss bar isnt showing , lemmie send code
double maxHealth = boss.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
double currentHealth = boss.getHealth();
bossBarID = Bukkit.getScheduler().scheduleSyncRepeatingTask(BossesMain.getInstance(), new Runnable() {
@Override
public void run() {
bossBar.setProgress(currentHealth / maxHealth);
}
}, 0, 1);
if (boss.getNearbyEntities(50, 0, 50) instanceof Player player){
bossBar.addPlayer(player);
}
}```
you have to keep sending it
I do
also if (boss.getNearbyEntities(50, 0, 50) instanceof Player player){
collection cant be nstanceof a player
cant type with ice cream in my hand lol
?
that method is returning some kind of collection of entities
ye
wait
do I have to check if it contains players?
loop over it and chheck if there are players inside and add them
for entty e : boss.getnearby { if e insanceof player { bossbar.add((Player)e) } }
let me eat my ice cream before i can type normal lol
alr
that was some serious dedication eating that
gimme those too
it's fudge bars from food lion
ye it shows now
but
it doesnt updated for some reason
public void showBossBar(){
double maxHealth = boss.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
double currentHealth = boss.getHealth();
bossBarID = Bukkit.getScheduler().scheduleSyncRepeatingTask(BossesMain.getInstance(), new Runnable() {
@Override
public void run() {
bossBar.setProgress(currentHealth / maxHealth);
}
}, 0, 1);
for (Entity e : boss.getNearbyEntities(50, 0, 50)){
if (e instanceof Player player){
bossBar.addPlayer(player);
}
}
}
You gotta calculate the health inside the runnable
You’re just using the old value every time
;-;
cannot resolve method ‘super(net.minecraft.server.level.ServerLevel)
trying to make a custom entity
the constructor’s super method is underlined in red
send code
send ice
yeah ice
ice?
lol
🧊
um actually i can’t send my code because my school wifi won’t allow it
but uh
i’ll get back to you on that
alr
now how do I make it remove players who isnt near the entity
i can load PDC data from player instances only when that player is online right?
check that in the same runnable
set their health - amount
I was referring to altering a raw damage that a melee can do, for example
I see that DamageModifier is deprecated but I think I don't need it anymore
i mean the line giving the error i can just type out
super(((CraftWorld) world).getHandle());
and that’s in the constructor of a class that extends Villager
Iirc it needs an EntityType also
EntityTypes.VILLAGER, ServerLevel maybe?
Something like that, not 100% sure what it is exactly.
[11:31:03 ERROR]: Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:314) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:875) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity.teleport(CraftEntity.java:236) ~[patched.jar:git-PaperSpigot-"4c7641d"]
[11:31:03 INFO]: shakiz[/172.18.0.1:49466] logged in with entity id 723 at ([world]-226.9407122602794, 67.0, 536.1383005521543)```
uhh idk how to fix this
public void onJoinEvent (PlayerJoinEvent event){
Location spawnLocation = Utils.getSpawnLocation();
Player player = event.getPlayer();
player.teleport(spawnLocation);
Utils.clearChat(player,250);
player.sendMessage(Utils.CC(""));
player.sendMessage(Utils.CC(" &f&lShakiz&b&lNetwork&r "));
player.sendMessage(Utils.CC(""));
player.sendMessage(Utils.CC(" &fWelcome &b" + player.getDisplayName() + " &fto the network !"));
player.sendMessage(Utils.CC(""));
player.sendMessage("");
player.spigot().sendMessage(Utils.discord());
player.spigot().sendMessage(Utils.website());
player.spigot().sendMessage(Utils.creators());
player.sendMessage("");
player.sendMessage("");
}```

i never got an error like this before
First, Paper 1.8.X is garbage (breaks many plugins), second, I recommend you to update
update what ?
Your server
i didnt realize i was using paper f
eh i use both 1.8.8 and 1.18.1 on other servers
I fixed my problem that there is I random nms class used. It was not randomly use, the name of it was wrong! This was because of I used the remapped nms code and i didn't get reobfuscate the right way. So how can I reobfuscate it the right way?
I looked at a older of the plugin, and it doesn't even re obfuscate anything
Are you using Maven or Gradle?
Maven
?1.17
Install 1.17 with BuildTools: https://www.spigotmc.org/wiki/buildtools/
nope not
that
wait
Scroll down to the 2nd post by md_5, there's a guide for remapping using maven.
Ok, I run package, but I keep getting this error:
hey, if i want to get world face liek NORTH EAST WEST SOUTH
is there a enum?
or something?
Do a clean package and make sure you've ran BuildTools
BlockFace
Is it a good practice to pass in my JavaPlugin if I only need the logger?
thx
Bukkit.getLogger() is a thing I think
whats even te difference between those two loggers?
a lot
Bukkit is the generic logger, the plugin logger is the plugin-specific logger
the better question would be why one would need the logger in the first place
Always use your plugins logger where you can.
why is it even possible to access the bukkits logger then?
Bukkit being bukkit
kek
Because it's a public field that they can use in their classes
Just because you have access to it doesn't mean you should use it
So I should just pass in the logger?
I ran clean and keeping this error. I am 100% sure that I ran build-tools
using the server's logger can generate tick issues with large amounts of log spam
I imagine the same would be true for the plugins logger
not necessarily
you can run your own logger on a separate thread
is currently fighting log spam on the main thread for a fabric server
I mean you can but you really really shouldn't be logging that much
Because Bukkit wants to log things too? 😅
Bukkit needs to ask for my consent before logging to my console 
a legacy implementation for Advancements pushed MSPT to 1800
and was generating a 5Mb logfile just on startup
Sounds like a dev problem 
yeah it is
Logger abuse
👍
so far i've managed to get the MSPT spikes down to a max 83
[12:04:23 INFO]: UUID of player shakiz is 3feba136-2df5-33c1-afb5-75b681ae5bb8
[12:04:23 ERROR]: Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT
[12:04:24 INFO]: shakiz[/172.18.0.1:49968] logged in with entity id 264 at ([world]-215.57224306261594, 64.0, 533.1253183677277)
[12:04:26 INFO]: shakiz lost connection: Disconnected```
ì never got this error before
Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT
To me it looks like there isn't enough information
should ask the paperguys what went wrong
Still using paper
am not
[12:21:06 INFO]: You are 52 version(s) behind```
@viral crag ?
idk am new to this
[11:31:03 ERROR]: Could not pass event PlayerJoinEvent to Core v1.0-SNAPSHOT
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched.jar:git-PaperSpigot-"4c7641d"]
You are 52 version(s) behind
i did /version
update please
^^
how do i check what version am using
most people just read their server file name, since thats the fastest
You don't you just update using buildtools
😛
Who cares what version you're using it's behind build a beautiful brand spankin new one with buildtools
how do i paste a link ?
depends what the link is to
this is the one am using
Everything
idk
?bt
that one have a nice builtin exploit?
this is the server.jar file am using *
almost, nft guys have that title now
the snapshot afaik
but will this fix the issue ?
Maybe but it'll help fix the fact you're a scary amount of versions behind
thinks there is no way to fix the 1.8.x issue
Ah I found the issue missing a 1 in front of the 8. 1.18 aha problem solved
The event problem is possble to fix if you can get an error that tells you something useful
?paste
30.03 16:29:59 [Server] INFO java.lang.NoClassDefFoundError: com/gmail/dejayyy/killStats/ksMain
define your class
how do I do that?
gmail oof
?
does not know how to respond to that
paper 
whats wrong with paper
It's paper
this is a spigot help server
short answer is ... the paper guys are ex-spigot
btw the killstats plugin is broken and has been for a long time
you can fix it yourself if you want to use it: https://www.spigotmc.org/threads/killstats.37073/page-2#post-3851321
drama? lol
you can interpret it however you wish
hehehe
the only thing I am currently aware of is a rumour of a hard fork soon
hard fork?
okay i got it but its a folder rather than a jar file
yes, you would have to compile it .... you are asking for support in a development channel ...
where else should I ask?
not continue to use source after a certain point
I just mean that if you do not know how to program or compile a plugin you might need to do some research
i know how to compile
i just
dont code so
that didnt come to my head
to do that
but now I understand
Is there a better way to do Stream<Path>#toArray() as Array<Path>?
needing a lib idea
World Generator, even though there are some out there.
eh
Oooooor, Region Library.
Similar as to what world guard has, but in a library, ya know?
Or is that bad as well ?
i feel like the idea isnt so original
Okay just so we're on the right page, a Library is supposed to make the code easier to understand for the person thats using it right?
ye
wat
Yeah I'm retarded I know..
Ummm, something that'll sync player's data and server data using a database, my need to be MySQL
Does that make any sense ?
the new java 18 vectors for spigot
I get this error when i try to execute the command
org.bukkit.command.CommandException: Unhandled exception executing command 'economy' in plugin CoStrength v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:897) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2287) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2098) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2079) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-177]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at io.github.thelordman.costrength.commands.economy.EconomyCommand.onCommand(EconomyCommand.java:18) ~[CoStrength-1.0.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 21 more
anyone know whats up?
all of my other commands are working fine
and i have registered the command
accessing a zero length array
The stacktrace does not lie
well im not seeing anything causing this error in the code
EconomyCommand.java:18
uh
line 18
yes, but yours is empty. it has no element zero
make a database design for me
When I am running a piece of code to spawn in a npc I get an error saying CraftServer can't be cast to MinecraftServer but when I change it to not have that, it brings up saying CraftWorld can't be cast to WorldServer. Even worse is after even fixing that it still errors but this time with no stacktrace just an error saying the same line is causing an error.
EntityPlayer npc = new EntityPlayer((MinecraftServer) player.getServer(), ((WorldServer) player.getWorld()), new GameProfile(uuid, name));
Before Fixing
org.bukkit.command.CommandException: Unhandled exception executing command 'npc' in plugin QuestTest v1.0-SNAPSHOT
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R2.CraftServer cannot be cast to class net.minecraft.server.MinecraftServer (org.bukkit.craftbukkit.v1_18_R2.CraftServer and net.minecraft.server.MinecraftServer are in unnamed module of loader java.net.URLClassLoader @58d25a40)
at me.ispeakweeb.questtest.NPCManager.createNPC(NPCManager.java:25) ~[QuestsTest.jar:?]
at me.ispeakweeb.questtest.QuestTest.onCommand(QuestTest.java:35) ~[QuestsTest.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
After Fixing
org.bukkit.command.CommandException: Unhandled exception executing command 'npc' in plugin QuestTest v1.0-SNAPSHOT
Caused by: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_18_R1/CraftWorld
at me.ispeakweeb.questtest.NPCManager.createNPC(NPCManager.java:25) ~[QuestsTest.jar:?]
at me.ispeakweeb.questtest.QuestTest.onCommand(QuestTest.java:35) ~[QuestsTest.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
how do i check if a string in an array doesnt exist since if (args[2].isEmpty()) doesnt work
if (args.length > 0)
oh yeah true
i am trying to compile it but eclipse is saying no projects found in that repo
alright it works now thanks
you likely need to setup maven or gradle
0
it starts at 0 also FindFirst is a thing
how do I do that?
start by figuring out which one the project uses and get those plugins that eclipse needs
how do i figure out which one the project uses?
Eclipse comes default with both
You could use IntelliJ instead of Eclipse
IntelliJ sets it up automatically
okay
is there a pom.xml file?
then it is likely gradle and you will have a build.gradle file
hmm nope its a bare java
after I have IntelliJ how do I compile it?
Hi, i was wondering how could i make a sort of entry for a Constructor that will define what will happen to the selected entry whenever its picked. As you can see i'm doing a queue system
like a Consumer but i don't really know how do they work
?
how do consumers work? could you help me please?
is that supposed to spell plugin?
You click the run button to compile your code
bruh IntelliJ is paid so i gotta buy it before i can compile
im just looking for smth
to compile the plugin
once
and be over with
you get the commercial version or something?
community is free
maybe let me see
oh yeah I did
lol
a consumer is something like
Consumer someConsumer = event -> {
System.out.println(event.getPlayer().getName());
}
void onEvent(Event e) {
someConsumer.accept(e); // will execute the sysout stuff
}```
I'd like having a system that has multiple entries and a runnable that every 25 ticks takes the first entry of the list do some stuff (and i want to specify this. How can i specify a list of code that will happen when an entry is selected?) and then removing that entry.
For example i have a list named PLAYERS_TO_WARP and every 25 ticks it takes the first entry of the list and warps it to the hub. My question is: How do i specify this last thing? How do i specify that the players will be teleported to the Hub?
hope its clear
or if you write it like this
Consumer<Event> someConsumer = new Consumer<>() {
void accept(Event event) {
System.out.println(event.getPlayer().getName());
}
}```
stack
basically
e.g pass a consumer to someone
i have absolutely no idea of how this work
then do consumer.accept(<T>)
On the github page for the project, click the button marked "code". Then click the copy to clipboard button for the URL.
In Eclipse File menu -> Import.
Expand the Git entry, and select Projects from Git (with smart import).
click next and select Clone URI in the next menu.
Click next and everything should be filled in for you.
Click next and it should be imported
itll run the code in the consumer
Create a new project
yes but
i have the admit espresso man's link is better
how do i clone
:)
from

