#help-development
1 messages · Page 198 of 1
you'll have to make a clause disregarding regular eggs
!= is a thing
Oh, maybe I chould check if it contains _EGG so 🤔
thank you, I'll try some things ^^
There are some non monster eggs too
but if you want just egg ig you can just Item#getItemMeta() instanceof SpawnEggMeta
Make a hash set or that
OHHHHHHHH you save my life dude
You were going yo die 😳
Yeah, my life said I had 10mn to do it or she would left me alone and steal all my goods
the command mvn is not found. I reinstalled maven and added to my path, but still not found
If your on windows who knows
Windows is weird
If your on Linux just add the vars to your .bashrc and you'll be fine
It's windows 😄
?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.
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.
no
is there any documentation on the md-5 specialsource-maven-plugin?
I can only find a github repo with a relatively empty readme
only 23 ms 🤡
lmfao
is there a way to get an anvil block that is used in PrepareAnvilEvent?
can some 1 help plz?
where can i download the mojang authlib library?
just use maven or gradle to depend on it
oh so i can just add the dependency without having to install anything?
<3
is there a way to get an anvil block that is used in PrepareAnvilEvent?
the code
Is there an API function to return a random valid enchant within a level range (the one used in NMS for e-table)
not that i know of. but you could probably make one yourself
although the only way of getting an enchantment's max level is through nms i believe
really?
aperantly so lol
yeah
well then its really easy
and minimum level is normally 1, but just in case you could use Enchantment#getStartLevel
in case Mojang decides to add a new enchantment starting at level 2
i doubt that but yea. sure
cool, thanks, I'll take a look tomorrow!
Caching layer
what is the best way to test things on "fake players" a localhosted server?
im so bored
Apparently bungeecord 1.19 totally broke serverkickevent
in practice now only the disconnectevent gets fired, this is making development harder, i mean, why
probs being dumb in some way, but java public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { System.out.println(event.getPlayer().getName() + ": " + event.getMessage()); } isn't firing seemingly?
oh, ok
sorry, new to bukkit/spigot
It's fine, you're doing better than 90% of beginners
and i do have @EventHandler
Did you register the listener?
public ServerMessage(SaltyBot plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}```
Did you initialize that constructor?
new ServerMessage(this);```
Okay..
in my main file
And is the plugin loading?
Fr
it is loading, /plugins does list it
Okay
Now that we have exhausted the common blunders
I'll ask to see full code for both classes
?bin
?paste
might wanna use the JavaPlugin#getLogger
instead of using sysout
ok
i know this is probably just java and not spigot spigot specific, but when I try to declare the logger inside the serverMessage class, it complains it can't be referenced from a static context, but if i declare it in the main class, i don't see anywhere to pass it?
someone has any idea about bungee kickevent? i mean what's going on
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
does any 1 know why this doesnt work when i give an item to an allay?
the allay class extends InventoryHolder
ignore that plz
🙂
basically im looping though all entities (that have an inventory) in the world and see if they have a dragon egg
it works with a hopper minecart but it doenst work with an allay
im trying to figure out how to use the logger that bukkit/spigot has since you said to not use System.out.println
trying this, it says cannot resolve symbol getLogger
lmao
no, im using a dot, i thought i remembered that # was the way to do it in doucmentation or whatever
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { Bukkit.getLogger.info(event.getPlayer().getName() + ": " + event.getMessage()); }
mb
yea, i shoudlve caught that in this
well, it's logging now, although didnt i see somewhere it was supposed to say what plugin logged it?
[15:25:07] [Async Chat Thread - #1/INFO]: kirjorjos: t
ok
@last temple can u help me there?
ok
it is now?
[15:25:07] [Async Chat Thread - #1/INFO]: kirjorjos: t
[15:25:07] [Async Chat Thread - #1/INFO]: <kirjorjos> t
```from 1 message sent
my plugin can't seem to find craftplayer
how can i add it?
im on paper and i use maven
it doesn't find it when i use spigot aswell
my plugin can't seem to find craftplayer
how can i add it?
im on spigot and i use maven
bruh some 1 plz help
do allays even have inventories?
They do, yes
holy shit its the dude from thread ive been looking at
then why doesnt this work?
goofy ahh spigot not working again -_-
at what after size is good to do a Binary Search?
why do you need binary search?
or what are you searching for anyway?
basically a general question
Someone can help me with BungeeCord
needs a Binary Search to implement a Search Function
usually HashMaps are better for most things
I need a list here so
honestly binary search is pretty quick in any case
? 😄
yeah also is there a way I can search for a HashMap if key name for example String contains given value?
you would have to check every single value which is significantly more than the usual O(1) you optimally get
same as a list but more memory usage basically
help!!!
try console logs to see what it does?
we still have no idea what youre trying to do in that code
also what "allay" XD
from here @crimson terrace
still, whats an allay
oh shit, never seen that
mob vote 2021
new mob
looks nice
they're pretty pointless
you give it an item, it picks them up drops them to you or on a noteblock/jukebox iirc
well Allays seem to be LivingEntities and InventoryHolders
does Java stop the checking when you're using && and the first value is false?
so basically u can give them an item but it doesnt count as putting the item in the inv i think
mojang adding useless mobs are usual
yes exactly
so I dont know why it wouldnt work. maybe the item they hold is separate from their inventory?
but it doesnt work
yes
maybe it requires a different method to get?
thats my guess
but if you use binary & it won't
how tho?
i think this is the problem
well, i gave it the egg
entities dont have a hotbar right?
just debug it a bit, check whether the method passes for the allay
nvm they dont lol
(use of google translate) Само английски тук
is there any player dmg event?
Example: (when player takes damage)
Знам английски
type it then
thanks
Какво ще стане, ако не пиша на английски?
for clarification do i put that in the arguments like this -() or when setting the variable use that line
ok
but it gives me an error
thanks!!
1 quetsion.
why didn't you add static
at the start of making the function
ok thx i just started coding lol :p
where do you get the IP off of a Connection in bungeecord api (a string ip)
no worries i fixed it i accidently put it in the argument
You should Google what static exactly mean
It basically binds method to class instead of instance
It can be easily abused
WILL ANY OF YOU HELP ME OR NOT?
well you didn't speak English
its probably somethign wierd like most of them
true
NOW ARE YOU SATISFIED THAT I WRITE IN ENGLISH?
yes
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!
bulgaria?
how do i decrement the worldborder in a player variable
Bulgarian ABC has Russian characters?
any clue?
and?
Was just wondering... Actually didn't know that lol
#getAddress returns a SocketSomething i forgor 💀
okay do u speak bulgarian
tysm, and to be clear, does this line of code set the worldborder to 100x100?
getServer().createWorldBorder().setSize(100,1);
разбираш български
да
ясно
Let's stop because this is not Bulgarian channel
Is this... da?
you mean #getAdress again in the socket thingy
it means yes
ok srr
hmm ill check it out later ig
Create the border so you have it as an object, then set its size
oh so put it in a variable first?
Wouldn't have been surprised if it would mean no. Just actually remembered the characters, and just toughts, it says "DA".
Which I tough means yes
as of using Russian characters
yes. If you want to manipulate it or send it to a Player you have to have a reference
Ah gotchya
btw, whats the point of this?
@EventHandler
public void onJoin(AsyncPlayerPreLoginEvent e) {
Player player = Bukkit.getPlayer(e.getUniqueId()).getPlayer();
just cause it highly returns null and I hate it
(UUID is null...)
(dont ask how, either why)
(idk as well xd)
thats bad. There is no player yet in Asyncpre login
if I'm gonna creat a variable should i make it a Server variable
can I manage player permission in LoginEvent then? xd
just because something... seems a bit buggy....
no
I mean...
well yes in Login, not in PreLogin
ok
I have prefix on chat, and player list, which means I have the correct permission...
but server can't use prefix on join message?
ok so, this line creates a variable of the world border that can be effected
yes it can, but it depends on yoru permission plugin. At Login there is no valid world for the player. It will always return the default main world
ok thanks so much
or the player
if reply to me: aswner is kind of... however, it was the same as when I had it as PlayerJoinEvent, and AsyncPlayerPreLoginEvent as well.
should I just... Delay join message a bit then?
Sorry, during the PlayerJoinEvent you can get the correct World permissions. During the PlayerLoginEvent it always returns the main world.
asynclogin event has only offline player and player obj is created after this event
Ah. So there is a difference between Login and Join
so will this block of code make the worldborder smaller by 1 everytime player takes damage
yes
Login = they are currently Logging in and there is a partial player object.
preLogin = no Player object, only UUID and IP
asyncprelogin = async studf before login, smart to handle database stuff here for example, when its finished then player obj is created and then playerjoinevent happens
that explains lots of things. Thanks.
However then I guess I will just delay join message.
Instead we have ItemMeta... 😒
You should not have to delay the message. Its in the PlayerJoinEvent so all the players details are available, BUT be sure you don;t run your event before normal priority or you may run before your permission plugin
bukkit doesnt
Now I am sure that permissions are loaded correctly. The only thing I need the delay (one or two ticks only) is because of the prefixes, because a VIP player cannot have the prefix of a default player
because generally speaking, builder pattern is for immutable objects
All of that shoudl already be set, but it does depend on your permisions
what the plugin literally does, is just gets the player permission, then returns the prefix, like §4
yes using §4 cause I was lazy
and what I realized is that since quit message has prefix, permission is not loaded correctly, so setting join message to "", then broadcasting it will do it I guess xd (ofc after a little delay)
now it works :D
Theres something up with your permission plugin if the prefix is not already loaded in the PlayerJoinEvent
or just my stupidness 🙃
like... as always... i am stupid. 🤣
anyway thanks for the infos and tips :D
can I store a map in a yml file?
well I want to store player data, with mapping names to locations
Do you need the data when the player is offline?
no
Then the final question is, how much data are you wanting to store?
🤷♂️ a lot?
If its a lot then yes use yaml
hey it doesn't work, am i doing something wrong?
code line:
serverwb.setSize(getSize -1);
oh ok
nvm getAddress is deprecated
bungeecord
there's getSocketAdress which returns a SocketAddress class which is basically EMPTY
Serializable
that's it
idk 😦
it's an abstract class though but I can't see any Implementations
this is stupid tbh
?jd
Hello, I have a question real quick. What's the difference between PlayerLoginEvent and AsyncPlayerPreLoginEvent.
As far as I know the AsyncPlayerPreLoginEvent is called before the PlayerLoginEvent but what is the difference between disallowing the player from joining using the first one and second one?
You can delay the AsyncPreLogin while you do lookups
you can;t delay the PlayerLoginEvent
like this serverwb.getSize(-1);?
Delay?
So it takes longer to connect?
then what am i supposed to do
because this is my code related to the worldborder
public static void onPlayerDmg(EntityDamageEvent pdmg){
WorldBorder serverwb = getServer().createWorldBorder();
if(pdmg.getEntity() instanceof Player){
serverwb.getSize(-1);
itsd Async so its running off the main thread. you can do whatever you need (within reason) and only delay that player joining not the whole server
Oh alright thanks
you don;t create a new WorldBorder every time. you create one and send it to the player, then you modify the players border each time you want
ok i'll move the variable creation above the function
when teh player joins, set his border
then if you want to decrease itjava WorldBorder border = player.getWorldBorder(); border.setSize(border.getSize() - 1); player.setWorldBorder(border);
ok thanks
If I've stored something in a yml using:
pConfig.set("Homes." + name + ".X", loc.getX());
pConfig.set("Homes." + name + ".Y", loc.getY());
pConfig.set("Homes." + name + ".Z", loc.getZ());
How would I go about looping through each name and getting the coordinates? I tried:
Map<String, String> homes = (Map<String, String>) pConfig.get("Homes");
for(String name : homes.values()) {
p.sendMessage(name + ": " + pConfig.get("Homes." + name + ".X")+ ": " + pConfig.get("Homes." + name + ".Y")+ ": " + pConfig.get("Homes." + name + ".Z"));
}
But got this error:
well they are stored as doubles, and I thought it would map "Homes" to "{name}"
either way it still says cannot cast
ok so logging pConfig.get("Homes"); shows
how do u check if an item is any shulker box (not like a specific color)
Tag.SHULKER_BOXES.isTagged(Material)
yes
so how do I get a list of the names of the homes with the x y and z properties
:/
like this?
yep
thx
or getValues() will return you a Map
like this? claerly not cus error
No, the name is the key in the map
here is the format:
Homes.Home1.X: 0.0
Homes.Home1.Y: 0.0
Homes.Home1.Z: 0.0
Homes.Home2.X: 482.0
Homes.Home2.Y: 89.0
Homes.Home2.Z: -1728.0
Anyone know how to remap your own plugin to use classes that extend nms in another plugin? :p
your yaml should not look like that
i want a list of the homes (Home1 and Home2) mapped to the X, Y, and Z values
thats not how it looks
not with the code you showed
Homes:
Home1:
X: 0.0
Y: 0.0
Z: 0.0
Home2:
X: 283
Y: 24
Z: -1278
It would look like that
^
so if you get Homes you are being returned a MemorySection with keys of Home1, Home2
MemorySection homes = pConfig.get("Homes");
homes.getKeys(false).forEach( key -> {
sysout (key);
sysout (homes.get(key + ".X"); });```
fixed 🙂
also how do u check if a player has any shulker box?
pseudo of course
that hard?
Inventory has a contains method
Which takes a Material
oh different Materials.
probably shorter than checking 56 slots 🙂
?
no, inventory
well yes
you could use that code and then Inventory.contains(material)
I'd argue that's a worse way to go about it because Inventory#contains() actually does iterate over all slots already
You're going to do way less iterations if you iterate over the inventory slots once and check if the tag contains the current slot's material
Only 36 iterations in the loop and an O(1) Set check
for (ItemStack item : inventory) {
if (item != null && Tag.SHULKER_BOXES.isTagged(item.getType())) {
return true;
}
}
return false;```
(I always forget if the iterator contains null items, so uh... should probably double check that)
It does. Need a null check
so like this is good?
yep
getInventory returns a Itemstack[]?
getContents()
oh ok
this worked tysm
now I just need to get sign input working :/
https://www.spigotmc.org/threads/signmenu-1-16-5-get-player-sign-input.249381/
trying to use this
public static void getNewName(Player p) {
SignMenuFactory.Menu menu = SetHome.signMenuFactory.newMenu(Arrays.asList("", "", ""))
.reopenIfFail(true)
.response((player, strings) -> {
PlayerInteract.signInput = strings[0];
return true;
});
}
public void onPlayerInteract(PlayerInteractEvent e) {
getNewName(e.getPlayer());
setHome(e.getPlayer(), PlayerInteract.signInput, bedLoc);
I don't see the problem
as soon as i get this working ill be done and out of ur hair
nvm it doesnt return for the shulker box (2nd for)
@eternal oxide ^
um
if whats is what i think it is
im stupid
yeah, I never did menu.open(p);
signData.getIntegers().write(0, ACTION_INDEX);
``` it's not liking this
I've never used protocl lib
do u know another way to get input from players without using commands or the chat?
ig for now I'll put in text input
maybe anvil ?
do u have a guide / forum post on how to do that?
already gave you them
It's quite simple
all it does is wrapping and reflections
it just adds getters to all types of fields so you can get the internal values from packets
yeah i was trying to do that but it gave me some weird error. the error was from the code that person wrote
how do I check if an ItemStack is the right tool to break a certain block?
Weird data structure question
Mostly math
How would I go about getting the biggest possible cuboid that contains all the locations within a set (the set can be bigger than the volume, but the cuboid can't contain any location not specified in the set)
how would i give a play an item when an event is executed
Add the item to their inventory
Hi everybody. Can you tell me why my events don't work?
I'm trying to make a GUI that will work as a menu, from where nothing can be taken or put into it. But it turns out that the GUI works like a chest, when you reopen it, you will see the same arrangement of all items inside it as it was when closing (if we put something there or took it from there)
Have you debugged correctly that you are clicking in the correct inventory?
Also you probably don’t need to worry about whether the item stack is an item.
No, how can I do that?
I also had the idea to make a getter for inventory, because I think that just inv is already a different inventory
Well there is a thread on spigot on how to debug really nicely https://www.spigotmc.org/wiki/intellij-debug-your-plugin/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Or an old fashioned way is getLogger().info() or system.out.println
Okay, thank you
[20:52:49] [Server thread/WARN]: Illegal Entity Teleport EntityArmorStand[' '/840, uuid='69cd0542-0cd0-46a8-9fd1-85b31f89ad56', l='ServerLevel[world_nether]', x=-41.49, y=58.00, z=-185.70, cpos=[-3, -12], tl=2844, v=false] to ServerLevel[world]:net.minecraft.core.Position@50c1752c java.lang.Throwable: null
Whats an illegal teleport?
https://github.com/PaperMC/Paper/issues/5380 This might be on the right track.
Also this is probably something to discuss in #help-server
its from my code, and its not a dead entity
(1.19 with remapped NMS) How do you get the correct tool type to break a block and how do you get the tool type of an item
Or in other words, how do I check if an item is the right tool type to break a block (shovel for sand / dirt, axe for wood, etc)
nmsPlayer.hasCorrectToolForDrops(nmsState)
wait why are u returning true to a void?
so im becoming quite confused on how to initialize a final variable inside the onEnable event, and access it when an event is fired, only place i see to pass it is the register event
thanks
Thanks as well but Elgar’s solution works better for what I want to do with it
I checked, but why does it turn out that current inv is different from class inv?
instead of comparing inventories with .equals
just add custom inventory holder
and then check that holder of the inventory player is clicking on is instance of your custom holder
if it is, cancel the click/drag and other events
also add a check that clicked inventory is not null on InventoryClickEvent
Can you give me an example, please? This is my first time working with inventory
because if you click outside of the inventory, e.getInventory() would return null
instead of null
do new MyCustomHolder();
create MyCustomHolder class
and let it implement InventoryHolder
and let it's getInventory() method return null cuz who cares
yes
and now just use it for your inventory
and instead of inv.equals(inv2)
do event.getInventory().getHolder() instanceof CustomHolder
if it is, then inventory is your plugin's menu inventory
also
,
so you will get NullPointerException when trying to get something
you are braking a pattern i guess
So, it turns out, I need to create a new CustomHolder in the inventory class constructor. And then compare e.getInventory with CustomHolder?
oh..
Bukkit.createInventory(new CustomHolder(), ...);```
if (event.getInventory() == null) return;
if (!(event.getInventory().getHolder() instanceof CustomHolder)) return;```
Understood, thanks
FREEJAVALESSONS
checkmybio
Null here because I need to register events. And so, 2 Strings are passed there to find them in the config
i mean
you register events for new instance of enchantmentgui in onEnable()
and create another instances of enchantment gui in your SwordGUI class
you are not registering events for these instances
Then I probably need to create an instance in the Main class
got it
tho
you are breaking SOLID Pattern twice
Especially S
Single Responsibility Principle
don't make your class both work around events and also create inventories and stuff
you should have one class which listens to events
and one class which holds inventories and stuff
connect them by
- making second class a
static utility class - dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Understood you. I've been doing wiki from spigot
if you need any help feel free to dm me
CUZ FREEJAVALESSONS
ahahah, okay
some one idea?
dont initialize it like that
use some method in constructor
or utilise OOP and have a custom item system
is that not supported?
It is not
Just remove the spigot()
hey how can i add some attrubutes to player for eg fire to a player or else should i use something else
Heh? What version are you using
1.8.8
Ah no wonder
but i want compatibility for all
How I can get the Item’s name?
You'll probably have to check the server version and use spigot().setUnbreakable for 1.8.8 and setUnbreakable for the other versions
ItemMeta has a getDisplayname()
I talk about an item which don’t have meta just a Default Item not edited
I mean I’ll maybe gonna need to use some NMS
Try ItemStack#getType#name
Ehh I doesn’t work for colors or other languages
If you want colors you need to use a displayname
I think I’ll need NMS
if you haven’t touched the ItemMeta then displayName is null
ItemMeta#getLocalizedName works?
If you've set a localized name, then yes.
finally I’ll use NMS I guess
Is there any way to play custom sound in resource peck?
Yeah, there's api in spigot to play sounds by name
May I see some example cod about that?
declaration: package: org.bukkit.entity, interface: Player
Ahha we have String sound thx 🙂
how do I send message?
also pog pfp
ye
gimme a sec
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
ah ok
if you want to send a String Message use player.sendMessage(message);
no need to do player.spigot()
hi, I'm a newbie learning to write plugins. I want to customize some item names, like when I use //set command, I hope I can simplify orange_stained_glass_pane to osgp, can anyone provide an idea of how to implement this functionality?
there are gonna be probably a few duplicates...
I just want to change specific names, not all
Whenever I reload my server, my plugin doesn't work.
For example, Every command is disabled. it return only it's usage message.
Above all there was no any error message in console.
Those any one know about this problem? 😢
Let me guess. /reload? @fierce whale
yes reload confirm
break..?
Yes. It can break plugins and cause them to stop working and have issues
Never /reload. Instead Restart the server. Or Stop and then Start it
If your plugin doesn't work after you properly stop and start the server then your plugin is broken.
But still, don't use /reload ever.
ahha..
So...
If I wanna solve this problem..
I have to make new plugin.. than't right..? 😦
No. Just fix what is broken with your plugin
/reload surely is fine for a test server right?
Ahh... Okay let me find something wrong
It will still break plugins in a test server. it is essentially forcing plugins to disable. Then forcing them to enable.
PLugins don't get a chance to properly disable and save etc..
Hey guys, as I know the spigot server is not the multi thread server Therefore, is there way to enable multi thread server?
I use it all the time
Upto you. I'm just stating a fact. Im not here to debate it or anything. It's just how the command works. It forceably disables and enabled plugins. That's how it "reloads" the server. Which doesn't give plugins time to properly go through their disabling methods.
where can I find resources on how the anvil format actually works/what kind of information it stores?
I usually have my plugins automatically be reset when theyre reloaded. they save during runtime and not on shutdown so when I use /reload it still works just as well.
HashMaps are my bestest friend 🙂
Hi guys. I have a certain number of items. How, having this number, is it possible to place objects in the gui in the center?
For example, if I have 3 different items, then they should be in slots 4, 5, 6 (if we are talking about 1x9 inventory)
Use a loop and check if the slot number is the ones you want, an if it is, place an item then continue the loop
math
I've already done it, but the problem is different.
Here is a GUI with 36 slots. Conditionally, we have 10 subjects. Since slots from 0 to 9 are prohibited, then items will be in slots from 10 to 16, and 1 more item in slot 19.
When how do I mean that the last item should be in slot 22
Hey, can we ask about NMS there?
you can ask but we might not know
okay okay 👌
With loottable, how can I change the luck of a LootTableInfo ?
I tried adding the LOOTING_MOD parameter and also adding an item with the looting enchantment, but the LootTableInfo don't accept these parameters for i'm stuck for now :/
Here's my current code:
lemme open an ide
Sure 👌
When I restart my bungeecord server it changes one part of my config (plots.root) to {} even tho I never set that anywhere. That doesnt happen on my spigot server. Through what could that happen?
The only time I set plots.root is in a command
isn't it what you're doing at PlotCommand line 182?
maybe you don't execute the command through, therefore my question doesn't make any sense x)
yeah I dont... its just weird cause it works on spigot and doesnt on bungee
it happens when you restart the bungee right ?
is it clearing the section on stopping or starting through ?
yes, aswell it only changes the plots.root.1 and plots.root.2 and nothing else in the config
on start or stop ? 😂
oh haha i dont really know i will try it again
thats how it looks normal:
maxPlotAmount: 1
plotSideLength: 98
blocksBetweenPlots: 5
root:
'1':
==: org.bukkit.Location
world: world
x: -187.0
y: 63.0
z: 487.0
pitch: 0.0
yaw: 0.0
'2':
==: org.bukkit.Location
world: world
x: -284.0
y: 63.0
z: 584.0
pitch: 0.0
yaw: 0.0
and thats after:
plots:
maxPlotAmount: 1
plotSideLength: 98
blocksBetweenPlots: 5
root: {}
you are creating an empty root section
like this would do? ```java
if (Data.cfg.get("plots.root") == null) {
Data.cfg.set("plots.root", null);
}
whats the issue then?
and you wanna boost it for all mobs?
so ig some are just not dropping antyhing since i'm not lucky enough
that's why i'm trying to increase that luck
what happens if you make 50 much higher
there's others fields through for LootTableInfo.Builder
one requiring a float, another one with long + random
i'm gonna try some of these to see if it changes anything
how did u get the unobf thing ? ;-;
it was hell already to add the nms to my gradle project lmao
ahahah
are you using gradle?
im using paper userdev at the moment, but with spigot i think its not that hard, there is a guide somewhere for maven
https://www.spigotmc.org/threads/1-17-mappings-with-gradle.511184/
this might help?
Just use maven with spigot it's not like gradle is actually better anyways if that's ur reasoning
gradle is better, i just dont know it
Oh boy don't let frostalf see that
you're so right lmao
Ye
the repos attached to this thread are archived, are you sure it'll supports latest mapping?
you can only try?
good point
userdev is great for looking at source
^
https://github.com/PaperMC/paperweight-test-plugin if you wanna try it out
how do i fix that
where can I find resources on how the anvil format actually works/what kind of information it stores?
how do u get an itemStack from a block?
the items the block drops?
or the item used to place the block
if it's the item to place it (like emerald ore, you want the emeral ore block), use Block#getType
for the items it drops i only know a way using nms, but for newer version i'm sure it's possible through a method like break or smth
nvm i meant Item
not itemstack
can anyone help me with this pls?
nms item ? ...
or you meant Material ?
what's "Item" for you
basically what im doing is checking if the shulker box u placed has a dragon egg inside, however this doesnt work
(the 2nd if)
ye, actually ignore this question
wait, can event handlers method be static? never knew that x)
so you want to get the shulker's content basically?
ye, i want to check if the shulker i placed has a dragon egg and if yes, it returns the loaction of that shulker
cast the block's state to a Shulker
it is tho
Yeah
As it extend Container you can use
declaration: package: org.bukkit.block, interface: Container
wdym?
Hello, can someone help me with a code?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I'm getting this error and I do not have two classes that extend JavaPlugin. All I did was copy over one of my previously made plugins, changed the name of it and used it as a base for this one.
Could not load 'plugins\ShinobiMechanics-v1.0.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
Make sure you aren't creating a new instance of your plugin class (the one that extends JavaPlugin)
I don't do that either, I pass 'this' to methods that need to access it
[15:15:16 ERROR]: Could not load 'plugins\ShinobiMechanics-v1.0.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[paper.jar:]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:331) ~[paper.jar:]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:254) [paper.jar:]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:293) [paper.jar:]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:202) [paper.jar:]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:549) [paper.jar:]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_321]
Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:123) ~[paper.jar:]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[paper.jar:]
at dev.bloedarend.plugin.Main.<init>(Main.kt:8) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_321]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_321]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_321]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_321]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_321]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper.jar:]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper.jar:]
... 6 more
Caused by: java.lang.IllegalStateException: Initial initialization
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:126) ~[paper.jar:]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[paper.jar:]
at dev.bloedarend.plugin.Main.<init>(Main.kt:8) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_321]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_321]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_321]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_321]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_321]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper.jar:]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper.jar:]
... 6 more
Could you send your Main class
also what plugins are installed?
Are both of your plugins installed
looks like a duplicate plugin issue
Hold on, I've changed the main method to something different. This seems to fix it but I've got another error now
If you look at the package and class name I suspect that both their plugins share class name and package name
How can i create rank plugin (bungee)?
I'd just use LuckPerms
They probably don't
So I've refactored the Main class to ShinobiMechanics. I've also changed the path to the main class in my plugin yml, but I get this error. No idea what it refers to, does anyone know what it means?
[15:21:11 ERROR]: Could not load 'plugins\ShinobiMechanics-v1.0.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.NoSuchMethodError: dev.bloedarend.plugin.utils.Configs.<init>(Ldev/bloedarend/plugin/ShinobiMechanics;)V
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[paper.jar:]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:331) ~[paper.jar:]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:254) [paper.jar:]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:293) [paper.jar:]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:202) [paper.jar:]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:549) [paper.jar:]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_321]
Caused by: java.lang.NoSuchMethodError: dev.bloedarend.plugin.utils.Configs.<init>(Ldev/bloedarend/plugin/ShinobiMechanics;)V
at dev.bloedarend.plugin.ShinobiMechanics.<init>(ShinobiMechanics.kt:13) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_321]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_321]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_321]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_321]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_321]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:77) ~[paper.jar:]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[paper.jar:]
... 6 more
Line 13:
private val configs = Configs(this)
Does that constructor exist
Also are both of your plugins installed?
and do both of them contain the Configs class
class Configs(private val shinobiMechanics: ShinobiMechanics) {
// Make the HashMap 'static'.
companion object {
private val configFiles: HashMap<String, YamlDocument> = HashMap()
}
fun reloadConfigs() {
for ((_, value) in configFiles) {
value.reload()
}
// Pass the new instance of the configs to the utils.
shinobiMechanics.messages = Messages(this, shinobiMechanics.modules)
shinobiMechanics.events = Events(this, shinobiMechanics.helpers, shinobiMechanics.messages, shinobiMechanics.modules)
shinobiMechanics.commands = Commands(this, shinobiMechanics.events, shinobiMechanics.messages, shinobiMechanics)
}
}
They are
and both contain the same class yes
So I cannot share those for any class or package between plugins at all?
You can share you just can't have two of the same class
To prevent conflicts between your plugins you should use unique package names
So this would not work, unless I have different package names
Change your package name to dev.bloedarend.shinobimechanics instead dev.bloedarend.plugin for example
or make a library plugin that contains these classes. and have both plugins use the library
They don't contain the same things
ah nvm
I've got multiple modules tho, so I'd need to have a different name for all of them right?
dev.bloedarend.shinobimechanics.plugin
dev.bloedarend.shinobimechanics.api
dev.bloedarend.shinobimechanics.v18
....
You can do that if you want it's not required. They can all be dev.bloedarend.shinobimechanics (assuming no conflicting class or package names). It's up to you how you structure your plugin
version specific modules share the same class names
Basically the way Java identifies classes is by their package name + class name
if there's more then one it doesn't know what to do
i see
id do that yeah
domain.project.module is what i usually do
I have a problem: Block#isPreferredTool returns true for dirt and wood and leaves and other blocks even if you are using a pickaxe since it still drops items if you break it with a pickaxe. Is there a method that makes it so it only returns true if the block has the correct tool that speeds up breaking it?
does anyone know of client-side mods to debug invalid packets?
private boolean isPreferredTool(IBlockData iblockdata, net.minecraft.world.item.ItemStack nmsItem) {
return !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata);
}
This is the source code behind it... The only thing i can think of is to use getBreakSpeed for the different tools and return the lowest
would that be inefficient though?
oh yes
whatever
so I would run that for every diamond type of tool and find the lowest number then?
would that work?
I'm trying to spawn a FishHook entity with no gravity that should work on versions 1.8 and up. What would be the best way to do this? Haven't looked into the gravity yet, but something like spawning the entity itself does not work and results in this error:
?paste
use that instead of flooding the chat with code / errors / stuff
its also easier to read
there ya go
something is wrong with the way you're spawning the fishhook
can you send that PlayerToggleSneakEvent as well
This is how I do it.
@EventHandler
fun onPlayerToggleSneak(event: PlayerToggleSneakEvent) {
val player = event.player
player.sendMessage("sneakEvent")
if (player.isSneaking) {
player.sendMessage("isSneaking")
val fishHook: FishHook = player.launchProjectile(FishHook::class.java)
fishHook.velocity = player.location.direction.multiply(2)
}
}
is this kotlin?
yes
You just can't spawn a fish hook with launchProjectile
You have to spawn it some other way
oh yeah you need to get the player's world and add it to the world first right?
(in java)
@EventHandler
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
player.sendMessage("sneakEvent");
if (player.isSneaking()) {
player.sendMessage("isSneaking");
FishHook fishHook = player.launchProjectile(FishHook::class);
fishHook.setVelocity(player.getLocation().getDirection().multiply(2));
}
}
What other way can I spawn it?
Try spawnEntity maybe? If that doesn't work then you might have to use NMS
Tried world.spawnEntity()
What'd it say
I get the same error. It was the method I had tried before using player.launchProjectile
Maybe Google it and see if someone else has figured it out with the API
Could only find some old threads that made their own fishhook by extending EntityFishingHook
the entity for a hook is Fish
that should probably fix your problem 😉
I'll give it a try but it's deprecated
deprecated doesn't mean unusable
It does spawn it in, but, it doesn't live for too long
progress at least 🙂
It despawns because I am not holding a fishing rod I assume
that would be correct
Because when I hold one, it just casts it like normally
Is there a way to bypass this?
Yes there is a way to bypass it
you either use the API to trick the server into thinking the player is holding an item that it isn't
or you use NMS
how do I go from a Spigot BlockState to an NMS BlockState?
nms block stats is not spigot block state
the equivialent would be block data in spigot
ah ok
block states are closer to block entities
well how would I turn the block data to the nms blockstate
there should be methods somewhere to grab it as an NMS copy
the data that is
no guarantees of it working, generally a pain to go from NMS to API or vice versa
specifically CraftBlockData#fromData
ok thanks
fish commandsender
((CraftBlockData) data).getState()
So, to trick it I'd assume you mean to put a fishing rod into the player's hand and then remove it later? I don't really want to do this because the player should be able to hold other items while they are casting the fishing rod. The hook also despawns the moment the player lets go of their fishing rod, so they should be holding it for a long time. So I'm guessing I'll have to use NMS. Is there any method I can use in specific, or do I need to create my own class that extends EntityFishingHook?
that last part
this is why we need more elders of spigot/cb code
if I wasn't here, this person wouldn't have gotten closer to solving their problem 😄
Soo, the code to change this behaviour is in this method:
https://paste.md-5.net/rexuduyimu.cs
I should override this and remove itemstack.getItem() != Items.FISHING_ROD right?
but i did shulkerbox.getInventory().contains(Material.DRAGON_EGG)
sadly chatpreviews are removed on 1.19.3
just in case anyone reads this back (probably not) this is what I did instead java if (item.isCorrectToolForDrops(CraftBlockData.fromData(((CraftBlockData) block2.getBlockData()).getState()).getState())) (item is an NMS item, block2 is a normal spigot Block)
and it worked somehow
but it only works for pickaxes. isPreferredTool would work better for other tools like shovels and axes
what is the player hunger event called? nvm found EntityExhaustionEvent
These are all private tho. To override the method, how should I get these values?
reflection
what's the point of making a method private anyways?
I've never understood that
what does it change?
whats the point of coding
least incompetent spigot plugin dev
why thank you
I just never ended up learning some stuff about programming
I didn't take any classes and I taught myself
Hi, how can i get all the blocks a bounding box contains?
believe so
been a while since I had looked at anything with the fishing rod
So I can use .getClass().getDeclaredField() to get the field, but which object should I use. Should I create new EntityFishingHook inside the custom class?
ah so you do "private Object object = something here"
and a "getObject" method to make it readOnly? that seems to be part of it at least
thats what I got from reading about it
then again I am dumb so idk
I think he has a point there
you should extend EntityFishingHook
I do do that
But I want to access EntityFishingHook's private fields
then spawn your class as the entity since it is extending one already
you need reflection for that
Yea, I googled about reflection and you can get a field by object.getClass().getDeclaredField()
but, I am wondering which object to get the field from.
but I am not sure with updated java versions if you are able to change something from being private though
please
you iterate
well you have two known points
an upper point AKA the max, and a lower point AKA the minimum
Location point1 = <yourfirstlocation>;
Location point2 = <yoursecondlocation>;
Vector max = Vector.getMaximum(point1.toVector, point2.toVector());
Vector min = Vector.getMinimum(point1.toVector(), point2.toVector());
for (int i = min.getBlockX(); i <= max.getBlockX();i++) {
for (int j = min.getBlockY(); j <= max.getBlockY(); j++) {
for (int k = min.getBlockZ(); k <= max.getBlockZ();k++) {
list.add(i,j,k); //or however you are wanting to store the locations
}
}
}
someone send tutorial on completable futures 👉 👈 😊
code example
/shrug if you are not willing to read I don't think anyone woujld just send plain example
Discord smh
here
@wet breach So now I've got my own class, but can't seem to launch it as a projectile, even tho it extends EntityFishingHook.
yeah this is where you are going to have to do some trial and error and digging around 🙂
welp
thank you!
does anybody know, why the zombie dont spawn? working with nms : https://pastebin.com/X0W79HgD
and yes im calling the #spawnAt method
Have you tried setting the entities position before spawning it
instead of teleporting it
no, how?
setPos iirc
ill test it
Make sure to set it before adding the entity to the level
yes
no, isnt working
BotIntelligence.botIds.add(uuid)
this.setPos(location.x, location.y, location.z)
level.addFreshEntity(this)
return this
}```
and i use the 1.19.2 if it helps
Hi, how can I rayTrace for all the entities? I mean literally how can i make a rayTrace?
How does HashMap work?
It is a collection that holds key value pairs
Ig you're not asking about the internal impl
let me see
How can I get a private field by using reflection that is a custom type such as EntityHuman or Block? I can't cast it
yeah, Entity#getNearbyEntities(x, y, z)
anybody?
Kotlin and nms, good luck getting a reponse
actually i need it for a location, but i found how!
what entity is null? Your entity is instanced by you.
when im using Bukkit.getEnitity(uuid) there is no entity
so the entity didnt event get spawned?
Oh damn lol thats tough combo
no idea on Kotlin. In Java you use the nms and call getBukkitEntity
your addFreshEntity shoudl be creating a Bukkit Entity
but that is Kotlin so I have no idea how you are assigning bukkitEntity
you seem to have no assignment for it
the nms to get the Bukkit entity should be (in the Class) this.getBukkitEntity()
You have a reference to a field bukkitEntity straight after adding to the world but no assignment to set it.
yes, this is getBukkitEntity()
I don;t know Kotlin so no idea where/if you are even using that
Do Spigot mappings use Searge or does Spigot have its own format for mappings?
it doesn;t look like you are to me
so the bukkitEntitiy is in java -> this.getBukkitEntity
OK, if that is so then there is no reason for your bukkitEntity to return null
If you set the posRot on the Entity you should not need to teleport it
yeah, but no entity is spawning
this is the problem
and sorry, the entity isnt null
Yeah, Kotlin is all I can say. That is so ugly I can;t really help.
Not really Spigot, but here goes: I wish to save statistics on.. everything. If a player breaks a block, it should save the block type. If a player places a block, it should save what block was saved (not really where, etc). I'm hoping to also being able save these with dates of some kind, so you can sort by last week, last month, etc. What is the cleaneast way to structure the database tables for this and also reaching the highest performance? I'm thinking that inserting each block that was broken will quickly flood the database and make it slow.
okay, there is now spawning a entity for some milliseconds
but then the entity is gone
perhaps your location is wrong?
Hi , iam working on a way to check if the quest started time is the same as now :
this is my code i will be happy for anyone to help with changes :
just want to know if iam doing anything wrong .
That would do it 🙂
thank you
anyone know how to remove Repair from McMMO?
disable in config?
JREE FAVA LESSONS
what event would I use to get whenever the player attacks an entity?
thanks
in that event, event.getDamager(); is the entity that does the damage, and event.getEntity(); is the entity taking the damage?
did u watch taht iceberg coding video
no
yes
if damager instanceof player
what packets are required to display a world?
im assuming just Chunk Data and Update Light after login and then tp the player to the chunk?
does anyone know how to deal with this?
Blocked mirror for repositories: [upstream (http://ci.nametagedit.com/plugin/repository/everything/, default, releases+snapshots)]
Since Maven 3.8.1 http repositories are blocked.
Possible solutions:
- Check that Maven pom files do not contain http repository http://ci.nametagedit.com/plugin/repository/everything/
- Add a mirror(s) for http://ci.nametagedit.com/plugin/repository/everything/ that allows http url in the Maven settings.xml
- Downgrade Maven to version 3.8.1 or earlier in settings```
I don't seem to have a settings folder and changing `http` to `https` sends a 503 response
best thing i saw today
lmao wtf
ello anyone know if creating schematics through the worldedit api purely through written code and not ingame is a thing?
like generating schematic files
or having a set of blocks with positions to set in-game
wondering if i = i == 100 ? 100 : i will be optimized to an if check by the compiler or jit
does the operation work before the condition
or is that just my python lectures leaking in
nvm nah java ternary operators work different
i saved custom name on a arrow and when i tried to get it back it returning null
comma
woher ist die Comma
also check if player::isOnline
}, 400
i misread
a
i thought u were setting it to 1 lmao
just wondering
im not talking bout performance, just wondering
for assignment especially primitives i wouldnt think it would make an impact
and no thats probs the most compact ur gnna get that unless there's some method i haven't come across
i've come across a problem
i'm working on a redstone plugin but it's come to the copy-pasting, and everything gets updated, observers, pistons, etc
also how do i paste down a block in a certain state like a piston that's extended, or a block that's connected to a piston
damn my head hurts imma use the worldedit api
Hi all! I have a question how to get the last message of the player, I know that you can receive it through the Scanner, but it is more for the console. Is there a replacement for the scanner? (I need to compare the received number with another later)
scanner?
just listen to player chat and store it in a map
idk if they changed it in like 1.19.2 tho chat got a bit screwed
I forgot to say, I do not need all the latest messages, but only if the player entered the command
well then use ur command listener and store the message?
using the default command, the params are a primitive string array i think so you can just String#join(" ")
Hello folks, is there a method to check when a player's visual is moving?
check PlayerMoveEvent
no comma