#help-development
1 messages · Page 1371 of 1
I use it for parallelism
added a shutdown hook to save recorded data as csv
filters out everything I don't want
it's great
pog
Hey guys this might be a stupid question but I genuinely am not sure. I have heard the term server core being tossed around when talking about servers and plugins what exactly is the core? Is it just one big plugin with the main parts of the server? Like would I create the main functionality of the server in one big plugin or should I stick to separate jar files for each part?
Modularity is always best than singularity
It's better to have multiple little plugins, than a massive one that does everything (imo)
woopsie
I mean if you're given the chance to only use one plugin that could be somewhat more optimized. (Negligible)
However it comes with a cost
So would the core just be small things like command aliases, ban management and other small main parts?
When you wanna update, you'd have to update the entire jar each time
which comes with other drawbacks
Yeah, that's the major down of singularity
hey is there any way to make a plugin loader? as in you have a config.yml and in it you say true to a line and on startup it downloads that plugin
The core could be an api that most of your plugins rely on for example
If you split it up, you could easily swap smaller modules allowing you to work efficiently even with multiple devs concurrently
But it may be cumbersome to switch project window assuming you're working on many modules in a short period of time (For IntelliJ this is a problem I've experienced)
That's one of the reason I stick with Eclipse
So annoying to deal with it on Intellij
yeah I actually use Eclipse sometimes for that very reason
looks fine to me>
looks like a mess to me lol
Yep that’s what it looks like
hey is there any way to make a plugin loader? if yes is there anyone that could show/tell me how?
You can load and enable any plugin you want with the methods in PluginManager
i meant download a plugin from lets say a web page
oh
Sure. You have a full blown programming language and spigots plugin loader. You can just download a plugin from the web and enable it.
You can even download dependencies of your own plugin on runtime.
How would I do that? Im pretty new to this sorry
can you explain more what you want
@lost matrix I dont think hes talking about coding a spigot plugin at all
Im trying to make a plugin that downloads one of my plugins from a website. Im thinking to have a config.yml with option of which plugins you can enable, in onEnable have a if statment to check which ones are enabled. Each one has a link (option) and it downloads from that
yeah its possible. Just send a request to the download link get the inputstream save the file to plugins folder.
np
Ah ok. Downloading a file from an url is quite easy. You can use Javas IO, NIO or even an external library for that. If you want something Netty based then i would recommend AsyncHttpClient.
Apache commons probably has something for that too actually...
2nd question, how would I download it to the plugins folder?
You can just open an InputStream from any URL that points to the target file and download it.
I just used FileUtils.copyURLToFile(new URL(args[2]), pluginCache);
wait so I put that it and it downloads to plugin folder or am i completely missing the point?
Well you need to modify the args but yes you can use that to download a file to a folder.
ok this may sound VERY odd but is there a plugin that when someone types a certain command it dupes ther whole inv i want to run like a 2b2t practice anarchy server so people dont have to worry about losing armour and such any help would be appreciated in finding or even making one
ping me
how would i spawn lightning that doesnt harm a player at a location?
World.strikeLightningEffect
guys is it safe to read from a treemap async? like from 2 threads at once (assuming no writing)
im pretty sure it is but i could f*** stuff up if im wrong LOL
@arctic summit read the doc splease
declaration: package: org.bukkit, interface: World
"Strikes lightning at the given Location without doing damage"
ok sorry
reeeeeeeeeeee
how can I convert a string into a PermissionAttachment?
not hard to do if you wanna learn programming
just iterate over their inventory and drop them as items
wait i think i have code for that
anyone know what the best way to store data inside mysql for a server? since there's a table then there's values, and it would be easy to create an element of a player's uuid as the primary key each time, what would be the way to store server data such as the most amount of ppl on at a time, spawn location, etc.?
no lol, im actually working on sql storage myself rn ._. dont use uuid as primary key
not talking about that but why?
its slow, im using ints
dm? so i get pinged automaticly
@karmic grove here's some code
for(ItemStack is : p.getInventory().getStorageContents()){
Item i = w.spawn(ploc, Item.class);
i.setItemStack(is);
}```
just ask here lol
#1 just think about it lol, long strings take longer to compare than simple ints
#2 i keep a local cache of database id's mapped to uuid's (and vice versa)
most likely theres some command with a guide here
Check the docs for Creeper, should be obvious
well im looking at the intellisense, nothing there
after that what do i do to give it to them lol
also can it be a command like /dupe
I can’t imagine it’s that big a difference
#1 computers r very very fast, especially ones with a top tier cpu (such as my rig) and nvme
#2 cache = memory
that drops the items as items on the ground @karmic grove
if they have space, it goes into their inventory
there's nothing wrong with keeping a cache, if anything ima try to create a cache of data instead of constantly accessing the database
ok um i never made a plugin in my life do i just copy code then save it as a java file or ... LOL sry
ehhh well idk man, could be simply a choice of speed vs. memory. and yes computers r fast but ints r still faster xD
java first?
lmao yea i feel u but ig it's up to the person
i cant tell u how much faster doe, maybe i'll run some tests at some point now im curious lol
@solemn shoal weird, open a feature reuqest
i sorta have some bad code causing memory usage to build up and blah
wdym java forst
learn java first before using the spigot api
where can i open feature requests?
or, any sort of programming because "saving as a java file" just ain't it
nvm the jira exists
i just wanted to know if a plugin existed lol
anyone know
python intensifies
i mean yea u need at least a decent foundation in programming, not necessarily java
oh LOL
ur in #help-development
also @sullen marlin is it possible to change my name on the spigot site?
pony up
aight how much
$350 i dm u bitcoin addy to send to
aight
damn ;-; if i knew itd be taht ez id actually hav a btc account ready LOL
i could ahv tree fiddy rn fml
xxxDDDDDDD
:I
nvm spigotplugins is plugin support
is there a way for me to set an entire row to a certain item when making a gui?
iterate over all the slots
?
package index
Is there a simpler way to do that?
for (int slot = 0; slot < gui.getSize(); slot++) {
if (i < 9) {
gui.setItem(slot, ItemStack);
}
}
ok
that sets 0-8, the first row to ItemStack
which you'll need to define
make sense?
ye athanks
but where is i defined? @rugged topaz
slot*
i'm pretty sure you could realize that yourself
yea i did lol
also wouldnt it be better to do java for (int slot = 0; slot < 9; slot++) { gui.setItem(slot,ItemStack); }
well yes i knew but i thought id point it out
sure, less of a loop, but if he wants to set multiple rows
for (int slot = 0; slot < gui.getSize(); slot++) {
if (i < 9) {
gui.setItem(slot, ItemStack);
}
if (i > 17 && i < 26) {
gui.setItem(slot, ItemStack);
}
}
and so on
this would set the top row and the bottom row, right?
1st and 3rd
k thx
if you changed the 9 to 10 and the 17 to 16 itd fill the left and right in the middle row too
idek what that means
If you wanna make it easier, use slot % 9 to get the column (vertically) and slot / 9 to get the row (horizontally)
tfw math
lol
seems simpeler but doesn't the % operator get remainders?
% means modulo
o
i used it once to detect for even numbers
An example for columns would be btw:
for (int slot = 0; slot < inventorySize; slot++) {
if (slot % 9 == 0) {
// TODO: 4/10/21 set the slot with your item
}
}
don't tell me you got ur rank from mineplex
Because the mod will be 0 if u devide even number by 2
divide* but yes
i didn't pass englis either
y
because i moved to gradle
o
anyways, now to make a jar...
well i found one way to make a jar..
zip up bin folder
is there such an event that gets called when a compass points at somewhere?
theres compass.setLoc
package index
ik
Runnable is your best bet
if you want to change it periodically
or just have a runnable until it points in a direction
yeshi
i'm placing an armorstand above a player as a "status" with a custom name, and it moves per tick (also tried playermoveevent) but, it's off, either delayed (or too early?) ik there's no way to perfect things faster than a tick but i've seen many servers pull off perfect and accurate movement, any idea?
it's just like a second nametag
ye ik
I'm not too sure, I usually use hologram API for something like this not exactly but it was flush
hm
holographic displays?
time for pain
I'll see if I can find some of my old code but I'm on mobile rn
my armor stands lag behind a shit ton as well lol
hypixel does it
idk if thats just the nature of armor stands or smth
if anyone's seen that here
why do you have two print statements
Bukkit.getScheduler().scheduleAsyncRepeatingTask(instance, () -> {
status.teleport(p.getLocation().add(0, 2.35, 0));
}, 1, 1);
``` 🤷
try it without async
tried both
dang
tried repeatingtask, tried event
tried spamming several instances of both
repeating tasks, and events
^ it was closer with that lamo but
something seems odd here
anyone here have gradle experience?
minecraft has a really dumb method of storing its tick times imo
its just an array of long's
:bruh:
and it overwrites one value accorrding to a modulo
ticks is private btw so i cant even get it without reflection
what is the material type for a water bottle
you've become the very thing you swore to expose
hm?
@quaint mantle do you know the material type for a water bottle
how do you mean
Water bottle? GLASS_BOTTLE ?
ik
There are no water bottles in MC
but how do I check if there is water in the bottle
idk
Material.POTION
its drinkable, so are potions
ok but then how do i check if that potion is water
ok, and this might sound stupid but how would I check for an awquard potion
lol
ok
i am not your dad
this is how i test my plugin no joke
@solemn shoal you know what they say
If Iooks stupid but it works, it ain’t stupid
I still have to actually learn maven
zipped up the net folder, added plugin.yml
fair enough
renamed to .jar
renamed to jar
what's to learn about maven? you just choose it in intelij setup and then double clik on package
You poor soul
I’ve probably wasted 5 hours by just avoiding the problem and copy pasting rather than properly learning it
i migrated from apache ant a few days ago
well a few days
last week
only got it biulding today
i have a 65 line gradle file
20 lines
running shadowJar gives me a 261 byte file
Probably isn’t ideal but it works
i might just make it download 7z and build the jar thru cli commands
there we go
smooth as butter
PotionMeta I believe
ok
and then from the meta get the type
not working (bottleVal is the item stack)
oh
nvm hold on
.get potion meta isn't a thing either
Cast it
says ```Condition '!damageMap.containsKey(event.getItem())' is always 'true'
don't get it
am i too dumb rn?
or just have to ignore it
its like paradox lol
nvm i'm dumb i guess
yeah forget about it, figured it out lol
ide?
curious
themed intellij?
intellij with material theme, yeah
How do i set a potion type?
k
cant potions have multiple potion effects tho?
no a potion like item
^
he has a dog on his pfp, so he's always right
ik
i wish i could change my name on spigot lol
is that a dog? to small to see instantly
i havent used this name in YEARS
Map<ItemStack, Integer> damageMap = new HashMap<>();
damageMap.put(event.getItem(), damageMap.getOrDefault(event.getItem(), 0) + 1);
Different way of doing it, will silence it prob
donate
figured it out already lol. everytime on event-call i created that new hashmap
oh yeah that'll be it lol
none of those do set potion type
so obv it's always false
adCustomEffect
doubt
setBasePotionData sets the main effect iirc
ok
donating 5€ (or whatever your currency is) is enough i believe
and it's definitely worth it
are there like, actual docs on this? lol
changing your spigot username lol
well they say you have to donate to change it...
oh wait
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
its right there
Probably being dumb but...
lol
also its 10$
what is potiondata
it just takes the data...
not a potionType
ok
so then how do I set the type?
money doesnt grow on trees, yeah
ik
i have to live to end of month with like 60€
i feel you my man xd
well i'd say lets see how it goes
Ramen exists
if i die, it happened lol
true
i get 150-200/month
i'm probably being stupid but how would I set the potion type
keep in mind that includes food, netflix for the family etc
like, i dont have spare lol
Once again, Ramen
well i dont have school now because vacation so food doesnt count
what vacation?
meta.setBasePotionData(new PotionData(PotionType.AWKWARD));```
personal or is it a big holdiay
big holiday
thx
oh
where do u live (country)
ah
ohh hello my neighbor :)
where do u live, Rivex?
germany lol
country with almost worst internet
been there once
what's ur speed
i get 250 down and like 10 up
on paper, or really? xd
but that's on cable line
i get 140 down 7 up on cable
deecent
onece we ditched stupid at&t it was much better
and i need my fucking upload
i mean, at least its stable
Guess ur not gonna be a youtuber anytime soon
my internet is so unstable, cant even host discord bots properly
big files
That's sad
ah f
i can watch 4k videos
i used to host mc servers on my home connection
i do that rn
How can I set the animation state of a Double-Chest to closed? I've got a PlayerInteractEvent that opens its inventory, but it stays open perpetually. trying to close() both chests doesn't help.
Single chests work as expected.
//If that block is a Chest
if(Attached.getState() instanceof Chest) {
//Open the inventory
Chest c = (Chest)Attached.getState();
Inventory i = c.getInventory();
p.openInventory(i);
if(i instanceof DoubleChestInventory) {
DoubleChestInventory dci = (DoubleChestInventory)i;
((Chest)dci.getHolder().getLeftSide()).close();
((Chest)dci.getHolder().getRightSide()).close();
}
c.close();
c.update(true);
}
double-chests are dumb to work with
people timing out left n right
i guess my internet is enough for vc, thats it
now my server is hosted in the US and sometimes my ping jumps to 7000+ ms
1080p discord-live is lagging like hell
because company server
oh
well "company"
he's a big guy lol
no?
How do u need 32 gigs
then nvm
is that a mc server
Why does it need 32 gigs
yeah
not me lol
Large amounts of RAM may actually slow down GC
then my mistake, looked like it
oh so u have like a big server
im using aikar's flags
But I imagine java has been optimized better for that now
xd
No dip u have a minecraft server ur in spigot debug 🤦♂️
yea I have one for my friends too
they are pains
still wondering that 2 players can lag my server to hell, just with chunk loading
I host for free and then they're always like CHANGE THE WORLD
ummm
did remote viewer break?
That is the optimal setup for a minecraft server
ssd or hdd?
nvme ssd
That’s a decent deal though
yeah, its offsite
y do u need a ryzen 9 for mc?
Lol u want rams not cpus
check cpu usage
The problem I’ve had with shared hosting is moving files around to change mods/version/etc
for 2 players? please
That and my terrible upload speed
Not a virus.jar
lol jk
regardless, it has a command (/stats)
i guess 8gb of ram should be far more than enough for 2-5 players
5 at really maximum
obviously, shows stats lol
that is a huge screen hogger
oh nvm
considering i play with gui scale set to 2
eww
at 1080p lol
i mean
i have mine at 3
it IS a toggle
this is mine
guess thats auto? so maximum
Then yeah it’s probably useful
idk I get used to it
i mean it doesnt show when you initially join
you have a 4k or just very small gui
i have 1080p
1 pixel per item
no?
im kidding
dafuq
hm?
just small
i send you mine, gimme a sec
thats mine
lol
that's what she said
regardless
F
gottem
use my plugin if u wanna check cpu
lol
can any1 recommend me a staff plugin?
how do you mean a staff plugin
Just something i can use to manage bans and that kinda thing, maybe staff chat too
Thank you!
i mean, managing bans isnt that hard with vanilla commands
tho idk if it does timed bans, if you need that i'd say get essentials
Vanilla does not
however that comes with a lot of other stuff such as /home, /warp, /vanish etc
ree i have to rewrite my fast xp pickup thing to support mending
whats the best way to make a custom item work with say a kits plugin?
wdym with custom item?
like a stick with name/lore that would do something special
should work like a normal item lol
i guess just have the put the name/lore in manually
why that? dont know exactly what you wanna do lol.
your custom item has the same base as a vanilla material.
so it uses your custom name/lore/whatever
except youre doing some weird stuff
Yeah I know my question was bad i don't even have a custom item
just was thinking about this
well i would say then, use an item builder to create and set that item, so it has the same lore and name as every other one
sorry that question was dumb heres a better one unrelated
is there a way to add a non visible identifier to an item
so does this no longer work in 1.16? specifically the getTitle
if(event.getClickedInventory().getTitle().equalsIgnoreCase());
Edit: nvm figured it out.
Yes, PersistentDataContainer
Anyone know what this could mean? It happens every time I refil a water bottel
Something is null at that line
does it say the line?
My plugin doesn't do anything when it comes to refilling water bottles
Yes it does
r u author of survivalislanddigital plugin?
yea
if so check ur playerinteractevent handler
Read the bit directly below nullpointerexception: null
event.getClickedBlock is nullable
Mhm
bingoe
also instead of (!(a==b)) u can do (a!=b)
that event catches most player click interactions
yes, if not try this
ok thx
gl gl
is detecting if a player drank something the same as player consume event?
Yes
ok
For banning-muting players would you rather save them on a separate yml or use "Bukkit.getBanList"? Etc
banList
use SQL if possible for muting
I suggest using the Bukkit method for compatibility and in a worst case scenario backup if your plugin decides to take a swan dive
I wish LiteBans had a feature where it would sync with the local banlist
idk if that exists
So I have this https://paste.md-5.net/tifuwicoro.cs, and If the sender doesn't have that permission, would the code stop after the return true and doesn't perform the command?
I mean doesn't run the subCommands.get(i).perform(sender, args);.
Does someone know how to fix this error https://mystb.in/StemJoyNever.prolog when getting something from the datastore? The metadata class looks like this: https://mystb.in/CompressedMarkerReveal.java (Morphia)
Thanks
can i change the default message of some commands? (like /gamemode).
make a new command for it
I need help: I use schedulesyncrepeatingtask to create a countdown if a player dies. I save the taskid and cancel the task when the countdown = 0. But when two player die, the saved taskid gets overritten and only one task gets cancelld. Any better way to create a display?
a task isn't player-specific, except you do them for(online-players) or save them in a hashmap
i know, thats the roblem i have, is there something like a player specific scheduler
i think even in for(players) they're not for specific players
yeah i tried it
not directly i think
maybe i try to save player uuid and taskid in a hashmap
i would say, you use a hashmap<UUID,Integer> and count down that player-specific integer
thats what i use for cooldowns
ok ill try, thanks
maybe take a look at this, this is how i put kit's on cooldowns, maybe it helps
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (cooldown.containsKey(p.getUniqueId())) {
//still on cooldown
} else {
//execute your command
cooldown.put(p.getUniqueId(), 15); // 15 means 15 seconds cooldown
task = Bukkit.getScheduler().runTaskTimer(Main.getPlugin(), () -> {
if (cooldown.get(p.getUniqueId()) > 0) {
cooldown.put(p.getUniqueId(), (cooldown.get(p.getUniqueId())) - 1);
} else {
cooldown.remove(p.getUniqueId());
//cooldown removed.
task.cancel();
}
}, 0L, 20L);
}
}
return false;
}```
or whatever, i gave that another user here
I usualy use expiringmaps
Does anyone know how to calculate the remaining XP to a level with the XP increasing exponentially? (Not MC XP)
you should have some type of formula
then pre-calculate the xp for each level and cache it
then check how much is needed until next level
Basically, you need to add some Math#pow spice
Anyone have co.aikar.commands in JAR?
I suggest using maven: https://github.com/aikar/commands/wiki/Maven-Setup
or gradle: https://github.com/aikar/commands/wiki/Gradle-Setup
Java Command Dispatch Framework - (Bukkit, Spigot, Paper, Sponge, Bungee, JDA, Velocity supported, generically usable anywhere) - aikar/commands
how do i use player#teleport without playing the landing sound?
do you mean "fall on land" sound?
Could probably try some hackery with Player#teleport(), then Player#setFallDistance() or whatever that method is... set it to 0
Not sure if that would fix it but 
what do you mean by "exact coordinates"?
Resolved it with
int coordinatex = e.getClickedBlock().getLocation().getBlockX();
int coordinatey = e.getClickedBlock().getLocation().getBlockY();
int coordinatez = e.getClickedBlock().getLocation().getBlockZ();
um, that is literally the Location
I know
I needed it as coordinates
ok
Anyways, how can I get the item in the mainhand of the player?
so player.getItem()
no event
Then you need to read it.
I did
the method is in there and it tells you exactly what it does
I cant understand what its trying to tell me, I dont see the syntax
I need an example
this is just some sort if method list
You just need to learn to read javadocs. they have all the information you need
How?
just look at teh method summary section
player.getInventory().getItemInMainHand()```
I need to to get the item from the player, because I later have to delete after the event ends
Which is a method of that event
You do not get it from the player, you get it from the event.
Ah. Didn't read into the context other than getting the item in the main hand. Then do as ElgarL mentioned.
if you want to delete it just set its stack size to zero
if(e.getItem().equals(Material.SHEARS) && e.getItem().getItemMeta().getLore().equals(protectorlore)){
int coordinatex = e.getClickedBlock().getLocation().getBlockX();
int coordinatey = e.getClickedBlock().getLocation().getBlockY();
int coordinatez = e.getClickedBlock().getLocation().getBlockZ();
}
So this should be correct?
getLore.equals is going to instance check the returned array
huh?
ArrayList<String> protectorlore = new ArrayList<>();
protectorlore.add(ChatColor.RED + "" + ChatColor.BOLD + "Vyvolá gigantického golema, který bude chránit tvé okolí!");
protectorlore.add(ChatColor.GOLD + "" + ChatColor.BOLD + "MYTHIC");
equals will not pass just because the contents are the same
So what do I do then?
you need to check the contents manually, or create a method to do it. if you just use equals it will fail as the two arrays are different objects.
Also getItem() is not a Material. You would have to getType() and check using ==
e.getItem().getType() == Material.SHEARS
Or just do a lore without an arraylist
But that would suck
getLore() returns an array
Ok, so if I cant use equals. what do I use?
one sec
checkign the equals
OK, you can use equals, with Lists it only checks the contents not an instance
So I can leave like that
You have to be really careful with .equals as usually it also compare teh object instance.
yes
Thank you
Is there a reason you needed the precise coords?
Yes beacuse I need to dispatch a command with coordinates, I'm spawning a custom entity using MythicMobs
I dont know, but I dont think getLocation prints out the exact coordinates
it does. You are rounding it with getBlockX
you're actually throwing away precision.
Oh
Location location = e.getClickedBlock().getLocation();
now its better
ty
And now I forgot, how do u dispatch command as a console?
You try to avoid it if at all possible.
why?
Thats what APIs are for
Well I dont know how to program one for MythicMobs
Well, fuck...
it has a full API
MythicMobs API Examples - www.mythicmobs.net. Contribute to xikage/MythicMobs-API-Examples development by creating an account on GitHub.
I have no idea what to do
what command do you need to issue?
"mm m spawn golemfinal " + location
btw
Location location = e.getClickedBlock().getLocation();
Pretty sure you can spawn MythicMobs mobs using their API.
Bro I dont know how to work with that
Use the BukkitAPIHelper class
Whats that?
Ok this looks usable
but I need to somehow import mythicmobs classes/methods etc idk
you add MM as a dependency in your pom
whats that
It tells you here https://www.mythicmobs.net/manual/doku.php/api
Hello, spigot! I made a custom recipe (with ItemStack). And I tried to set the amount of items needed, but I can't. Code example I tried:
ItemMeta meta = sickFlesh.getItemMeta();
sickFlesh.setDisplayName("Flesh");
sickFlesh.setItemMeta(meta);
sickFlesh.setAmount(4); // **this part**
ItemStack damager = new ItemStack(Material.AIR); // Material for craft
... (setting meta)
ItemStack lightningAxe = new ItemStack(Material.AIR); // Item made in craft
... (setting meta)
NamespacedKey key = new NamespacedKey(plugin, "LightningAxe");
ShapedRecipe recipe = new ShapedRecipe(key, lightningAxe);
recipe.shape("%% ", "%$ ", " $ ");
recipe.setIngredient('$', new RecipeChoice.ExactChoice(damager));
recipe.setIngredient('%', new RecipeChoice.ExactChoice(sickFlesh));```
Amount has to be 1 in recipies iirc
Is there anyone on youtube who made a video on this stuff?
Recipes don’t support custom amounts for ingredients
Are you using Maven to build?
hmm, what do you meant "iirc"?
If I Remember Correctly
^^
Yes but don't it will just be confusing for users
If you want to use more than one you’ll have to do some stuff with the PrepareItemCraftEvent
^^
Then do I have to throw away all the codes I've done so far?
Hello, are there any "started breaking block" and "stopped breaking block" events?
Yeah loops through all the blocks and set the type manually
You'll need 3 for loops
get location, get block then set Type
ok thanks
Hello, how to replace a default Minecraft command (E.g. msg) with a custom command?
i believe the default commands will always exist, but you can just make another command with the same name and set the event priority to highest (?)
commands have no priority.
nevermind, https://bukkit.fandom.com/wiki/Commands.yml says that plugin commands are done second, mojang command last
You shoudl be able to just make a command and override it
can someone help me, when i load my plugin this error comes up https://pastebin.com/J3s4xX96
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/kian/SpigotPlugin/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0
You compiled your plugin with a newer Java version than the server is running
Set the target compile version to Java 8
Hello when i try to build my plugin in Intellij IDE i get this error https://prnt.sc/119n8g2, and my maven file https://prnt.sc/119n9h1
reload maven
does your Main class extend JavaPlugin or java?
Is that Sync database code 👀
i just grabbed it from a tutorial
bruh-
it's my first time coding with databases in java
Remove the Bukkit dependency from yoru maven
i will try
if you need NMS you depend on spigot. if you don;t need NMS you depend on spigot-api
^^
lastly, stop using artifacts to build
how am i then supossed to do it?
very right hand side you need to open teh Maven tab and use the lifecycles section
package
Please don't name your main class Main ;/
and also that
ok
this is my main class 😎 pretty swag for my plugin PlayerWarps
Nice but why is that boolean field static?
Don’t make something static unless it absolutely needs to be ^
so it can be accessed staticly...
Isn’t it better to create a new object and access the variable that way rather than doing static variables?
Easier to do <class>.variable
I know it’s easier, but all people who’ve taught me in the past call that a band aid solution
I just wanna get more opinions lol
Is there any reason beyond ease of use?
Most people here will complain its "abusing static" but in reality its not. Its opinion based.
private static with a getter would be the proper method
Makes sense, thanks 🙂
Not really, because it tightly couples your code making it a mess. But using dependency injection you loosely couple your code making it more component friendly which makes it easier to scale, maintain and extend.
Does anyone know which field in NMS is displayed in the tab list?
I've had no problems using static. It makes it generally easier to access variables per class without having to make getters or other shit.
the point of getters is to control the access from external sources
This is probably because your projects are small
Getters and setters are good because it protects you from yourself and gives you more control over your fields. It’s also nice if you for instance wanna change the logic internally.
Doesn't use static because of fear of outside sources changing variable... Uses public getters/setters anyways
If you make a field public static you are then exposing that whole field. If you use a static getter/setter you only expose teh result. the field you can change however you like without breaking your API
the event fires before damage is applied
which is why its cancellable
How do i change that? (In eclipse)
you simply get teh health - final damage
event. and look at the provided options
String.format
or whatever you choose to display
Math.floor(damage)
It floors it, not rounds afaik
because it gets changed statically from another class lmao
yeah i know by using the plugin instance
i mean its just easier so i dont have to get the plugin instance all the time just for that little boolean
I can’t change your opinion so I guess
i think theres only 4 static variables in the entire of 7k lines of code 😂
But if you just prioritize to code with minimal lines and not caring about the actual project structure/design then just use kotlin or something that would remove all unnecessary boilerplate and verbosity.
"If you don't want to code your way move to a different language"
Its accurate though to what you said lol
Elaborate
i never said that i wanted minimal lines, and i also never said i dont like the project structure of design because i do, i literally make my own object for everything. i love how all of this is over one static variable lmfao
With “easier” I assume you meant less lines or did I assume wrong?
no i did not mean less lines
So what did you define easier?
so you dont have to store the plugin instance in classes that really do not need it, i'm just saying i ain't going to add the plugin instance to every class i have 😂
Can't blame a man for static usage when spigot/Bukkit itself is very static reliant
you think thats bad with one variable as static oh boy you wanna look at grief prevention 😂
Well it’s sort of an api context provider lynx
So ? XD
i've seen a lot of OOP apis/libs tbh
Usually when it comes to api modules you’re fine to have a class using static as entry point
No lol 😂
Yep
Have you tried unit testing Bukkit ?
I mean MockBukkut
But yes even that is cumbersome
An entire project is needed just to unit test it
There are plenty of well designed APIs out there that do not rely on static as much as Bukkit does
Java itself provides the service loader which could have been used to get your initial instance of Bukkit. Sponge used injection to get you your game instance etc
Relying on static may the wrong word but providing the api with static rather. Take a look at LuckPerms for instance. To get its api you can either use their static singleton or I think services manager. But even so if we exclude the services manager it wouldn’t make sense to create a new object that doesn’t have a state, but purely is made of providing the api.
Hmm I mean yes, Bukkit doesn't just do that tho
But well I don’t like the overuse of static and I agree
There are a lot of places in bukkits API where they themselves call on the Bukkit singleton
Which is the problematic part
😪😪 yus
Hey
I created a custom enchantment that i can give me using a command
How can I "add" this enchantment to a books? I mean when I go to creative, I go to book and I can see my enchantment in a book
how did you create the enchantment?
Uh random tutorial on YouTube
But using something like this:
public class EnchantmentWrapper extends Enchantment {
private final String name;
private final int maxLvl;
public EnchantmentWrapper(String namespace, String name, int lvl) {
super(NamespacedKey.minecraft(namespace));
this.name = name;
this.maxLvl = lvl;
}
public class CustomEnchants {
public static final Enchantment SAVE = new EnchantmentWrapper("save", "Save", 1);
public static void register()
{
boolean registered = Arrays.stream(Enchantment.values()).collect(Collectors.toList()).contains(SAVE);
if (!registered)
{
registerEnchantment(SAVE);
}
}
public static void registerEnchantment(Enchantment enchantment)
{
boolean registered = true;
try
{
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
Enchantment.registerEnchantment(enchantment);
}
catch(Exception e)
{
registered = false;
e.printStackTrace();
}
if (registered)
{
}
}
}
do you know how could I "put" this enchantment in a book forever?
get the book's item meta and add the enchant to the book's stored enchants
declaration: package: org.bukkit.inventory.meta, interface: EnchantmentStorageMeta
umm
okay
i've just started today so i can't really do this
is there any easier way
I suppose you could add the enchant names to the lore of the book
Then check if the book has the enchant's name when you are going to apply it
Enchantment MyCustomEnchantment = new blah.blah.blah.MyCustomEnchantment();
ItemStack newBook = new ItemStack(Material.ENCHANTED_BOOK);
newBook.addEnchantment(MyCustomEnchantment, 1);
¯_(ツ)_/¯
With this method the book itself would be enchanted
Hi, I have a lag exploit involving PacketPlayInAutoRecipe in 1.12.2. Is there a way to disable it?
@quaint mantle so what's the issue? isn't that what they want?
So if you add fire aspect or something you could slap people with a fire aspect book
Not really
Do you mean players spamming teh crafting to lag/ddos the server?
o.O
Adding enchants to the book and storing enchants in the book are not the same thing
@quaint mantle but you use anvil event listeners to apply the enchantment from the book to eligible items. and skip your enchantment code when it does not apply to the item it's on.
and then it would be fine.
one sec
Mm, I suppose that could work. But I still think storing would be less work
it's what I wound up doing anyway for one of my enchantment plugins, idr where my headache was but I remember most of the actual enchantment stuff seemed fine. I think one of the headaches though was that when you enchant you have to also have your plugin add the lore to the item being enchanted.
not so much a headache really
just didn't know that when I was messing with it
by 7smile7 to stop that exploit https://gist.github.com/Flo0/abaf7f6e41f99231f4c425b0e5c67d6d
thanks a lot
ayy tysm
@quaint mantle But using his method i'm going to be able to get the book in creative mode ?
You mean with commands? Or purely creative?
purely creative
like
/gamemode creative
you open inventory
and you found it
No
I guess I need to add the enchanted book to the creative mode ?
in onEnable
You can't add items to the creative inventory with a plugin, you would have to get the custom enchanted book with a command
frl?
i through we were able to add any items to creative inventory
Only with mods
do you know a painless way to build it?
what's the difference between mods and plugin
none
then?
Though bukkit is only serverside, which is the only limitation
ah yes
Creative list is clientside
I believe its complete. uses Protocol Lib. Just needs putting in a plugin
But as you may know, the client needs to download it manually
and I guess we cant' make something like when someone connects to the server (with any client), it "gave" the mod
yes
Not with any client, no.
can we make it with Forge ?
Probably not as easily, but it would be possible