#help-development
1 messages · Page 1735 of 1
so the size start at 1 and the arrayList starts at 0?
you use the wrong data structure if getting the last added element is important
How do I get the last one then correctly?
well, probably with a Dequeue
Okay I will try that thx
thank you
common implementation is either ArrayDequeue or LinkedList
read about the different time and space complexities they have before deciding
Would anyone know why this won't work? Casting it results in just using texture item/fishing_rod/bamboo_rod
Doesn't change texture at all. Texture file it self is fine
?
Doing this works fine
How can I set a projectile to follow a entity?
hey is there any reason this wouldn't work for a crafting recipe? https://paste.md-5.net/ovatowokon.java
and of course I am registering it with java Bukkit.addRecipe(new SharpRecipe().getRecipe());
Seems ok
does the function getHostName returns the ip?
well then idk bc nothing happens
Feel like you want getHostAddress or someone
found it ty gonna try it out
I have an item and this isn't working for me for some reason. meta.addEnchant(Enchantment.DAMAGE_ALL, 7, false);
does anyone know how I can send a world border color change to players?
I'm currently just sending a packet to players every second for the world border
but when I change the color, players don't see the new color
I can change the border size without problems but player's don't see the new color
I'm currently using this to change the border every second:
public void sendWorldBorder(Player player, Color color, double size, Location centerLocation) {
WorldBorder worldBorder = new WorldBorder();
worldBorder.world = ((CraftWorld) centerLocation.getWorld()).getHandle();
worldBorder.setCenter(centerLocation.getBlockX() + 0.5, centerLocation.getBlockZ() + 0.5);
worldBorder.setSize(size);
worldBorder.setWarningDistance(0);
worldBorder.setWarningTime(0);
((CraftPlayer) player).getHandle().b.sendPacket(new ClientboundInitializeBorderPacket(worldBorder));
}
Sorry I was just being dumb, I just needed to change false to true lol
ok but why is offline player by name depricated?
because players can change their name so you should use UUIDs instead
but how do i get a uuid from a name?
by using the deprecated method 😄
xd
just because it's deprecrated doesnt mean that it will be removed
it just means you think twice about it when using it
like
ok
you CAN use it when you only have the player's name
but
you should instead think about why you don't have their UUID
because banning ofline players you know?
sometimes it's legitimate to use player names for offline players, e.g. when you have some kind of message plugin etc
oooh well
you can get the UUID of an offlineplayer
OfflinePlayer#getUniqueId
yeah but i have to use the deprecated method to get offlineplayer
still i am only using uuid just for complete functionality i add name
Seems like you only have to send the border once
To change color, seems like the following:
Expanding: green
Contracting: red
still: blue
I believe you should use this packet
ty
Or one of the other various LoginEvents, they run before join
To change colors, it goes something like
Color color = ...; // RED, GREEN, BLUE
ClientboundSetBorderLerpSizePacket packet = new ClientboundSetBorderLerpSizePacket(new WorldBorder());
long speed = color == BLUE ? 0 : Long.MAX_VALUE;
packet.a = <border size>
packet.b = <border size> + 0.1 * (color == RED ? -1 : 1);
packet.c = speed;
just use reflections
or do an nms hack
Hi, does anyone know how to block the player from moving his head while riding an entity ?
You need to make it spectate an entity for that to happen
Not exactly what I mean ^^'
A weird complex hack is:
- Spawn a fake player npc, riding the entity
- Set the player to spectator mode
- Force it to spectate the fake npc
That's why there's a fake player npc
How would you send the input if you're on spec mode ?
Spec mode shouldn't send move packets
Try it
Ok I'll try it x)
you're asking to lock up game mechanics, you gotta face limitations yourself
Tbh, I was thinking about sending a entity_head_rotation packet with the corrected yaw/pitch to the player
that looks stuttery
Yeah I guess so
how do i get plugin directory?
Hey! Is there a way to make a client not calculate lighting updates?
Ok, now I have an other problem ^^ How would I get the entity object for the entity id (not the uuid)
Do I really have to loop through the living entities and get it by comparing ?
does someone know why ```public class JoinListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerPreLoginMonitor(AsyncPlayerPreLoginEvent e) {
if(BanList.getBanList().isPlayerBanned(e.getUniqueId()))
{
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Banned player " + Bukkit.getPlayer(e.getUniqueId()).getName() + " tried to join");
e.disallow(e.getLoginResult(), BanList.getBanList().getBanMessage(e.getUniqueId()));
}else
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Player " + Bukkit.getPlayer(e.getUniqueId()).getName() + " joining");
}
}``` doesnt get fired?
have you registered it ?
Entity ID -> Entity Object?
Yeah just loop
Oh ok
fuck me no i thought i did
Generally the server is the one sending lighting updates
its for client side block changes
Client-side blocks are fun
I'm sending the client a large amount of block changes, and it works flawlessly except for the fact that the client tries to calculate all the lighting then just dies on me
I believe the client will just use the Sky light if the block light doesn't exist (or is set to 0)
hi, does anyone know the variable to create a top?
?
Multi-Block-Change might work better
Im using multi block change. Ironically its proven to be more client intensive. Definitely more server friendly tho
Well, if the entity is only client side, the server will not have it registered :/ So, can't find the actual entity
I've forgot to mention that the npc is spawned through packets also ^^'
and can someone tell me why this e.disallow(e.getLoginResult(), BanList.getBanList().getBanMessage(e.getUniqueId())); still lets me join
pls?
pls pls pls use proper names instead of "e"
should work though
sry when you check above there is the code
is it AsyncPlayerPreLoginEvent?
okay first, you shouldnt use disallow on MONITOR prio
does the disallow() part actually get called?
use HIGHEST priority
but that shouldnt be the problem
yes
hm that's strange, sorry I have no idea too then
all I can say is that it SHOULD work fine lol
but it doesnt hm
let me check too
it works fine for me
@EventHandler
public void disallow(AsyncPlayerPreLoginEvent event) {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "go fuck yourself");
}
are you using a strange fork or sth @jovial nymph ?
why disallow method
why? isn't that what you are trying to do? disallow players from logging in?
what forK?
like paper, tuinity, ... ?
or are you using normal spigot as server software?
I tried it using paper #255 1.17.1
no i mean why "@EventHanlder"
i have spigot buildtools server
without @EventHandler, your method isn't called
but you have that in your code too so that's not the problem
ah sry i always though those methods are pre defined but it actiually depends on the event XD
the @EventHandler annotation tells spigot that this method should be called whenever that event is called
i never learned annotations
but you said that your disallow code definitely gets called
are you really sure about that?
oh i found it i think
what was it?
that AsyncPlayerPreLoginEvent.Result.KICK_BANNED
i just take the result of the event
it's okay, masturbation is totally natural lol
😂
well anyway, the disallow method works fine. pls make 100% sure that your code actually gets called, like... add some debug output to see if it INDEED gets called
i found it you did this event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "go fuck yourself"); and i did this event.disallow(event.getLoginResult(), BanList.getBanList().getBanMessage(e.getUniqueId()));
ooh
yeah that basically means you're setting it to allow
because it was ALLOW when you got the event
sooo
of course you have to set your own Result^^
you're just taking the allow result and use that again
i didn't thought of this
it should work fine when you explicitly use Result.KICK_BANNED
it did ty
np! Now go to paypal and send me many many $$$ for help lol
Does someone know how to get the data serializer for the PacketPlayInSpectate with the entity id ?
is there a method to add a permission to a player?
something like Bukkit.getPerrmissions().add(permission) (obviously that doesn't exist)
wut is towny?
this channel is for making spigot plugins
ooh
thx
np
sorry, I'm having trouble using it. can you give me some example syntax?
basically
all these inherit this interface
AbstractHorse, Ageable, Ambient, Animals, AreaEffectCloud, ArmorStand, Arrow, Bat, Blaze, BlockCommandSender, Boat, CaveSpider, ChestedHorse, Chicken, CommandMinecart, CommandSender, ComplexEntityPart, ComplexLivingEntity, ConsoleCommandSender, Cow, Creature, Creeper, Damageable, Donkey, DragonFireball, Egg, ElderGuardian, EnderCrystal, EnderDragon, EnderDragonPart, Enderman, Endermite, EnderPearl, EnderSignal, Entity, Evoker, EvokerFangs, ExperienceOrb, Explosive, ExplosiveMinecart, FallingBlock, Fireball, Firework, Fish, FishHook, Flying, Ghast, Giant, Golem, Guardian, Hanging, HopperMinecart, Horse, HumanEntity, Husk, Illager, Illusioner, IronGolem, Item, ItemFrame, LargeFireball, LeashHitch, LightningStrike, LingeringPotion, LivingEntity, Llama, LlamaSpit, MagmaCube, Minecart, Monster, Mule, MushroomCow, NPC, Ocelot, Painting, Parrot, Pig, PigZombie, Player, PolarBear, PoweredMinecart, Projectile, ProxiedCommandSender, Rabbit, RemoteConsoleCommandSender, RideableMinecart, Sheep, Shulker, ShulkerBullet, Silverfish, Skeleton, SkeletonHorse, Slime, SmallFireball, Snowball, Snowman, SpawnerMinecart, SpectralArrow, Spellcaster, Spider, SplashPotion, Squid, StorageMinecart, Stray, Tameable, ThrownExpBottle, ThrownPotion, TippedArrow, TNTPrimed, Vehicle, Vex, Villager, Vindicator, WaterMob, Weather, Witch, Wither, WitherSkeleton, WitherSkull, Wolf, Zombie, ZombieHorse, ZombieVillager
and to use it
I understand it
player.addAttachment(bluh bluh);
I thought it was its own class 🤦♂️
I will
How do you put a player in spectator on an other entity ? (not a bukkit entity, an nms entity)
Tried with PacketPlayInSpectate
With no luck
PacketPlayInSpectate ppis = new PacketPlayInSpectate(ridable.getUniqueID());
((CraftPlayer)player).getHandle().b.a(ppis);
tried with that, but does nothing :/ (I'm in spectator mode)
ridable is a EntityPlayer
And yes, it requires an UUID
Can’t you just get the Bukkit entity from it and just work with that
Since it's not an actual spawned entity not really ^^'
Yes, with packets
quick question, so if i have a plugin that doesnt have any specific minecraft version imports like import stuff.1_18_R1.stuff for example, will my plugin just automaticly support 1.17 if i have a 1.16 plugin? is there anything else id need to do? ive looked at forums but all they say it how to make a plugin support multiple versions if there are version specific imports
does anyone know about the code to create a tops command example that lists the first 5 or 10 places
Pretty much
would it still work on 1.17 if i set my api-version to 1.16 in my plugin.yml? or would i just need to do no api-version
It will work on anything at it above the API version
Assuming nothing in the API has changed, which it usually doesn’t
alright thanks
Specify better please..
I was looking in the spigot api for a command to perform a top, but I can't find any
A top what
The spigot API lets you make commands, it doesn’t include any
Well the server has a few, but that’s not the point
So I tried to find a base, to guide me to make a top of the 10 people with the most kills of a server, that works with an example / bcaro top command
Generally you want to save that data somewhere and then make use of that
But you could also use the built in stats of minecraft for tracking kills
and do you know where I find that form of statistics?
ok thanks for the information
for packet play out map if you specify a width / height smaller than 128 does it keep the previous pixels color or just reset them
A follow up on this issue - Say i have a kotlin plugin (in this case a dependecy, but it is just an example) that I upload.
Take the somewhat readable kotlin code:
fun applyDefaultInteractionsBlocked(defaultInteractionsBlocked: Boolean) {
val delegate = ::interactionsBlocked.apply { isAccessible = true }.getDelegate()!!
@Suppress("UNCHECKED_CAST")
val property = delegate::class.members.first { it.name == "value" } as KProperty1<Any, *>
property.get(delegate) as Boolean? ?: run { interactionsBlocked = defaultInteractionsBlocked }
}
This translates into most decompilers (i used luyten in this case, one of the very decent ones) into something along these lines:
public final void applyDefaultInteractionsBlocked(final boolean defaultInteractionsBlocked) {
final MenuItem$applyDefaultInteractionsBlocked$delegate.MenuItem$applyDefaultInteractionsBlocked$delegate$1 menuItem$applyDefaultInteractionsBlocked$delegate$1 = new MenuItem$applyDefaultInteractionsBlocked$delegate.MenuItem$applyDefaultInteractionsBlocked$delegate$1((Object)this);
final KMutableProperty0 $this$applyDefaultInteractionsBlocked_u24lambda_u2d0 = (KMutableProperty0)menuItem$applyDefaultInteractionsBlocked$delegate$1;
final int n = 0;
KCallablesJvm.setAccessible($this$applyDefaultInteractionsBlocked_u24lambda_u2d0, true);
final Object delegate2 = ((KMutableProperty0)menuItem$applyDefaultInteractionsBlocked$delegate$1).getDelegate();
Intrinsics.checkNotNull(delegate2);
final Object delegate = delegate2;
final Iterable $this$first$iv = Reflection.getOrCreateKotlinClass(delegate.getClass()).getMembers();
final int $i$f$first = 0;
for (final Object element$iv : $this$first$iv) {
final KCallable it = (KCallable)element$iv;
final int n2 = 0;
if (Intrinsics.areEqual(it.getName(), "value")) {
final KProperty1 property = (KProperty1)element$iv;
if (property.get(delegate) == null) {
final MenuItem $this$applyDefaultInteractionsBlocked_u24lambda_u2d2 = this;
final int n3 = 0;
$this$applyDefaultInteractionsBlocked_u24lambda_u2d2.setInteractionsBlocked(defaultInteractionsBlocked);
}
return;
}
}
throw new NoSuchElementException("Collection contains no element matching the predicate.");
}
This is still a simple example, with only three lines of more or less basic functions from the kotlin reflection library. In many cases it will translate to be much worse - so how readable does it have to be..?
In some cases, many decompilers will actually completely fail to decompile certain methods
here is an example - this method:
fun openMenuPage(player: Player, page: Int) {
Bukkit.broadcastMessage("start open" + with (System.currentTimeMillis().toString()) {substring(length - 5)})
if (!isValidPage(page)) throw IllegalArgumentException("Page $page does not exist in this menu!")
player.openInventory(getInventoryPage(page))
viewers[player.uniqueId] = page
Bukkit.broadcastMessage("stop open" + with (System.currentTimeMillis().toString()) {substring(length - 5)})
}
decompiles with this huge error listing all of the byte code: https://pastebin.com/raw/VS74GtPY
I mean
This doesn't fall under obfuscation rules
It is not technically obfuscation
Even if the name-mangling makes it terribly unreadable.
Deprecated.
ChunkGenerator.ChunkData are now directly provided
wot
im just tryna create a void world man
hello how do i check if the "WALL_SIGN" when right clicked, is attached to the chest behind?
kotlin bad
So, anyone know combo duels?
Yea, they are mainly 1.8 right?
But how do you make it 1.17
Is it possible?
Pls @ me
you mean you want 1.8 pvp in 1.17?
If you get the appropriate block data you can get the direction of the sign
@steady smelt
yea
wait no
i want no hit delay
like no invincibility frames
i still what the cooldown
yeah thats kind ahard i think, not on my brain
whose blockdata do i need to get? cause there is a event of right click and it checks if the player right clicked on a "wall_sign" and if yes then it proceeds now i want to check if the "wall_sign" is attached to a chest, is there any way to check that?
Anyone know a way to shorten this?
if (recipeType == Recipe.RecipeType.WORKBENCH) {
new CraftingTableRecipe(args[0], recipeType).getGui().show(player);
} else if (recipeType == Recipe.RecipeType.FURNACE) {
new FurnaceRecipe(args[0], recipeType).getGui().show(player);
} else if (recipeType == Recipe.RecipeType.BLAST_FURNACE) {
new BlastFurnaceRecipe(args[0], recipeType).getGui().show(player);
} else if (recipeType == Recipe.RecipeType.SMOKER) {
new SmokerRecipe(args[0], recipeType).getGui().show(player);
} else if (recipeType == Recipe.RecipeType.CAMPFIRE) {
new CampfireRecipe(args[0], recipeType).getGui().show(player);
} else if (recipeType == Recipe.RecipeType.SMITHING) {
new SmithingTableRecipe(args[0], recipeType).getGui().show(player);
} else if (recipeType == Recipe.RecipeType.STONE_CUTTER) {
new StoneCutterRecipe(args[0], recipeType).getGui().show(player);
}
You should at least use a switch
aren't if statements faster if you have more than like 5 checks?
nvm I had that reversed
Other than changing to switch is there anything quicker?
I'm still confused for the INT(n) for creating column in sql, can someone explain it? What does the "n" do.
number :yes:
Idk, maybe a map?
I don't see an implementation of a map in this setup
EnumMap<RecipeType, Function<String, Recipe>
map.put(CAMPFIRE, CampfireRecipe::new);
map.put(SMITHING, SmithingTableRecipe::new);
map.get(type).apply(args[0]).getGui().show(player);
yea but the problem is solved
testing rn
Oki
Is there event that called everytime Player receives item? Includes Inventory#addItem, basically anything.
Hi, I have an issue with despawning a packet npc
Like, sometime it despawn, and sometimes it just stay there
Could changing skin several times make that ?
you will need to have multiple listeners
but probably the best way is having a repeating task
dont think any functions to add items call any events
@summer scroll well the N in int(n) is the range of the integer. For example if you have int(3) the number can not have more then 3 integers
Examples:
Correct: 555
Incorrect: 5555
Ah okay, thank you.
Is there any way to set Items lore using packets and keep items untouched?
public class PacketManager extends PacketAdapter {
public PacketManager() {
super(AGMEnchants.getInstance(), ListenerPriority.NORMAL, SET_SLOT, WINDOW_ITEMS);
}
@Override
public void onPacketSending(final PacketEvent event) {
final PacketContainer packet = event.getPacket();
final PacketType type = event.getPacketType();
final Player player = event.getPlayer();
if (WINDOW_ITEMS.equals(type)) {
final StructureModifier<ItemStack[]> structMod = packet.getItemArrayModifier();
for (int index = 0; index < structMod.size(); index++) {
final ItemStack[] itemArray = structMod.read(index);
for (int i = 0; i < itemArray.length; i++) itemArray[i] = this.apply(itemArray[i], player);
}
} else if (SET_SLOT.equals(type)) {
final StructureModifier<ItemStack> structMod = packet.getItemModifier();
for (int index = 0; index < structMod.size(); index++)
structMod.modify(index, input -> this.apply(input, player));
}
event.setPacket(packet);
}
@Override
public void onPacketReceiving(PacketEvent event) {
}
public ItemStack apply(@Nullable final ItemStack item, final Player player) {
if (item == null || !item.hasItemMeta()) return item;
ItemStack result = item.clone();
LoreManager.setFinalLore(result, player);
return result;
}
}
I have this but items get modified every time 😦
Yeah you have to keep updating it
Listen to the server update packet and modify it
Oh and this will cause an issue in creative
I recommend hooking an existing custom enchants plugin instead of making another one
It should add a new part to existing role
New Part
Old Part
But it keep duplicating it 😦 So I get sth like this after a while
New Part
New Part
New Part
Old Part
Creative mode?
I did test in creative so is it the problem?
So if someone wants to use it on creative it won't work 🤔
If anyone has a clue that would help me a lot 😢
Atm yes
Does anybody know how to make a 1.17 Tablist plugin? I can't any forum or YT Tutorial
Why not use an existing one?
Check out TitleManager it's open source
I would like to implement it into my system
you could store original lore in a PDC or NBTTag
Thanks, You saved me
on the item
Look at their code to see what they do, and try to implement it ^^
thx ill look for it 😄
But if they decide to change the lore how can I detect it?
uhh
You can't
¯_(ツ)_/¯
you should scan constantly for items
but probably wont be the best thing to do
Creative has full control over items
will !null throw an npr?
wdym !null
its if (!hashmap.get(value that may not exist) && false)
i know but would it throw an npr?
No since you check for it
saw that
Good, I found the answer xD
just hashmap.containsKey()
smh
also you might want to use hashmap.getOrDefault()
i just want to know if it will throw an npr
Now I got another issue 😦
Lore Exists when I enchant 👇
aah finaly
Now it doesn't
IntelliJ shows what does a method throw, just hover over it
pff i want to make a kind of map with a string (commandname), an commandexecutor and a boolean that indicates whether or not the command supports console
i think it can be better than Map<String, Map.Entry<AbstractCommand, Boolean>>
because i also want a collection with all my command instances and i was trying to combine these two
but that goes brr
Have an interface of ConsoleCommand or something?
i was thinking about an command enum with the instance and the boolean
so i can check it with enum.isConsole()
I would have commands that should support console implement an interface so I can just instanceof
Personal taste i guess, havent understood enough of the context
Surely you have a CommandParser somewhere
how long does a hurt take in minecraft?
like, the knowckback you get from getting hurt
hmm
You mean invulnerability frame?
no not really, like how long you get knocked up in the sky for getting hit etc
By who, player? Golem?
I don't think there is any fixed time for that.
what do you even mean by that?
oh right, so that different.
yea that makes sense now that i think about it
What are you trying to do anyway?
well, is there somewhere where i can see the different times for golems, players, cactusses etc
If you made custom command classes (not sure if you created the AbstractCommand class), then it makes sense you have some way of parsing the userinput into that command class
every of my command classes does that itself with the execute() method
so, i have this fly check i made for an anticheat, but taking damage etc in the air makes you go up while in the air (which false-flags), i need to disable the check for the duration of the damage-time
while at the same time not making a verus 2.0
Ok nvm im being stupid
ah welp, can't really help you with that, sorry
i dont need any help with the check itself though, just how long you go up in the air after getting hit etc
you can't really get the exact amount of time, what if you got a hit in a cliff and you fell down, that's different thing too.
not really, i could just reenable the check when they hit the ground again, but that is an very very easy bypass. just take dagamge and go zooming around
i don't understand what the falling off a cliff has to do with this, if i just make a variable called lastHit and a HitType Enum with how long it should take for the check to be reenabled, then thats a problem solved
there is a plugin WORLDEDIT, in which copy pasting chests is glitching where double chests gets converted into single chests, I asked their support staff and they replied saying that its a spigot glitch, is there a given time when it will be fixed?
is it possible to put null as yml value?
if you rightclick on the chest, arent they back normal?
iirc
nop
oh
maybe try with paper instead
What version are you using
stop the cap
yes I didn't notice srry for that
instanceof interface does mean the class is implementing that interface right?
yes
cringe but i'm not implementing it
does viaversion completely swallow plugin messages?
uh no i don’t think so
if i do this instanceof ConsoleCommand in the base command class, will that work for child classes?
How can I add custom NBT to an item? I want to make some custom items unstackable and I was someone made it by adding uuid to the NBT
how do I check if a player died in a specific way
do I need to check the death message everytime
or is there a method
theres a method
which one bro
its like
event.getCause().equals(DeathCause.FALL_DAMAGE)
something like that
lemme open eclipse dw
oo
i have a command implementing an interface, i check for that in the base class and it returns true everywhere
i dunno why
Base class?
i have a base class which handles the onCommand method and checks if the player is authorized (console and permission etc)
You have both an interface and base class?
the interface is just empty and i implement it if the command has to support console
doesnt seem to work
Oh okay, I thought you had something like
interface Command
abstract class AbstractCommand implements Command
because that’s totally unnecessary
Okay that’s fine
@quaint mantle
if (e.getEntity().getLastDamageCause().equals(DamageCause.FALL))
Multiple inheritance
whats an enum?
how can I use it
any better ways for my "leaky abstraction"?
May I ask, why in the first place do you use the instanceof?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
therefore i had a map with the command string and a boolean whether the command supported console and that worked
We usually create molymorphistic object models to avoid this sort of coupling
and i thought by implementing consolecommand the base command class would be able to recognise it as a command which supports console 🎃
get ignored
isconsole = !sender instanceof Player
so if i'm executing it from the console but its not supposed to
you still get it?
GIT IGNORED BOI
Your instanceof works
your suspicions were in fact reality
But your logic is weird
dont know a better way
Just think about it,
if not player and is not consolecommand
So if the command does not implements ConsoleCommand and the sender is a console sender then it should run that in principle
can you refactor the name of the variable to something like isConsoleSender, a bit more readable
wtf
yes.
public enum Name {
VALUE_A,
VALUE_B,
VALUE_C;
}
you can imagine the values inside the enum to be integers
for some reason got problems with enums rn
Brush what command did you try this for?
Name value = Name.VALUE_A;
i think i got it working
if (value == Name.VALUE_A) {
}
Alright
In C/C++ the compiler replaces enum values with their index integer
so its an integer behind the scenes
not sure how java treats it
i can just use switch()
class Boi {
public static final Boi A = new Boi();
public static final Boi B = new Boi();
}
enum Girl {
A,
B;
}
Almost equivalent
heh
if i log an enum constructor parameter
liek
enum lang {
NO_CONSOLE("messages.noconsole", "console cant execute this");
Lang (String path, String defaulT) {
log(path)
}
}
does that logs all the enum paths?
Precisely
what
wym what
i lvoe how
Yeah
they’re initialized before anything else in the Enum
leading to inf lag
lag?
They don’t cause any lag
well if i get the value for some reason the constructor is called
Yes but everything causes cpu usage more or less
When the plugin starts
right
or application
Cause enum values themselves seem to be sort of "static".
So am I correct?
Assume you do reference an Enum constant of the Enum during onEnable then yeah
When it starts
If it’s the first time the jvm gets to know that Enum exists then it would log
?paste
look this is my class
every time i use the .get() it log that there is missing data, which is not true
it should normally only log at class load and not when i use the method
https://paste.md-5.net/nokiwoweyu.cs
I just found out that Bukkit.getPlayer() is depricated. What can I use instead?
string
^
The method getPlayer(String) from the type Bukkit is deprecated
On Spigot 1.17.1 its not
deprecated
declaration: package: org.bukkit, class: Bukkit
let me check my pom.xml
If you use paper then it might be the case, they do all sort of changes
<version>1.17.1-R0.1-SNAPSHOT</version>
This is my entire dependency html <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.17.1-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>
I mean it will log every Enum constant
Lazily tho
this advanced this
Do you wanna debug all paths when your app starts?
Just do this
can I just ignore the deprecation and move on?
for (EnumName name : EnumName.values()) {
log(name.path);
}
Yes, I don't know why its apparently deprecated for you?
oops
pinged wrongperson
nvm it is tthe right person

Lmao
wut
What if you try Bukkit.getServer().getPlayer(...)
Uh that’s weird
@SuppressWarnings("deprecation")
ez as pi
3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679
?
Hey is it posslible to reload a plugin external like pluginmanager i tried something yesterday bug it did not work
the reason its depricated is bc
the version is incorrect
even though it is 1.17.1
idk
NO
it seems to be below 1.16
You shoudlnt do this
^
https://stackoverflow.com/questions/27325391/what-is-suppresswarningsdeprecation-and-how-do-i-fix-it
bc Material.NETHERITE_BLOCK doesn't exist
but i need that
Why
yes but this not matter
i hat some plugin issues (not my plugin) when the world is not loaded
Then contact the author or make plugin load post world
it is proof that the version is below 1.16
this plugin is not supported now
yes
the source code is not the correct one on github and does not work
Decompile it
I can recommend Recaf
ok thx i will test it
how do I add spigot 1.17.1 to maven
IDE issue
because I tried it and it seems to be an earlier version
wut i was logging all the values of the enum and first it says it cant find it and after that it logs it correctly
for (Lang l : Lang.values()) {
Utils.logDebug(l.get());
}
<- pog
^^^
is seems to be an earlier version
Material.NETHERITE_BLOCK doesn't exist
I know
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
^
run buildtools
nah
thats exactly what I did
Okay clear caches and restart
but is seems to be an earlier version seeing as Material.NETHERITE_BLOCK doesn't exist
Might be called invalidate caches and restart
Do what I said
It's under the file tab
k
You are missing the api version from your plugin.yml
Can anyone help me with the WorldGuard API and making custom flags?
Sure what version
no api version in plugin.yml and it reverts to legacy
api-version: 1.13
it is in, I might have my plugin.yml in the wrong place. is it supposed to be in src/main/resources?
yes
version: 1.0
author: CJendantix
main: com.CJendantix.CustomRecipes.CustomRecipes
api-version: 1.17```
looks ok
if you use methods only in 1.17 you must use 1.17 api
Of WorldGuard?
methods like Material.NETHERITE_BLOCK
so 1.12 = 1.12.x and above can run the plugin?
Yes
7.0.4
?paste your pom
Are you using maven?
yes
it seems i have to call all the values from my enum before i can use them
Hm
Because Enums load lazily
strange
pom is fine
Try to exclude spigot from vault?
still..
I'll remove vault
can i just put a for loop over the values in a static block in the enum?
is that a yes or a no?
It would still require you to call it somewhere else
removing the vault API didn't do anything
if i just do that and after that i use them for real, would it work?
have you done as Olive said and invalidated cache and restart?
Anyways why don’t you just create a static function which logs all the Enum constants and then call that function in onEnable?
I don't know how
tell me
file menu
find it
there is no "invalidate cache" button
I don;t use InteliJ but I know its there
I'm using eclipse 🤦♂️
Hehe
much easier then, just update project in the maven menu
ok
fixed it
yay
thanks every1
why does the vault API break everything?
hellooooooo
🎃
Never had an issue personally
same with me
“It works on my machine”
when its just the spigot api everything is fine, when I add the Vault API it breaks everything
what is the latest version of the vault API?
what does "break everything" mean
I guess vault depends on older spigot version. Try excluding spigot artifact from vault
vault prob hasn't been updated in years
nvm
this doesnt makes sense, first it says the path is valid but after that it cant find it :/
Using enums for configs is a bad idea smh
< Object mapping
if my file is valid it doesnt makes sense that it is null
Enums shouldnt have mutable state, like at all
I don't care about vault as long as this would add the permission CJendantix.test to PintSizeJedi java Player PintSizeJedi = Bukkit.getPlayer("PintSizeJedi"); PintSizeJedi.addAttachment(this, "CJendantix.test", true);
It should, but it won’t be saved
how do I save it?
Vault i guess
if you mean it will be removed when I restart the server, that is in the OnEnable
Hi, I need to access a constructor using Reflection but I have no idea how to when there's an arbitrary number of arguments
// code
}
Could someone help me out please? 🙂
You need to pass an Object[] which will be invoked as the constructor arguments in the arrays order
Then you should be fine
Example:
int x = ...;
int y = ...;
int z = ...;
Constructor<T> constructor = ...;
Object[] arguments = new Object[]{x, y, z};
T instance = constructor.newInstance(arguments);
No really other good ways tbh
You can hook into the permissions plugin directly, but thats cumbersome,
cringe
excluding spigot didnt help?
for some reason getting a value from my config returns null
By using color codes. You can just prepend them to Strings.
ChatColor.RED + "no"
okay tysm
🎃
Example one:
String coloredMessage = ChatColor.RED + "Im gonna be red";
Example two:
String coloredMessage = "§cIm gonna be red";
Example three:
String coloredMessage = ChatColor.translateAlternateColorCodes('&', "&cIm gonna be red");
stop abusing enums and consider some configuration library
That makes sense, but what about the actual constructor parameterType (I'm using getDeclaredConstructor() and I don't know what to put as the parameterType, would it be 3 lots of Location ?)
isnt example two causing problems?
Varargs are considered arrays at runtime. So you need to get the constructor which has an Location[].class argument.
You mean for the colored Strings? Then no.
Example three literally just replaces all & with §
Its the same String at the end
Using enums for things that it wasnt intended ror
mvn clean install
?
a proper configuration library if you want type-safe configs
This is a perfectly valid use of an enum.
He has a fixed set of elements where element type and amount is predefined.
I dont think there is a better example of when to use an enum.
I mean using an enum for config keys is probably fine but for storing values which may change thus mutable, meh
yeah, fine for keys, but not for values
In eclipse its using the run configurations
you add one for a maven build
the values are defaults but yea..
I ran into this problem too. Sadly enums cant be generic. But you can create a generic wrapper class for the value.
Which is not ideal but viable.
Yeah
I am completely new to maven, what is that?
I mean, the biggest problem is that you have to somehow access configs in a static context
Or create a pseudo Enum with maybe the use of sealed to make it better supported at compile time
Right click project, run as... run configurations... select Maven and add
Goals would be clean package
Yeah using a dynamic config approach and then implementing a pseudo Enum also seems like a nice idea.
add your goals, then apply
what goals
huh
type in the goals box clean package
k
Or you just throw away all the fiddling and let Jackson do the work
like I said, I know absolutely nothing about maven
nerd moment
lol
look handy tho
once you apply and run, it will now be available under teh Run button of the task bar
Configurate or dazzleconf as variant
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
your pom needs a source level
wuts that
in my pom I have xml <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
yours would be 16
here is my pom https://paste.md-5.net/wibowazaqa.xml
:cat-gun:
hehe
I miss my emojis : /
should I just copy and paste this into my pom?\
replace the 1.8 with 16
k
yay
works
ok, is there a way to do something that runs every tick? like a tick.mcfunction in a datapack
Use a runnable
?scheduling
no idea in a datapack
Hey, I would like to know how could I basically know if a block should be affected from an explosion (especially the "native liquid protection" thing) but I can't think of a way of doing it 😒
(One easy way of doing it would be to be able to make obi appears in the inital blocklist from the ExplodeEvent, but I couldn't find anything that would allow it in spigot config)
you have nitro tho???
Not boosting this server
that shouldn’t matter… meh idk
@ivory sleet you aren’t boosting this server
can you use custom emojis


Hey, does anyone know a plugin that will let players know when they enter/leave spawn/safe area?
what can I use instead of addAttachment java public void runnable() { new BukkitRunnable() { @Override public void run() { Player CJendantix = Bukkit.getPlayer("CJendantix"); Player CatLordBlob = Bukkit.getPlayer("CatLordBlob"); Player PintSizeJedi = Bukkit.getPlayer("PintSizeJedi"); CJendantix.addAttachment(this, "CJendantix.test", true); CatLordBlob.addAttachment(this, "CJendantix.test", true); PintSizeJedi.addAttachment(this, "CJendantix.test", true); } }.runTaskTimerAsynchronously(CustomRecipes.getPlugin(), 0, 10); }
The method addAttachment(Plugin, String, boolean) in the type Permissible is not applicable for the arguments (new BukkitRunnable(){}, String, boolean)
this is inside the BukkitRunnable so is referencing teh runnable and not yoru plugin instance
it is temporarily in the main class
makes no difference
k
this is inside the runnable. It needs a plugin reference
can you answer my main question now?
why are you trying to add a permission every 10 ticks?
How to run a function every x minute, second or hour
because Bukkit.getPlayer("an offline player") throws an error if the player is offline, so I want to keep adding it until the player is online, it works fine
eww don;t do that
what do I do then?
just add it in the PlayerJoinEvent
I am so fricking dumb
I completely forgot about events I haven't used them in so long
guys join my thread
Can I somehow get if a player is constantly rightclicking or can I only get if he right clicks once?
how to hide a player in the tab list of players
hey guys can someone help me? https://www.spigotmc.org/threads/events-not-firing-for-a-specific-player.530010/
Explain more? What are you trying to do?
for example: I want to spawn a sphere of particles on right click and constantly make it bigger if you are holding right click. If you let it go it stops growing.
is there an event called when a spectator stops spectating someone? (presses shift)
Okay I am gonna look at that thank you
Paper has an event for this. Spigot does not
ah, do you know what the paper event is called?
PlayerStopSpectatingEntityEvent
HOw can i send an action_bar message in 1.17.1? I have this but I get an error in my coding probram: all.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.GOLD + (speed*20*3.6 + " KM/U")));
ChatColor.GOLD.toString()
I have a red line under sendMessage
what is all?
all are the online players
all.spigot().sendMessage()
for (Player all : Bukkit.getOnlinePlayers()) {
sendmessage is a method under spigot() you can;ty just use all (a collection) to send a message to all
ok
then as agler said
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; this are my imports
yea thats correct
Try this, it isn’t deprecated
It wont work with the chatmessagee type
Is it working or not?
No
how do I loop through an 2d array?
Just like you loop array but you have two loops
What does the error says?
like this?
for(int i=0; i<coordinates.length; i++) {
for(int j=0; j<coordinates[i].length; j++) {
}
}
If i remember right then it is correct
okay thank you
yeah what does it say? you have a red line right?
Yes under the word sendMessage
okay, send me your code
for (Player all : Bukkit.getOnlinePlayers()) { if (all.isOp()) { all.sendMessage(ChatMessageType.ACTION_BAR, (ChatColor.GOLD + speed*20*3.6 + " KM/U")); } }
all.spigot().sendMessage(), I've said it above.
Can't you just use Bukkit.broadcast(String, String)?
all.sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD.toString() + speed*20*3.6 + " KM/U"));1 This also wont work
omg
all.spigot().sendMessage()
bro, you need to use the sendMessage method from Player.Spigot class to send the action bar message
Aglerr is raging
No because it send something every second
And????
Broadcast message is chat not action bar
@keen obsidian you need to see my chat bro
spigot cannot be resolved or is not a field
What version of Spigot?
1.17.1
Oh I was reading sendMessage
And 1.17.1 is in your project too?
Hm
Maybe am I to dumb
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("Message here"));
The method spigot() is undefined for the type Player
Player interface javadoc, instance method
what ide do u using?
It's weird then, the method spigot() should be there.
one i had problem when ide didn't recognise some methods
Lars send the code you got rn
if ur using intellij idea try invalidating cache
I think Eclipse wont like the Actionbar because in Intellij idea it isnt an error
How can I fix the ArrayIndexOutOfBoundsException in line 12?
https://gist.github.com/ItzJustNico/fa341f85e273bb04f01c8f775a6b21d0
cuz ur loop where u increasing arrayLocation is running (Math.PI * 2 / (Math.PI / 10)) * (Math.PI / (Math.PI / 10))=200, but ur arrays size is only 31
Ah yes I got it thank you
np
I made 3 classes called "Deck", "ExtraDeck", and "SideDeck" which all extend the "DeckSet" class which extends the "DeckManager" class.
These classes are erroring: "Deck", "ExtraDeck", and "SideDeck"
Error: There is no default constructor available in DeckSet (recommends I create a super() and I don't know how to use that keyword)
I just don't understand why it needs a default constructor when the one I have already does what I need it to. Could anyone attempt to help explain?
How do i add more then one compatible api-versions to my plugin.yml?
Can't. Spigot should add the option to do a list or remove that option all together.
Hi, does someone had a similar issue where if you spawn/despawn an npc fast there is a dupe of the npc stay there ?
Hey! i have a problem with a file code
public class UUIDStore implements Listener {
private static FileConfiguration UUIDconfig;
private static File UUID;
@EventHandler
public void playerUUID(PlayerJoinEvent e){
Player player = e.getPlayer();
UUID = new File(Bukkit.getServer().getPluginManager().getPlugin("MineSpaceSkills").getDataFolder() + File.separator + "Data", player.getUniqueId() + ".yml");
UUIDconfig = YamlConfiguration.loadConfiguration(UUID);
}
}```
why this doesn't create a folder?
the file niether
try printing the .getDataFolder() path and check if its a null pointer
System.out.println("a");
UUID = new File(Bukkit.getServer().getPluginManager().getPlugin("MineSpaceSkills").getDataFolder() + File.separator + "Data", player.getUniqueId() + ".yml");
System.out.println("A");
this you mean?
no check if System.out.println(Bukkit.getServer().getPluginManager().getPlugin("MineSpaceSkills").getDataFolder().toString()); works
can a commansSender have a permission? i dont mean player
don't really understand?
check if it is something else than null
it sends this
plugins/MineSpaceSkills
than its notnull
does the folder gets created?
nope
well then I think it could be because you try to create a file without creating a folder first
so, first i create the folder
i always do it like this
File file = new File(plugin.getDataFolder(), name);
if (!file.exists()) plugin.saveResource(name, false);
return YamlConfiguration.loadConfiguration(file);
let me try
and at th top
if (!plugin.getDataFolder().exists() && !plugin.getDataFolder().mkdirs()) {
Utils.logError("Could not create files");
return;
}
whi i have a problem with my plugin , i tried spigot 1.13.2 api , 1.8.8 api , 1.12.2 api , and even 1.16.5 api
mysql is not connecting ..
define "not working"
isnt this better instead of making a player variable?
if (sender instanceof Player) {
player = (Player) sender;
}```
can i msg you privitaly?
instanceof Player player smh
i can't really explain it here
If you can explain it in a private msg then you can also explain it here 😄
i can't disagree
but luckperms is working ..
first i thought that oky bcz iam using old ver [spigot 1.8.8]
but i tried all version
i guess you are stting up your own mysql connection?
1.13.2 , 1.16.5
that doesnt care about the spigot or api version
bcz from what i read , that spigot 1.8.8 [dont support mysql 8]
i know its old ver , i tried 1.13.2 and same error ..
Spigot has the mysql jdbc driver provided
YES
iam trying to realocate it to mysql 8
i tried to edit it in pom.xml but nothing changed..
Use the maven shade plugin and relocate it
But you should not need it as spigot has a working driver
Show your pom pls
shadedPattern has to be a path which derives from your applications path. So
com.me.money.skypvp.mysql for example
Next: You are using the <scope>provided</scope> for your mysql driver but you also relocate it. This makes no sense.
Remove the scope then relocation works.
You cant relocate what you dont have. If you relocate a dependency you need to provide it yourself.
oh
pattern is mysql
shadedpattern is your.path.mysql
Wait. Mysql might have a weird packet structure... so pattern could be something else.
Anyways you are using an ancient Spigot version so ill just recommend you to not use such an old piece of (unsupported) Software and move on. 👍
tru
thank you , i tried 1.13.2
same thing not working
tried 1.12.2 same error .. <
tried 1.16.5 mysql not working ..
Remove mysql from your pom
Completely. Spigot has it already as transitive dependency.
i will try that thank you
Hello there, I have a trouble with Hikari Database Pool
Why I get this after 1000000ms Connection is not available, request timed out after 1000000ms. I tried every time close pool and connection but nothings go on.
@Override
public PlayerOptions select(@NotNull Player player) {
UserData userData = App.getService(PlayerService.class).getUser(player);
try {
Connection connection = Westcore.getDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM wl_player_options WHERE player_id = ? LIMIT 1");
preparedStatement.setLong(1, userData.getPlayerID());
ResultSet resultSet = preparedStatement.executeQuery();
if(!resultSet.isBeforeFirst()){
return null;
}
PlayerOptions playerOptions = new PlayerOptions(userData.getPlayerID());
while(resultSet.next()) {
playerOptions.setId(resultSet.getLong("id")); playerOptions.setShowDeathMessage(resultSet.getBoolean("show_death_message")); playerOptions.setShowJoinMessage(resultSet.getBoolean("show_join_message")); ...
}
connection.close();
preparedStatement.close();
resultSet.close();
return playerOptions;
} catch (SQLException e) {e.printStackTrace();}
return null;
}
And my configuration is:
public void configureDatabase() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://xxx
:3306/xx");
config.setUsername("xx");
config.setPassword("xx
");
config.setMaximumPoolSize(5);
config.setPoolName("WCDataPool");
config.setConnectionTimeout(1000000);
config.setMinimumIdle(0);
config.setIdleTimeout(35*1000);
config.setMaxLifetime(45*1000);
config.setConnectionTestQuery("SELECT 1");
dataSource = new HikariDataSource(config);
}```
leaked your database info for like 20 seconds 
Hey, i have this code:
https://paste.md-5.net/erakikiher.java
But it doesn't create a file or a folder, could anyone help me?
Just changed, my wrong 🥲
so i cant drop items, crops that get dropped when breaking them dont get dropped and entities dont spawn
anyone an idea what could be causing that?
We aren't gods 🙂 without a plugin list we cant help
is there a 1.17 plugin where you can spawn in player entities to keep mobs spawning in a grinder
doesnt seem like a good idea
its for a personal server so it doesnt really matter just dont wanna have my computer on to afk
