#help-development
1 messages · Page 1744 of 1
Git bash ❌
can someon answer pls ?
what's wrong with git bash?
doesn't work
answer what?
works fine for me
gives me the same issue in gitbash as in Powershell or cmd
FFS just rename the directory to a "normal" name and try again
its not that easy...
it's one right-click, one left-click, entering the new name and hitting return
oh yea and then I have to fix like 50 other Projects.
if you hardcode that path all the time, you messed up biiiig time way earlier
hello my friends. Im trying to create a custom block with inventory (clay block with inventory 😎) this is my current code: https://paste.md-5.net/ejubacohay.java
when i drop an item to a hopper above my block, it spam my console (print) and the item dont leave the hopper. any help pls
and it still keep giving money even tho i changed to something else
I did not, that "» Projects" folder holds 50 Projects, one of them Is the one I am trying to generate Javadocs for.
and why would the other projects break by renaming that folder?
because Gradle is stupid
although I hate gradle, I wouldnt call it stupid 😄
well then just do this:
move or copy your current project to any folder without spaces/special chars, try to run the javadocs there and see if it works now
if so, we know that the folder name is the issue
and then we can find out how to get it working because tbh it should work with ANY valid directory name
but it doesn't make sense to spend hours trying to fix it unless we know where the problem is
I suggest that you open a new thread for this topic
ping me there when you opened it and we can have a look
You cant assign a TileState to a random Block. It has to be a TileState as well.
clay with inventory
works when moving the Directory but thats not a good Solution (atleast for me)
https://gyazo.com/76f51fbcd068dc59ff06c52eb8cc537d could u pls say one more think it doesnt say in that website do you do it like this ?? or do you remove thos thinks in front of link or what why it did go white when i twas yellow
and also how do i do the, command for voting list ?
im tryna use nms for the first time and when I build my jar i get this error
package org.bukkit.craftbukkit.v1_17_R1.inventory does not exist
my 1.17.1 jar is in the libraries in my project structure too
why on earth do you need nms for an inventory
well its for nbt tags
which you need why?
trying to store data in the nbt so its much easier to access
PersistentDataContainer
Use PDCs
o wat r they
no nms required
?pdc
does that work in 1.17?
alright so everytone is ignoring me now okay
Hey all, what's the the procedure for going about creating an async method?
I'm trying to query my database to update a progress bar (boss bar) and do it async so it doens't slow down my main thread- any thoughts?
Here's what I've got right now as a skeleton: ```@EventHandler
public void onPlayerJoin(PlayerJoinEvent ev) {
BossBar bar = Bukkit.getServer().createBossBar("Zombie Quest", BarColor.GREEN, BarStyle.SEGMENTED_10, BarFlag.CREATE_FOG);
bar.removeFlag(BarFlag.CREATE_FOG);
bar.addPlayer(ev.getPlayer());
}
@EventHandler
public void asyncProgressUpdater(Player p) {
}```
Thanks!
I generally use bukkittask
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
// DO STUFF ASYNC
}
}.runTaskAsynchronously(PLUGIN INSTANCE);
, period, delay
I am having trouble enabling the listeners for my plugin using this code
getServer().getPluginManager().registerEvents(new FLevelChangeEvent(), this);
getServer().getPluginManager().registerEvents(new FLoginEvent(), this);
The first enables, but the second does not. Any ideas as to why?
No human on earth is going to know why if that's the only code you're showing them
public class FLoginEvent implements Listener {
@EventHandler
public void onLogin(PlayerLoginEvent event) {
Bukkit.broadcastMessage("A player joined, refreshing the firmament.");
FirmamentPlugin.worldBorder.refresh(false);
// If the player spawns outside the firmament
if ((FirmamentPlugin.worldBorder.getRadius() < event.getPlayer().getLocation().getBlockX()) || (FirmamentPlugin.worldBorder.getRadius()< event.getPlayer().getLocation().getBlockZ())) {
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (15 * 20), 4));
event.getPlayer().sendMessage(ChatColor.BLUE + "You are temporarily invulnerable for 15 seconds.");
event.getPlayer().sendMessage(ChatColor.BLUE + "Your grace period will end soon; ensure that you are within the firmament's borders.");
}
}
}```
does this help? sorry im new to this lol
@quasi stratus bro make the player a variable
lol
Player p = event.getPlayer()
Also if youre going to be doing stuff to the player entity use the PlayerJoinEvent
You're basically trying to do stuff to the player when they aren't even loaded in yet, this is most likely your issue
Also I don't think your location checking is accurate. Might want to rethink your approach on calculating that.
ah i think this was the problem

u need to add the spigot jar not the minecraft launcher jar
& why do you need nbt for this
how does it show the, links for website ? the nuvotifier?????
i putted links doesnt show and doesnt allow to vote for others
how do i give the player 1 of what they are holding?
here u can see it i putted all links and doesnt work still and others cant vote .. when u do /vote its just disappears and nothing happens
fist of all this is a development channel
second of all, # is a comment
@subtle folio should be fairly obvious from the methods available https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/PlayerInventory.html
declaration: package: org.bukkit.inventory, interface: PlayerInventory
- Player.getInventory
see im tryna but, ItemStack item = event.getPlayer().getItemInHand(); item.setAmount(1); event.getPlayer().getInventory().addItem(item); it sets their item beforehand to 1
so im on wrong think then... where do i ask it then ? on help channel
clone the item before setting the amount
.clone() ?
bet ty
how i comment in spigot webiste i verifyed my acc but cant see whre to comment in forums for help
i cant do it its pain in the head ... no one is showing how to add websites or to use them in game or why others cant do vote ..
Thanks. Problem resolved
I want to work closely with schematic files
can you not use Minecraft's native structures?
I haven't seen plugins using .nbt structures.
For example World Edit uses schematics
If I want a compatible plugin i have to work with both formats
How do I force an Illusioner (or any IllagerWizard) to do its spell casting thingy?
Hey guys, I'm trying to make boss bars indicate specific player progress. How should I go about this?
specific player progress towards a quest goal, essentially. Is there a library that handles this? Or should I stick with the bukkit.bossbar library?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Spellcaster.html#setSpell(org.bukkit.entity.Spellcaster.Spell) might be what you are looking for ?
declaration: package: org.bukkit.entity, interface: Spellcaster
How would you go about to parse a unicode into an object
That question doesn't make sense
Stick with the library, it's not hard
emoji's
You have a Unicode representation of an object?
you don't need to parse anything, just put the emoji in
no?
I guess, how would I make bars to be associated with certain players?
I feel like I need a Player.getBossBar method in order to update the bar as the player completes tasks
Map the boss bar to a player’s uuid
but that doesn't exist. Kind of stumped
Use a HashMap
HashMap<UUID, BossBar>
Yeah that makes sense
Just make sure that when players leave the server you clear the instance from the HashMap
would anyone know why the values of my hashmap are returning null when i do new Class().hashmap().get() from another class
what does PathfinderGoalCastSpell do?
the method inside of it is just empty
I imagine it’s for casting spells
well yes but it looks like this
protected PathfinderGoalCastSpell() {}
It probably gets overridden
How would I save player data into a database-
i found this https://gist.github.com/graywolf336/8153678, but it's throwing java.lang.IllegalArgumentException: Size for custom inventory must be a multiple of 9 between 9 and 54 slots (got 41)
@EventHandler
public void onHi(PlayerJoinEvent event) throws IOException {
Player player = event.getPlayer();
Bson filter = Filters.eq("_id", player.getUniqueId().toString().replaceAll("-", ""));
Document findIterable = collection.find(filter).first();
if (!(findIterable == null)) {
System.out.println(findIterable.get("inv"));
Inventory a = fromBase64((String) findIterable.get("inv"));
System.out.println(a);
player.openInventory(a);
}
}
It's getting data from mongodb
I get this error when I try to use specialsource
Failure to find org.spigotmc:spigot:jar:remapped-mojang:1.17.1-R0.1-SNAPSHOT in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are forced
How can I make a boss bar without any bar flags?
Don’t pass any flags?
Right now Im initializing it with a flag and then immediately removing the flag lol
It's a NonNull
Sike
big sike I was being dumb
how do I fix this?
player.getInventory().remove(new ItemStack(Material.PUMPKIN_SEEDS, 50));
so i already know this ^ is wrong, but how would i do this if there wasn't an exact stack of 50 seeds and if those seeds had any kind of extra meta?
I think that would work regardless of stack size as long as its more than 50
no
when i have a stack of 64 seeds it doesn't remove
but it does when i have 50
huh
How do I fix this error with specialsource
that makes sense
tysm
a little too lazy to test rn, does calling setSprinting fire a PlayerToggleSprintEvent?
or is that only fired when a player actually does the action
hi, how do you make a tab completer for a second argument?
/<command> <arg 1> <arg 2>
^^^^
Check the arg length in the tab complete method
how?
if (args = 1) {
arguments.add("foo");
} else if (args = 2) {
arguments.add("bar");
}
like that?
args.length

missing an =, but on the right track
ya know what? I'm used to autocomplete in my ide
don't judge
well, you can judge a little
that would actually be a cool feature for discord to add tho
discord isnt an ide
but it could be
but it shouldn't be
My IDE is googling "Online Java Compiler" and crying when it times out on me
oof
also
if (arguments.isEmpty() && args.length == 0) {
arguments.add("logins"); arguments.add("playerKills");
arguments.add("deaths"); arguments.add("mobKills");
} else if (args.length == 1) {
arguments.add("test");
}
this does not work
sad
but I have no idea why
what are you doing 🤨
args is an array? so has no isEmpty() method
arguments is the tab complete menue
ok so a List
not to be confused with the args
yeah the tutorial I've been using isn't exactly the best
private final List<String> tabComplete = Arrays.asList("logins", "deaths", "playerKills", "mobKills");
//
if (args.length == 1) {
return tabComplete.stream()
.filter(str -> str.startsWith(args[0])
.collect(Collectors.toList());
}
Just use copyPartialMatches
whats that
thats so implicit only little people would know the use
im sticking with my streams
tabComplete in this case is my arguments?
ye
I'll stream you
Dont threaten me with a good time
and what is private final (I'm new to java)
can only be accessed inside the class
cannot be modified after assignment (unless through reflection)
but wouldn't I want to modify it?
.-. And Java 16 has some funky ways to even stop reflection
no
to add the second set of tab compeltes?
its all there
if (args.length == 2) {
return secondTabComplete.stream()
.filter(str -> str.startsWith(args[1])
.collect(Collectors.toList());
}
you do it by the length of args
oh so I just make another variable
secondTabComplete
yeah thats the private final
lol no
just...um
and name it better
java is medium
Just go to basics.
if(args.length == 0) {
// return a list of stuff for the first argument.
} else if(args.length == 1) {
// return a list of stuff for the second argument.
}
wait so what the heck is secondTabCompelte
They don't know lambda
im trying to teach them
a variablew
referring back to this
ok, so this goes back to the whole "second variable"
java
if 2 argument, return this variable
so there are two variables
for each tab complete
ok
as for this, I would just test to see what that value of args was
to tell which tabcomplete to send
u can write and run javascript in discord, therefore it is a javascript ide
because the entire window acts as a browser
if(args.length == 0) {
if (args[0] == "string") {}
} else if(args.length == 1) {
// return a list of stuff for the second argument.
}
its just embedded js and html
o.o
im aware of electron
therefore, every website is an ide 🤯
Why are you checking for args[0] equaling "string?" Also, == only compares direct instances. Use .equals() or .equalsIgnoreCase
switch (args.length) {
case 0:
return new ArrayList<>();
case 1:
return null; //players
default:
return whateverYou wantInTheList;
}```
Collections.emptyList()
Collections.emotyLis- damnit
Haha
And I can't spell
Slow
Collections.singletonList("") :smug:
all do the same thing
new ArrayList<>(Arrays.asList());
Muahahahaha
doesnt even work
Yeah, I know
yes it does
ok I do not understand that, but regarding to @glad badger's messsage, "string" is the first argument after the command. And assuming I use .equalsIgnoreCase, I'm good?
does it
Yeah
ima just assume it works then
Yes, but Arrays.asList(); uses a constructor that passes the array
Which sets the array inside of array list
and it's a funky mess lol
fair
But, yeah
That's why I jokingly wrapped my Arrays.asList in a new ArrayList.
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 1) {
arguments.add("logins"); arguments.add("playerKills");
arguments.add("deaths"); arguments.add("mobKills");
} else if (args.length == 2) {
arguments.add("test");
}
ok so that just shows all five
and now I'm really confused
You don't even return anything?
I don't need to?
I have this in my main: java this.getCommand("mystats").setTabCompleter(new StatTab());
so I feel like I wouldn't need to
eclipse
null?
how
Okay
unpopular opinion: switch to node.js
That's javascript
accessor returntype methodname(arguments) {
}
The accessor is going to be public, protected, or private.
returntype, if present, requires the method to return something.
If you have a returntype, like List<String>
You have to return something
In this case, a List<String>
but why does it work just fine when I dont?
I shall show you the whole file
oh
package me.theeyeofthepotato.stats;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
public class StatTab implements TabCompleter {
List<String> arguments = new ArrayList<String>();
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) {
arguments.add("logins"); arguments.add("playerKills");
arguments.add("deaths"); arguments.add("mobKills");
} else if (args.length == 1) {
arguments.add("test");
}
List<String> result = new ArrayList<String>();
if (args.length == 1) {
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
result.add(a);
}
}
return result;
}
return null;
}
}
You are returning null
Or result
oooh you're right
On paper
but it doesn't do that
Set<String> modules = this.plugin.getEnchantmentRegistry().getNames();
List<String> suggestions = new ArrayList<>();
StringUtil.copyPartialMatches(args[0], modules, suggestions);
return suggestions;
}
return Collections.emptyList();
what is this StringUtil.copyPartialMatches(args[0], modules, suggestions);
hell what is this: Set<String> modules = this.plugin.getEnchantmentRegistry().getNames();
hmm
Set<String> modules = this.plugin.getEnchantmentRegistry().getNames(); you can ignore that
ok then
and this?
copyPartialMatches is a convenience method for copying, well, partial matches
I definitely know what that means
Which will filter your tab complete to strings that match what the user has already typed in
so use that instead
If the user has already typed in fals you don't want to be still suggesting true
ok?
so replace this:
List<String> result = new ArrayList<String>();
if (args.length == 1) {
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
result.add(a);
}
}
return result;
}
with that
(minus the first line)
(I think)
I'm just doing this all in discord, but I imagine any one of the people here will correct me on this if something is off...
But going back to basics a tad bit
List<String> arguments = new ArrayList<>();
if(args.length == 1) {
arguments.add("logins");
arguments.add("playerKills");
arguments.add("deaths");
arguments.add("mobKills");
} else if(args.length == 2) {
for(Player player : Bukkit.getOnlinePlayers()) {
arguments.add(player.getName().toLowerCase());
}
}
return StringUtil.copyPartialMatches(args[args.length-1], arguments, new ArrayList<>());
what is this... for(Player player : Bukkit.getOnlinePlayers())
copyPartialMatches is weird and modifies the passed in array
It does not return anything
reminds me of cpp bullshit
But also modifies the one you pass in, weird
"collection" argument is just a Collection that it'll add the results to
Woo 1 less line of code, get ready for some performance
I mean it could just create the collection itself
Yeah, but I can imagine a reason for passing an existing array in
I guess if you want to have some options always show up it may be useful
^
if (args.length == 2) {
Set<String> modules = this.plugin.getEnchantmentRegistry().getNames();
return StringUtil.copyPartialMatches(args[0], modules, new ArrayList<>());
}
return Collections.emptyList();
}
how can I make clickable/hoverable chat messages?
TextComponent acc = new TextComponent("[ACCEPT]");
this piece of code gave me this error in the IDE
'TextComponent(java.lang.String)' is not public in 'java.awt.TextComponent'. Cannot be accessed from outside package
Wrong import
Look for net.md_5.bungee.api.chat
List<String> arguments = new ArrayList<>(); //I understand this
if(args.length == 1) { // <command> <args 1> <args 2> I'm going to assume that "args.length == 1" means that the user as gone to <args 1>
arguments.add("logins");
arguments.add("playerKills");
arguments.add("deaths");
arguments.add("mobKills");
} else if(args.length == 2) {
for(Player player : Bukkit.getOnlinePlayers()) { //I did not know that for loops did this.. whatever that is?
arguments.add(player.getName().toLowerCase());//this just makes the second argument the playername of ther user... I think?
}
}
return StringUtil.copyPartialMatches(args[args.length-1], arguments, new ArrayList<>()); // I have no idea what this does what the hell why is there args.length-1
correct me if I'm wrong
You are not, really.
if(args.length == 1 ) is
If the last argument they are working on is the first argument
dafuq
So with this:
shooter.launchProjectile(Arrow.class);
How could I launch a TippedArrow with specific potiondata etc
The for loop is called a "foreach"
launchProjectile, I believe, returns a projectile instance you can modify. You will also want to use TippedArrow(or whatever is the nondeprecated version of that is)
someone really needs to make two help channels
yeahh TippedArrow is deprecated, what replaced it?
It's looping through all the players and adding their names to the arguments
I imagine you'd want that
and finally
tipped status depends only on base potion type not being UNCRAFTABLE and effects being empty.
return StringUtil.copyPartialMatches(args[args.length-1], arguments, new ArrayList<>());
Looks like tipped arrows are technically normal arrows
args is an array.
oh yeah sorry, I should mention that I'm basically trying to recreate the vanilla commands argument for argument
that example is just some tutorial I found
array[array.length-1]
Since launchProjectile doesn't have a callback option, you will have to modify the arrow right after you launch it
actually, is there a better way to do this?
than what I'm doing rn
which is just going through every single command
.-.
oof that's a no?
This entire thing has been a giant xy problem
lol
Why override the default commands argument for argument?
soorrry
ok
here's the entire project I'm working on
I'm trying to add variables to minecraft commands
the best way, in my mind, to do that is something like the following:
give @s $(variable_name) 64
replace the $(variable_name) with whatever "variable_name" is set to
I would first send it to my own parser, do that replace stuff, and then send it to brigadier parser
so, I have /varm give @s $(variable_name) 64
varm being the plugin command
so that is why I need to recreate the entire autocomplete menu
and I feel like there MUST be a better way
how would one do that (abstractly, I'm to tired to actually read through code)
I have no idea what that means so we're just gonna go with the manual option
wait wouldn't I need a ```java
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
Not necessarily
calculate the material keys once
Re-use the set
private static final List<String> ITEM_KEYS = Arrays.stream(Material.values()).filter(Material::isItem).map(m -> m.getKey().toString()).collect(Collectors.toList());
// in the tab complete
StringUtil.copyPartialMatches(args[0], ITEM_KEYS, new ArrayList<>());```
List. No purpose in using a Set because the elements are all being iterated in copyPartialMatches(). No contains() operations being performed
wait so does this work?
package me.theeyeofthepotato.stats;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
public class StatTab implements TabCompleter {
List<String> arguments = new ArrayList<String>();
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(args.length == 1) {
arguments.add("logins");
arguments.add("playerKills");
arguments.add("deaths");
arguments.add("mobKills");
} else if(args.length == 2) {
for(Player player : Bukkit.getOnlinePlayers()) {
arguments.add(player.getName().toLowerCase());
}
}
return StringUtil.copyPartialMatches(args[args.length-1], arguments, new ArrayList<>());
}
}
You'll be in for a rude awakening
When every time a tab complete is made
more and more strings appear in the list
Since the list is an instance variable and allows duplicates that will add more entries to it each time
Populate the list in the constructor, or move the list into the method
Or clear it at the beginning of the method
I have no idea what that means
ok that I think I get
Move the arguments list declaration above the if(args.length == 1)
what is the arguments declaration
List<String> arguments = new ArrayList<String>();
it is above
Move it below the
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
and above the if(args.length == 1) {
Is there a way to get ItemMeta of a landed projectile on projectile hit event?
package me.theeyeofthepotato.stats;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
public class StatTab implements TabCompleter {
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
List<String> arguments = new ArrayList<String>();
if(args.length == 1) {
arguments.add("logins");
arguments.add("playerKills");
arguments.add("deaths");
arguments.add("mobKills");
} else if(args.length == 2) {
for(Player player : Bukkit.getOnlinePlayers()) {
arguments.add(player.getName().toLowerCase());
}
}
return StringUtil.copyPartialMatches(args[args.length-1], arguments, new ArrayList<>());
}
}
that's code 2.0 (or more like 200.0 but whatevr)
so that will work?
ProjectileHitEvent#getEntity will return the projectile.
If you know what type of projectile it is, you can cast that.
e.g. (Arrrow) e.getEntity()
It isn't
But you can at least get stuff like potiondata, color, and whatnot
and, I suppose, recreate it lol
If you want to get super fancy, you can make use of Metadata to store the ItemStack on any fired projectile
Can then just fetch it from the Metadata when picked up
I guess that can solve the issue xD
I was thinking Metadata or an array of uuids
Ehm, sure. If that's what you need
I just need to make it so when my special arrow lands, it does something
which is defined in its object class
In which case I'd opt for a Set<UUID> or a Map<UUID, YourObject>
Pdc tag could be nice
Will presist restarts, which is nice
I'd personally keep metadata, as it's less cleanup.
yeahh, ill have to figure out how to use metadata for that
Metadata really isn't meant as a data store though
What would you need to clean up
It's meant to share data with other plugins without actually having to depend on it
Arrows don’t tend to stick around
That's the point
(e.g. VanishNoPacket has a vanish metadata on players :D)
I just need it to last for the duration the arrow is in flight
skeleton.setMaxHealth(skeletonHealth);```
after i added these lines, my plugin started misbehaving helpp
Metadata and a set will last the duration unless there is a restart
Arrows will yeet out of existence... and same with their metadata
If you use an array, map, or set... You'll be listening to despawning and a bit more to keep your map clean
True
can someone help me here
PersistentDataContainer?
Yes
my vex was spawning after Skeleton died, but after i changed the skeleton's max health to config's value
pdc is so useful lol
vex stopped spawning
i think im just gonna use a set of uuids
whats the diff between a list and set..?
i always use lists
That’s almost certainly not the cause
whenever I try to make a set of my custom object it makes me implement all its functions..?
nah it was working fine
until i added those line
Well, does removing them fix it
yes
Display-Name: "&cSaviour"
Max-Health: "300"
Messages:
Attack-Block: "§c§lYour attack was blocked!"
Punched-Player: "§4§lYou were punched into the air!"```
i have Max-health in config as String ig
thats why not working?
yes it works
but the hit damage is same
skeleton gets killed in 10 shots in 300 max health
also
skeleton gets killed in 10 shots in 1000 max health
how do i fix it
You need to set the health as well
Set it to whatever the max health is
ok so I'm trying to make a tab complete thingy
well, more specifically, I'm trying to recreate the minecraft syntax tab complete
don't ask why
is there a way to modify the duration of how long a particle is displayed for using only the spigot api?
hang on
?paste
get rid of that
why?
because if 1416 people posted this every time they want someone to take a look at their code this room would be unreadable
so how do you propose I ask said question
direct your eyes to the command I ran 2 seconds before saying what I said
seeing is believing
ok
so
I'm trying to make a tab complete thingy
well, more specifically, I'm trying to recreate the minecraft syntax tab complete
don't ask why
here is my code https://paste.md-5.net/xujiminuge.js
now, at line 107
are you aware that a bunch of frameworks exist that do this for you?
I
am very new to java
so you're gonna have to explain to me what a framework is
because I have no idea
https://www.spigotmc.org/threads/cloud-command-framework.467183/ here I went back in time to october 2020, hjacked into intellectualsites' spigot account and wrote a full breakdown of a system that does exactly what you probably want to do in the first place
how do i use color codes in wither's boss bar
i set withers name &cYouDad
works fine
same way you'd use them elsewhere
which is not &c
ye ok
no
i am trying to change from config.yml
directly
wither.setCustomName(withername);```
&c is already parsed, §c is the actual value used internally
u gotta use ChatColor.translateAlternateColorCodes
same as for any other color code
you can also hardcode it by using the color or chatcolor class
it's one of the two
ChatColor
ok I do not understand any of this
wither.setCustomName(ChatColor.translateAlternateColorCodes('&', withername));```
hope this will work
what exactly does it do
ignore the big words and just look at the function
which function
how it functions
bruhhh..
in the features section?
and how you write the code for it
are they even the same entity type after hitting?
I doubt it
*onGround
so does that mean I can untag them and give them a new velocity even after they get stuck?
No, inGround
really?
Yes
Also I just realized saying NBT tag is like saying ATM machine
they turn into abstract arrows..
this is dumb af bro
im trying to see if the arrow i pick up's UUID is in my list
I added the uuid of the arrow to the list when it fires
then it changes
That doesn’t make any sense
exactly idk why they coded it that way.
Anyway, why are you looking for the uuid when you pick it up
custom arrows
So you want to get the proper item back
Correct.
arrows don't change UUID
idk bout that one chief...
There are two arrows on teh floor when you pick it up
then you have two UUIDs
and they're both added to the list.
but i found another way
3 actually
UUIDs do not change, end of. Thats the point of a UUID
ok lol
How can I send a link to a user?
I think minecraft automatically makes links clickable
Look at the Events section https://www.spigotmc.org/wiki/the-chat-component-api/
Right now I'm doing: TextComponent message = new TextComponent( "Click me" ); message.setClickEvent( new ClickEvent( ClickEvent.Action.OPEN_URL, "https://localhost:3000" ) ); Bukkit.getPlayer(id).spigot().sendMessage(message);
But this doesn't seem to work
I'm not getting the message
are you getting the correct player?
public Optional<CustomArrow> getCustomArrow(ArrowType arrowType) {
return getCustomArrowList().stream().filter(customArrow -> customArrow.getArrowType().equals(arrowType)).findFirst();
}
Optional<CustomArrow> customArrow = archery.getCustomArrowManager().getCustomArrow(arrowType);
customArrow.ifPresent(arrow -> arrow.performLand(shooter, landedArrow));
First time using streams, is this the proper way to do it? (code works fine)
Basically finding the first CustomArrow in my CustomArrowList that has the ArrowType equal to the ArrowType of the item that lands
then performing the landing code on it
Yes
im having a weird ass issue rn, might require screenshare or something
theres very clearly 3 arrows there right
pick them up and it gives me 2.
wait..it seems to just be a bug while in creative..? wot
Delay between searching and checking world entities
is this a good optimization ?
How could I make it so my potion data effects don't apply potions to the hit targets?
remove it when it hits 🙂
but..
I mean I guess I could but
anyone know of a really good per-player scoreboard tutorial video..?
Is there any way to set up a listener to a mySQL database in spiggot? I want something to run when a value in my db is updated. Thoughts?
I don't understand why you would want to do that lol (are you using the effects for the color?)
Yes
oohh that makes sense
https://i.gyazo.com/f1b3238de1982aea0838d27475da8db2.png green is multishot, orange is explosive, etc
thats cool
tyty
now just gotta make a scoreboard system to keep track of the player's points
AbstractArrow.setColor(Color.GREEN) etc
just don't set it to null
isn't full rgb 1.14+?
1.16.5+
Rgb chat is 1.16
oh
But this isn’t chat
Idk how it's in potions, but chat 1.16
omg i just thought rgb arrow that cycles thru colors
I think potions too
Unlucky
Could add it to the enchantment plugin I guess
BROOO IT CHANGES THE TRAIL COLOR TOO
epic
bump!
;)
Any way to clear someone's E chest?
wait
i think you can just
uhhh
use resource pack
the problem is that now everyone has to accept a resource pacjk
and some people might not want to
I'm trying to hook into the vault api. I have essentialsx and vault installed on my server.(they're both also set as soft dependencies for my plugin). However, essentials doesnt seem to be registering an economy provider.
Does anyone know what could be going wrong?
Ok have u made sure ur running the code provided by vault in ur plugin?
Are u running a compatible version?
But It does everything
U may want to copy the tutorail
Only the getregsitration(economy.class) returns null
Versioon of what?
Can u send the code where this is
It's all the latest
Ok
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}
public static Economy getEconomy() {
return econ;
}```
Copy it & paste it down below the lisners
How would I go about giving an item a description/title with coloring?
Thanks
Specifically an "Item Stack"
Google your question before asking it:
https://www.google.com/
public class DepositHandler {
private static RegisteredServiceProvider<?> service = null;
public static boolean depositPlayer(Player player) {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
return true;
} else if (!Bukkit.getPluginManager().getPlugin("Vault").isEnabled()) {
return true;
} else if (!Main.getPlugin().getClanConfiguration().isVaultEnabled()) {
return true;
} else {
if (service == null) {
service = Bukkit.getServicesManager().getRegistration(Economy.class);
}
if (service == null) {
return true;
} else {
Economy economy = (Economy)service.getProvider();
//Rest
Wait ugh
Weird on phone
You can use
ChatColor.YOURCOLOR + "your text"
For a item
Meta?
Ok i only use it for chat
That's what I was looking for thanks
@pine island do you see anything off?
The code is not formated also my debugging is bad so no
Hm
Send code?
Hm
All I have to do to get essentials x to register the provider is install it on the server right?
Currently v2.19.0
Yeah could be i dont have tho code so a wild guess is all
Kay thanks
It dont
flip it around maybe?
Nope
hm
ChatColor.BOLD + "" + ChatColor.BLUE + "Your message here"
because java is dumb like that
I'll see if that works
wrong order
and if that doesn't work theres always ChatColor.translateAlternateColorCodes
no it is minecraft not java
or maybe the bukkit itself 😭
no java can only handle one non-string object in a string before it has to translate the other into a string via toString() iirc
Yeah java has some flaws
Altho they should have been fixed by now but whatever its easier than python & is stackable
i heard someone said mc so idk
but uhhh java dumb
ItemMeta swordMeta = sword.getItemMeta();
swordMeta.setDisplayName(ChatColor.WHITE + "" + ChatColor.UNDERLINE + "Nike:" + ChatColor.RED + " Zombie Quest");
List<String> zList = new ArrayList<String>();
zList.add("\nThis quest will " +
"require you to " + ChatColor.RED + "fight 10 zombies " + "\nin order to get" +
ChatColor.GOLD + " 100 CartCash");
swordMeta.setLore(zList);
sword.setItemMeta(swordMeta);``` For some reason, my sword itemstack is showing no lore in game. Thoughts?
Any help?
has to implement CommandExecutor
So alt enter would fix it?
has to implement CommandExecutor
oh you fixed it lol
getCommand("SelfDP").setExecutor((CommandExecutor) new SelfDP()); so this?
e.g. java public class SelfDP implements CommandExecutor { ... your code here ... }
No
This
Your class SelfDP has tp implement CommandExecutor
Oh yeah shit i forgot
If you want tab completion processed in the same class, implement TabCompleter as well (separate them with a comma) and use public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { ... } for that. Make sure to register it as the tab completer for the command as well
Hmm ok!
quick question, hopefully I'm not interrupting,
how do I add an option for a player to use a command on other players?
This is my code rn
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equals("sharkheal"));
if (sender instanceof Player) {
Player player = (Player) sender;
if (player.hasPermission("shark.heal"));
player.setHealth(20.0);
player.setFoodLevel(20);
} else {
System.out.println("You cannot use this command through Console!");
sender.sendMessage(ChatColor.RED + "You are lacking the permission " + ChatColor.GRAY + "shark.heal");
}
return false;
}
}
So how would I do something like /sharkheal {otherPlayer}, and add the permission shark.heal.others to it for example?
check arguments and permissions as necessary
Ok
get the {otherplayer} arg then use bukkit.getPlayer or whatever to get the player as a CraftPlayer then use it as player instead of the sender
hey, I looked in all spigot (not spigot api) jars and I idn't found one with the deobfusced nms (without a, b, c) I used the remapped arg with the buildtool so can you help me?
Player player = Bukkit.getPlayer(args[0])
}
What version of spigot
1.17.1
e.g.java if (args.length > 0) { if (sender.hasPermission("shark.heal.others")) { Player target = Bukkit.getPlayer(args[0]); if (target != null) { // do your stuff to the player here } else { // player could not be found, alert player } } else { // tell the user they don't have permission? } }
Did you add the special source plugin to your pom?
Thank you all! 😄
oh yes I missed that I have overwritten my pom and didn't added it back
speaking of specialsource mine isn't working :/
Failure to find org.spigotmc:spigot:jar:remapped-mojang:1.17.1-R0.1-SNAPSHOT in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are forced
nah idk why but on 1.16.5 i can use tab completer by implement tabcompleter in the same class without register tab completer.
Did you run BuildTools?
maybe i will need to register it if it is different class
ye
getCommand("ClearEco").setExecutor(new ClearEco());
getCommand("SelfDP").setExecutor(new SelfDP());```
Command Dosnt show up in mc even tho its registered
*Code:*
package me.lumina.hardcorepurge.commands;
import me.lumina.hardcorepurge.HardcorePurge;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SelfDP implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args ){
if (cmd.getName().equalsIgnoreCase("SelfDP")){
if (args.length == 1) {
Economy economy = HardcorePurge.getEconomy();
Player player = Bukkit.getPlayer(args[0]);
economy.depositPlayer(player.getName(), 1000000);
sender.sendMessage(ChatColor.RED + "Proudly created EasterEgg/Exploit/Bully By LuminaEXE");
}
}
return true;
}
}
PLEASE
oh ok
Hmm, maybe Bukkit registers the tabcompleter by default if the class implements it when you set it as the executor
good...
Yeah lol messed up
yeah nothing too weird to understand
Could you send your pom?
ok one sec
ok
which parts broken
i accidentally deleted the classifier in this file but in the real file the classifier for spigot is there
Personal preference, but I generally recommend doing if (args.length > 0) { ... } or if (args.length >= 1) { ... } instead of if (args.length == 1) { ... } (unless handling multiple argument lengths and you specifically need it to have only 1 argument), since if a user enters /command john doe, that's two arguments, so now it won't run that code for targeting another player.
Hm looks okay then
Yeah ik but looks better for me
Why doesnt the plugin show up?
..
it's this one right? xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>attach-sources</id> <phase>verify</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin>
No
Read developer notes
my build worked but vs code still give me errors
Try using an IDE like Intellij or Eclipse
vscode is good for plugins as well
yes I do that normaly but I like the vs code graphics so rip vscode
just get java addons
I already have a lot of java extansion xd
I got these from the start of my plugin
"I like the vscode graphics" https://plugins.jetbrains.com/plugin/11938-one-dark-theme
(also how come setting up run configs is so much weirder in VSCode?)
Eclipse is terrible.
and I got the same error from vs code to eclipse
are you suggesting that IDEA gives different errors? lmao
What is the difference between Bukkit#getOfflinePlayer and Bukkit#getPlayer? Which one should I use?
One gets a offline player and the other one gets an online player
Use the one you need
and the online player can be an offline player but an offline is not always an online player
yes
we can basically use get offline player to get a player in both status: online and offline right
Yes
the colors work perfectly for what i want
is it possible to create a command block ItemStack with a command already in it?
nbt tags
default minecraft already have that
how do i set nbt tags btw
ah wait nvm ill just google it
thanks
another ez question, if a player isnt specified, how can I stop Java from going through?
This is my current code, but it doesn't work
if (args.length == 1) {
player.sendMessage(ChatColor.RED+"Please Specify a player");
return;
}
Player target = Bukkit.getPlayer(args[1]);
If args length is not 1 it will reach the target variable.
What lib do you guys recommend for websockets
And do I need it on a separate thread
resolved, thx btw
I have a variable target, how can I make it a Player variable if a given player is online or a OfflinePlayer variable if a given player is offline?
Get OfflinePlayer then check isOnline
are plugins generally more performant than command blocks?
they can be yes, but sometimes no
There are a lot of stupid plugins out there
hey it's me again, this wasn't some false errors, when I tryed to see what was the compiled code and in reality it replaced my nms code by an error saying that he didn't found all the classes so how can I do?
Using the eclipse compiler?
Yes. In almost all cases.
Well... it depends. There are a ton of horribly written plugins out there.
like I wanted to don't use the obfusced mappings but the mojang ones, but I needed to change mappings when I compile it to use it in a spigot server I need to change the mappings to the obf ones so I put a plugin to remap all of that (clearly not ctrl+c ctrl+v) and it don't work
so I saw in my decompiler this :
Use recaf
...who the fuck throws Error?
is that a custom type or literally java.lang.Error?
java.lang.Error
Its his decompiler
nop the compiler
I don't see how a decompiler could do that
especially when it's easier to make that work than not
like maven did some weird things
considering exception tables specifically state their exception type in bytecode actually this is in regards to try/catch, but it still holds up since throwing is a new then an athrow
so legit
for some fucking reason, someone is throwing Error
(ftr, Exception or RuntimeException are better)
say that to maven xd
(Error represents a RuntimeException that should not be caught, e.g. with a try/catch)
(it's mainly used to handle errors on the JVM's side, e.g. OutOfMemoryError)
the base code look like that
(self-explanatory name btw)
if you want advanced shit u might want to check out netty
io.netty
its also what minecraft uses
Either use java.net or Netty.
whats the "ding" sound that everyone use ?
xp pickup probably
I once implemented a webserver with just java.net lol.
i do kinda want it to not be so complicated however
i used java's HttpServer
There are several. Exp orb, Bell or Noteblock pling. All available in different pitches.
to make a webserver
ill check out netty
Well I implemented mine by scratch.
nice
Just use Spring or Quarkus. Literally 3 lines and you have a web socket, rest endpoint or http server.
well Spring is an entire framework, is it not?
case HEAD:
case PUT:
case DELETE:
case CONNECT:
case OPTIONS:
case TRACE:
case PATCH:
``` what there are more http requests than just `GET` and `POST`?
Yes.
Quarkus example:
@ServerEndpoint("/chat/{username}")
@ApplicationScoped
public class ChatSocket {
@OnOpen
public void onOpen(Session session, @PathParam("username") String username) {
}
@OnClose
public void onClose(Session session, @PathParam("username") String username) {
}
@OnError
public void onError(Session session, @PathParam("username") String username, Throwable throwable) {
}
@OnMessage
public void onMessage(String message, @PathParam("username") String username) {
}
}
u can't use spring in mc if that's what u want
But most of them are really unused lol.
i kinda want a websocket i can keep alive and send and receive messages thats pretty much it
You might just want java.net then.
put and delete are used mostly in good rest apis
oh
I think HEAD is also an efficiency thing.
You can encapsulate your Spring application and start a new jvm instance that runs it.
basically it just describes its deleting or updating something on the server
but idk.
i use head for uptime checking on something
That's a terrible idea tho.
That requires having multiple JVM instances open.
Then you might just want a simple ServerSocket from java.
yeah and you can run a Minecraft server using python
doesn't mean u should
im confused about all this
mc server opens the socket to the server and keeps it alive and sends and receives messages
as long as the server has the full minecraft protocol you can make a minecraft server in any language
websockets not just sockets
server yeah
that's what I said :)
client too
totally :)
._.
As long as you properly implement the protocol
wouldn't be too hard
you're looking at a binary professional
- Maow, someone who is terrible at visualizing bitwise operators.
ok java.net.http.websocket looks good ty
the full protocol description
There is for example a nodejs app that implements the protocol so you can have virtual clients or "bots". Its called PrismarineJS
be weary, that only exists on Java 11+
And you could just implement both server or client in lets say C++ if you really wanted to.
epic Minecraft moment
I
I kinda wanna implement a Minecraft server in Rust now.
lol.
but i like Java
I'd probably fall flat on my face immediately though.
there are like 100+ packets
I'm like... barely alright at Rust, I just learned how to do idiomatic error-handling or whatever.
and you would have to implement the logic too
oh god
macros to the rescue
entity processing