#development
1 messages · Page 102 of 1
theres a function to send data while catching errors, but idk how i'd detect a disconnect right away
i could use ping the client but
in the docs it says that it handles close and ping/pong stuff unless its a raw web socket session
How do i loop through a config list and do something with every string ?
I tried this but it didnt work as planned, it put everything in one item and not in multiple items:
for(Object object : listobjects) {
ItemStack obj = new ItemStack(Material.SKULL_ITEM);
List<String> objLore = new ArrayList<>();
objLore.add(Format.chat("&7Rechter muisklik om te openen!"));
ItemMeta objMeta = obj.getItemMeta();
objMeta.setDisplayName(Format.chat("&a" + object.toString()));
objMeta.setLore(objLore);
obj.setItemMeta(objMeta);
inv.setItem(i, obj);
i++;
}```
it gives this but i want it to be seperated items
thats cause you are using toString
on a list
and you are getting your objects using the get method which is returning a list
Use the getList method instead
instead of Collections.singetonList ?
you seem to be getting confused here
yes
Yeah no <Collections.singletonList(Data.getCustomConfig1().getStringList("player-data." + p.getUniqueId()));>
dont do that
final List<String> list = Data.getCustomConfig1().getStringList("player-data." + p.getUniqueId());
then loop through elements of list
and also please actually use managers rather than static abuse
this works ty https://paste.helpch.at/egazivuheh.cpp
idk what static abuse is tho
you are making your config static
when it can just be a manager class
like configmanager
its a project for me so no one will see that
i will look in to that
ok
Hey anyone can help me with this that would be wonderful
I have an NPC plugin that uses craftworld and craftserver i want to set up a PlayerInteractionEvent but I can't figure out how to make it specifically work with only the NPC it still works on the NPC but when I click a grass or anything else it still works anyway to block everything else but keep the NPC
Can I transfer a Skull BLOCK to a Skull Item?
I'm probably being dumb, but why is this only saving the last insert? (MySQL)
for (final BlockPosition blockPosition : blockPositions) {
final int x = blockPosition.x();
final int y = blockPosition.y();
final int z = blockPosition.z();
statement.setString(1, uuidString);
statement.setLong(2, chunkKey);
statement.setInt(3, x);
statement.setInt(4, y);
statement.setInt(5, z);
statement.setInt(6, x);
statement.setInt(7, y);
statement.setInt(8, z);
this.plugin.logger().error("Saved block: " + blockPosition);
statement.addBatch();
}
this.plugin.logger().error("Executing batch");
statement.executeBatch();
The statement is
"INSERT INTO " + TABLE_NAME + "(" +
WORLD_UUID_COLUMN + ", " +
CHUNK_KEY_COLUMN + ", " +
POSITION_X_COLUMN + ", " +
POSITION_Y_COLUMN + ", " +
POSITION_Z_COLUMN + ") " +
"VALUES (?,?,?,?,?) " +
"ON DUPLICATE KEY UPDATE " +
POSITION_X_COLUMN + "=?, " +
POSITION_Y_COLUMN + "=?, " +
POSITION_Z_COLUMN + "=?";
I'm also using HikariCP if that helps
I am dumb
I set up the keys wrong
yeah i was about to say
I'm too tired for this lol
Does anyone know how to hook into MVdWPlaceholderAPI? I copied the repository and dependency on the SpigotMC page, but it does not seem to work...
Can anyone help with bungee supervanish?
I don't think SuperVanish has BungeeCord support.
Mvdw is deprecated, Maxim's plugins use PAPI
What is the event to listen to command executed on proxy from console.
@dense drift I saw you asked the same question before. ChatEvent is for player commands. I wanna get console executed commands.
.clone()
you'll probably have to manually check against each material. Make a set for all the tools and check if the set contains the material you're testing for
How do i create a set?
u can probably just take the material name and check if it ends with AXE, SHOVEL, etc
that is also an option yeah. but problem with that is youd still need to have to make like 7-8 cchecks bcz there's other tools as well
Set<Material> tools = new Set(Material.FIRST_TOOL, Material.SECOND_TOOL);
what other tools?
sheers, fishing rod
oh
what others are there. only those probably unless carrot on a stick is also considered a tool
right. bcz I know java xD
public static interface Map.Entry```
Map.Entry has 2 implementing classes, and 7 methods.
A map entry (key-value pair). The Map.entrySet method returns a collection-view of the map, whose elements are of this class. The only way to obtain a reference to a map entry is from the iterator of this collection-view. These Map.Entry objects are valid only for the duration of the iteration; more formally, the behavior of a map entry is undefined if the backing map has been modified after the entry was returned by the iterator, except through the setValue operation on the map entry.
1.2

not sure why that's not working
I am getting a null error that is saying that this is null:
|| !playerItem.getType().toString().contains("BOW")
|| !playerItem.getType().toString().contains("HELMET")
|| !playerItem.getType().toString().contains("CHESTPLATE")
|| !playerItem.getType().toString().contains("LEGGINGS")
|| !playerItem.getType().toString().contains("BOOTS")) {
return;
}```
I'm guessing playerItem is null
also, use .name() instead of .toString()
and I'd recommend using endsWith instead of contains just in case 😉
if (playerItem == null) { return; }
ty
I am 100% sure the itemtype contains SWORD but it still says it doesnt
I doubt the item material name includes the words sword, bow, helmet, chestplate, leggings and boots at the same time, you'd better use && instead of ||
Quick question: PlaceholderAPI.setPlaceholder(p,text) translates hex or color codes?
Try getting the item meta and checking if it is instance of Damageable (the block one, not the entity one).
Oh okay no problem
So i have a command in my plugin but the player and also the console must be able to execute it, but i have the Player p = (Player) sender; in my code and i don't know how i can make it compatible with both
i get this warn https://paste.helpch.at/ejolonuged.bash
only cast if you're sure the sender is a player
so check if sender is insatnceof Player
tried that but i don't think it was right
i tried:
ConsoleCommandSender console = null;
if(sender instanceof Player){
p = (Player) sender;
}else {
console = (ConsoleCommandSender) sender;
}```
afaik you can have only 1 instances of each event, whats the best way to pass through data from other classes so that i dont have 1000 lines in my event class?
Hi guys, can you please give me a hint on setting up a modern MC plugin development environment?
What i am used to is using IntelliJ IDEA, Java SE 8, Gradle and the Spigot API.
But AFAIK there is modern Java like SE 17, should be a lot more modern than the 8. What version can I use? What are the restrictions and conditions?
A java class with the java version x and a jvm instance with java version y you get the compatibility
x <= y
I don't understand how that would help me.
you wanna support 1.8 to 1.17? use java 8
You might be able to use java 17 to compile your plugin, however that also requires your server to run java 17
I understand that, but what Java versions do different version minecraft servers run?
However, you can still compile your plugin to a lower version like java 11 and still be able to run your plugin on a server that runs java 17 or java 11 (or something in between)
I mean java gets better and better for every update
but depending version certain things might not be compatible at all
I am confused, so can a server owner choose what version of java do they want to run their minecraft server instance on?
mostly.
tho
on spigot for example you are limited
on older versions
for example on spigot 1.13 you can only have up to java 11
Who cares about spigot 🤡
Thank you finally something concrete 😄
the thing I'd recommend you use newer versions of java for public plugins. I usually do at least 11.
If you are coding your plugin only for 1.17 tho, just use java 16
you mean only and above? 🙂
Well Java 16 is the min for 1.17
If you use java 17, the server owners have to run java 17 too, but that's good tbh
Because 1.18 is going to have Java 17 as minimum anyways
Okay so let's say MC server is 1.17.
How can the server owner tell which version of java is he hosting the server on?
1.17 MC servers can only run in java 16 and above
it cant run anything below
or else it will crash
Okay, great, but still how can I tell the java version on a server? (owner is a friend so can access the server)
in linux terminal right?
Yes
Great, thank you.
And if he installs the latest Java LTS (SE 17), will everything work correctly as if it would run on an earlier Java version? I mean plugins written for Java 8, etc.
Not all plugins
some plugins use NMS
But otherwise, for the most part, yes
(if they use only api)
Ah what I meant is that his current 1.17 server, if he runs java 16, change to java 17 would not make anything go wrong
Yes, actually. Is he using the --ilegal-permit flag?
Sorry, help me out with that flag
Like when he runs his server
with jvm arguments
does he include that too?
also this doesnt seem to be development related, maybe lets move to #minecraft
really?
oh
yeah. its what I found out yesterday lol
anyone got a Deluxemenus Config already Configed that i can use for my server ?
anyone have issues with unresolved references when trying to compile a module in intellij that depends on another module in the same project?
I've run maven install on the project i need as a dependency and I see it in my .m2 folder, however when compiling the second project it gives me unresolved reference errors and fails to compile
o/ question. anyone knows a good, up-to-date item nbt api? i did some searching but what i found was either too old or too bloated with unnecessary stuff
how to convert SKull block to SKull item
d;health
public class ThreadLocal
extends Object```
ThreadLocal has 1 extensions, 6 methods, and 1 sub classes.
This class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own, independently initialized copy of the variable. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID).
For example, the class below generates unique identifiers local to each thread. A thread's id is assigned the first time it invokes ThreadId.get() and remains unchanged on subsequent calls.
Each thread holds an implicit reference to its copy of a thread-local variable as long as the thread is alive and the ThreadLocal instance is accessible; after a thread goes away, all of its copies of thread-local instances are subject to garbage collection (unless other references to these copies exist).
1.2
d;spigot health
public final class HelpTopicComparator
extends Object
implements Comparator<HelpTopic>```
HelpTopicComparator has 1 extensions, 1 implementations, 3 methods, and 2 all implementations.
Used to impose a custom total ordering on help topics.
All topics are listed in alphabetic order, but topics that start with a slash come after topics that don't.
d;spigot EntityHealth
public class EntityChangeBlockEvent
extends EntityEvent
implements Cancellable```
EntityChangeBlockEvent has 1 extensions, 1 implementations, 8 methods, 1 all implementations, and 1 sub classes.
Called when any Entity changes a block and a more specific event is not available.
#bot-commands
Just ctrl + click it in your ide
I mean he could be on the phone
are there "official" or widely used naming conventions in sql? i keep finding a bunch of things
ex when looking for tables i found "Something", "something_else", "SOMETHING", etc so idk which one is best to use ;-;
or is it just do-whatever-you-want
what about columns?
That's what I use
you are correct
^
Was looking for all events that contained health
But failed
Miserably
if you use Bukkit.getOfflinePlayer(uuid); Can i do this with a uuid of a player that hasn't joined before.
yeah. the javadocs say that it will return an object even if the player does not exist
Always use capitals for SQL :P
But can i use this object to set it as a skullOwner of a PlayerSkull?
Okay i'll try
So it gives me a alex/steve head
bump :c
Uh doesn't shadowjar relocate all already? Even transitive ones?
Can you recommend me a good/standard .editorconfig file for Java/Minecraft plugin development?
(Like I would recommend dotnet/roslyn's .editorconfig for C# development.)
(Bonus question: does Intellij IDEA support it? 😄 It should I guess)
I believe intellij does support it
Is this a correct gitignore file? I'm using gradle + IDEA
# out folder
output/
# Gradle
.gradle/
build/
# IDEA
.idea/
*.iml
Because that way, these are getting commited, I guess it's fine
yeah you want those to get committed
edit: nvm
I need some help with gradle, a new version seems to work differently than old, and I am getting error:
So my plugin.yml is like this and this script used to work
main: arphox.JumpCounter.JumpCounter
api-version: 1.16
name: @name@
version: @version@
author: @author@
duplicatesStrategy = DuplicatesStrategy.INCLUDE
In Kotlin, I can't search a MatchGroupCollection by name anymore, it just throws an UnsupportedOperationException: Retrieving groups by name is not supported on this platform. Any ideas?
Where to put that?
processResources {}
Amazing, thank you very much! ❤️
np
Anyone have a clue why depend does nothing and my plugin loads after vault?
If you depend on vault, your plugin should start after vault
Sorry, I meant the other way around 😅 Vault loads after my plugin!
I do get org.bukkit.plugin.UnknownDependencyException: Vault if Vault doesn't exist at all
maybe youve given it the wrong name in the plugin.yml? its case sensitive I believe
depend: [ Vault ]
What is the most idiomatic way of flattening a Option<Pair<A, Option<B>>> to Option<Pair<A, B>> using arrow? This is the code were I want to apply that
fun playerDisconnect(player: Player) {
activeDungeons.remove(player.uniqueId) // returns a String?
?.let { dungeonRepo.getDungeon(it) } // returns an Option<Dungeon>
?.tap {
dungeonRepo.getLastLevel(it) // I need to somehow zip the "Dungeon" with this Option<Level> (returned by the getLastLevel), and use both, or none of the two, if there's no last level
// filter the result using levelSpawnsManager#isLevelComplete, passing the Level I just got as argument
// then run these methods after
levelSpawnsManager.cancelDungeonSpawns(dungeon)
levelSpawnsManager.resetCompletedLevels(dungeon)
player.runLogoffCommands(dungeon)
}
}```
Any clues then on whats happening?
Do you mean Either instead of Pair?
No, there's no error there, I need both Dungeon and Level, or none of them, so it is really an Option
fun isLevelComplete(dungeon: Dungeon, level: Level): Boolean =
level.id in completedLevels[dungeon.name]``` I'll use both to check for the completion of the level, and if it's *not* completed then I would like to run the three method calls on the `tap` method
fun playerDisconnect(player: Player) {
activeDungeons.remove(player.uniqueId).toOption()
.flatMap { dungeonRepo.getDungeon(it) }
.flatMap { dungeonRepo.getLastLevel(it).map { level -> it to level } }
.filterNot { (dungeon, level) -> isLevelComplete(dungeon, level) }
.tap { (dungeon, _) ->
levelSpawnsManager.cancelDungeonSpawns(dungeon)
levelSpawnsManager.resetCompletedLevels(dungeon)
player.runLogoffCommands(dungeon)
}
}``` this is what I got so far, it works, but doesn't look exactly idiomatic since I had to use `map` inside `flatMap`
hm, there's not much you could do, perhaps remove the filterNot onto the getLastLevel directly
Then you never need to deal with a pair
Argh help me how to broadcast a simple string please 😄 it has been deprecated what I used before
This is deprecated this.getServer().broadcastMessage("hello world");
are you using paper?
i think it is changed to be components
d;paper Server#broadcastMessage
@Deprecated
int broadcastMessage(@NotNull @NotNull String message)```
use broadcast(net.kyori.adventure.text.Component)
Broadcast a message to all players.
This is the same as calling broadcast(java.lang.String, java.lang.String) to BROADCAST_CHANNEL_USERS
the number of players
message - the message
Yep, you have to use the Component API
do something like Component.text("Hello World")
yes
all raw String's and stuff have been replace with components
thankss
I mean not because of that
Because the game hasn't used strings to represent text for over 7 years
^ lol
You mean something like this?kt fun playerDisconnect(player: Player) { activeDungeons.remove(player.uniqueId).toOption() .flatMap { dungeonRepo.getDungeon(it) } .filter { dungeonRepo.getLastLevel(it).map { level -> !isLevelComplete(it, level) }.getOrElse { false } } .tap { levelSpawnsManager.cancelDungeonSpawns(it) levelSpawnsManager.resetCompletedLevels(it) player.runLogoffCommands(it) } }
Because the game internally has been using components but Bukkit is dumb fuck to push legacy text since then
hey, i got an issue when trying to connect to my mariadb database:
Current charset is UTF-8. If password has been set using other charset, consider using option 'passwordCharacterEncoding'
it denies me access and it says this
password is wrong probably (or at least is what this message seems to indicate)
no it isnt i double checked
then idk
What is the modern way to format strings in Java?
I would like something similar to C#: $"Hi {name}, how are you today?"
because the percentage stuff look awful
16
Ok nice
Java doesn't have much salvation, if you have a lot of placeholders you want to replace, you better probably using String.format("blah %s blah %s", "onePlaceholder", "twoPlaceholder"), or the formatted thing
d;String#formatted
public String formatted(Object... args)```
Formats using this string as the format string, and the supplied arguments.
15
A formatted string
args - Arguments referenced by the format specifiers in this string.
Like this?
@EventHandler
public void onPlayerJump(PlayerJumpEvent event) {
jumpCounter++;
event.getPlayer().sendMessage("JumpCounter: %s.".formatted(jumpCounter));
}
Yes
Thank you
Format actually has different thing for each percent too
it checks for the specific type
you can do very silly things, it's pretty cool
Mhm lol
any help?
Not much I would say other than a) make sure to run the jvm with the -Dfile.encoding=UTF-8 flag and b) make sure the file is saved with UTF-8 encoding as well
You could use flatMap instead of filter + getOrElse, but yeah
I think
do you?
no he doesn't
Player.Spigot, Server.Spigot !!! 🤡
how do i get a skull using the base64 system?
you'll have to read this https://www.spigotmc.org/threads/tutorial-skulls.135083/
Anyone aware of a kotlin compiler API similar to javac api?
Kotlin compiler plugin?
No I meant like to compile kotlin code at runtime
Not to execute it like with kts, just to compile to bytecode
Oh hmm I'm don't know that 
💀
Why do I get these kind of errors? Should I care?
Enabled plugin with unregistered PluginClassLoader
I literally created a new dummy plugin and enabling-disabling it to test how it behaves.
show your code
Not necessary, if someone knows this problem, they will know why it happens. My code is literally a new, empty plugin.
glhf
Hi,
public void inject(Player player) {
CraftPlayer craftPlayer = ((CraftPlayer) player);
channel = craftPlayer.getHandle().playerConnection.networkManager.channel;
channels.put(player.getUniqueId(), channel);
if (channel.pipeline().get("PacketInjector") != null) return;
channel.pipeline().addAfter("decoder", "PacketInjector", new MessageToMessageDecoder<PacketPlayInUseEntity>() {
@Override
protected void decode(ChannelHandlerContext channelHandlerContext, PacketPlayInUseEntity packet, List<Object> list) throws Exception {
list.add(packet);
readPacket(player, packet);
}
});
}```
This is outdated (1.8) and I'm trying to update it to 1.17 how do I fix this line:
```java
channel = craftPlayer.getHandle().playerConnection.networkManager.channel;```
The method should inject the player into the packet reader
In 1.17 it's CraftPlayer#b iirc
I'm guessing you got red text on the playerConnection?
Hi, whats wrong with this DI? https://paste.helpch.at/paquqovebu.java
You haven’t set the variable yet
?di
Dependency Injection
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
Read more here: https://en.m.wikipedia.org/wiki/Dependency_injection
Dependency Injection in Java:
https://paste.helpch.at/yijawupoju.java
Dependency Injection in Kotlin:
https://paste.helpch.at/esogakutod.kt
I'm not really sure but maybe the declaration in the constructor is made after the other variables are initialized @cinder forum
so in this case it would try to initialize host, port etc. before you gave a value to plugin
you will have to initialise those variables in your constructor as well
How do you think, an Object should be capable of saving itself to a database?
Sounds the object has more than one major reason of changing, which can arguably break single responsibility principle but I mean. If you have a valid reason to do so, maybe it’s fine.
Well, trying to design a convenient api. My colleague already asked this questions, but we have a Clan. On clan, we can call setDisplayName, addMember, addHome to modify a clan. We need to somehow apply those changes in database too
Yeah usually I try to keep storage and data model separated, for the implementation.
And for the api, I assume its just a set of interfaces. So in that case you might wanna make a proxy implementation of the interfaces which encapsulates your actual model, where it might be fine to merge some storage behavior with data model behavior.
oh, fr, thats a good point! Thsnks
Is there any way to have a variable E in an abstract class, which is of a different type based on which class is extending it?
Incompatible types. Found: 'me.ocracked.playagain.tasks.HealPoolTask', required: 'java.lang.Object'
package me.ocracked.playagain.tasks;
import com.andrei1058.bedwars.api.arena.GameState;
import com.andrei1058.bedwars.api.arena.IArena;
import com.andrei1058.bedwars.api.arena.team.ITeam;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import me.ocracked.playagain.Main;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
public class HealPoolTask extends BukkitRunnable {
private final ITeam team;
private final int maxX;
private final int minX;
private final int maxY;
private final int minY;
private final int maxZ;
private final int minZ;
private final IArena arena;
private final Random r = new Random();
private final int particles = Main.instance.getConfig().getInt("heal-pool-particles");
private static final List<HealPoolTask> healPoolTasks = new ArrayList<>();
public HealPoolTask(ITeam team) {
this.team = team;
int radius = team.getArena().getConfig().getInt("island-radius");
this.maxX = Math.max(team.getSpawn().clone().add(radius, 0.0D, 0.0D).getBlockX(), team.getSpawn().clone().subtract(radius, 0.0D, 0.0D).getBlockX());
this.minX = Math.min(team.getSpawn().clone().add(radius, 0.0D, 0.0D).getBlockX(), team.getSpawn().clone().subtract(radius, 0.0D, 0.0D).getBlockX());
this.maxY = Math.max(team.getSpawn().clone().add(0.0D, radius, 0.0D).getBlockY(), team.getSpawn().clone().subtract(0.0D, radius, 0.0D).getBlockY());
this.minY = Math.min(team.getSpawn().clone().add(0.0D, radius, 0.0D).getBlockY(), team.getSpawn().clone().subtract(0.0D, radius, 0.0D).getBlockY());
this.maxZ = Math.max(team.getSpawn().clone().add(0.0D, 0.0D, radius).getBlockZ(), team.getSpawn().clone().subtract(0.0D, 0.0D, radius).getBlockZ());
this.minZ = Math.min(team.getSpawn().clone().add(0.0D, 0.0D, radius).getBlockZ(), team.getSpawn().clone().subtract(0.0D, 0.0D, radius).getBlockZ());
this.arena = team.getArena();
runTaskTimer((Plugin)Main.instance, 0L, 70L);
healPoolTasks.add(this);
}
public void run() {
if (this.arena == null || !this.arena.getStatus().equals(GameState.playing)) {
cancel();
return;
}
for (int x = this.minX; x < this.maxX; x++) {
for (int y = this.minY; y < this.maxY; y++) {
for (int z = this.minZ; z < this.maxZ; z++) {
Location l = new Location(this.team.getSpawn().getWorld(), x, y, z);
if (l.getBlock().getType() == Material.AIR) {
int chance = this.r.nextInt(this.particles);
if (chance == 0)
l.getWorld().playEffect(l, Effect.HAPPY_VILLAGER, 1);
}
}
}
}
}
public static boolean exists(IArena arena, ITeam bwt) {
for (HealPoolTask hpt : new ArrayList(healPoolTasks)) {
if (hpt.getArena() == arena && hpt.getTeam() == bwt)
return true;
}
return false;
}
public static void removeForArena(IArena a) {
for (HealPoolTask hpt : new ArrayList(healPoolTasks)) {
if (hpt.getArena() == a) {
healPoolTasks.remove(hpt);
hpt.cancel();
}
}
}
public static void removeForArena(String a) {
for (HealPoolTask hpt: new ArrayList(healPoolTasks)) {
if (hpt.getArena().getWorldName().equals(a)) {
healPoolTasks.remove(hpt);
hpt.cancel();
}
}
}
public ITeam getTeam() {
return this.team;
}
public IArena getArena() {
return this.arena;
}
}
..
same class
which line?
73
81
90
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
paste it
oki
new ArrayList<HealPoolTask>(healPoolTasks) maybe
idk why u create a new array list
but that'd fix it
tysm it fixed it
public abstract class Beast<E extends Mob> implements Soul {?
Thing is that E wouldn't extend Mob
It would implement Mob
But I cant do Beast<E implements Mob>
Does it work fine anyway?
(I want E to be an instance of an object which implements Mob)
Generic extends means both implementing and extending
Ahh alright cool
also I am getting this warning here
Is generic casting bad?
Cause if I don't cast to E then I won't be able to save what world.spawnEntity() returns to mob
Not bad
But cannot be checked unless you have something which can keep the type at runtime
Is there any way to avoid this warning? Is suppressing the only way
or I mean should I be ignoring that warning
replacing Beast with Beast<?> removes the warning, but it feels wrong to do that
Is it alright to use <?> when I am fine with anything being assigned to the generic?
sure
unless it is supposed to be some sorta type
Alright
using jda chewtils to make jda commands but this also applies to discord slash commands in general.
I have a /play command and I want to have 4 options: link youtube youtube-music and soundcloud. Is there a way to make it so they have to chose 1 option? But like it doesn't matter which but they have to chose 1 and can't chose another. Or do I have to set up subcommands?
Yes you can do that
Idk about chewtils but just don't mark the sub commands as optional?
oh so I Do have to make sub commands
I was trying to do it with just Options
but makes sense
Yea
If you want a larger than 32 char sb you need to double buffer which is what can cause flicking or the cause could be spamming updates every tick. Other than that shouldn’t flicker
https://paste.helpch.at/muquxicufu
https://paste.helpch.at/oyinujalug
anyone know why the console log is: started routing routing end done stop? ws and ws end don't print :/
Before I was using CIO instead of Netty, but since CIO doesn't support https i switched to something else
i've tried with other server engines so i don't think thats the issue
CIO doesn't support HTTPS? 
nope 🥲 (the server doesn't, idk about the client)
CIO Engine does not currently support HTTPS. Please consider using a different engine if you require HTTPS
Where did you find that?
Which version? ;o
I thought that was fixed already
Hmm maybe i was thinking about 2.0
Early access
Changes a lot btw, so i don't know if it's a good idea to try it right now
Yeah
Also if you want you can try creating your own engine
does ur code look different than mine?
Also if you want you can try creating your own engine
uhhh 💀
Well i never really used websockets with it
Basic routing for a rest API
:/ even if i remove ssl
it doesn't work
it's just when i have the environment parameter it stops working
nvm now nothing works 😦
Are there any JAR's or something similar that I need on my computer to create a discord bot in java?
You need a jdk installed
Jar was the wrong word
But else than that
I need that installed? Don't I just put that in my build.gradle?
yes
Yes
in build.gradle
So it doesn’t really count :p
Oh yeah I'm pretty sure I already have that, I just imported a discord bot file I had and it's not recognizing jda so..
IntelliJ?
Since you could technically go with the standard jdk tools to build something to interact with the discord api.
Yessir
Reload gradle project nevertheless
lol
Holy cow
wait
jcenter bad
totally
There 🙂
Yeet jcenter
verbosity 😷
What does JCenter do?
its a repository thats going bye bye
Nothing
So why was it there? 🥲
Hmm
and see if there are any errors
Alright, but is there literally no reason to have JCenter..?
Not anymore, JCenter is closing
use Somethibg like jetbrains annotations
There is another one, just can’t get it on my mind rn
For the JDA utilities
Might wanna check up on that dependency
jda uses javax
Oh, it's the implementation that's an issue
Link me
Like link an example where JDA uses it
Afaik they used their own annots but that was a while back
It uses javax yeah
Java wrapper for the popular chat & VOIP service: Discord https://discord.com - JDA/ActivityFlag.java at master · DV8FromTheWorld/JDA
ez
Ah well
Is that something I need to import orr
I can't even find jda utilities' latest version on their github 🤨
wut
route("/testing", HttpMethod.Get) {
handle {
println("handle start")
call.respondText("Hi! ${Random.nextInt(1..5)}")
println("handle end")
}
}
webSocket("/chat") {
println("ws")
session = this
runSession(this)
println("ws end")
}
```anyone know why does `/testing` work but not `/chat` ☹️ (gives 404)
or what i could do to debug
Hey probably a very stupid question but how do I get random Files from a folder?
(Javascript on a website)
Also probably a stupid question - When using a jar application, where exactly do I set the path to jar?
the jar 🥲
what r u trying to do?
Remember what you did for me a while back?
I don't have a jar
I'm trying to run my discord bot on my machine
gradle run
just put gradle run..?
well
exit out of the configurations menu and double click ctrl
then type gradle run
if you configured ur build.gradle correctly
it should run ur bot
Task 'run' not found in root project 'TheHokage'.
I guess I didn't configure it correctly
show build.gradle
ctrl click twice again
and type gradlew
then tell me what gradle version it says
7.1
[run]
Could not find or load main class your.package.MainClass 🤨
u need to change that 🥲
Also, jda has support for slash commands right?
yes
inside the ctrl x2 menu?
yes
How can I update this (1.8) function into a 1.17 one?
public void inject(Player player) {
CraftPlayer craftPlayer = ((CraftPlayer) player);
channel = craftPlayer.getHandle().playerConnection.networkManager.channel;
channels.put(player.getUniqueId(), channel);
if (channel.pipeline().get("PacketInjector") != null) return;
channel.pipeline().addAfter("decoder", "PacketInjector", new MessageToMessageDecoder<PacketPlayInUseEntity>() {
@Override
protected void decode(ChannelHandlerContext channelHandlerContext, PacketPlayInUseEntity packet, List<Object> list) throws Exception {
list.add(packet);
readPacket(player, packet);
}
});
}```
The problem is with playerConnection
if (event.getMessage().getContentRaw().equalsIgnoreCase(Constants.TheHokagePrefix + "shutdown")
&& event.getAuthor().getIdLong() == Constants.ownerID) {
event.getChannel().sendMessage("Access granted - Shutting down").queue();
event.getJDA().shutdown();
System.exit(0);
}
```Anyone know why the message isn't being sent but the bot is shutting down?
@upper walrus check your dm please 😅
playerconnection has a different variable name. Its b in 1.17
Shutdown is instant while queue() is... queued.
Do .complete()
what about network?
Gotta find the variable name for that. IDK it off hand sorry.
Wait I found it lol
Channel channel = ((CraftPlayer) p).getHandle().b.a.k;
I was recently working on packets and had to find the obfuscated variables myself
ah ty so much
np
I'm getting a
class file has wrong version 60.0, should be 52.0
Error on compilation
For
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;```
You're compiling with Java 16 and attempting to run on Java 8
Wont work
Is there a way I can fix it without swapping?
If I swap to 16, I get
Could not initialize class org.jetbrains.jps.builders.JpsBuildBundle```
No, You cant run something compiled for a newer version on an older version. You need to specify Java 1.8 as the target version in your build tool
How can I do that in IntelliJ?
What build tool are you using?
I'm not sure what that is but im using artifacts in the project structure
Ew
Please switch to a proper build tool, you'll have an easier time around
Anyway
File -> Project Structure -> Project SDK
Yea
What should I do inside of 1.8 tab?
I have src of a plugin , it has a class called papihook , but now I aint able to figure out what are its placeholders...... can someone help me out ?
I mean look in the class
ok
Do chunks outside of the world border not load for example if I create a small world border that means it won't use server resources loading chunks that can't be accessed right?
to an extent yes
they'll likely still render whatever your server render distance is outside of the border
Hey does anyone know how to bypass the autoplay policy? I am working on a Loading Screen for Garry's Mod for a private Server. because we have long load times sometimes we wanted to add music to the loading screen. The problem is that the Music doesn't play. In the Browser I get this in the console : The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. Once I click the page once it works fine, but I can't click inside Garry's Mod because it doesn't work
Weird, I created a custom world just now, an empty world and set the world border with a radius of 40, the world folder is 200x larger than the preset worlds???
the preset worlds prob weren't pre rendered
because when you render out a world, the folder becomes the chonkiest shit you've ever seen
is 300mb for an empty world with an area of only 40x40 normal though?
Also one more question, do you know a way to store worlds in memory instead of them actually generating a folder?
no
Alright, thank you for your help 🙂
no
204 chunks (overworld), 18 (nether), 0 in end, haven't reached it yet ~1gb
help
@pulsar ferry not worked command: /dm open advancedmenu GABSSGOD
@celest tendon
Can you chill my buddy
and what should I watch there?
because from what you described, it's not development related but rather, a configuration one
Hey, im having a little bit of a issue, and would like to ask for help:
I have set up a integer in my config.yml which can be used to define a block.
This block should then be pasted down below in
block == Material.[The Block]
Does anyone know how I can paste it in there?
(Yes, I've looked it up, but I cant seem to find anything that helps.)
My config is layed out with 3 variables in this example, lets just say the variables are "block-1", "block-2" and "block-3".
.complete() after what?
pretty much
I want it to use the variable
hm
I would prefer if my config could just be
STONE
use .complete() to send it immediately. instead of .queue()
without the Material.
since I wanted that to be pre-defined
woah
that is
surprisingly complicated
if (block == Material.) {
player.sendMessage("Test");
Oh 🤔 so why wouldn't I set everything to .complete()?
Im gonna look if it works, thank you!
Rate limits
complete doesn't affect ratelimits vs queue afaik
don't use - it blocks the thread use it for this case but not everywhere.complete()
wheras .queue() runs async
it's the same with bukkit - if you run laggy tasks on the main thread, it'll lag the server
so if you do queue() and then a complete() inside the success consumer, I think that should be fine
if you use too many .complete() operations on the main thread, jda will throw an error in console too
in this case you should use .complete()
(but how it works is that complete() blocks the thread so it won't shut down until the action is completed)
It’s like await for an async function
What could be wrong when registering a command...?
this.getCommand("aw").setExecutor(new *******Command());
(The full file is censored for secure reasons. The IDE does not shows any errors, but the server cannot load this line, and disabled the plugin. Is my server the problem or... I am just too tired to fix it...?)
"the server cannot load this line, and disabled the plugin" what does it say or do exactly? how do you know it's disabling the plugin?
Well... Easy awnser: after a reload (there are only three other plugins, and I am optimanizeing the plugin), the plugin becomes red in the /pl, and actually... I get a big error.
This is just some lines from the error
[00:12:50 ERROR]: Error occurred while enabling AgeWars v1.0E-4 (Is it up to date?)
java.lang.NullPointerException
at agewars.nog.****.Loader.onEnable(Loader.java:16) ~[?:?]
does it work fine without reloading? on normal startup
Lemme try 🤔
..?
Uuuh.. No. It doen't works.
🤔
if it's not there, getCommand will return null (and that line there will throw an NPE which is what's happening)
That might be true. Once the server actually said, that the plugin.yml is invalid, and I was like... WAT?
if it was in the plugin.yml then it would work fine
Oh yes. That was the problem. Thank you for the help.
I learned a lesson: using getCommand("cmd").setExecutor requires plugin.yml.
myes
If I want to hide a file in .gitignore, can I just type out the file name or do I need to also type out the directory?
Thanks
But I screwed up when pushing my project to github, I deleted the repository but I also wanna reset the project in the ide
It still thinks it has a repository
you need to do a couple things:
- delete
.idea/vcs.xml - Go to
Settings | Version Control, select themapping(s), click[-]icon or pressDeleteto remove the mapping or change the association toNone. - delete
.git
ye just disable that
I can't
huh
o
am I gonna need a new project
I don't have a .git folder
then just delete vcs.xml 🥲
does the button at top bar say VCS or Git?
VCS
thats where it stores local git history and stuff
o
i think u should be good then
np
Ok time to start again
It's not working 🥲 I try and share project on github but it says remote origin already exists
proceeds to spam press until github runs out of storage 🙂
you'll probably run out of life before that happens
maybe if we band together we can achieve it before then 🙂
we'll get banned before that happens
also. why would you want to ruin github?
its already bad
enough
so we can launch our own product and gain an instant fan base
So what do I press..
but share on github makes sense
- Create git repository
- Manage repotes
- add https://github.com/YourUsername/YourRepository.git
It doesn't recognize https://github.com/YourUsername/YourRepository.git
plz tell me u changed YourUsername and YourRepository
delete github

I could try again
i thought u were changing repos
oh
Also - when I get asked this
then press Share to Github
and delete these two
🥲
That's when I share to github
Yeah but nothing's in it
do u still have 2?
master/main
Literally master/main?
btw
add .idea to gitignore
@limber lagoon
you shouldn't really put IDE specific stuff (such as .idea) in git
and whenever you want to update gitignore run the commands (after changing gitignore): ```
git rm -rf --cached .
git add .
````rm= remove (to remove files that should be ignored)-rf= recursive (for folders)--cachedso that it doesn't remove the files from the git repository.= all filesadd` = readd the files that weren't ignored
Oh okay
and where do I run these commands?
Ok I pushed the new commit
Yet it didn't update?
😔
I thought github was simple
i dont think thats related
Hm
Well do you see your files in blue names
in intellij
terminal
right click .idea/ folder and click add to gitignore
or something similar to that
after its added to gitignore run these commands
Okay I did, then I go to git (at the top) -> commit -> write my message -> commit -> back to the top -> push?
or can I just Commit and Push
if you did this, then commit & push
I did infact run the commands
So, how do you know this
Where did you learn all that
uh
yeah but on the left
no u just press push
which one do I click on
or commit
it's push
left just shows what ur committing
Oh it's not actually a selection? 🥲
nope 🥲
Hey friends, I need career advice 😄
My employer just sent me my new contract in which my position is called "IT Specialist".
Is having that on my CV bad when there is a good chance I will try to apply for jobs in 100% Software Development in a couple years? (as of now, development is only part of what I do)
You'll most likely only need to submit a resume when applying for a job. Just exclude this position in it if you feel like it doesn't contribute to the position you're applying for
Well if I leave that out I'm gonna have a hole in my resume right after I finish my masters and raise even more questions why my masters took so long 😄
BSc Computing (2018)
Jr. Software Developer 20h/week (2017-2021)
MSc Information Technology & Management (2018-2022)
IT Specialist (2021-2023 maybe)
I mean, can I just informally agree with my employer on a cooler title and call it a day or does it have to say the exact title on the contract and I need to sort this out before signing it?
oh wait, this should've been in #dev-general I hope cube doesn't lynch me 😳
In the contract
Wait, why have you taken 4 years for your msc?
Had to learn how to make Spigot plugins 😩
I postponed plenty of exams and now here we are 😄
I suppose it's not that bad, because I worked 20+ hours all the time, but I know it doesn't look epic. But one more reason I cannot just leave out the jobs I did 😄
what...?
I assume thats a joke xD
rip
There's a little truth to every joke 🙃
@lyric gyro Not 100% sure, but don't you have to specify a delay in runTaskLater() ?
oh, I'm turbo blind.
You forgot the , tho, didn't you 🤔
before 30L
https://img.olziedev.com/vY489iZDR489Rv489489W.png does anyone know this is for luckperms
I did ask in their discord, taken longer than a day lol
i wanna get all users in the db
what database
isnt normal db request faster
probably. pretty sure lp api doesnt even offer that so maybe that's what they want
also i doubt there is lp method "get all users"
yeah i am using their api they do have a method called getUniqueUsers
not sure if thats all users in the db though
Test?
yeah thats what i am doing lmao
@lyric gyro answer them or else
in their docs it literally just says gets all unique users
so its not really much of an explanation
That seems like what you want
Yeah, i wish it loaded it as a user object though so much easier xd
PlaceholderAPIPlugin.getInstance().getCloudExpansionManager().downloadExpansion(…)
I think?
question. in C# the default SystemSounds only work in windows? Because I'm trying to play them and I hear nothing. am on linux rn
oh nvm.
Retrieves sounds associated with a set of Windows operating system sound-event types.
if only I Could read the docs
Hmm. New question. So I have an Class Library in my solution and under it I have a Sounds directory and in that directory I have an MP3 file. How would I get this file using relative paths? This is basically my setup:
Solution -> Project -> Class.CS
-> Utilities -> Sounds -> Sound.MP3
And I'm trying to get the sound from class
oh ok. Directory#getCurrentDirectory might get me there
Hi, is it possible to hide a world border (WB API)? So it will remain existing, but is invisible when you are far away.
Hmm it needs an instance of CloudExpansion
how do I get that?
Do i have to do it like it?
CloudExpansionManager#findCloudEpansionByName
Thank you
does anybody got that problem w moded/plugin minecraft:
The drops just vanish
huh?
why would you need to do that?
load-before does not prevent your plugin from loading if the other is not present, just so you know; it's somewhat like "other plugin soft-depend on this plugin"
in fact, that's literally what it does lol https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/plugin/SimplePluginManager.java#224-238 it literally adds "this" as soft-depend of the other
I know that
and my plugin have an extension system, so if any other developer wanna make an extension that uses another plugin's API than I need to plugin to have a soft depend of that "another plugin" So that plugin don't get loaded after my plugin.
Cause if it does than my plugin's extension will error out
it's probably possible to use reflection (idk about java 9+ tho), but imo just don't worry about it - it's just a warning, not an error
and iirc the same is with PAPI
hm what you can do is check if the other plugin is loaded:
- if it is, load the extension
- if it isn't, just wait and listen to the PluginEnableEvent so you can load the extension then when the respective plugin enables
it'll still give the warning tho - but thats a good idea 👀
#general-plugins please
https://pastebin.com/gMRBhms7
can somone explain me why the "3" are not brodcast ?
at line 42 - 43 the outpout are the same but the next line don't become true
It's because how you are comparing the objects
No check the x y z and worldname
Oh thx i go try rn
public boolean isEqual(Location from, Location to) {
return from.getWorld().getName().equals(to.getWorld().getName()) && from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && to.getBlockZ() == from.getBlockZ();
}```
^
or just from.equals(to)
thx 😉
wath difference between '.equals' and '=='
== compares instances
ex java Location a = new Location(world, 1, 1, 1); Location b = new Location(world, 1, 1, 1);
a == b would be false, while a.equals(b) would be true
new = new instance
you'd usually use == except for enums/constants (ex Material, Sound) and primitives (int - 4, double - 4.5, char - 'c', etc) since primitives aren't classes, and so they don't have methods so .equals wouldn't work
idk if I'm stupid or smthing
@Getter private YamlConfiguration data;
public YAML enable(Plugin plugin) {
file = new File(plugin.getDataFolder(), "language.yml");
if (!file.exists()) {
try {
boolean success = file.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
data = YamlConfiguration.loadConfiguration(file);
for (LanguageEnum lang : values()) {
if (lang == null || lang.getKey() == null || lang.getKey().isEmpty()) {
Bukkit.getConsoleSender().sendMessage("what");
return this;
}
data.set(lang.getKey(), lang.getValue()); < error here
}```
java.lang.IllegalArgumentException: Cannot set to an empty path```
Send your LanguageEnum class
Just an enum with several VALUE("key", "value");
none of them are null/empty
@Getter private final String value;
LanguageEnum(String key, String value) {
this.key = key;
this.value = value;
}```
problem found
Does anyone know if I have to call the release function of a ByteBuf if im using ByteBuf.allocate()?
one of the keys was incomplete (ended with a .), i.e something-asd.
thought so, good job debugging!
cheers
Nope
its on the jvm heap
ahh kk
will be gc'd
diretBuffer?
you mean when calling allocateDirect ?
Still no afaik
Yeah
It there was such a requirement it would be explicit in the jvadocs
idk why i said ByteBuf#allocate
it should be unpooled
lol
seems like ur right tho
either way
Yeah
Not sure if there's anything to explicitly release it
I'd assume its taken care of with a phantom ref or something
Might be in the wrong place here, but im new to discord/PC in general and I downloaded Minecraft Java Edition through xbox gamepass and I'm trying to add it on steam as a non-steam game so i can use a controller but the file is nowhere to be found. Anyone have any advice or is there somewhere else I should be asking this?
Ok, where is a better place
ok thanks
since when is java edition on xbox game pass
lol
who knows, its probably not im so lost lol
oh it does include it
If you have an active Game Pass Ultimate or Game Pass for PC subscription, you can install and play both Minecraft: Java Edition and Minecraft for Windows on PC.
Anyone who has experience with JacksonJson:
I have a class that I serialize/deserialize into Json, and some of the fields are annotated with @JsonProperty. When they object is serialized, however, it also serializes fields/getters that are NOT annotated with @JsonProperty. Is there a way to make these fields not be serialized by default, without @JsonIgnore'ing each one?
praying @JsonIgnoreProperties(ignoreUnknown = true) works (update: it doesn't)
alternative annotation found
where can i report discord error?
did somebody ever got the problem of no food dropping by mobs?
i play on magma 16.5
How can I check if a player puts an item in a slot? I want them to put X item into a slot then for item Y to update its lore based on the item name
not in this discord server. This is not Discord Support but rather Minecraft and general development support. if you want support with discord then you need to go to https://support.discord.com
😦
🤣 🤣 🤣
You know whats funny? The description says it is for Minecraft related stuff LOL
yeah well ig people don't read that bit
11211 members
=flex
/flex
idk what the command is
11219
personally I love how there's 2 links to helpchat
and both have different member counts
Here are some guild wide stats for your eyeballs. :eyes:

23,378,114
24,941
68,471
150,927
84,434
71,952
4,897,743+
11,219
Mar 29 2016
you were looking for this?
Hio,
How can I check if a player puts an item in a slot in a custom gui? I want to make a repair GUI, so a player puts their sword in and the item they click to purchase will have a cost depending on how much money it will take to repair
Nice idea thanks 😄
correction: your discord is nowhere near our discord.
I can make it so when I click purchase it updates the cost but i'm not sure how to cause the update when the player drags the item into the empty slot
Inventory click event has inventory action
Is it possible to insert a row with a defined rowid in mysql/sqlite?
how do i make a for(int..... loop that has a countdown
for(int i = 54; i < 0; i--)
how do i make a countdown in this loop
delay the execution
i want to go from 54 to 0
Got him
I is on mobile, leave me alone
but then he says 1
player.sendTitle("Hello!", String.valueOf(i), 2, 20, 2);
}```
it goes from 54 instant to 1
how do i fix that?
=
you mean i?
who is u?
And your 1 letter variables
I think he's asking how to make it go each second
instead of just printing the numbers at the same time
I mean I did mention a delay
Where?
.
how do i add a delay 😂
.
you mean
@Override
public void run() {
for(int i = 54; i > 0; i--){
player.sendTitle("Hello!", String.valueOf(i), 2, 20, 2);
}
}
}, 20L); ```
this?
Not exactly
Since that'll delay the entire thing and the prinout will still be instant
how should it be then?
You could use that but have a variable you initialise outside of the loop and increase within with i++ for example and then check if it exceeds your given value and stop the runnable
this:
int currentHP = (int) Math.ceil(entity.getHealth() - dmg);
if (currentHP < 0) {
currentHP = 0;
}```and this: `int currentHP = (int) Math.max(Math.ceil(entity.getHealth() - dmg), 0);` are the same thing, right?
Trying to refactor my method so it has less lines
I believe so yes
you could also do
int currentHP = entity.getHealth - dmg < 0 ? 0 : (int) Math.ceil(entity.getHealth - dmg)
tho the max one would probably be cleaner
final AtomicInteger index = new AtomicInteger(54);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
final int current = index.getAndDecrement(); // or whatever the hell the get and then lower by 1 method is called
if (current < 0) {
this.cancel(); // can't remember if it's cancel or stop
return;
}
// send title
}
}
Don't quote me on this tho, I can't remember the exact methods cause fuck spigot
runTaskTimer 😌
Whenever possible it's better to run tasks async right?
depends
what are you wanting to run async?
I mean idk in general, I got multiple tasks in my plugin so I was wondering if I should try running whichever I can async
not everything should be async
bukkit things should usually be ran sync unless it specifies that it's thread-safe (ex ChunkSnapshot)
I mean whichever code actually works async
so it depends on what you're wanting to run async
and also variables/lists are not thread safe by default
Uhm okay
run it async, if you get problems then don't run it async 🤷
wiser words were never spoken
Async doesn't always mean better performance
Where's triumph chat weeb
Asynchronous good for parallel computing
Do you consider that parallel computing “speeds up the full, large scale task” or do you think it simply “reduces the time”
I’m just wondering lol
Cause obviously async != faster
It could do the complete opposite depending on the number of threads
well yeah. Obviously if there is a bunch of threads waiting for other ones to finish (too much divison) its bad
but assume its the optimal number
It simply lets the cpu time share between tasks, time taken on the cpu is usually the same, just multiple things share the time

