#help-development
1 messages ยท Page 1425 of 1
if (!(event.getWhoClicked() instanceof Player)){
return;
}```
will always be false
only players can click inventories
it has not been satisfied
means the title isn't exactly that
best practice is to not match just name
keep a cache of inventories and handle it with some sort of manager
still doesnt work xd
i dont know what that means
have a manager class that keeps track of all custom inventories made
then if that list contains the current inventory, it means it's custom
i started on spigot plugins about 3 hours ago
i know what u mean
but not how to do it
new to java aswell?
yup
gotcha
yeah that might be a bit complicated
you can strip colours on the title and then check if its the same
ChatColor.stripColors(string) I believe
can i see your if statement
if (event.getInventory().getTitle().equals(ChatColor.stripColor("(GUI)"))){
mb it needs getWhoClicked
god no
ok
They're new to java, I don't wanna overwhelm them with other stuff
don't use inventory names to identify inventories
a player renames a chest and they can change the inventory title all they want
== the inventory/holder instance
its a gui
a gui is an inventory
ok then say how else
men that makes no sense
== compares object identity
every inventory is an object
check that the object that is being looked at is the specific inventory you want
String title = ChatColor.stripColor(event.getInventory().getTitle());
if (title.equals("(GUI)")){
}```
that would work
private final Inventory myGui = Bukkit.constructInventory(...)
and then if (e.getClickedInventory() == myGui) {
can i broadcast title
to see output
if you want yeah
Bukkit.broadcastMessage(string);
i just use System.out.println() to debug though
quick n dirty
dahell
its the event
its wrong event or some shit
public void onClick(InventoryClickEvent event)
did you register the event listener
@EventHandler
public void onClick(InventoryClickEvent event){
//stuff
}```
yeah ik
Bukkit.getPluginManager().registerEvents(listener, plugin)
or plugin, listener, idr
so thats why nothings been working
lmao
dw i do the same shit all the time lmao
i put this in the gui creating part right
well that doesnt work
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.WHITE);
Error: no suitable constructor found for itemstack
(byte)0
wat
wdym
factions:
names:
tester:
leader: TheRifty
tester1:
leader: TheRifty
Is there any way of getting rid of tester rather than setting it to null?
Setting it to null should get rid of it?
it does
bukkit config api doesn't write null values for dictionaries
i'm actually not sure how it deals with null values in the backing yaml file
as in whether keys with null values would show up in getKeys and whatnot
Yeah it lacks of certain things clearly
setting it to null give me this ```
factions:
names:
tester:
tester1:
leader: TheRifty
Hello, i want to create a AirDrop plugin and i have some pb for create my Class DropManager
oh, I was messing with wrong code :/ Sorry for the inconvenience
It's betetr to put my code in a throwbin or i can put here ?
Ok ok i write my code and i put ^^
My Object Drop
My manager
Idk if it's correct
And i want to spawn a chest at the Drop location
I have already write a "code" for spawn a chest at a random Loc but i didn't used the OOP
why doesnt this if statment work even though i am holding that item if(whoHit.getInventory().getItemInMainHand().equals(item.item)
Hello guys, does anyone know if there is a possibility to add durability to an item that is not breakable, for example: Stick
Use the ItemMeta
i don't remember if that's supported
you're probably gonna get a missing texture if nothing else
But is there a possibility that the durability bar will appear?
no
No
best case scenario is that the item is going to become a purple/black square to indicate a missing texture
the other scenario is that nothing happens
ItemStack itemStack = new ItemStack(YOUR.ITEM);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.spigot().setUnbreakable(true);
itemStack.setItemMeta(itemMeta);
"spigot()" i think u can removed this
But the best way is the itemBuilder
is there a correct way to see if an item is an certain item like comparing the item in ur hang is an custom made item
yes
insert a tag into the PDC of the item
and check the tag to see whether it's your custom item
When the player wins the game, they need to be teleported to the lobby, but that doesn't happen. Can anybody help me?
I could not see any mistake
and the error is
the world is null
the world of your location is null
nullcheck your Bukkit.getWorld result
you are reading the String at lobby-spawn instead of lobby-spawn.world
thanks, but i would like to know if it is possible to add the durability bar to the item.
it is not
Location is ConfigurationSerializable; you can just set(path, location) and getSerializable(path, Location.class)
no need to serialize and deserialize it by hand
ah i miss it
sorry -_- problem fixed xD
https://www.spigotmc.org/threads/setting-item-durability-not-showing-to-client.103081/ look this i think
does not mention adding durability bars to non-damageable items by half a word
You can't
You can use resource packs with metadata to simulate it
But you can't add a durability bar to an item that's unbreakable
Bukkit.broadcastMessage(event.getCurrentItem());
Why doesn't this work? Any way to broadcast clicked item?
java: incompatible types: org.bukkit.inventory.ItemStack cannot be converted to java.lang.String
ItemStack is not a string
the method expects a string
you can try calling toString on the itemstack
but it may or may not give you human readable text
no errors
lemme try
lol thats weird
if (title.equals("(GUI)")){
player.sendMessage("Works!");
event.setCancelled(true);
Bukkit.broadcastMessage(event.getCurrentItem().toString());
if (event.getCurrentItem().equals(Material.RED_ROSE)){
Bukkit.broadcastMessage("Healed");
player.setHealth(12.0);
}
return;```
so checking if its a rose
doesnt work
an ItemStack will never be equals to a Material
You aren't checking the material
get the getType of the ItemStack
that will return a Material
which you can then compare to the other Material
Yeah
thx xd
not the right channel
yes
thanks
How do I get the blocks that are next to each other (like veins or logs of a tree)
check the neighboring blocks, add them to a queue if they are of the same type, and then do the same for the next block in the queue
rinse and repeat until the queue is empty
how do i check the neighboring blocks
Hello guys, do you know any way to increase the speed of breaking a block, without using Haste? for example: I would like to break a stone faster using a stick.
i believe there is an attribute you can set
any idea why setting block type to concrete powder with water next to it does not update the powder? is there any way to apply physics?
getState#update does not work, nor does Block#setType(Material, true)
spawn some fallingsand there manually :fingerguns:
Why does my server give me an exception when I try to run a plugin that I made, the error is:
Could not pass event <EventName> to <MainClassName/PluginName> v1.0
or when I kill someone on the server
because an exception arose while trying to pass eventname to your plugin
as for what happened or why, literally impossible to tell without the actual exception
So what should I do?
when talking about exceptions, 100% of the information is in the stack trace
if you don't include the full stack trace of an exception, no-one can help you
the stack trace details the exact position in the execution of your code where the exception was thrown, the type of exception thrown, and usually an exception message
IllegalArgumentException: bound must be positive
(FunnyDeathMessagesEvents.java:26)
yeah
Random.nextInt
this like is
you are trying to call random.nextInt on line 26 of that class
String random = list.get(randomizer.nextInt(list.size()));
the size is 0
sorry I just forgot to add a space after the - in config file list
I feel stupid af
lol all g
Help! I'm stuck!
I'm getting this errors on my server
Could not load 'plugins/SCFAlogin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
But the plugin.yml is valid and included(i looked into the jar file). The jar works on my test server but not on my real one
show ur plugin.yml
main: me.SCFA.login.SCFAlogin
name: SCFAlogin
version: 2.1
author: SoicBR
api-version: 1.12
commands:
forcelogin:
register:
registrar:
login:
logar:
changepassword:
mudarsenha:
add descriotion to commands
that isn't valid yaml
yaml requires every key to be associated with a value
forcelogin: is a key without a value
so are the other commands
atleast
i dont think this applies in the plugin.yml
i do it
still not valid yaml
@wraith rapids no it doesnt
And Why does ur package have Uppercase?
@weary summit you need to post the whole error
yeah this will help us get where the error is
I started this plugin before knowing the naming conventions for java and never bothered to change
(pro tip: don't add Uppercase in packages it will be confusing)
ik
08.05 20:52:34 [Server] ERROR Could not load 'plugins/SCFAlogin.jar' in folder 'plugins'
08.05 20:52:34 [Server] INFO org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
08.05 20:52:34 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:158) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:318) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:222) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:616) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
08.05 20:52:34 [Server] INFO Caused by: java.util.zip.ZipException: invalid END header (bad central directory offset)
08.05 20:52:34 [Server] INFO at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.jar.JarFile.<init>(JarFile.java:166) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at java.util.jar.JarFile.<init>(JarFile.java:130) ~[?:1.8.0_282]
08.05 20:52:34 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:146) ~[patched_1.12.2.jar:git-Paper-1618]
08.05 20:52:34 [Server] INFO ... 5 more
i vaguely remember the exception about missing dependencies being very vague
youre not running spigot
he is running Paper
go ask in paper
aww that's disgusting
the plugin jar is borked; make sure you are transferring it properly
if you're using FTP make sure to use the binary transfer type instead of ascii
i'll try that
not the plugin jar, it works on local server
yes, but that is a different jar
the jar on the not-local server is a jar you tried to copy over and apparently the transfer failed
@wraith rapidsThank you! It was ASCII mode
Changed to binary and it works
Also, my yml wasn't invalid, this worked
add ~'s
It's fine
not everything is willing to parse that
Then its a bad parser
you're a bad parser
this made me LoL
no its valid yaml
Would any of you see what the problem with this is?
I get these errors:
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[patched_1.16.5.jar:git-Paper-601]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-601]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-601]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:251) ~[patched_1.16.5.jar:git-Paper-601]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-601]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-601]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more```
Your plugin.yml doesnt get put in your jar
You could put it in your src folder directly
ok
you could open your jar with winrar and put it in manually
that's what real men do
I also tested it with creating a resource folder and right click -> mark as... -> Resource map and it would add the yml
when i press mark as, it only says "excluded"
Have the resources folder in your base folder, not src
Intellij?
yes intellij
Build -> Build artifacts
done diz
but I use gradle ๐
it's resource root
If you build the artifact now it should clone the files in there into the jar
ohh
I use Maven normally myself but already helped someone else with the same issue
im trying it
same but I forgot the solution
๐
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[patched_1.16.5.jar:git-Paper-601]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-601]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-601]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:251) ~[patched_1.16.5.jar:git-Paper-601]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-601]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-601]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more```
wait me?
Yes
you should see the plugin.yml inside their
if not, click the "+" button and choose file
I meant follow this dude
added
so like this?
add this
That should be it
nice
And then build -> Build Artifact
ok!!
im very new to plugins, is there a way to detect player movement without detecting head movement
yes!
You can check to see if the x/y/z of getFrom() and getTo() are the same, if that is the same, it's only head movement
it's something like "PlayerMovementEvent"
that detects head movement as well
ill try that
oh i thought it doesn't im sorry
no problem
now we got this :(
how do you do that?
you compiled source double time
not sure why
WorldGuard has API for movement checking
Ah i found the problem
Something like
@EventHandler
public void onMove(final PlayerMoveEvent event) {
if (event.getFrom().getX() == event.getTo().getX() && /* getY() & getZ() checks here */) {
return;
}
}
yes?
Other way around btw but yes you should change IDE JDK to Java 1.8
then
ok
No the problem is that the plugin is written in 11 and the server runs on 8
there's no 11
yes that's right
?paste
use this
TYSM
The SDK here
That's likely Java 15, use 8 or 11
11
im usign 8
use 11 instead
ok
I'd already removed java 8 xd
oh lol
With how many servers still run 1.8 I still need it
wait 1.8 works, should i still use 11?
It's absolutely not 8%
2020 stats
smh my brain
ok
there is no reason why we should use 8
just wait till 1.17
but this made my sad
I meant Minecraft 1.8
not even 8%
still same principle
bstats says 8.8% runs 1.8.8
and 1.8% run 'other'
does PlayerToggleSneakEvent detect when a player starts/stops sneaking?
yes
it detects both
k
There's probably a lot of small servers that just run 1.16 as a survival
how do you get the item in a players hand?
it says that:
player.getItemInHand()
is depreceated
in 1.16 it's player.getInventory().getItemInMainHand()
I ran snapshot ๐
snapshot is cool tho
I love the new additions MC adds
It just sucks that PVP has gotten so bad
Because that's the sole reason people are stuck on 1.8
bstats
dude
mojang never ever wants pvp things
but not really people still use 1.8
๐คช yes
The problem with bStats is that it doesn't show how many players themselves use a version (also because it only does a simple check to see which spigot you run). Their average playercount on a server is 0.6, with ~60k servers empty.
Hypixel's playercount is what the more active minigame player uses, and that is still incredibly skewed towards 1.8
It sucks for devs and it's why the Hive shut down their Java server
minigames are cancer anyway
ah shit
it's unsurprising that the people who have been just fine spam clicking in their stale minigames that were old 5 years ago aren't seeking the new content
Hypixel is doing just fine lmao
skyblock isn't as much a minigame as it's a gamemode
They are hitting new records every week
i meant new content
how would u get the type of a dropped item?
.getType()
get the stack and get the type
ty
ty, im resending this cuz i think an anti spam bot deleted it
do u guys know why this doesnt work?
@EventHandler
public static void onPlayerChangedMainHandEvent(PlayerChangedMainHandEvent event) {
Player player = event.getPlayer();
Material itemType = player.getInventory().getItemInMainHand().getType();
if (itemType == Material.NETHER_STAR) {
player.setAllowFlight(true);
player.sendMessage(ChatColor.AQUA + "Flight enabled!");
} else {
player.setAllowFlight(false);
player.sendMessage(ChatColor.AQUA + "Flight disabled!");
}
}
Have you registered the listener in your onEnable()?
yep
Make it not static
why?
Oh right missed that
so this?
public void onPlayerChangedMainHandEvent(PlayerChangedMainHandEvent event) {
Yes
You should read what that event does
lol
Because I donโt think itโs what youโre thinking
oh shoot it isnt
if i want to detect when a player switches their selected item how would i do that?
PlayerItemHeldEvent iirc?
what?
myes
i don't remember if that fires for when the player manually moves items around their inventory into and out of the highlighted hotbar slot
hmmmmmm, now it does the opposite of what i want
@EventHandler
public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
Material itemType = player.getInventory().getItemInMainHand().getType();
if (itemType == Material.NETHER_STAR) {
player.setAllowFlight(true);
player.sendMessage(ChatColor.AQUA + "Flight enabled!");
} else {
player.setAllowFlight(false);
player.sendMessage(ChatColor.AQUA + "Flight disabled!");
}
}
it definitely fires when the player scrolls around their hotbar though
it does
but now it sets flight to true if they are not holding the nether star
try getting the item from the event
the event probably happens before the item is actually held
as is the case with most events
I believe you have to use player.getInventory().getItem(event.getnewItemSlot())
Not sure what the exact function name is
Something with newslot
and then pray that the slot layout of the methods is the same
exactly fucking half of bukkit methods use raw slots and the rest use inventory slots and it's never documented which is which
Also it might be fired when you change it while dropping the item or clicking around manually
hmmmmmm got a nullpointerexception
on the getType()?
You likely need to check if the item in his hand is an actual item
bukkit also returns air on exactly half of the getItem methods, and the rest return null
consistency is great
๐ฏ
do you know if this would work?
Material itemType = player.getInventory().getItem(event.getNewSlot()).getType();
if (itemType == null) {
itemType = Material.AIR;
}
ok, if so how would i set item to air?
ItemStack itemInHand = //Here your getInventory().getItem(...) code.
Material itemType;
if (itemInHand == null) {
itemType = Material.AIR;
} else {
itemType = itemInHand.getType();
}
More fun way
ItemStack itemInHand = //Here your getInventory().getItem(...) code.
Material itemType = (itemInHand == null) ? Material.AIR : itemInHand.getType();
thats very very messy please clean it
How is it messy
umm what lmfao
I don't see any major nesting
wdym
@EventHandler
public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
Material itemType = player.getInventory().getItemInMainHand().getType();
if (itemType == Material.NETHER_STAR) {
player.setAllowFlight(true);
player.sendMessage(ChatColor.AQUA + "Flight enabled!");
} else {
player.setAllowFlight(false);
player.sendMessage(ChatColor.AQUA + "Flight disabled!");
}
}
There's 1 thing you could do which is
@EventHandler
public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
Material itemType = player.getInventory().getItemInMainHand().getType();
boolean isNetherStar = itemType == Material.NETHER_STAR;
player.setAllowFlight(isNetherStar);
player.sendMessage(ChatColor.AQUA + "Flight "+ ((isNetherStar) ? "enabled" : "disabled") + "!");
}
but that's literally it
There are literally 12 lines
still adds up
?paste
What
I think he wants the link
There isnโt even a nested if in there
You haven't even said how you would do it
You just said nesting when there isn't even nesting
because you already said
@EventHandler
public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
Material itemType = player.getInventory().getItemInMainHand().getType();
boolean isNetherStar = itemType == Material.NETHER_STAR;
player.setAllowFlight(isNetherStar);
player.sendMessage(ChatColor.AQUA + "Flight "+ ((isNetherStar) ? "enabled" : "disabled") + "!");
}
Wait I can shrink it more
ye
^
public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
boolean isNetherStar = (event.getPlayer().getItemInHand() == null) ? false :
event.getPlayer().getItemInHand().getType() == Material.NETHER_STAR;
player.setAllowFlight(isNetherStar);
player.sendMessage(ChatColor.AQUA + "Flight "+ ((isNetherStar) ? "enabled" : "disabled") + "!");
}
if we are talking about least lines in the method then you can define the boolean outside the method but then its actually messy
Alright let me see here
public void onPlayerChangedMainHandEvent(PlayerItemHeldEvent event) {
event.getPlayer().setAllowFlight(event.getPlayer().getItemInMainHand() != null && event.getPlayer().getItemInMainHand().getType() == Material.NETHER_STAR);
event.getPlayer().sendMessage(ChatColor.AQUA + event.getPlayer().getItemInMainHand() != null && event.getPlayer().getItemInMainHand().getType() == Material.NETHER_STAR ? โenabledโ : โdisabledโ);
}
2 lines
2 lines, and the worst thing ever to read, enjoy

I agree
^
havent we all wrote terrible code before
sometimes its too much work to make it look good, or we are too lazy to fix after writing messy code to see why somthing is broken
or simply u just started coding and u made bad code, eveyrone has
I am sorry for this but only a little bit
int xOffset = dir == 3 ? 7 + level * 4 : dir == 1 ? -1 : 2 + level;
int width = (dir == 0 || dir == 2) ? 5 + (level * 2) : 7 + (level * 4);
int height = (dir == 1 || dir == 3) ? 5 + (level * 2) : 7 + (level * 4);```
ternary
the ancient texts
player.damage accounts for armor iirc
how do i check if the world isnt loaded but exists? ex. if (getServer().getWorld(worldName) != null)?
I suppose you could do new File(new File(Bukkit.getWorldContainer(), worldName), "level.dat").isFile())
okay ty
&& !"session.lock".isFile() >:)
if (new File(new File(instance.getServer().getWorldContainer(), worldName), "level.dat").isFile() && new File(new File(instance.getServer().getWorldContainer(), worldName), "session.lock").isFile()) ?
!isFile
but your first suggestion would work to see that the world isnt loaded
probably
is there an event that checks every time the player gets a message from anywhere?, like from broadcast or send or more the important thing is that the player gets chat
i dont think so
How do I make it so that an item can be enchanted in the enchantment table? Made an "emerald" sword using the Diamond Sword ItemStack, Meta, etc. How do I make it so that the emerald sword also inherits the ability to be enchanted?
i think smth like InventoryClickEvent then check the inventory type if its enchant table
[NMS] How to set mob's follow range?
I'm talking about attacking the player when he's in the n block.
Since you're using NMS you might have to find that yourself
Minidiggers mapping viewer is a good start
ty, but uhh it seems doesn't work
LivingEntity livingEntity = (LivingEntity) this.getBukkitEntity();
AttributeInstance followRange = livingEntity.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
followRange.setBaseValue(10000);
its not gonna follow past either activation range or chunk loaded range
cant all swords be enchanted?
ill try to rephrase my question. how do i make an item enchantable?
No, it's odd
let me do a test hold on
I dont see why it wouldnt be enchantable
....yeah never mind. some big user error on my part lmao
do you know any mojang api wrapper for maven cause i'm too lazy to do it on my own?
mojang API wrapper?
yes instead of having to create a connection and type the url and all that stuff having an api to do it
i can do it own my own but i'm lazy so if there's something like that it would save me a lot of time
i need to get skin data of players by the way
NMS's game profile should do that but idk
i know it does that i just wanna grab the skin data from the mojang servers
Im making an anticheat and for some reason when i get kicked and rejoin I cant see flags in chat until someone else is kicked, I can see flags after that again
@outer sorrel show us ur code maybe?
also it still flags because you still get kicked so idk whats wrong, just doesnt send the message
Don't return in that loop
Use continue
Or it will only alert one player max
(Line 60)
eh we all make mistakes
you know when people shout about "dAtaBAsE cALLs shOUlD bE asYNCHroNouS", is calling them on a different thread from the main one synchronously enough? (having trouble figuring out how to run concurrent callable asynchronously)
yes
okay thank you โค๏ธ
๐ฅฒ
@chrome beacon is the best helper tbh
@fading lake honestly didnt expect to see u get into MC dev all those years ago lol
neither did I honestly, pretty sure back then I was just getting into roblox lua lmfao
We have expert on OOP ? (yes pls)
No
You provided too much information so I cannot help you
And I guess that also applies to the rest of the peeps on here
BiteDick
I am trying to get a string from a yaml file, but it returns null, and when i check if the file contains that value, it says it doesnt. but it does work with integers, doubles, longs and booleans?
switch (dataType) {
case STRING:
if(!config.contains(dataKey)) Bukkit.getLogger().info("wtf");
String test = config.getString(dataKey);
Bukkit.getLogger().info(test);
break;
case INT:
Bukkit.getLogger().info(String.valueOf(config.getInt(dataKey)));
break;
case DOUBLE:
Bukkit.getLogger().info(String.valueOf(config.getDouble(dataKey)));
break;
case LONG:
Bukkit.getLogger().info(String.valueOf(config.getLong(dataKey)));
break;
case BOOLEAN:
Bukkit.getLogger().info(String.valueOf(config.getBoolean(dataKey)));
break;
}```
```yaml
sql:
host: 127.0.0.1
port: 3306
database: minecraft
username: "%plugin"
password: ""
useSSL: false
someotherthing:
inttest: 0
doubletest: 0.0
longtest: 0
stringtest: "heya"
and my output is this:
[12:18:32] [Server thread/INFO]: [CM] Enabling ConfigManager v1.0.0
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
[12:18:32] [Server thread/INFO]: false
[12:18:32] [Server thread/INFO]: 0
[12:18:32] [Server thread/INFO]: 0.0
[12:18:32] [Server thread/INFO]: 0
[12:18:32] [Server thread/INFO]: wtf
[12:18:32] [Server thread/INFO]: null
What is "dataKey"?
the key from the config, so for example sql.database
Sure? Otherwise config is invalid
i mean it works with everything other than the string
That is because 0/false are default
They cannot return null due to the way primitives work in java
yes
anyways turning decimal numbers into hex
fun stuff
jk thats where python comes in
I mean Integer.toHexString(int n) is quite handy
java can do that?
yes..
yes ?
aside like "%x".format(int)
eh i just threw it in a python array and used its hex function
no, so it would be
this.put(Integer.toHexString(16755200), "GOLD");
that works too
nah im still trying to represent a number
just make it make more sense in my code
if only i knew ij could do this before i grabbed python lol
this makes more sense lol
now to make everything uppercase
perfect
String#toUpperCase()
There's another way to do it using a function if you want:
public int toHex(int n) {
int remainder;
String result = "";
char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while (n > 0) {
remainder = n % 16;
result = hex[remainder]+result;
n /= 16;
}
return Integer.parseInt(result);
}```
not tested but it should work
"%X".format(int)
anyways all i needed was hex in my code to represent colors instead of numbers
how would i update a zombies health to its health everytime it takes damage
package index
ok thanks
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent
does anyone know how to get all the files (from a Folder) to a inventory?
can I make a system of friends on the server so that the commands are on the spigot plugin and the data is sent to the bungeecord?
using Bukkit & BungeeCord Plugin Messaging Channel
why wouldnt u just do bungee plugin?
but yea u can do that just use ToProxy channel
rgb = more fps
yes
yes
Hi, i created a bug report for spigot 12hrs ago i see it now its labelled as resolved so it will work on latest BuildTools' spigot version? https://hub.spigotmc.org/jira/browse/SPIGOT-6452
ToProxy?
for some reason when a value in the config is set to nothing it gets it from the default config, can i stop this somehow?
Yes
Can you make a COMPLETELY Custom mob? So instead of extending, for example EntityZombie it would extend the base class?
thanks
not sure but you would need players to download a custom texture pack if it has custom textures
hmmm, thats a point
and i dont think the game even supports specifying entity type sthat dont exist
does anyone know how to get all the files (from a Folder) to a inventory?
so you'd still have to represent it as SOMETHING
how do you mean?
like, a file browser in an Inventory?
I got a folder with a lods of report files, i want to get all the files in a inventory
i did this kinda thing once
yeah one sec
ill find my code
k
ok
looking back on it, it is bad code
ty <3!
ok, so don't take this code and use it
cause it is bad
take the idea, and make it better
basically, the format for the file
ok ty man!
was the player's uuid+".yml" as the name
and then some other lines
inside the yaml file
k
and then it added the piece of paper with lore lines to an inventory
and showed the player it
pls dm me if you need more help
ok
also, that inventory shoudn't be static
hey md_5, how does spigot get working 24bit color in console?
im using jansi but its only outputting in 8/16 colors or so
im wondering if im missing something (i have AnsiConsole.systemInstall(); in the beginning of my code)
WSL for reference:
under spigot:
according to the craftbukkit source its using the same code as i am
would it be possible to make something that makes a small wall when i place my barricade block
unsupported java check on craftbukkit, begone
absolutely
i mean, you could listen for the block place event and then make the structure when they place it
how would i make the structure?
by placing blocks
hhhhhhm
Hi i need help in making a custom Play time recorder plugin
i need to know how to do it
uhm yes
i want to make a bungeecord plugin which keeps track of how much time a player plays
in the whole of server and other servers
also, I am very new to plugin development
and i am learning
thank you
it may be hard to read, but i understand what goes on behind it so Ill use that
why is maven creating two jars the one with "original" prefix and the other without it and how can i prevent this from happening?
thats from the shading plugin
and what is it's use?
one is with all the dependencies one without
which do i need to keep?
i always use the non-original one
The original is not really relevant for you
how do i prevent original from generating then
Cannot do that
^
๐ข
Why do you want to prevent it too?
The shaded requires the original to exist
its not a big deal
i just don't wanna have both inside my plugins folder
i want the jar to be built there
uh you're doing something wrong
i just don't want to have to move it every time i want to debug or test
to my plugins folder
dont you just specify outputFile?
did that not work
<outputFile>path-to-server/plugins/${project.artifactId}.jar</outputFile>
<directory>C:\Users\Dennis Gyftakis\Desktop\1.16 SMP\plugins</directory> i added this to the <build> ... <build\>
well.. thats why
you don't specify directory
cause that will just put the target folder and all the compiled shit in the plugins folder
including the original jar
ok so i just have to add the above?
add the outputFile thing to the maven shading plugin and remove the directory
idk why you would want to use <directory> anyways
ok thanks
anyone?
Save timestamp on join and then calculate time when they leave
Add that to some storage and your plugin is done
can u tell the method?
to save timestamp?
System.currentTimeMillis()
okay

do you guys know why this doesn't work?
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can use that command!");
return true;
}
Player player = (Player) sender;
player.setFlySpeed(Float.parseFloat(args[0]));
return true;
}
it gives an error
but [0] should always be the first argument right?
/label args[0] args[1] ...
yes, even if I send /flyspeed 20 it still gives an error
what is the error
send it
lemme get it
isnt btw flyspeed max 10?
i dont think flyspeed can be creater than 1
when asking "why doesn't x work" and you have an error, start with the error
no im pretty sure the max is 1
the error contains 90% of the information we need
oh yeah maybe yes
0.1 to 1
reading the error yourself can also help
org.bukkit.command.CommandException: Unhandled exception executing command 'flyspeed' in plugin tutorial v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:810) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2176) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1991) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1944) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:50) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:8) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-651]
at
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1255) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeAll(IAsyncTaskHandler.java:95) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1391) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1126) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-651]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.lang.IllegalArgumentException: 2.0 is too high
at org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.validateSpeed(CraftPlayer.java:1786) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.setFlySpeed(CraftPlayer.java:1753) ~[patched_1.16.5.jar:git-Paper-651]
at com.defiantburger.tutorial.commands.flyspeed.onCommand(flyspeed.java:18) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-651]
... 19 more
thats the error
IllegalArgumentException - If new speed is less than -1 or greater than 1
ohhhhhhhhhhh
World#rayTraceEntities doesn't go through walls right?
it can be made to, but i don't think that is the default no
@cold tartan
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can use that command!");
return true;
}
Player player = (Player) sender;
Float flySpeed;
try {
flySpeed = Float.parseFloat(args[0]);
if (!(flySpeed >= 0.1 && flyspeed <= 1.0)) {
player.sendMessage("Fly speed must be from 0.1 to 1.0!");
return;
}
player.setFlySpeed(flySpeed);
} catch (NumberFormatException ex) {
player.sendMessage("You need to enter number");
}
return true;
}
private void setNameTag(Player player, String name) {
try {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
onlinePlayer.hidePlayer(player);
}
GameProfile profile = ((CraftPlayer) player).getProfile();
Field ff = profile.getClass().getDeclaredField("name");
ff.setAccessible(true);
ff.set(profile, name);
Field ffu = profile.getClass().getDeclaredField("id");
ffu.setAccessible(true);
ffu.set(profile, UUID.randomUUID());
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
onlinePlayer.showPlayer(player);
}
} catch (Exception e) {
e.printStackTrace();
}
}``` This is my method for setting someone's name, it works well however their old name is still part of the tablist as shown here
https://i.theblitzbot.com/KYsFH.png
try hideplayer and then showplayer
nice variable names
yeah xd
yeah
i dont think they're bad except the Fields
Yeah they're only used in the directly associated lines so it's fine
By the way I'm already hiding the player before the gameprofile is modifed & also showing the player after it's done
oh yeah sry didnt notice
it may be the case that their displayName still retains the old username
it's just added onto the tablist
you are changing the username of a player
displayname is stored separately from the username
and it may retain the old value from before you changed the username
and is used as the default for the playerlist name
try calling player.getDisplayName and see what it returns
i'm not talking about what he should do
i'm talking about what is probably the cause
even if the displayname remains the same it shouldn't just add more of the same ones onto tab right
p.updateInventory();``` guys will it set the item in current opened inventory?
void changeNameForTest(Player player, String name, List<Player> viewers) {
GameProfile gp = ((CraftPlayer)player).getProfile();
try {
Field nameField = GameProfile.class.getDeclaredField("name");
nameField.setAccessible(true);
nameField.set(gp, name);
} catch (IllegalAccessException | NoSuchFieldException ex) {
throw new IllegalStateException(ex);
}
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(player.getEntityId()));
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer)player).getHandle()));
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer)player).getHandle()));
for (Player pl : viewers) {
if (pl == player) continue;
((CraftPlayer)pl).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(((CraftPlayer)player).getHandle()));
}
}
found this on forum try the sending packets
the issue is that that doesn't actually change the name of the player
anything else that sends a tablist update for that player will revert the value to the old name
see where the incorrect tablist name is coming from; get the player's tablist name and trace that value to its source, then replace the value at the source with the new one
just throwing packets at the client isn't reliable
doesn't change the overhead name
hmm ill try smth with it
Perhaps the hiding + showing thing might be a solution for this
hello
hello
hello
oh you're correct NNY
I currently already have code to change the skins of the players that works flawlessly but changing the nametag seems to be a whole different animal
i'm making a plugin to change skins and i need to perform a dimension change. would it be better to teleport the player to another world and then back to where they were before or just kill them and instantly re-spawn them?
If I wanted to get a player another player is looking at, would it be more efficient to raytrace or use a nearby entities + line of sight?
from 2011 though ๐
raytrace is basically a slightly optimized version of getting nearby entities and line of sight
still can work
like getNearbyEntities, it only checks the chunk slices that overlap with the ray
it's about as fast as searching for nearby entities can get
im doing this like 1000+ times a minute lol
but it looks in every direction, not just along a single ray like the raytrace call
yeah i think it makes sense for raytrace to be faster
its performance characteristics are similar to the collision checks the server does every tick for every entity
of course if you're doing a batshit insane number of those calls, you could hack into the chunk slices yourself and iterate over their contents asynchronously
you might get some stale data now and then because no synchronization, but it comes at basically zero main thread time cost
is there a way to visualize the raytrace with particles
not with the raytrace call itself no
but drawing a line of particles is very trivial and cheap so you can do it yourself just fine
hi, I need to check whether there is another block of a certain type around the block, how can I do this without getting each side through getRelative since this is too many variables and calculations
you can do a for loop
for (BlockFace face : BlockFace.values()) {
Block neighbor = block.getRelative(face);
}
could smbdy help me?
[17:12:28 ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: null
at org.spigotmc.SpigotConfig.stats(SpigotConfig.java:260) ~[server.jar:git-Spigot-79a30d7-acbc348]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
at org.spigotmc.SpigotConfig.readConfig(SpigotConfig.java:110) ~[server.jar:git-Spigot-79a30d7-acbc348]
at org.spigotmc.SpigotConfig.init(SpigotConfig.java:76) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:184) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [server.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
[17:12:28 ERROR]: This crash report has been saved to: /home/container/./crash-reports/crash-2021-05-09_17.12.28-server.txt
my spigot.yml: https://paste.md-5.net/wayucahiku.bash
thx
what is your plugin name
its spigot.yml
is it called SpigotConfig?
no its like a spigot.yml file
its not a plugin
?
SpigotConfig is the class that backs spigot.yml
its a spigot.yml file in the server root where are worlds eula
What did you change that broke it?
if it's not programming, you should be in #help-server
i dont know i changed everything except world-settings
That English doesn't make sense. Try again
better?
look at the sauce and see what it's trying to parse i guess
Not really
i just changed every line that there is except the world-settings column
Hey, does anyone know if it's possible or how to edit a chat message. So for example for displaying a timer like 10 seconds till borders drop, then instead of sending a new message 9 seconds till borders drop, then kinda edit the first message and update it with 9 seconds and so on?
kind of
you can't modify already sent messages, no
but what you can do is re-send the entire chat history to a player with that particular message changed
which involves keeping track of all the chat packets each player receives, then modifying the contents of the message you want to change, and then resending them in bulk
seems like a bit of a hack.
i think i would rather send bossbars
it also is kind of laggy for the client and takes shit tons of bandwidth
The only noticable thing I see is your forced-stats: [] Mine forced-stats: {}
i'm using the packetplayoutgamestatechange to show respawn the player as if they've bitten the ender dragon but the client gets stacked at the loading terrain part until the player dies
what causes this?
ender dragons taste bad
i couldn't care less
i do hate it when the clients are stacked
me too that's why i'm asking
did you write this with speech to text
no
how can i disable players that are connecting with versions under 1.12.2 on bungeecord?
are you working with a bungee or spigot plugin?
with nothing
then obviously make one
just wanted to ask bcz there's a outdated_client in messages.properties in bungee
not sure let me check
the protocol version of the client is probably exposed somewhere
okay
how do I get the number of players online? something I can't find in the api
get the count of Bukkit.getOnlinePlayers
I would like to know if it is possible to update only one section of a chunk ?
Bukkit.getOnlinePlayers().size()
also that's threadsafe.
[Server thread/FATAL]: Error executing task on Server
java.lang.NullPointerException: null
at net.minecraft.server.v1_16_R3.ChunkMapDistance.b(ChunkMapDistance.java:244) ~[server.jar:2991-Spigot-018b9a0-f3f3094] when entering the portal to go back to the overworld after killing dragon
Please help
0_0
?paste full error
ok : D
thx
theres more to that error
If thats the case you have a serious issue as there is only Minecraft packages in that stacktrace
No plugin
yes it's not caused by a plugin
Then you need #help-server
i suspect it's probably the values that are being set to initialize like the packet
or smthing
but i need to replicate this on my plugin
sendGameState(p, PacketPlayOutGameStateChange.e, 0);
public void sendGameState(Player player, PacketPlayOutGameStateChange.a type, float state) { PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(type, state); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); }
that's supposed to send the credit screen after beating minecraft
but even in vanilla if i kill the dragon and get into the portal it crashes
and prints that error
shall i move to #help-server ?
is there a better way of saving the lore of an item to a location than this?
Double.parseDouble(clickedItem.getItemMeta().getLore().get(1)),
Double.parseDouble(clickedItem.getItemMeta().getLore().get(2)),
Double.parseDouble(clickedItem.getItemMeta().getLore().get(3)));
the lore is
world
X
Y
Z
why are you using the meta to store information
you know if you used pdc it would be much easier
what is pdc
persistent data container
. . .
ty
yeah well
ooof