#help-development
1 messages · Page 1767 of 1
what's wrong with vscode
simply find the best suited library on github and shade it in
slow, and theres so much
i forgot the name but like reused manual tasks everytime
slow and there's so much? vscode is the most lightweight ide i've ever used
lightweight but the intellisense is really bad
i only use it for json, css, js and html, i think those are the only things it should be used for
i mean it was developed in a web environment
you can do so much with it, and yes of course you can't expect a intellij-like complexity of it, but it's still a great ide for most languages or frameworks
its there when you dont need full help
what would be the best way of implementing it in a plugin, though?
shade it in and run it on a seperate thread
actually it's the same as if you'd do it with a normal program
how to check if a world exist
you can use spigot's new library feature if you want, but i'd just stay with shading it in
Bukkit.getWorlds().contains(
tsym
Maybe okhttp, idk if netty has anything on that, maybe even spring got something nevertheless will the jdk provide you some 'primative' stuff
nv-websocket-client also got on my mind just rn
iirc JDA does use it also
Do all plugins use the same config.yml?
If not, where do i save it so only my plugin uses it?
- No, 2. In your plugin data folder
where is that
However it won’t stop x plugin from accessing your config.yml
thats alright
Usually something like:
server/plugins/PluginName/config.yml
Indeed
hey, does anyone have experience adding features to existing mobs?
Although it’s basically with spigot just Plugin::getDataFolder and then File::mkdirs iirc
does file#createNewFile also create non existing folders?
File::createNewFile creates a file not a directory
like say i wanna save the file in ./abc, does it create abc?
No
ok
It does not
File#mkDirs can handle that
Usually (what I do) is in onLoad:
Path dataPath;
Files.createDirectories(dataPath = this.getDataFolder().toPath().toAbsolutePath());
And in onEnable
Path config;
if (!Files.exists(config = dataPath.resolve("config.yml"))) {
Files.createFile(config);
}
[or something] since Java kinda states the class File is obsolete
Also yea I wrote it on phone lol
anyone know why this only runs the first for loop? lmk if and what more code you need
https://paste.md-5.net/owiwafemuh.cpp
because the conditions in the other two are false
int i = 9;
if (i < 3)
9 is bigger than 3
so it wont run
convert your for-loop to a while loop and youll get why
for (int i = 45; i < 9; i++) {
inv.setItem(i, borderItem);
}
as while:
int i = 45;
while (i < 9) {
inv.setItem(i, borderItem);
i++;
}
"as long as i is smaller than 9"
but i is never smaller
Yeah the two lower loops are using a dummy variable where the value exceeds the upper bound value used in the condition to determine if the loop should continue to iterate thus they never iterate, not even once
ah
@ivory sleet
Why
Path dataPath;
Files.createDirectories(dataPath = this.getDataFolder().toPath().toAbsolutePath());
instead of
Path dataPath = this.getDataFolder().toPath().toAbsolutePath();
Files.createDirectories(dataPath);
?
Oh it was just easier to write on phone
ok :D
One could say the former is worse because it has to mutate its value
well, have to do that anyway, since otherwise i cant use dataPath in onEnable()
Yeah, in principle you could have a private final field in your class where it essentially stores the data path.
thats what i was planning to do
Yeah, probably better that way.
Arguably just a method to get it
Since it might be a waste of variables and unnecessary caching but that’s negligible lol
private final Path dataPath = this.getDataFolder().toPath().toAbsolutePath();
@Override
public void onLoad() {
try { Files.createDirectories(dataPath); } catch (IOException ignored) {}
}
thats what i did
Yeah that should work
does it throw an exception when the folders exist?
idk if you would want to just ignore the exception lol
iirc no
if your plugin relies on that data path
floskater afaik it does not
But if it does, just use Files::exist and Files::isDirectory or smtng c:
ok :D
yeah might be confusing in case it fails xD
xD
ofc it is
plugin config files
getCommand("challenge").setExecutor(new Challenge());
IntelliJ says "Method invocation 'setExecutor' may produce 'NullPointerException' ", should I fix this using Objects.requireNonNull, or is that usually just ignored?
How would i be able to make a fox follow a player with pathfinding
Yeah you can just use requireNonNull
//places the blocks for the portal
public void placePortal(Block[] portalBlocks) {
//separate the blocks from the array
Block portalLowerBlock = portalBlocks[0];
Block portalTopBlock = portalBlocks[1];
//set block types to END_GATEWAY
portalLowerBlock.setType(Material.END_GATEWAY);
portalTopBlock.setType(Material.END_GATEWAY);
//set teleport location for the end gateways
//only used to listen to the event
portalLowerBlock.setExactTeleport(true);
portalLowerBlock.setExitLocation(portalLowerBlock.getLocation().add(0, 3, 0));
}
does anyone know why I can't do the last two lines of code?
IntelliJ says that that method cannot be resolved
my config setup is adding to the config, but is unable to retrieve data
This prints nothing: System.out.println(CustomConfigFile.get().getStringList("parkour.maps"));
but, this works fine, and adds to the config: java CustomConfigFile.get().set("parkour.maps", maps); CustomConfigFile.save(); CustomConfigFile.reload();
hey, im using bungeecord and im trying to place my players online in certain server, how do i do this? is there a video about it because i cant fine one
how do i zoom out on my intellij text editor
using the bungeecord api, you can get a server by its name, something like this: ServerInfo sv = <plugin_class>.getInstance().getProxy().getServerInfo("SERVER NAME");
then
using a ProxiedPlayer, you can do ProxiedPlayer.connect(sv);
ok that to confused for me rn ive been awake for too long lol
here is how I do it in my plugin
@EventHandler
public void onPlayerJoin(ServerConnectEvent e) {
String type = CustomConfigFile.getConfig().getString("config.join-type");
ProxiedPlayer pp = LobbySystem.getInstance().getProxy().getPlayer(e.getPlayer().getUniqueId());
ServerInfo sv;
if (type.equals("RANDOM")) {
sv = LobbySystem.getInstance().getRandomLobby();
}
else {
sv = LobbySystem.getInstance().getProxy().getServerInfo("LOBBY2");
}
System.out.println(ChatColor.AQUA + "[LobbySystem] >> " + ChatColor.GOLD + "New Player Connected. Sending them lobby " + sv.getName());
e.setTarget(sv);
}```
ctrl + or ctrl - ?
google prob has a answer
CTRL + ALT + (+) or (-)
option i think
yea its option
maybe its cause I am trying to do something spigot cant handle
doesnt seem to be doing anything
I'm not to familiar with custom configs sorry, ask on the forums tho
it isnt custom
Try CTRL + SHIFT + A
sorry if you thought that, it is just what I named my config file class
just name it config.yml
cause it is different from like spigot.yml
that is what it is called in file explorer
I use YamlConfiguration
Try:
System.out.println(getConfig().getString("parkour.maps"));
You missed the message that was deleted
Something about Silkroad Online the game
hey, I'm looking to create a plugin that adds some arbitrary changes to existing mobs (e.g mob does extra damage). My plan was, on mob spawn, to randomly assign these elements. I'm aware the bukkit api has the "on mob spawn" event, but I'm not sure how to add stuff to existing mobs. Anyone have any insight on this?
declaration: package: org.bukkit.event.entity, class: EntitySpawnEvent
is there any way to write text like "&1Like&2This" and then convert it into a Component? And get the colorcodes replaced correctly? Because thats way shorter than all that new component.text().color().append(component.text().color().append()...)
id recommend tbh to use something like adventure (off topic)
but its a great lib for components
the translate do nothing but convert & to § which in its unicode is \u00A7
so it basically still text
and §1 gets interpreted as a color, like it used to?
and when you put it in minecraft, they dont care, they see you have that code, then you get the color on the text
might be
idk
but i think you still want to use & instead of that
then in translatealternativecolorcodes('&', text)
Ex: &cHello
It will convert to \u00A7cHello
and the \u00A7c will always be red.
What event gets fired if an entity attempts to attack a Player, but the damage is blocked by a Shield?
afaik, EntityDamageByEntityEvent is still called
even attacks blocked by a shield trigger EntityDamageByEntityEvent
hello good evening, someone knows how to get the result of this command but on top, since it only grabs that of a particular player
else if (args[0].equalsIgnoreCase("zombie")) {
FileConfiguration mobs4 = plugin.getMobs4();
if (!mobs4.contains("Players")) {
jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
jugador.sendMessage(ChatColor.GREEN+"Zombie Asesinados: "+ChatColor.DARK_GREEN+"Ninguno");
jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
return true;
}else {
if (mobs4.contains("Players."+jugador.getUniqueId()+".zombie")) {
int cantidadzombie = Integer.valueOf(mobs4.getString("Players."+jugador.getUniqueId()+".zombie")); //aplicar la cantidad basandose en la id del jugador
jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
jugador.sendMessage(ChatColor.GREEN+"Zombie Asesinados: "+ChatColor.YELLOW+cantidadzombie);
jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
return true;
}else {
jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------"); //si no lleva ninguna kill
jugador.sendMessage(ChatColor.GREEN+"Zombie Asesinados: "+ChatColor.DARK_GREEN+"Ninguno");
jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
return true;
}
}
}
could you elaborate
I don't get it either
what do you mean with "but on top"
Finally finished my first ever plugin :D
Thanks to everyone who helped me :3
gg
...?
anyone wanna test if it works?
I only ran it on my pc till now. not sure if i have to add any dependencies or stuff like that for it to work on other systems
IntelliJ is redly underlining the dependency, but idk what that means
soz but no ones gonna do that lol
youll need to ask a friend
people here are skeptical
yea, makes sense xD
i could send the code tho, but then thats just too much work to set up for most people
if it works on your server it should work fine on others
unless you're doing some OS level stuff it should be fine
Why is it underlined?
in my pom.xml i have
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
</dependency>
does it give you a message?
when hovering?
nope
i used Spigot BuildTools to install that NMS stuff
if that matters
hoow about on compile?
yea xD
just click it and type package
still red :/
--- maven-compiler-plugin:3.3:compile (default-compile) @ LevelToWorldborder ---
[INFO] Nothing to compile - all classes are up to date
i guess thats a no?
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
i included this one
is that the right one?
well its building fine
so nothing to worry about
could be just a matter of restarting the ide
Does anyone know how to set an EndGateway's state if I have a block?
//places the blocks for the portal
public void placePortal(Block[] portalBlocks) {
//separate the blocks from the array
Block portalLowerBlock = portalBlocks[0];
Block portalTopBlock = portalBlocks[1];
//set block types to END_GATEWAY
portalLowerBlock.setType(Material.END_GATEWAY);
portalTopBlock.setType(Material.END_GATEWAY);
//set teleport location for the end gateway
//only used to listen to the event
* portalLowerBlock.setExactTeleport(true);
portalLowerBlock.setExitLocation(portalLowerBlock.getLocation().add(0, 3, 0)); *
}
those two lines don't work
Alright I've done this.. seems like it will work
EndGateway portalData;
portalData.setExactTeleport(true).setExitLocation(portalLowerBlock.getLocation().add(0, 3, 0));
portalLowerBlock.setBlockData(portalData.getBlockData());
You should be setting it to portalData
Currently you are just setting it to the data it already has
And you should be assigning getBlockData to portalData
setBlockData
Ah alright
How do I initialize portalData by the way?
I tried just doing EndGateway portalData = new EndGateway(); but it didn't like that
EndGateway portalData = (EndGateway) Material.END_GATEWAY.createBlockData();```
public void openSheepRecipeMenu(Player player) {
Inventory inventory = Bukkit.createInventory(null, InventoryType.DROPPER, CC.translate("&cS&6h&ee&2e&1p &5C&ao&3r&9e"));
ItemStack redWool = new ItemStack(Material.WOOL, 1, (short) 14);
ItemStack orangeWool = new ItemStack(Material.WOOL, 1, (short) 1);
ItemStack yellowWool = new ItemStack(Material.WOOL, 1, (short) 4);
ItemStack greenWool = new ItemStack(Material.WOOL, 1, (short) 13);
ItemStack blueWool = new ItemStack(Material.WOOL, 1, (short) 11);
ItemStack purpleWool = new ItemStack(Material.WOOL, 1, (short) 10);
ItemStack limeWool = new ItemStack(Material.WOOL, 1, (short) 5);
ItemStack cyanWool = new ItemStack(Material.WOOL, 1, (short) 9);
inventory.setItem(0, redWool);
inventory.setItem(1, orangeWool);
inventory.setItem(2, yellowWool);
inventory.setItem(3, greenWool);
inventory.setItem(5, blueWool);
inventory.setItem(6, purpleWool);
inventory.setItem(7, limeWool);
inventory.setItem(8, cyanWool);
inventory.setItem(4, sheepCore());
player.openInventory(inventory);
}
why are none of the items here setting?
That's a pretty bad way to do that
I know
But the code looks like it should work
I would double check that this method is being called properly
And try clicking in the inventory as the player
also < 1.13, so like how many years outdated
Also I would keep an array of ints and iterate over them rather than doing this madness
That too
ew SheepRecipeMenu().openSheepRecipeMenu(player);
The menu opens but nothing is inside it
could be a bug with custom dropper inventories in that version
This is good?
public boolean onCommand(CommandSender sender, Command comando, String label, String[] args) {
if (!(sender instanceof Player)) {
Bukkit.getConsoleSender().sendMessage(plugin.nombre+" no puedes ejecutar comandos desde la consola");
return false;
}else {
Player jugador = (Player) sender;
if (args.length > 0) {
if (args[0].equalsIgnoreCase("gallina")) {
FileConfiguration config = plugin.getConfig();
if (config.getConfigurationSection("Players").getKeys(false) != null) {
List<String> zombie = config.getStringList("Players.name");
for(int i=0;i<zombie.size();i++) {
}
return true;
}else {
jugador.sendMessage(ChatColor.RED+"Aun no hay top");
return true;
}
}
}
}
return true;
}
No
You can improve this in any number of ways
The simplest is with better code structure
You can do some early return, and you're already doing some
If you have a return in an if statement, you don't actually need an else
Since a return exits the function
Everything after the if statement becomes an implicit else
Also you probably want to return true after telling the console they can’t use the command
public boolean onCommand(CommandSender sender, Command comando, String label, String[] args) {
if (!(sender instanceof Player)) {
Bukkit.getConsoleSender().sendMessage(plugin.nombre+" no puedes ejecutar comandos desde la consola");
return true;
}
Player jugador = (Player) sender;
if (args.length == 0) {
return false;
}
if (args[0].equalsIgnoreCase("gallina")) {
FileConfiguration config = plugin.getConfig();
if (config.getConfigurationSection("Players").getKeys(false) == null) {
jugador.sendMessage(ChatColor.RED+"Aun no hay top");
return true;
}
List<String> zombie = config.getStringList("Players.name");
for(int i=0;i<zombie.size();i++) {
}
}
return true;
}```
Here
I've restructured your code a bit to make the structure better
Whenever you hit a condition that allows you to immediately exit the function, you should return early
That makes the flow of your code more linear, reducing the number of branches in it and making it easier to read
Also, doing commands this way is tedious and error-prone
Ideally you should use a library that adds layers of abstraction so that you don't have to worry about all the manual checks and conversions
I have one called RedCommands: https://github.com/Redempt/RedLib/wiki/Command-Manager
There's also ACF: https://github.com/aikar/commands
And CCF: https://github.com/Incendo/cloud
Take a look at these (or find more for yourself), figure out how they work, and pick one you like
A good command library will save you an immense amount of effort
oh lol, so you think this is easier to look? i think this is a little bit better heh
this i mean
my example
heyy, so im wondering if i can convert like, a colored String with Bukkit chatcolours, to a TextComponent
im kinda new to this ChatComponent stuff, and if i had to be honest the help page isnt very helpful as its rather outdated
...
you can scroll up a bit
like a few messages
yeah
what
just scroll up to see the answer lol
ohh
i just answer this a few hours ago
mm r u sure
because i cant find anything, maybe i scrolled too fast
are you talking about this
yes.
so thats not what im asking
you're talking about a Text
im asking about a TextComponent
im not sure they're the same thing, and i doubt they are if i cant use one in the HoverEvent, and not the other
ping me in a response)
learn component when...
im pretty sure component has a text method.
didnt care about the textcomponent tho. component still can use hoverevent so i dont really use textcomponent
i literally cannot understand you
what
what is that
is StringTextComponent a thing?? irdk if ur talking about a class, or what
well it literally there
fromlegacytext
hello???
you didnt read javadocs before asking?
i though i was on the forge cord
you didnt read my question before answering.. three times?
TextComponent != BaseComponent[]
helloooo
They still aren't the same
dawg
kinda??? im on phone rn, but i got the idea of the thread
let me better explain my question..
is it possible to convert a Bukkit coloured String (so things w/ ChatColor.GREEN from bukkit.ChatColor to a TextComponent
You would have to write your own system or use the string as is
i see
Since for the moment legacy color codes do still work
so riddle me this then
how should i gather the chatcolours of a String, and then convert them to Bungee colours
welp... i think my answer is not that obvious to tell you the thing you want then 😛
thanks for noticing just now
Why do you need to convert them? I'd just use Bungee colors in the first place
Also doesn't Bukkit color have asBungee method
i have a Rank enum that has prefixes, and im trying to make the chat hoverable w/ some stuff
Then this
so like, i think i do.. i have a TextStuff.formatProperly, that has HEX stuff
but tbch it returns a String
and im not sure if ima messs smt up
Just use legacy text it works for the momemt and you won't have to over think anything
alr, thanks for the help :)
Or you could take a look at Adventure it's quite neat
Anyone know why when I tried to compile cloned project from here https://github.com/FarisR99/KingKits, I get cannot access com.faris.kingkits.api.event error?
Actually there are 57 errors, and all of them is cannot access ... error.
The error log: https://paste.md-5.net/kuqimojiwa.sql
well that repo doesnt comtain a com.faris.kingkits.api
so im assuming theres another thing you need to dep[end on
its not included in the pom either
What? the code is all there
oh nvm im blind
i never got this error before
how can i make a drop confirmation? currently i have this but if i swap items between the confirmation, it still stores the old int
hello, i am wondering if someone with development experience could make or help me create a fairly simple plugin
!ask
.ask
how
Bruh
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
stonks
¯\_(ツ)_/¯
just do ```java
public void createHypixelSkyblock() {
Bukkit.getLogger().info("Hypixel SkyBlock has been created!")
}
then execute that method on enable
yes. and you have skyblock!
I don't know javascript !!!
🤣 Lmf
that isnt even javasciprt...
I wrote this on behalf of the person who asked
the one who asks for help with this
and people like them usually confuse java with javascript😐
I thought you would get the joke ..
i thought you would say oh i forgot that is not java script it is python...
I don't know the syntax is too different
Better pascal
basically im wondering if anyone would know how to configure a plugin where you start with 1 heart and gain 1 everytime you die, once you've hit 10 hearts you're banned for 1-2 days and your balance, enderchest and homes are reset
moment
the moment of truth...
when he finally say what he is asking for...
👌
She
oh lol
asian moment
stalker
pls donate towards me and josie buying a minecrafr server
yes pls 🙏
...
Well, what has someone donated to you?
nothing yet 💔
How old are you
im 16
where do I put the permissions.yml and how do I use it?
this is not help server channel.
in my plugin
nah
working-with-configurations-file
i think this is the tag
there is a small wiki
with that tag
go search it and put spigot last
got it
so I just put it in the resources folder and call it permissions.yml?
and then the p.hasPermission() just takes from that file or is there more to it
figure it yourself is a better way while waiting for answer
why i can't use this https://cdn.discordapp.com/attachments/871420093937123379/908337799118323763/unknown.png
help
i want to solve it
i need to solve it
this isnot help server channel.
dev channel only.
this is from worldguard
how to solve it
Ask it in #help-server
where is the dev channel
this.
is there a way to check if an item is a pick,axe,shovel,or hoe?
me ?
no, just so you know this channel is for creating plugins only
make sure you have the itemstack
then just compare the item name
it should suggest you the name if you type pick in intellij
alright, ill upload this code to intellij then, it was broken yesterday when I was working on a plugin
names can be changed, check its Material#name() for .contains("_PICKAXE")
Thats what I was thinking so its itemstack.gettype().contains(blah)
getType().name()
dam I was close lmao
isnt there a Tag for pickaxes?
no
Will InventoryClickEvent fired when player click on their own inventory?
Yuh
great
Me making an enumset for swords...
how can I get the item in the players main hand in the BlockBreakEvent?
I tried e.getPlayer().getInventory().getItemInMainHand(); but it keeps returning air even though I obviously have a pick in my hand
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (player.getInventory().getBoots() == null) return;
if (player.getInventory().getBoots().equals(rocketBoots())) {
player.setAllowFlight(true);
} else {
player.setAllowFlight(false);
player.setFlying(false);
}
Can someone please tell me wtf is wrong with this. After they take the boots off they can still fly.
I dont understand
Disable fly if the boots is null too.
you didnt do anything there
well, you can use armorequipevent or something like that
check if they have permissions to fly or are in gamemode
and if they are dont disable it
I'll figure out a way to check for it
but yeah ur right
it works if they have smth
in your code, if player equip the rocket boots, they able to fly, but if they take off the boots they still can fly because you didnt do anything there
yeah makes sense
yeah, armor equip event would be best for what your trying to do
I couldn't find it unless I'm just blind
yeah it's not exist on spigot api
paper?
paper api has it
or you can use this if youre using spigot https://www.spigotmc.org/resources/lib-armorequipevent.5478/
ok I'll move it to paper
tried it
the only other way I can think of doing it in spigot is checking inventory click event and checking on click if they have boots on, should cover both putting on the boots and taking them off via right clicking outside the gui or adding them on inside
but thats more work than switching to paper
anyway any reason why this wouldnt work?
Its because I didn't declare an API version
for anyone wondering the same thing
How can I achieve pagination inventory from a list of itemstack?
Well, there's no ready solution with spigot api. You break down the list into part each 36 elements (inventory size - 9). Then, build an inventory. Do a for loop i < 36
inventory.setItem(i)
and then, add next/previous button and listen for them
on next button, just cleear the inventory and set the content of the next part
I'm having a hard time keeping track of the showed item and what will be the previous page item and next page item.
store the page index somewhere
?paste
Thats how i did it
Thanks for the reference but I'll try to make it by myself first, and here's what I got right now. https://paste.md-5.net/iyeberomoc.java
Why map? Cant you Just use a 2d list?
It's easier I guess, and I'm more comfortable using it.
Is a WeakHashMap<> good for cache or should i use Google's cache builder?
Its good if you HAVE to use something like a Player as a key
how to check in what world is player?
player#getWorld()
Im using a class which holds a player and some chatchannellists
Like I want to create plugin what will give you an slow falling plugin when player is in the end
How to do it?
Why is this not working?
public ShapedRecipe rocketBootsRecipe() {
ShapedRecipe boots = new ShapedRecipe(rocketBoots());
boots.shape("SSS",
"I I",
"* *");
boots.setIngredient('S', Material.NETHER_STAR);
boots.setIngredient('I', Material.IRON_BLOCK, 32);
boots.setIngredient('*', Material.FIREWORK, 64);
return boots;
}
getServer().addRecipe(new RocketBoots().rocketBootsRecipe());
What IDE do you know how to use?
Intellij
I know how to create plugin
Use the scheduler to every x amount of ticks and then loop all players. Check the world and then apply effect
bot how to check the world
.
You are using a deprecated method, and the int value is not a quantity as you think
Quantities don't work in ingredients
Do I need to make an itemstack and then use that?
you can not specify the amount
^
Use the PrepareCrafting event or whatever and implement your own system
you would have to monitor the pre craft event and check quantities
oh I cba with that I'll just make an item that requires multiple iron blocks in one
and require that custom item
assuming thats possible
public ShapedRecipe rocketBootsRecipe() {
ShapedRecipe boots = new ShapedRecipe(rocketBoots());
boots.shape("SSS",
"I I",
"* *");
boots.setIngredient('S', Material.NETHER_STAR);
boots.setIngredient('I', Material.IRON_BLOCK);
boots.setIngredient('*', Material.FIREWORK);
return boots;
}
this still isn't working?
have you given the recipe to anyone?
player.discoverRecipe(recipe)
ye they should have the recipe
and you did Bukkit.addRecipe(recipe);
omfg im so dumb lmfao, I made a method to register recipes but didn't get an instance of that method
I encountered a weird problem, the value on the map is somehow changed itself. As you can see on the debug, the first and second page have size of 20 but when I try to check it again after the iteration, the size is only 10.
Code: https://paste.md-5.net/owezebunit.cs
Debug: https://paste.md-5.net/arepudovej.md
Java works mainly with references to objects
When adding a list as a value to a map like this you are basically just handing the map a pointer to that list
oh wtf
You are the later modifying that same list
so i'm putting the same List to the map?
Pretty much yea, just create a new list instance each iteration
ah it works, thank you so much
my brain was ready to explode
finally i got my pagination inventory working
i'm getting an npr when trying to get Bukkit.getPlayer(args[0]) when clicking on space after the command name
Hi!
If i have a permission maxamount.1, how can I get the number without knowing what numbers you can be faced to?
i use bungeecord
Thanks
Are you using a permissions plugin?
should i run Bukkit.getOfflinePlayer(string) async as it performs a blocking web lookup?
Yes
and if a player == null, will Bukkit.getOnlinePlayers().contains(that player) always return false?
it just a player object rn
ah oke
Hi i'm writing on a plugin with the requirement that i can place blocks at 60 replacements per second..
I'm making a display/screen, and im wondering if i can go above 20fps
i'm struggling to find anything above 20fps, as the spigot servers run at 20TPS, so my guess is im stuck at 20 changes on 1 block per second?
I think i could run it faster at the server side, but then the TPS would just check for the state at 20 ticks per second?
Can i manually send block updates to increase the TPS for blocks only? or for a certain area of blocks?
honestly, I'd even take 30fps, anything above 20 will be a win for me.
screw safety
Threads 😼
You can send packets in your own thread which can use ms instead of ticks.
i thought world changes were impossible using threads?
Yes but you can send world changes slowly while packets are semi instant (depending how its coded)
possibly? if theres some kind of context check maybe but idk
hmm.. for some context, the plugin im writing is a wack idea of making a computer, we got a cpu going, next is the gpu. Obviously we want a screen for it,
everything is stored in block form, wool for 1's, glass for 0's, basically, as much as possible in world so its visual...
Same way the screen should be an actual thing we can write to
Yeah just use nms and packets in a thread. Only lag should be the players fps ;)
I don't do threads @sweet helm
sorry, didn't want to have multiple convo's at once in one chat
but alright
So basiclly, i can do as many changes as i want server side, the TPS throttles this to 20 something and thus the world changes are slow to the player,
but if i just send the packets ahead when i change the block, the player should be receiving the blocks as quickly as the server can generate them?
i mean if thats the case.... i can smell burning plastic already
please confirm? 😅
Create a thread and send all block updates to your thread. You can change all blocks for a player at any ms.
how can i get the command args to a string?
Arrays.asString adds [] iirc
prob stringbuilder then
String.join
oh forgot that that existed, thanks
What is wrong with this? I haven't done a crazy amount of work with custom crafts
public ShapedRecipe rocketBootsRecipe() {
ShapedRecipe boots = new ShapedRecipe(rocketBoots());
boots.shape(" ",
"SSS",
"* *");
boots.setIngredient('S', Material.AIR);
return boots;
}
@EventHandler
public void recipe(PrepareItemCraftEvent event) {
if(event.getRecipe().equals(rocketBootsRecipe())){
if (event.getInventory().getMatrix()[6].equals(rocketCore())
&& event.getInventory().getMatrix()[8].equals(rocketCore())) {
event.getInventory().setResult(rocketBoots());
}
}
}
probs using equals on itemstacks
I highly doubt that would fix it but I can try
doesn't work
this also wont help
the issue is with checking, pdc would just make sure that its the right item
Any errors? What do you mean by "doesnt work" ?
It doesn't make the craft
and no there are no errors
Well, do some debug. Log every step and see what happens
The event isn't even firing
why are you doing " " and then "SSS" and * is nothing?
copy and paste some tutorial first
chgeck if it works and start editing it from there
clearly you do lmao
and the 3 spaces are for formating
and stars are from an old thing I had
Hello guys,
Today I want to show you how to add some custom recipes in to your Minecraft server. Custom recipes add a lot of uniqueness to your server,...
read that
is there any way i can decrease the amount of reccomendations? because whenever i write a method it sometimes seems to just overlap and i dont see what im writing
intelij btw
I know that you can disable that feature
is this correct english: the player is not in any channels!
would an exactChoice do you better?
are you trying to make the crafting recipe take your special items?
yes
No, it's not supported on this version
oh ok then. what version would that be?
1.12.2
It was added in 1.13.2
aight
reject legacy
?
reject humanity
if a player doesnt have permission to use a command, will a tabcomplete with options be triggered?
can someone help me testing my plugin?
you shouldnt disable this
try to use it, it can be really useful if you understand how it works
hm?
i think not
xd
what's funny
i was testing my plugin on my server with an alt and now they removed that altmanager :pepe:
i used to do that too
whats the plugin about?
jailstick
anime girls
well you can simulate a player
instead of "sending the player to jail" you could try to imagine and follow the steps you are doing
and add a command to trigger the event
so you can test it on yourself
basically you test the first part and then the second with a command
How can i add an suffix to a players name with teams and scoreboards?
np
version? current code? example?
in the 1.17.1
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
Team team = scoreboard.registerNewTeam("Ducks");
team.setColor(ChatColor.RED);
team.setPrefix("[Hi]");
if (sender instanceof Player) {
Player p = (Player) sender;
team.addEntry(p.getName());
team.addPlayer(p);
p.sendMessage("Added you to an team!");
}
return false;
}
and that doesnt work?
team.setSuffix?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scoreboard/Team.html#setSuffix(java.lang.String)
declaration: package: org.bukkit.scoreboard, interface: Team
docs?
no i don't become a suffix or a prefix it just don't change anything
do i need to set permissions in my plugin.yml if i create them within my code?
how to set skins without leaving the server in 1.17+?
I've seen some plugins where they don't define any permissions in the plugin.yml, they just check for them in the code. I wanna know, how much does...
wdym
where are you trying to set the prefix
do you know skin restorer ?
sry just tryed something
ohk
uh no
But it don't work with suffix too
I say you should have them in your plugin.yml so luckperms can tab complete them
i want to do something like that: /skin set <Player name> and the skin will be set to command sender without leaving server
isint there like a bunch of plugin to do that?
dont reply if u want to answer like that man
lmao
im learning config.yml file. when i try to get it from other then the main class, it doesnt work. can anyone help me?
Is there a way to set and get metadata for the itemstack?
itemstack.getItemMeta()
ItemMeta you mean?
nbt?
probably
Isn't it possible to do it using this: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/metadata/FixedMetadataValue.html
?
i guess thats dutch
no errors
package Commands;
import org.bukkit.plugin.Plugin;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import alma.Tanulas;
public class ConfigTestCommands implements CommandExecutor{
Plugin plugin = (Plugin) Tanulas.getPlugin(Tanulas.class);
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName() == "ConfigFood") {
String food = plugin.getConfig().getString("Food");
Player player = (Player) sender;
player.sendMessage(food);
}
return true;
}
}
whats that
what the hell
your stuff here
how is your project set up bro?
is there no codeblock tag or something?
?
like ? paste
this?
nvm
you can make it a codeblock by following the picture sent above
kinda just put java after the backticks
this is a codeblock
hr
you need to get config from an instance of your main class
?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
they are
actually maybe not
i gtg i look into that anothr tim, thanks
hmm (Plugin) and the static singleton goes brr
true
what is the problem?
java.lang.NoSuchMethodError:
but this method exitsts
there is #getPlayer and #getEntity
or tell me what mehod i need when i want to get the Player out of the PlayerDeathEvent?
uhh getPlayer() probably
Did you replace your plugin jar while the server was running?
yes
and then i shutted the server dfown
i did
Oh, so to clarify, during the run of that log you did not replace your plugin jar?
no
Im not too sure then
normally you cant replace the server jar when running?
you can not
there's a lock on it
Not the server jar, the plugin jar
impossible
uhh i mean the plugin jar
well you can unload the plugin and load it again
BileTools does this
i mean i drag the jar in and then i restart the server
You can replace the plugin jar while the server is running, you just cant delete it
self disabling you mean?
Just make sure to reload or restart the server
BileTools makes it faster ^^, on linux it is only dragn drop, no reload or restart even required
BileTools disabled other plugins or enables them
ah that way
How it works on Windows:
/b unload (plugin)
Replace plugin in directory
/b load (plugin)
On Linux:
Replace plugin with new plugin
BileTools automatically reloads it
cool tho
windows can not remove active files, caused by the NTFS file system (it sucks, ik)
ZFS would be cool on windows
can you stagger permissions like you do in a config or do you have to make the perm path as one line?
permissions:
plugin:
oneSection:
onePermission:
description:
default:
this is what i mean by staggering
But it can replace
not active files
Yes it can haha
"this file is currently being used by process ..."
replacing does work
I do it very frequently for plugin jars while the server is still running
Windows lets me do it with no problems
it would be very infuriating testing plugins when you have to restart the server every time you wanna give it a new version
Reload?
nope
first it asks for admin perms
then this
i mean if you had to stop the server to give it a newversion
it wont let you
Are you trying to replace the entire plugins folder? Or just the jar in it
only a single jar lol
Oh thats odd, it lets me do that without asking
i found the issue.. thanks for help
I mean I changed a lot of stuff in my windows build (and I have win 11) so idk if I changed something important regarding that by accident
Take new build > Replace old > Reload > Ez
is your old build loaded at that time?
in Linux terminal: kill 1
Yeah, the server is running with the old plugin loaded
odd
Buuut, without reloading you get alot of no such method errors
only use BileTools
I dont need to, it should be the same
Im a bit confused as to what you're trying to do
make a RunTaskAsynchronously with a RunTaskTimer that starts in a newly defined random delay
the RunTaskAsynchronously runs every tick, but checks if RunTaskTimer is active
by getting its taskid
If you're doing it async and not looking to do any main thread operations you should be fine
I mean, in most of cases you would just do a single check only
even on main thread this is nothing
^
You're attempting to run the task again while inside of itself, its not gonna let you do that
It’s not as simple, doing stuff async requires you to properly implement whatever you do thread safely which is a pain since it’s hard to test thus hard to know if you’ve done it correctly.
Yes it was just easier to say haha
Also starting a thread is an expensive operation
Yeah although you can have something like a work stealing pool
Is this a proper permissions setup in the plugin.yml or do I have to make every permission with the whole path in front?
permissions:
plugin:
oneSection:
onePermission:
description:
default:
secondPermission:
description:
default:
secondSection:
thirdPermission:
description:
default:
just check for permissions in your command executor .-.
Once again, you should still have them in your plugin.yml so luckperms can tab complete them
Among other things
They want to make the permissions editable by server owners
then thats even easier
player.hasPermission(getString("permissions.admin"))
top of my every command
getString is a method to get a string from the config
I believe they're just trying to look for a userfriendly way to edit it, not how to actually do it
this is user friendly
Not really sure why you’d need to make permissions editable
Im not sure either LOL
some plugins have custom commands
Im developing a plugin and have never done permissions before so I want to be able to check in my code wether or not the server owner has given the player the necessary permission
Ohhhhhhh, so you do just want to check if a player has a permission?
And thats all?
yeah Im just getting confused doing it myself. pls halp
Player#hasPermission
Location loc = player.getLocation();
scheduler.runTaskTimer(myPlugin, task -> {
if(loc != player.getLocation()) {
sender.sendMessage(getString("messages.tp.cancel"));
teleporting.remove(player.getUniqueId());
task.cancel();
return;
}
}, 0L, 20L);
Why does this cancel immediately?
Im trying to get the permissions in the plugin.yml set up
even if I dont move
Pitch or yaw might be making a difference?
nope 100% not
why do you return? lol
i am not touching my keyboard
theres more below, i removed it for this chat
ah okay
but why does it cancel immediately
you are comparign two Location objects with !=
Are locations referentially comparable?
should be
you will also have it randomly cancel due to FP math rounding errors
player.getLocation returns a clone
also, a location only has world, x, y and z
No I believe it returns the players active location
Location tp = new Location(world, telX, telY, telZ);
try it
on any objects you should use equals unless you need to check if its exact instance
Location has pitch and yaw
It still has a field for pitch and yaw
why tf doesnt it show then wtf
It returns a clone
it has multiple constructors
Im like 99% sure that the javadocs do say clone but the object is the players live location
I might be misremembering
well
its just an api object to provide necessary context of the players current location when invoked
If it wasn’t a clone mutating it would move the player
I am just gonna round to the nearest .2
Don;t compare Locations with !=, don;t even compare them using .equals. As they have doubles, you will rarely ever match two locations. Compare teh getBlockX() etc.
Yes but the locations pitch yaw, and world coords should change with the player
not accurate enough tho
no it doesnt
Then nevermind
if you cache the Location instance of Entity::getLocation it wont be automatically updated sadly
then compare the doubles, but round yourself.
yeah i did that now
Does anyone know why this piece of code doesn't enchant the item? I can't seem to solve this ```java
toggle = true;
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
player.sendMessage("Left Click");
// Define values
ItemStack item = new ItemStack(inHand);
ItemMeta meta = item.getItemMeta();
if (toggle = true) {
// Add glow to item in main hand
item.addUnsafeEnchantment(Enchantment.WATER_WORKER, 1);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
} else {
// Remove glow from main hand
item.removeEnchantment(Enchantment.WATER_WORKER);
meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
}
}```
You have a meta instance, use the add enchant method in that
^
How do I cancel a task after it ran x amount of times?
if (toggle = true) {
count
Count the amount of times its ran?
will always be true
cant use ints in it
yes you can
Why not?
Why so
I used unsafeenchant because I'm trying to enchant a shield with aqua infinity
lemme show u what i mean
The meta will allow you to add the enchant the same way
use a BukkitRunnable and put the int outside the run method
The meta method has a Boolean to bypass enchantment restrictions
Yes make sure to do that haha
anyone?
Can I see the whole snip?
use a BukkitRunnable or make it final
final int delay = getInt("values.delay");
scheduler.runTaskTimerAsynchronously(myPlugin, task -> {
double ssX = Math.round(player.getLocation().getX() * 10) / 10D;
double ssY = Math.round(player.getLocation().getY() * 10) / 10D;
double ssZ = Math.round(player.getLocation().getZ() * 10) / 10D;
Location sLoc = new Location(player.getWorld(), ssX, ssY, ssZ);
if(!loc.equals(sLoc)) {
sender.sendMessage(getString("messages.tp.cancel"));
teleporting.remove(player.getUniqueId());
task.cancel();
return;
}
if(delay == 0) {
sender.sendMessage(getString("messages.tp.successful"));
player.teleport(tp);
teleporting.remove(player.getUniqueId());
task.cancel();
return;
}
sender.sendMessage(getString("messages.tp.time").replace("%time%", "" + delay));
delay -= 1;
}, 0L, 20L);
making it final prevents modification
You gotta use the non lambda version
Hello, I tried my plugin in 1.7.10 and it's working fine but in 1.17 it crash whre the plugin needs to send a command in the console given in a post request here is my crash:
I am using Bukkit.dispatchCommand
prevents re assignment
Yeppers
unless atomic
i tried atomic
use a BukkitRunnable
kk one sec
I cant find a proper documentation, do you have one on this ?
cant reference that from a static context
?
You can store a runnable in a task
new BukkitRunnable
because i cant call event.getRecipients do i need to switch from async chat event to chat event?
Why can’t you call it
Caused by: java.lang.IllegalStateException: Asynchronous getNearbyEntities!
thats not from getRecipients
ah uh my mistake i also call that somewhere
You need to sync back to the main thread for that stuff
does EntityDamageEvent#getDamage() return the value in hearts or health?
Don’t force the chat event to run sync
Health
Health, max 20 (By the default of a player)
thanks
oh ok
I mean it can probably be over 20
so scheduler.runtask
Yeah I rushed to clarify LOL
ig he said it to be more clear
BukkitRunnable performed every 1 tick, where I send the packet to players is a heavy load on the server?
no
unless it's a 1GB packet i don't see how it could be that heavy
how do I cancel the runTaskTimer from within the Runnable?
cancel()
this.cancel()
both server and client send and recieve many more than a packet per tick so it won't be an issue
A tick is much shorter than a minute
cool, but now I still have the same problem of not being able to modify the integer
Anyway if it’s just packets you can probably run it async
define the integer inside teh runnable, outsdide the run method
ok
player movements by themselves are sent about 80 times per second aren't they
thanks
I think tick rules still apply
i Wonder if sending packets async is actually useful
afaik playermoveevent is called multiple times per tick so
yuh
probably many packets per tick are too for movement
Arent they got queued by netty*
Saves a bit of load on the main thead
¯_(ツ)_/¯
thanxolotl, now it works fine
Anyone knows how to turn my name in chat red?
player.setDisplayName(ChatColor.RED + player.getName());
do u use Essentials?
Im using a Chatplugin but it goes brr and i couldn't remove the color so that's why
Hello, I am making a new BukkitRunnable and in my run methode I have Bukkit.dispatchCommand and when this is executed the plugin crash and I have this error:
Your runnable is async
at the end I have .runTaskAsynchronously(main.plugin);
you have to jump back to sync to use the API
where main.plugin is the class where I have JavaPLugin
and How do I do that 😅
plugin.getServer().getScheduler().runTask(plugin, () -> { Bukkit.dispatchCommand(player, "command"); } );```
actually the space after area is the first args
no
yes, tabcompleter does not include the command
yes, as soon as you press space, your length is 1
but as you havn;t typed anything yet it will be an empty string
So I need to do this?
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
List<String> lis = new ArrayList<>();
if (args.length == 1) {
lis.add("new");
lis.add("remove");
lis.add("set");
lis.add("add");
lis.add("info");
} else if (args.length == 4) {
lis.add("owner");
lis.add("coowner");
}
return lis;
}
run after plugins have loaded
It's working THANK YOU !
How can I check if a player right or left clicked while interacting with an entity?
hello i have problems with hikaricp
public void connectMySQL() {
String host = getConfig().getString("mysql.host");
int port = getConfig().getInt("mysql.port");
String database = getConfig().getString("mysql.database");
String username = getConfig().getString("mysql.username");
String password = getConfig().getString("mysql.password");
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(10);
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.setJdbcUrl("jdbc:mysql://" +
host + ":" + port + "/" + database + "?useSSL=false");
config.setUsername(username);
config.setPassword(password);
hikari = new HikariDataSource(config);
}
21:47:10 WARN]: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
what is wrong
public Connection getConnection() {
try {
return hikari.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
I don’t think it is a class
Maybe the Creeper class has a method to get the creeper’s state
Or you can just spawn a creeper and spawn a lightning at its location
im here to ask for help with setting up a work envioment in VScode for making plugins
this is as far as ive come
https://cdn.discordapp.com/attachments/458957565431250965/908786177161699359/unknown.png
You should move to intellij
Since in intellij you can download a plugin that will set up your environment for plugins
vs isn't good for java at all kek
oof im kinda new to java ive tried Python and Js before
final ItemStack bloodMoonBoots = addLore(new ItemStack(Material.LEATHER_BOOTS), "BloodMoon Boots", cool);```
how do i recreate this line to be unbreakable
how can i add a scoreboard to multiple players?
thats fine
/scoreboard add *something* dummy *something*
altho java quite enforces oo as opposed to the other two
oh
can anyone help me ?
its very minimal
can you send your class or smtng?
and how you use it
but the exception hints at your db not being reachable at all
maybe passed the wrong credentials etc
final ItemStack bloodMoonBoots = addLore(new ItemStack(Material.LEATHER_BOOTS), "BloodMoon Boots", cool);```
how do i recreate this line to be unbreakable
?paste
am i young padawan
meta.setUnbreakable
thank you
Lasse333 making a plugin
Hi
I want to know how does Bungeecord or Spigot event system works. Like how it manage the events calling?
why am i getting these errors? can anyone help?
Logger logger = plugin.getLogger();
