#help-development
1 messages · Page 2004 of 1
oh that teams
that plugin above deals with factions which is somewhat a different type of team implementation
Minecraft wiki n javadocs is j too general i need specific documentations for teams, i mean like to put 4 players split in 2 teams to fight each other
so
still not returning
"That message recieved event won't be fired on the server thread. Be aware this might cause issues" as Olivo said
he said to use this channel?
yes they said that too
is there anyway i can set PDC as a stringlist?
than can i get help in this channel?
why dont you listen for a command instead of trying to work with a messaging event that might not happen?
do uhm
How would I create a function outside of a file in java, and use import to retrieve it and use it?
wdym
register and listen for your own command - then the server will respond when the comamnd gets called
is the discord API actually working fully again? - yeah it looks like it
it was broken most of yesterday
yes maybe
hello guys, I use ProtocolLib to get a packet from the server, but I get this error. anyone knows what the problem is?
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
20:35:32 ERROR]: [Terraplusminus] Unhandled exception number 512 occured in onPacketSending(PacketEvent) for Terraplusminus
com.comphenix.protocol.reflect.FieldAccessException: No field with type [B exists in class ClientboundLevelChunkWithLightPacket.
at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:218) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:197) ~[ProtocolLib.jar:?]
at de.btegermany.terraplusminus.Terraplusminus$1.onPacketSending(Terraplusminus.java:87) ~[terraplusminus-1.0-SNAPSHOT.jar:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:535) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:516) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:346) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:308) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:436) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ChannelInjector.access$800(ChannelInjector.java:72) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ChannelInjector$3.handleScheduled(ChannelInjector.java:376) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ChannelInjector$3.onMessageScheduled(ChannelInjector.java:346) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95) ~[ProtocolLib.jar:?]
at net.minecraft.network.Connection.writePacket(Connection.java:401) ~[?:?]
at net.minecraft.network.Connection.send(Connection.java:348) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2022) ~[?:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2008) ~[?:?] at net.minecraft.server.level.ServerPlayer.trackChunk(ServerPlayer.java:2162) ~[?:?]
at net.minecraft.server.level.ChunkMap.playerLoadedChunk(ChunkMap.java:2139) ~[paper-1.18.1.jar:git-Paper-"c50fc3a"]
at net.minecraft.server.level.ChunkMap.updateChunkTracking(ChunkMap.java:1587) ~[paper-1.18.1.jar:git-Paper-"c50fc3a"]
at net.minecraft.server.level.ChunkMap.move(ChunkMap.java:1920) ~[paper-1.18.1.jar:git-Paper-"c50fc3a"]
at net.minecraft.server.level.ServerChunkCache.move(ServerChunkCache.java:1158) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleMovePlayer(ServerGamePacketListenerImpl.java:1528) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.handle(ServerboundMovePlayerPacket.java:114) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos.handle(ServerboundMovePlayerPacket.java:42) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-"c50fc3a"]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
```...
so I would like to get this packet (https://i.imgur.com/3mj57Wb.png), but it gives me this error
When moving commands to an executor, it doesnt work ingame. All that happens is it types "/challange" in chat. Why?
main script:
getCommand("challenge").setExecutor(new ChallangeCommand())
ChallangeCommand.java
public class ChallangeCommand() extends JavaPlugin implements CommandExecutor{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
if (sender instanceof Player){
if(getConfig().getBoolean("damageEvent")) {
getConfig().set("damageEvent", false);
new PluginFuncs().sendGlobalMessage(ChatColor.RED + "Challenge has stopped.");
}else{
getConfig().set("damageEvent", true);
new PluginFuncs().sendGlobalMessage(ChatColor.RED + "Challenge has began!");
}
}
return true;
}
}
if i use field index 0 and 1 for ChunkX and ChunkZ it works, but when I try to get packet.getByteArrays().read(4))); packet index 4 (the data field), i get this error
yep
commands:
challenge:
description: Starts the server challenge.
usage: /<command>
Are you not allowed to run "extends JavaPlugin" twice?
does BlockPlaceEvent#getItemInHand() return the placed block when it was an item, based on what hand did the player place it with?
Cause otherwise I cant run getConfig in ChallangeCommand
same for mainhand
wrong ping
dw
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Oh thats in a seperate script alltogether
so I can have seperate functions in a different place
package me.emerald.mphone;
import org.bukkit.Bukkit;
public class PluginFuncs{
public void sendGlobalMessage(String msg){
Bukkit.getOnlinePlayers().forEach(sender -> sender.sendMessage(msg));
}
}
wym?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I see
PluginFuncs.sendGlobalMessage(ChatColor.RED + "Challenge has stopped.");
So if I convert it to static I can do this
Thats what you mean?
Also why doing that method when you just do: Bukkit#BroadCast("my awesome text")
Sounds ilogic but idk
because that requires a perm
Oh.
What requiere perms?
Bukkit#broadcastMessage() requires players to have a perm to see it
1.18
Im using 1.12.2 for the time being
Emerald we recommend you learning java
You cannot use an api without learning the laguage Java()
I mean, I know how HTTP requests, and apis work
Ive done them in the past lol
GET, POST, etc
as u can see here.
How HTTP works has nothing todo with Java though
?learnjava It's time
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Agree
You should straight learn the programming laguage to them understand how the api works and use them
🤔
By the way, what do you mean here?
I am learning, its why I ask questions
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
We already told you. First learn java
Yeah please read the documentation
Its a simple questions that I think google can answer better than us
@EventHandler
public void onRightClick(PlayerInteractAtEntityEvent e) {
Player p = e.getPlayer();
if (e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
if (e.getRightClicked().getCustomName() == null) {
return;
}
if (e.getRightClicked().getCustomName().equalsIgnoreCase(ChatColor.RED + "Beast")) {
new SpawnGUI();
return;
}
}
Someone who can tell me if this code is right?
what does pdc stand for?
about what
Which doesnt explain it
He should learn everything literally
wha-
Java DI, constructors, static, private, etc fields
no
Ive done LuaU for 4 years
and trying to learn a new language
not the funnest change
considering its VERY different
Because how you would be using an api without knowing how static, private, etc keywords works. How to do dependency injection and many things
I dont know Lua but Java its oriented to Object
But even without using the name, f.ex. this:
@EventHandler
public void onRightClick(PlayerInteractAtEntityEvent e) {
Player p = e.getPlayer();
if (e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
new SpawnGUI();
}
}
It is still not opening the gui when I right click an armorstand
no need for equals
use == instead
kekw
the spawngui isnt probably opening itself
I prefer doing equals for comparing object
public class SpawnGUI implements Listener {
private final Inventory inv;
public SpawnGUI() {
inv = Bukkit.createInventory(null, 9, "Spawns");
initializeItems();
}
public void initializeItems() {
inv.addItem(createGuiItem(Material.BEACON, ChatColor.AQUA + "Center", ChatColor.BLUE + "Click to spawn!" ));
inv.addItem(createGuiItem(Material.COBBLESTONE, ChatColor.AQUA + "Parkour", ChatColor.BLUE + "Click to spawn!"));
}
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
final ItemStack item = new ItemStack(Material.BEACON, 1);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Parkour");
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return item;
}
public void openInventory(final HumanEntity ent) {
ent.openInventory(inv);
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
if (!e.getInventory().equals(inv)) return;
e.setCancelled(true);
final ItemStack clickedItem = e.getCurrentItem();
if (clickedItem == null || clickedItem.getType().isAir()) return;
final Player p = (Player) e.getWhoClicked();
if (clickedItem.getType().equals(Material.BEACON)) {
Location loc = new Location(Bukkit.getWorld("world"), 139.5, 8.0, 75.5, 180, 0);
p.teleport(loc);
new Beast().giveKit(p);
return;
}
}
@EventHandler
public void onInventoryClick(InventoryDragEvent e){
if (e.getInventory().equals(inv)) {
e.setCancelled(true);
}
}
}
lol
thanks
query. Does declaring variables in the function head final convert those variables into final ones or is it a necessity to enter final variables into the function call?
i would initalize te items in the constructor too
Can you tell me what i'm supposed to put in the brackets of openInventory() ?
the inventory
aasuming Player#openInventory(inv)
wait nvm that method
im doing a related thing lol
well, that just sounds like openInventory with extra steps
yea but
why not call directly said function
I read that
but
either way you're allowing access to openInventory() from outside the class
why not declare openInventory() public and be done with it
then why in the world do you write a function which does nothing besides calling openInventory() ???
huh i thought it didnt matter
since you're only passing the player there
public void initializeItems() {
inv.addItem(createGuiItem(Material.BEACON, ChatColor.AQUA + "Center", ChatColor.BLUE + "Click to spawn!" ));
inv.addItem(createGuiItem(Material.COBBLESTONE, ChatColor.AQUA + "Parkour", ChatColor.BLUE + "Click to spawn!"));
}
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
final ItemStack item = new ItemStack(Material.BEACON, 1);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Center");
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return item;
}
Is that second method really necessary n if not what am i supposed to put in place of inv.addItem(createGuiItem(Material.BEACON, ChatColor.AQUA + "Center", ChatColor.BLUE + "Click to spawn!" then?
we all do, mentally that is
final Proton instance = Proton.getInstance();
Intrinsics.checkExpressionValueIsNotNull((Object)instance, "Proton.getInstance()");
instance.getCommandHandler().registerClass((Class)BanCommand.class);
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I have that code
code block please
how
` three of that symbol
followed by java
followed by code
followed by ` three times again
Intrinsics.checkExpressionValueIsNotNull((Object)instance, "Proton.getInstance()");
instance.getCommandHandler().registerClass((Class)BanCommand.class);
?
No that's a useful method
its inventory.addItem(slot, itemstack)
final Proton instance = Proton.getInstance();
Intrinsics.checkExpressionValueIsNotNull((Object)instance, "Proton.getInstance()");
instance.getCommandHandler().registerClass((Class)BanCommand.class);
and what do we need to do with that?
final Proton instance = Proton.getInstance();
Intrinsics.checkExpressionValueIsNotNull((Object)instance, "Proton.getInstance()");
instance.getCommandHandler().registerClass((Class)BanCommand.class);
I'm pretty sure you can just add it and it will go an available spot
like picking up an item from the ground
well i need to do that but...
my plugin is kotlin code, so I don't know how to make parse the final, to kotlin
since there's no final in kotlin, only var and val
ah wait it is setItem which requires a slot
owo
i dont think you can make plugin in kotlin
you can
oh ok
then cant you just use var/val?
inv.addItem(2, new ItemStack(Material.COBBLESTONE, ChatColor.AQUA + "Parkour", ChatColor.BLUE + "Click to spawn!")));
I feel like i'm doing it wrong but idk
why kotlin tho?
setItem i mean
lol look at the methods available
and te signature
Then how am i supposed to add a name and a lore
You need to get the meta, set the name and lore, and then set the meta back
ur method before was perfectly fine
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
final ItemStack item = new ItemStack(Material.BEACON, 1);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Center");
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return item;
}
You mean this?
yeah
why not
They don’t need to be, but they might as well be
If i want to add a second item, am i supposed to do it in the same method or in a diff one?
same
whole point of a method like that is to simplify code that repeats
that u run multiple times
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
final ItemStack item = new ItemStack(Material.BEACON, 1);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Center");
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return item;
final ItemStack item2 = new ItemStack(Material.COBBLESTONE, 1);
final ItemMeta meta2 = item2.getItemMeta();
meta2.setDisplayName("Center");
meta2.setLore(Arrays.asList(lore));
item2.setItemMeta(meta);
return item2;
}
Error: unreachable statement (line final ItemStack item2 = ...)
Sorry if it's bad this is kinda new for me
Run the method twice
ohh so bc it returns it stops the code
yeah
Don’t add more to the method
yes
i see
n at the end do i j return item2 then
unless if it's like in an if statement
No just remove all that
How do you get all the PermissionAttatchents from a player?
run the function again with the other information
No you need the first return item
dont modify the method, just call it again but wit different parameters
so for each item
^
kinda owo 
If you have problems just use a command framework
that wont solve the issues lol
Menu framework*
still
Didnt he have problems with menu items?
I don't get what i'm supposed to do w what ur trying to explain me
Or ima wrong
So for the first item
I think you should save it by your self
Call the function with your arguments
And then when you need to create the second item
Call that function again but with the second items information
inv.setItem(2, createItem(Material.WEED, "weed or something", "just", "no"));
inv.setItem(3, createItem(*/ some other stuff /*))```
^
ah there is no weed ingame
So in a HashMap ?
so the point of that method is that you can call it multiple times to create different items
Prob, a HashMap<UUID, PermissionAttachment>
Ohhh okay i understand now, thanks @earnest forum & @tardy delta :)
Vuxer if you have more dudes just rember to ask
Ty
dw
I still down understand after research zach.
this.JavaPlugin = JavaPlugin
It doesnt seem to work when doing this
?
?learnjava moment
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
JavaPlugin is a class name, javaPlugin is a variable name
We told him many times that its java learn momment. But he doesnt listen
So prob its ignoring time now....
Well I ask for legimate help, and I check those sites
NONE OF THEM help me with that
learn java before doing spigot
agree
JavaPlugin is a class name
You have to set that variable to
your main class
the one that extends JavaPlugin
So id have to set JavaPlugin to the testPlugin class?
Idk you should know which class extend JavaPlugin
testPlugin extends JavaPlugin
clearly it is
So why you ask btw
Classes shouldn't start with lowercase
😂
Cause im confused on how to do that
lol
alr, ill fix that
But yes
Your main class already extends JavaPlugin. You need to pass the instance of the main class on to the common executor class. The common way to do that is called Dependency Injection.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
@quaint mantle where are you trying to make the variable?
I have a folder for commends, but when I use "extends JavaPlugin" in it, it doesnt seem to work
I need JavaPlugin in order to access getConfig
so I can overwrite a setting
you're not supposed to extend JavaPlugin again. Only your main class should extend it.
You can only have 1 class that extends javaplugin
you can only have 1 class that extends JavaPlugin
I figured so. But how can I access it then?
uhhh I'm new to intellij but how can I make spigot functions and stuff show when I type it
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Your main class
*From other areas
You really should learn Java before attempting plugin development, but you’re going to want your JavaPlugin instance (of which there is only one allowed) in your command class
"TestPlugin"
I told you, dependency injection
This will only be a miserable experience for you if you don’t learn Java beforehand
can I vc and screenshare to show u lol
And then you create a constructor with the TestPlugin object as an argument
public ClassName(TestPlugin plugin) {
this.plugin = plugin;
}
Sorry I'm on phone I can't do the code block
yes
yes
im extremely sorry
or if you want
Make a static object in your main class
So you can just do TestPlugin.plugin
Sadly when doing that, states its unable to reference it
But thats fine lol
Ill just do it the slightly longer way
This one of main reason why its straightly recommend to learn Java before trying to use an api
No cause I did this earlier
I just wasnt understanding what was being said or meant
So I was confused
Okay?
Not about an hour ago
I didn't learn java before doing spigot and it was very annoying
public class PluginFuncs{
public static void sendGlobalMessage(String msg){
Bukkit.getOnlinePlayers().forEach(sender -> sender.sendMessage(msg));
}
}
doesnt Bukkit::broadCastMessage work?
can I get some help with something basic, I'll tell u what it is a vc screenshare
remember it requires a permission now
I already say it, but they said it need a permissions to see the broadcast
to actually send
in 1.18 or what?
Yeah
yep
So
Which you specify
There is 2 methods right?
BroadcastMessage() doesnt require?
yes
Yes
one with and without a permission
So he probably should do: Bukkit.broadcastMessage("text here")
can someone help me with something basic in general 1
idk probably returns the amount of players reached
some servers have like messages that advertise stuff
like store or discord or something
Probably clogs up console
some body know how to break a block?
break naturally drops the block
Yes
I wish it played the break noise too
would be cool
You can make a player break it too
yes but how to do it? Exactly
cant you do breakNaturally() and play sound?
block.setType(Material.AIR)
I've been trying
.-.
But I don't wanna make a whole hashmap for each block break sound
lol
they've changed nms blocks
haven't found any pages on how to get the sound of it breaking yet
how would i go about checking if the player can have X of itemstack
without going overboard
You mean if they can fit it into their inventory?
Loop their inventory contents
You can do it with API
An empty slot += the the stack size of the item you're trying to fit
A slot with another item = 0
Block.getBlockData().getSoundGroup().getBreakSound()
Inventory#getFirstEmpty != -1 ?
is that actually a thing
A slot with the same item += the max stack size minus the amount of the stack
that saved me so much time thanks
I didn't know that was a thing that's awesome
You can also make the player break a block
what does that return?
Probably makes a sound
think that works
Sound object?
A Sound
That's so useful
Does calling breakBlock on a player call a BlockBreakEvent
afaik it returns -1 as default
Yes
Or does it just break the block straight-up
Oh cool
Since when has that been a thing
That’s why it’s useful
yup
lol
?ischocoreal
No, Choco is not real. I was not programmed to say this by Sam.
BlockIgniteEvent
I don't think that gets fired when it's triggered by redstone
Idk if that’s tnt or fire tbh
Pretty sure that's fire
I opened a feature request for it
It was closed as duplicate and then never added lol
Link?
@earnest forum Found a smaller way to do it in the process!
Again tysm!
public static JavaPlugin jp;
jp = this;
TestPlugin.jp.getConfig() //works
put the jp=this in onEnable
I did
just dont make it public but write a static method to access it
ok nice
@young knoll
I’ll look at it when I get home later
Jira mobile is trash
I used to get yelled at on forums for using static access. so I started using dependency injection (for retrieving main plugin)
?main lol
is that like really bad to do?
MyMainClass.getInstance looks nicer
here broo
call it getInstance or getPlugin or something ._.
lots of arguments around how you actually should do it from what i've seen dependency injection is the better way overall, but with spigot the static access doesn't matter too much
As for if a static getter for your plugin is bad
Ehhhh
Hard to say
It’s a singleton anyway
hey does anyone know how to use the lombok setter with bukkits fileconfiguration? i know how to use getter already
Dependency Injection - Should be used to access to every classes
Singleton - For access to utility clases or libraries
That what ima understand
The problem with DI for your plugin class is you sometimes end up passing it around a lot
Since you need it for some things, like runnables
yea do something like
@Setter FileConfiguration config;```
this is my getter
works nicely
but i have to use config.getBoolean so i cant set a fileconfig getter so
yea my code ends up looking like this, but I'm fine with it
public RandomMenu(FileConfiguration config, JavaPlugin plugin) {
super(config);
this.cooldownManager = new CooldownManager();
this.plugin = plugin;
this.randomSpots = new HashMap<>();
}
im just having confusion
Honestly I might start using the singleton again
I don’t think it gets a premium plugin denied, so that’s all that counts :p
why would singleton use get a premium plugin denied?
im fairly sure that will allow you to set the value of the Fileconfiguration, not set values inside of the config
There’s a lot of argument about treating your main class as a singleton
like it will create the method setConfig(Fileconfiguration config)
singletons have legitimate uses in Java o.O
that is because it is one
yes was that not what you were asking

I mean to be fair, most of the times singleton causes more trouble than the benefits you get from it
hello
🎶
if used incorrectly I agree
Imma make a plugin with only singletons
It scarcely has a correct usage
Just for the spite
why are so many people adament on using dependency injection and shaming singleton instance of main class
as in i want to be able to set stuff in my config using the lombok setter
?paste
no clue
If you are providing an API with your plugin, singleton usage will break some things
otherwise internally wise, singleton use is perfectly fine
ahhhhh
also singleton is really the only way to ensure a singular object exists
and that someone doesn't accidentally create another one
https://paste.md-5.net/acavunixem.java - A simple FileHandler based on spigot ones. Its make the job simplier
Oops I accidentally reflected another one into existence
So it used on libraries?
sometimes
just depends on why you need it, as stated most people don't use them correctly
for my personal library I just call JavaPlugin over any specific instance 🤷♂️ easier for me though I'm sure theres probably a better way there almost always is lol
so for example in that plugin, I use a singleton for TutorialManager
because I need to ensure only one of those exists
so how i cna make my perm node?
perm mode?
ItemStack deco = new ItemStack(Material.STAINED_GLASS_PANE);
for ItemStack, how would I make it a colored stained glass?
EX: The color red
What version
what version
1.12.2
Ew
not entirely sure what you are asking
oh fk yea
red is 14 yea
at least not 1.8
look up bytes needed on google there is probably somtehing
So glad those magic values are dead
agreed
lol I always hated dealing with damage values
one of few areas I hated magic numbers
how do i check for online players?
Bukkit.getOnlinePlayers
Bukkit.getOnlinePlayers
Player player = getServer().getOnlinePlayers(); dont work
you type faster than me ahh
because you need an array
We really need a /jd <method/class>
Incompatible types. Found: 'java.util.Collection<capture<? extends org.bukkit.entity.Player>>', required: 'org.bukkit.entity.Player'
Player isn't an array type or collection type
now Player[] is though
seems you need to learn your Java types
I just use object for everything
have no idea what you are doing, but I doubt you really want a Player[] array object though
you are using a Map<String, Object> grr
cant make a type mistake if type is basically everything
i need to check if the player is online for play particle at em
uhm why
What player
Hey guys im trying to freeze someone when his heart is half how can i do
all
Then loop over getOnlinePlayers
if they are not online it won't play?
Alright, Bukkit.getPlayer(UUID);
can start by using FREEZE instead of JUMP
for(Player players : Bukkit.getOnlinePlayers()) {} got no errors
The heck is FREEZE
you could optionally use OfflinePlayer().isOnline() as well
dude
that command does not even work im trying to fix it
you can freeze a player several ways
tf is freezing ffs?
Make no move
ohh
p.addPotionEffect(slowness)
check damage event
High slowness and jump boost is an option
Set movement speed to zero, give the player a negative jump boost effect, and cancel move events that change their location, not their facing direction
ya but you can still jump for the setWalkSpeed
Yeah
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, timeInTicks, 255))?
So combine with jumpboost
Teleport them back to loc is also an option.
That’s what the boost is for
Although even then you can still creep forward
minecraft should add a way to set jump hight without jump boost
negative jumpboost? :thonk:
pretty much anything else might show a result rather than the jump potion effect
if(e.getEntity() instanceof Player && ((Player) e.getEntity()).getHealth() <= 0) { this is not working
That would be nice
is there any problem?
you can just cancel the player move event if they are frozen too
A jump height attribute
yes!!!
Either a really high or low jump boost effect
For players, not just horses
I don’t remember which
why check for health
make players horses!!!
they are looking for half a heart
if a player is dead then <=0 is valid, you need to go back to <1 - at least you are no longer checking a dead player to see if they have health
Ya'll are using nms for the height so i'd check if that has to do with anything, like disable the nms injector and try
still not working
I dont think, it has something to do with that
because <1 is dead
youre looking for <2 that would mean they are on 1(half) heart
i am using onPacketSend method of protocollib
Hmm any example of specific params that causes the issue?
that seems plausible !
if(p.getHealth()>=0.0 && p.getHealth()<=0.5){
//returns half heart
}
r u sure
Health is a double
yes
I used this examples https://dev.bukkit.org/projects/protocollib/pages/tutorial
Trying to get the BytesArray of Field index nr 4 causes it
what is the default walk speed?
why >= 0.0 ? - not sure the value of running anything on a dead player
So the byte array of the chunk sections
Yes
for scoreboard or moving them to a different spawn etc?
I made respawn event but how can i control players respawn
like if(e.getPlayer.Respawn == true)
that would be a good use of the playerDeathEvent
i thought respawn would be better
depends when you want the action to happen
No, when i set entity's walk speed 0 if he dies, after he respawns he continues with same walk speed
want to freeze the entity
Use the respawn even to set it back
is it possible to see what ip/port combination a user connected with, and then run bungeecord commands that way?
i couldnt use
Why
does potion effect get canceled on respawn? i'd think it would
public void onDying(PlayerRespawnEvent e) {
if(e.getPlayer().getWalkSpeed() == 0) {
e.getPlayer().setWalkSpeed(0.2F);
}
}```Like this?
oh forgot
Controversial
Curly brackets look better lol
at that point why bother with the if, lose an extra char
@novel vine Assuming your using an idea such as intellij that can decompile class files, check all the fields of ClientboundLevelChunkWithLightPacket class
cause No field with type [B exists in class ClientboundLevelChunkWithLightPacket.
Ah shit its not a class lmao its a custom exception
just gonna throw this here btw
do i need to control players health from damage event?
is there any other event which control healths?
Should I use a hashmap for per player variables over persistent data?
talking about chars? theres a regex file for Integer.parseInt()
25k chars long
Depends on what you are trying to do.
Hashmap isn’t persistent
If you want it to be persistent then hashmaps need extra work
Well saving it to a file
EntityRegainHealthEvent
i cant take the health of entity
No idea what that means
Im trying to control the health of an entity if its smaller than 1.
EntityDamageEvent
ye
in the config file, how would i create an array and overwrite it?
ex:
Challanges:
Hunger: false
BreakBlock: true
I know how regular ones work
but not maps
If its not possible however lmk
Do you want to know how an array is structured in yml or how a map is structured?
I want to know how to access it with getConfig() and overwrite a value
setting hunger to true or smth
As it seems that I cant do that
What does "it" refer to?
public EntityDamageEvent onGetDamaged(Player p){
if(p.getHealth()<=1.0&&p.getHealth()>0.0){
return healThing
}
}
config.yml
thats what getConfig() is for
part of JavaPlugin
FileConfiguration configuration = getConfig();
configuration.set("MaxHealth", 40.0);
saveConfig();
This overwrites the MaxHealth path inside the config.yml
Yes but that isnt inside of an actual array, thats EZ of access
the way im doing its an actual array
inside of it
would i do idk
configuation.get("Challanges").set("Hunger", true)
I see. One moment.
public void Health(EntityDamageEvent e) {
Player p = (Player) e.getEntity();
if(p.getHealth()<=3.0) {
p.setWalkSpeed(0);
}```
In this when he fells or he gets damage from lava p.setwalk not working
FileConfiguration configuration = getConfig();
List<String> values = configuration.getStringList("SomeValues");
values.set(2, "TripleFF");
configuration.set("SomeValues", values);
saveConfig();
yml before:
SomeValues:
- "Foo"
- "Bar"
- "Baz"
- "Han"
yml afterwards:
SomeValues:
- "Foo"
- "Bar"
- "TripleFF"
- "Han"
This will lead to class cast exceptions for obvious reasons
Also this gets the health pre damage retraction
Wait.. so what about overwriting values?
SomeValues:
- "Foo": true
- "Bar": true
- "Baz": true
- "Han": true
SomeValues:
- "Foo": false
- "Bar": false
- "Baz": false
- "Han": false
Like so
same
you sure it will work the EXACT same?
cause im overwriting the bools not the name
Oh wait. What you posted is something completely different
Thats an array of objects... quite weird to handle
Why dont you just do
SomeValues:
Foo: false
Bar: false
Baz: false
Han: false
And then overwrite SomeValues.Baz
Wait.. You can do that?
FileConfiguration configuration = getConfig();
configuration.set("SomeValues.Bar", true);
@lost matrix ???
Sure
what
is there a way to convert yaw into 0 to 360 instead of -180 to 180?
yaw + 180 lol
when using fileconfiguration.set() if the key is already there will it set the key? and if its not there will it create the key?
yaw = 360 lol
or is that setdefaults
set will always put that key:value into the FileConfiguration
where will it it put it
just at the end of the file? or in a space
between lines
Depends on if parts of the path already exist
How to handle java.lang.Record cannot be resolved to a type?
check your java version
It's 17
Full stack trace pls
if the file had return gaps and stuff
It's a compilation error, there is no stack trace
I'm trying to create a very simple record
In fact, even without any fields the error is still thrown
Show it. Also the compiler has stack traces too
Make sure you have the right java version specified in your pom
okay for some reason the error vanished... ._.
@lost matrix You. Are. Amazing.
most likely a reload bug
Thank you SO much
How can I set a player to max health using attributes?
player.setHealth(20.0)
Just change the value of the GENERIC_MAX_HEALTH attribute
or that
This is deprecated, and he very clearly talked about attributes.
a
alr thx
thx
?jd moment
is there a way I can do the same for saturation and hunger?
Google your question before asking it:
https://www.google.com/
The first adds the right side on a value the second one just reassigns it.
Example:
int x = 10;
int y = 10;
x += 8;
y =+ 8;
x will now be 18
y will now be 8
=+ is the same as =
oh kk thanks
yeah... broken operator
the same way you debounce switches?
onclick offclick
<-- --> like this
where clicking on back arrow fires an event
clicking on foward also fires an event
but they're both in the same line
I dont think you can do that
dunno, i cant use those
not really, y =+ 8 is really just y = +8, as in you're assigning y with positive 8
i've seen servers do that before
You can use hover event
supposed to be pre-increment and post-increment java just refused to implement post-increment
okay
Wait i will send a sample code
@ornate patio Make separate TextComponent, one for left arrow and one for right arrow. Set a different click event for each of these text components. Then append them together.
how do you "append them together"
// Hover message
TextComponent component = new TextComponent(Chat.style("&sMy message"));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style("Hovered message")).create()));
// Hover message that execute a command
TextComponent component = new TextComponent(Chat.style("&sMy message"));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style("Hovered message")).create()));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/gamemode 1"));
@okokay1204
im asking how to have two seperate click events in one line
component1.addExtra(component2) ...
ty
You can just create a somehting like this
// create each comoponent
TextComponent right = new TextComponent("text");
TextComponent left = new TextComponent("text");
// Main component
TextComponent base = new TextComponent(Chat.style("&sMy message"));
base.addExtra(right);
base.addExtra(left);
ye i figured
i just needed to know .addExtra()
Just search the class TextComponent and read the methods
I am trying to ENTITY_DESTROY my snowball.class projectile but I am getting an error code not sure how to properly destroy the projectile but keep the passenger so that the projectile is invisible
whats that website that has imgs of all mc blocks/items
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Please read, it will help u
?ask I am trying to ENTITY_DESTROY my snowball.class projectile but I am getting an error code not sure how to properly destroy the projectile but keep the passenger so that the projectile is invisible
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
A searchable Minecraft ID list, containing all item and block IDs from the latest version of Minecraft (1.18) and lower versions (1.17, 1.16, 1.15, 1.14, 1.13, 1.12, 1.8, etc).
No no, it just explain how you should ask for help
Sorry i confuse you
You do know spigot has an api to hide entities now
no i don't what is it
i want to hide a projectile snowball
thought you had to use packet destroy but what is the api to hide entity?
or... projectile
Like for asking help, you have to explain your problem/issue or question and send the code you are using
Send it on ?paste
aw so you can just hide it
?paste
Just use the api
Yeah dont complicate your life using packet when you can use the api
is it just hideEntity?
I sent you the docs
He sent the docs link. There you can find it
Read them
Why people doesnt like reading the docs?
hm, thought there was another one, cause this doesnt have like just one of the block faces
trying to get deepslate coal ore texture
I always think the same question
I answer my questions too also figured it out
Is there an event for when a player puts something in their offhand?
what's that website
?jd-s
thx
guys but if I wanted to make a plugin that assigns specific permissions like I write "/ perm @user plugin.fly" assign the specific permission can it be done?
yes it can be done
is there any guide?
no
.-.
I would prefer using luck perms or something
^
I've been trying for a month
why do you want your own permission plugin tho
well you would have to be advanced in both java and spigot to recreate a plugin like luckperms
I prefer to create my own plugin
I don't see the point
me neither, Luckperms has everything you could hope for & is bug tested extensively
yeah
Im starting in that world
So if you wanna you can add me and them we can take a look together
im italian
Doing permissions plugins
Gl
GI?
Good luck
^^^
How can I create a repeating task?
?scheduling
?sche ah well coll has fast hands
Do you guys know how to run a synchronous task after an async is done? After asynchronously trying to put up an item to auction (using sql), I want to return them the item if it fails and think I should do that in sync right?
Use a future
maybe CompletableFuture
Those have stuff for handling exceptions and syncing back to the calling thread and all that
Yeah I’m currently using a completable future with a while loop, but Idk if that’s the best way
show your code
in a paste
A while loop?
Don’t futures haves methods for doing stuff when they finish
Like thenAccept
yea they do
Oh I’ll look into that
uhh I got an error and I'm confused on what I did wrong
java: no suitable method found for registerEvent(com.blebdapleb.firstplugin.listeners.WelcomeListener,com.blebdapleb.firstplugin.FirstPlugin)
method org.bukkit.plugin.PluginManager.registerEvent(java.lang.Class<? extends org.bukkit.event.Event>,org.bukkit.event.Listener,org.bukkit.event.EventPriority,org.bukkit.plugin.EventExecutor,org.bukkit.plugin.Plugin) is not applicable
(actual and formal argument lists differ in length)
method org.bukkit.plugin.PluginManager.registerEvent(java.lang.Class<? extends org.bukkit.event.Event>,org.bukkit.event.Listener,org.bukkit.event.EventPriority,org.bukkit.plugin.EventExecutor,org.bukkit.plugin.Plugin,boolean) is not applicable
(actual and formal argument lists differ in length)```
``package com.blebdapleb.firstplugin;
import com.blebdapleb.firstplugin.commands.AddCommand;
import com.blebdapleb.firstplugin.commands.FeedCommand;
import com.blebdapleb.firstplugin.commands.HealCommand;
import com.blebdapleb.firstplugin.commands.MultiplyCommand;
import com.blebdapleb.firstplugin.listeners.BlockBreakListener;
import com.blebdapleb.firstplugin.listeners.WelcomeListener;
import org.bukkit.Bukkit;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class FirstPlugin extends JavaPlugin {
@Override
public void onEnable(){
//Commands
getCommand("hello").setExecutor(new HelloCommand());
getCommand("add").setExecutor(new AddCommand());
getCommand("multiply").setExecutor(new MultiplyCommand());
getCommand("heal").setExecutor(new HealCommand());
getCommand("feed").setExecutor(new FeedCommand());
//Events
Bukkit.getPluginManager().registerEvent(new WelcomeListener(), this);
Bukkit.getPluginManager().registerEvent(new BlockBreakListener(), this);
getLogger().info("Hello world");
}
@Override
public void onDisable(){
getLogger().info("This plugin has been disabled");
}
}``
registerEvents
registerEvents
shoulnt you use registerEvents
?
yep
Ur ide should be yelling at you
Okay so we are at a complete loss. We're trying to make an invisible arrow. Everywhere we've looked says to use packets however we have absolutely no clue how to use packets.
yeah it should
Use the API
Assuming you are on latest
We've looked at the api.
any1 know the problem here?
Player#hideEntity
#hideEntity?
Yes
Thanks
is often used to denote instance methods
there's no use in obfuscation
if someone wants it deobfuscated, it will be deobfuscated
cause its useless
because what do you have that's worth protecting?
makes debugging a bitch, can be bypassed immeditly
My amazing code
even if someone rips your plugin apart, changes it, and uses it for themselves
so what?
what actually does your plugin do
Support open source
like, anticheat, core, etc?
oh
Public or private?
now that is a somewhat useful case
Meh
The cheat developers know how to unobfuscate
Id recommend you look into MCMs policys regarding obfuscation
Not sure if they have one or not, I know Spigot does for example
MCM doesn’t really care
Afaik
Well yeah
It’s java
It’s always going to be convertible to something readable
to your original question, most things will be deobf very fast, it's def a short list that take a little bit longer than instantly to deobf
Optic would prob know some decent ones, if they are willing to share them
Do you guys ever upload open source plugins under your real names, or is it a good idea to use a separate Minecraft-username-GitHub account?
thing is with Java is that a plugin doesn't need to be deobfuscated to use it
Yeah like my main GitHub for irl stuff, versus my Minecraft one
they're a spigot resource staff, Optic prob sees obfuscation on a daily basis lol
he would know more than you think given his background
Okay so question about this. According to the api. This method is deprecated. Does that mean they made anew method for doing it or are they just removing it in newer versions?
I personally just use my main
this is why obfuscation is mainly pointless
Read why it’s deprecated
the only valid use case for it is optimization purposes
as obfuscation can make things smaller
Deprecated:
draft api
There you go
What does that mean?
it's a draft of a feature I presume
you can still attempt to use obfuscation if you want. Just don't be surprised if people still get around it. Like myself, I don't need to actually see your code to know how it works, I can just read the bytecode to figure it out.
I wonder why spigot doesn’t make like
An @Draft annotation
I wonder how many anti cheats exist now
The only reason I want to use my main(real name) GitHub is because I want to put the project on my resume. But at the same time I don’t want my Minecraft name linked to my irl name. I’m in a tough spot. I might post the open source project on my real GitHub and create new accounts for everything (like spigot to post it) to protect my anonymity alittle. What would you do in my situation?
not care? Why would it matter if your mc name is linked to you?
The same reason banksy doesn’t want their identity to be revealed xD
My name on github is my dumb old tag "Gestankbratwurst" which literally means stinky sausage in german. None of my employers cared.
Lol
Your real name isn’t really that personal
Especially if it’s just your first name
I agree. Making your first name public is like disclosing the color of your dogs hair. Not really that personal.
No it’s first and last
Meh
Why?
Unless you have the worlds most unique name combo, it doesn’t really matter still