#help-development
1 messages · Page 1728 of 1
PersistentDataContainer on entities is stored even past restarts, correct?
Main difference I notice is that the first one specifies the encoding, though I'm not sure what the default is
Also sets the default config data to a config.yml that was stored inside the jar
sure, that's why it's called Persistent
Also is there any way to set the lifetime of a vex? I'm trying to replace the vexes summoned by a specific evoker, but they end up not automatically dying and don't follow what the evoker attacks.
A good method for finding the vexes that were summoned would work too, but I haven't been able to find that either
i am quite new, so i wanted to ask a quick question, i am using player heads in my gui of my plugin and i want to use "skinrestorer plugin" to set player skins and use its code a bit to use player head of those skins in my code....
So i wanted to ask was, how can i link that plugin code with mine? and how do i use it...like yea
do it have api?
try searching for its api
ohhh wait i will try
What are you trying to do?
ok so
can i use skinrestorer plugin as a api? i am making a plugin and i want to use this plugin to get custom heads, for example, i set my skin, and i use a command from my plugin, which opens a "gui" having my player head of the skin that i set...
🇬 radle vs 🇲 aven ?
what?
Depends on what you want to do. Gradle is good at handeling a lot of sub modules but maven is easier to setup for a simple project
I usually use maven so that's what I will put in your poll
i dont mind which one i use, but im more familiar with maven so thats what im voting for
I don't like gradle, their servers are so slow... it takes a like a minute to download a 100mb wrapper
i vote for those 2
i wonder if i can stream some mc monke version pvp here
oh wrong channel
sorry
Wat
Sounds like a you problem
nah I got 1Gbit/s, steam downloads with 125MB/s, it's only so slow when gradle downloads its wrapper everytime I clone a repo
maybe their peering to germany is just shit, no idea
Takes like 2 seconds for me
Can someone tell me why this method cant read these strings and add them to my set of materials?
public void loadNPCStartup() {
FileConfiguration file = gameManager.getGame().getConfig();
file.getConfigurationSection("world.breakAbleBlocks").getKeys(false).forEach(material -> {
allowBreak.add(Material.getMaterial(material));
});
}
world:
breakAbleBlocks:
1: dirt_block
2: grass_block
What happens when you run that
^yeah what's the debug
the arraylist is [null]
its just plain empty
Check for typos
well i checked, no typos should be there
Does it read from the right config
yea theres only 1
you're calling #getMaterial("1")
not #getMaterial("dirt_block")
so ye it returns null
but it should get me the things behind the 1:
no it shouldnt
How did I miss that :c
:8
that's not what u did in ur code
well and how would one fix this problem?
Get the value with the key
okay ;7
ConfigurationSection section = ...;
for (String key : section.getKeys(false)) {
String value = section.getString(key);
// Optional null handling
/* Code */
}
alternatively, you just use a list
cos you're not using the keys anyways
my-section:
- diamond
- emerald
I was just going to ask that as well... is there any reason you're not using a YAML list?
Hey Guys
I would like to create a quest plugin where admins can spawn a "Quest Villager". When a player right clicks on it, I want a custom inventory to open. This all works but now comes the problem. With the function on right click event I check if the villager has the custom name "test", if this is the case the inventory should be opened. But now it is so that the players can create nametags and assign them to other villagers. But i only want to get into this menu if the villager is created by a developer. Is there any solution for this?
persistant data
for 1.14+ i think
hello
im editing an item with packets
but when i open an inventory using openInventory the inventory is updated
and the item back to the original item
1.17
https://paste.md-5.net/ujoropemem.css
Please tell me what's wrong 😂
as @quaint mantle said, use PersistentDataContainer to save a custom value on the entity
love pdc <3
how can i check against what block a specific block is placed?
ok thanks
I second this, and my internet is pretty good.
it's one of the main problems I have with Wrapper tbh
Does anyone know how I can remove 1 of a specific item from a player's inventory?
yes
well you didnt ask how before this message
I was gonna help
I dont want your help
ok
someone else please
fuck sake
I tried item.setAmount(item.getAmount() - 1); but there's a problem with that
if item is null, you have a problem yeah
If that item is a clone, you might have to set it on the inventory
Generally give code, what you tried, what works, what doesn't
So people have context
that does work
just did it the exact same way 5 minutes agao^^
public static boolean checkForAndRemoveOneItem(String itemId, PlayerInventory inventory) {
for(int i = 0; i < inventory.getSize(); i++) {
ItemStack item = inventory.getItem(i);
if(item == null || item.getType() == Material.AIR || item.getAmount() == 0) continue;
if(PDCUtils.has(item,"token", PersistentDataType.STRING)) {
if(PDCUtils.get(item, "token", PersistentDataType.STRING).equals(itemId)) {
item.setAmount(item.getAmount() - 1);
inventory.setItem(i, item);
return true;
}
}
}
return false;
}
If I do it with unstackable items (like a trident or a potion) it removes all of them from my inventory while I just want one removed
Read above ^
You're probably calling remove(item)
my code does exactly what you are looking for
no i'm doing it the way you guys are doing
I'll try it out yeah.
Yeah but you're looping through the inventory
consider breaking out of the loop if you're doing so
what do you mean?
yes
He's looping through all slots and checking if it's a trident
but after removing he keeps going
aaah I thought you were talking about the code I sent
Instead of calling break; or return;
hey everyone! how's your day going?
i am in need of help with nbt. i'm trying to make a placeable building item with spigot api, but i do not know how.
if someone could help that would be really nice. thank you!
Yeah all I had to do was just put a break; and check if the item is not null
tysm for the help
How do I play a sound to a player?
Cannot resolve symbol 'ANVIL_LAND'
player.playSound(player.getLocation(), Sound.ANVIL_LAND, 500.0f, 1.0f);
nvm, now it fixed itself when i tabbed org.bukkit.Sound
anyone know how to share a link and have it scroll to a certain point on the page? i have a question about a code in this tutorial https://www.spigotmc.org/wiki/connecting-to-databases-mysql/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
but i don't know how to specify the code lol
You can't really, the best you can do is add #wikiContent at the end of the URL and it'll scroll to that
But it seems like all the titles are within that, so you can't scroll to them
You config will contain something like this:
Code (YAML):// <<<< which yml file is this?
database:
host: localhost # host of your database
port: 3306 # default port for MariaDB and MySQL
database: db # name of your database. A database server can contain multiple databases
user: username
password: passy
Now we need to configure our DataSource. Both DataSources provide the same methods:
Code (Java):
Database database = config.getDatabase();//<<<HERE
// we set out credentials
dataSource.setServerName(database.getHost());
dataSource.setPortNumber(database.getPort());
dataSource.setDatabaseName(database.getDatabase());
dataSource.setUser(database.getUser());
dataSource.setPassword(database.getPassword());```
where is this Database class from?
is this config.yml file the auto generated one you create when you use config.addDefault(path: , value: )
How can I get the NamespacedKey of a recipe?
Bukkit.recipeIterator returns an Iterator<Recipe> but in order to unregister that recipe I need the recipe's NamespacedKey
You need to check and cast to keyed
me thinks its a hikari config
why doesn't this work:
@EventHandler
public void playerChat(AsyncPlayerChatEvent e) {
String rawMsg = e.getMessage();
for (String i : bannedWords) {
rawMsg = rawMsg.replaceAll("(?i)" + i, "");
}
if (e.getPlayer().hasPermission("donator.minecraft")) {
rawMsg = rawMsg.replaceAll("(?i):shrug:", "¯\\\\_(ツ)_/¯");
}
String msg = e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + rawMsg;
e.setFormat(msg);
dBot.playerMessageSent(e.getMessage(), e.getPlayer().getDisplayName());
}
the banned words part that is
anybody know why if i execute a command, instead of executing it, it sends a message in chat of what command i executed?
screenshot of example?
is there an event for whenever someone uses glowstone or their hand on a respawn anchor?
i executed /etp and this happens
I’m returning true
I don’t have a return false statement in my code
1 sec I’ll Send
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)){ return true; }
Player player = (Player) sender;
if(command.getName().equalsIgnoreCase("etp")) {
Player target = Bukkit.getServer().getPlayer(args[0]);
if(target!=null){
Location targetLoc = target.getLocation();
player.teleport(targetLoc);
player.sendMessage("[ExpressTP] You have been teleported to " + target.getDisplayName());
} else if (target == null) {
player.sendMessage("[ExpressTP] This player is offline!" + ChatColor.RED);
}
}
return true;
}
did you update your jar?
yes
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
check what block was clicked & what the item used to click was for respawn anchor & glowstone
hello
o/
im using protrocollib to intercept some packets
specifaclly
the setslot, entitymetadata and entityequipament
?paste
in 1.16, when a player joins, the server sends a setslot packet
to every single item in his inventory
but in 1.17 the packet is not sent
can someone tell me why this code is lagging/crashing the server
https://paste.md-5.net/efirovuwuw.cs
trying to make a black hole thing
i want to know how could i intercept the inventory packet sent when a player jpoins
just do a PlayerJoinEvent and then event.getPlayer().getInventory() or smth
lol i just thought of something
what if u cancel the join event
did not worked
error?
guys
thx
when editing the bukkit helpmap is more pain than adding the command manually
helpmap api should change, maybe sometime i'll do pr for it
basically you cannot add helptopics to indexhelptopic
only set new collection
which sucks
why would i create a new object
for no reason
and guess what sucks more
you cannot get the indexhelptopic collection
good luck appending new information to indexhelptopic
you can use reflections
sure
but its a fucking bukkit api
not OBC
or NMS
you can use initializeCommands()
but it adds overhead
it basically refreshes all the topics of the helpmap
SELECT *, CAST(JSON_EXTRACT(stats, '$.points') AS UNSIGNED INTEGER) AS points, RANK() OVER(ORDER BY points DESC) AS ranking FROM Cookies_LT someone knows, why there's an error at "ranking"? phpmyadmin says, the field points doesn't exist.
But if I execute the query, only with the JSON_EXTRACT, everything's working.
with another database server, there aren't any problems...
[17:43:59] [Thread-6/WARN]: at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
[17:43:59] [Thread-6/WARN]: at java.util.ArrayList$Itr.next(Unknown Source)
[17:43:59] [Thread-6/WARN]: at vinnydgf.grenade.Grenade.stepSimulation(Grenade.java:236)
[17:43:59] [Thread-6/WARN]: at vinnydgf.grenade.bukkit.scheduler.TPS_60.update(TPS_60.java:37)
[17:43:59] [Thread-6/WARN]: at vinnydgf.grenade.bukkit.scheduler.TPS_60.run(TPS_60.java:23)```
https://paste.md-5.net/egikahubex.cs where is the problem and how i can fix it
is there a way to make it so falling blocks always snap to a block where they can go so that the block is always placed
I'm going to guess it.kill() also removes it from your collection
lol i have no idea why i just made a thred i thought id just give it a try
so whatever anyone got an idea how to do it
how can i paste a schematic using fastasync worldedit api? i cant find anything on it, only worldedit, and the worldedit stuff doesnt work just gives me errors
worldedit api works fine for me
alot of the stuff is showing up as red like Cannot resolve symbol 'MCEditSchematicFormat'
^ and Cannot resolve constructor 'EditSession(com.sk89q.worldedit.bukkit.BukkitWorld, int)' Cannot resolve symbol 'CuboidClipboard' Cannot resolve method 'paste(com.sk89q.worldedit.EditSession, org.bukkit.util.Vector, boolean)'
?
How can i set actionbar position and duration without an API ?
Pretty sure you cannot set the duration. You can however send an empty actionbar after a certain duration or just keep repeating it
You cannot change the position either.
i mean, the position of the messages
for example, one in the right of the action bar and the other in the left
i want to set messages in the parameters of the action bar
but changing the position of different texts inside the action bar
There is only one actionbar. You can send a message that is like: LEFT STAT HERE RIGHT STAT and that would cound as left and right of it
ok, ty!
show us the line 37 and 23
Hey, so basically I made a shop were there are multiple items but I can only buy one of each, what would be the best way to put a number of item selector, so the player can buy multiple items at a time? I already tried making another Inventory and calling it every time a player click on an item in shop, but it's too much of a pain, and I wanted to know if there was easier way of doing it.
Hey, so I have coded a bot which sends discord message to minecraft which is perfectly fine just that it is sending it 3 times even if someone types a message once
Code
@Override
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
super.onGuildMessageReceived(event);
if (botEnabled) {
if (event.getChannel().getId().equals(plugin.getConfig().getString("chatIntegrationChannelID"))) {
if (!Objects.requireNonNull(event.getMember()).getUser().isBot()) {
String format = plugin.getConfig().getString("DiscordToMinecraftFormat");
assert format != null;
format = format.replace("{user}", Objects.requireNonNull(event.getMember()).getUser().getName());
format = format.replace("{message}", event.getMessage().getContentRaw());
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', format));
}
}
}
}
@Override
public void run() {
running = true;
long startTime, elapsed, wait;
while (running) {
startTime = System.currentTimeMillis();
update(); // line 23
elapsed = System.nanoTime() - startTime;
wait = targetTime - elapsed / 1000;
if (wait < 0) wait = 5;
try {
Thread.sleep(wait);
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void update() {
plugin.stepSimulation(); // line 37
Grenade.blocks.removeIf(block -> block.body.isDisposed());
}
}```
is the bot running 3 times?
Maybe make a button to increase the amount of item by x1 stack?
Eg, 1 Stack, 2 Stack, 3 Stack, etc...
ok but this is my shop, the button will set all items stacks to 64 then?
And no I don't think it is
I mean the bot is run on other codes too does that count?
oh but it was not happening before?
it recently started to give this issue
Also the code is not in Java, it is in JavaScript, like the same bot is doing other things too
Do you know ShopGUI+ plugin?
no
Ok so they have this really cool feature
Where you can select how much stack of an item you want to buy
Something like this
You could implement this into your shop system
How would I fix this? Im having trouble setting the block face to up
What else should i use?
that means I need to call the inventory to select the item every tie a player clicks on an item
thanks
wait
thats deprecated too
wtf
declaration: package: org.bukkit.block.data, interface: Directional
((Directional) block).setFacing(BlockFace.UP);
If you don't want the inventory thing then at the bottom you could add a sign where play could type the amount of items they would like to buy
Or you could do that in chat too
why doesn't this work:
@EventHandler
public void playerChat(AsyncPlayerChatEvent e) {
String rawMsg = e.getMessage();
for (String i : bannedWords) {
rawMsg = rawMsg.replaceAll("(?i)" + i, "");
}
if (e.getPlayer().hasPermission("donator.minecraft")) {
rawMsg = rawMsg.replaceAll("(?i):shrug:", "¯\\\\_(ツ)_/¯");
}
String msg = e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + rawMsg;
e.setFormat(msg);
dBot.playerMessageSent(e.getMessage(), e.getPlayer().getDisplayName());
}
That would be really cool
yes
Yeah I thought of that
the chat blocker part that is
Yeah, i dont have that on 1.8, setFacingDirection works thanks
👍🏿
The only issue with the chat thing is that this might not work for people who are muted
hm
Sorry to tag you but does it matter if the bot is being ran by some other code in other language? It might be running in JS by my co-dev for some other stuff
But then why isn't it sending minecraft messages to discord 3 times? 🤔
What?
anyone?
actually, so the config.yml is generated in a directory in the plugins directory named after your plugin
so that's where i would place a manually created one
so everythings cool... other than the fact that i need to put my database password in that config file
i would think its typical to try to keep that secret when someone downloads your plugin? how do you do that?
i need to store my own database not an external one
wait let me do something then
?
how to listen to packets using Spigot & ProtocolLib 1.17?
Every single example code I've seen fails
How can I get all of the blocks in a chunk?
What are you planning to do?
ChunkSnapshot or a for loop of x,y,z
"custom_model_data": 1
},``` Is it possible to change custom_model_data to something like MyCustomData?
(resource packs)
afaik no
Hover over it
I assumed it was possbile and spend 2 hours on why my stuff didn't work
fml
seems so logical, since you can attach custom data
Thing is, it’s the clients job, the code implementation of the client that can decipher what the server talks about such as the custom model data key name
Does anyone know why this send an error to the console?
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
ActionBarAPI.sendActionBar(player, "action bar message.");
}
}
it's well imported
Maybe send the error
sure
[23:09:01] [Server thread/WARN]: java.lang.NoSuchMethodException: net.minecraft.server.v1_16_R3.PacketPlayOutChat.<init>(net.minecraft.server.v1_16_R3.IChatBaseComponent,net.minecraft.server.v1_16_R3.ChatMessageType)
[23:09:01] [Server thread/WARN]: at java.base/java.lang.Class.getConstructor0(Class.java:3517)
[23:09:01] [Server thread/WARN]: at java.base/java.lang.Class.getConstructor(Class.java:2238)
[23:09:01] [Server thread/WARN]: at com.connorlinfoot.actionbarapi.ActionBarAPI.sendActionBar(ActionBarAPI.java:79)
[23:09:01] [Server thread/WARN]: at com.connorlinfoot.actionbarapi.ActionBarAPI$1.run(ActionBarAPI.java:104)
[23:09:01] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:81)
[23:09:01] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400)
[23:09:01] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1179)
[23:09:01] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:394)
[23:09:01] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1127)
[23:09:01] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:966)
[23:09:01] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273)
[23:09:01] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:831)```
Ah, custom data like that is not send to the client?
Well
The process goes like this:
The server creates an item stack,
The server sets the custom model data tag on that stack to for instance 1,
The server sends a packet to the client about the item stack,
The client receives it
The client decodes the item stack so that it can know how to render the item stack,
The client looks if the custom model data tag is set to a value, if so then it gets the corresponding texture and renders it,
thing is the custom model data tag must be hard coded such that both the client and server knows what tag to use as communication
so, the problem is from the API?
Yes
hmm
uh
do you know any great thread about actionbars?
I haven't find anything about it
but is sending an error
What’s the error
it was a newer
use the api method spigot has
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Hello!")); this?
Precisely
Would anyone happen to know how to get Gson to store a single backslash as a property, instead of escaping it? Trying to store \uE000 as a String and it keeps making it \\uE000
but i have problems with it
i haven't find any thread about it
so i don't know how to align or send the action bar much times so it doesn't dissapear
Use a scheduled task to send it repeatedly
Afaik not possible
ok, that's the next episode i was about to see in the guide xD
I assumed the client knew all data and it did some pattern match
oops
and the align? days ago i did something (don't know what) and it appeard a method called align but don't know how i did it :/
i mean
Believe Apache has a StringUtil class which might just fit your needs

You could use String::format
It's valid JSON though so it has to be possible somehow
but i really remember a way to align it but i don't know how i got it
damn
Yeah Idk maybe check out jackson or moshi dessie
I wonder if org.json will do it
Adri possibly a stack overflow post with a google might assist you here
Any hardcore programmers can help a homie out. I have this thing were I have an enum that stores sub-commands, but one of the sub commands I can use it in multiple places, but it needs another enum input. When I check up on the value inputted, it returns null, anyone know what might be happening?
So you mean the pointing value of CommandType.AMETHYST is null?
Or what is the issue?
Yeah, CommandType.AMETHYST is null when I grab it
Could be possible but that screenshot there is too little to tell anything
Most likely you’re Enum cycling
You're returning CommandType are you sure CMD_Help isn't null?
i can't literaly find anything about actionbar in spigot lol
If you load Enum constant a which requires Enum constant b that requires Enum constant a then it won’t work
As said you’ll get yourself an Enum cycling dependency flow
However the entire idea of using enums for this is a bad practice somewhat
Just create a Map or smtng which acts like a repository / registry for your commands and can do lookups
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
Much more object oriented and will help you with your code infrastructure
yeah, calls it self....
i technically could just do two help commands
just that this help command can show help for both commands
And with objects you can to a certain extent have two objects simultaneously interdependent
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.Spigot.html#sendMessage(net.md_5.bungee.api.ChatMessageType,net.md_5.bungee.api.chat.BaseComponent)
@sullen marlin oh, ty
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
No I mean
class A {
B b;
A() {
b = new B(this);
}
}
class B{
A a;
B(A a){
this.a = a;
}
}
Here they’re interdependent
And what makes it possible is that you can control when they’re instantiated
So this works: https://img.martenm.nl/jEp6x
But the following: https://img.martenm.nl/n0wX5 wont work for some reason when I try to strip out the 'cast' part out of the first file
Is there something with overrides only working to a certain depth?
Oh I get it, alright, I shall try this out, thank you very much 😉
Gl (:
PlayerItemConsumeEvent or smtng
Listen to that
The other stuff is trivial
Check if the item stack is your item
Then apply the effect
Potions is NMS. You've no reason to be using that
It's not even compatible with that method signature
You need a PotionEffect, so I'm not sure where you got Potions from ;p
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/LivingEntity.html#addPotionEffect(org.bukkit.potion.PotionEffect)
Quite simple should learn Java first, using the correct parameter types and understand deprecation is so simple
can someone help me with this?
My plugin lets you tame random mobs, and I want a tame evoker to summon tame vexes. I ended up making it so that on evoker cast I save the evokers status, and then when vexes spawn I apply the status based on the last evoker spell. It might not be perfect, but it seems to be working.
send your pom
i dont use gradle or maven
...
and yes i added it as a library and dependency
obv not
obv i did
ok well you can figure it out yourself if you're going to give me an attitude
how am i giving u attitude
?paste
Start using one
It’s almost a pre requisite for managing dependencies
Yeah
if you aren't using Maven or Gradle, you are missing out on so much oppurtunity
also its easier cause you can just add one line to add a dependency
rather than all this ui stuff
idk i just find it extra work thats rly un-neccesary since i dont really make plugins with dependencies and why make life harder when you can already do it jsut by adding a library :p
ik
It’s not unnecessary work
i mean adding a plugin dependency
It’s to protect your future self from a catastrophe
Realize that the advice we give to you is so you can succeed in the future 🙂
why doesn't the chat blocker part of this work:
@EventHandler
public void playerChat(AsyncPlayerChatEvent e) {
String rawMsg = e.getMessage();
for (String i : bannedWords) {
rawMsg = rawMsg.replaceAll("(?i)" + i, "");
}
if (e.getPlayer().hasPermission("donator.minecraft")) {
rawMsg = rawMsg.replaceAll("(?i):person_shrugging:", "¯\\\\_(ツ)_/¯");
}
String msg = e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + rawMsg;
e.setFormat(msg);
dBot.playerMessageSent(e.getMessage(), e.getPlayer().getDisplayName());
}
Just try it
idk i guess i can look at it butttt i still added it as a library and my code doesnt work
some world edit stuff does work and lets me import it and all that but what i sent it isnt recognizing
The only reason not to use a built automation tool would be if it’s a test project of some sort where JDK solely is needed
Anyways there isn’t much assistance many of us can give here unless you’re willing to use a build automation tool
so no one would know why my code isnt working?
I don’t know what does it say?
here i put what the problem is and what it tells me
Can you screenshot?
it saying it doesnt recognize the stuff?
But most likely the dependencies aren’t added to your compile time classpath
Which might be due to incorrect project setup
Needless to say gradle or maven would help significantly in this case
I meant the whole screen 
Looks like it should be added
But ant is ass
(IntelliJs default build automation tool)
Which is the one you’re using
So can’t help you any further unless you decide to make a big commitment and try maven or gradle out
rip ok ty anyway ig
ant is like old grandpa
Actually you could try restart and invalidate caches
the thing under the file setting?
Indeed
i just tried it, nothing changed
Hmm alright then Idk sorry
People are always learnjavaing me and it gets annoying, so here is a class to prove I have some basic Java knowledge
https://paste.md-5.net/wojodiceta.cs
It’s good except the abysmal comments
Thing is, I’m gonna give you a pro tip
if it is sc.nextInt I know
You can extract a method called for instance multiplying and then do multiplying the operation in that function and just call that function
I just don't know the error for it not being an int
I’m planning to write an object oriented guide, Object Orientation in Spigot Practice
nice
Yeah cjendantix
Longer functions are rude and impolite to the reader
Because you need to read the entire function in order to understand what it does
Its the main class, so its technically not a function
If we extract functions we will get this semantic layers of function calls so we can then exit early if we want
It’s in a function
main(args)
yes I know public static void main(String[] args)
So it’s in a function
yes, I just call the main function in the main class the main class
I don’t know about that one 🥴
Idk I mean it’s important to differentiate between classes and functions
But as long as you understand it is in a function then it’s fine Ig
ok then its just main
Yeah guess that’d be more accurate (;
?
your main function is still a function
lmao?
I just don't want to call it a function unless necessary, its called preference
this isnt called preference. what you simply stated is just wrong
These are functions and are defined as such
mutes the server
if you dont wanna get learnjava'd... at least trust what we say
LeArN jAvA ,
kek
? What are you trying to do?
Aslo can you show the code
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)){ return true; }
Player player = (Player) sender;
if(command.getName().equalsIgnoreCase("etp")) {
Player target = Bukkit.getServer().getPlayer(args[0]);
if(target!=null){
Location targetLoc = target.getLocation();
player.teleport(targetLoc);
player.sendMessage("You have been teleported to " + target.getDisplayName());
} else if (target == null) {
player.sendMessage("This player is offline!" + ChatColor.RED);
}
}
return true;
}```
?paste
Can you use that
no
command works fine
I got that wron for the longest time
can't remember what label is for but isn't it like, for the aliases or smth?
so what maybe causing this? https://prnt.sc/1vq9pi9
yes
What exactly is the issue @valid solstice ?
this is the issue https://prnt.sc/1vq9pi9
when executing the command, it just sends the command in chat
Also are you actually supposed to use command because if so I've been doing it wrong for like a year lol
yep, cmd will give you the actual command thats registered and was used. label gives you whatever was typed (alias) to trigger the command
Ok that makes sense, thanks
@valid solstice do some sysouts because it is returning true somewhere
it is returning true everywhere
i dont have a "return false" statement
The last one should be false
if you use label, you gotta look for all the aliases
if(label.equalsIgnoreCase("peanut") || label.equalsIgnoreCase("pnt"))
while with cmd you can just do
if(command.getName().equalsIgnoreCase("peanut"); // this will get the command /peanut, even if you use the /pnt alias
looks to me from that SS you havn't registered the command
Won't it return an error if that's the case?
no
in the plugin.yml?
No on your onEnable
oh
if you don't register the command but have it in your plugin.yml it'll "exist" but there's no code for it to execute, so it just returns false by default
ah ok
that must be why, thank you
how would i add x points into an int i, and if it pass y then it would reduce the i to equals y other than using a nested loop like this?
int i = 2;
if (i < 3) {
i = i + 3;
System.out.print(i);
System.out.println("");
for (int e = i; e >= 3; e--) {
System.out.println(e);
}
}```
heh
the explanation is a bit hard to follow
Ternary
if it pass then y : i means what?
let me learn java basic 😂
i = (i + x) > y ? y : i;
is the same as
if((i+x) > y){
i = y;
}else{
i = i
}```
Help, what am I getting wrong? Everything works and I get the message I am suppose to get but the gamemode just won't change
CODE: https://paste.shockbyte.com/ludedotucocipibucagi.cs
If the code runs you have a listener preventing changing of gamemodes
I hope i did this right 😂
if (3 < 5) {
getConfig().set("Players-Data." + pUUID + ".Fantom", 3 + 3);
saveConfig();
int i = getConfig().getInt("Players-Data." + pUUID + ".Fantom");
int finalAmount = i > 5 ? i : 5;
getConfig().set("Players-Data." + pUUID + ".Fantom", finalAmount);
saveConfig();
}```
you can just use Math.max for that
ide already suggest that but havent really understand what math max is
if i is greater than 5, it will chose 5
public void addLives(UUID pUUID, Integer lives) {
getConfig().set("Players-Data." + pUUID + ".Fantom", Math.min(getFantom(pUUID) + lives, getMaxFantom(pUUID)));
saveConfig();
}```
wait then it would only be this 😂
Anyone know how to use vector speed
I thought it was multiply but doesn't seem to do anything
Like multiplied by 10 seems to have no difference from 20
Minecraft has a limit iirc
Ik but the limit is like 500 or smth
Cuz I've seen plugins yeet ppl rlly far
But with just multiplied by 10 or 20 or smth doesn't seem to make a difference
They probably do it continually
I’ve found 10 is around the limit
If you want to send someone really far you need to keep applying a velocity with a runnable
But generally an x y and z of 10 is the max
does anyone know where knockback would be located in the Spigot-Server folder
like I would like to modify knockback
but modifying it with a plugin seems a bit scuffed
You’d need to create a patch over NMS
yeah i get that, but do you know which file knockback would be located
wait also is NMS only for newer versions?
ye my bad
hmmm can this serialize location hmmm```java
public String locationToBase64(Location pLoc) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(pLoc);
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save location.", e);
}
}```
Location is already configuration serializable
But yes that will probably work for converting it to base64
Alternatively you can just write worldname,x,y,z,pitch,yaw
YEA
*yea
sorry caps
but uhh
i dont think i need to change anything in the location normal
so change it to base64 is maybe less storage
:yay:
oh no thanks i will not change it to base64 let it be normal maybe better
that is horrible
MD does not approve
😂
I'm gonna go gouge my eyes out now
To be fair I don’t know what id do to save a location outside of yaml
Probably just this
How to make a Bungeecord server
Gim me an example why it is horrible 😦
@young knoll then what to do
for some reason when I right click on sand and replace it with a note block it plays the sound but not on grass or dirt
does that have something to do with grass/dirt being able to be turned into dirt paths using shovels but theres no interaction with shovels on sand so it still registers the right click on sand?
how should I go about getting around this?
java.lang.IllegalStateException: PlayerTeleportEvent may only be triggered synchronously. anybody know whats causing this?
callSyncMethod?
runTask iirc
You probably want to cancel the right click when you convert the block
thanks
i already have it canceling the event prior to even converting the block
everything
worst code I've seen this week
why would you want to do that
😦
How does the output look?
I'll answer: terrible
I assume so, as well
Wouldnt that encoding be a lot slower than serializing the normal way
Double paired with string wrapped in map converted to bytes converted to string
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I’m sure we can add more conversions
I am making a nick plugin, but i am having a problem, i want to change the player's name in player list too, to his nicked name.
@EventHandler
public void PlayerList(PlayerJoinEvent event) {
event.getPlayer().setPlayerListName(event.getPlayer().getDisplayName());
}
}```
this is my code
but it dosent work
give solution
is it registered
yes
ok
try sysout their display name
idk what the difference is
it may be working you just don’t realise
if it was the offhand why does it only trigger for sand and not dirt or grass?
my coding is correct?
in chat the nicked name is coming
but in player list
its not
where are you changing the nick
in another class
ah ok
ik in the past people have had issues with the player list
and changing names and stuff
just its not showing in player list, though i have modified it to display name
No clue, maybe try setting the useInteractedBlock action directly
ah someone experienced pls help
probably
what the fuck
- You can save a location as a string in config
- There are n other ways to store a location in a config in a readable way
you may use base64 serilization for inventories maybe 👀
I want to have a way that is unreadable.
But anyways u don’t have it reply to it
Or at least don’t ping
why would you want that
only at that time
i guess it is faster to stick to the normal way after some mins after posting the question 😂
Do you know
.
.
WHAT THE HECK IS THIS? YOU HAVING EYES ISSUE? #help-server
Sowwwy
I am making a nick plugin, but i am having a problem, i want to change the player's name in player list too, to his nicked name.
@EventHandler
public void PlayerList(PlayerJoinEvent event) {
event.getPlayer().setPlayerListName(event.getPlayer().getDisplayName());
}
}```
this is my code
but it dosent work
give solution
do i have to use NMS if I want to trigger the clientside animation of a player "using" a shovel
like they swing it
how would I go about hiding an armorstand with packets and then let it reappear with the same equipment? im using minecraft 1.17.1
so my custom made itemstack is having this issue
the checker checks if there is lapis
and for the item to work, it should be like this
not this
contains(Material.
yes
wait is getItemInUse equal to getItemInHand?
use material
uh no
item in hand is the thing their holding
and in use is uh
using
duh
why does the console say i tped twice. it also consumes twice
public static void onClick(PlayerInteractEvent e){
Player p = e.getPlayer();
if (!( p.getInventory().contains(Material.LAPIS_LAZULI) ) && p.getInventory().getItemInHand().equals(SMPCoreMightAdded.aspectOfTheEnd)) {
if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Not enough materials!");
p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 999f, 0.5f);
}
} else if (p.getInventory().contains(Material.LAPIS_LAZULI)) {
if (e.getAction() == (Action.RIGHT_CLICK_AIR) || e.getAction() == (Action.RIGHT_CLICK_BLOCK)) {
if (p.getInventory().getItemInHand().equals(SMPCoreMightAdded.aspectOfTheEnd)) {
Block b = p.getTargetBlock((Set) null, 8);
Location loc = new Location(b.getWorld(), (double) b.getX(), (double) b.getY(), (double) b.getZ(), p.getLocation().getYaw(), p.getLocation().getPitch());
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, 3));
p.setWalkSpeed(0.2f);
p.teleport(loc);
Bukkit.getLogger().info("got tped 1x");
p.getInventory().removeItem(new ItemStack(Material.LAPIS_LAZULI, 1));
p.sendMessage(ChatColor.AQUA + "Teleported!");
p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 99999f, 1f);
}
}
}
}
}
here is my code for the event
ah ok
?jd
How would I run a command as console, & get the output?
Use Bukkit#dispatchCommand
that doesn't return the output though
it'll only return an output if there's an error
it does return an output to console tho
how do i read that output then?
not sure if what youre trying to do is possible unless you scan every message in console for what youre looking for
rip, alrighty
you could attempt to implement your own command sender
but I havent played with that yet so i might just be completely off
that wraps the existing console representation
how would i do that?
i found this, but got confused https://www.spigotmc.org/threads/execute-a-console-command-and-get-the-results.164709/
The real question is why
rcon, but making it 10x harder for myself
And what don't you understand?
I did uh, this
public interface FormattedCommands extends CommandSender{
default void sendMessage(@NotNull String message) {
}
}
but it's always returning void for some reason
you have to capture the message
e.g. have a List<String> field
and append each message passed to sendMessage to that list
oh
confusing, but i'll attempt something like that
If I add 2 different versions of spigot in dependencies, can I use functions from both of them or will there be some conflicts? I'm new to java.
imagine
Probably wouldn't work because they share some classes?
maybe learn some java instead?
I will, I'd just like to have some idea of what is and isn't possible, because I have a feeling whatever resource I'm going to read through does not make this obvious.
if you are adding 2 different versions im assuming there is functionality in one version that doesn't exist in the other?
If you want multiple spigot versions you should use Gradle or Maven modules
your runtime environment will only contain one of those dependencies
Assuming you what you want is multiversion support
Also this
I'd use a string list and convert that
Something like that yeah
https://paste.gg/p/anonymous/49b625b18b6f4f38861bc5449f3b3698
hello why is my NickAPI in red?
i am new to programming 😅
Can someone tell me, why this is throwing me hundreds of errors after backing up the world, unloading the old one onDIsable, deleting it, moving the new one there?
I think there is no import statement for nickapi
if you are new to programming, i would recommand learning at least the mere basics of java
great tutorials are from Alex Lee (https://www.youtube.com/watch?v=az6SehZyY7U&list=PL59LTecnGM1NRUyune3SxzZlYpZezK-oQ)
Full Java Course: https://course.alexlorenlee.com/courses/learn-java-fast
If you're new to programming, I HIGHLY RECOMMEND solving challenges on Edabit: https://edabit.com/?ref=alexlee
Get my favorite programming audiobook for free! https://audibletrial.com/alexleefree
20% off Brain.fm (productivity hack): https://www.brain.fm/alexlee20
Get Tabn...
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
currently redid it by loading a map they put in the folder
but still it throws error when unloading the world
and then moving the new one there
ok redid it again
i got so far to delete the world folder without errors
but when now moving the backup world to the right location it still loads the old one
someone got an idea why?
this is currently my onDisable method
@SneakyThrows
@Override
public void onDisable() {
for(Player p : Bukkit.getOnlinePlayers()) p.kickPlayer("");
Bukkit.unloadWorld("world", false);
File mapBackup = new File(this.getDataFolder() + "/maps/world");
File target = new File("world");
System.out.println(ChatColor.RED + target.toString());
FileUtils.deleteDirectory(target);
}
do you have to have a plugin disable itself in the main class?
or can you somehow have a method in a sub-class that triggers a plugin disable
with like getServer().getPluginManager().disablePlugin();
oh sorry i wasn't directing that at you i was asking a general question lol
I think you can disable it when you feel like it. No real restriction
Yeah, but why would U disable IT 😂
lets say plugin detects it has lost connection to a database and the database is critical for its operation
I could cry rn. The Plugin deleted the whole world folder and replaces it with a fresh one. But it still loads the old one. Why 😂
it sees it cant reconnect so it disables itself
Makes sense
Unloads the old world before doing so
Makin no sense
how would I find out whether a server a plugin is on is bungee or spigot at runtime? trying to have 2 different main packages, one for spigot, one for bungee in one jar and select between the 2 given each's needed environment, I'm fine with adding a third manager package/class if needed
or would it just be as simple as having both, and then one of them just doesnt run
Yes
alright, ill try it, thanks ❤️
Just 2 ymls
2 ymls in the different packages?
?
Yes
thanks both of you ❤️
?jd-s
Could someone here send me an example on how to load an world after deleting the old one?
for some reason it still gives me te old map
got this for deleting the old map
Bukkit.getWorld("world").setAutoSave(false);
for(Player p : Bukkit.getOnlinePlayers()) p.kickPlayer("");
Bukkit.unloadWorld(Bukkit.getWorld("world"), false);
File unloadedWorld = new File("world");
FileUtils.deleteDirectory(unloadedWorld);
How can I check if a block is a block entity?
do you mean a TileEntity?
instanceof
So like block.getState() instanceof TileState
👍
tho getState creates a snapshot
similar to getItemMeta
you will have to store it in a variable before modifying it
i have a question
how to disable these warns
what warn shod i suppress
im sure it will not cause
and it does not need any null check
the warns are still there
lol
there is 0 chance for it to get null it is impossible
better make it -1
for (final String s : data.getConfig().getKeys(false)) {
final ConfigurationSection locationSection = data.getConfig().getConfigurationSection(s).....
how could it get null
not possible
Could someone explain me about getHealthScale?
For what it is used?
what should i suppress
Nothing, you test for null
bruh i dont want useless checks
if a method can return null checking for null is nto useless code
how this code
can return null
it may not be a config section under that key. It could be a value
which would return null when you call getConfigurationSection
so that will be the problem of the user (that is me)
thats a data file
so it will get set
a user should not edit the data file
unless its needed
Stop arguing against correct coding practices. You are trying to convince others that your shortcut is valid.
bro just what should i supress
i want to suppress
please tell
No
i know how to code
Then code properly
can you please tell so
No
test for the null and you'll have no warnings
@quaint mantle U blind?
Lets chill guys
check if the configurationsection is null
so there must be something that i can suppress
supressing is shit
using @SuppressWarnings("") will just tell the ide what it shouldnt inspect
@SuppressWarnings(configurationSection == null) right ?
right ?
no
tf
it does not affect your codes behaviour at all
i know
see
it is annoying
and you can only pass a string there
i know it is a string
just in your loop if(configurationsection == null) return; or smth along these lines
We are not going to tell you how to avoid coding correctly. We WILL tell you have to do things properly
i just wrote the code to tell him that i want that
not a null check
i just want to know bruh
i will put a check
but just tell me
what suppresswarning is it
google then. We will not do this for you
that will prevent that warns
what prevents warns? good checks
...
anyways you can check that yourself
alt enter on the inspection and chose suppress
in intellij
lemme open
idkhow2 do it in eclipse
its literally in his code add if (locationSection == null) continue;
I think he just wanted to suppress it
yes he does
yeah
Which is why I'll not tell him. Code properly and don't ignore errors
¯_(ツ)_/¯
Quick question: For map resetting, can I just delete the world folder in my onDisable and then just copy a new one there?
no
nope
only in onLoad
Rly?
thing is first you need to unload the world, then hope and pray to the omniscient god that it will be garbage collected
then once gc'd delete the folder
they are still loaded/accessed in onDisable
and assuming its not the main world
^
Bukkit.unloadWorld
Or not?
Yes IF its not a main world, and you run a task to check for when it is actually unloaded
it has to be fully unloaded with all file locks released
such ass suppress
ah yes
and if some other plugin strongly references the world or smtng you're basically fucked
yep
so somehow i have to get the players off the main map and onto the other map that i can reset?
Or maybe you can keep tracks of all blocks that are destroyed/placed and you can replace/break the blocks at the end of the game.
Yeah, you can't have any players in a world you're trying to unload
just kick everyone
thats not the problem
or ima just use worldedit
will do the trick too
thanks tho
Could someone explain me about getHealthScale?
For what it is used?
how can I shade mongoDB in my plugin using maven?
the maven-shade-plugin will do
How can i do that a plugin works for different versions
How can I get all classes that are implementing / extending a class? (Reflection purposes)
boils down to scanning all classes
the super class does not track/know its children (by design anyway). Sealed classes would obviously change that fact but eek
Ok, and if I have scanned then just check their superclasses / interfaces?
ok so I undrestand, how I can listen to BlockBreak event but I dont know how I can drop random item when it is mined
Can someone help me with circular dependency? I'm using Gradle multi-modules, basically I want to use the modules on the main code. https://github.com/aglerr/PlayerCosmetics
maybe with random but not sure how I can get it to work
ok so I have found the solution
Hey I have small confusing is event handler annotations necessary? (I am a starter)
I can iterate though all minecraft items and add them to arraylist and then just pick random one with random!
