#help-development
1 messages · Page 676 of 1
yes
Client console?
yes
Or just go to logs
ok it may not be called client console, I forgot what it's actually called lol
Ah i was missing a bracket in the file lol
I found it using the logs but how can i access the client console
If you're using vanilla launcher, there is some setting in it.
/home/minecraft/signal/start_cmd: line 1: 12282 Killed /opt/java/17/bin/java -Xmx${SERVER_RAM} -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -DIReallyKnowWhatIAmDoingISwear -Djline.terminal=jline.UnsupportedTerminal -jar server.jar what does this error mean?
its not my server
It typically means there is an issue with your argument most likely it didnt specify the ram amount
someone in minehut chat posted it
Don't allocate 100% of the systems ram to the server
he said it was full log
Leave some ram for the OS and java overhead
you cant change the arguments on minehut
Assuming that is the issue. The other issue is the script didnt intepret it was supposed to replace the value there and left it as is
Then you contact Minehut about the issue
it could be caused by a plugin using native memory but I doubt that would be the case
Plugin wouldnt cause the script to complain about a line
It can
Well i never experienced such things then nor ever heard of a plugin causing such things. But if its a possibility i suppose check for weird plugins
depends, you have 2 options
load: STARTUP
load: POSTWORLD
they're kind of self explanatory. The default is POSTWORLD iirc
where can you change them?
in plugin.yml
or whatever it's called
ok
Hi, do you know what's a good way to test my plugin performance? I cant get many players online at the same time, is there something good for botting my testserver?
The load setting actually changes when the plugin is enabled
They are all loaded at the same time
run /timings
Hello, I would like to be able to cancel this Bukkit task after a certain number of uses
BukkitTask routineTask = Bukkit.getScheduler().runTaskTimer(main, (Runnable) () -> {
if (i[0]+1==playersRoutine.size()) {
return;
} else if(!playersRoutine.get(i[0]).isOnline()) {
i[0]++;
}
player.sendMessage(ChatColor.GOLD + "Téléportation sur " + playersRoutine.get(i[0]).getDisplayName() + ChatColor.GRAY + " (" + i[0] +1 + "/" + playersRoutine.size() + ")" );
}, 10, timeInTick);
How could I implement this?
Thanks in advance
use a proper anonymous class
(or an actual class)
How can I set this up from another class ?
easiest way is to use an anonymous class with the consumer
Bukkit.getScheduler().runTaskTimer(myPlugin, new Consumer<BukkitTask>() {
private final int maxRuns = 10;
private int currentRun = 0;
@Override
public void accept(BukkitTask task) {
// here's your code that runs every tick:
// ...
// Now we cancel ourselves after 10 runs:
currentRun++;
if(currentRun >= maxRuns) {
task.cancel();
}
}
}, 1, 10);
to do this from another class, you just move the whole thing into its own file, e.g. like this:
public class MyTask implements Consumer<BukkitTask> {
private static final int maxRuns = 10;
private int currentRun = 0;
@Override
public void accept(BukkitTask task) {
// here's your code that runs every tick:
// ...
// Now we cancel ourselves after 10 runs:
currentRun++;
if(currentRun >= maxRuns) {
task.cancel();
}
}
}
and in onEnable:
Bukkit.getScheduler().runTaskTimer(myPlugin, new MyTask(), 1, 10);
You can just have the currentrun++ as part of the if
ofc, but that's not the point
it also confuses people, especially if they don't know how to declare an anon class
Shh
but yeah sure, that would work
Every extra line of code means a kitten gets sad
I'd rephrase it to "every extra line of code and frostalf starts to discuss with Emily about the implementation of java's FileSystem class"
coll have you seen my ultra fance buildtools PR
Lol
No
"does it look correct?"
has buildtools always had a gui
it's not merged yet
but you can get it from #1117702470139904020
would it be a seperate utility or smthn?
It’s built in to the jar
nah it's the same .jar
double click = GUI, run from console = same as before
seems legit
Run from console with any args*
I still pledge to add a --gui option
yeah i assumed
cause how else would you tell the difference ig
by checking whether System.console() is null
or not
well yeah
but this is funnier
probably makes sense that way for the most people anyways
does anyone know why i cannot create an injector?
[14:22:50] [Server thread/ERROR]: Error occurred while enabling NightMarket v1.4.5 (Is it up to date?)
java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'
at com.google.inject.internal.MoreTypes.<clinit>(MoreTypes.java:61) ~[?:?]
at com.google.inject.TypeLiteral.<init>(TypeLiteral.java:83) ~[?:?]
at com.google.inject.TypeLiteral.get(TypeLiteral.java:150) ~[?:?]
at com.google.inject.internal.ProviderMethodsModule.<init>(ProviderMethodsModule.java:60) ~[?:?]
at com.google.inject.internal.ProviderMethodsModule.forObject(ProviderMethodsModule.java:93) ~[?:?]
at com.google.inject.internal.ProviderMethodsModule.forModule(ProviderMethodsModule.java:67) ~[?:?]
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:435) ~[?:?]
at com.google.inject.spi.Elements.getElements(Elements.java:113) ~[?:?]
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:160) ~[?:?]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107) ~[?:?]
at com.google.inject.Guice.createInjector(Guice.java:87) ~[?:?]
at com.google.inject.Guice.createInjector(Guice.java:69) ~[?:?]
at com.google.inject.Guice.createInjector(Guice.java:59) ~[?:?]
For some reason it works on loads of other servers, this exact plugin. But for some reason its not working on this specific server.
In the plugin.yml, i do have the guice library specified and it does download it correctly on this server.
https://haste.olziedev.com/huqipedaxu.less downloads for the working server.
https://haste.olziedev.com/etiqumizor.css downloads from the not working server
which dependency is "MoreTypes" class from?
guice?
t's google common and tbh I also don't see any buildOrThrow method there https://guava.dev/releases/23.0/api/docs/com/google/common/collect/ImmutableMap.Builder.html
paste the full stacktrace
its guava 31 thats being used
The full strace would be helpful
Huh but where does it come from
Whats line 30 in onEnable
How did you include guice? Shaded?
plugin.yml libraries
otherwise i cannot upload the jar on spigot it will be too big
Is the version in plugin.yml the same as in your pom?
yes
like i said, its inconsistent. works just fine for all these servers, apart from one server
Then paper 1.17 included an outdated version maybe?
ouch, thats a bit stupid if thats the case
Does the library loaded message appear
yes
Is it still too big if you shade guice, relocate it and use minimizeJar?
look at these messages
Doesn’t show the library loaded message
check the haste links
Ah I didn’t see those
i would of thought the bukkit class loader will always make the libraries take priority over itself
so maybe perhaps paper has an older version of guava?
in your main class, add a static init block that does Guice.class (or whatever class) and print out getProtectionDomain().getSource() or what's it called
and see if it actually uses the library-loader .jar or whether it's coming from somewhere else
have you tried whether you can just shade it using minimizeJar though?
idk if paper does (or did, in 1.17) any funny class loader things
might have to ask there although they'll probably just tell you to update to latest
yeah im not the actual server owner ahah
im just the developer and only one of my clients is having this issue out of all my clients and myself, found it very inconsistent
for now, i'll try running it with 1.17 on my local machine see if there is any similarites .I just found it incredibily weird
print out the resultof this Builder.class.getProtectionDomain().getCodeSource().getLocation().toString() where Builder.class is any class from guice
guava*
yeah guava, guive, whatever
but yeah ty
you know what I mean 😄
sorry im being cheeky ty for the idea
if it does not point to the libraries/ .jar then there's sth wrong
ah yeah well, news is its only doing it with 1.17
ouch,....
its coming from the inbuilt dependencies from paper
yeah apparently paper issue
did they patch the class loader?
anyway this is probably time to ask on paper's discord. The class loader should "prefer" classes from the libraries instead of builtin ones
Well its an outdated build and wont provide any support
i know 1.19 and higher works just fine
although as said, you can easily fix this by shading guava yourself - have you tried whether minimizeJar gets the file size below the upload limit?
i'll try that now
don't forget to relocate it!
yess
i guess this will also add support for 1.15 and below
as 1.16 and higher added library downloading i believe
maybe but nobody uses 1.15 and below (except 1.12.2 and 1.8.8)
?whereami
would be funny if ?whereami would suddenly dox people and tell them "You're in <city>, duh"
im sorry md_5 🙏
your profile looks like choco's pfp
im unaware of who that is
Legit
bro the pictures look nowhere alike
can I get imajin's discord roles, now that he deleted his account? /s
Chocos old one
ouch with minimize jar its now 3mb big
oh i thought spigot was 2mb
Hi, yesterday i was looking for a small standalone solution to find classes in a package
i found an answer on stackoverflow but it doesnt seem to work
ill link it in a moment
org.reflections is always a last resort
yeah i dont want that tho
so basically the issue is from my debugging
File.isDirectory doesnt work correctly
it returns false even if path is a directory
this is the answer
1s ill dig in logs
jar:file:/home/kaspian/Documents/Minecraft/Server/plugins/AxolotlEnchants-1.jar!/com/github/kaspiandev/axolotlenchants/enchantment/impl/hand
hand is a package
it has 2 classes inside
obviously that is not a directory
you're looking at a .jar
that is not a directory
you can get all classes from a certain package inside a .jar like this @onyx fjord https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/ClassUtils.java#L123
i found something rly similar to yours
show code
https://paste.md-5.net/rejajomado.java this is what i ended up with after a few tweaks
because it inits the class
public abstract class $ {
public static void main(String[] args) throws IOException {
try {
Class.forName("com.jeff_media.ursus.TestClass");
} catch (Throwable ignored) {
}
}
}
public class TestClass {
static {
System.out.println("test");
}
}
this DOES print "test"
you don't want that to happen
what do you even need this for?
to dynamically load an initialize classes in a package
and why do you need to do that? seems like flawed design in the first place
you should never Class.forName() anything you don't really want to initialize
but you'll init every class
idk this seems like a huge design flaw
why can't you use contracts instead of reflection
is that for a plugin btw?
because you'll also get a ton of CDNFE if you init classes like that that depend on other plugins that aren't installed
TL;DR bad idea, don't do it pls
do what you gotta do, I still think this is a very bad idea
ik how to deal with this now at least
i found a library that does similar thing to what im doing
found this online https://haste.olziedev.com/xususecohi.csharp
ah its mainly for parent classes i assume
that's a recipe for disaster
i have no idea if it works lmao 😂
I still wonder why anyone would ever need such a thing
i still think org.reflections library >>>
I'm also a champion in doing weird thigns but never would I randomly use Class.forName() or classLoader.loadClass without a very good reason
I made my own addon system
ServiceLoader my beloved
Kinda required
?
the one that nobody uses except vault?
some apis uses it to
no, jdk serviceloader
ah I never heard of that tbh
still looking for a not-totally-out-date book about gradle btw, hmu if anybody knows a good one 
Is there a way to remove the name of an item and also the NBT information? I want like an Gray Glass Pane but when the player hovers over it, nothing appears (its for a menu)?
new ItemStack(myOldItem.getType())
I got rid of the name but cant get rid of the NBT information aka the "minecraft:gray_stained_glass_pane"
you can not make "nothing" appear
The tooltip will always be visible.
well it has to have a type
That is not NBT information, you have advanced tooltips enabled so you see this
that's not arbitrary NBT info but "the least an itemstack must have"
That's shown if you use f1+ h i think
Isnt it F3 + G?
I don't remember
F3+H
F3 + H
F3+G is chunks
you can press F3+Q to list all shortcuts
Cool
csharp 💀
Found another interesting issue. I made an inventory menu so i can click on custom items and then the item will be put in my inventory. I made it so people cant take items out and also cant put items in but for some reason when hold an item, press on an empty slot, keep holding the mouse down and dragging down, i am still able to place items into it. Is there a way to block this?
I do want to keep the interaction that when a person clicks on an item, I can link it to a piece of code I would like to run
probably something to do with InventoryDragEvent
Oh there is an event for that, ill check it
Whenever you move cursor even a pixel, it uses this event instead
Ahh i see
@EventHandler
public void ORC(PlayerInteractEvent event) {
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
if(event.getItem() != null) {
if(Objects.equals(event.getItem().getItemMeta(), EK.getItemMeta())) {
Player player = event.getPlayer();
if(player.isSneaking())
if(player.getInventory().getItemInOffHand().getType().equals(EMERALD_BLOCK))
player.getInventory().getItemInOffHand().setAmount(0);
event.getItem().addEnchantment(Enchantment.DAMAGE_ALL, player.getInventory().getItemInOffHand().getAmount());
Bukkit.getScheduler().runTaskLater(_plugin, () -> {
event.getItem().removeEnchantment(Enchantment.DAMAGE_ALL);
}, 100);
}
}
}
}
}```
@EventHandler
public void ORC(PlayerInteractEvent event) {
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
if(event.getItem() != null) {
if(Objects.equals(event.getItem().getItemMeta(), EK.getItemMeta())) {
Player player = event.getPlayer();
if(player.isSneaking())
if(player.getInventory().getItemInOffHand().getType().equals(EMERALD_BLOCK))
player.getInventory().getItemInOffHand().setAmount(0);
event.getItem().addEnchantment(Enchantment.DAMAGE_ALL, player.getInventory().getItemInOffHand().getAmount());
Bukkit.getScheduler().runTaskLater(_plugin, () -> {
event.getItem().removeEnchantment(Enchantment.DAMAGE_ALL);
}, 100);}
}
}
}
}```
which looks better?
There is a special place for you in hell
To actually answer: neither
Both are trash
you have annotations on the same indentation level
you do not do
if (something)
if (something different)
}, 100);}
Literally what is this
does anyone know their way around proguard?
i want to use libraries per certain packages
No need to be so harsh about it
is there any advantage of having a database interface and having database classes implement it?
Yes
standardization?
Ugh well, whats the advantage if you dont have it?
1 less class
Yes
Anything else you can think of?
I can think of 7 reasons why you would want to decouple it
Unit testing, reusability, mockability and modifiability/extendability are the four main ones that probably matter to you
But yea, for the love of god abstract your dB logic
It's like the easiest thing to abstract as well XD

Myea I lied 🤥
how obvious is it that i dont understand generics
Ok then it ought to work (:
yes
dothe generics mean anything by themselves? or does it only matter how i use them
I mean generics are just higher level types in principle
And partially yes they mean something by themselves
But ofc its how you use them that actually impacts you
Yeah nw (;
what do i do if my methods are like this
You probably wanna go with an adapter class/interface
Look at for instance I think ChatChat (maybe) or LuckPerms
basically they have sth like
interface StorageFacade {
void sinkUser(User user);
void sourceUser(User user);
}
interface AsyncStorageFacade {
CompletableFuture<Void> sinkUser(User user);
… etc
}
so a combined adapter where you also make the storage facade a humble object
(Humble object principle & adapter design pattern are the canonical names of these things)
hi conclure
Hola or I mean hi ofc
hi, is it possible to create webdisplays using a plugin? and if yes are there any available, i havent found any options
As in a website page?
yes
The following code returns the error "java.lang.IllegalStateException: Not scheduled yet" in my console.
if (currentRun>maxRun){
player.sendMessage(ChatColor.GREEN + "Routine terminée");
cancel();
return;
}
Does anyone know why?
how can you solve the problem that there are 4 classes inheriting the interface and all these classes need to be called, but if done in the usual way, there will be code repetition
call under different conditions
Looking to patch out health indicator cheat on my server, this seems like a fairly simple process with some simple packet modification but haven't had any luck, I want to do this myself and not with someone else's plugin but I can't seem to find any source code examples of this online
what will happen if I post a plugin with a similar name on popular servers in spigotMC
hold on
bukkit.getscheudler
kinda reminds me of
Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.
on level 4 you go to hell
bro do u have be that mean just because im bad at coding
everyone have their time on being bad at begging u want everyone to roast ur progress is piece of shit at begging?
was my answer really that harsh ?
Sorry for that.
💀
do u really have to tell people go to hell
do u have autisim
or u get bullied at school
yes
?? what going on
do you know the definition of a joke
you go to the programming hell
not the hell
the place where you go when you commit programming crimes
100%
i gotta be honest i didnt get the joke so :/
what will happen if I post a plugin with a similar name on popular spigotMC servers
and with similar functionality
if you make it clear it's different probably nothing
I’ll write I dreamed of similar functionality and made it not exactly similar in logic
there are minor differences
mm. To be more on topic for the channel, is there a way to treat PotionEffectType as an enum? I want to declare two equal-length lists of effects and duration, but discovered it's apparantly an abstract class for some reason
Do i have to declare a list of PotionEffectType objects, or is there a workaround, or would it be better to press a string list through PotionEffectType#getByName() ?
what are u trying to make
a list of effects to apply, different for a bunch of 'castes'
i'm setting up an constructor and deconstructor and thought it'd be probably smart to not just be like 'PotionEffectType.NIGHT_VISION' etc everywhere
ure trying to delete "PotionEffectType"
and just do NIGHT_VISION instead?
valueOf?
its not an enum
and im not trying to delete it
it just feels wrong to be like
List.of(...)
that got nothing to do with potions
do you want to make a list of effects like this?
what
why do you want to treat it as an enum
basically yes
PotionEffectType#values() returns an array of PotionEffectType
what else do u need
just like an enum but it just isn't an enum
EffectType type = EffectType.valueOF
that is not a thing
cause it's not an enum
??
do YOU have an array?
did you make an array with effects?
i have no idea wha you're saying
its a method
in PotionEffectType
PotionEffectType#values()
values get all enum object
what the fuck are you saying
idk wat you want
Hello, I'm curious someone know why TrimMaterial is an interface and not an Enum class ?
cause you can add new ones. enums are bad for this stuff, tons of stuff that is an enum currently in the API won't be hopefully in short order
Material, Particle, Sound, PotionType, Attribute, tons of sub enums for entity variants, and some more won't be enums at some point in the future
well actually Material will be, it'll just be deprecated, but ItemType and BlockType aren't
I see, but it's more boring to go through all the values, no ?
Is there a way to one-line collect player names as strings and add something? the List#add returns if addition was successful
Bukkit.getOnlinePlayers().stream().map(e -> e.getName()).collect(Collectors.toList())
Should be I imagine, set it equal to List<String> and it might work. I remember doing something similar for CreatureSpawnEvent
I'm not entirely sure what you mean
why do you need 1 line?
write a function that does it, and call that function, there 1 line
cuz i dont want to assign it to a variable
also it helps doing things i dont know how to do to understand the language better
you can probably do it with a custom collector, create a new array list with guava's Lists and pass in what you wnat to add, then the rest of the stream will be added by the collector
Streams.concat seems easier
that works too
don't think i'd do that tho
this is really micro optimization territory, but just creating a stream instance for no reason
i mean i need to convert players into strings anyways
so its either stream or a for loop
a stream is fine, using concat with stream means you have to create another stream just for whatever you want to add
if you use a custom collector, no second stream needed
I really doubt i can make a collector good enough i should use it over just two streams tbh
Collectors.toCollection(() -> Lists.newArrayList("whatever"))
its pretty simple, just creating and returning a mutable list with what you want already added
...so I'm temporarily inserting some test code and my plugin refuses to compile cuz of 'unreachable statement' being a syntax error
is there some kind of flag i can use that it ignores that
correct the code
test code
you have unreachable code, fix it
there is no reason, even with test code to have unreachable code
or just comment it out if you don;t use it
if (true) return is your friend there probably
"",
"§fSpielzeit:",
"§e" + PlaytimeUtil.formatTime(playtimeMap.get(board.getPlayer().getUniqueId())),
"",
"§fTop Spieler:",
ChatColor.of("#FFD700") + "Dofaking",
ChatColor.of("#C0C0C0") + "PidoubleZa",
ChatColor.of("#bf8970 ") + "BlockSeinBuster",
""
[18:51:28] [Craft Scheduler Thread - 0/WARN]: [Playtime] Plugin Playtime v1.0-SNAPSHOT generated an exception while executing task 2
java.lang.IllegalArgumentException: Could not parse ChatColor #bf8970
at net.md_5.bungee.api.ChatColor.of(ChatColor.java:273) ~[bungeecord-chat-1.20-R0.1.jar:?]
at de.doppelbemme.playtime.Playtime$1.run(Playtime.java:58) ~[?:?]
at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:82) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3856-Spigot-94e187b-b76ceb4]
at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3856-Spigot-94e187b-b76ceb4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
I want to use the ChatColor.of from bungee code, which takes a hexcode. Why do I get the error, that it cant parse the chatcolor then?
Where is the space? I dont see it
Given user input for enums, which of those would be better? Doing a try/catch with IllegalArgumentException, or checking if values.stream.map.tostring contains the input, then converting?
I do remember people saying to avoid try/catch
Yeah. You can use a utility method if you'd like. Guava's Enums class helps you do it and get an Optional
im looking at it right now, i can see how that'd be useful
do you by chance know why google is using an internal version of Optional?
use try-catch for OutOfMemoryError 
I'm just realizing the google optionals dont have javadoc for me
can i assume it's the same as for normal optionals?
aren't guava optionals effectively deprecated? I think the javadocs say to use the java util one
oh ok
There are no plans to deprecate this class in the foreseeable future. However, we do gently recommend that you prefer the new, standard Java class whenever possible
what i meant is that the Enums utility class throws the google optionals at me
If you don't wanna use Guava you can use Apache's EnumUtil or whatever it's called lol
But yes, like many of the Guava-duplicate classes (their functional interfaces included), prefer the stdlib ones
tell me, let's say there is a class that stores 4 objects with a common interface, and as the classes expand, it becomes more what to do in this case so as not to write a bunch of code and at the same time store these objects
Collection<CommonInterface>?
but how to create them so that there is no duplication (the parameters are different)
Have a Set and override equals and hashCode in those classes
these classes are used to get data from the config and store it. They have common methods and variables so they have an abstract common class. Each class is each section of config.yml. I wanted to ask how to get rid of code duplication
where exactly is hash use
in all class or abstract
I've seen a project using @Inject but not sure it's worth
?
ur checking if connectionPool is empty
if it's empty size is always 0
so unless max_size is 0, intellij is right
:d
ahah
intellij smort
I was once told that I need to come to terms with the fact that I make mistakes and not intelji is stupid
put(K, V) returns V
no need to put then return get
u can also just use Map#compute to simplify all that but up to u
were use hashCode end equals - in abstract class or in all heir classes
were se
need
idk
How does one make a custom entity with modified goals persistent across chunk unloads and server restarts? I've looked into registering the entity using the registry, but that hasn't really helped.
would there be a way to set a tab completer for the Command class?
since i ain't using PluginCommand
not necessarily?
put; return get isn't the same as return put
it returns the old value, not the value you just put
Map<String, Integer> map = new HashMap<>();
map.put("foo", 1); // Emily smells
int value = map.put("foo", 2); // value = 1
int value2 = map.get("foo"); // value2 = 2```
more like
Map<String, Integer> map = Map.of("foo", 1);
int value = map.put("foo", 2); // throws UnsupportedOperationException
oh,, but..
I HAD IT RIGHT THE FIRST TIME
i thought we had something
Fixed my mistake by reverting to the original
With an extra comment just to be sure
😤
oh that is not very nice
immutable map
?whereami
👍
how many here mems?
ive looked into it and it seems even less possible to me
whats the easiest way to sort players in the tablist by rank? i tried with color code prefix but that doesnt seem to work
team name
if you create a team A and a team B then the players on the A team will be above the players on the B team
(on the playerlist)
ohh so it sorts by the name of the team
oaky thx
can a player be in multible teams
?nms
How do you make a custom entity with modified goals persistent across chunk unloads and server restarts? I've looked into registering the entity using the registry, but that hasn't really helped.
You can register it using the registry
Or you can stick a pdc tag on it so you can identify it and add the goals back
When a chunk loads
I'm using a pdc tag to keep track of my custom entities, but I'm wondering what the purpose of registering an entity is if a pdc can just be used instead. How do you do add the goals back? I thought goals could not be modified once an entity is created.
They can be modified whenever
shouldn't break; split the scope?
switch(something){
case a: Player player; ... break;
case b: Player player; // <- syntax error here
}
also, can i redefine player in case b, or does that also not work?
i am getting an error
yea that does it lol
lambda switch 😍
wouldnt work here
case 1,2 -> {
Player player;
break
}
nah i was just like 'i should be able to do this with switch so why am i getting an error'
its some data manip
brackets create scopes so imma agree on that one
i wasn't aware the switch would be different
i thought it just added the brackets in the background
if (true) return true;
return string.toLowerCase() != "yeet" ? "yeet" : "s";
yyes it is...
gone
i ate it
whats wrong with that?
mine_level = mineLevel
ohhh
yea
cus theyre not the same name
no reason to use this
because u dont have the inspection set on it prob
I mean I like to always use this or super if possible to show where the field or method invocation is coming from
mine_level != mineLevel;
but I know a lot of devs who dont share that same preference
Why balance etc are final? I think player balance, mana and mine level can change value
Is there a way to see how the spigot API does certain things?
I am working on a 1.8 plugin but would like to implement some methods from higher versions with NMS.
ew
?source
uuid varchar(64)
Coreprotect wack
?stash
?Coll1234567
md doesnt know his own commands
we need this
my intellij does that lol just tested
If that's the case, then you shouldn't ask others for tips on improving yourself. Hate to break it to you
Can't seem to find setSilent
I'm looking in CraftLivingEntity
its in craftentity
I see, ty
Just note that its implementation greatly varies between 1.8 and 1.20 and that there's a chance that it won't be helpful
Did the silent tag even exist in 1.8
Well, it appears this also exists in 1.8 so I hope it works
is there a reason why you're looking in craftliving entity and not in living entity?
as far as i know it's in the interface
this being EntityBat
Huh I guess the tag did exist in 1.8 then
So would it even be possible to achieve this?
to silence a mob?
yes
from which version?
Pretty sure that you have to use NMS in 1.8.8
Then you'd google it and hope that someone has already done it https://www.spigotmc.org/threads/silent-villager.106983/ or painfully search the needle yourself under the haystack
the nms entity
always returns the delegate
has always done that and will always do
Hi. I'm making plugin that have some cutscenes in it. It will set player gamemode to spectator and than teleport them by small steps. But it is teleporting them like 100 000 times with 1 tick delay witch is kinda laggy. So beside making bigger steps and making longer delay, is there any way how to optimize it so it will not lag to much? Thx for any help.
Use velocity
ah, makes sense why I don't have to do that then
Ill see if b() works
Oh yea, that makes sence, thanks
Mmm obfuscation
yea obfuscation is fun
yeah, it fails badly when nbttag is involved
public void e(NBTTagCompound nbttagcompound) has a lot of strings which help
How do people even find out what a,b,c etc. is? Try and error after updating?
patterns
mappings
1.17.1+
or mappings
Are there official mappings from mojang?
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
but before mappings patterns were your friends
1.17.1 and after yeah
it probably got backported
For spigot*
Why do they even obfuscate if they release mappings?
wait are there any for 1.8?
Nope
Mojang started releasing mappings in 1.14
1.14+
:(
its actually rather easy to start mapping obfuscation if u can use stuff like strings, magic values etc
ohh
Which is when spigot started using them
but based on how buildtools operated, i assume they couldn't use them without the license update
Why do they still obfuscate their code if they release mappings for it?
Doesn't that pretty much reverse the obfuscation?
to still show its proprietary
Makes it a bit smaller too
its not open source
the moj maps are only to be used under the given "license"
^
I mean I also have to stick to their license when not using mappings
you were in the wrong actually
it was all copyright reserved or something
you couldn't do anything with it
its just to basically say this isnt open source this is still proprietary software
Spigot existed beforehand and nms was a thing before 1.17, too
i mean we use buildtools for a reason
freestyler knows that, theyve been here far too long arguably lol
That's a weird way to say that
how else should they say it
License?
Yeah why obfuscate and license mappings instead of not obfuscating and putting a license on the code?
crazy
they do have a license
on the mappings
I mean they have a license on the code too
And they also have a license on their code I'd assume? So obfuscation wouldn't be necessary
well duh
It’s called all rights reserved
but then you could distribute it easier its just meant to be an additional roadblock and also because of legal shit
like why are u complaining abt this so much they are unique for releasing mappings at all
that too though
most proprietary games wouldnt give you a way to see the code exactly as they wrote it
I'm not complaining. I was just asking. You were making me sound dumb
i don't care how they did it, i'm just happy they helped the community with the mappings
and asking again you arent gonna get a different response
its like how you have to agree to the eula before starting a server
that entirely depends on perspective
When's the PlayerSpawnLocationEvent fired and when was it added?
I was given an answer without any reasoning behind it.
I wanted to understand the reasoning
So yes, I asked again
?stash
Called when player is about to spawn in a world after joining the server.
is there a way to debug your plugin in your IDE? I'm getting some weird behaviour i could probably easily dissolve if i could peek at values
using intelliJ
its like how you have to agree to the eula before starting a server, its a relatively small roadblock just to prove its still their game, not yours just because you have the code
and it also ensures you actually agreed to their terms
before playerjoinevent
You can remote attach to the server
right when the location is set
https://www.spigotmc.org/resources/always-spawn.111331/ my plugin uses it
ooo nice
thx
which packet is that? OutPosition? OutRespawn?
i support 1.8.8 and i see it in there
the event I mean
for the event?
ye
no it's just when the location is originally given to the joining player
it is called
Yeah I got that now. Thanks. I asked again because I was wondering why licensing the code isn't enough. But that was answered, too. So now I know all I wanted to :)
and you can change it with yours
it's better to use this event than doing it in playerjoin event
but most events correspond to certain packets
exactly, so the location in the packet is overriden with the one set-up in the event
most events i know are triggered in the server logic and not from packets
I guess that's true
and in fact spawn location is taken from the userdata and not a packet
but the server has to tell the player where he is
the unaltered one
well, you have to look elsewhere
metadata maybe?
the metadata packet
Yeah I know, packets are a communication method, user data is a file storing system
OutEntityMetadata?
i can follow the code for you, give me a second
But that's for other players
What do you guys name your module with interfaces for all NMS specific classes? I already have an api module so I cannot use that.
depends on what you're naming
PacketPlayOutSpawnPosition it might be this
but it seems to be unaltered by what PlayerSpawnLocationEvent does
I have modules called v1_8_r3, v1_12_r1 etc
but need one for the interfaces
common
or abstract classes
not sure if it's an oversight in the 1.8.8 server
just common?
Yeah
but for what exactly? World classes, packet classes?
You plan on adding them all?
no
possibly adding an arrow class depending on if i need nms for my purposes
it's mainly to copy api methods from newer versions into 1.8
and you're adding them using ByteBuddy as interfaces for efficiency?
i am not using bytebuddy afaik
i have a maven module for each version and one with abstract classes and interfaces
isn't this modified in the event fire call before being sent as a packet?
no
so you're doing it manually for each version?
hmm
yes
but thusfar only 1.8
my project structure as of now
named it common because someone here suggested it
ignore discordo-api, removed that
wait, you can have your own icons?
idk intellij does that for me
common is usually used when, let's say, adding multi server engine support
by that you mean supporting multiple versions, not just 1.8?
i think it suggested it to me at some time
if so, I plan to do that eventually
I mean supporting multiple server engines.
Like minestom
That was just an example
Or fabric
for multi-version support it can be the same thing
i see
anyone know why this doesnt have the variable
Like you have Player on bukkit and ProxiedPlayer on bungeecord but the classes have the same code, so you just leave as an customziable class parameter in the common package
show the full code
or at least the relevant part
I can't really tell from this
So common is fine as a module name?
ah thats a good point
ye
alright cool
also, why do you feel the need of creating a local variable you're returning in the very next line?
so that i can debug it?
i found out, the packet PacketPlayOutSpawnPosition is for setting the compass
I guess makes sense
the compiler/or JIT may even optimize it
it looks awful tho
Likely a syntax error
i agree
with the IntelliJ highlighting it's even worse
Interesting, I never had that
Wait how do you use the intellij debugger with minecraft plugins?
was linked like three minutes ago
There are many ways to debug
something something port 5005
just dont debug
Anyways I'm going to sleep now. Goodnight y'all
ive been using printlns
you dont have to debug if you have no bugs
👍
thats the proper way
sadly those seem to be unavoidable in my plugins
And if there's bugs you just declare them as features
or remove the entire function if they are bad
true, just delete the whole repo and start over
nah
What if hes looking for a bugs nest to avoid new bugs from being born
declare it as "coming soon..."
you have a silverfish infestation somewhere i can tell
Gotta release a roadmap that's delayed from the start
bugs dont get born, they just change the owner
also i figured out that you can build and reaload without screwing the debugger
so at least simple things can be looked through quickly
That sounds like slavery😔🚬
on a completely unrelated note, how do you cut off the parts of a return list that don't match the possible command arguments?
like /set type black|blue|red -> /set type black|blue
no clue what you mean
He's talking about the command recommendations
i mean if i type 'b' how do i manipulate the List<String> i throw back to remove everything not starting with the character sequence already typed
StringUtil.copyPartialMatches
^^
ah thats what you mean
yeah this
StringUtil.copyPartialMatches(args[num], entries, new ArrayList<>())
its annoying how you cant just flag a command to do that
u technically do have commodore (the file format), or even so I may mention brigadier as well (which is shipped)
...ykw im just going to make a helper method and not bother with external libraries
brig is not an external lib
and brig looks horrid
oh u can write readable code with brig
ah i meant while typing in the chat
just that its somewhat more effort taking
why does getOnlinePlayers return a collection of captures?
Because it's stupid
i can just cast it a la (List<Player>) then?
Probably
it returns Collection<extends Player> because the CraftServer of it returns Collection<CraftPlayer>
why doesnt this happen with getPlayer tho?
getPlayer?
because type theory is fun
nah the Server.getPlayer
why would getPlayer be player and getOnlinePlayers be craftPlayer
why can't it just be changed to not do that?
I mean it could yea
It'd be a source break
barely
existing code should still compile just fine i believe
the other way around would be more catastrophic lol
If you've done List<? extends Player> in your code I don't think it will
I mean in the case of Server#getPlayer its just not involving generics, or well "higher ordered logic in terms of types" w/e u wna call it
it should
yeah, that still compiles
so does this
when you change it just return Collection<Player>
How do I spawn an infinite Area Effect Cloud? In Vanilla you have to set its Duration to int limit (it's not really inifnite but it's ok), but it doesn't work when I do it with my plugin.
Also, how do I delete the particle effect?
if it works like a potionEffect, duration = -1, and there's a constructor signature that gives a boolean to toggle visibility of particles
oh yea it takes a potionEffect
hey
I found this thread on how to force the riptide animation effect using the nms, but sadly this is for the 1.16.5 and does not work on the 1.20.1
https://www.spigotmc.org/threads/using-the-riptide-animation.469207/#post-3980186
Does anyone have an idea on how to force the riptide animation on the 1.20.1 using the NMS?
this may be a very silly question, but I'm developing my first Spigot plugin. is there any compelling reason to use one of Java or Kotlin over the other and why? I'm not too worried about docs because I'm fairly familiar with both languages - I'm just wondering if either language specifically offers anything that makes plugin development easier.
Does anyone know why "profiles" propertry in spring-boot-maven-plugin does nothing. I set it to
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<profiles>prod</profiles>
</configuration>
</plugin>
But still, both spring-boot.run.profiles and spring.profiles.active env vars are empty.
I found this ( https://prnt.sc/7G_XLNdqkeI- ) in BuildTools but somehow I can't access this function https://prnt.sc/dKgpoiadr0Dt
I'd go with java
Mostly because 95% of spigot devs can help you or work on your code if it's in java
but only about 5% ish can work on it if it's kotlin
Only one or two networks are looking specifically for kotlin devs
oh true i hadn't thought about the network thing
i'm not sure how much that'll matter because i don't know if i'll ever actually end up trying to work for one of them ? but that is a very good point
thanks for the input !
It's the kind of question like
Should I follow an industry trend or go with a minority
yeah that's fair
idk i'll probably go with java just to be one of the Cool Kids
follow up question: gradle or maven and why
I'd say it's pretty much the same discussion. Maven is more popular and therefore you'll receive more support
But gradle is probably a little more popular than kotlin. Still a long way to go to overtake maven though
your dependency management system doesn't influence your code maintainability though
So it's a lot more personal
Does anyone know if there is a way to send Packets to players via velocity?
?whereami
Im banned from the paper discord
This is our problem how?
F
idk I was just wondering if someone knew
I'm trying to set non-naturally generated shriekers so they can spawn wardens (only natural ones can by default)
Spigot provides this isCanSummon method, but it doesn't seem to change the actual block. Is it supposed to change the block? Source code looks like it should.
(the tryShriek method is something I'm adding... working on a PR)
idk how Kotlin's setters work, they look stupid, but isCanSummon() != setCanSummon()
kotlin handles that.. so they are equal in this case. To prove it, you can see the debugger is on line 58 and can_summon=true in the blockdata there
kotlin code usually doesn't look so stupid but it doesn't really look good in bukkit code 😆
Oh I missed the debugger. Don't see those often for plugins
too used to people asking bad questions without trying to find the answer on their own?
nah I get it
honestly don't know how some people code plugins without it
how do you even set up the debugger to work with the plugin? in intelj
use remote jvm debug.
you can also do that to debug craftbukkit, which I'll try for this
tbh Bukkit.broadcastMessage is the best debug
I mean it's a useful tool, but without a debugger, you're playing whackamole with earplugs and a blindfold.
how would one replace a block breaking sound?
would i have to make a packet listener or something?
i want stone breaking sound to be a different block
packets yeah
would i have to modify the incoming packet?
uhh it's outgoing
but yeah
easiest way is just protocollib and change a single value
Thing is
protocol ew doe
You can't exactly figure out what block it's coming from
oh idc, its for a prison server. I can make it for every block really
i dont think it'll matter
Sure whatever
is there a way to do this with NMS?
uhh
instead of protocol
You can inject into the packet handler yeah
hmm
I wonder how plugins like ItemsAdder replace the sounds for their custom blocks
If they can’t tell what block it’s coming from
their custom blocks are note blocks
Yes
So they just fire whatever
netty?
?
would that work
they listen to the animation packets and fire it?
Oh right they don’t actually get broken client side because of the custom breaking system
Forgot about that
nothing stopping them from just setting an empty sound on the client
for the real block
True
omg nvm
what's the packet for block breaking sound lol
manager.addPacketListener(new PacketAdapter(javaPlugin, ListenerPriority.HIGH, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketReceiving(PacketEvent event) {
PacketContainer container = event.getPacket();
Bukkit.broadcastMessage(String.valueOf(container));
}
});```
Shouldn’t you be using onPacketSending
