#help-development
1 messages Β· Page 729 of 1
^ this as well alongside whats called open source projects where there can be thousands of contributors
I keep getting this error : "org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!" because i'm initializing the plugin twice, how do I not
That was my question
Starting again from a clean slate, my point, put simply is yes for the vast amount of variables encapsulation is great. But there are edge cases where its more annoying than useful. In a usecase where you're developing a plugin for personal use and are going to use it with other plugins, the likley hood another plugin dev who has never heard of your plugin, attempting to disable and cripple it is almost 0. At that point it's malware and shouldn't even be on spigot. Race conditions yes. If you're threading then it's very dumb to not use it. If I wanted to protect my variables from invalid write or read requests I'd be on it all day. Nothing is perfect. I could bypass the method with reflection and set it to null if I wanted. Or some JVM trickery. It's not going to kill someone if the instance of the main plugin is public. That's all.
Maybe I said it wrong
You have more than one class extending JavaPlugin. :p
No worries mate you do you. Method or no method
damm
?DI or a static instance (preferably with a getter :p)
yes its not gonna kill some1 thats true
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Stupid bot is case sensitive smh
I think it may be fine for certain singletons, esp if they are eager ones
If a getter's only purpose for the variable is supervises is to provide the variable and there is no other validation logic, or threading, I don't see why it needs a getter
I'll use dependency injection
the issue is that you rarely know if a getter's only purpose is ever going to be that of a vessel just acting as a bridge to the field invocation
i mean sure we can assume that
but that also presupposed that we never use that class in a situation where it is exposed to situations that may widen its usecase
or well that variable at least
You can never know the full requirements of a system
this especially in light of that I wanna avoid writing proxy patterns and adapter patterns for poorly written apis just to have that binary compatibility
they always seem to grow
depends, we have different requirements
well yes
functional and non functional
However, a private instance doesn't stop me from killing a plugin
there are many ways one can do that
yeah
you might want to protect instance if you're doing other things in the main class?
other than onEnable and onDisable?
personally I'd delegate those to other classes hence the S.O.L.I.D principles
from what I have been taught and what I learnt its rather about trying to show our intentions in code
as good as possible
aye
I'm still getting the error. Should I paste my code?
sure thing
i mean whilst keeping it maintainable and extendable etc :>
oh ofc :>
Should I open a thread instead?
optional, I wrote a pinned message about it tho no1 really cares
so I can talk in 2 places
fr
or multiple
there is a game framework for java, I think it's LibGDX, you'll faint when you see how many public vars it has lol
I keep getting this error : "org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentExce
Is there a way to config the clean task to not clean certain moduels? I dont want my nms modules to be cleaned
since it takes like 40s per
and i have 7
gradle?
yes
@wraith apex I tried to type an actual apology and got hit with the "contains content blocked by server owners" message, I have literally no idea what I would have said that triggered that
you can define a lifecycle task
originally meant to DM it but it wouldn't go through so
that just composes the clean tasks of said modules
Ooh find the filtered word
lmao, don't worry about it it's all good π
My favourite game
we both get hot headed :D
Still, I'm sorry for being a total ass back there. I respect you for being chill about it, though.
not that this excuses it but I think work/home stress are just spilling over into other shit lately π
The secret is my coconut scented candle
maybe I should invest in one lmfao
shit, it's popular
aw :c
raincheck time
it's great
oh yeah, I originally did come in here to ask a question - has anyone worked with the JNI through Spigot?
the Java GC isn't super performance friendly sometimes, even with object reuse
would rather just hit it with the C++ treatment
I heard GC is pointless since a call to GC is only a oh would you pleeeease gc this?
you can
have u tried optimize gc first?
it's not great
A manual GC call? yeah I don't even know why it's an option
it's like someone tried to memory management and then didn't
its disabled for most jvm instances
jvm flags
yeah well they have a steep learning curve
I'm trying to think of a way to simulate how this stuff would get used in an actual environment
i still dont get some of them
it's okay I've been working with what I do at my job for over a year and I still don't understand about 70% of it
tl;dr state machines (on custom entities) and stateless sequences as well as serverside custom projectiles
plus shit like raycasting
guess I'll have to write some kind of test plugin to break the server first
i'm absolutely terrible at profiling plugins, haven't really worked with spigot for a couple years so idk what tools people even use anymore
Spigot devs when they shade their plugin with 2tb of node modules because it has an inbuilt web server
sweats
it contains the entirety of jackson, unfortunately
it's actually not that much code
oh
christ what does this plugin do lmao
my unshaded jar is like 1/10 the size
a lotta stuff, let me find where the img is
lmfao
bro wrote a comprehensive solution to all spigot problems
just kidding, you'd need to fork spigot
was like 45k lines
i've got one that's uhh
325kb? but that's only about 30% done because I got an actual job and just left it on the backburner
this is 1 of many mechanics inside it
damn, that's actually really cool
looks really clean too
blueprint plugin for survival
factorio energy
allows players to create, store, rotate, mirror, copy, and paste blueprints of builds
it's to encourage bigger base building
not much of a builder and the lack of a blueprint system is probably why tbh
is this for a server?
yup
ah, alright, having an actual purpose probably helps too lmao
I kinda lost motivation to work on any plugin stuff once I stopped working on servers lmao
pivoted too many times and I'm stick of re-inventing the server every year
so I'm sticking to Minecraft is a lego game and will be treated as such
so SMP with some roleplaying basically
also did some re-inventing with /home and /tpa
tpa stuff allows someone to automate the process of a teleport request. If you trust a player, they can just tp to you. No need to keep asking
can also just block others from asking to tp to you
or leave them on request only
yeah I was uh
working on basically a full-scale RPG overhaul with support for shit like Overwatch-style barriers and completely custom models + skins + animations for classes
i am genuinely not trying to one up anyone here, especially because i never finished it. it was such a pain in the ass lmao
kinda sad I came up with a name for this plugin long ago only for Intel to nick it for their GPU's
QoL feature go brr
me naming my skyblock core "SkyblockCore"
i'm surprised that's not in normal TPA plugins actually
qol goes a long way
chad straightforward naming sequence
oh wait I have something else neat
I think a huge part of why it's a pain is because everything is completely customizable
if you want you can just do vanilla+
or you can go full mmo
but that results in really stupid shit like uhh
best of luck with that. fr. Used to know someone on my server team who was building an rpg before they even joined. That was 2019, they've still not finished the damn map
rpg servers are pain
fortunately i have never tried to make one myself, this is purely the plugin
yeah you get stupid shit like this
which exists solely to let people configure conversions from vanilla damage to whatever damage system they have in place in a way that doesn't look insane in config
and then you end up with this massive setup lmfao
after 1.19 hit with the in-game reporting bs, I decided it was a good time to build my own chat
modules is literally just extra code the plugin can load for extra NPC behaviours/abilities/etc.
fun lol
huge brain tbh
unironically
does your plugin just yoink incoming chat messages and put them through a relay server somehow, or?
it yoinks them from the AsyncChatEvent
cancels the chat event
and sends them through the server
as if it's a server message
always think it's neat when a plugin just completely disregards spigot/minecraft conventions and does something else
can't report the server for cussing π
is that a workaround for the MS stuff?
kind of insane that they did that in the first place tbh
and yes there is a setting in spigot
to disable chat auth
but I'd rather not have it accidently turn on one day
Tbh Iβm surprised no public tpa plugins have a trust system
At least none that I know
right? it seems like common sense
i think this might actually be the same rpg plugin, but this gif is from like 2016
think I was 17 at the time so the code was awful though
basically gutted and rewrote it when I came back to it a few years back
Poor creepers
I still have no idea how the game actually orders entities
my intent was to pull a DVD screensaver and go back and forth across the center of the circle, but I did not have the know-how for that at the time
is it by UUID or something?
Chat bubbles are cool
yeah I was just about to say
it's like Habbo Hotel lol
this definitely goes beyond just chat formatting lmao
if you get that reference
or gmod
worlds online wants to know your location
nexpo did an excellent video about that one, actually
Source? Looks really cool.
the little blip sound for chat is a nice touch too
Should be a ghast scream
lmao
but I actually did lol
this is all custom coded by me
tis not on spigot anywhere
unless someone has hacked me for my source code
i thought about implementing DRM not because I care about piracy but just to be spiteful ngl
Quick someone steal his ideas and make them public!
and doing it in a way that makes it nearly impossible to disentangle it from the plugin code so someone can't just decompile and edit like one line of it lmao
fact of the matter is you could but like with many plugins, if it's premium, someone is going to buy it once, rip the drm out and post it on a certain cough other website that is a lot 'darker' in colour
Dark yellow spigot
Yeah, that's why you'd have to basically completely entangle it with the actual code itself
which
i can't even think of a way to do that offhand lmao
that's pain
me when my code runs on a 10 year old ARM processor but not my own CPU
You'll be able to mess with it on my server when my update is done lol
I need some leverage/reason for people to join heheh
we even have a block bank
:)
well, I guess having a plugin that's a pain in the ass to set up properly is another form of DRM
I was considering having the plugin .jar double as a config tool, tbh
but like
that's work
dunno if anyone's done that before, haven't seen it
the only 'good' way to have a plugin that cannot be pirated
is a plugin that makes calls to another server that actually has the code on it
the plugin you buy is a skeleton plugin
and needs a license key
yeah that's one way to go about it, i don't really know how feasible that would be for a particularly demanding plugin
for something with minimal throughput, though? for sure
the native/dll approach could actually work to some extent
use native code for anything related to actual performance and treat java as a glorified schema/config loader
What I'm working on atm, my own land claim plugin. Why? Lands is money and Grief prevention sucks ass
if auth fails then just have the dll break
Land claim plugins are a bloody rabbit hole of their own
reminds me
server I used to work on was gonna have like, a towns plugin
it's been two years and apparently the guy who was working on it hasn't finished it yet
have I finished my rpg plugin? no, but i also haven't touched it in 14 months.
lol
14? 16
I should attempt a land claim plugin. It'd probably pretty easy with the chunk pdc now.
oh yeah that was my other question, i just remembered
think again
All fun and games until you want non-chunk aligned claims
how feasible do y'all think it would be to write a plugin that's capable of creating artificial players that actually play the game
that's something beyond nightmarish
That's fine. There's ways around that.
there's a gmod addon that does this for gmod sandbox, it's what gave me the idea
yeah that's why almost every land claim plugin uses either perfect circles or chunks with no in-between
I'm demoing the cancellation of illegal power sources of redstone
majority are strictly chunk based
(from outside a claim)
government regulation plugin
π³
chunks are easy for efficient checking
instead of checking everytime player moves
or running logic when they move
just check if they've moved chunk
lot less calls
I can't imagine how much work would need to be done for a non chunk system that is easy to use.
At least chunk based systems are easy enough to make and gets the job done.
adding to this, i already have a prototyped statemachine-based AI system with custom behaviours
i don't think it'd be much of a stretch to use those behaviours to have an entity actually play the game, it'd just be tedious to work out what their goals should be (and I don't mean the built-in goal system)
depends on your claim format
circles are really easy to check
dispenser is weird
it fires but nothing comes out
which is fine I guess
it's also easy to check a regular quadrilateral for whether a specific tile falls into its boundaries
or any rectangular prism, if your claims work in 3 dimensions
if you want to start doing stuff like convex hull claims it's more complicated
each chunk I can check relative from 0,0 to 15,15
especially if you move into three dimensions
no dispenser cancel event?
that's what it is when it gets cancelled lol
weird that it still fires
probably just a spigot issue but if it isn't functionally firing that's fine ig
yeah no the item stays in
which is good
but it still makes a sound
fun thing about observers though
you have to check that the pulse they get is not from an illegally powered block
like say a noteblock
redstone would set off the noteblock which would set off the observer
redstone is outside the claim so it should be not allowed to power it
this is a headache
don't get me started on the bs with checking for entities landing, being thrown into or interacting in a claim
ender pearls, snow balls, eggs, boats, armour stands being pushed in etc.
on the bright side, my land claim plugin mechanic does have one thing that a lot of players will love
I dub it the YEET mechanic
you can YEET unwanted players out of your claimed area
automatically ofc
oh thsi reminds me
@wraith apex you might wanna check out some of the stuff Noita did for resource conservation per chunk
Yeet
oh? what did they do?
most relevant one is gonna be marking inactive chunks
and only reactivating them if anything happens in an adjacent chunk or something happens that affects the inactive chunk
noita's a bit different since it uses a cellular automata-based engine (it's a falling sand game)
but I employed something similar for a plugin I threw in with turrets
chunk grid is 2d, tbf
yeah it is
it's more so how fast can the server load a chunk
to let a projectile continue
prototyped this by basically flagging turrets as active/inactive based on nearby chunk activity since they do have their own update thread
seems to work
nah, more like
turrets aren't tied to anything specific, so by default they wouldn't care what the status of their current chunk is
their update logic is in the spigot thread
meaning that if a server has a thousand turrets, but only two people are online and so only like 50 of those turrets are actually active, all 1000 will still update every tick
not great
so it p much just cycles turrets into/out of an update pool based on which chunks are loaded
but i have no way to test this organically and I wrote the plugin itself in 30 minutes so
Great opportunity for a minigame here, Leaf spleef
mojang really added spleef blocks
invalidating the work of spleef devs everywhere by using some leaves
well not really, I'm just using them for that
spleaves, even
actually i'm curious, do they trigger events when that happens?
might want to check EntityChangeBlockEvent
and check the type if it's a drip leaf
so probably
unlike some plugin implementations of some other games, you can't cheat by being on the edge, it will depress
Hello! Im pretty new, and Ive been twisting my head on smn thats probably really simple. Does anyone know if there is a plugin (or how to make one) that will track the position (coordinates) of an arrow that is in flight? all i need is for it to track the position from when its fired to when it lands so i can then model it as a cuadratic equation (ive removed drag and randomness). Please ive been really stuck so any help is appreciated. Thanks!!
yeah it's not hard to make
declaration: package: org.bukkit.event.entity, class: ProjectileLaunchEvent
you'll want to listen to this event
tbh you don't really need to track the arrow, either
and then once you have it sample the x,y,z coords of the projectile as fast as you want (up to 20 per second)
you can just keep printing out the x,y,z values
possibly even the yaw and pitch
you can extrapolate the arrow's trajectory solely from the launch event given the direction and velocity
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
and the weirdly specific number of how much gravity affects arrows
hit event is when arrow/projectile has hit something so it will stop moving
^ this fires on hitting an entity or block btw
if you want the "real" trajectory of the arrow, then def use this too
I'm thinking these 2 events + a bukkit clock to sample the projectile
clock will start then the projectile is launched and it will stop when it hits something
you could also just use system time
which is TPS agnostic
I'm probably overthinking though
okay yeah arrows are subject to 20m/s^2 of downward acceleration due to gravity
that's some powerful gravity
I just mean the arrow is not going to move in less than a 20th of a second
oh yeah, it's not
since the server has to move the arrow :p
now, if you use my implementation, it will
xD
(don't use my implementation, it's bad for you)
my implementation basically raycasts
mmm raycasts
and wraps it up neatly
I love raycasts
default mc projectiles behave so badly on servers
ah yes the arrow comes up directly behind me, stops, I step to one side, and then it zooms past at mac 12 exploding an entire mountain before getting glitched in a mob
being on fire is basically free iframes
and because of how global no damage ticks are, well, global, you can't disable them without turning fire/lava into an instant death sentence lmao
i mean you can, but that requires some fuckery
better to just offload projectile hits to a more reliable method
I see no problem with getting instantly melted in lava
anyone else here really fucking hate the death event?
anyway, we're wildly off track, @full gull let us know if you need further assistance lmao
i hate it specifically because there's no kill event
death event does not even tell you WHO killed you
it just like you ded
suc it bruv
It does if youβre a player
it didn't for years
Since player has getKiller
aye aye but that's not intuitive
And yeah it still doesn't work for mobs, which makes pve-centric plugins kind of a pain still
I expect that to be in the event
^
the event itself I expect to have methods relating to what just happened
I p much just threw in a death event that fires when an entity takes fatal damage
bit dumb that's not already in, though
aye same
I also don't have any commands registered in the 'traditional' way
christ lol
are you an annotation mapper type
annotation-mapped commands are probably easiest honestly
<insert smug smile>
any idea why private static final World world = Bukkit.getWorld("world"); return null?
pros: it pretty much auto generates pretty help formats
cons: inheritance based
where's this being invoked?
@Command(name = "chatchannel",alias = {"cc"},description = "A command to change the channel you're talking in.")
public class ChatChannelCommand extends BaseExecutor
{
public ChatChannelCommand()
{
addSyntax("changeToGlobal",Sender.PLAYER,new ArgumentSet().of("global"));
addSyntax("changeToParty",Sender.PLAYER,new ArgumentSet().of("party"));
}
@Syntax(description = "Changes your chat channel to global",permission = "arc.command.chatchannel.change.global",syntax = "/chatchannel global",example = "/chatchannel global")
public void changeToGlobal(CommandSender sender,String[] args)
{
Player p = (Player) sender;
PlayerEntityDataKeys.CHAT_CHANNEL.set(p,PlayerEntityDataKeys.CHAT_CHANNEL.getDefaultValue());
PrintUtils.sendInfoMessage(p,"You are now talking in Global chat");
}
@Syntax(description = "Changes your chat channel to party (if you are in one)",permission = "arc.command.chatchannel.change.party",syntax = "/chatchannel party",example = "/chatchannel party")
public void changeToParty(CommandSender sender,String[] args)
{
Player p = (Player) sender;
if(((String) PlayerEntityDataKeys.PARTY.getValue(p)).equals(PlayerEntityDataKeys.PARTY.getDefaultValue())) { PrintUtils.sendMessage(p,"&cYou are not in a party!"); return; }
PlayerEntityDataKeys.CHAT_CHANNEL.set(p,"party");
PrintUtils.sendInfoMessage(p,"You are now talking in Party chat");
}
}
This is what a command from my system looks like
oh god the anno makes it look ugly af
After server load on playerjoinevent t.teleport new location...
yes
if you're calling this on STARTUP and not after the server has loaded the worlds then Bukkit is null
Bukkit does not get initialised until AFTER
You can set your plugin to only load after worlds have loaded iirc
It does by default
does it? mb, i'm rusty
or you can have a second init method that gets fired upon the event: ServerLoadEvent
But the plugin instance is created before
A more secure way of doing this would be to code around it
After... called in PlayerJoinEvent new Location(Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
yeah, something like that would be better
Should be fine if you set it in onEnable
can you paste the stacktrace? use hatebin or something
hahaha thank you very much. Honestly im really new to coding so most of what you guys said is too complex for me to interpret lmaoo. From what i did understand tho, id have to make the plugin run upon the arrow being shot (obviously), sample its coordinates (not sure how to do this part), and make it stop when it lands on a block
ah, so server is already on a player joined
Yeah - the issue is if you do it on load, iirc
i.e. a class level field
Mhm
Don't worry, most of what we said was tangentially related at best lmao
Do you have a world called 'world' ?
y
yes
p.getWorld return world but Bukkit.getWorld return null
Are you familiar with the concept of an event system? if not, it's p much what most plugins run on
also yeah if you're having code trouble, just paste your relevant code + stacktrace if applicable into hatebin or something
hastebin but angry
?paste
java.lang.IllegalArgumentException: location.world
World is null
world is not loaded then
Mine's a bit hideous, each command ends up in its own object
however, as a result of this, any plugin that uses my core library can have its command descriptions/permissions edited by server owners if necessary, which is nice
yeah it's just not loaded
ik but why.. π I tried add flat to plugin.yml about post load world but didnt work
I'm guessing world is not the main world then
yeah if you don't have a world named "world"
you have to tell bukkit to load additional worlds other than the main 3 it usually loads by default
the default world is world, but yeah if you're running like, multiverse, that won't be the case
anything that would interfere with that, basically
Arrow tracker
Even with multiverse the default world is world
Okk thx
Itβs only different if you change it in the server.properties
to load a world in code
new WorldCreator("world").createWorld();
this will load if the world already exists
Bukkit.loadWorld("world")
or create a new world if it does not
ah alright, mb
There is only Bukkit.unloadWorld()
I have a new parser where I can have arguments of what the player typed in-game casted and presented in a method neatly in any order I wish!
@Path(name = "mapped args",description = "A test for mapped args",syntax = "/test mappedArgs <material> <amount> <message> <say message>",usage = "/test mappedArgs sand 5 \"Hi there\" true")
public boolean mapArgs(Player p,@Mapped("sayMsg") boolean say,@Mapped("amount") int a,@Mapped("mat") Material m,@Mapped("msg") String s)
{
PrintUtils.sendMessage(p,"Aye!");
PrintUtils.sendMessage(p,"Material: " + m.toString());
PrintUtils.sendMessage(p,"Amount: " + a);
PrintUtils.sendMessage(p,"Message: " + s);
PrintUtils.sendMessage(p,"Say: " + say);
return true;
}
ew
in the constructor I have
public TestCommand() throws MissingAnnotationException
{
super(TestCommand.class);
addPath("mapped args",CmdSender.PLAYER,
new ArgSet()
.of("mappedArgs")
.of("<material>",ArgTypes.MATERIAL,Suggestions.minecraftMaterials()).map("mat")
.of("<amount>",ArgTypes.INT).map("amount")
.of("<message>",ArgTypes.STRING).map("msg")
.of("<say message>",ArgTypes.BOOLEAN).map("sayMsg"));
}
:)
does it auto generate tab complete?
ye
cool
so how do you input arguments?
those 2 arguments I assume you need to create in advance?
Ah ok
Is that hardcoded to the last arg
uhh
Or does CommandContext have a stack
it's like a mutable thing
Because some arguments need others I build from start -> finish
So /test 123 abc 456
makes a mutable command context with full input as "test 123 abc 456" and then I parse each node with "last input" being the word I'm parsing
So the later nodes have context of the early nodes
under a single object
bit messy
bro thanking a month old post
next time just ask for it again
data watchers are simple
yeah 1.19 changed stuff
Protocollib sending packets is so jank
Compared to just NMS
Yes I know it needs to be version independent
oh that's nice, I'd be worried about parsing for when a command takes multiple arguments of the same type
uhh it's picky
you need to send entity metadata once
to define the item in the itemframe
that's why they have a mapping name
All following packets are just map packets
re-use the map id
yada yada
updating the map's content
you need to toss a map itemstack with the map id in the meta
json object
bro thinks a json object is going to solve all his life's problems
bro can't think of a good alternative
you can make a map view with bukkit
json object is basically a map anyway
and set the view on the map meta
can turn it into a string

we're talking about
like
actual map items
not a Map<?, ?>
oh

toss it in a json object
can we toss you in a json object?
StackOverflow eh?
sigh
Let's recap
-
Create a map view
(Contains map id, all that stuff) -
Create a map itemstack
-
Set the map view in the mapmeta
-
Create an entity metadata packet for your fake item frame
-
Set the item frame's contents as the map itemstack
-
Send a map packet with the id of your mapview, and whatever colors
there
here's an old impl I did
uses nms, I can't be bothered
sleep time
btw ty @wraith apex for the help!
should I make eventhandlers private methods
No
why not?
method identity must match
I don't exactly want people to be calling these methods instead of using the plugin manager
hmm?
Spigot will look for a public method annotated as an event handler
well that brings me back to here
and it just seems odd having those methods publicly available
has to be pubic and accept one of the event args
Hey so I am trying to setup Unit tests for Spigot 1.20 using MockBukkit and I am getting this issue when trying to test my getters Cannot access com.sk89q.worldguard.bukkit.WorldGuardPlugin
any idea why? not used Junit or MockBukkit in ages lol
Assertions.assertNotNull(plugin.getWorldGuard());
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.9' in my gradle
oh I see compileOnly is the issue
Maven
i need madle
I'm trying to create a custom mob and I've reached an issue where I can't use this.setCustomName() since it requires a Component, I tried using TextComponent
this.setCustomName(new TextComponent(ChatColor.GREEN + "MyEntity"));
But that didn't work it said needing (Component) not (TextComponent) I tried casting Component to it but that also didn't work
isnt there Component#text ?
I tried that, didn't find it
I'm just using spigot
I'm extending the Sheep class from net.minecraft.world.entity.animal.Sheep
No
are u using the right text component
what version ru even working with
There's only 1 that I can use
1.20
net.md_5.bungee.api.chat.TextComponent The only TextComponent I can use
does ChatComponentText exist?
I can't find any other that I can import
Nope, I was first looking for that
And what type of component is the method asking for?
Just Component
Also from md5?
net.minecraft.network.chat.Component
Bruh
net.minecraft.network.chat has no importable TextComponent
nor does it have ChatComponentText
Sheep#setCustomName
nms?
mojang remapping
so nms
yes
well I don't work with nms often
but why don't you use spigot api to change the name of the mob?
^
How would I do that?
entity. setCustomName()
Alright I'll attempt that
and entity. setCustomNameVisible(true)
I did that using Sheep#setCustomNameVisible I just didn't expect Sheep#setCustomName to be such a roadblock
I also found a resource that says TextComponent should be an import from net.minecraft.network.chat.TextComponent which is why I'm confused how I'm missing it
TextComponent. fromLegacyText()
not a function, the only one similar is toLegacyText which returns a String
also I think I found a fix
Component.literal(String)
So I'll leave it here incase anyone else faces that issue
okay
can I use my api in another project via projectSettings -> models - Dependencies so that there is NO dependence on the location of the api on the PC?
or is the only way to use maven?
can you clarify what you mean?
I think you are confusing two different build systems that your IDE lets you use?
The location of the dependency is always a factor regardless of the build method used. Maven just handles this for you by making use of maven stuff
the build system your IDE most likely has built in that isn't maven is ANT
i want add api for my plugin
but but not using maven
add in local
or how this say
ANT is more basic and requires you to fill in more details manually that maven would do at times automatically. Such as specifying the location of the dependency
I heard about 2 ways to add a dependency so I wanted to use method 2
load jar
or how this saying
the easiest method to add an API into a project using ANT is to simply copy the sources for said api into the project under its own directory AKA package
Sorry to ask, but why not
the other method is just ensuring the API is present in the same location as the plugin, meaning the plugin directory for the server
but as the above, I was going to recommend to just continue using maven as its just easier and really not much of a reason to avoid it unless you want to use gradle. ANT doesn't provide many things and isn't always easy to use without issues unless you know what you are doing. This is why things like maven and gradle came about
when I try to add a dependency through models in settings api becomes location dependent and I canβt use it on another PC
the same will happen with maven and gradle if the API isn't accessible in a repository that the other PC has access to
so that means if the API is only in a local repository, you will get the same problem
InventoryCloseEvent : the item that is on the Courser will be removed no matter what i do is there a fix for it
best option is to make use of the windows file sharing or linux which ever you are using, and just transfer the api to that other pc
wait, if maven has the same problem, then using the api will depend on whether the server is connected to the Internet or not?
optionally you could run a small http server to make your local repo accessible for those other pc's
well since you are referring to another pc, I assume its a pc in your home network
it would depend on whether the pc has appropriate connections to the other PC
but server can be localhost
in
if server in local host then how my project can search repository in internet
the server has a built in lookup that looks to maven central for dependencies
if the dependency is not found on maven central it will fail, so it doesn't work for all dependencies
so this system use pc for coonect with site?
well of course, that is how connections work in regards to software it isn't going to manifest its own system you know lol
so a localhost only pc that has no connection to the internet, it will obviously fail
are you afraid of maven or smth?
so if i disconnect internen in my pc plugin not found repository
you just update your project once you filled in maven stuff
that isn't their issue
and then you can plug off the internet cable
wdym "you just update your project once you filled in maven stuff"
well for the server to find the dependency on maven central, it would need internet access, otherwise as I said it will fail. However, it will still fail if the depenency is not on maven central to begin with.
fill pom.xml with data -> update dependencies -> dependency is installed locally now and you can use it even without internet access
this is why many projects still provide the repositories or links for dependencies their projects require
because not all projects submit their stuff to be on maven central
model in project setting work same?
idk which ide are you working in
intelji
this isn't going to work unless the dependency in question is accessible in a repository. So that means for your own projects between 2 pc's this isn't going to work without some additional setup being needed
Well, judging by the attempt, it doesnβt work that way
i mean you can depend on WG or spigot-api
that way
sure because they have repositories that are accessible
yeah ofc
Isnβt it possible to add a dependency so that it looks for api in the plugins folder on any PC?
but 2 pcs on your home network though to have one that has the dependency the other not, this won't work and will not magically make your dependency move to the other pc π
but after you do maven update you can work with that stuff even offline
that's what i'm trying to say
can't you just depend on .jar tho?
i mean it was possible in eclipse, at least
this is default behavior of java. The first thing java will do when a jar has dependencies not in the jar, it will look in the directory the jar is in. But you will still need to provide a way for someone to have that dependency
Install the dependency plugin on their server?)
@upper hazel what exactly are you trying to achieve?
settings-> models-> dependency not work so ?
look - https://youtu.be/r7x4XRQsD6k?si=feIEuvtNH4NZJ9vI it adds a dependency not using maven and it won't work on another PC right?
Love the video or need more help...or maybe both?
π¬Join us on Discord: http://discord.gg/invite/fw5cKM3
Thank you for tuning in to this episode of TheSourceCode! β€οΈ
If you enjoyed this video make sure to show your support by liking , commenting your thoughts, and sharing for all your friends to see and learn!
All code is available on Github:
...
wdym on other pc
other server
you need the same jar to be on another pc too
you just install the plugin you depend on
on this server
and it just worksβ’οΈ
- You have Plugin1 with API
- You have Plugin2
- You add Plugin1 as dependency to Plugin2
- You code stuff
- You install both Plugin1 and Plugin2 on the server's
pluginsfolder - You run the server
- KA-BOOM
api depends on its location, you confirmed this
he not use maven
so this not will worked if another person want use api
I thought you want to code on 2 different computers, not use plugins on a server
Most IDE's for java or at least the common ones that are used, use ANT as the default builder if you don't specify maven to be used. I already stated this some time earlier. It just isn't obvious that is what is being used by the IDE
however for a project that dependends on something built this way, requires that dependency to also be present on another system for it to work
its not magic
the exception to this, is if said dependency is on maven central
because the modern spigot servers will look to maven central for dependencies
and if it finds it, will auto download it
the build system only matters for building btw. The build systems have nothing to do with the jar running afterwards
^
so that means you can build with ANT, and the server still pull a dependency from maven central
even though maven wasn't used to build it to begin with
so If I add an api like in the video, will other users be able to use the api?
they would need your API to be installed on their server
as a plugin
with implements JavaPlugin shit
so you would need to provide some way for them to obtain the API to put it on their server. This is how we get maven repositories for projects existing primarily for developers to use, and other methods for users π
I feel we are making progress in clearing this confusion of theirs
@upper hazel look at Vault plugin
it's useless by itself
but lots of plugins depend on it
it's just an API plugin
and its provided by both spigot site and has a maven repo
and well, you can still depend on it manually
yeah you can do that too lol
but guys who use your plugin would need to install Vault by themselves from spigotmc website and put it to the plugins folder
so well, you can also post your API plugin on spigotmc and tell people to download it if they want your plugins to work
but bruh
ahh now I understand. In order for another user to use the api, he needs a repository on my PC to access the api, and maven solves this by using the Internet available to everyone
this is true?
if so, then a good addition for the spigot server would be to search for the api in the same folder as the api itself
almost correct. They need someway to download it. This is where spigot site comes in, where users could download it. Or you can provide alternative means for them to get it. Maven repos is a way but this method is typically used for developers when building their plugins so they don't have to go to something like the spigot site and download the api and then manually attach it to their project. Maven is where this comes in doing that for you if a maven repo is available for them to specify
why shouldn't the plugin use the API artifact itself in the server folder, then Maven is not particularly needed in this case
just search him in plugins
derictory
or he do this?
if the timings system is turned off does that mean I cannot use bukkit runnables?
if this true then repository not need bc plugin just can search him in plugins derictory
But u havr no performance insight
but in fact you can use the api for example like this βBukkit.getPluginβ without using the repository in maven
or I'm wrong
i was not use it but think obaut this
i mean a repository in maven only saves us from a lot of lines of code, no?
You need something to compile against
If you plan on using code from some other project it needs to be added as a dependency in maven
hey what mean this error 0.9/worldguard-core-7.0.9.jar(/com/sk89q/worldguard/protection/flags/Flag.class)
[ERROR] class file has wrong version 61.0, should be 54.0
has to do with the java version. The java version you are using is too old for the version of worldguard was compiled against
I was trying hard not to π
either use an older worldguard version or upgrade your java version
54 refers to java version 10
61 is java 17
Dont shade worldguard core into your plugin.
hey, I'm developing a plugin for my friend to run a script, but when the path contains a space it breaks and since all my servers are in a directory called "minecraft servers" I can't really test it and I also don't wanna rename the folder
can you translate what that's saying lmao
it switches to german halfway through
is it saying it can't find the path or
don't need to know german to figure this out
i don't know what exactly the error is
you can circumvent that by just wrapping the arg in quotation marks
I'm not sure if the output is printing it in quotes because of formatting or because that's how the arg is being parsed, but I guess it's the former
"the command "C:/Users/andre/minecraft" could not be found"
command.add("\"" + runetimeCommand + "\"");
^ yeah p much, or you can use string.insert or whatever if you're weird
ah
oh, that's weird
indeed it is
I wonder if cmd is executing as the command is pasted?
this is probably some weird edge case shit
sounds like shit
hold up
I'd print runtimeCommand
try not adding the quotes
just before you add it
does it work then?
yeah could try that
that's how it has been initially
quotes are all fine and dandy when typing the command but it's running through an API here so
then it didn't work, I tried adding quotes
hmm, okay
can you print out 'runtimeCommand' before you add it to command?
seems fine
weird stuff
I guess further debugging is trying hard-coded file paths and see what works and what does not
Just add escaped quotation marks
we already tried that
What was the exception on that?
there is none
you get this
so, I tried this now and now it just can't find the file (plugins\ScriptRunnerMC\runtime\node.exe) which exists
node modules
my friend wants to run his djs bot on a mc server
it's by default in the node binaries zip
my friends exist too btw
and you're not helping fix the problem, why criticize a choice I didn't even make
wdym
Try preppending your program with another backslash
\runtime instead of runtime
Is that the correct path to the file
Is it maybe confused because itβs trying to run βruntime/node.exeβ instead of just βnode.exeβ
I tried running it through powershell and git bash and it worked like that
if it's because a backslash I'll
idk what I will do
- cmd -> full path to node binary
- cmd -> full path to script
*Or relative when setting the folder
You need to specify the full path to the file including the extension on windows.
Not quite sure why the string isn't allowing spaces though. Might want to stick with non spaced folders for the time being.
Generally good advice to begin with anyways lol
The thing is, before I run node I have a check to make sure the script and the runtime exists and both of them pass, but once I try to run stuff, it doesn't run
Didn't linux used to absolutely hate spaces
I think yes
Command Prompt and Powershell are not consistent for some reason.
I think you can get away with more in CMD, but usually you only need to encapuslate the path in strings if your path contains a folder with a space.
I think in some cases it wants you to surround only the folder in the path with quotes.
Β―_(γ)_/Β―
im having again an error for Caused by: java.lang.NoClassDefFoundError: while the class it's from the own plugin.
Any thoughts why this is happening?
Send the entire error
?paste
instead of slashes we used File.seperator
so it would use whatever the OS used for seperating files/folders in a path
probably the wrong place for paper stuff
Gotta love when people say this and then self report themselves using paper methods.
the server is working fine
Probably an error in your class static initialization or static Field
wdym?
what paper method am i using?
both classes have no static
then repeat the error using a Spigot server
it's hard to repeat error since it happens randomly and rarely
out of nowhere classes cant be found
yeah I've seen the error from one other Dev
You got some weird java install?
Repeat it on Spigot
Imagine if the gc was an ai: "this mfs code is so bad I'm gonna take out all of his garbage classes once an instance is created"
Do you stop and restart your server for every new build or are you doing a /reload or using something like plugman to reload the server inbetween new builds?
GC knows all. Don't question it.
I restart all the time
aight
is your cmdHome.java:39 fetching a null value for HomeDataBase?
and it works fine at first, then later some class disappears
HomeDatabase is a class that then gets the data for the players home
Thats not an answer to my question
the problem there is that the HomeDatabase can't be found when it's a class on the plugin
Do you have any logic that mucks around with URLClassLoaders? or really class loaders in general?
yesterday i got the same issue for another class
idk what you mean by this
I was having this issue yesterday, ended up fixing something else and hoping it fixed the issue. Ain't got no idea if it fixed it kekw
I mean do you have logic that involves the loading of classes or any custom url class loaders e.g:
Class<?> someClass = Class.forName("net.something.blah.Kek");
no
and your plugin the only plugin
This was a discussion on your exact issue <#help-development message>
in the server
I think they were also using a paper server in that discussion.
And they behave fine?
Well I'd start eliminating variables, remove all plugins apart from your own
Their pastes showed spigot but I dounbted it
every plugin seems to be fine yes
only mine is giving this error
this are the plugins
Moterious was teh exact same error but he was also messing with the logger which could be been an issue
I can only assume classpath is faulty
weird cause its a class from the plugin π
if the classpath was wrong, it wouldnt be working either on the import part and the plugin would be giving me a lot of reds
But you say it happens rarely
its not the classpath
I thought by our conventions we don't name the main class Main
nah the IDE and the compiler are different
IDE will show squiggles as a static evaluation of the code
this really adds a lot of explanation to the conversation
it may be there and it may be showing perfectly fine
I will change the main class to other thing, surely it will fix the issue πΌ
Well, who knows, I've heard of one case where the name of some class was an issue
if it was an actual issue with classpath/manifest.mf it would error every time, not randomly
how come the Main class name would affect ClassNotFound for other classes?
a dumb fix for this I've found is copying the code somewhere, deleting the class file, re-creating a new class file with the same name and then copying the code back in
i feel like you're just wasting conversation space here π
I have no idea, but this is java
the thing is when server starts everything works fine
as I said, repeat the error on Spigot and come back. You are on Paper and I suspect the other dev was also.
if i restart, the the class will suddenly work fine
and then later into the server, some other class will disappear
at least thats what has happened
weird tho, cause then other plugins would also break
at this point I'd have to agree with Elgar, try running it on a spigot server
Theres obviously a specific set of variables required to trigger it
not a paper one
Is your plugin depending on those other ones?
nope
for a plugin to loose a classpath midway through is odd
my plugin only uses spigot-api and "spigot remapped" stuff
doesn't matter
Ok? Paper server isn't spigot.
the server is what is running the code
that error is generally due to a Statc intializer/Fied error when instancing the class, or a caught exception being hidden.
paper makes many alterations to the implementation
Their most recent ones including changes to plugin loading.
run the plugin on a spigot server
this will be so annoying
cause even if i open a spigot server, it only happens randomly after a while and seems after many things have been done on the server...
Β―_(γ)_/Β―
Then do many things and let it happen
We can't really do a whole lot then
yeah i will try
but yesterday for example there was 10 people playing and running commands
and everythign worked fine
now i restarted like an hour and its just us 3 on the server, barely did much
and it happened
πͺ
just change teh server jar for a day to spigot
Spigot is more laggy tho, is there a guide to follow to make it less laggy like paper?
this is just for testing
Do you want to fix your issue or just complain?
don;t change anything other than the server jar
or what's the reason for paper to work so much "better" than spigot for servers?
i mean i will try stuff, but im curious on the difference between paper and spigot servers
paper changes how some of underlying implementation for some operations on spigot work to make them either more memory efficient or use less cpu cycles
Didnt read everything but such an error can occur when code inside a static class initialization throws an exception
Show us some code
^
Was mentioned but they claim they don't have any static blocks. :p
Line 39 of cmdHome:
HomeDatabase db = new HomeDatabase(p);```
code for HomeDatabase:
```java
public HomeDatabase(Player p) {
this.p = p;
}```
