#help-development
1 messages · Page 2190 of 1
wdym
What do you mean it’s name has version in it
That’s the maven config not the plugin config
They're talking about the build artifact
Lets take 16 teams of 1 player, then you have 16 chunks, and one chunk is 16 block wide, so they would be dropping too close, won't they?
That’s configurable separately, you don’t need to make version null lol
then make the play area bigger
Just set a custom radius on your spread
Like when I build the plugin it's name is what's in artifactId and then what's inside version in the .pom file.
I want it to just be the artifactId
So double or triple that
Okay, thanks
<packaging>jar</packaging>
<build>
<finalName>WhatEverYouLikey</finalName>
</build>
What is the new PacketPlayOutMapChunk in 1.18[.2]?
Anyone know how i can change the specific item back to durability 0 when putting it in a chest/dispenser like the OnWeaponDrop in screen
Use the InventoryClick and InventoryDrag event
ItemStack isn’t mutable down to the NMS, once you modify it you then have to set it
Using the appropriate inventory events
That is an awful practice you're showing there
Can I make some suggestions
It's for 1.7.10 and modded server so yh lots of stuff not possible
whoever just replied to me and deleted it, client bound
and needs to work with modded items hands the reason why IDs is used
yea sry that was me, just noticed that my question was stupid
Hi quick question, what spigot version do I use to make a 1.8.9 plugin? I assume 1.8.8?
1.18.2
^
Use latest :)
Oh I can just use latest. Sweet! Thanks
Viaversion for backwards compatibility if you really need people to be able to join from 1.8
What kind of suggestions?
1.8.8
Not latest
Use hasPermission instead of looping through all permissions
Now confused....
If you don’t want to help the kid just say that guys
Don't copypaste code, extract it into a method
Don’t lie to him
You shouldn't be using such an outdated version and it will be much harder to get support for it
Use latest
where did you find that?
But it works for a 1.8.9 server?
They don’t support people working on 1.8, if you actually want to do 1.8 spigot use 1.8.8
For a 1.8.9 server, latest will not work, you want spigot 1.8.8
Okay, thank you very much!
Presumably ClientboundLevelChunkWithLightPacket
Yeahh that code is from my server dev, but he is inactive lately so i'm trying to fix it myself but ye not rlly experienced 😛
i bet i dont even need the else if in this: ```java
Player player = (Player) commandSender;
if (flyingPlayers.contains(player.getUniqueId())){
flyingPlayers.remove(player.getUniqueId());
player.setAllowFlight(false);
Msg.send(player, "&cFlight has been disabled.");
} else if (!flyingPlayers.contains(player.getUniqueId())) {
flyingPlayers.add(player.getUniqueId());
player.setAllowFlight(true);
Msg.send(player, "&aFlight has been enabled.");
}
You're PAYING to get code like that?
No just friends helping out
You don't
Matter of fact this code can be dramatically simplified
bro what the actual hell
a print statement is determining whether or not my code works
??
oof
If flyingPlayers is a set
You can replace that contains and remove with just remove
Yep
In a set remove returns true if the element was in the set, false otherwise
It could look like this
anyone have a clue how this is happening
could be using getLogger().info(); instead of System.out.println();?
player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
player.sendMessage(player.getAllowFlight() ? "You can now fly!" : "You can no longer fly!");
if (!player.getAllowFlight()) {
flyingPlayers.remove(player.getUniqueId());
}```
i mean thats not really the point here
Not sure why you even need to have a Set to keep track of a property that's already stored on the player though
i can still make the message send in colour?
Hello, I am trying to find packet equivalent of a method. This is the method I need: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html#setRotation(float,float) Because it can rotate passengers without need to eject. Anyone know what packet does it use?
I am using protocol lib so here are the packets types: https://github.com/dmulloy2/ProtocolLib/blob/master/src/main/java/com/comphenix/protocol/PacketType.java
intellij asked if i wanted it to be and if else
Can you send more of your code
Prefer ternaries over inline if-else
thanks 😄 I will try it
I guess that's personal preference
I mean I also do love the ? operator
Inline if statements are considered an antipattern
but there's also nothing wrong in using if else
Not using braces is how you get security flaws
Having more than a few in one function is a sign of bad code
but anyway, if/else is nothing that one should avoid imho
Having a bunch of nested if-else can be a sign of bad code, but not just if-else in and of itself
No, either way
Man i have this architectural problem
I have a feature, function which I would like to implement
Nested or not, if you have more than a few in one function something is probably wrong
There are a few exceptions
but if i Implement it, there's an impact of performance
it does work when unmounted, but does not work when armor stand is passenger unlike the spigot method
Well the spigot method is likely performing more than one operation
should i move my main class from Mecha.class to Main.class?
You’re probably going to need a few different packets
Your main class should not be named Main.class
It should be YourPluginNameHere.class or something to that effect
Explain it
hm ok
how can I learn what spigot method does? someone said on the code side of things its the ClientboundMoveEntityPacket$Rot but it doesnt mean anything to me as idk much about packets
Maybe make a thread
That one will be https://github.com/dmulloy2/ProtocolLib/blob/240920d642be3ff5d84f45586e01ddb2444cf1c2/src/main/java/com/comphenix/protocol/PacketType.java#L147
thx going to try now
I have an experimental UI framework which allows you to simulate clientside inventory actions, the thing is I could reuse some of the handling code from the action handling system I'm currently using, but they're optimised in way, that some actions are remain to be calculated by the client, by that I'm saving bunch of iterations which server doesn't really need to do. On the other side, these optimisations break my feature of clientside interaction simulation which seems like a cool idea, and I can't think of how to implement this gracefully without any performance drops.
Proper abstractions
Have an interface that represents all the needed behavior
For simulating inventory actions, you have an implementation of it that does all the calculations
For non simulated ones it can basically just be a dummy that does nothing
makes more sense to put command usage like that?
thing is that the implementation is very abstract and action handlers can be swapped due to how strategy design pattern works
its not monolithic
Adding another polymorphic component seems like the solution
Makes more sense to use a framework, default commands suck
same problem :/
You’ll probably want to look at the decompiled spigot source for that method and see what it’s doing differently from you then
Or look at it on stash
how can I do that?
I would say yes, that way your plugin could properly respond to the changes in the plugin.yml file, if server owner wishes to change the permission nodes or to localize the description of the command (although its not recommended to do it that way, some plugins crash due to this)
although command frameworks are more fancy and flexible to work with
bukkit api should add static tab completion maps to the plugin.yml
that way plugin developers wouldnt need to rely on tab completion events every time, thus save some performance (although not much)
dynamic tab completion are not that common for simple commands
basic dynamic tab completion is already implemented (player names, worlds, etc.)
Do you know how to get a LightEngine in ClientboundLevelChunkWithLightPacket(Chunk var0, LightEngine var1, BitSet var2, BitSet var3, boolean var4)?
I'm a bit lost trying to interpret the table at https://wiki.vg/Protocol#Chunk_Data_And_Update_Light
So why are you trying to send a chunk packet
Trying to send chunks from a certain area of the world to the player at a different location
Oh well guess you're going to have to dig around a bit
Hey guys! Need some help.
Does any of you know if there's any way I can set an ItemStack display name in multiple languages? So it's translated client-side?
yeah
Just as any other regular Minecraft item
Translatable key in the Resource pack
Or modify the packet before it's sent to the player replacing a specific placeholder with the text in question
Alright, so I must either use a resource pack or deal with packets?
Thank you folks
o/
anyway theJsUsed I believe ItemMeta setLocalizedName/getLocalizedName might be for you
or if you use paper then those w/o the get/set prefixes
for some reason my plugin runs the onDisable method whenever I do /stop but if I do /restart it doesn't. Anybody know how this is possible>
It's weird, set/get LocalizedName was my first approach, but setLocalizedName only received one single string
shouldn't I be able to set a localized name for English, Spanish, Protuguese and any number of different languages?
Okay, I'm not getting it. Sorry if i'm just being dump:
Let's say I got an Itemstack with a glowStone material. I want it to be called "magic dust", but I want English clients to see "magic dust" and Spanish clients to see "polvo mágico". How would I achieve that using the ItemStack's localized name?
Oh custom localized names can only be supported using a resource pack as tommy said, or if you translate it server sidedly
but that presupposed you also are aware of the language of said usr
Ohh! got it!
I guess I'll just translated I server-side. Player#getLocale should be enough to get the Player's language
indeed
The drawback it that if an English located player crafts my custom item, drops it and then a Spanish located player picks it up, they'll see an English display name and lore.
not the server version
does anyone know how to do that?
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Msg.send(commandSender, "&7------------= &aMecha &7=------------");
Msg.send(commandSender, "&aVersion: " + Bukkit.getVersion() + " &ais installed.");
Msg.send(commandSender, "&4PRE-RELEASE!!! THIS VERSION IS NOT STABLE");
return true;
}```
plugin.getDescription.getVersion
Do you know what nmsChunk.i.getChunkProvider().getLightEngine() has changed to in 1.18?
probably something diferent
user your plugins main instance
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Use dependency injection
Set a static member of type JavaPlugin in your Plugins main class, define it in onEnable(), then access it from your command class
okay
hey, am I dumb because it's too late and I'm overworked or why can't I add player to this Set
private final Set<Player> players = new HashSet<>();
public void addPlayer(Player player) {
if(players.size() >= size) return;
players.add(player);
Logger.info(getPlayers()); //TODO: remove
}
in this function
I see it doesn't work
it prints out empty set
that logger is custom class, just shorter bukkit.getLogger()...
public Set<Player> getPlayers() {
return players;
}
getPlayers() function
if i can find it
i've got a PlayerInteractEvent and i'm trying to make it so when a player right clicks a container with a certain item, the container won't open. i've already made a list of every block which does something when you right click it. I'm trying to do .setCancelled(true) on the PlayerInteractEvent but it doesn't stop the inventory from appearing?
please
The Static member approach is just a simple an easy solution. There're definitely more elegant patterns to have the job done, like using dependency injection.
what's the value of size?
I'm going to sleep, you found the problem that I've been working on for 1 and half a hour in minutes, it's 2am and Im tired, sorry
ok so i will use this code instead, i want to cancel the inventory appearing if the player is sneaking
if (player.isSneaking()) event.setCancelled(true);
surely that would work
that's what i have
make an int called count = 0 and a string called last = null, iterate thru the stringlist and check if the current string = last, if it does increment count by 1, if it doesn't equal it then set count to 0, return current string if count reaches 5
it's a PlayerInteractEvent
^^
I'm proud
why
i got a B in algorithmics
Niice
my problem still : (
Yes
i need to check if they are crouching
if they are, and they're right clicking a block which is in my list of forbidden blocks, then i need the inventory to not open
i mean i cancel the event at the end anyway idk why im actually checking again
i always cancel the event
but the inventory always opens
when u want to exit the method use return;
So do ur checks to not open the inv and return
that won't cancel the inventory opening
I dont understand why it won't
returning from an event handler won't cancel the event
So why does the inv open?
i don't want the barrel to open
Well cancel tje event first
Can i see ur listener?
the final line there is supposed to make it so if you right click while crouched, the barrel won't open
but the rest of the event listener will play out
Yep
Set the listener priority to monitor to test if something is uncancelling the event
how do that :v
Next to @EventHandler
(priority = EventPriority.MONITOR
also print somethingafter u check that the data is correct
so would adding that have fixed it
so what should the monitor have done
the thing i added to check if i was crouching says i am
Where did you print the crouch check message tho?
immediately after the last line in that screenshot
MONitor makes your listener code run after all other listeners so u have the final say
Are u sneaking when u right click the barrel?
yes
nop
Quick question, for a server that will have a lot of features. What would be the best solution, 1 big plugin or a lot of small ones?
not using && on purpose
i don't want to quit the rest of the event listener if the player is only standing up
they need to be standing up and clicking a forbidden block
Doesn't matter too much
That's not what && does
my brain isn't very good today so that might be wrong but it's working
i know && skips evaluating the 2nd one if the first one fails
separate different things
anyway the event still isn't getting cancelled
Yep but that won't quit your listener or anything
ex 1 core plugin, that handles the stuff that would be used on the full network etc; specific plugins for each gamemode, etc
im so bad at this
i saw someone on a forum post say that they cancelled the event when they clicked a dispenser and it worked for them
Can i see what blocks are in the list
It's supposed to
idk how to use dependency injection
i am crouching and clicking doors and chests
And they still open?
yes
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Is possible to create Mongo POJO's ? so then i dont need to set each class object data into a bson document for them saving, reading, etc
it says that's deprecated
all i want is to do this
If you are not in the main class, you cannot call getPlugin()
rip
What are you doing?
you need an instance of your main class
trying to grab the version from plugin.yml
from either DI or a singleton, read the guide
@humble tulip it says iscancelled is true
You have to pass an instance of the main class using DI or Singleton
Rack, do you have experience with mongo?
eh a bit
Oh ok
Then wtf is going on
What's the issue VERANO?
I dont think you would know, but mye. I want to know if possible to define model with mongo db
Like you do on NodeJS for example
Ive never messed with anything like node, so I cant help you with that
I mean I dont have any reference on what a model would be
I wondering if possible to use a custom class which define properties so them i can saving/deleting and updating it
I somewhat do that
Arent called MongoDB Pojo's?
I have objects created that will be used for the DB, but methods in that class I have basic save/update/delete methods; its hardcoded -> All it basically is, is converting it to a bson Document
Yeah
I do that
But i seen that some people dont use bson Document
They directly save/update/delete/etc a class object with properties already defined
Hey, im not really able to figure out what is the problem with my plugin. Is someone able to help me (this is the console when i enable it: https://pastebin.com/SLhtQRKQ)
Command is not defined in plugin.yml
best guess off a quick look- your command isnt defined in your plugin.yml
Make sure you put it there
oh, yea. I switch two letters. I am far too tired for this. Thanks 😄
https://www.spigotmc.org/threads/beginner-programming-mistakes-and-why-youre-making-them.278876/
I was reading this post and I noticed that I frequently made this mistake in a recent plugin. What would be the correct and efficient way to do the thing that this codeblock does so poorly?
I was making pets and did the exact thing here.
I'd honestly just do a weird map supplier type thing
Map<String, Supplier<SpawnPet>> petSupplier = ...;
petSupplier.put("common_cow", () -> new SpawnCommonCow(this.plugin));
etc
String value = container.get(type, PersistentDataType.STRING);
SpawnPet whatever = petSupplier.get(value).get();
whatever.spawnPet(player, 3);
getKeys(true) returns all paths
or recursion
wait so what's your objective?
make a tree view or something?
what if you do getKeys(true) and substring(lastIndexOf(".") + 1)
it's just simpler
^ it probably does recursion under the hood lol
Hello! Is it real to set ItemStack lore with md_5's TranslatableComponent?
I couldn't find the feature I need in the Spigot API
?tas
This is inappropriate. I don't ask if I can do it. I ask how exactly can I do what I need
I couldn't find the feature I need in the Spigot API
Well, if there are no native solutions, then I'll use Kyori. Thanks
Paper loves their components
ok so I am trying to use essentialsx, but non opped players cannot use any commands from essentialsx
any fixes?
Program a permissions plugin https://bukkit.fandom.com/wiki/Developing_a_permissions_plugin
This tutorial will guide you through how to create your own permissions plugin that sets permissions using the new Bukkit permissions API. This tutorial assumes you have a good understanding of the Java language, and general plugin development. This tutorial will only cover the specifics of the Bukkit permissions API. Everything that can have pe...
well using luckperms doesn't work, so why should making another plugin for the same purpose work?
(ik u did not know that part)
Because you have been asking in the programing channel
is it possible whatsoever to make every block in a players render distance update? like how reloading/relogging does it?
is there a way to get a Plugin from bungeecord like bukkit JavaPlugin.getPlugin(Class)?
Is there a event for when a entity moves and not just a player?
sadly nope
oh heck, is there a way I can check if a mob moves outside of a certain radius or nah?
but nms have a move method
nope
inside the Entity class
What is the event called?
i mean
yes but EntityMoveEvent doesnt exist because it had too much overhead
the Entity class from nms have a method called move
since it would record a timing when the event fired, and the system uses reflection
but that will only work for custom entities
so I cant check if a regular zombie moves somewhere?
is there a client side block physics event?
you can do a 1 tick runnable
id rather not but alright
and create a new event bus just to not use the bukkit's one
because it uses reflection
does anybody know how to setup protocollib
everytime I build my project it builds as a file
folder*
im trying to build it as a jar
for the entire plugin
Hey I am looking at the SpigotMC wiki on how to connect to a MySQL database and it provides this snippet of code to test connect
private void testDataSource(DataSource dataSource) throws SQLException {
try (Connection conn = dataSource.getConnection()) {
if (!conn.isValid(1)) {
throw new SQLException("Could not establish database connection.");
}
}
}
I do not believe most of this code is valid but I don't exactly know how to fix it so I was wondering if someone could give me a corrected version of it?
How do I unobfuscate NMS methods?
you can use a remapper at compile time
which also reobfs during compile time so that your plugin can run on servers
uhhuh
how do I build a project with nms
I have multiple versions
idk how to set it up to read that
first and foremost you pretty much need to use maven/gradle
oh you need to create a module per version
I do?
oh kkill myself
I've been trying to do public class main extends JavaPlugin but it doesn't find it for some reason
thats a lot
yeah alternatively reflection
Yeah I see that
Anyone know some good plugins for trading items with chest that is crossplay compatible like 1 item for another no money system
make sure your plugin.yml has the right path
it did not create a plugin.yml
you have to create the plugin.yml
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Anyone know some good plugins for trading items with chest that is crossplay compatible like 1 item for another no money system???
Who
how would this help exactly
you
Asked
the plugin.yml contains some info about the plugin like path to main class, description commands etc
The plugin.yml is a file made to contain information about your plugin. Without this file, your plugin will NOT work. It consists of a set of attributes, each defined on a new line with no indentation.
All attributes are case sensitive. Attributes in bold are required. Attributes in italics are not.```
yes but I can't even code it thats what my issue is
the wiki goes over all the fields you need in it
make a file called plugin.yml in your resources folder
I'd spend a couple days aquainting yourself with the syntax then that should be really all you need if you have plenty of programming experience already. I also recocmend using a package manager like Maven or Gradle for java projects
it's also under the "Referenced Libraries"
Im using eclipse with a Maven project already
I learn syntax by coding something
so thats what im doing
your class naming conventions are slightly off I'd just check out java naming conventions
I will name them how I like to name them
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
lmao
realest shit i’ve seen in a minute
I'm putting numbers in my class names now for because I want to
I mean Id advocate naming conventions but ye
well it's more of the stuff I code its mostly only for me so Im gonna name them how I like to
so called free thinkers when naming conventions and camel case is brought up
yeah well its not the most fundamental thing in the beginning so no shame :3
yeah rn its just been trying to get the api to actually function but it isn't rn and can't figure out why
you need to add it to your maven dependencies
https://www.spigotmc.org/wiki/spigot-maven/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
^ wiki tells you how to
stil won't import the API when I try to use extends JavaPlugin
are you importing it
Ever wanted to know how to make Minecraft plugins for Java edition? In this new series we'll be starting with the basics and eventually diving into the advanced details of plugin development.
I've been developing plugins and running my own servers since 2013, so expect to see step-by-step tutorials with plain English explanations.
🎓 Take my FR...
Could be useful
he walks through the process, may have something
im already watching one but I'll give that one a look rq
👍
yeah so a few issues, he's using linux I believe, im on a windows machine and I already tried that software and it didn't work for jack shit so I removed it and am using eclipse
oh your not using intelliJ/jetbeans?
nah was having issues with it so using eclipses
oh, yeah then I'm not much help
why doesn't it work on your computer?
cause i also have windows
pretty sure it was something with the java file I had downloaded it using intelij and kept saying it was corrupted and wouldn't continue
rip
yeah but eclipse works without issue so just went with that
yeah i heard that you can use eclipse, but i never have so im not sure what the issue may be
how do I make holograms, I want to make a plugin to do /npc hologram <line> <message>
for spigot at least
how can I send a string between a Waterfall plugin and my server plugin?
Im making a care package plugin and im just trying to figure out how i can make the care package spawn ON surface, im randomizing the x,y,z but i want the package to be on surface and if its meant to spawn in a ocean/over water, itll restart the randomization
You need to do like a simulation, get the surface location and check the block
how do I access the second argument the user sends
for a command
args[0]?
nvm I figured it out
Is there a packet associated with tripwire client predictions
im sorry, i geniunely have no idea how i should do that at all, im still new to spigot plugins ngl
world.getBlockAt(gen_x, 100, gen_z).setType(Material.CHEST);
So how can I put some contents into this chest?
whenever I type in /hologram t
its saying what I used for if the length of args is above 2
length of args array
it makes no sense
why is it sending when the arg is 1
can you send an ss of what it sends in game?
ah, okay i got it
oh
my
GOD
I meant to use a greater than sign
but I used less than
nvm im dumb
its mostly how i access the inventory for this chest, i know how to put stuff in
do .getState() on it
and then cast it to a Chest
then from that you can do Chest#getBlockInventory()
yeap no idea, what exactly am i doing .getState on? ofc its not on the code i sent above so kinda at a loss atm
on the block sorry
Block block = world.getBlockAt(x,y,z);
if (block.getState() instanceof Chest){
Chest chest = (Chest) block.getState();
Inventory inv = chest.getBlockInventory();
}
@quaint mantle
does anybody know how to make new lines for hologram custom names
the plugin holograms?
no
I mean like when you enter text in
one line
two lines
this is the first line
this is the second line below it
\n
yes
you make a new armour stand for each line
armour stand 1 name = line 1
armour stand 2 name = line 2
offset them on the y coordinate a little bit
are you programming a plugin or using someone else's
so if user args[0] == line number for whatever user sends the command make a new armorstand and offset its value in the same location the previous hologram was but make its y coordinates minus a few values?
Making my own plugin
yep
oh wait
so when the text gets too long you want it to automatically go to the next line?
Is there a way to get client block update packets?
no I just want other to be able to do /hologram 1 test 2 another
and in coding logic
print("test"\n"another")
looking at how other plugins do it
you create a hologram which is stored somewhere with a name
and then you set each line of it with a separate command
/createhologram "test"
/changehologramline "test" 1 "this is line 1"
/changehologramline "test" 2 "this is line 2"
wait
instead ill do /hologram a b c
so arg 1 which is a will be line 1
b is 2
c is 3
ill automatically make whatevers next on the next line
that way its not so complicated
but then you can't have sentences
oh
because a space in the command
oh my god
makes it a different argument
int min_xpos = -3000;
int max_xpos = 3000;
int gen_x = (int)Math.floor(Math.random()*(max_xpos-min_xpos+1)+min_xpos);
int min_zpos = -3000;
int max_zpos = 3000;
int gen_z = (int)Math.floor(Math.random()*(max_zpos-min_zpos+1)+min_zpos);
Block block = world.getBlockAt(gen_x, 100, gen_z).setType(Material.CHEST);```
"Incompatible types. Found 'void', required org.bukkit.block.Block"
*pain*
setType doesnt return anything
Block block = world.getBlockAt(gen_x, 100, gen_z);
block.setType(Material.CHEST);
@quaint mantle
how do I get whatever is in the first argument and whatever ends off the last bit of the argument
args[0:-1]?
or is it args[-1:0]
no java doesnt have that
yes
bro WHAT
java isnt js and python
how can I do that thne
if you want to get the last argument you get the length of the args array and then subtract it by 1
are you trying to combine arguments?
generally java doesnt add unnecessary language features
Lmao
I mean they only add features if proper motivation is given else than arbitrary usefulness
how would I setcustom name to all the args they provide instead of just one
for loop
I cant use for loops ?
Im making a care package plugin and im just trying to figure out how i can make the care package spawn ON surface, im randomizing the x,y,z but i want the package to be on surface and if its meant to spawn in a ocean/over water, itll restart the randomization
i am an extreme beginner so if you guys do know, please dumb it down a lil lol
hologram.setCustomName(ChatColor.RED + args[0]);
I cant use a variable and keep adding onto it and setting it
There’s a method for it
Lemme find it
Your trying to find the highest solid block right
more or less yeah
StringBuilder?
i want it to spawn on any available block but not inside of one
world#gethighestblock(x,z) I think
Is Bukkit.getServer().broadcast() supposed to be deprecated?
getHighestBlockAt(x, z)
StringBuilder builder = new StringBuilder();
for(int i = 1; i < args.length; i++) {
builder.addend(args[i]);
}
@quaint mantle
im gonna try it out
And it requires a message & permission but it's @NotNull so putting null as the permission isn't going to work, right? I don't remember this being the case but Ig it is now?
yes
if its paper
since they favor adventure
Oh I forgot I'm using paper for this project, nevermind
Whilst you're here though, what should I put for the permission if I want it to be null?
Within paper using a string yes
it worked! tyvm
Np
Whatever I'll just go learn how to do it the way they want me to
Even though I'll probably never use paper again
use Bukkit.getServer().sendMessage() if you wanna do it without permission
(paper only)
so my next and hopefully last question for a while is, how can I make an armorstand and make it spawn at an exact location? this goes hand in hand with the care package
Only accepts Components, just going to learn how to use components for now
Component.text("blah")
I've used them briefly in the past but I lowkey forgot
World#spawnEntity(EntityType.ARMOR_STAND) Or Use NMS
yes but it needs to spawn at an exact set of coordinates, ive randomly genned a set and need it to spawn there
spawn entity has location argument
ah yep im dumb
wdym subtract health ? I dont want double damage, i just want double attack speed..
it doesnt include spaces
Pretty sure you have to have modified jar
might be some way to do it with nms
What
Add a " " after
Oh yes sorry Xd
Location location = new Location(gen_x, 100, gen_z);```
im misunderstanding something here :thonk:
StringBuilder builder = new StringBuilder();
for(int i = 1; i < args.length; i++) {
builder.addend(args[i] + " ");
}
Nice that works
now I need to figure out the super hard part
different lines
I think I want to make a specific system for this
after the hologram armor stand is made give them a random generated ID
they can take that id and add a line to the hologram, what it does is make a new hologram with whatever text in the same location as the hologram given (the id given) just subtract y value some
You can do this by spawning the upper armor of the lower armor of the lower stand
Location location = new Location(player.getWorld(), gen_x, world.getHighestBlockYAt(gen_x, gen_z), gen_z);
world.spawnEntity(location, EntityType.ARMOR_STAND);```
This code spawns it perfectly, now how can i make my armorstand invisible and give it a name? im not sure how to access the armorstand itself
store the entity when you spawn it
Entity e = world.spawn....
you can then cast it to ArmorStand which has cool stuff
yea
ArmorStand hologram = (ArmorStand) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
hologram.setGravity(false);
hologram.setVisible(false);
hologram.setCustomNameVisible(true);
thats for you
anyways
armorStand.setVisible(false);
nms
what is nms
One hard
basically mojang's code
spigot is an API which builds on mojang's code and makes it easier
Net.Minecraft.Server ...
it's basically packets
so... can I just make an npc in the same location the armor stand gets created at?
you can Google player npc tutorials on YouTube
you basically have to make a fake player
right
Ye
I'm on phone and I think teixayo is too so it's probably best to look up a tutorial
https://www.spigotmc.org/threads/how-to-create-and-modify-npcs.400753/
Maybe it will help you
Yep
alr
ArmorStand entity = (ArmorStand) world.spawnEntity(location, EntityType.ARMOR_STAND);
entity.setCustomName(ChatColor.translateAlternateColorCodes('&', "&l&cCARE PACKAGE!!!"));
it spawns but it doesnt have the custom name..
entity.setCustomNameVisible(true)
oh my bad didnt see it
public void particilizeAirdrop(Location airdropLoc) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int i = 10;
@Override
public void run() {
if (i <= 0) {
Bukkit.getScheduler().cancelTask(how to get the task id);
}
airdropLoc.add(0, i, 0).getWorld().spawnParticle(Particle.FIREWORKS_SPARK, airdropLoc.add(0, i, 0), 8, 0.2F, 0F, 0.2F);
i--;
}
}, 0, 10);
}
I have this method that particilizes an airdrop, but I'm not sure how to cancel it after it runs 10 times. I don't want to create a variable outside the loop because then it would be replaced if someone places a different airdrop and the task would never be cancelled. Any ideas?
so ive got a chest, how can i add an item with something like efficiency 6 or protection5 to the chest?
Make an ItemStack[], add the item you want to the array, then set the contents to the array
Or just make an ItemStack and add it to the chests inventory
Either way works
main issue im facing is getting the item enchanted
how can i make it an enchanted item
Call addEnchantment on the item stack
Or addUnsafeEnchantment if you want to enchant highee levels
oh thank god you told me about unsafe
and does anyone have a little guide on how to make custom enchants?
I honestly wouldn't go down that path
it's really bad
yeah me neither, i decided against it
I recommend making your own enchantment system
and is there a like PlayerAttack event? for when a player hits an entity
Recommend adding lore that contains the custom enchants if possible, you can make a pretty simple system like this
It's still really messy to deal with
Highly recommend using an already existing plugins api
It's a fun project and you learn a lot from it
It's fun until you realize how creative mode works
bump
How can you get a player's IP (such as 12.34.56.78)? I've tried Player#getAddress, but it returns null.
nbt > lore
the lore is for show
hi BikGamer!
i need help my buildtools arent installing
Exception in thread "main" java.lang.RuntimeException: Error running command, return status !=0: [C:\Windows\system32\cmd.exe, /D, /C, I:\Developement\BuildTools\apache-maven-3.6.0/bin/mvn.cmd, -Dbt.name=582a, clean, install]
at org.spigotmc.builder.Builder.runProcess0(Builder.java:973)
at org.spigotmc.builder.Builder.runProcess(Builder.java:904)
at org.spigotmc.builder.Builder.runMaven(Builder.java:873)
at org.spigotmc.builder.Builder.main(Builder.java:698)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
this is wat error i get
Variables with salt xd
Have you tried AsyncPlayerPreLoginEvent?
It's a little more complicated than that, I need to get it outside of any event
where I only have the Player object
?scheduling
Ok so here: Store it in a database or something when a player logs in, then you can just access the database to get the ip
I highly recommend storing with UUIDs over names or anything else though
Thanks for the tip
That's why I just said to use uuids :p
Yeah just explaining why
Ah, also all the methods using BukkitRunnable are deprecated?
Sleep is important
Indeed
I'm in one of those periods of time where I just can't stop coding
Then I'll get burned out in a few months ago
It's a whole cycle at this point
Hey Guys I'm making Warp Plugin and I wanna make warp list command How can I get Warps name from config?
Im a bit confused about how to properly depend on another one of my plugins.
I thought i always need to get the plugin instance by doing PluginManager.getPlugin etc etc or whatever.
Braindead i wrote it like PluginMainClass.getWhatever and it works fine, is that intended or did i just not get far enough to encounter issues?
Hey, im kinda new to coding and trying to learn hashmaps for a plugin. Is there a way to sort information after value to make a leaderboard?
Now that is a complicated problem
You can loop through HashMaps, and then probably use any sorting algorithm
Generally you wouldn't want to use HashMap but rather LinkedHashMap for displaying the sorted key-value pairs
And then sort the linked hashmap through clearing the whole map and inserting the elements in their sorted order
do you have some sort of example, sorry if thats too annoying to get 😄
In one of my plugins I instead use TreeSet using a custom immutable datatype that stores player UUID and player score - however it's #equals and #hashcode operations are rigged to only compare UUID where as the compareTo compares only the score. You'd need to delete and reinsert the datatype to update the score however and I am not overly sure if that really works since I have only used that approach in plugins I use for my own server which is pretty much empty
https://github.com/Geolykt/bake/blob/master/bake/src/de/geolykt/bake/Bake_Auxillary.java#L159-L174 is the first algorithm I described (which uses a seperate map)
(Don't comment on the rest of the code - I know that it is absolutely trash)
im new to coding, so for me its surprising what you are able to do :)
but yea, i think i get what you have done
Any idea why this keeps teleporting me into the ground like this?
Location newLoc = p.getLocation().clone().add(xDistance, 0, zDistance);
p.teleport(newLoc.getWorld().getHighestBlockAt(newLoc).getLocation());```
Probably because it is the highest block but that will still be non-air (you'd need to add 1 to y to get the air block)
Most likely
Is there a reason I'm always facing the same direction event though setting the yaw randomly
yaw randomly between what values
-180 to +180
ok should work idk
always facing 0 (south)
Random r = new Random();
float randomYaw = -180 + r.nextFloat() * 360;
Location newLoc = p.getLocation().clone().add(xDistance, 0, zDistance);
newLoc.setYaw(randomYaw);```
How can I string of String Path?I will save a many warps. and I wanna make list of them. How can I get String of their name
im not sure what the -180 * r.nextFloat() stuff is
it's basically the same formula to set bounds
min and max
min + r.nextFloat() * (max - min)
but yeah that's more comfortable to use
the generated values are fine, but it's not setting them
how do i add skins to player heads in an inventory?
This question has been asked like a thousand times, ur one quick google search away from the answer
thx for the obvious reply
?wiki
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I start to belive that this is a bug rn, no matter what I try it's not setting yaw or pitch
so whats stopping you from jusit getting the player's uuid and removing it?
@jagged quail
?paste
i have this code right now, i just want to add when they disconnect it removes them from the hashlist https://paste.md-5.net/emohixigej.java
@drowsy helm :v can I get some help with buildtools
sure wahts up
Wait let me post the logs
oh just make the set public and access it from the PlayerQuitevent
what are your params
java -jar BuildTools.jar --rev 1.8.8
1.8.8 is unsupported
who r u replying to
package me.oliver193.mecha.commands;
import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class FlyCommand implements CommandExecutor {
public final Set<UUID> flyingPlayers = new HashSet<>();
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!(commandSender instanceof Player)) {
Msg.send(commandSender, "&cThis command can only be used by players.");
return true;
}
Player player = (Player) commandSender;
// Enable/disable fly mode
player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
if (player.getAllowFlight()) Msg.send(player, "&aYou can now fly!");
else Msg.send(player, "&cYou can no longer fly!");
if (!player.getAllowFlight()) {
flyingPlayers.remove(player.getUniqueId());
}
return true;
}
}
``` how would this make 2 hashsets?
meant to reply to you
heh wdym? buildtools for 1.8.8 is still listed in wiki
when yous et the command executor store the instance of the new class
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
right in here
yeah but it's not supported though
your basically on your own if you have issues unless people want to help
but worked on my ubuntu system. buildtools isnt installing on main system
what java version do you have
java 8
do you have git installed?
there is a java runtime rror
send the log in
i even tried installing latest on windows with latest java still doesnt work
?paste
[ERROR] I:\Developement\BuildTools\CraftBukkit\src\main\java\net\minecraft\server\DedicatedServer.java:[1] The type org.apache.logging.log4j.util.Supplier cannot be resolved. It is indirectly referenced from required .class files```
try deleting buildtools and download it again
Nevermind, got it working now
Random r = new Random();
float randomYaw = r.nextFloat(-180, 180);
Location newLoc = p.getLocation().clone().add(xDistance, 0, zDistance);
p.teleport(new Location(newLoc.getWorld(), newLoc.getX(), newLoc.getWorld().getHighestBlockYAt(newLoc), newLoc.getZ(), randomYaw, newLoc.getPitch()).add(0, 1, 0));```
.getHighestBlockAt(loc).getLocation() seems to return a locatino with yaw and pitch = 0, that was the reason I think
maybe build it on your ubuntu system and transfer it to your pc
is the ubuntu system a vps or local system
then how am i gonna use it. it wouldnt be in my local maven repository
for intellij?
its hosted on a virtual box
hmm
wot to do :v
put this in your repositories <repository> <id>spigotmc-repo</id> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> </repository>
then this in dependencies <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.8.8-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>
doesn't intellij download it automatically for you?
i have this
yes
because i havent got that
i did that
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
its already like that but i can't access nms
did
org.spigotmc:spigot-parent:pom:dev-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced
i suppose it's fixed now?
like when installing>?
yes
yes, see above for solution
thats the error log
hmmm thats weird
this one?
hmm
i am going for nms not normal spigot
nms?
when u install buildtools it puts nms on ur local repository
ah
net.minecraft.server
how can i get the base value of any Attribute?
the default?
theres a thread on that
might help you
i dont think the spigot api has it
but then again its been like 4-5 years
that doesnt change it
why do you keep saying this
can someone help? i am getting kotlin.UninitializedPropertyAccessException: lateinit property plugin has not been initialized in my dependancy injection]
ok i need to figure out how to make it remove the player from the hashlist when they leave
Listen for the PlayerQuitEvent (or however it is called)
in the main class?
?paste
Bukkit.getScheduler().runTaskLater(Bukkit.getServer().pluginManager.getPlugin("Mobwars")!!, Runnable {}, 20) is this a good way to delay execution?
new Runnable
kotlin
its a bit complicated to do in kotlin
at least i haven figured out with my knowledge
what does !! do
!! or what?
ah
Basically an Objects.requireNonNull, right?
probably, not familiar of how it would be done in java
But yeah, I think this logic is right
hm for some reason its not waiting before executing in my for loop
Are you sure that you are using runTaskLater?
yeah
ok so i have this so far
Yank up the delay I guess, it might be too slow for you to notice the difference
private final static
public
private final static Set<UUID> flyingPlayers = new HashSet<>();
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!(commandSender instanceof Player)) {
Msg.send(commandSender, "&cThis command can only be used by players.");
return true;
}
Player player = (Player) commandSender;
// Enable/disable fly mode
player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
if (player.getAllowFlight()) Msg.send(player, "&aYou can now fly!");
else Msg.send(player, "&cYou can no longer fly!");
if (!player.getAllowFlight()) {
flyingPlayers.remove(player.getUniqueId());
}
return true;
}```
you could make it public or make a static method which removes it
public static void removePlayer(UUID uuid){
remove from set
}
...
sorry im rushin
and ive never actually used a set idk if you use .remove on it lol
oh my god
remove from set is not valid code
i just put it there as placeholder because i was rushing
Anyone knows a way to get a random color code? java ChatColor.getByChar(Integer.toHexString(r.nextInt(16))) isn't working anymore for me
whats the error
package me.oliver193.mecha.commands;
import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class FlyCommand implements CommandExecutor {
public final static Set<UUID> flyingPlayers = new HashSet<>();
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!(commandSender instanceof Player)) {
Msg.send(commandSender, "&cThis command can only be used by players.");
return true;
}
Player player = (Player) commandSender;
// Enable/disable fly mode
player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
if (player.getAllowFlight()) Msg.send(player, "&aYou can now fly!");
else Msg.send(player, "&cYou can no longer fly!");
if (!player.getAllowFlight()) {
flyingPlayers.remove(player.getUniqueId());
}
return true;
public static void removePlayer(UUID uuid) {
flyingPlayers.remove(player.getUniqueId());
}
}
}
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.
helps a lot
yeah
Bukkit.getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("Mobwars")!!, Runnable {}, 20) its still not waiting execution
:V breh its been 3 days and i still cant fix this problem
is looping a map entry set in a block break event a bad idea
Just note that the code getting called is within the runnable