#help-development
1 messages · Page 1716 of 1
Great :)
if (args.length >= 3) {
if (args[0].equalsIgnoreCase("addline")) {
StringBuilder builder = new StringBuilder();
for (int i = 2; i < args.length; i++) {
builder.append(args[i]).append(" ");
}
Utils.addLine(args[1], builder.toString().trim());
player.sendMessage(Utils.translate("added line &e" + builder.toString().trim() + " &ato &2" + args[1]));
return true;
}
}
i want to know what is wrong with this that if i put multiple arguments, nothing happens at all
working
not working
no output and error
Is there anywhere a list of ALL NMS classes?
In the server jar
Ok, not anywhere else?
Not that I know of
Ok
I am creating an enum of all classes, that's why. I can easily copy it from WinRar
are you sure that that is necessary / a good idea?
Yes
"Making an enum of a list of classes" is certainly in the bucket of "definitely not a good idea"
It are just 3860 classes
Bigger than the material enum
Yes I know
Whats the point of doing that?
You can access NMS classes without reflections
Yes, but to also allow multiple version support, including 1.17
just write it in krakatau assembly, no reflections needed
What is that?
What is krakatau assembly?
Reassembler/Disassembler for java bytecode
Are you going to put the name and package declaration of each class for each version in the enum or something
Yes
How is this better than modules
Checking if the class exists in the version, putting it in the enum with supported after the version
Just sounds 10x harder to maintain than modules
Ok then tell me what you would do
How would the index of the slots of a crafting table work?
Would it work like this:
I am open for everything
Starts at 0, but it is any further correct
I would use modules
An example?
Ok will look
even if you have a list of classes ... you'd still end up having to write version dependent code. things get moved, change names, use different args, etc.
Just a quick mock up:
@RequiredArgsConstructor
public enum NMSAccess {
ENTITY_HUMAN("net.minecraft.world.entity.player.EntityHuman");
private final String className;
private Class<?> cachedClass;
private List<Method> cachedMethods;
public Class<?> getNMSClass() {
return this.cachedClass == null ? this.loadClass() : this.cachedClass;
}
private Class<?> loadClass() {
try {
this.cachedClass = Class.forName(this.className);
} catch (final ClassNotFoundException e) {
e.printStackTrace();
}
return this.cachedClass;
}
public List<Method> getMethods() {
return this.cachedMethods == null ? this.loadMethods() : this.cachedMethods;
}
private List<Method> loadMethods() {
this.cachedMethods = Arrays.asList(this.getNMSClass().getMethods());
return this.cachedMethods;
}
}
This could actually be handy.
Looks good
But you still need versioning on this. So maybe a Map<Version, String> for the class name.
Ok good idea thanks
Guess it isn’t too bad
If you only include classes you care about
Still gotta get the method you want out of that list tho
Ok
how can i make a clickable text where i can only click on a part of the text? now i can click on the whole line
i have this now
public static void suggestCommandByClickableText(Player player, String begin, String clickableText, String end, String command) {
messageSpigot(player, new ComponentBuilder()
.append(colorize(begin))
.append(suggestCommandByClickableText(clickableText, command))
.reset()
.append(colorize(end))
.create());
}
public static TextComponent suggestCommandByClickableText(String message, String command) {
TextComponent textComponent = new TextComponent(colorize(message));
textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to run command")));
return textComponent;
}
Yeah this needs a lot of refinement. Maybe a Map<String, Method> and a Map<Class<?>, List<Method>> for return types and so on.
Still gotta worry about method args changing
This just looks like a bootleg adventure
Or the method names changing
Oh wait its using componentbuilder m,b
I wish components themselves used a builder pattern
i thought appenLegacy(string) would remove the clickevent from that string but it doesnt work
It would be nice to just be able to .append(new TextComponent(“blah”).color().bold()...)
probably nms would work but that goes brr
how can i call my custom item
for example all items have names like STONE or GRASS
so i want my item to have a name something like SHARP_SIX_BOOK
Material name?
yeah
Yiu can't change material name
no, i like have a custom itemstack
and i want it to have its own id or something
so i have this custom craftable itemstack
and i want it to have its own id
so you want to be able to use something llike Material.YOUR_CUSTOM_ITEM ?
yeah
Im getting this error when typing a command to open a crafting table inventory
https://paste.md-5.net/potofimuma.bash
This is my code for it
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("craftingtable")) {
if (sender instanceof Player) {
Player player = (Player) sender;
Inventory craftingInterface = Bukkit.createInventory(player, InventoryType.CRAFTING, "Crafting");
player.openInventory(craftingInterface);
}
else if (!(sender instanceof Player)){
System.out.println("Error! You cannot use this command.");
}
}
return true;
}
you can't create custom items like that using plugins. you'd need a mod for that. plugins are limited to whatever blocks and items are present in vanilla MC. You could set an NBT tag to your custom id though
alright
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryType.html
The current list of inventories that cannot be created via Bukkit.createInventory(org.bukkit.inventory.InventoryHolder, org.bukkit.event.inventory.InventoryType) are:
CREATIVE, CRAFTING and MERCHANT
damn
If you just want to open the crafting interface for a player, you can use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/HumanEntity.html#openWorkbench(org.bukkit.Location,boolean)
declaration: package: org.bukkit.entity, interface: HumanEntity
help, my plugin has this problem of not increasing the enchants
https://gist.github.com/83ce015da3dc597ac897668cbac0fb5e code of the anvil event
None of the code actually does anything to increase the enchantment level
it really just copies the enchantments
so no wonder that it does not increase the level
the fix is to write code that increases the level of the enchantment?
that is what i thought
it's like setting the result equal to 1 and wondering why it's not adding another 1; you actually have to do the thing that you want it to do
It is so
With the onTabComplete method, how would I make it only tab complete one argument. My command has two arguments, the first one is a player, and the second one is an integer.
makes the URL look closer to regular English via removing the .com
obviously you can't just do tryitandsee so they have to use the Estonian TLD, .ee
^
the entire arguments string[] is passed, you can check for length and do whatever
this should be easy but I did ```java
if (args[].getLength == 0) {
}
but getLength isn't a method
so how would I check for length?
args.length
I have a simple tabcomplete
@Override
protected List<String> tabComplete(@NotNull String[] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], Arrays.asList("help", "accept", "request", "decline"), new ArrayList<>());
}
return null;
}
btw this method is called by onTabComplete(...)
org.bukkit.util.StringUtil
so you can just check
args.length == 0
return players // returning null means the default playerlist
args.length == 1
return integer
lol
I was being dumb
I did args[].length not args.length lol
What do I return so there are no tab complete options?
@tardy delta
you mean nothing or just the server tablist (the player names)?
nothing is new ArrayList<>()
player names is null
it is possible that bukkit takes the wrong class to deserialize objects in yml?
i even dont have a ConfigurationSerialization.registerClass(Home.class) in my code
return null for no tab complete options
no
You have to register the class before you attempt to deserialize anythign using it
returning null gives the default playerlist tab complete options lol
guess I didn't understand what fourteen said
this is my code java List<String> onlinePlayers = new ArrayList<>(); for (Player player: Bukkit.getOnlinePlayers()) { onlinePlayers.add(player.getName().toLowerCase()); } if (args.length == 0) { return onlinePlayers; } else { return new ArrayList<>(); } and now no tab complete options are showing up.
So if you type no args you will get all players. If you type any args you get none.
but they start at 0
what start at 0?
lists and arrays
this works java onlinePlayers.contains(args[0].toLowerCase()
whatever, I will try args.length == 1
ooooh
args[1] is the second arg
moment of realization
(args.length == 0) means empty, nothing in it, no args
List<String> onlinePlayers = new ArrayList<>();
List<String> matches = new ArrayList<>();
StringUtil.copyPartialMatches(arg[0], onlinePlayers, matches);```
That will only show players who contain what you are typing
well, make the onlinePlayers as you do
That'll show nothing since onlinePlayers is an empty ArrayList. Gotta populate it with names. Also the issue of case sensitivity, unless StringUtils.copyPartialMatches is case insensitive
of course, if you had followed the conversation he actually builds a List of lowercase player names
This should do it all in one command java List<String> matches = Bukkit.getOnlinePlayers().stream().map(player -> {if (player.getName().toLowerCase().contains(args[0].toLowerCase())) return player.getName();}).collect(Collectors.toList());
You will have to switch from using spigot-api to use spigot in your pom to gain access to StringUtil
But don;t use that unless you go through it and understand it
Command atocomplete
public List<String> getMatchingPlayers(final String input) {
final Pattern ignoreCase = Pattern.compile(Pattern.quote(input), Pattern.CASE_INSENSITIVE);
return Bukkit.getOnlinePlayers().stream()
.map(Player::getName)
.filter(name -> ignoreCase.matcher(name).find())
.toList();
}
😄
hey, I'm using some file systems to delete the world folder and replace it with a different world folder, it copies the files fine, but when I go on the server it still has all the old world, but restarting the server kicks the changes into effect. Is there any way I can make it do it by itself? I use this.plugin.getServer().unloadWorld("world", false); to unload it and Bukkit.createWorld(new WorldCreator("world")); to load it which I'd expect makes it work but it doesnt
much better
After calling unloadWorld() the world is not completely unloaded right away
Can someone look to #help-server
Be patient
I looked, your question makes no sense
well after I unload it, I delete the world folder and make a new one, is that not enough time for it to unload? Is there a way to wait for it to unload or just add a delay of a few seconds?
There is a hacky way if you want to delete the world folder.
Btw do you try to unload the main world of the server?
yes, I do this.plugin.getServer().unloadWorld("world", false);, delete the world folder, clone a world_TEMPLATE folder and name it world then load it again
Can only be done in your onLoad method of your plugin during startup.
You cant unload the main world while the server is running
before the world is loaded
I'm trying to make a mini-game world (there are multiple worlds, its running bungee), i just want to be able to reset the world to how it was before another round starts, what's the best way to do that?
by not using the main world
One approach would to just use docker container
@zenith shard you could also just restart the server then?. itl take a bit longer but would work
I think you should throw everyone from the server that runs the minigame, delete the whole server folder and copy a new one in. Then just start the server again 😄
Oh jeah or just do your stuff in the onLoad method and restart the server...
Probably better
Is livingEntity.damage(20, player); ignoring armour? If no, how do I damage an entity and ignoring amour?
set health (math.max (0, currentHealth - damage) )
pseudo code
can I unload the main world in the onLoad method just using this.plugin.getServer().unloadWorld?
In the onLoad there is no world laoded
Okay. Should I do entity.damage(0, player) after that?
Because I still want that mobs get triggered
You might need to do some more stuff to make sure you handle events from other plugins
Yes. I already did.
But would that work?
livingEntity.setHealth(livingEntity.getHealth()-20);
livingEntity.damage(0, player);
NO, you can NEVER unload the main world. If you want to do anything with it you must do it before its loaded
I'm gonna unload the main world out of spite now
Sure. But you will bypass any plugin protection with this
BUT remember a reload will also fire onLoad and the worlds remain loaded
only a clean start has no worlds
Hm. You're right. I forgot.
You might need to do some more stuff to make sure you handle events from other plugins
yes...
^^
I think about it. Maybe I write back later
can I just delete world folder and replace it with new one (while the world is loaded and server is running), then restart the whole server?
Nope
no
when the server stops it will save
Bungee log pls
also @lost matrix now that i see you here, love your resources on spigot, very informative
Hm, i dont see anything odd
What does livingEntity.setLastDamage(); do?
It sets the damage event that was last applied
declaration: package: org.bukkit.entity, interface: LivingEntity
Thanks.
This is usefull.
Can I use it like that?:
livingEntity.damage(0, player);
livingEntity.setLastDamage(20);```
I have this code where it spawns an entity with a armorstand passenger holding a fishing rod with custommodeldata 1, but when i use a texture pack to retexture the fishing rod to a 3d model it only shows the same fishing rod in a different holding degree, when i give myself a custommodeldata 1 fishing rod the model works normally
public PassengerButterfly(Location loc) {
super(EntityTypes.c, ((CraftWorld)loc.getWorld()).getHandle());
this.setPosition(loc.getX(), loc.getY(), loc.getZ());
this.setMarker(true);
this.setInvisible(true);
ItemStack item = new ItemStack(Material.FISHING_ROD);
ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(1);
meta.setUnbreakable(true);
((LivingEntity)this.getBukkitEntity()).getEquipment().setItemInMainHand(new ItemStack(item));```
its nms btw
Looks like you forgot to set the itemmeta after editing it
ooh wait i see it
Also I don't see the point of using NMS here
so i add this right?
item.setItemMeta(meta);
Yeah
okay ty
gonna add custom pathfinding later
and some other things
to add nbt tags, but from ur question i think that its not needed
can I change the name of an inventory somehow?
👀 guys, anybody know how to use TranslatableComponent(BungeeChat) on the Sign?
you can set Inventory Name while opening Inventory:
Player#createInventory(foo,bar, ->your inventory title here<-);
how do u make an explosion of particles
like spawn them in a sphere around the player with their own directional movement
ik its probably an algorithm or smth but i cant find it
that's changing the name when creating, but not after having created it already
so maybe you can create another one...?
well i didn't and a I also don't want but for some reason i have that error when loading the file
of course you do, because you are not doing what you have been told
if you don;t register the class Bukkit does not know about it, so you get that error saying so
yes i registered it some weeks ago and then i removed it
do i need to unregister it?
but i don't want that serialisation anymore cause it's saved in another format now
then stop trying to get from the config using that class
i'm not even using that class anymore
the error says you are
i dunno most of the times it works and sometimes i get that error when trying to load the config
what is the EASIEST way to add ench glowing effect to item WITHOUT adding real ench or using nms?
lemme now just delete the file and try again
Choose one or the other
You can use nms to inject an empty ench tag value
Or you can add a random enchant and hide it with an item flag
he doesnt want that
And?
it would be the easiest way but yea
The options are as I listed
uhu
The spigot api does not have your best interest in mind
But no framework does really
just put smth that that object doesn't use on it gg ez
smh i'm only supposed to be able to click on the /home list
seems better like this
this doesnt seems to workhttps://paste.md-5.net/itakemugod.cpp
make a prefix component and a suffix, then the one you want to be clickable and do that
aight forgot something
https://paste.md-5.net/aveginadah.cpp
its been a while since ive done it but you need 3 different components for it
at least that's what I did
i have three now right?
.append()
.append()
.append()
ah it kinda works but now the clickable component and the last both have the hover event
what's even the difference between .append(string) and .appendLegacy(string)?
?jd-bcc
IntelliJ can't handle enums from more then 7500 lines 😄
oh fourteenrbrush probably legacy format string
like when it used to be just colorcodes
and not components
does anyone remember what's the argument to install paper repo to the maven
of paperclip
java -Dpaperclip.install=true -jar paperclip.jar
thanks ❤️
is it possible that i cant execute async stuff in onDisable?
is there a way to maek an explosion effect without it destroying anything or damaging people?
There is no need for async stuff in your onDisable anyways.
declaration: package: org.bukkit, interface: World
It depends if the server is being shut down or if its just reloading
You could also just spawn the particle and sound
when an item's meta gets updated while i have it in main hand, it bounces
is there a way to remove this item animation?
For example, is there another way to update the item meta in such a way that it doesn't have that effect on the user's end?
or is there a way to change that through datapack?
it was shutting down, anyways let me just do it async
What version?
sync*
1.17.1
wait how again lol i forget
but its not new to 1.17, it has always been like that
theres a tnt particle?
EXPLOSION_HUGE
EXPLOSION_LARGE
EXPLOSION_NORMAL
these are the explosion particles
Yellow
You mean this bounce?
i cant understand bukkit crafting api
in this example
how the item will look like
like the diamond sword recipe just with emeralds instead
Truncate it. Yours currently only works if the sword is build exactly in the middle
Exactly
and how something like
G = Gold
D = Diamond
S = Stick
E = Emerald
[G] [D] [G]
[E] [S] [E]
[G] [S] [G]
will look like
you do realize that you already formatted it the way it will look like in the crafting box?
"GDG", "ESE", "GSG"
But you should truncate empty columns and rows:
final ShapedRecipe recipe = new ShapedRecipe(key, result);
recipe.shape("E", "E", "S");
recipe.setIngredient('E', Material.EMERALD);
recipe.setIngredient('S', Material.STICK);
Bukkit.addRecipe(recipe);
final NamespacedKey key = new NamespacedKey(yourPluginInstance, "cool_sword");
ok
how can i make my Sidebar consistently update health
doesnt seem to work to remove the hover event
i tried .reset() but then the whole componentbuilder is resetted
wait what i guess .reset() works on the previous one
alright ty mate
Probably also PlayerJoinEvent
i have it on my join event already
how do i send a massage to all players that have a permission
yes
there's a method that actually checks for permission https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#broadcast(java.lang.String,java.lang.String)
if (P.haspermission(permission){ what dio i put here}
Have a clue if I can remove this bounce either by updating the item meta in another way or by adding some stuff in a data pack
execute the message part
It gets very annoying because some items are constantly updated, due to animation
No idea.
yea but what do i put
I fear that this bounce may be created by the client
I use an item display compiler that fetches the item packet and changes it for each player
wont this do exactly the same behind the scenes
Sure
having your own thingy allows for multiple checks
but if ur doing it just for a perm i guess thats the superior way yea
if (command.getName().equalsIgnoreCase("staff"))
if(P.hasPermission("ee.need.staff")){
P.sendMessage(Utilities.color(plugin.getConfig().getString("prefix") + "&3 the Request has been sent for help to a member of staff!"));
if(P.hasPermission("ee.staff")){
}
}
what
how would I take an argument from a command (a string) and make it the type of Player
Player player = Bukkit.getPlayer(args[]i)
where did the { go in the if (command.getName().equalsIgnoreCase("staff"))
then player != null // do something
already made sure the player is not null
in sendTitle() is the fadein/stay/fadeout in ticks or seconds
well there's your answer
ticks
as you can see here btw https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#sendTitle(java.lang.String,java.lang.String,int,int,int)
declaration: package: org.bukkit.entity, interface: Player
one simple search
I assume there is no bounce caused by the item update while in hand with this method right?
If so could I have a sample of how I could do it as well or links?
any ways i can remove a scoreboards' specific line?
https://www.youtube.com/watch?v=78sQ_naiSk0 cuz then this mess comes up
can i give access to the recipes to specific players ?
Only with a bit of trickery
and what is it
A Map<NamespacedKey, String> where the keys are the namespaces of that recipe and the value is the needed permission.
Then using the PrepareItemCraftEvent
@lost matrix Can you send me the util again?
(on the right scoreboard) i dont have much time. my sister wants to play mc with her friends. plz. i need solution, or i die
wait its getBedSpawnLocation lol
Player#getBedSpawnLocation()
if this is null then
Bukkit.getWorlds().get(0).getSpawnLocation()
so
ok ig im dying bye lol
you are doing it with a plugin ?
dont add lines. Just set a line.
declaration: package: org.bukkit.event.player, class: PlayerLoginEvent
setKickMessage
so
what should i do now
private final Map<NamespacedKey, String> recipePermissions = new HashMap<>();
@EventHandler
public void onPrepare(final PrepareItemCraftEvent event) {
final Recipe recipe = event.getRecipe();
if (!(recipe instanceof Keyed keyed)) {
return;
}
final NamespacedKey key = keyed.getKey();
final String permission = this.recipePermissions.get(key);
if (permission == null) {
return;
}
if (!event.getView().getPlayer().hasPermission(permission)) {
event.getInventory().setResult(null);
}
}
Wait what. There is setLine and addLine?
idk i dont use scoreboards
what is Keyed
the item ?
use netherboard api and shade or shadowJar it
Not all recipes have a NamespacedKey. The ones that do implement Keyed. If they implement Keyed then they are an instance of it and can be cast.
and im using java 8 not 16
Then you need to convert the syntax a bit and manually cast
and should i put anything to the hashmap ?
put key, "craft.sheesh"
If you want it to work.
sheeeeeeesh
Quick question- anyone know if it is possible to register a listener after the first tick?
you mean not registering it onEnable ?
You can register listeners whenever you want
and a tick after onEnable ?
yep, that answers it, thanks
is there no way to do this? how does it know which event has to go away?
nvm got it
just casting
how do I change nbts of my clientsided armorstand like making it invisible?
I use WrapperPlayServerSpawnEntity
Entity metadata
https://wiki.vg/Protocol#Entity_Metadata
Ive looked for that under the packet functions
is invisible is part of the base entity bitmask
If you use ProtocolLib then you need a wrapped data watcher
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity();
packet.setEntityID((int) (Math.random() * Integer.MAX_VALUE));
packet.setType(EntityType.ARMOR_STAND);
packet.setUniqueId(UUID.randomUUID());
``` a part of the code
Yep. Not sure if they abstract out the bitmask though. If not, all you need is 0x20
If you're using the packet wrapper lib, you also need to send the metadata packet https://github.com/dmulloy2/PacketWrapper/blob/master/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java
Looks like you'll want to add in the value new WrappedWatchableObject(0, 0x20)
Im a little confused do I need to use this instead of WrapperPlayServerSpawnEntity
it is, because if it wasn't, the first if would've succeeded
If the length is not 0 then its always bigger than 0
I cant understand anything from this (0, 0x20)
for example how will I make it both invisible and invulnerable
you should add the message lines inside private static const primitive array, since it would create the array every time it executes the command iirc
btw
@quaint mantle Emm Hello Dabsh
Chetori ?
Eh. The JIT will optimize it after first few executions anyways. Maybe even the compiler optimizes it right away.
i guess come to #general we will talk
Go
idk, i wouldnt trust it and just put it outside the method scope.
!paste
?paste
public class MeowCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("Meow")){
Player p = (Player)sender;
if (sender instanceof Player) {
p.sendMessage(ChatColor.RED + "Playing cat meowing sound");
p.playSound(p.getLocation(), Sound.ENTITY_CAT_BEG_FOR_FOOD, 2F, 1F);
return true;
}
}
return true;
}
}
``` i need help a bit here, idk what i did wrong but when i do the command /meow it doesnt make a sound and doesnt send the message "Playing cat meowing sound"
also says this as a warning
it's redundant because you check instance of after you've already casted it
this it would only reach that line if the cast succeeded, otherwise it would've already thrown an error
are you sure you've set this as the executor of the command?
Best way to store a integer per player?
Likely resolved
Maybe with PDC api?
Hello there. :)
Has somebody any experience with giving fake entities (ProtocolLib packets) a potion like invisibility?
This is what I have right now:
val packet: PacketContainer = protocolManager.createPacket(Play.Server.ENTITY_METADATA)
packet.modifier.writeDefaults()
packet.integers.write(0, entityId)
val dataWatcher = WrappedDataWatcher()
// This should add the invisibility, but seems to not do anything:
dataWatcher.setObject(0, Serializer().byteSerializer, (14.toByte()))
val optional: Optional<*> = Optional.of(WrappedChatComponent.fromText("testNPC").handle)
dataWatcher.setObject(
WrappedDataWatcher.WrappedDataWatcherObject(
2,
WrappedDataWatcher.Registry.getChatComponentSerializer(true)
),
optional
)
packet.watchableCollectionModifier.write(0, dataWatcher.watchableObjects)
protocolManager.sendServerPacket(player, packet)
oh that sounds interesting! What exactly is an item display compiler?
Can that be done with NMS or ProtocolLib?
My goal is as I told you to remove the bounce animation when an item gets updated in your hand, does your thing prevent that?
This packet can only be used to edit the hotbar of the player's inventory if window ID is set to 0 (slots 36 through 44). If the window ID is set to -2, then any slot in the inventory can be used but no add item animation will be played.
SetSlot packet
aw thank you!
np
yes
hmm never thought that far about it
it represents my personality
aww
wdym?
epic
that function will execute every time to replace colors
and that's wasteful
instead you should create a variable outside the method
which uses that utility method, and then return the result from the variable
so like that?
well kinda, but you could return the array instead of sending that message inside the utility method, and then sending it manually
that way you wouldnt need to replace colors every time
Modify Utils.Message() method to return the colored array and then use it inside variable outside the class
that way the replacement of the colors would only occur at object creation
Utils.message returns a colored array?
Have you thought about having the commands message be handled in a command handler? I mean it can make it a lot easier
and also send it?
yes i do
Yea I mean, if you have your own command handler, then you can have a description for the class, and display that in the home "super" class or whatever. You could display all of the sub classes and their descriptions. You don't have to manually do it in a static array
private static final String[] helpMessage = Utils.message(
//"message".. etc
)
and then in method
sender.sendMessage(helpMessage)
then i would use Utils.colorize()
then use it
its a static message it doesnt have anything dynamic
eg. player name
its not necessary, performance could be the same, as 7smile said JIT compiler could optimise that in runtime, im not sure
What you linked me to is received from an event right? I mean it's not a method/function right
From what I understand: When an item gets removed or added into an inventory slot, this event gets fired with corresponding packet data/event context
I'm not sure though if it corresponds to my situation:
I continuously update a player's armor color (to animate it). Thing is, when he has it in hand, it keeps bouncing up and down due to being updated animation, and i want to remove this bounce.
so just private static final String[] help = Utils.colorize(message)
and sender.sendmessage(help)
its server sent packet
it could never be received
its purpose is to send it to the client
should be
ok, so I have to send it myself every time i wanna update the armor
i mean from the server ofc
if you want to have no animation yes, idk maybe there's a better way, but this should work
you're doing some kind of rainbow armor or what
yep!
as far as i know animation only occurs in hotbar
Actually it fully works already, u can test it out on my server if ya want
i just want to remove that boring bounce
alrightie!
wow second 8gb ram stick really does the trick for development
finally i have no lag running server, intellij and server
and chromium
im using mixed ram
~~I use my brothers ~~
just because of PANDEMIC
i won the russian roulette and found similiar specs ram stick
one is from crucial and another one is from kingston
Yeah idk what stuff I have
That requires having siblings
online-mode: false and be happy
True
||ask your parents||
Well yeah
A Player isn't a String
So no casting that
wait selling accounts now after the microsoft migration means you gotta sell microsoft accounts and not just mojang accounts! madge
._.
dont spam @quaint mantle and look at what olivo said
sorry for the ping olivo v.v
No problem 🙂
yes
I know java, but I don't know anything about plugins. How can I write an http server? @golden turret
how does http server correlate with spigot plugin development
what?
i write http server in java but how to include plugin????
you extends your class by JavaPlugin
override onEnable() and/or onDisable method of JavaPlugin super class
add plugin.yml which consists of main:, name:, version: yaml keys
main key should provide package path to your plugins main class
@mortal hare Is there a chance to pull console with plugin?
https://www.spigotmc.org/wiki/spigot-plugin-development/
Here you can find a tutorial on how to start with your IDE of choice
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
What do you mean by "pull console"
you want to send console output via http protocol?
is that what you're seeking
?
yea
sorry i use google translate
I have no desire to write a plugin, I just want to write that plugin because it is not available anywhere.
It uses java's logger
sorry
how?
i wish
console output console.txt in real time
this.getLogger().addFileHandler()
im not expert in logger api
but something like this
i cant help you much
you which use IDE?
Intellij IDEA Community edition
thx
do you send me simple plugin.yml file?
plugin.yml example
main: me.dovias.mypluginname.MyPluginMainClass
name: MyPlugin
version: 1.0-SNAPSHOT
author: Dovias
how do i retrieve the value and signature of a player's skin?
you want to get it?
if yes
yeah
my first thought would be to use mojangs auth api
i dont wanna get banned
see this
for what
it happens like every 10m
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
GameProfile profile = ((CraftPlayer) event.getPlayer()).getHandle().getProfile();
for (Property property : profile.getProperties().get("textures")) {
try {
URL url = new URL(
((Map<String, Object>) ((Map<String, Object>)
new Gson().fromJson(
new String(Base64.decodeBase64(property.getValue())).replace("\n", ""),
Map.class
)
.get("textures"))
.get("SKIN"))
.get("url").toString()
);
PLAYERS_SKINS.put(
event.getPlayer().getUniqueId(),
ImageIO.read(url)
);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}```
i use it at PlayerJoinEvent
will this work in 1.8?
nice
i need the value and signature
then just change the values used
hold on one sec
In your code you're iterating through all of the texture properties
Is there only 1?
if you want to just store it and compare base64 values, its all you need
it should
idk
when i was testing it
i saw
i havent used 1.8 for years
the value and signature in the map
idk if 1.8 has API differences
but i dont think so
because 1.7.10 introduced the uuids
yes
everything can be serialized, question is probably is your class implements serializable interface
which simplify things
old api
but it should be fine in newer versions
BlockStateMeta implements ConfigurationSerializable
invoking serialize() method you can get a map
with all keys and values
how to solve @mortal hare https://ibb.co/ryPhdJD
import them
?learnjava
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.
have you imported the Spigot API
no
how would IDE know what black magic you're writing then
where is the download apı?
you are joke?
What is wrong with this?
capital O
GameTestHarnessTestCommand wtf is this command
i found it inside NMS
but seems its not used ingame
it still shows that there is an error @tall dragon
well look for utility methods in google
which parses the object into json or anything else
please help please
wrong O's lol
wdym
it's onEnable and @Override
^
you switched the capitalization of the wrong O's
you can also just let the IDE generate the right stuff for you
alt + insert -> override methods
there is a bug in my plugin where a player can get infinite hearts by putting the heart item in their offhand and right clicking. The item is supposed to delete itself when you right click but the offhand is not technically the inventory so it doesn't clear
here is my item's class
ItemStack usedItem = PlayerInteractEvent.getHand() == EquipmentSlot.HAND ? PlayerInteractEvent.getPlayer().getInventory().getItemInMainHand() : PlayerInteractEvent.getPlayer().getInventory().getItemInOffHand();
huh
You have to get which hand is used and get the item from that hand.
?
^
When was that added?
Long time ago
There was a site that allowed you to view what versions a method was available in
I wish I remembered what it was
how to send image?
how to solve? https://ibb.co/Hq1gnxX
i create new project
I believe InteliJ has a plugin to generate a basic setup for you
It's called Minecraft Development iirc
solved thankyou
why my plugin dont show
help me
come general-1
how can i install netherboard api?
how would I make a GUI type thing?
?google "Spigot create gui"
Google your question before asking it:
https://www.google.com/
I just want it to open a chest
?
help
?google how to open a chest
Google your question before asking it:
https://www.google.com/
@fringe pawn use something like gradle or maven
bro i If I send you anydesk, will you do it for me?
im trying to make a command with args but whenever i use any args it just shows the usage
return true
send code
does any of you know how does bukkit command execution work
its so strange
it seems that bukkit only uses brigadier for tab completion
its added to a map
i need deeper understanding
apart from craft implementations
from NMS perspective
I've spent over 3 hours searching where bukkit hooks into brigadier, and only thing i found that its adding new CommandNode to the datapackResources commandDispatcher
lol how do u make text smaller in intellij trying to make a screnshot
which seems to be used to sync bukkit commands
with brigadier ones
the thing is, idk if bukkit uses brigadier apart for tab completion or does it use its own algorithm some sorts
to execute the command
from what i see it splits the command and does the error checking by themself
and ignores brigadier
public int run(CommandContext<CommandListenerWrapper> context) throws CommandSyntaxException {
return this.server.dispatchCommand(((CommandListenerWrapper)context.getSource()).getBukkitSender(), context.getRange().get(context.getInput())) ? 1 : 0;
}
what's more strange that method has throws CommandSyntaxException which is from brigadier but i cant seem what could throw it
can someone help me im trying to use config outside of my main class
i tried to do this, but it didnt work
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Main");
plugin.reloadConfig();
o
@mortal hare
?
i seem to think like this too, but i see things like CommandSyntaxException which are thrown by brigadier when dispatching failed, etc
idk
but i cant find no trace of the logic behind apart from this
i would love to use native brigadier
but couldnt seem to find a way to modify the thrown error messages
without rebuilding the jar
because they're very ugly and hard to understand for some people
newest 1.17.1
there's things like commodore, but its just a mappings utility, nothing more apart from that
say to me the package of the class
BukkitCommandWrapper class from craftbukkit package
Hello, is it possible to compile a .jar with another .jar (jedis) without a maven?
In eclipse *
that's what im talking about
i successfully registered the command inside the dedicatedServer's command dispatcher
but this message is ugly
Does yours show up as minecraft:command as well :p
yes it does, but its a craftbukkit's implementation problem
since it uses separate commanddispatcher
for packet sending
of tab completion
it uses CommandDispatcher from DatapackResources inside dedicatedServer
to sync the bukkit commands with minecraft ones
spigot doesnt find Plugin object inside command map and it assumes that inside brigadier is a minecraft command
porque?
you can deregister the child node with key "minecraft:" and resend packeplayoutchat packet or there's dedicated syncCommands method which does that at startup
Thus, we are Mojang
its possible to fix this, but it requires manual deregistration or modification of spigot jar i assume
have you managed to change that ugly error message
here's the output from DatapackResources object CommandDispatcher (Inside DedicatedServer.class)
it stores the tab completion data for bukkit there
you can delete the node with minecraft: prefix there
and you're done fixing it, after that you need to resend the packet or use the method which is already provided somewhere i dont remember
and "minecraft:yourcommand" is gone
i don't understand why craftbukkit team doesnt make their command api deprecated
brigadier is way more flexible and more performance friendly
since its based on tree structure, and doesnt need to get computed that much
?paste
check your logs
kaboom is not on your server
no appearance of my kaboom plugin :(
change dependency name in plugin.yml
from Netherboard-Bukkit
to Netherboard maybe?
👍
👍
👍
👍
Bukkit's command API does not use brigadier because md_5 wants to keep backwards compatibility.
that sums it up sadly.
fuck backwards compatibility
That's sad, I mean they could keep the old one and deprecate it whilst adding a new one which builds around brig
command API uses a little bit of brigadier, but only for simple tab completion
ArgumentCommandNode<CommandListenerWrapper, String> defaultArgs = ((RequiredArgumentBuilder)RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString()).suggests(this).executes(this)).build();
that famous tooltip "<args>" lies
inside bukkit brigadier impl
its hardcoded inside the class
its kinda hacky how this brigadier impl works
it uses brigadier's greedy string argument type class to bypass tab completion from brigadier (error tooltip)
how do i avoid the circular error in my case
i have 2 modules
core and adapter
i want to use something in the adapter
make it unidirectional
and this thing is in core
probably through making everything depending on abstractions
yes
but
i want this
in the
adapter module
and the core build.gradle
i tried to exclude
but doesnt work
I really dont understand what you're trying to do here, maybe im just dumb
core:
coolpackage.Class
adapter:
coolpackage.aa.AnotherClass
core implementation(project(':adapter'))
what i want
is
from the adapter
access a class in the core
without doing circular error
I'm trying to understand this method:
HashMap<List<UUID>, List<UUID>> battles;
public List<UUID> getBattlePlList(UUID uuid) {
Entity e = Bukkit.getEntity(uuid);
for (List<UUID> list:battles.keySet()) {
if (main.registry.isNPC(e)) {
if (list.contains(uuid)) return battles.get(list);
}
else {
if (battles.get(list).contains(uuid)) return battles.get(list);
}
}
return null;
}
It returns a List of UUIDs but wouldn't it just return a single UUID?
Damn, that looks like it needs to be converted into a class
Yeah its old code, i'm currently making it into a class. Just trying to understand this so I can better convert it
No it will always return a List<UUID> IF the searched UUID is in either the key or value List
how do you stop someone from being on fire
set their fire ticks to 0
well it depends do they stay in the fire
ive also tried setting to invulnerable but after its turned off they catch fire
ima try invulnerable + setfireticks
lol
(said it out loud, why does my dog look so guilty now?)
ok so for some reason whenever i try to turn off the fire it lags me back and sets me back on fire
Thinking more about being able to "save" pixelstacker projects. It would require a way to serialize a blueprint in a way that it can be deserialized for future use....
anyone know whats happening here lol
Its either setting ticks to 0 or editing the meta package, which IDK is possible
This is how I do it
btw isnt there a thing where u can wait a tick
What version are you on
1.17
strange, I am and it works fine
lol
xD
lol ignore the timeunit thing ik its shit
but idk what the wait tick thing is called
i could google it ig
but idk why its lagging me back
it says it in the logs
[18:43:09 WARN]: Can't keep up! Is the server overloaded? Running 8473ms or 169 ticks behind
[18:43:09 WARN]: TristanDaSavage moved too quickly! 12.997392193638632,1.0,21.009445078726685
that happens every time i "die"
for some reason the stuff heals after invulnerability turns off even tho this is the order
That much lag you are doing something heavy on death
?scheduling
you use teh scheduler to delay code
how do i loop using the scheduler
cuz it just runs the scheduler a bunch of times but delayed
use teh BukkitRunnable and add a variable outside the run() method
a simple Int you can increase every time it executes
then do whatever you want in the run() method depending on the int value
teh
when it reaches a set value call cancel()
so like
for(int i = 5; i > 0; i--) {
int finalI = i;
new BukkitRunnable() {
@Override
public void run() {
player.sendTitle(ChatColor.RED + "You Died", ChatColor.YELLOW + "Respawning in " + ChatColor.RED + finalI, 0, 21, 0);
player.sendMessage(ChatColor.YELLOW + "Respawning in " + ChatColor.RED + finalI);
}
}.runTaskLater(plugin, 20L);
}
no
not a for loop
the for loop is for how many seconds
just an int variable inside the runnable, but outside the run() method
no, you do a repeating task
you do it all in one runnable
lol
wait how do i make it the same number as how many times looped then
@eternal oxide
new BukkitRunnable() {
int sec = 5;
@Override
public void run() {
if (sec == 0) {
this.cancel();
return;
}
player.sendTitle(ChatColor.RED + "You Died", ChatColor.YELLOW + "Respawning in " + ChatColor.RED + sec, 0, 21, 0);
player.sendMessage(ChatColor.YELLOW + "Respawning in " + ChatColor.RED + sec);
sec--;
}
}.runTaskTimer(plugin, 0L, 20L);
new BukkitRunnable() {
int i = 5;
@Override
public void run() {
player.sendTitle(ChatColor.RED + "You Died", ChatColor.YELLOW + "Respawning in " + ChatColor.RED + i, 0, 21, 0);
player.sendMessage(ChatColor.YELLOW + "Respawning in " + ChatColor.RED + i);
i--;
if (i == 0) cancel();
}
}.runTaskTimer(plugin, 0L, 20L);```
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
uh hm
#text ig
sori
when i opened the project on another computer, this happened
btw there is
@Override
on the top
take it or leave it lol
il go with this one
Just means that the parameters are annotated with @NotNull in the Bukkit interfaces but they're not in your project
If you prefixed all of those parameters with @NotNull it would go away
How to return in runTaskAsynchronously?
You can’t return the outer method inside a task
CompletableFuture
I am so confused
any idea why my main class public static void main(String[] args){} wont run?
heres my manifest file
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.6.3
Built-By: PC
Build-Jdk: 16.0.2
Main-Class: me.silentprogram.discordbot.MainClass
im trying to make an excecutable jar
what is BanList banlist; in java [what does it do]
public class InternalListener implements Listener {
@EventHandler
public void onPunish(PunishmentEvent e) {
BanList banlist;
if (e.getPunishment().getType().equals(PunishmentType.BAN) || e.getPunishment().getType().equals(PunishmentType.TEMP_BAN)) {
banlist = Bukkit.getBanList(BanList.Type.NAME);
banlist.addBan(e.getPunishment().getName(), e.getPunishment().getReason(), new Date(e.getPunishment().getEnd()), e.getPunishment().getOperator());
} else if (e.getPunishment().getType().equals(PunishmentType.IP_BAN) || e.getPunishment().getType().equals(PunishmentType.TEMP_IP_BAN)) {
banlist = Bukkit.getBanList(BanList.Type.IP);
banlist.addBan(e.getPunishment().getName(), e.getPunishment().getReason(), new Date(e.getPunishment().getEnd()), e.getPunishment().getOperator());
}
}
}
what does BanList banlist do?
also what does the e in (PunishmentEvent e) do?
public void onPunish(PunishmentEvent e) {
BanList banlist;
BanList banlist is a variable declaration
And the e is the parameter name of type PunishmentEvent
BanList = banlist?
= is for assigning a variable
BanList banlist; is the same as BanList = banlist?
No
BanList banlist creates a new variable of type BanList named banlist
BanList = banlist assigns the value of banlist to the variable named BanList
However BanList would be a bad variable name as it starts with an upper case letter
looking like a ?learnjava
Oh that’s sad
?learnjava
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.
This isn’t me being a dude with a stick up my ass. You legit need to watch a few videos or read about basic Java before working with spigot
Do not use .equals() for enums !! Enums only ==
i think there are more pressing concerns for him - ie assuming a variable
He don't know Java
But in any case, maybe he will remember what I wrote and will not allow it when he learns the language
😋
don't tell this guy I prefer equals for enums