#help-development
1 messages · Page 354 of 1
Its increase damage
oh ty
yeah the bukkit names for some stuff is.... not the greatest
Blvck tag me when its done i go with my gf for like 1h i comeback after ^^
https://github.com/BlvckBytes/PlayerBrewingListener
Here you go, I hope it all works out. This was quite the rabbit-hole, I had to experiment a lot to come up with this solution. If there are bugs or unexpected behavior, please let me know. Would love to improve on this first draft.
@quaint mantle was most definitely right when they said "not gonna be easy". I was like "pff, come on, LOL", but I most definitely didn't expect such a day-to-day task to be that involved.
That's why I strongly believe that we need to abstract these headaches away on a library level, instead of opening PRs all the time. If everybody contributes a properly tested and fully working lib, the world would be a better place, xD.
do i add somethings to my pom.xml or just the things in the onenable ?
And thx bro
Look at the readme, there's a small example. You can just copy the three classes directly into your project, no need to go through the shading process.
Can u put the plugin builded in the releases ?
It's not a plugin, it's just a small library
where i drop the file in my server ?
Oh, I wasn't even aware of that, as I didn't work much with NBT. What exactly is the issue all about?
No, you don't load what I wrote anywhere. You download the zip, copy the three .java files into your project, register the listener as stated in the readme and listen for the new event, as also stated in the readme.
okkk
Like this ?
Exactly. Now, register the listener and add an event handler for my new event.
if i remove the print and and i just get the player?
That was just an example. You now have a player reference and the original associated brew event. Now, act accordingly, don't quite know what you want to do.
Btw, you can remove the package from right before the event name and just add an import. No idea why that happened.
Where you got it in that screenshot already works
I dont optimize the import
What do you want to do with the strength? Just set 2 back to 1? If so, I could also show you a specific example of that.
I want to make impossible to make strenght 2
(splash and normal) and when som1 try to do it
send
'§f » §cErreur : Vous ne pouvez pas créer de potion de force 2."
Yeah, but as you found out you cannot cancel the event. So just setting it from 2 back to 1 and in effect undoing the upgrade would be okay, right? The player looses the one glowstone dust, but who cares, lol
yeah
its good
Don't think that's something that would get added because it's not something the server does. Players aren't at all associated with potion brewing. It's done autonomously by a tile entity
I dont want new player buy strenght 2 thinking its working but they cant use it
Or things like that
When I wrote a quest system that required a quest for brewing potions, I just grabbed the player closest to the brewing stand
Or if applicable, one of the players with the brewing stand inventory open
If he close its not gonna work
Well, I already went through the trouble of tracking this, so I might as well use it now, xD
Okay, that worked out, but it's still in a loop of trying to brew it to strength II over and over again. Also kind of logical. What do you think about just replacing it with an empty bottle to stop this loop and signal to the player that this is forbidden?
Yeah it can work
Or maybe an awkward potion, don't know if that would stop it
idk can glowstone do somethings on it ?
package fr.worldorder.wobaguettes;
import fr.worldorder.wobaguettes.commands.BaguetteCommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import me.blvckbytes.playerbrewinglistener.PlayerBrewItemListener;
import me.blvckbytes.playerbrewinglistener.PlayerBrewEvent;
public class WOBaguettes extends JavaPlugin implements Listener {
private Player player;
@Override
public void onEnable() {
Bukkit.getConsoleSender().sendMessage(
"§9" + getDescription().getName() + " enable!\n" +
"§9Version : " + getDescription().getVersion() + "\n" +
"§9WorldOrder"
);
getCommand("baguette").setExecutor(new BaguetteCommand(this));
this.getServer().getPluginManager().registerEvents(this, this);
getServer().getPluginManager().registerEvents(new PlayerBrewItemListener(), this);
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerBrew(PlayerBrewEvent e) {
player = e.getPlayer();
}
public void onBrew(BrewEvent event) {
for (ItemStack item : event.getResults()) {
if (item != null && item.getItemMeta() instanceof PotionMeta) {
PotionMeta meta = (PotionMeta) item.getItemMeta();
PotionData data = meta.getBasePotionData();
if (data.getType() == PotionType.STRENGTH && data.isUpgraded()) {
event.setCancelled(true);
player.sendMessage("§f\uE259 » §cErreur : Vous ne pouvez pas créer de potion de force 2.");
}
}
}
}
@Override
public void onDisable() {
}
}```
Is this good ?
https://paste.md-5.net/holomovanu.java
Yep, AWKWARD stops it
I replace my event handler by this ?
No idea what you did there tbh, you need to get rid of the original BrewEvent, just delete it
Yes
Okk
Ok i try
Right, tell me how it went, xD
Awesome! :)
Again, if you ever encounter any issues, let me know, I'd love to improve the lib
with splash too
Thx mate
u save me 🙏
Haha :D. I love solving problems, so no worries! :p
@glossy venture Lol, is that your YT account? I knew that I was familiar with the nickname at the moment I came across it, xDD.
Fanboy
?paste
public double findStrengthEffectMultiplier(final Player player) {
final PotionEffect effect = player.getPotionEffect(PotionEffectType.INCREASE_DAMAGE);
if (effect == null) return 1D;
return resources.getStrengthMultipliers().getOrDefault(effect.getAmplifier(), 1D);
}
public double findWeaknessEffectMultiplier(final Player player) {
final PotionEffect effect = player.getPotionEffect(PotionEffectType.WEAKNESS);
if (effect == null) return 1D;
return resources.getWeaknessMultipliers().getOrDefault(effect.getAmplifier(), 1D);
}
can this be simplified? i feel like i can make a general method like "findEffectMultiplier" but it'd be inconvenient to also pass a map every time
yeah lmao
what vid is that
Create a new method named findEffectMultiplier and pass as parameter the effect you're searching. ig it's surely easier ¯_(ツ)_/¯
and wdym pass a map?
resources.getStrengthMultipliers() & resources.getWeaknessMultipliers() are two different maps from where i fetch the effect multiplier
if i were to create a general method i'd need to pass that map as an argument
yeah it's my bad, i didn't read the return statement before answering ^^'
😛
Each PotionEffect has its own formula for multipliers. So I recommend you to still create a new method named findEffectMultiplier as I said earlier and make a switch statement for each effects you want to handle.
It's still better than just copy and paste methods that are basically the same
imo
oh, no, it's not like that, it's configured by the administrator
it's for my plugin PlungingAttack, where the damage has some multipliers (general, sharpness, weakness, strength, etc) that are all configured by users
it's not like it's hardcoded
but i guess a switch could work here
I mean even if you made it, a switch statement still is better in my opinion
potioneffecttype
there is a method named getByKey(NamespacedKey key)
my life would be ten times easier if switch cases could take non-constant expressions
public double findEffectMultiplier(final Player player, final PotionEffectType type) {
final PotionEffect effect = player.getPotionEffect(type);
if (effect == null) return 1D;
if (effect.getType() == PotionEffectType.WEAKNESS) return resources.getWeaknessMultipliers().getOrDefault(effect.getAmplifier(), 1D);
else if (effect.getType() == PotionEffectType.INCREASE_DAMAGE) return resources.getStrengthMultipliers().getOrDefault(effect.getAmplifier(), 1D);
return 1D;
}
no switch unfortunately
Make your own language that is able to do so
that's a viable solution
though it'll be a pain to then make a spigot api wrapper for it
i'll pass
i mean i have a Constants classes with static final values and case still doesn't accept it 😭
Use a map with effect type as key
make your own enum or use a map as FourteenBrush said
I could
"OnHangingPlace.java uses or overrides a deprecated API."
is that listener deprecated?
"That listener"
what listener
OnHangingPlace
uses or overrides a deprecated API
thats not a listener in spigot
in the event
what listenerd do you specify
doesnt look deprecated, you using ij?
yeah, intellij should show what
yeah
Is it possible to use FileConfiguration class for another .yml file that isn0t config.yml?
yeah
check the class you want for words witha strikethrough
that will show you whats deprecated
Does anyone know how you can add your data to the player's data that is stored in uuid.dat?
?pdc
probably some nbt stuff
I didn't find anything like that, because the player's data is immediately entered into the variables
I am using version 1.7.10
?1.8
Too old! (Click the link to get the exact time)
That was a zozin session, haha 😂. Nice to see others in here show interest in things like these too.
References:
- Source Code: https://github.com/tsoding/ded
oh yeah
Can someone help me with a plugin, so when I right click a compass it will run a command for that person, do you know how the code will start?
make a listener and listen to PlayerInteractEvent, check if the item is compass and run the command
okay and how would the code run the command like how would you write it?
Still learning so sorry
Bukkit.getServer().dispatchCommand(sender, "yourcommand");
Where sender is either Bukkit.getConsoleSender() if you want to execute as console or player if as the player.
Thank and how would you int what item is being pressed and only that item? so like Compass?
so if that item is in hand and pressed then it will int the command for the player who right clicked it
event.getItem()
also, make sure to check the hand so as not to trigger it twice,
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html
?interactevent
okay thank you
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
isSimilar for itemstacks
okay thank you
you could also do ``event.getItem().getItemStack().getType() == Material.COMPASS` if its all compasses
all it is a compass in the middle of the inventory bar and when you right click it, it will run a command for that person that pressed it
inventory interact event, check for hand and check if its not a compass
entity type
How do I get a material's name?
material.getData().getName() -> Cannot get class of modern material
to string it
thanks
How can I make so FileConfiguration generates the config file automatically?
I want to use a separated yml
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
saveDefaultConfig() would do the job but it doesn't
oh wait
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
Well, I would most definitely not try to hide the player and track another entity to it server-side, as that seems immensely wasteful to me.
Since the player is also just an entity and the server already broadcasts move and look packets to all players, I'd personally try to intercept PacketPlayOutNamedEntitySpawn & PacketPlayOutEntityMetadata, drop them and replace them with the spawn packets for the entity you want to display, while keeping the entity id. While you're at it, also drop the PacketPlayOutPlayerInfo, as there's no need to perform tablist manipulation on such an entity.
By keeping the original entity-id, you're making use of all the movement packets the server already broadcasts. I'm pretty sure that this will work out, didn't give it a shot yet tho.
problem with that is metadata packets
you're gonna have to do a lot of manual conversion
I'd just make a client-sided entity and replace the entity id for movement packets
the client will still receive metadata packets for the player but it won't matter because the player isn't there
you can also just drop them to save on networking
So you'd create another clientside entity and patch the movement packets? What does that solve, you could also just drop the metadata packets for manipulated clients. But things like entity flags for on-fire, etc, will still work out anyways, so you'd just need a little logic to check what to let through.
that's easier than converting field indexes
You don't need to convert anything, just drop them, xD.
ehh
I just really think that it's best to not have to touch the immensely fast stream of move and look. If you keep the entity-id, you save yourself from a lot of patching.
maps have a rather fast lookup time
I'd rather do light conversion all the time than something a bit heavier once in a while
you run the risk of sending an itemstack when the client expects some floats
I want to display success only when a command is executed and an event occurs, and if the command is not executed, even if an event occurs, success does not appear.
I don't know what that means
do you know java?
What I want to ask is how do you detect that you have hit a command
Yes
ah! OK
thank you!
Hi guys, i need this dependency (not necessarily this specific version) for my plugin, it's available from bungee (i think, used in past)
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-proxy</artifactId>
<version>1.8-SNAPSHOT</version>
</dependency>
not 1.8 obv
What do you need it for?
messing around with things
i need for some reserch purposes also, it was really useful for me
The latest version is 1.19-R0.1-SNAPSHOT
it doesn't show up
says can't find it in repo blabla
it was before i think last summer
where can i find it?
ah i see, should i compile it?
They specifically want that proxy module for some reason
Run maven install
"bungeecord-api" is the "normal" dependency
what for?
found it, thanks @chrome beacon
i need to set gamemode from proxy, that's why i need it
but seems that setGamemode doesn't work
bungee has no information about your gamemode
that only changes entity type for other players
which i already achieved long ago
apparently it's recognizing gamemode
i did some tests, it can read it but not change it
i mean for the player himself (the changed one) is it possible for em?
how are you reading it?
UserConnection user = (UserConnection) sender;
System.out.println(user.getGamemode());
it's just for test, not real code obv
it's recognizing the gamemode but won't change it in game
iirc its on krpytonmc
latest on there is 1.19
The official Krypton Maven repository, containing many of Krypton's published artifacts, as well as some other projects.
Could've been way more specific with your question then, :))
Hi, does anyone by any chance know how can i get item NBT tags? version: spigot 1.19
/data get entity @s SelectedItem if you just need to look at it
thanks, but i want my spigot plugin to do it
Hey, im trying to change the block type after breaking it like this:
public void onBlockBreak(BlockBreakEvent event) {
event.getBlock().setType(Material.STONE);
}```
but nothing is happening does anyone have an idea?
Cancel the event then set the type.
did you register events?
register listener
yes
thanks
Hey Guys How can I detect 12.00 AM in a real time(every day) I just don't know is there only scheduler for check it?
is there a way to disable air resistance on projectiles?
unix time stamp
What's that
Yeah I've seen that long numbers
LocalDateTime
Ahh Anyway can I check with delay?
thank uu I think that's the answer
In scheduler for check it?
No
to me?
No
k
so instead i create a class for each one and make it private and access with public Data get() ?
I think if I use a scheduler it's gonna make huge a lots of lag as if so many players in the server isn't it?
sry im bad at eng
okkk
is it possible to change player location on PlayerQuitEvent
Idk 🤷♂️ does it give you a player object
yeh
Sure
any issue or improvement to this ?
Storing player object is asking for memory leaks but you do you
@vital sandal just don't store player objects
hmmm alright this is a nice explain
In past I had problem after an hour or so if you did any changes on player object in map it would not take any effects on the player even if they didn't reloged at all
Store uuid as key always
yes
You can store player objects so long as you're handling it properly.
If you need the player object, which he clearly does, storing the UUID doesn't really make a ton of sense.
You're just forcing yourself to constantly call Bukkit.getPlayer()
this seem stupid idea :d
should i do that or just one Listener for every player ?
why would you do one for each player
you if check it
just check if the location handler list contains the player
dont need to pass a player in
if (item != null && item.getType() ==Material.ELYTRA) {
System.out.println("found ELYTRA");
event.setCancelled(true);
event.getWhoClicked().getInventory().removeItem(item);
}
this code to block elytras works, but people can just bypass it by getting the elytra from the end city and shift click to equip it, i want to prevent that by deleting the elytra out of the inventory
thats what im using
listen to item pickup event too
ok thanks
check if player.isOnline()
instead of
weap just in case the data passing steep is malfunction
now it should be this
that explanation doesnt make any sense
let talk about this instead
talk about what
is there any issue with it ?
yes
looking at that you register a new listener, use it once, unregister it
have a global listener and check if the list contains the player
if multiple player active it it will be multiple listener right ?
Btw, I just gave this a shot out of curiosity. I am only substituting the named entity spawn for a entity spawn of the required type with the same entity-id and there are absolutely no issues whatsoever. The player has a tab-entry by not dropping those packets, which likely is desired. All metadata packets like on fire, invisible, etc work, and the client - of course - has no issues with packets that send unsupported behaviour for the disguised type, as it just doesn't apply them. Pickup animations work too, and everything else that's bound to entity IDs. It would have just been insanity to modify all of these packets, as there's no need to do so.
Now let the player equip armor
Okay, what should I expect?
Crash
Uhm, it just does nothing, xD
Do you know a specific version the crash would happen on?
In terms of performance, would it be (acceptable) to have a runnable run every tick?
int taskId = scheduler.scheduleSyncDelayedTask(plugin, timeChecker, 1L);
depends what tasks you perform inside the runnable
The goal is to run a piece of code when a specific time is reached
No not really. I could use between x and y
But if there is a cleaner solution, preferred
else i'd suggest just checking every second or so to see if the time has been reached.
Yeah, if i go a step further even, if there would be an event to listen for changes between day and night time events, perfect
hi can someone help me how to do a custom message when server stops
i want to be like this
[Servername]
&a§l⚀§c§l⚁§b§l⚂§e§l⚃§5§l⚄§4§l⚅§3§l⚄§6§l⚃§2§l⚂§d§l⚁§9§l⚀§r
4♥§6Sorry about that!§4♥
§6Server Stopped
§6Contact with a ADMIN§r
§6or see Announcements§r
§9§l⚀§d§l⚁§2§l⚂§6§l⚃§3§l⚄§4§l⚅§5§l⚄§e§l⚃§b§l⚂§c§l⚁§a§l⚀§r
hmm maybe this gets called when the day resets ? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/world/TimeSkipEvent.html
declaration: package: org.bukkit.event.world, class: TimeSkipEvent
not sure bout that tho
I believe the TimeSkipEvent is used when someone is sleeping, in my other plugin I already cancel it to avoid the server from changing the time 🙂
well then ur best option is to just check every X amount of time i think
prolly doesht have to be every tick though if i understand u correctly
its not about blocking the server but rather about the hardware usage
By doing that you're basically hooking into the tick loop, and there's nothing wrong with that. If your task doesn't depend on the world itself, you can even run it asynchronously and get the precision for free. Just checking for some registered timers will be blazing fast anyways. Just a few loops and long comparison.
Alright, thank you all for the advice!
If you want to you could tell us about what exactly you want to accomplish tho, as maybe somebody has a better idea. You're basically polling for something to occur, while interrupt style procedures are to be preferred.
@EventHandler
public void onDisconnect(PlayerQuitEvent event) {
event.setQuitMessage("");
}
you can throw in a check to see for the cause of the disconnect
i am not usig this type of code
what?
nothing
I have a
Map<Class<?>, Collection<IScriptLoader<?>>> loaders
and I want to get the loaders for a specific type.
Right now I'm doing this with a jank double cast because without the object cast the IDE complains
(Collection<IScriptLoader<IGenerator>>) (Object) loaders.get(IGenerator.class)
is there anything I'm missing or is this a certified java moment
Looks like java generics being itself
hello, why this code doesnt make folder with file on first time plugin run?
https://pastebin.com/4mHbvVhg
how would I go about storing items for a block? (maybe in nbt, maybe as a file?)
I do need to store both the input items and the output items
You could use the pdc.
pdc prolly good option
Am I missing something here? Cause this shouldn't even load at all since it's not extending JavaPlugin.
why not storing it in memory?
well wouldn't that be too much processing? write, read, write, read...
compared to pdc
yes it it, its normally works in game and response
huh, storing it in memory does not require writing / reading ?
it wont
that will not work
but it working
spigot never calls a constructor of a class
he prolly has another actual main class then xD
[19:03:20] [Server thread/INFO]: [Valentynek] Enabling Valentynek v1.0
lol well it has to work when even not interacting so i do need to eventually
and calls it from there
What does your main class look like then?
idk if pdc is the best option then tbh. if ur going to be trying to get the data while this block/chunk is not loaded. the chunk would probably need to load before u can get the data from the pdc.
yeah i am going to only process it when the chunk is loaded
ok, then it should be fine.
thats really misleading. the name you used for your command executor is very commonly used as main class.
??
all i'm saying is. the way you named ur classes is shite
and thats why it doesnt work?
no
firstly, sentValentineFile = new File("sentValentine.txt"); this is not going to make a file where u want it to probably
i wanna make a level generation, what could i use to make the generation update in some time like a loop or player walk event, infinite loops very bad, i couldnt find player walk event
since ur not providing the path to ur plugin data folder before the file name
playermoveevent?
dont
infinite loops very bad
depends, but you can also use a scheduler repeated task with 1 tick delay
I don't know what you're trying to do, I just joined the convo
hope this could be any relevant
lol how couldnt i find it
what do you even mean with level generation?
generation of a ... thing
how do i force any jetbrains product to login with another gh account?
its defaulting to my primary gh acc
got it
I've been working on a common library to automate some parts of plugin dev. While most librairies are external plugins that they depend on, i'd like to simply include classes in the jar directly. How can i do that? simply selecting the library while exporting doesn't do it
shading it?
basically, but without maven or gradle, just raw java projects
cant help with that
fudge
You have to copy the files into the project then compile it at that point.
You can't shade with JDT - for IJ Artifacts idk
the only proper choice
i know nothing of maven. Is there an archetype for minecraft plugins? or do i just make a project without an archetype
Just don't bother with archetypes
I need to get the stats of the players (deaths, killed mobs...), I thought of making an api which sends the data on my site to record them in base at each connection of the player, but is there a better technique?
Of course there are a few that swear by it, but it just isn't that useful beyond saving you a few minutes or so
sir, this is #help-development
do you plan to display these stats to a website or what?
yes
I guess you could use a shared DB for that or make the website request data from the server on an as-needed basis
is it possible to request information from the site to the server?
Having the server contact the website when a change occurs could be considered unstable
I agree with that, that's why I'm trying to find another technique
If you use PHP or any other language yes
yes with laravel, how to call a function of a plugin from the site?
Although you could also make the browser contact the server but that make open up large scale datamining
I'd not publicly expose API endpoints
player data are collected via getPlayer#getStatistic()
You need to have the server open a port (an http webserver is enough) and communicate through it
like that? https://www.spigotmc.org/threads/minerest-an-easy-to-use-rest-api-for-your-server.484780/
I have full knowledge of api endpoints in php but in java it's another story, I don't see how to do it
I haven't used the apache spark framework yet
If I had to I'd create a server through the takes library or similar
Hi, i have a question. If i put a customodeldata on a carrot on a stick. I want to create a craft with the custom carrot on a stick and disallow the normal carrot on a stick, is this possible with spigot ?
Is there a way for holograms to show diff info for diff players? Never really worked with em
With placeholders yes. Or send unique hologram packets to each individual player.
preparecraftevent
Do you have a example pls ?
get inventory then get matrix and check corectness
👍
Uhm, what? How about just registering a new recipe and either disallowing or removing the vanilla recipe? Going as low level as checking the matrix against all permutations is not at all necessary for such a simple change.
public static String serialize(Recipe object) {
Bukkit.getLogger().info(object.getClass().getName());
try {
ByteArrayOutputStream io = new ByteArrayOutputStream();
BukkitObjectOutputStream bos = new BukkitObjectOutputStream(io);
bos.writeObject(object);
bos.flush();
byte[] serializedObject = io.toByteArray();
return Base64.getEncoder().encodeToString(serializedObject);
} catch (IOException e) {
Bukkit.getLogger().info(" > Failed to serialize Recipe.");
}
return null;
}
could someone explain to me the potential causes for null returns here? (Recipe is a class I made)
how to create own command in the server ?
thix
np
How to make a mattress like Creative?
Mattress ???
I don't understand you
There are no mattresses in minecraft
Make what arranged like creative
y
Arabic
Sorry I can not help you
Is EntityDeathEvent supposed to fire when you /kill entities?
i imagine
Using protocollib I am trying to empty a player's inventory
var container = new PacketContainer(PacketType.Play.Server.WINDOW_ITEMS);
container.getBytes().write(0, (byte) 0); // Window ID
container.getIntegers().write(0, 999); // State ID
var count = player.getInventory().getSize();
var emptyStack = new ItemStack(Material.AIR);
var stacks = new ItemStack[count];
for (int i = 0; i < count; i++) {
stacks[i] = emptyStack;
}
container.getIntegers().write(1, count); // Count
container.getItemArrayModifier().write(0, stacks); // Stacks
container.getItemModifier().write(0, emptyStack); // Cursor
Now there are two issues I see: I don't know how to get the State ID, and the getIntegers seem to be of length two, and there doesn't seem to be any byte slots in getBytes
are there any shortcuts to get total player kills? or do i have to save it myself and run it over config
player stats iirc
Can't you do that with api?
true.. thanks!
Or is there any particular reason for using protocollib
Fake inventory
It's safer than storing the player's inventory, I just need to edit what's shown, don't care about what's actually in
(For context, my original solution used the Spigot API and it didn't work like I needed it to, so now I am using protocollib)
only time i used protocollib was when i was doing a codedred tutorial on yt
lol
my projectiles slow down after a while, is there air resistance or something? and if so how do you disable it
make plugin with multiversions ?
There's drag applied on each tick. I think there's a wiki page about this. I guess you can compensate for it by applying an equally strong opposite force every n ticks
so no setting i can disable, ok, guess ill do that while spawning my particle trails then
develop it for the lowest version you want to support, it should work on all higher versions
ok thx
Hello, I would like to learn how to use nms. Having the basics in java I would like to be able to move forward. Do you know how I can learn while using the nms of the latest version of the game?
Should i create more classes to higher versions ? and check on version ?
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
oh for nms you will need to depend on each version that changes nms
easiest way to do that is multi module
ok thx alot
have anyone used gradle shadow plugin before
im trying to decouple my project into commons and bukkit subprojects
whats so special about it
no one here uses it
I mean, the shadow plugin is rather straight forward
what is your exact question
yeet it into your plugins block
i did
and it will shade whatever you define as implementation
?paste build.gradle
groovy 
groovy is great
what is the exact issue ?
i prefer groovy than kotlin
paperweight does touch shadow a bit
ehm
multi module?
yea gradle does not support nested shit
implementation (":something") instead
nested != multiple
this is how i would handle multi module with gradle https://github.com/The-Epic/GradleModuleStuff
you are trying to have a module inside another module
its probably easier to do that
your commons inside core
which makes no sense tbh
idk they're next to each other
rpjobs-core is just a folder
gradle doesnt like nesting true
tho it looks like it should work out 
exactly
you dont need to specify the top folder
I mean where do you call that from
I presume it is a module on the same level as core
could this be true just for the enderdragon?
if that build.gradle is in the same location of those 2 folders it would be just :rpjobs-stuff
i call the shadowjar from rpjobs-bukkit
then it would just be :rpjobs-commons yea
im pretty sure your build.gradle should be in the rpjobs-core for doing that if you need to acces other stuff otherwise you need to do parent(":rpjobs-commons") i think it is
let me try to remove rpjobs-commons
and put it inside the rpjobs-core
it strange that intellij detects rpjobs-core as a module
although only nested ones are modules
maybe that's the case
somehow
if thats a subfolder thats why
gradle 💀
i've done mostly cpp for a year
maybe both modules should have plugin inside their build.gradle?
no way
that worked lol
in this snippet how do I make it show "power:" instead of "v:"?
I'm using intellij
?
that hint is made by the variable name itself
I have it on my other computer
different spigot import or something
it could be that you're using different versions of the spigot api
Hey guys, I am trying to set up an autocompleter for my plugin. I think I figured most of it out, but I'm not sure how to have the next portion of the auto complete know to list players like many plugins do. Is this something I have to hardcode? Here is what I have so far.
if(args.length == 0) {
return Arrays.asList("give");
} else if(args.length == 1) {
if(args[1] == "give") {
// need to make this show a player list
}
}
check StringUtil from spigot package
i didnt knew this existed
thanks i guess
ask ChatGPT
he will help you
he knows some Spigot
Instead of ItemMeta, you use SkullMeta
SkullMeta will have a function to set the owner of the head
Just make sure you set the ItemStack as a player head material.
ChatGPT is good at making stuff up, not good for coding with an API
💀
You can use this for example
boolean isNewVersion = Arrays.stream(Material.values())
.map(Material::name).collect(Collectors.toList()).contains("PLAYER_HEAD");
Material type = Material.matchMaterial(isNewVersion ? "PLAYER_HEAD" : "SKULL_ITEM");
ItemStack item = new ItemStack(type, 1);
if(!isNewVersion)
item.setDurability((short) 3);
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwner(p);
item.setItemMeta(meta);
return item;
}
🗿ah yes, the typical spoon feed
cache the boolean to global class field
okay but why?
that way you wouldnt need to calculate the same check all over again
oh i understand
why?
because you're calling the same funcs every time player's skull is retrieved
its just optimization technique its not necessary
oh okay i understand
I have one question how do i can make a invsee command that also shows the armor and offhand? bcs i don't get it how to do that
there's no "one-liner" way of doing that, you would need to open separate inventory and play with events, to sync player's container with your new inventory
or use some NMS wizardry to fool server, that its placing items inside player's inventory
but it involves knowledge of nms and some smelly hacking of classes
to do it cross compatible without NMS, you would need to open up new chest inventory
scan player's inventory and add them to the new container
when player removed or adds items
remove the items from there too
Why not create a custom inventory that shows that and update it every 5-10 ticks?
if you pickup that item from new container, you need to remove item from player's inventory
Just open an inventory with one extra row where you map the armor and offhand to. If you need to have live changes too, there's more work to do.
you can but you'll lose ability to pickup items
By pickup u mean taking items away from player?
yes
Well, that depends on what he needs by invsee
You could just create a inventoryclickevent of that custom inventory and get the slot u click and take that item away, and then map the slots for the armor and offhand
yea, thats what i already provided above 😄
Or I guess when u update that inventory also update the players inventory with what is in it.
I saw you talking about NMS, that's why I stepped in
There are way more cases than just the click event
yea, its not necessary, its just that you can use it, and let the server handle the inventory for you
by mismatching inventory views
More cases?
i already tried it
and it worked
but involves reflections
to open up some private fields
Item pickup, armor equip, switch item to offhand, programmatic adding of items, tool break, interacting, etc
Well, when I meant by inventoryclick was the person using the invsee to interact with it.
I guess u would need to create a list of players with their inventory being seen and on every inventory changing events go through another list that contains the watchers and update their custom inventory.
It's actually a really hard problem to solve, as inventories sadly don't seem to be observable. You can't even detect all updates through events, as there are so many possibilities and also programmatic ways to update it. I wonder what the most elegant solution would look like...
Som1 know how i can make this work with all leaves (and not only one type of leaves)
I personally just really dislike the idea of polling constantly. I'd rather like to be notified when the inventory changes. Maybe I could intercept the packet stream of players and check for inventory updates aimed at the own inventory, this way the two would - by definition - always be synchronized.
Tag.LEAVES.isTagged(material)
like this ?
if (Tag.LEAVES.isTagged(event.getBlock().getType()))
Okkk
Is it possible to detect a players fabric mod list in 1.19?
can i check if an Entity came from a spawner
relatable
you can listen to SpawnerSpawnEvent
afterwards? I dont think so
ive seen stuff about CreatureSpawner
if the entity was already spawned, I dont think you can check the spawn reason anymore
yeah well ofc you could just add some data to the entity while it is spawned
e.g. setMetadata or however it's called
or the PDC
yowza
it appends to a value
whatver += 20 is the same as whatever = whatver +20
so this would return Hello World!
String yep = "Hello";
yep+=" World!";
System.out.println(yep);
because + will not change that variable at all
you would use ++ to increase once
int a = 20;
a + 30; // a is still 20
a += 30; // now a is 50
also you can do ++ before or after but it affects the code as before sets it before passing the value in and after passes after running
no
u get nothing
a + 30 means "add 30 to a" but it doesnt update the original value
yes
and that's the difference
but that doesnt compile
so in that you wouldnt get anything
IJ's new UI is so bad, wtf
well ima go create an IString and a StringImpl
nobody ever needs that, if it even exists
tf i dont know any of those
same
I do java for 20 years now and I never saw any of those operators, if they exist in the first place
& means "and"
dont forget about condition ? true : false
ternary operators
yeah but the name is annoying to remember lol
now we dont talk about #stream()
if you need it, sure
Yes. Modulus is useful
cute pfp
some dumb elementary kid
e.g. to turn "8.27 hours" into "8 hours and 16 minutes"
well thats where Duration comes in
erm sure, one sec
Duration#toHoursPart()
Duration#toMinutesPart()
use Duration, so much easier
Duration does it for you
Yh for playtime I just guarantee a max of 3 units up to a year. So you can get 1y, 2mo, 5d for instance. I just use duration and toXPart for that.
never saw that
Might be a better way but that was just logical in the moment
Duration duration = Duration.ofSeconds(event.getPlayer().getStatistic(Statistic.PLAY_ONE_MINUTE)/20);
epik
bro left for a sold 2 min to look up Duration
When if there's an hour in there, it won't display seconds. So on and so on
duration is hot
I bought all my furniture at roller
you dont need Math
at least it's not Go's math package
I currently read a python book and it's a huge joke
honestly all u need is classes statements and some other suff
then StackOverflow is your friend
noooooo py too easy
java is soooo much different
Go is nice to learn coming from java
Or at least, I've really enjoyed it coming from java
Py is a scripting lang whereas java is Object oriented
lol
py u need only 2 min
its that easy
rip
py is good for idk
well js is more web stuff
no and yes
not advanced math
unless your building a lib
but u need it for loops and stuff
where the i++ comes in
prob not
unless u see some purpose to it
plus if u evere need it it will always be there
lmao
you might need Math#Random();
you most likely wont need java as much bc u will mostly be using libs ( unless ur building some bomb)
why not
math and Booleans are ez tho
True, but fun fact, most of discord api backend is done in python
imagine js user comes to java: if (Object == undefined)
everything lol Discord's backend is written mostly in Elixir and Python, as well as Rust, Go, and C++.
Never heard of elixir and go, but I know they are migrating some of critical endpoints to rust
never have used any of those besides py
i have dabbled in Cpp
imagine spigot in Rust
Rust is becoming "hey I'm using arch" meme
Go is really nice
nasi goreng
Discord had a blog a long time ago discussing some issues they had as a result of GCs with it and they migrated the service to Rust as a result
Wierd system of error handling imo, but ig its same in rust
Like weird in comparison to other languages
i dont like go, because I dont know it
Based
skull issue
my skull is healthy
those are fun
i wouldnt go that far into arrays as i would replace those with lists
I like Go's error handling
Just look at how healthy my skull is
nice
Yes
yes
Noone
if you wanna get laughed at then you can get a w3 schools cert
all u need it some skill with programming to get a job
what the heck is a java certificate o0
to show u know java
Certificate that you finished java course
its ||gay||
you are gay
It's not even degree, not official
it means nothing other than "i paid this company money"
Just smth you can show like, hey look, I finished this course
interesting
ill just forge 1
okay guys, I also offer java certificates. just send 100$ to paypal.me/mfnalex and you'll get one
it uses comic sans
alright i passed the exam
🗿
lmao this looks sooo bad
ikr
it looks like something tRump would have tried
omw to get some certificates
"tRump java academy"
omw to the midjourny server
proxmox' firewall is so weird
in what way
It's probably better to just do some project instead of just learning function names and what they do
it cannot do any actual useful things, e.g. for MASQUERADE you still need to use iptables manually
then how would you port forward?
e.g. www.myproxmoxhost.com, you wanna forward that to, let's say 10.0.0.101
here
another funny thing: proxmox always quires you to create a bridge on your own
somehow they think that everyone got a whole /29 subnet
lol
while in reality, nobody does
imagine failing the java cert exam with a 0% and not getting a refund
pls nobody DM me - I am exactly at 200 DMs now
where did you get the nazi font from?
?
in your bio
this
ah thx
its the 1st 1
thanks
2nd
I don't know what I need it for, but I'll bookmark it lol
𝕴𝖒𝖆𝖏𝖎𝖓 𝖘𝖚𝖈𝖐𝖘 𝖆𝖘𝖘, 𝖆𝖓𝖉 𝖓𝖔𝖙 𝖎𝖓 𝖙𝖍𝖊 𝖌𝖔𝖔𝖉 𝖜𝖆𝖞
@quaint mantle
N̴̆̾O̵̎̈́P̸̽͝E̶̾̇ ⓃⓄⓅⒺ N҉O҉P҉E҉ [̲̅N][̲̅O][̲̅P][̲̅E]
𝖕𝖚𝖇𝖑𝖎𝖈 𝖘𝖙𝖆𝖙𝖎𝖈 𝖛𝖔𝖎𝖉 𝖒𝖆𝖎𝖓(𝕾𝖙𝖗𝖎𝖓𝖌... 𝖆𝖗𝖌𝖘) {
𝕾𝖞𝖘𝖙𝖊𝖒.𝖔𝖚𝖙.𝖕𝖗𝖎𝖓𝖙𝖑𝖓("𝖑𝖔𝖑𝖟");
}
me: gonna get rate limited
omg
I will never send normal code again
no pe
𝖕𝖚𝖇𝖑𝖎𝖈 𝖘𝖙𝖆𝖙𝖎𝖈 𝕾𝖙𝖗𝖎𝖓𝖌 𝖙𝖔𝕽𝖊𝖆𝖉𝖆𝖇𝖑𝖊𝕾𝖙𝖗𝖎𝖓𝖌(𝕰𝖓𝖚𝖒<?> 𝖊) {
𝖈𝖍𝖆𝖗[] 𝖈𝖍𝖆𝖗𝖘 = 𝖊.𝖓𝖆𝖒𝖊().𝖙𝖔𝕷𝖔𝖜𝖊𝖗𝕮𝖆𝖘𝖊().𝖗𝖊𝖕𝖑𝖆𝖈𝖊("_", " ").𝖙𝖔𝕮𝖍𝖆𝖗𝕬𝖗𝖗𝖆𝖞();
𝖇𝖔𝖔𝖑𝖊𝖆𝖓 𝖋𝖔𝖚𝖓𝖉 = 𝖋𝖆𝖑𝖘𝖊;
𝖋𝖔𝖗 (𝖎𝖓𝖙 𝖎 = 0; 𝖎 < 𝖈𝖍𝖆𝖗𝖘.𝖑𝖊𝖓𝖌𝖙𝖍; 𝖎++) {
𝖎𝖋 (!𝖋𝖔𝖚𝖓𝖉 && 𝕮𝖍𝖆𝖗𝖆𝖈𝖙𝖊𝖗.𝖎𝖘𝕷𝖊𝖙𝖙𝖊𝖗(𝖈𝖍𝖆𝖗𝖘[𝖎])) {
𝖈𝖍𝖆𝖗𝖘[𝖎] = 𝕮𝖍𝖆𝖗𝖆𝖈𝖙𝖊𝖗.𝖙𝖔𝖀𝖕𝖕𝖊𝖗𝕮𝖆𝖘𝖊(𝖈𝖍𝖆𝖗𝖘[𝖎]);
𝖋𝖔𝖚𝖓𝖉 = 𝖙𝖗𝖚𝖊;
} 𝖊𝖑𝖘𝖊 𝖎𝖋 (𝕮𝖍𝖆𝖗𝖆𝖈𝖙𝖊𝖗.𝖎𝖘𝖂𝖍𝖎𝖙𝖊𝖘𝖕𝖆𝖈𝖊(𝖈𝖍𝖆𝖗𝖘[𝖎])) {
𝖋𝖔𝖚𝖓𝖉 = 𝖋𝖆𝖑𝖘𝖊;
}
}
𝖗𝖊𝖙𝖚𝖗𝖓 𝕾𝖙𝖗𝖎𝖓𝖌.𝖛𝖆𝖑𝖚𝖊𝕺𝖋(𝖈𝖍𝖆𝖗𝖘);
}
@𝕹𝕸𝕾("1.16.2")
𝖕𝖚𝖇𝖑𝖎𝖈 𝕹𝖆𝖒𝖊𝖘𝖕𝖆𝖈𝖊𝖉𝕶𝖊𝖞 𝖌𝖊𝖙𝕭𝖎𝖔𝖒𝖊𝕹𝖆𝖒𝖊𝖘𝖕𝖆𝖈𝖊𝖉𝕶𝖊𝖞(@𝕹𝖔𝖓𝖓𝖚𝖑𝖑 𝖋𝖎𝖓𝖆𝖑 𝕷𝖔𝖈𝖆𝖙𝖎𝖔𝖓 𝖑𝖔𝖈𝖆𝖙𝖎𝖔𝖓) {
𝖋𝖎𝖓𝖆𝖑 𝕻𝖆𝖎𝖗<𝕾𝖙𝖗𝖎𝖓𝖌, 𝕾𝖙𝖗𝖎𝖓𝖌> 𝖐𝖊𝖞𝕻𝖆𝖎𝖗 = 𝕵𝖊𝖋𝖋𝕷𝖎𝖇.𝖌𝖊𝖙𝕹𝕸𝕾𝕳𝖆𝖓𝖉𝖑𝖊𝖗().𝖌𝖊𝖙𝕭𝖎𝖔𝖒𝖊𝕹𝖆𝖒𝖊(𝖑𝖔𝖈𝖆𝖙𝖎𝖔𝖓);
𝖗𝖊𝖙𝖚𝖗𝖓 𝕹𝖆𝖒𝖊𝖘𝖕𝖆𝖈𝖊𝖉𝕶𝖊𝖞.𝖋𝖗𝖔𝖒𝕾𝖙𝖗𝖎𝖓𝖌(𝖐𝖊𝖞𝕻𝖆𝖎𝖗.𝖌𝖊𝖙𝕱𝖎𝖗𝖘𝖙() + ":" + 𝖐𝖊𝖞𝕻𝖆𝖎𝖗.𝖌𝖊𝖙𝕾𝖊𝖈𝖔𝖓𝖉());
}
i love that 1
@𝕹𝕸𝕾("1.16.2")
𝖕𝖚𝖇𝖑𝖎𝖈 𝕹𝖆𝖒𝖊𝖘𝖕𝖆𝖈𝖊𝖉𝕶𝖊𝖞 𝖌𝖊𝖙𝕭𝖎𝖔𝖒𝖊𝕹𝖆𝖒𝖊𝖘𝖕𝖆𝖈𝖊𝖉𝕶𝖊𝖞(@𝕹𝖔𝖓𝖓𝖚𝖑𝖑 𝖋𝖎𝖓𝖆𝖑 𝕷𝖔𝖈𝖆𝖙𝖎𝖔𝖓 𝖑𝖔𝖈𝖆𝖙𝖎𝖔𝖓) {
𝖋𝖎𝖓𝖆𝖑 𝕻𝖆𝖎𝖗<𝕾𝖙𝖗𝖎𝖓𝖌, 𝕾𝖙𝖗𝖎𝖓𝖌> 𝖐𝖊𝖞𝕻𝖆𝖎𝖗 = 𝕵𝖊𝖋𝖋𝕷𝖎𝖇.𝖌𝖊𝖙𝕹𝕸𝕾𝕳𝖆𝖓𝖉𝖑𝖊𝖗().𝖌𝖊𝖙𝕭𝖎𝖔𝖒𝖊𝕹𝖆𝖒𝖊(𝖑𝖔𝖈𝖆𝖙𝖎𝖔𝖓);
𝖗𝖊𝖙𝖚𝖗𝖓 𝕹𝖆𝖒𝖊𝖘𝖕𝖆𝖈𝖊𝖉𝕶𝖊𝖞.𝖋𝖗𝖔𝖒𝕾𝖙𝖗𝖎𝖓𝖌(𝖐𝖊𝖞𝕻𝖆𝖎𝖗.𝖌𝖊𝖙𝕱𝖎𝖗𝖘𝖙() + ":" + 𝖐𝖊𝖞𝕻𝖆𝖎𝖗.𝖌𝖊𝖙𝕾𝖊𝖈𝖔𝖓𝖉());
}
NOOOOOOOO
i love it
haha yeah those unicode things
idk at this point
🅿🆄🅱🅻🅸🅲 🆂🆃🅰🆃🅸🅲 🆂🆃🆁🅸🅽🅶 🆃🅾🆁🅴🅰🅳🅰🅱🅻🅴🆂🆃🆁🅸🅽🅶(🅴🅽🆄🅼<?> 🅴) {
🅲🅷🅰🆁[] 🅲🅷🅰🆁🆂 = 🅴.🅽🅰🅼🅴().🆃🅾🅻🅾🆆🅴🆁🅲🅰🆂🅴().🆁🅴🅿🅻🅰🅲🅴("_", " ").🆃🅾🅲🅷🅰🆁🅰🆁🆁🅰🆈();
🅱🅾🅾🅻🅴🅰🅽 🅵🅾🆄🅽🅳 = 🅵🅰🅻🆂🅴;
🅵🅾🆁 (🅸🅽🆃 🅸 = 0; 🅸 < 🅲🅷🅰🆁🆂.🅻🅴🅽🅶🆃🅷; 🅸++) {
🅸🅵 (!🅵🅾🆄🅽🅳 && 🅲🅷🅰🆁🅰🅲🆃🅴🆁.🅸🆂🅻🅴🆃🆃🅴🆁(🅲🅷🅰🆁🆂[🅸])) {
🅲🅷🅰🆁🆂[🅸] = 🅲🅷🅰🆁🅰🅲🆃🅴🆁.🆃🅾🆄🅿🅿🅴🆁🅲🅰🆂🅴(🅲🅷🅰🆁🆂[🅸]);
🅵🅾🆄🅽🅳 = 🆃🆁🆄🅴;
} 🅴🅻🆂🅴 🅸🅵 (🅲🅷🅰🆁🅰🅲🆃🅴🆁.🅸🆂🆆🅷🅸🆃🅴🆂🅿🅰🅲🅴(🅲🅷🅰🆁🆂[🅸])) {
🅵🅾🆄🅽🅳 = 🅵🅰🅻🆂🅴;
}
}
🆁🅴🆃🆄🆁🅽 🆂🆃🆁🅸🅽🅶.🆅🅰🅻🆄🅴🅾🅵(🅲🅷🅰🆁🆂);
}
but I can use funny symbols without any website, äfter äll I äm Germän
chicken wing
W♂▬▐☻♀
~~```java
p♥u♥b♥l♥i♥c♥ ♥s♥t♥a♥t♥i♥c♥ ♥S♥t♥r♥i♥n♥g♥ ♥t♥o♥R♥e♥a♥d♥a♥b♥l♥e♥S♥t♥r♥i♥n♥g♥(♥E♥n♥u♥m♥<♥?♥>♥ ♥e♥)♥ ♥{♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥c♥h♥a♥r♥[♥]♥ ♥c♥h♥a♥r♥s♥ ♥=♥ ♥e♥.♥n♥a♥m♥e♥(♥)♥.♥t♥o♥L♥o♥w♥e♥r♥C♥a♥s♥e♥(♥)♥.♥r♥e♥p♥l♥a♥c♥e♥(♥"♥_♥"♥,♥ ♥"♥ ♥"♥)♥.♥t♥o♥C♥h♥a♥r♥A♥r♥r♥a♥y♥(♥)♥;♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥b♥o♥o♥l♥e♥a♥n♥ ♥f♥o♥u♥n♥d♥ ♥=♥ ♥f♥a♥l♥s♥e♥;♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥f♥o♥r♥ ♥(♥i♥n♥t♥ ♥i♥ ♥=♥ ♥0♥;♥ ♥i♥ ♥<♥ ♥c♥h♥a♥r♥s♥.♥l♥e♥n♥g♥t♥h♥;♥ ♥i♥+♥+♥)♥ ♥{♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥i♥f♥ ♥(♥!♥f♥o♥u♥n♥d♥ ♥&♥&♥ ♥C♥h♥a♥r♥a♥c♥t♥e♥r♥.♥i♥s♥L♥e♥t♥t♥e♥r♥(♥c♥h♥a♥r♥s♥[♥i♥]♥)♥)♥ ♥{♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥c♥h♥a♥r♥s♥[♥i♥]♥ ♥=♥ ♥C♥h♥a♥r♥a♥c♥t♥e♥r♥.♥t♥o♥U♥p♥p♥e♥r♥C♥a♥s♥e♥(♥c♥h♥a♥r♥s♥[♥i♥]♥)♥;♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥f♥o♥u♥n♥d♥ ♥=♥ ♥t♥r♥u♥e♥;♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥}♥ ♥e♥l♥s♥e♥ ♥i♥f♥ ♥(♥C♥h♥a♥r♥a♥c♥t♥e♥r♥.♥i♥s♥W♥h♥i♥t♥e♥s♥p♥a♥c♥e♥(♥c♥h♥a♥r♥s♥[♥i♥]♥)♥)♥ ♥{♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥f♥o♥u♥n♥d♥ ♥=♥ ♥f♥a♥l♥s♥e♥;♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥}♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥}♥
♥
♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥r♥e♥t♥u♥r♥n♥ ♥S♥t♥r♥i♥n♥g♥.♥v♥a♥l♥u♥e♥O♥f♥(♥c♥h♥a♥r♥s♥)♥;♥
♥ ♥ ♥ ♥ ♥}
ᔕ
why not when you stop for the night start a mini project with what you learned
That is good, for me personally it's always easier to just learn trough projects
Not really, most things I do are open source
kinda
but it's not very much
maybe 100e per day
€
depends, my normal job pays better
in newer java versions, yes
in older versions, no
well, not really
switch("My String") {
case "My String":
case "Another String":
// These are two separate cases
switch(c) {
case 'A':
case 'B':
sout("A or B");
break;
case 'C':
sout("C");
break;
}
yeah that's two separate cases that just happen to run the same code
but end-result is same, isn't it ?
yeah that is true
anyway, it looks much better in newer versions
not really, i think that wont even compile
switch (material) {
case anvil, cauldron -> {
//some code, newer versions
}
}
yeah because its day 4, if it was day 3, it will be wrong
it would print both its day three and its day four
if using standard : syntax, you need to have break after every case
but if using enchanted switches in newer versions, you dont need break
the anvil does the same thing as cauldron
because there's no "break"
oh
I should have added a break after the first sout
yeah
wtf
I lost my old macbook
where the fuck is it
it used to be on the couch yesterday but now it's gone lol
Why the heck does my mac wanna boot to windows lol
Just as a side note, I seriously advise against Material switches
You're going to add ~100kb of code to each file that uses it
how do I hide the color code symbols from the text?
it just shows the Item as &2itemname
Need to use translateAlternateColorCodes("&", string here);. To automatically convert to a color code
how do I set custom name of a nms entity?
using § worked too
huh?
wdym
I mean, yeah, switches over material should be avoided because it'll "soon" not be an enum anymore anyway. but wdym with it adding 100kb of code?
Compile that snippet you sent and look at the size of the .class file
Could you please explain that in more detail? I'd rather not make that mistake myself either. But in essence, it's just a table of ordinals, so I don't get what's supposed to add weight here.
will do, 1 sec pls
Switches work by generating an array at compile time populated with all the constants ordered by their ordinal. The bytecode generated for the getter is horrendously large and effectively generates a block of code for each possible entry
This commit alone shaved off 2MB from the final Spigot jar
but how does that relate to plugins that merely compile against spigot?
because all that was generated just by using a switch statement over Material
It may just be the Eclipse compiler that Bukkit/CraftBukkit uses, but still worth avoiding switches over large enums
(notice in that screenshot I'm at line like 9000 and the scrollbar still isn't even half way down lol)
See the size of a good chunk of those files. They're all because of a switch statement
This is a more detailed bug report btw, https://hub.spigotmc.org/jira/browse/SPIGOT-7146
That has to be a compiler-bug, it's just stupid to call ordinal at runtime, as it's a compile time known constant which cannot be changed at runtime.
that looks like someone shading the classes tbh
That has to be a compiler-bug
Again, could be an Eclipse compiler-specific thing done for performance reasons
maybe, idk. I use the default maven-compiler plugin, not the eclipse one
anyway, I'll throw myself into the bath tub now lol
For performance reasons? Isn't the highest performance you'll ever get accomplished by inlining the constant ordinal values into the lookupswitch? This looks like a serious bug to me.
I totally get why you say what you said and I am happy that you brought this topic up, but I don't think it's good to discourage people from using switches on big enumerations, only because that one compiler messed up.
Realistically you should avoid switches unless you're explicitly making use of fall-through statements anyways
Otherwise you'll get some nicer-looking/more compact code using either a Map or if/else if
Switches are usually extremely fast, otherwise allatori etc wouldnt use them
especially for a large enum because you're going to end up with something like this lol https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java#4404-5384
What is the recommended way to handle "per player config"? Should I embed an H2 instance? Does the spigot API provide something to achieve this? Thanks in advance guys, you all have been super helpful.
Depends. Do you ever need to load offline player‘s data? If no: PDC
No need for offline data, lemme check out pdc =]
?pdc
Fucker beat me too it
I am awesome
Only awesome when u have your jäger
I dont know that

