#help-development
1 messages · Page 2034 of 1
do you know how we could use reflection to import CraftPlayer according to current version server is running? (so we don't need to update this code every update)
you can't "import" it using reflection
either you access all it's methods and fields using reflection
or you do it properly by writing a module per version
yeah haha i remember it was called like that before remapped, i had crazy fun finding those fields when they got obfuscated this way lmao
?
so you mean i import an *, then chain a bunch of getField() or sth?
That’s the docs for component builder
when u get an exception in your exception catch
If you want to access a class with reflection you have to use class.forName
And then getMethod and getField
@ivory sleet which one of these would i use instead of protocolVersion?
Is there a way to add an enchantment, but only if it's compatible?
1.18.1
let me check
ItemMetw#addEnchantment(enchant, false)
Iirc
ty :) Also, is there a way to check if an item can take durability? I tried itemmeta isntanceof Damageable, but it doesn't work.
weird
@patent horizon
((CraftPlayer) null).getHandle().connection.connection.protocolVersion still works just fine
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
Y'all wanna know something crazy
Zlaio was able to comprehend my small brain and help me without the need of ?learnjava
this is strange
starts having flashbacks
what version are u finding that from
because it looks like this is using 1.18, not 1.18.1
I feel u lmao
Hey, i've been trying to turn off sprint swimming for a week now.
However, it doesn't work for me, I've tried a lot, but nothing works.
I'm now trying to use nms but I also can't find a packet how to get the player out of that swim state.
Does anyone know what I can use or does anyone know of another solution?
I can help u in dms @lime jolt
what's the thing that's writes text here?
idk remember the name or anything
Actionbar
i got the same error a while ago but with like Materials and whatnot
some people told me to fix my dependency and those went away
could be the same thing
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>```
thanks
Anyone know why my config isnt updating when I change it? This is my code:
this.saveConfig();
ConsoleCommandSender console = getServer().getConsoleSender();
String botToken = getConfig().getString("discord-token");
console.sendMessage(botToken);
How are you changing it? Manually or with code?
Manually
I told you an hour ago to reload your config
why didn't you do that
You need to reload the config.
It didnt work
And restarting the server reloads it
it must have worked unless you did it wrong
:C
also why are you saving your config?
idk
instead of saving it, you should load the config
replace saveConfig() with reloadConfig()
does anyone why this line does not work "players" is an arraylist of Player objects if(sender.getName().equals(players.get(0).getName())){}
The array may be empty.
it is not empty
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
guess what????
but I think it is because it is ignoring the if statmnet
it still didnt work
this.reloadConfig();
ConsoleCommandSender console = getServer().getConsoleSender();
String botToken = getConfig().getString("discord-token");
console.sendMessage(botToken);
Does someone know how I can raycast if a player is looking in a BoundingBox?
actually Ima just keep trying random stuff until this works
Where do you even call that code?
onEnable
send your config with censored bot-token
the one that's in your plugin folder, not the one in your IDE
before they didnt say it was in onenable
oh its different
exactly
huh
before they just said "how can I make the bot token chane after I changed the file"
your code is reading the bot-token from your included default config.yml if it doesn't also exist in the actual file
@ivory sleet could u dm me your pom
I use gradle
ok
how to convert itemframe entity to itemframe itemstack (that holds all the data ofc including "fixed" "invisible" "item"
is it possible without nms
The frame itself?
ye
ah ok then nms will be an easier road
oki thx
do u know how to convert bukkit (itemframe) entity to nms (itemframe) entity?
I am trying to make a game, where multiple people can join, but the game is running it for every player that joins, is there any work around to this problem, so that when a player joins once, the game will only run once, even when the other players join
so the first player that does the command sorta starts it all
the rest dont have that ability
i didn't know those were castable from bukkit to nms
Cuz for itemstack there is a method ".asBukkitCopy and .asNMSCopy" or sth
so i thought i needed to do sth similar for entities
but i can't find such method so ig ur right
why that?
That gets the NMS entity from the craft entity
CraftItemFrame isn’t NMS
you’re casting the ItemFrame to CraftItemFrame because CraftItemFrame is the craftbukkit implementation of ItemFrame
CraftItemFrame#getHandle is returning the NMS instance
ah okay makes sense, also just cuz we're talking about that, even tho i could google it, why is there bukkit and craftbukkit impls?
i suppose craftbukkit is the most abstract one? like an api for bukkit?
No
Bukkit is the API
Bukkit is an API, it provides no implementation
CraftBukkit is the imp
ahh
CraftBukkit is the implementation of Bukkit’s API, and Spigot is a fork of CraftBukkit with additional changes made
i see
Is there a way to avoid this throwing an error in the console? Player target = Bukkit.getPlayer(args[0]);
I don't want to get spammed when a player makes a typo, or spams it
Make sure args.length > 0
thx alex & coll 🙂
And make sure you check if target is null after
^
If I click on an item, it doesnt detect that I clicked it for some reason
if args is an empty array there is no args[0]
Will it be null if the player doesn't exist?
Yes
Alright
if (clickedItem == emeraldOreItem) {
System.out.println("emerald ore clicked");
player.openInventory(emeraldConfirmGui);
Well, yeah
They could exist and be offline lol
If they don't exist, then error?
If they aren’t online it will be null
.equals
does that make a difference?
Yes
Just if a player makes a typo and the typed name doesn't exist
== is only for primitives, it compares memory locations only
alr ill try it
Equals is for objects, it checks equality by value
.equals can be overridden to do whatever comparison you want
Yeah
(But also defaults to memory comparison)
YOOOO IT WORKS
thanks!
You need to
a) Check the length of args to make sure they actually added an argument to the command
And
b) Check the value of target to make sure it isn’t null before you act on it
ok, thx
does someone know how I can add a marker (like on treasure maps) to a map?
I know I can create a custom renderer but it allows me to draw text, images or pixels, I just want the default red X to be added
declaration: package: org.bukkit.map, class: MapCursor
aren't those the player markers?
OOOH
there's a CurserType
thanks, I didnt even look at that class because I thought it was just the normal player makers
balls
should be the first one
other question: when creating a MapCursor, what's the center of the map? Is it 0,0?
yeah I thought so too, I'll just try out some values
nah it says invalid plugin when i try reloading it on my server
0,0 is the center
Did you read why
error?
Ah, fair enough
:3
make drakes map in minecraft
ah no i see why
make a display that you can play videos on
A zoomable mini map would be cool
thats been some like a quadrillion times
or better yet stream a pc or vm on maps
Lol
Omg
and have inputs ingame
Someone did it with blocks, not a map tho
You should stream a vm to maps and somehow have controls for the player to use the mouse and type in chat for keyboard
ive never seen that before
i know i can do this but like damn
it would be so cool
it would make a great youtube video
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDeath(PlayerDeathEvent event) {
Location location = event.getEntity().getLocation();
ItemStack map = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) map.getItemMeta();
MapView view = Bukkit.createMap(location.getWorld());
view.setCenterX(location.getBlockX());
view.setCenterZ(location.getBlockZ());
view.setUnlimitedTracking(true);
view.setTrackingPosition(true);
view.addRenderer(new MapRenderer() {
@Override
public void render( MapView mapView, MapCanvas mapCanvas, Player player) {
System.out.println("render");
mapCanvas.getCursors().addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 0,marker,true));
mapView.removeRenderer(this);
}
});
meta.setMapView(view);
meta.setLocationName("Test");
map.setItemMeta(meta);
Bukkit.getScheduler().runTask(this, () -> {
event.getEntity().getInventory().addItem(map);
});
}
Removing the MapRenderer from inside the MapRenderer causes this InternalServerError thingy
why
oh cause its accessing it but it doesnt even exist
oooo thats some trippy java logic
I have no idea, I basically just wanted to do add the cursor once instead of every tick
but it seems like you can only add them in the render method that gets called every tick
concerning map renderers
check if your .jar actually contains the correct plugin.yml
maprenderer#render triggers when?
(i mean when they are displayed on item frames)
ik they keep spamming the render method when someone is "viewing" it but i couldnt' really find out when it considers as being viewed/when it should be rendered
basically everytime someone has a map in their hand
I doubt it runs in a frame
no i mean in item frame
Since it takes a player
oh it does!
Iirc maps do not update in frames anyway
they do:
(i made a whole gif system so i know what i'm taliing bout)
when you have it in your hand, it gets called, when it'sj ust in your inv, it doest get called
im talking in item frames not in inv
oh and they do trigger #render like every 100 ticks orso
even if the map isn't changed
and even if its in item frame
“If a player holds a map whose clone is on display in an item frame, then that map updates while holding its clone.”
Sorta implies they don’t by default
really not
lemme give you an example:
it doesnt get called in frames
as someone already stated, the render method takes a player
maps in itemframes do not update, neither in spigot nor vanilla
Unless you hold a clone of them
no idea, all I know is that Player in render is annotated with NotNull
so it'll never get called without having a player holding the map
I login for the first time on my server since last reboot
my inv is empty
I look at my wall, it has an item frame holding a map
On startup, i removed all renderers of this map and added a renderer which #render(...) only executes System.out.println("rendering")
You will see, it will spam "rendering" to your console
Guys you all are wrong here
test it if u dont trust me
okay one minute
its just like anvilprepareevent, it keeps triggering
oh fun fact
it keeps rendering, but WAY slower
with a player holding it, it keeps spamming it like 5 times per second
without a player it goes down to once per second
^^
I don't have alt accounts right now since I'm too lazy to migrate them to M$
Lets say the stone block to the right is the starting location, and the stone block the left is the ending location, how would I get the location right in front of the starting location (jungle wood block) that's in between both locations
math 😛
vectors
I'm having trouble with that 😭
you can get the vector between both locations which is basically an arrow pointing from start to end. then you can normalize that vector so it has a lengh of one, add it to the original location, and get the block at that location
done
see i told you; anyway back at my question, i really wanna find out when this method triggers (when in item frame)
I mean the answer "when a player is viewing it is vague", cuz when does it consider that a player is viewing it? does it have a brainy logic to check if player is watching it specifically, like checking the angle of vision and big brain maths stuff to determine if its in his visibility? (Spoiler alert, no, i tested it)
I would imagine like
As long as the entity is in activation range?
Or what’s it called
Simulation distance
you don't have to "view" it, it's enough to be nearby a placed itemframe
IIRC the view distance for stuff in itemframes is 64 or 48 blocks
so probably the maps will use a similar distance
Alright so... ```java
endLoc.toVector().subtract(startLoc.toVector())
Would that be how to get the vector in between
Me too
Alright
Ugh making a mini map with maps is gonna be annoying
Thanks
I gotta like, manually render each pixel
yo guys, I don't see another solution as this to only add a cursor to a map - does anyone know if there's a better way?
view.addRenderer(new MapRenderer() {
boolean done = false;
@Override
public void render( MapView mapView, MapCanvas mapCanvas, Player player) {
if(done) return;
mapCanvas.getCursors().addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 0,marker,true));
done=true;
}
});
I basically just cancel the render() if done is true
which is a bit dirty since I still have the maprenderer object being around now
I actually don't need any renderer, I just wanna add one cursor that will stay at the same location forever
before I test this does this look fine 😭
currLoc.clone().add(loc.toVector().subtract(currLoc.toVector()).normalize());```
I'm trying to make a mob pathfind into a certain type of ore and mine the blocks in front of it, it's killing me lmao
yep that looks fine
Alright, and if I want to get the 2 blocks in front of that, would I just multiply the whole thing by 2/3?
exactly
I’ll have to just look at how Mojang renders maps and copy borrow that I guess
Alralr thank you
but ideally, I'd love to do it without NMS 😄
Can never escape NMS 😈
since remapping is a thing, I don't hate NMS anymore
only problem is when an update gets released
when 1.18.2 came out I was on vacation >.<
Im not even using the mappings, I'm deadass just going to this website https://nms.screamingsandals.org/1.18.1/
Don't know why I'm doing this to myself, but it works
you should be using mojang mappings
because
they allow you to recompile all your stuff with the same code
if 1.18.3 comes out, all you have to do is to recompile it without any code changes
Ah for cross version compability?
well, mostly without code changes
Hi folks! how can i send bungeecord messages directly to another server on the network?
for cross version you basically have to copy/paste your code into different modules and compile them all against different mappings
but yeah you can always just copy paste your stuff
That's true, abstraction is annoying to set up but over all better than reflection ig
yep. for example:
all I had to do to go from 1.17 to 1.18 was to change
playerConnection to connection.connection
when sending packets
no other change was needed
Well unfortunately you're obliged to use a mapRenderer (i've been dealing with that myself and i'm 99% sure u need a renderer here, mainly cuz the mapcanvas object where ur drawing ur stuff is only received over there in #render)
Concerning cursors, i think you could do image editing; add your cursor on top, and render your image on mapCanvas.drawImage(...) (kinda overkill for what ur trying to do tho i think)
I just want to add the default builtin cursors, but yeah no problem, I'll just get a new MapRenderer and make it do nothing after it ran once 🙂
yeah its what i've been using :p
e.g. this, just having a banner_orange in the middle, that's all I need
Yeah mojang mappings are def better, it was really weird when they changed the way to get the pipeline from ```java
playerConnection.networkManager.channel.pipeline()
b.a.k.pipeline()
yeah lol indeed
mojang mappings are heaven sent and cursed at the same time
cursed because ability to use reflection is completely gone
heaven sent for the rest
Oh yeah lmao I remember trying to do it for datawatchers and I had to add the seperate import just to see what the actual class name was
Then I realized I didn't need reflection at all 😆
At first it was also confusing to adjust to it because of all the name changes
More used to Hsjqwdhjqwdhu then Mob
I highly suggest to create a lib that you use for all your NMS stuff
I love reflection 
me too but "not workings" in remapped 😦
Probably a good idea, although it can get very uinnecessary because I usually do commissions
since we talked about map rendering, i'll just send that here https://i.imgur.com/sTaGrRc.gif
flex
This reminds me of when I got groomed by a furry
lol
yeah okay^^ I'd still do it. for all comissions I use the same lib that I use for all my other plugins 😄
Not great times 😆
🤣
Yea I have a lib for myself called AsePlugin and AsePluginDatabase, might make an AsePluginNMS
It's for auto registration of listeners and commands
Ohhh bro I got a cleaner version of that
Another question: Look at this map. This is the code:
meta.setMapView(view);
meta.setLocationName("Test");
map.setItemMeta(meta);
what's the location name for? it nowhere shows up on the map
are u guys trying to make remapped nms usable at runtime or sth? or what are all these sc
Google Commons lib in clutch
Saw that somewhere on spigot 2 years ago LOL
Makes sense
Maybe look into the code
I have no idea what they are trying to do
I mean if it's just for spigot then the google commons lib is prolly a good idea
Huh
Map location name isn’t documented properly
It has the same javadocs as setMapColor
Maybe it's supposed to set the text when you hover over a location on the map or something
probably the second wally
Second for spigot,
3rd for NMS
does anyone know how ticks count, do they count for each individual player or togheter
the server
so for all players the same
dang
why?
this is confusing then
what are you trying to do?
all my code bugs out because mutlipel players do a command that loads the entire game
so my chat format goes away when i use %s in my message. how can i fix this?
if (player.hasPermission("chat.color")) event.setFormat(u.f("&8[&e" + level + "&8] " + prefix + "&7" + event.getPlayer().getName() + " &8» " + chatColor + message));
else event.setFormat(u.f("&8[&e" + level + "&8] " + prefix + "&7" + event.getPlayer().getName() + " &8» " + chatColor ) + message);```
I only want the first player who does the command to load the game
and the rest who use it just join
I have a peratmeter that makes it do that
but
wdym with the "format" goes away?
i think but (really i'm not even 50% sure here) that location is just a meta data string which isn't relevant that much, just for some "checking what type of map it is" like "this map is the map of a shipwreck so location=beach?" or "this map leads to the illagers place" etcetera
Actually MapMeta is NOT interfering with actual stuff that it rendered on it, it's just a class to hold data; MapCanvas is the one where u'll be able to make appear some stuff on it like cursor text etc
it no work
Set a global variable hasGameStarted or something and set it to true whenever the first time its loaded
java.util.UnknownFormatConversionException: Conversion = 'p'
at org.bukkit.event.player.AsyncPlayerChatEvent.setFormat(AsyncPlayerChatEvent.java:105) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at net.plexpvp.core.listeners.ChatListener.onChat(ChatListener.java:50) ~[core-1.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:37) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:git-Paper-177]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.adventure.ChatProcessor.post(ChatProcessor.java:230) ~[paper-1.18.1.jar:git-Paper-177]
at io.papermc.paper.adventure.ChatProcessor.processingLegacyFirst(ChatProcessor.java:115) ~[paper-1.18.1.jar:git-Paper-177]
at io.papermc.paper.adventure.ChatProcessor.process(ChatProcessor.java:64) ~[paper-1.18.1.jar:git-Paper-177]
at net.minecraft.server.network.ServerGamePacketListenerImpl.chat(ServerGamePacketListenerImpl.java:2204) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2115) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2081) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket$1.run(ServerboundChatPacket.java:40) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
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) ~[?:?]
[01:07:22 INFO]: <WallyTube> %haha
oops
LOL
u saw nothing
you are doing it wrong
how so
you have to set the format to sth like htis:
Hi all
I did that
"[%s] %s"
I woke up
this will make it show like [mfnalex] hi
you can use two %s: one for the playername, one for the message
I created a static arraylist and asked if you are the last person in the array list, if so you start the game
DO NOT add your message manually into it
then check if its true, and if it's true, make them join, if it isn't true, make it start the game
@tender shard I love you for the vector math it finally worked
is using a runTaskTimer important or can I use something else to count ticks
:3
is this code to be able to use non obfuscated nms classes at runtime (with reflection)
my math skills are almost down to 0, I finished school 10 years ago, but good to know that I least can do basic stuff like this lmao
This code targets your plugin's stuff but is capable of targeting nms classes.
Yeah that's great, I might've been have been able to do it myself if I learned how vectors worked
Hmm I wonder think my minimap idea will work for anything bigger than 128x128
And what are intermediary/searge mappings?
what biome is this
old_growth_spruce_taiga
looks like an mmorpg
note: the golden platform is TOOOOTALLY vanilla
Of course
show your mousebutton history
wtf is that
do you people also have such weird config classes? or how are you handling default config values etc?
name.setHoverEvent(
new HoverEvent( HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder("lorem ipsum").create())
);``` how can i set a hover text with multiple lines?
Yeah mine looks about that ugly tbh. I tried a bunch of different ways to make it pretty but it gets too complicated to understand.
I do it differently in every plugin lmao. AngelChest is the weirdest one. I got a Class "Config" that has all the config node names like
Config.ALLOW_WHATEVER = "allow-whatever";
then in ConfigUtils I assign all the default values lmao
but I'm not going to refactor 400 config options now
RedLib makes it nicer
but can it auto-update existing configs, while keeping all comments?
Yes
that's nice
will take a look at it sometime again
for real, I have read so many blog posts and still don't understand why people think using a static instance getter is bad practice.
public class DeathMapManager {
private static final Main main = Main.getInstance();
How is that bad? I don't get it
hard to test
tightly coupled so it reduces re usability to some extent
how is that hard to test? MockBukkit and let's go
no lol
could i just insert a list?
and its hard to see the actual dependencies of a unit when u couple it that way
Every 20 ticks in one of my classes, a countdown from 10 starts. This is when a message and a title is sent to all the players in the game stating what the count is in the countdown (10, 9, 8, 7, 6, 5, 4, 3, 2, 1). However, the countdown is showing only even numbers for one player and odd numbers for another (when there are 2 players on the server) (One player sees; 10, 8, 6, 4, 2, 0, -2, -4, -6, - 8, -10 and other sees; 9, 7, 5, 3, 1, -1, -3, - 5, -7, -9). Why does this happen, and how can I fix this issue? the code below is what prints it, but this should not skip a count and have diffrent counts for each player every other 20 ticks .```for (int i = 0; i < MyFirstPlugin.players.size(); i++) {
MyFirstPlugin.players.get(i).sendTitle("" + countDown, "Void Is Starting", 1, 20, 1);
MyFirstPlugin.players.get(i).sendMessage(ChatColor.DARK_PURPLE + "Void Is Starting In: " + countDown + " seconds");
MyFirstPlugin.players.get(i).playSound(MyFirstPlugin.players.get(i).getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 9999F, 1F);
countDown--;
}```
Sure
You'd need power mocks to mock that dependency mfnalex
haha lol no I'm not crazy
mockbukkit is for mocking certain bukkit interfaces
But you can use \n in string too
power mocks is a lib in case you didnt know
whut? no, I just let mockbukkit instantiate my whole plugin for testing
Because your count down
but like you mock units to presuppose that no dependencies causes a unit's procedure to fail
I just do MockBukkit.load(AngelChestPlugin.class)
@lime jolt think about your code
it should only go down by one though
I'm not sure what you mean with "unit" tbh
AngelChestPlugin
countDown--;
When I was getting back into plugin development, I started not using static instances and it just makes the code messier WITHOUT a static instance, having to pass it in every parameters
exactly, everything gets so much dirtier
really doesnt
well not dirtier
but way more complicated
I don't want to have to pass 20 things to every new listener or class or whatever
if your code is well designed your constructors will still take a maximum of like 4 dependencies
Yea, and then you start having a bunch of managers that you have to call the instance for each time instead of just calling one single method
then you're doing something wrong
I am totally fine with a listener belonging to AngelChest depending on AngelChest's main class
well, my listener needs to access
- the list of all existing angelchests
- all config options
this is already two things I'd have to pass instead of just getting the main instance once
The point of using dependency injection is make any outside dependency conspicuous, decouple the unit such that it does not tightly depend on a specific instance which static singleton pattern surrounds and it makes the unit more testable and reusable in case you have a different instance of whatever dependency you might have.
yeah I get it but I doubt that 99% of people ever need that in a spigot plugin
create a context interface that serves as a middle man between the listener and your functional requirements
but I don't see any advantage in doing so
it would just make everything more complicated imho
decoupling, abstraction layering, separation of concerns etc
I don't need to decouple a listener that is made specifically for plugin X to be independent from plugin X
maybe not right now
it's worthless without plugin X anyway
but in the future its very possible radical changes may be encountered
people always assert and claim that future changes are predictable
I am pretty sure I'll never need a listener that listens to player's deaths and creates an AngelcHest for them in any other plugin that won't be angelchest, ever
thats 100% false without fail
but yeah, sure, one could never know for sure
I just don't see any advantage in doing all this refactoring right now without getting anything in return right now
business requirements change all the time, so making one's software as robust as possible is a substantial goal, if you cannot make software malleable and shapeable then your software is simply not soft
yes its mostly overkill for a mere spigot plugin
I don't consider one class a software but the .jar as a whole though
this is one of the most insane bugs I have every seen
yes
noone extracts a single class out of a project and expect it to work
4 arguments?
but in regards to this
its just worse in long terms to couple DeathMapManager with Main::getInstance
sadly that is what LuckPerms suffers with
its quite coupled to the plugin context object
somewhat impossible to track dependencies
yeah I do agree
I still don't understand why I'd ever need to keep a listener running that was made for exactly one plugin without having that one plugin's main instance
some people circumvent colossal argument constructors by using dependency injection frameworks
but those di frameworks just suck
Make a simple one just for plugins
I always just hated them
Injects your plugin instance into @Plugin annotated fields
then those classes still rely on the plugin though so where is the difference
imho making everything testable and reusable is a huge waste of time
Or can it just like, detect new instances being created
one should just make stuff reusable if you actually intend of reusing it
With magiks
well listeners should be among the lowest level classes you have so they will depend on higher abstractions
if your listener for instance encapsulates a static singleton call
then it will be impossible to substitute concretion of said higher abstraction
of course the disadvantage may seem rather subtle if you dont pay attention
but lets say you wanna test it, or you wanna swap concretion
then having that dependency injection from the beginning would have minimized the change you'd have to go through
and that's exactly what I don't need in 99% of cases
now yes you rarely do unit tests as I understand so automated testing for you is probably not something you account for
yes but these implementation changes happen all the time
like in adventure, bungee chat api
I do a huge amount of tests, angelchest takes about 2 minutes just to do all tests, but of course I have an instance of my plugin when running those tests
I can name just so many libraries where spontaneous changes to details had to be made
well I mean even LuckPerms
yeah there's a huge difference between a library and a listener that obviously does stuff only related to one specific plugin
altho its abstraction hierarchy is flawed
just replying in case this issue gets lost ;-;
well, at least I'd minimize the scale of impact future changes could affect me with, but Ig its up to you if you want to do that as well
like at the end sure using getInstance wont destroy you
its just about maintainability, robustness and clarity
sure I get that and also understand it's better, I just think that if I'd count the amount of time spent into making everything more abstract is not worth it in most of my cases
ending up with LinkageErrors eventually
I’ve never seen a linkage error
well in your cases it seems like
Just do better
Shh
I’ve seen NoClassDefFound
ye one of them
But that’s because I’m bad at shading
Use annotations to avoid it
mfnalex, like oop devs wouldn't have come up with all of these principles and patterns just because of mere fun
so that's why I hate it when people say "oh no, static getInstance is baaaad" no that's not true, It's not bad in general. It might not be the best future proof option but that doesn't mean it's inherently bad. Like, everything we are coding depends on something and we can never go 100% independent, it's just a trade-off between "how abstract do I wanna go" and "how much time do I rather want to spend on adding new features" etc
they had to address problems that oop generally had
the very flaws of developing with oop
For a projectile trail (for it to look a little smoother by being behind the projectile), do you think it'd be more efficient getting the projectile's velocity then subtracting it's x/y/z values based on the velocity and spawning the particle at that location until velocity = 0 (then it cancels)? Or do you think it'd be more efficient to use a BukkitRunnable timer, then another timer inside of it to grab the location currently then runTaskLater() lots of times until the previous and current locations match in which it cancels? More so thinking the 1st option but may as well ask to be safe lol
there's a reason why most companies demand developers to have high abstraction ability for instance and thats for good reasons
yes getInstance isnt inherently bad and no one has ever claimed it to be
Just use copium levels of reflection instead 
its just 16/17 times not gonna be the right design pattern due to the disadvantages it ultimately yields
I'd totally understand it for huge software projects, sure
Well, even for smaller ones
but I really don't understand it for spigot plugins
oh wait
wasn't there a tool to check the code lines and also prints out the number of lines per language
a linux CLI tool
lol
First one
idr
as aforementioned its not the most crucially integral thing as to a spigot plugin
but it sure helps once the plugin might scale to different platforms and what not
Conclure wanna see something nasty?
lol sure
Oh no
I wrote this class in 2018 when I just got started with MC plugins
every field is public
lol
why would they?
I very often have private final fields
or private static final fields
Private is banned

the most weird thing is "package-protected"
thats a thing?
that's using no modifier
it means same package can access it
ye
What’s the dif between protected and no mod
mye I kinda hate packpriv
I always forget
does anyone even use that
rarely ever needed
apparently yes
:thonk:
but it becomes incredibly annoying if you use it for, for instance constructors, especially when you start unit testing
default = no modifier
I see
mfnalex so since you do unit test
in SOME plugins, lol
would you claim that unit tests make your code architecture better
or not?
out of curiosity
How can I make this less laggy, it runs every tick and is kind of killing the server, it's checking to see if the path is done, and if it is, it will break the 3 blocks in front of the mob
not at all. I think tests should always be written by another person. Many persons start by writing the test, then doing the implementation and then think "oh the test works, alright so my class is working".
iirc u can set the type w/o applying block physics
yes, there's a boolean for that
lol okay
Im with u
unit tests at no point will give you better design
Sysout also tends to slow things down a lot
if at all, they make it worse by just writing the class to pass the test
How should I do that
yeah it's a philosophical question I guess 😄
setType(type, false)
Ah that's true
well Ig tdd fans might be hunting us down soon
Thank you Il, try it out
tdd?
If you can, use fawe api or nms
test driven development
That is already nms
Oh wait that isn't nms
I mean setType
does a while loop create its own thread in java?
I'll try that
but basically the cult of tdd enforces you to write humongous amount of tests
supposedly that will help you to code better or make sure no code goes unused
(tho im strictly against it)
Isn’t there coverage testing for this
yeah
you need to have like 99% test coverage
or sth
basically you wont be able to test priv, packpriv and prot functions
but all public functions should (in principle) be MUST tested
Ew
ye
I’d rather just use the default code coverage

Ahhhhhh reflection is so slow
Granted that’s harder on plugins
j18 gonna make it fast as fuck
yuh

Or use them method handles
I just don't write tests
why?
unit tests can be to much help if you have a couple of non trivial functions you wanna make sure dont do the wrong thing
and when it comes to atomicity
testing is more or less crucial I'd assert
I mean im using it for a protected NMS method and it freezes the entity every time
because it is faster to have beta testers test it out, then it is to create some test for it that may need to change later down the road
Will j18 reflection make method handles obsolete?
oh so the qa people gets to test it
Well, in terms of performance at least
while QA people are not perfect, it is still faster
meh
also, they will test for things you didn't think about as well
they cant test everything unit tests are capable of
I gotta admit
which a unit test isn't going to do
sure thing
Users can find some weird bugs
probably someone wrote a test to test if the test coverage reaches this goal
Like how someone found a typo in the latest snapshot :p
TestTests.java
but you have tests which tests when units talk to units, and when the entire system talks with it self also frostalf
Testing the unit tests
like system tests
lol
typically the one creating the code, shouldn't be the one creating the test
yep
because you already know how it is supposed to work, or in other words biased
depends I'd say
at least you shouldn't write the test before writing the class itself lol
it is the same reason why developers don't test their own stuff when it comes to QA
if you implement a multi threaded 2d map then perhaps its best if you write the tests for its atomicity methods
but yeah having another person to the tests will probably result in better testing
I mean alpha testing is fine for developers to do, but beta testing is done with other people
because you wanna show you coworker fucked up so you're trying to really break their code lol
for example imaine you have a math class that does stuff. now pass Double.NaN to it and watch it explode. you probably wouldn't do that in your tests for your own class
And when qa people test they sometimes find a bug which to most extent is impossible to identify trivially, whereas if some tests were written could have easily tested the procedure out
NaN is by far the weirdest construct in whole java
Double.NaN == Double.NaN returns FALSE!
Double.NaN == “potato” should return true
no that's false too
Because “potato” is in fact NaN
lol well yeah
hehe JavaScript
Double nan = Double.NaN;
if(nan != nan) {
downloadCraftbukkit();
}
THis will actually download craftbukkit
does nan mean not a number
yes
An operation that overflows produces a signed infinity, an operation that underflows produces a denormalized value or a signed zero, and an operation that has no mathematically definite result produces NaN. All numeric operations with NaN as an operand produce NaN as a result. As has already been described, NaN is unordered, so a numeric comparison operation involving one or two NaNs returns false and any != comparison involving NaN returns true, including x!=x when x is NaN.
Well, you can make tests, but the reason I don't is because generally it is me making the code anyways. Sure I can make arbitrary tests, but it is far harder to test for something you don't know then it is what you already know 😛
NaN in double is 0.0d/ 0.0
thats retarded
Yeah
why not just add more safety instead of having that
that is more dumb
0 / 0 throws exception
as it should...
but when using 2 doubles, it results in no expection
ok back to being dumb
sqrt(-1) is i
javascript is such a horrible language
I agree
Wait
NO
I don’t think so.
So divide by zero exception or whatever
just admit it, you don't think at all
Is only for integers
Every language has its feature.
and short, byte, ...
Well yeah
it's only doubles and floats that can produce an NaN
lol not
well by any means I don't mean arbitrary tests, rather you just test that something is not false (double negation, but thats the only way to put it), of course qa people have the advantage if easily finding bugs between different layers, but a lot of bugs can simply be reduced to atoms by merely testing correctly. tho I do agree many people fail to write good tests (thus the guessing of tests)
but I mean should we avoid a tool because its hard to use?
It just like Double.parseDouble can throw NPE, but parseInt can’t
Yep
what does Integer throw instead?
But parseInt just a throws NumberFormatException for null
lol weird
I am not saying to avoid it, just it isn't intuitive in terms of testing your own code if you are also creating the tests. Sure you can create some tests to just easily test certain things you know that shouldn't change, but like it is super hard to have broad coverage though if you are both the creator and the tester. But I wouldn't ignore it though because you can use it for certain functions that don't intend to change for example.
also it takes time to create the tests, I am of one that much rather utilize that time making more code or doing more things in the project then setting up tests
I mean to begin with the name unit test is an immense mismatch since we're actually just testing procedures, and then of course knowing exactly how to test the procedure might not be trivial at all. That's for instance why we make everything loosely coupled and plausible mock dependencies to isolate the mere unit along with the procedure. And yes what you said applies to thread safety and atomicity pretty much, how do we test it? What is it that we want to test? But for the most part you will learn what to test and how to write them if you write a lot of tests. Sure the tool is hard to use but it is pretty advantageous, lets say something changed, instead of letting qa people test the entire system once again you could simply press a button to test if the change broke anything else.
And no tests do not take much longer time to write once you get used to it, for instance it has generally been proven more effective to enforce employees to test driven development than to just let them write whatever code they feel like writing.
??
why can i do 0f for a float, and 0d for a double, and 0l for a long, but not 0b for a byte
binary iirc
I suppose it would just depend on where you are in the project maturity wise
myeah
in the beginning probably not an advantage to have tests
im not totally pro tests either
shorts also don't have it
but I believe its a substantial tool developers should learn (at least)
then whether you go full out testing is up to you 
but did you know you can add underscores to numbers?
public static final int ONE_MILLION = 1_000_000;
public static final int ONE_BILLION = 1_000 * ONE_MILLION;
ye
But if you get a nice established project going, where you are not making wild drastic changes
I can see it being a handy tool
but, despite me acknowledging this, I probably still won't write tests 😂
nope
Rip
yeah
the error is weird
I rarely test stuff
Sad you can’t use , in numbers
altho I got very committed to tdd for a time
"Binary numbers must contain at least one binary digit"
what is that supposed to mean
Wait
0b0 is an int
yup
So the “0b” is the constant
ye
let's blame md5 for this
everything weird in java is just md's fault
Is something wrong here?
did you log out and back in again after adding that var?
reboot or log out and back in again
not sure if relogging is enough
i have to update anyways
Ayyy
0ϖ0 looks a lot better in my opinion 😉

guice?
What is guice
thought u were using guice dependency injection framework
cuz it looks more or less identical
hmm u can use custom annots if wanted
Everything my lib does requires no external dep
Ah
Still didnt work :(
if u go to cmd
Fricken google always puttin U in things
Only catch is this only works on listeners and commandexecutors that I register.
Looks good to me
yeah Maven doesn't want bin
uwu
command prompt wants bin
its the best 🙂
making them 100 lines of bat files to do something that takes like 3-4 lines in bash
always fun
yeah lol
Bin me UwU
PATH and JAVA_HOME are separate
aight throws you in the trash
yep they are, however JAVA_HOME should point to the directory that java as a whole is in, not the binaries
hence you know its home
It should be common sense but I suppose these days confusing lmao
what would be nice is if maven stopped using JAVA_HOME
Well there are some files that aren't available just from bin
I don't know which ones Maven would use though
Makes sense
Where can I download the spigot javadocs?
This isnt working for me:
javadoc -d javadoc -sourcepath ./java -encoding UTF-8 -subpackages org.bukkit:org.spigotmc
Lmfao that's the java discord API
Yea but whats "sources"
Source code jar
The sources?
Why is that helpful?
You can view the source code
Oki
Comments and all
The most important part
Indeed
is there an earlier phase to generate-sources for the exec-maven-plugin?
the first phase is validate
what does that do?
what do you want to do?
idk yet
hm lol
you can also register commands at runtime
the plugin.yml isn't really needed
for commands
how
1 sec
I use this to register custom commands or commands with configurable aliases: https://github.com/JEFF-Media-GbR/JeffLib/blob/7f39ade400d43f118728fa0dd6cae5fb80ef4af1/core/src/main/java/de/jeff_media/jefflib/CommandUtils.java#L36
it's from my lib, you could just copy/paste that method
ok, seems useful, thanks
however most of the time I just use ACF for commands
one thing about the pom file, how do i add a second script? and how will it know which one to execute on each phase?
<build>
<plugins>
<!-- exec scripts before and after the build -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>bash</executable>
<workingDirectory>${basedir}</workingDirectory>
<arguments>
<argument>./scripts/pre.sh</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
i want to run pre.sh on the validate phase, and post.sh on the package phase
Wait the command map is in the simplecommandmap class? Damn now I can auto register commands and avoid plugin.yml all together 
I think you can just add that plugin twice
yep
why is executions a list and configurations isnt? is it supposed to run the same thing more than once?
tbh I have no idea
is there a better way to do discord JDA integrations with a spigot server rather than just running the discord bot directly on the server as a plugin? Like maybe something with sockets?
imo Lamp is better https://github.com/Revxrsal/Lamp
everything runs after the phase, right?
well no
they run during that phase
if you have more than one plugin for the same phase, they will be run in the order as defined in your pom
i thought that the package phase puts all .class files inside a .jar or something like that
validate -> compile -> test -> package -> deploy
that's the most important phases in their default order
yes, exactly
compile turns .java into .class
and package puts all .class files into a .jar
basically
so, what if i copy the jar or something in the package phase
but the jar isnt ready yet
or something
you want to declare your maven-jar-plugin at the top to make it create the .jar first
or at the bottom if for some weird reason you want it to run last
you gotta understand the differences between phases and goals if you really wanna do such specific stuff
is this the default config?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
well no, the default would be to not specify it at all, then it'd try to use java 5 as source and target and probably would use a 10 year old version of maven-compiler-plugin lol
but yeah that's basically the minimum information needed, so yes
ok, i tried to find the link to the repository of exec-maven-plugin and maven-compiler-plugin but i cant find it, any help?
it's in maven central, it's incuded "by default"
i mean like this, just html, with no css
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
yea but i want to check the latest version and add it to the pom file
yea, but thats for users, its a gui, there is nothing like this?