#help-development
1 messages · Page 2215 of 1
aight tyvm 🙂
nws
keep in mind that creates a new item each time its called
but thats not that bad honestly
17+ only if I remember correctly
ok
when would I use static blocks in a project
downloading new java versions can be quite painful
how
idk, i have to manually tell my computer to run specific versions of java
or something similar
ok ig
I mean if you wanna hve multiple JDKs you can just switch the env variables its quite easy
in the windows settings?
you know what environment variables are right?
i used to have to tell run.cmd which java version to use if i were to run like a 1.16 server
:/ how is that easier than changing the environment variable
not sure
👀 so you code
edit system enviromental variables?
If the PATH, ORACLE_SID, and ORACLE_HOME environment variables do not exist, you must create them.
I'm quite honestly surprised
🤷♂️
I had to even post this link
thanks? i guess...
You can just change your jdk version by changing the JAVA_HOME path
its super easy and you could even automate it easily
not sure how to on windows 🤷♂️
there's a method under PlayerDeathEvent that let's you set the message https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/PlayerDeathEvent.html#setDeathMessage(java.lang.String)
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
is it possible to give players the block selection menu in creative mode without giving them the ability to fly or the invulnerability
this
i cant post image
wow
create an inventory and send it to the player
you could probably make a custom menu with a listener rather than sending the actual creative menu but its all preference
with teh first approach you won't need to mess with packets at all
i figured as much, i just wanted to check if i can just give the player the creative mode menu so i dont have to code the custom menu
there is a command for it
method*
Well, technically you can disable ability to fly, and somehow bypass invulnerability, but player still would not see hp bar, so I think it would be better to make creative-like menu using chest guis
i see, ok
thx
Hey I'm trynna create a chest and have it placed on the ground upon player death
how can I do that?
You can listen to PlayerDeathEvent and place chest on player coordinates
placing chest is the part I'm trying to figure out
how do I create an item and have it placed on the ground is a better way to phrase my question
so you are not having the item be placed in the chest?
Yes but I know how to do that I can use the setContents method
My thing right now is I'm trying to figure out how to place a chest down
You can get Block instance from Location (https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Location.html#getBlock()) and then use setBlockData (https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Block.html#setBlockData(org.bukkit.block.data.BlockData)) to replace it
declaration: package: org.bukkit.block, interface: Block
declaration: package: org.bukkit, class: Location
how do I make a block will drop the items when I break it with a specific tool?
Listen BlockBreakEvent and check item in player's main hand. Then spawn item on block coordinates
I think this might be helpful https://bukkit.org/threads/getting-the-item-in-a-players-hand.459347/
kk ty
so your trying to identify if a zombie was knocked into lava by a player?
thats like player tried to swim in lava to escape zombie
but in reverse
if i were to make a custom menu i would have to type the names of every block and item in minecraft onto there....
oh
you can get death message and put it though some sort of method
to check
and see if it is one of those where the player dies in lava running away from zombie
check for the string "tried to swim in lava to escape zombie"
Why? You can just not set their names and Minecraft would use default ones
im making a menu where the player can click on any block or item from the game and get it
checking the name of the mob in the death msg is one way but thats just brute forcing it, there might be a method you can use
in the spigot api but i doubt it
Ah, now I understand
yea, do you know of a list of all mc items in their respective groups?
thats ordered in aphebetical, so i still have to sort the items in their respective groups
building blocks, decorations, redstone, etc
oh dayum
There is a method for it
that thing exists?
i never knew
well i dont think you can get the type of entity from .getDamageCause
your gonna have to track it some other way
maybe someone else can help
following up with my previous question, how can I set the items dropped upon death to the chest then have the chest disappear once the player removes all the items from it?
That would require me to check for a chest open and empty event, however how can I distinguish a death chest vs a normal chest, because I don't want normal chests disappearing when empty
mark the chest somehow 🤷♂️
maybe store its location
I was going to do it with persistent data container
but I only know how to use that with items in inventory not blocks on the ground
also I can't figure out how to set contents to a chest? For some reason it's not allowing me to use the method
For example, this is what I have
`
Material deathChest = Material.CHEST;
playerLocation.getBlock().setType(deathChest);
`
but I can't do deathChest.setContents()?
because that is a material
your setting the contents to a material, is that how it works :/
playerLocation.getBlock().setType(Material.CHEST)
you only need one line
Thanks for the information, I can see why that is now
So in that case, how can I set contents to the chest after I created it??
cast chest to the blockstate
do you not getBlockInventory() and addItem()?
which is from the chest
which you have to get from the blockstate
Chest chest = (Chest) playerLocation.getBlock().getState();
Use PermissionDefault enum values https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/permissions/PermissionDefault.html
declaration: package: org.bukkit.permissions, enum: PermissionDefault
got it already. thanks
Hopefully a quick question - Armor stands don't render if outside the player's FOV, but if armor stands are a passenger of the player, they are always in the FOV. Is there a way around that? Trying to get an armor stand to be invisible in first person, visible in third person.
I don't think there is a way to do this without modifying game client
Something like it is certainly possible, if not specifically for an armor stand, because I saw Origin Realms has cosmetic equipment - things you can wear on your back like a backpack. Talking to people there, it seems you can't see it in first person (e.g. backpack straps), but you can see it in third person.
It almost certainly has something to do with player FOV and the entity not being rendered, because there is no way server-side to detect the third person view.
My attempts to recreate it locally are perfect except for first person view
I think this can be done with custom armor models
afaik that's only supported if you have Optifine, vanilla doesn't have that.
From what I've seen, most of what Origin Realms does uses armor stands, including their really cool gesture system.
Here's my attempt to recreate it so far - https://imgur.com/a/dBHPdVL
It's super close. One idea I had was changing the body rotation of the armor stand, but that doesn't move where the neck of the armor stand is.
It just needs to be even a pixel or two behind the player's head, but the passenger system in Minecraft doesn't support offsets
My next thought is, maybe they aren't using an armor stand, maybe it's a different entity. But armor stands are the only thing with the Marker behavior, so it would introduce false raycast collisions for that client.
I would guess that’s a resource pack with something equipped in the offhand
It's definitely the head slot looking at the model JSON. That's where my confusion comes in, is unless it isn't a passenger of the player, they're doing something sneaky to place it behind the FOV
Could it be the player’s head slot?
Nah the model is offset down by a big amount, it's definitely something above the player
The only way for me to find that out specifically is to buy cosmetic crates and basically gamble for one I can verify with sadly
So the best I have to work with is people I randomly DM'd ingame saying they couldn't see it in first person
One thing I want to try is having two passengers - two small armor stands, the topmost one having the item on its head
I don't know how the game will handle that one
Looks like it makes no difference
hello any help me wiht my plugins?
What's wrong with your plugins?
Anyone know how to tell if an Entity is inside a Structure in 1.19? Like an End City.
There is a way to get nearby structures from a location. You'd then get its bounding box and check if it's inside. As for the specifics (e.g. inside a building vs next to it), not sure. You'd have to do some specific checks like proximity to floor/ceiling blocks
How would I get the BoundingBox?
How to Add Potion Effect On command plugin?
If you have the Mojang mappings, there's a class called StructurePiece, which has a method getBoundingBox(). Obviously if you don't use the Mojang mappings it depends on what version you're writing against.
Listen for mobspawn event
creature spawn event
how?
Means in my plugin when ever someone broke a block then in 3 second a random mob will spawn
So I have to make new method?
EntitySpawnEvent?
use CreatureSpawnEvent
I have to make new class and extend it to CreatureSpawnEvent right?
Okay...
?eventapi
which one should I add
playEffect or addPotionEffect
I need effect just
Like particle effect
Read the docs
neither of those
The docs say what each method does
i think the World object has a spawnParticle method
Yes
To follow up on my stuff here - turns out they have a Fabric mod that they recommend people use, that hides their cosmetic armor stands in the first person. So it's not magic, or some hidden thing I haven't discovered yet - it simply isn't possible without modifications.
https://www.curseforge.com/minecraft/mc-mods/origins-enhanced
to use ```java
ev.spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE,location,4);
get it from the block
you mean ```java
event.world().spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE,location,4);
this?
event.getBlock().getWorld().spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE,location,4);
this?
okay...
lemme try
still showing same error
try with getLocation()
yea still getting error
could you just paste the entire method in here?
?paste
paste your error
@EventHandler
public void onBlockBreak(BlockBreakEvent event){
World world = event.getBlock().getLocation().getWorld();
}```
wtf bedrock slab ;-;
Hi, i'm trying to developer a plugin with bungee 1.19 api, but seems that ServerKickEvent isn't fired when a subserver stops, did something change or am I stupid? The same code works well on waterfall and other forks.
After some debugging seems that bungeecord is calling playerdisconnectevent instead of serverkickevent when a subservers turns off
👍
Seems right to me. When a spigot server stops, players also are not "kicked"
it's just the PlayerQuitEvent on spigot
imho "kick" = admin kicked them. Disconnect because server shuts down = Quit / Disconnect, but not kick
so I have a question: How can I use a mapping with NMS that includes actual names for functions on classes?
yes
Yeah, seems that only kick is working
1.18.2
But now how am I supposed to work on it?
when I use those only 2 classes appear
which don't do anything
you want to prevent a player from disconnecting?
Yep
"only two classes appear"?
wdym?
I use "serverkickevent" on waterfall and works fine
2 random classes in NMS
I cover everything
stuff like NBT don't appear
On Bungee 1.19 only the playerquitevent is fired amd i can't do anything
that's because you're using the incorrect class names. in Remapped, the class names are different
for example "NBTTagCompound" is actually called "CompoundTag"
and it's not "EntityPlayer" but "ServerPlayer", and "World" is actually "ServerLevel", etc
Any idea?
so it's totally normal that your old imports are now incorrect @fierce terrace
Don't use NMS until you have to
On 1.18 was totally fine also on bungeecord, but is broken on 1.19 version
hello kacper, we're going to the end today, you down?
How many hours from now
btw @fierce terrace why do you need NBT anyway?
Oh yea we have nbtapi
idk. I'll invite you to the group dm
I need to store alot of data in items
Then use PDC
it was made for that
WTF is that
it's basically the "API version" of NBT
added in 1.14.1
it's basically like NBT in better
you can also create your own datatypes for PDC. for example you could store a Map<String,List<ItemStack>> inside a PDC
can the client see PDC
I believe so yes
on ItemMeta, yes
well with mods they can
but the same is true for NBT
can we change the size of mobs in spigot?
no
hitbox?
Isn't the client the one that sends the hit packet
I thought it was about stuff like arrows hitting something
if it's about punching stuff, then yeah that won't work
oh
thats means it will not be possible with reource pack also
excuse me guys, do you have any ideas for optimizing and improving this code? Sorry for the emotional damage that could cause the viewing of the code
https://paste.md-5.net/sotoyufeqi.cs
what is it supposed to do exactly?
I was scared of that question ahaha... So
I’m creating an Agencies Plug-in where when you do /agency create it opens up a 'menu' where it asks: Employees, name and initial value of the company. This code is about employees. When you click on that icon it splits the message of the player by comma and checks that for each player written it exists. If one does not exist, notify the player. If everything is valid, if the written player is only one, it takes the message that says "You added the %player% player" if they are more, it takes the message "You added %player% and other %othersnumber%".
ah okay. Well in general it looks fine for me, but you could definitely improve it by for example creating separate methods to parse the input. Then in the event you simply pass the message to your method. Also I think this would be perfect for the ConversationAPI which is included in Bukkit. It might seem a bit overkill at first but when you do stuff like "parsing chat answers" more than once, it's definitely really helpful
is it possible to create a command which works without typing slash?
yes sure
just listen to the chat event
like if player types hello it will reply hi
ok
PlayerCommandPreprocessEvent
for stuff that is not a command?
ah
ok thanks 🙂
sorry i'm bugghy
AsyncPlayerchat or PlayerCommand
he wants to basically do the same thing that you are currently doing lol. parsing normal chat input
Hello, there is a problem when I use a custom biome provider, it works perfectly in 1.17, but in 1.18 the generation is totally broken. I have an ocean generated instead of a plains (F3 shows plains) for example. Does anyone has an idea ?
I have created a chatbot in python can i implement it in spigot by any means?
wat
what is the ConversationAPI
the fact is that the biome provider override only landmass biomes, oceans are still generated.
@Override
public @NotNull Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z) {
if(x > 1024 || x < -1024 || z > 1024 || z < -1024){
return Biome.THE_VOID;
}
return Biome.PLAINS;
}```
I tried it but the bot replies faster than the player
<Bot> Hi
[11:49:43] [Async Chat Thread - #0/INFO]: <Sammu212> hello
in the asyncplayerchatevent, schedule a synced task
onChatEvent {
Bukkit.runTask(plugin, () -> {
// Chat message
}
}
How can I get the increment value of players armour level of an armour piece itemstack?
for (Player player : Bukkit.getOnlinePlayers()) {
Map<Enchantment, Integer> Enchants = player.getInventory().getHelmet().getEnchantments();
if (Enchants.containsKey(Enchantment.DURABILITY)) {
Integer level = Enchants.get(Enchantment.DURABILITY);
if (level == 1) {
// DO STUFF HERE
}
}
}
}```
Yes, this code does not completely make sense with what you asked for or almost but listen. You should take the level of the present enchant that you want to make (i++) then increase its value by 1 or as much as you want and then set a new enchant with its name to the itemstack. Even simpler can be making a foreach where you take all the enchants of an itemstack with getEnchantments() and rearrange them to the new itemstack. For the armor-stack storing, you can try to make a hashmap Player, ItemStack I assume
you mean the attribute?
I guess so. The thing, that makes the amount of silver chestplates increment above the hotbar. Not sure how it's called
yeah the attribute
there should be methods for that in ItemMeta
plugin.getPluginCommand("pork").setAliases(Arrays.asList("helo", "imagudguy"))
That's not what I want, but thank you. I meant to GET the attribute of the itemstack, not increment the protection enchantment.
Yes
did you register the command?
Because the command name is always feed
you’d have to use the label parameter to check which alias was used
HEREEEE
it worked for me
Well the issue isn’t the aliases, it’s his implementation of the command executor
^
ah, I didn't see the first image
also please stop googling what people ask and then sending the first result you find
I don't really see any methods for that. Also there are no inheritors for like ArmorItemMeta.
this was completely unrelated to what the guy asked
and you did the same thing few days ago when i asked something
bro, I thought he spoke of enchant not of other... Excuse me of heart
api version?
Shall i check on the latest one?
aliases is supposed to be an array
just reply what api version are you using
aliases: [something]
or
aliases:
- something
When I say, I get criticised for using "outdated and unsupported version" (that answers ur question btw xD)
It can be a single value
Snake yaml is kind enough
oh ok
1.8 didn't have api support for attributes
I have a fork obviously, so I could backport it from latest versions.
if that answers your question
you sure it's snakeyaml and not the builtin yaml parser? because normally SnakeYaml can't even read an int as double
Not sure but something in the implementation is nice enough to wrap it as a list value if needed
alright, that's good to know
Ye
you can do it with nms if you're interested
I am, I've noticed ArmorItem class having information about that
also i remember i had found an api once
also, you can't do per-slot attributes in 1.8
so you can't make an attribute work only when you have a piece of armor equipped
I just want the static value of each armour piece, it's used only once to pre-gen loots
what does "equalsIgnoreCase" do?
Checks if string equals to another string, ignoring the character case xD
"hello".equalsIgnoreCase("Hello") = true
checks for string equality, ignoring upper or lower cases
oh i see that makes more sense i thought it would check something else
oh right i had forgot you only need it for armor, that obviously only works when it is equipped
i'd have to do some nms digging to try and find a working method
yep
gimme few minutes
okthx
I have found one, but it requires me to convert from bukkit ItemStack to nms ItemStack, and that fails for some reason and returns null (Using CraftItemStack.asNMSCopy())
send code
?paste
https://paste.md-5.net/qekoqeriva.cpp
(toNmsItemStack = return CraftItemStack.asNMSCopy(stack);)
On my utility client, methods for getProtectionValue() work
toNmsItemStack(new org.bukkit.inventory.ItemStack(material)); whats this method?
it's not included in the code snippet
I sent below the link
I'm sure.
The System.out.println() one returns normal material enum names, and it always stops on the null check.
I can test for you
I've tried a lot tho. Probably need another conversion, or just entirely use NMS
try to cast the itemstack to a CraftItemStack
then call getHandle
((CraftItemStack) itemstack).getHandle()
Pretty sure there's no getter, but I can make sure
actually that would not work
getHandle should return nms itemstack, but in this class, handle field is package-only without a getter
^ because itemstack is not an interface like most bukkit classes
ok so it's seems that in 1.18 the BiomeProvider is used as a decoration provider, it doesn't override anymore the world generation. Does anyone know a solution to get it's 1.17 effect in 1.18 without having a full custom world generator ?
i tested on 1.8 with a diamond helmet and it didn't return null
[13:02:16 INFO]: stack:net.minecraft.server.v1_8_R3.ItemArmor@9785903
try ItemArmor#x_()
Hi, I'm making a bedwars plugin and I would like to restrict the items the player can put in a chest
For that I'm using InventoryClickEvent but for some reason it doesn't always fire, here is the code:
@EventHandler
public void onInventoryClick(InventoryClickEvent e){
Bukkit.broadcastMessage("fired");
if(e.getView().getTopInventory().getType() == InventoryType.CHEST) {
//If the player isn't placing an item
if(!e.getAction().name().contains("PLACE")) return;
//The player places an item onto a chest
if(e.getClickedInventory().getType() == InventoryType.CHEST) {
if (!insertSword(e.getWhoClicked().getInventory(), e.getCursor())) e.setCancelled(true);
}
//The player places an item onto his inventory
else if(e.getClickedInventory().getType() == InventoryType.PLAYER) {
int index = getSword(e.getWhoClicked().getInventory(), e.getCursor());
if(index!=-1)
{
e.setCancelled(true);
e.getWhoClicked().getInventory().setItem(index,e.getCursor());
e.getWhoClicked().setItemOnCursor(null);
}
}
}
verifyInventory(e.getWhoClicked().getInventory());
}
Any idea why?
It doesn't always fire, cuz it fires InventoryDragEvent (the one when u click in the slot and even slightly move your mouse) You can check that by clicking without moving the mouse at all, and moving a bit while pressing.
The only fix I know is to handle InventoryDragEvent as well :/
Oh I see that, that's really odd
I will try to also use InventoryDragEvent
Thank you!
Hi, anyone know how to get robbery leader in this plugin api?
https://www.spigotmc.org/resources/62739/
its not for the robber list
Then try decompiling the return value of getInstance() and see its methods
go ask in their support server
best thing i can suggest is decompiling the class and checking yourself
unless obfuscated like a few plugins out there xD
i did
its not
but there is a lot of errors in decompiled version (because dependencies in pom.xml)
this is what author said, i can't understand what to do
Make sure to set scope provided if you added it to your maven project
thats not what he said
forgot that, how to that stuffs the author said?
yes i've shaded that in to the plugin
ah ok
ok then
get a Robbery object somehow
from an event or so
then you can cast it to a GeneralRobbery or a BankRobbery and that will give you access to more methods
Robbery is probably an interface
do you care about General robbery or a bank robbery?
((GeneralRobbery) event.getRobbery()).
and check the autocompletions
or just decompile GeneralRobbery
make sure you check the right one using
if (!(robbery instanceof GeneralRobbery)) {
return;
}
GeneralRobbery generalRobbery = (GeneralRobbery) robbery;
ok
Alright
Probably should use an enum or a registry for places rather than comparing strings
I want to remove the item on the player's cursor but for some reason it only disappears after I try to place the item into the inventory
When I get out of the inventory it just throws out the item that I have 'removed'
Any Idea how to fix that?
The client doesn't send packets for hovering with the cursor
So there is no way to do this
Oh I see, I will try to find a way around it then
I want to teleport each player to spawn points separately, how can I do it? Like Hunger Games
store the locations somewhere and tp each of them to a location
Player target = Bukkit.getPlayer(args[0]); How can I check if the player "exist" ?
if (target != null)
getPlayerExact x)
Oh thanks.
was org.apache removed from repo in 1.19?
YOO i am having problems with ip_fowarding in bungeecord say it is false but in reality its true
and it will not let me join unless resolved
As foreshadowed with the 1.18 release, commons-lang has now been removed from the API. Plugins will not yet be broken as it is still included with the server, however it will eventually be removed in a future release. Please consider switching to Google Guava (which is a supported bundled API) or using your own copy of the much more recent commons-lang3.```
??
what could I use for StringUtils#isNumeric?
Have you completed teh post installation tasks? https://www.spigotmc.org/wiki/bungeecord-installation/#post-installation
I have a string of indefinite length. In the mysql column I should give it VARCHAR(n) value but what number do I put in place of n in this case? Are you new to mysql?
whats its supposed to store?
a list of players in a varchar lmao dont do that
depends on why you have a list of player names
you should be identifying players by UUID for a start
ps = plugin.getMySQL().getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS agencies "
+ "(AgencyName VARCHAR(100), AgencyOwner VARCHAR(100), balance DOUBLE(100), MaxBalance DOUBLE(100), employees VARCHAR, PRIMARY KEY (AgencyName))");
ah okay
but how should I store the players (employees)
I want to assign the names of players entering the game to a List
I've been looking through the Javadocs for hours and haven't been able to find anything about it
Could you show me an example?
so these employees are members of the agency?
y
you create a table for them with an agency and UUID
unique key pair
actually make the UUID unique
not a pair
Wouldn’t it be better to make a single string with all uuids and a character to which then associate a Split-Char?
so they can only be in one agency
hm
thats not how relational databases work
ah
thats how strings work
Why do you want all the names in a List?
Javadocs didn't help at all with this
yes i have
List<String> list = new ArrayList();
list.add(player.getName())
So all servers offline, IP forwarding is on
yes
Then explain your issue
- I will assign a list of players logged into the game
- I will assign another list of those who interact
- If they're both the same I will do something
For ManHunt plugin
If player interact, It means player is ready
my issue is exactly that it says ip forwarding is on but when i join one of the server it tells me i must enable it in config which i already did
Elgar just a question, but then in case, how do I basically get all the employees of a given company? Did you mean to do something like that first?
{AgencyName}:
uuidD,
uuidD,
UUID,
uuid{52},
UUID{2},
UUID{1}
and all players on the server have to ready up for teh game to start?
Yep
You have seperate tables. One for player UUID, agency. Another for the agency data
all clear then! thanks!
you pull from employees all where agency = whatever
How to make custom model?
Using ArmorStands or using something else
my issue is exactly that it says ip forwarding is on but when i join one of the server it tells me i must enable it in config which i already did
in your Bungeecord config.yml
yes
make 100% certain you have ip_forward: true
Then I see no reason for you to be getting that message
i can screen share for u
I want to make Cannon/Harpoon model
do you have bungeecord: true in each servers spigot.yml?
yup
@EventHandler
public static void onJoin(PlayerJoinEvent e){
List<String> list = new ArrayList();
list.add(e.getPlayer().getName());
}
@EventHandler
public void onInteract(PlayerInteractEvent e){
List<String> list2 = new ArrayList<>();
list2.add(e.getPlayer().getName());
if(list2.equals(list));
//do something
}```
Do you think this will work?
Oh
1 min
Nah
you are creating new List every time
Is this a problem?
you don;t need a list at all
Well idk what you plan on doing
but you are creating 100's of lists that can't be ever accessed
Oh
Dump
So store some List somewhere where it can be accesed
and just add the value to it
Set<UUID> ready = new HashSet<>();
@EventHandler
public void onInteract(PlayerInteractEvent e){
ready.add(e.getPlayer().getUniqueId());
if(ready.size() == Bukkit.getOnlinePlayers().size());
//do something
}```
If the player interacts with the block I set, I thought I'd increase the "AAA" value by one, if it was two, I thought it would run a command, but I wasn't sure if it would work.
use this
Oh
Okay
Thank you
I will use this
should work as a charm
Btw Is this true?
Only to information
can you show me a screen of this error?
I just need a pic
its not letting me send screenshots
!verify
Usage: !verify <forums username>
get verified
Do you guys know if it is possible to change Leather color armor based on permission?
Very possible
what does it mean by forums username
it means your spigotmc forums username
So something like this is possible: If player gets/wears red armor but has the permission armor.blue the red armor changes to blue?
yes
awesome will look into it thankss
Bumpity Bumpity
Not sure I see a question in there
Its a reply to a reply
Please just open it to see "details"
Is using json in spigot any different than using it in Java generally?
nope
Ok
I've not read it so it may be absolute trash
thx
this is whats happening
looks like you are tryign to connect direct to the server and not to Bungeecord
oh ok
Im having some problems with accessing Lists from yml files. i have tested if the file is correctly loaded by also getting a string from the same file.
File:
Bukkit.getLogger().info(FileHandeler.getFile().getString("LoremIpsum")); //Test Bukkit.getLogger().info(FileHandeler.getFile().getList("Test").toString()+" FileHandler"); //Line Of error
Error:
Cannot invoke "java.util.List.toString()" because the return value of "org.bukkit.configuration.file.FileConfiguration.getList(String)" is null
File:
Test: {"Hello","World"} LoremIpsum: "Test"
u have to use the local ips of the server if they r all hosted on one machine
it doesnt matter at the moment because im just using it as a format and when i get my server(irl) hardware ill switch over the files
ElgarL, one question... How do I know if a player is already employed in another company? More specifically I asked if you can check all the tables of companies in the employee section and see if there is the uuid of the player. Thank you again so much for your help!
you make the UUID in teh employes unique/primary key so there can only be one entry
they can only have one entry so only be in one agency at a time
Wait, so you’re telling me to make a table for every player and not every company with players in it right?
you use a SELECT statement to query the employees table
no
one table which has columns for UUID and agency
UUID is the PK
I'm doing something like that:
PreparedStatement ps;
try {
ps = plugin.getMySQL().getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS "+ agency +
"(Employees VARCHAR(100), PRIMARY KEY (Employees))");
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}```
no
ohups
Two tables. One called agencies, one called employees
obv!!
Sorry that's the entire code:
PreparedStatement ps;
try {
ps = plugin.getMySQL().getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS agencies "
+ "(AgencyName VARCHAR(100), AgencyOwner VARCHAR(100), balance DOUBLE(100), MaxBalance DOUBLE(100), PRIMARY KEY (AgencyName))");
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void createAgencyTable(String agency) {
PreparedStatement ps;
try {
ps = plugin.getMySQL().getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS "+ agency +
"(Employees VARCHAR(100), PRIMARY KEY (Employees))");
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}```
Is that what you meant no?
no
use a try with resources
Table employees has columns UUID (which is the employee UUID, and agency which shoudl be the ID of the agency they are in
Table agency has an ID column, name and any other info you think it needs
when a player dies, if they have a book in their inventory for example, i want the player to keep the item, is there a way to do this with the playerdeath event or would i need to use the respawnevent as well
ID would be unique
so to find all players in teh agency with ID of 01 you SELECT * FROM employees WHERE ID = 01
that gets you the UUID of all players who are in teh agency with ID of 01
registered them?
Thanks bro! I was trying that:
try {
PreparedStatement ps = plugin.getMySQL().getConnection().prepareStatement("SELECT * FROM employee WHERE Employee=?");
ps.setString(1, uuid.toString());
ResultSet results = ps.executeQuery();
return results.next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}```
I I haven’t tried but I think it works, anyway, wouldn’t it be the same if I associated the company name as id?
To make a temporary ban, I would have to put a date but how? And also how to check it.
private static void createReadyItem2(){
ItemStack item = new ItemStack(Material.LIME_CONCRETE);
ItemMeta meta = item.getItemMeta();
if(meta != null){
meta.setDisplayName(ChatColor.GREEN+" "+ChatColor.BOLD+"You are ready!");
List<String> lore = new ArrayList<>();
lore.add(ChatColor.AQUA+"When everyone is ready, game will start.");
meta.setLore(lore);
item.setItemMeta(meta);
ready2 = item;
}```
```java
Set<UUID> ready = new HashSet<>();
@EventHandler
public void onInteract(PlayerInteractEvent e){
if(e.getItem().isSimilar(SecondReadyItem.ready2)){
ready.add(e.getPlayer().getUniqueId());
if(ready.size() == Bukkit.getOnlinePlayers().size()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say a");
}
}
}
Why not working :/
There is no error in the console
kinda, but then if you want to change teh name it becomes difficult. also typos and case sensitive
if you use ID's you can change the name or anything about the agency and keep the same ID
Yeah but to get the new id, I count the values inside the agencies table and do +1?
registered Listener?
just use an auto incrementing column
Ahh okay! So I'll do VALUES(AUTO_INCREMENT,?,?)
Thanks bro! Sorry for the many questions, I started 3h ago with mysql
when creating a new agency you use null as the ID
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
So it'll be 00?
ah no
nonono sorry
how do I check if a raid was finished because it was won?
because RaidFinishEvent gets executed also when the players lose
null means SQL will auto assign a number. The next one in sequence
Thank you Elgar!! 🙂
Just a last question, what should I use as PK? The ID or the Name in ur opinion?
ID
thanks
however, you don;t want name clashes
so PK teh name instead., the ID is managed by sql
What event get's triggered when a dispenser places water or lava from a bucket?
?
probably
you could prob use BlockDispenseEvent and then check if Item a water/lava bucket is
um, linking paper here is not such a good idea
thank you so much for helping even if it was that simple u just safed us weeks of this thank you andu r really good at this do have a degree in it or is it self taught?
but there is no difference to spigot, when I link org.bukkit.* stuff
and what reason is winning?
Its like advertising BurgerKing in a McDonalds restaurant.
try it and see?
That seems like a lot of logic though?
There are cases where the dispenser will just dispense the empty bucket, water bucket, or lava bucket.
To cancel placement without changing any vanilla behaviour, you would need to check the dispenser, check what the block in front of the dispenser is, guess what the dispenser would do, and only cancel if applicable.
For example, if the dispenser is about to shoot out an empty bucket, and if the block in front of the dispenser is not fluid, you would not want to cancel the event.
Whereas, if the dispenser is about to shoot out an empty bucket, and if the block in front of the dispenser is fluid, you would want to cancel the event.
Been doing it for many decades 😉
People do not seem to have other problems lmao
well ur good at have u applied for a job for spigot or even a role in the server
👴
because ur more of a help than the actual inroled people here
No thanks. I only do this in my spare time. I have to be free to care for my disabled wife.
aww that makes sense i hope u guys do good and thanks for being a good guy 👍 ✅
?main moment
Have you done any kind of debugging to find out where the code stopped/what is actually run?
Hey.
Im having some problems with accessing Lists from yml files. i have tested if the file is correctly loaded by also getting a string from the same file.
File:
Bukkit.getLogger().info(FileHandeler.getFile().getString("LoremIpsum")); //Test Bukkit.getLogger().info(FileHandeler.getFile().getList("Test").toString()+" FileHandler"); //Line Of error
Error:
Cannot invoke "java.util.List.toString()" because the return value of "org.bukkit.configuration.file.FileConfiguration.getList(String)" is null
File:
Test: {"Hello","World"} LoremIpsum: "Test"
I've never seen a YAML list in {}, so not sure if it's possible, try it like one of the following:
Thing: ["Hello", "World"]
Thing:
- "Hello"
- "World"
Yeah, the "Thing" would actually result in this:
Test:
Hello: ~
World: ~
where ~ means null
so for arrays/lists, use [ ].
https://pastebin.com/u2aR3nuU
And that’s kind of my end result if you may be interested, it’s not tested yet and I’m afraid to do it ahah
How can i check the cooldown in the interact event when a player uses a goat horn
player.getCooldown(Material.GOAT_HORN)
you either want to close the resultset or the connection tho
Employee can be a fixed length of 36 (which is UUD.toString)
ElgarL, if you're using one db connection for your plugin, should you close it after every operation?
just wondering
(I'm closing it on the onDisable)
depends how frequently you are accessing teh DB
Evil people might say a connection pool is pretty cool
Okay so an off-topic question about development,
If I want to send information from Server 1 to Server 2, I should use an API Key, right?
Example usage: When a player joins a server that he isn't supposed to, send a message to all the staff members in other servers.
yesj, im that evil person
i guess if you're doing it relatively often, you could let it open
Yep
Cross server communication usually lives on pub sub systems anyway
Which require authentication
What I want to do exactly is make a plugin, that'll generate a Token which will be later use in an mobile app that I'm currently making.
After that, once someone tries to send a message from the app a console command, it sends it to the plugin and the plugin executes it.
Does that make any sense ?
how could you make so that it writes with [] instead of {} to the file
So a classic auth case ? You can pick anything from a session over JWT
If you don't want the user to have to input a password then yea
A access token works too
It'll all be stored in a database, when the token gets created, the server details get stored in a DB and it gets it off of there.
The problem is that, it'll send an info, but how do I make it so it watches for changes ?
Watch for changes ?
Am I missing something or are you literally just making a mobile client server side authentication
Hey, I want to place the blocks only on a single client, could anyone help me with that?
Ok thanks
Tho that'll be a fake block obviously
The second they interact with it it will revert to its proper state
any way I could detect that?
Ehhh not easily unless I missed smth
alright thanks
Idk if interact event might go through
I have moving object with its own location
And then I have player
But I need to calculate location which will be equalivent to the x blocks the object has moved
You could check that
will do thanks again
What is your object and how is it being moved?
So I have a ship
its being moved using WorldEditAPI
and I know the ships Location
But when it moves, the player stays on same place
So I somehow need to teleport him
location.add(location.getDirection().normalize().multiply(10))
10 being how many blocks youi are moving
oh right
thx
how do you make a hashset get stored within [] instead of {} in a FileConfig
use a List or array
can you store multiple coordinates in a list or array
coordinates?
org.bukkit.Location
i'll make sure that wont happend
attempting to make a custom object that acts like a drill
why is player.setCooldown(Material.GOAT_HORN, 0) not working?
I already tried setting it to 10 what also didn't worked.
Is the delay clientside?
Is in ticks, no?
Time is in ticks yes
Remove the cooldown from the horn. Setting it to 20 worked but no other players hearing the horn
When are you setting the cooldown?
Alright, try to give it a delay like 1-2 ticks.
set the cooldown AFTER the event
how do i set up my intellij javadocs for them to display the proper descriptions and or have a link to the online javadoc using maven?
ctrl+click on the .setLodestone()
then you will get "Download Source" up of the editor, click on it and u have the docs
it looks like my javadoc path doesnt exist, did buildtools not generate them?
if i do that it says cannot download sources because they are not found
That worked! Thanks
What does this error mean?
Could not pass event BlockPlaceEvent to MyFirstPlugin v1.0-SNAPSHOT org.bukkit.event.EventException: null
Doesn't tell us much. The whole error and relevant code would be useful
how can I get the face of the block the player is looking at?
You'd have to run a ray trace
Check if the result is null (meaning nothing was hit in range), then get https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/util/RayTraceResult.html#getHitBlockFace()
thanks
how do i get acess to this enum https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/CreativeCategory.html so i can check if it contains certain values
ty
if i have a plugin jar in the libraries but im using maven is there a way to make a local maven or smthn? cuz the plugin doesnt have a maven but i need to use its library
wat
spigot classes are weird sometimes lol
yeah
guess so
it's an hashcode method so makes sense
Caused by: java.lang.IllegalArgumentException: 100.0 is too high
if(!player.getAllowFlight()) {
player.setAllowFlight(true);
player.setFlying(true);
player.sendMessage(ChatColor.GREEN + "Flight Enabled");
player.setFlySpeed(100);
flight is enabled
however
"an internal error occured while trying to preform this command"
any ideas?
when I get an entity using the entity's id with nms, does it returns the entity only if it is loaded?
Isn't it a float?
Make the speed lower
yep i know, however i didn't notice anything above 1 was too high
Where i can download the JDk 17? Oracle doesnt allow me to log in their website, so i cannot download it
AdoptOpenJDK
0.0 to 1.0 is your range of being a float
Hello! anyone knows how I can easily get the block player is standing on when they are on the edge of the block?
How can i cancel the achievement message when a player is vanish? PlayerAdvancementDoneEvent is not the right event i think
How to set aliases from config file?
getCommand("fly").setAliases(Lists.newArrayList(plugin.getConfig().getString("commands.aliases.fly").split("\\|",-1));
And for example config.yml
commands:
aliases:
fly: "f|flyyy"
aliases: [ "f", "flyyy" ]
Do you know how to install JDK 17?
I have download it but its not a java file, its a zip
download the correct one then
i think event.getPlayer.getLocation.getBlock.getRelative(BlockFace.DOWN)?
Where?
Yeah i download it from there
If on Windows DL the MSI not teh zip
msi not zip
Microsoft installer
hmmmm, let me try
That won't work
There is no reliable way to get the block you are hanging off, even if the block under you is air
It possible to cancel only fall damage right?
Allright really thanks
You always help it really apreciated
getCommand("fly").setAliases(Lists.newArrayList(plugin.getConfig().getString("commands.aliases.fly")));
Is there something wrong with this code bcs it won't set the aliases when reloading?
@formal bear ```yml
adventure:
description: Manage adventure parkour courses
permission: adventure.play
aliases: [adv, advcontinue, advset, advadd]
take this as an example on how to do aliasses
I meant it does not register the alias, it's about the syntax or smh in the code not in the config, my config:
commands:
fly:
aliases: ["f", "latanie"]
and in this case you just do this.getCommand("adventure").setExecutor(new AdventureCommand(this));
remove the quotation marks
so set executor not set aliases?
setExecutor sets my command object
@green prism sql CREATE TABLE IF NOT EXISTS agencies ( ID MEDIUMINT NOT NULL AUTO_INCREMENT, AgencyName VARCHAR(100), AgencyOwner VARCHAR(36), Balance DOUBLE, MaxBalance DOUBLE, PRIMARY KEY (AgencyName) ) checked in https://www.eversql.com/sql-syntax-check-validator/
and then from the object.setAliases yeah?
any ideas?
Nothing at the end I understood doing a random thing, you have to put the length of the left and right (100,10). Another error is that you cannot give the AgencyName PK value if an increment is present. There can only be one increment column, by a similar error
so you want to set an alias for a command that exists in a different plugin. correct?
not null is redundant for auto increment isnt it?
I want to give option to set custom aliases for user
getCommand("fly").setExecutor(new Fly());
getCommand("fly").setAliases(bla bla);
why?
why not? XD if its possible why not, idk for example fly in other language or smh
then just set the AgencyName UNIQUE
you can do that in plugin.yml aliases
from config?
from plugin.yml
i dont want plugin.yml, user cannot edit it
i want to load them from yml file in plugins directory
@green prism sql CREATE TABLE IF NOT EXISTS agencies ( ID MEDIUMINT NOT NULL AUTO_INCREMENT, AgencyName VARCHAR(100) UNIQUE, AgencyOwner VARCHAR(36), Balance DOUBLE, MaxBalance DOUBLE, PRIMARY KEY (ID) )
cant you do that in commands.yml?
You can register command throw command map, after setting the things you want from a .yml file
load the yaml array properly into a list and it should work
Is the bot down?
yes
add an @EventHandler annotation
method names should start with a lowercase character
then setAliases should work
You didn't annotate it with @EventHandler
🤦♂️ thanks guys
yeah thats why im asking because its not working
getCommand("fly").setAliases(Lists.newArrayList(plugin.getConfig().getString("commands.fly.aliases")));
in the part getCommand("fly").setAliases(Lists.newArrayList() something is incorrect?
getConfig().getStringList
You don’t need to parse a string and convert it to a list yourself
Then how do i write it in yml file? aliases: ["foo", "boo"] or?
oke! tysm
how would I make it so you can do /heal (name)
here is my code https://pastebin.com/YtVGAPt6
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Hm, still nothing, maybe i will just paste the code
public void onEnable() {
this.saveDefaultConfig();
getCommand("fly").setExecutor(new Fly());
List<String> flyAliases = plugin.getConfig().getStringList("commands.fly.aliases");
getCommand("fly")).setAliases(flyAliases);
@onyx fjord do you hear me?
List<String> playerNames = new ArrayList<>();
for(Player player : Bukkit.getOnlinePlayers()) {
playerNames.add(player.getName());
}
return playerNames;
}```
Allr
Hey guys, I have a bit of a logic issue you may be able to help me with. I am listening to PlayerInteractEvent and doing stuff based on if they clicked a block or a liquid source block. However, I also need to account for entities. So I am listening to both PlayerInteractEvent and PlayerInteractEntityEvent. Problem is, BOTH event handlers fire in the case of an entity. First PlayerInteractEntityEvent, followed by PlayerInteractEvent. Is there a way to approach this to only have the entity event fire if an entity was what was clicked?
onTabComplete ofc
ok ty
oh
I thought about checking if event instanceof PlayerInteractEntityEvent inside of the regular event handler, but it wont allow that comparison
I cant implement a Listener! It just shows me the import for an Web listener can some help me with that problem?
You sure your project has the spigot api imported?
PlayerInteractEvent shouldn’t be called for entities… what is the action type?
is there a way to check this lol
its not being called for entities
Could you check if the action is right click air?
I found a thread about this from a while back
its calling entity for the cow, and also regular interact for the air around it
no real solution there though....
is it possible to have exp not be clumped into one ball?
simply by using Bukkit#getOfflinePlayer, OfflinePlayer#getName()
I suppose I could put a "handled" flag on the persistence data container of the item? that seems weird though....
Could not find spigot-api-1.18.2-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220524.110132-46).
wat
well yea
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.lexih.Main.getCommand(String)" is null how do i fix this?
public Test instanceTest;
@Override
public void onEnable(){
instanceTest = new Test(this);
getServer().broadcastMessage("server started");
}
@Override
public void onDisable() {
getServer().broadcastMessage("Server stopped");
}
}```
```public class Test implements CommandExecutor {
private final Main instance;
public Test(Main mainClass) {
this.instance = mainClass;
instance.getCommand("testt").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length >= 2) instance.getServer().broadcastMessage("Test");
return true;
}
}```
Lmao build tools doesnt works for me :(
helppp
please
is the command in your plugin.yml?
main: com.lexih.Main
version: 1.18
commands:
/testt:
description: this is just a test relax
aliases: /t```
yea
im not stupid man
remove the slash
nope
where tf is 1.18.2_
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
its that version exists
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}```
I see tons of examples online doing this check but for some reason my JDK complains about it. Has this been deprecated or something?
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
https://oss.sonatype.org/content/repositories/snapshots
i use these 2
the sona one looks different
nope still same
idk then sorry
please
I don;t think you need the = in there
man i need to dev something
i use gradle cuz a friend told me to
gradle its the best
repositories {
mavenCentral()
maven {url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'}
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
}```
wait maybe is ij idea issues
did u click the elephant?
where do i get the spigot 1.18 api from?
nope
Maven gets it for you
or
?bt
worth asking
its find me that
how do thiese buildtools work
I used them
basically you build the jars on your own system
I got like 6 folders
hello?
hello?
gradle spigot are broken :'
Build Tools are broken that my conclusion
he's got = in all his repositories. I've never seen any gradle.build have them
Me?
xmotro
the repos look right, but there might be a caching issue or sth
man its right to be that