#help-development
1 messages ยท Page 200 of 1
@FunctionalInterface
interface TriFunction<T, U, V, W, R> {
R apply(T t, U u, V v, W w);
}```
void doSomething(Type1 param1, Type2 param2, ...) {} ๐
Yeah it's just a very easy way to store info and is very performant since it's just stored in memory. Compared to dealing with a database it's theoretically less of a headache ๐
caches exist
i see
Yep which is basically how I was using PDC. As each chunk gets loaded/unloaded it's data from the PDC gets cached/indexed in memory
yes
So it doesn't really inform me what plugin causes the issue. I removed the plugin that was right before the first error message, but that solved nothing
Is it possible to get the player who manually ignited a creeper? I'm on 1.8.8, and yes I know its API is outdated but I'm doing work for someone else.
playerinteractAtEntityEvent?
Does the creeper entity object store the data? Or will I have to use that event + hashmap to do this?
check if someone rigtclicks with something burnable on a creeper
I have no clue what plugin that is because the plugin is not described in the error message
You think it might be ViaVersion that isn't working properly?
Is PacketEvents installed
Is that a plugin? then no
zip file closed?
Okay then one of your plugins includes it
probably something related to Discord/VK/Files integration
Most of the plugins have database integration
Send your plugin list or smth
do you use PlugMan/PlugWoman or do /reload instead of /restart?
I only use restart
hmm
I think reload was used one time like a few days ago
But this didn't occur before a couple hours ago
like 1 hour ago
try removing LiteBans for a test run, if not -> all things related to Skript(SkQuery) + Bande
do players get kicked before or after the plugins disable?
Ok so is this some kind of Packet hacking that i need to do, or is there something in spigot that i can do to prevent the "placing" act of this block?
https://gfycat.com/ReflectingSeparateFieldmouse
wdym
like the ghost place
you just cancel the BlockPlace?
hmm
For example, When you are holding an item i want to deny that you are able to place it at all
like you cant place a Hoe for example
i cant Cancel any event that im aware of, Playerinteract block place or anything because the client still sends to the server that it attempted to place and that player still places it
technically anyway, the server then just undoes it
Lemme rephrase,
https://i.imgur.com/tNzemNu.png
im already canceling it
Like have you ever played in adventure mode?
.
you cant place anything even if you have it in your hand
.
im trying to DENY the placement
yes ping the message as many times as you want
thats not what im trying to do
you said you are trying to make players not see flickering
thats a side effect of what im trying to prevent
alr
like i want to tell the client that they cant even place the block to begin with
psudo adventure mode if you will
Are you asking me ?
yes
nah dw i figured it out
ah
you can try setting players gammode to adventure and in 1 tick return it to previous gamemode on BlockPlace
hehe
Rifty do you have any idea to why i get this error?
declaration: package: org.bukkit.event.block, class: BlockCanBuildEvent
there is also something like this
@nimble hill
setBuildable(false);
There is no specific plugin info related to the error message, and the only thing usefull is that "PacketEvents" is used or smth. But that could be so many different things
.
How did you conclude those three plugins?
also some of the plugins can be corrupt, so you need to reinstall/remove them to get the answer
i don't know anything about skript except it's simplifying plugin coding
Do you know what Bande is ?
and your Skirpt.jar is doing the work under the hood
this is clever
Alright i found the problem
i guess it's connected to skript
Karhu Anticheat is an advanced Minecraft-anticheat that detects large variety of cheats and works on versions 1.7.10 - 1.18.2. Don't let cheaters ruin your day!
It wasn't
https://www.spigotmc.org/threads/an-exceptioncaught-event-was-fired-protocol-lib.575785/ might be the same thing. So check your protocolLib version
[23:28:02] [Server thread/WARN]: [skript-reflect] Loaded class dk.plexhost.bande.BandePlugin from Bande v1.2.8.138 which is not a depend, softdepend or loadbefore of this plugin.
Any Brazilians here?
skript somehow loaded and used BandePlugin via reflection ๐
Yea skript-reflect is an addon allowing use of Java import in skript :)
It was actually this. I think an outdated version of ProtocolLib disabled the use of Karhu which for some reason fcked up the whole server
Well since it's gonna use ClassLoader it can cause zip file errors too
Well since the error had to do with PacketEvents, i feel kinda stupid not realising that the anticheat was using packetevents
which makes alot of sense tbh
ProtocolLib uses reflection, Kahru depends on ProtocolLib in some way
So well with outdated ProtocolLib you can have a NoSuchField/NoSuchMethod
which leads to giant error
If i were to guess protocollib implements the PacketEvents api/lib idk
anyways shit works now xd :D
next time be aware of plugins like ProtocolLib and ViaVersion
Well actually protocollib was not outdated
but i think the version of Karhu relied on a test version of ProtocolLib
And plugins which depend on them
ask Karhu developer to update plugin for newer protocollib version i guess
hmm yera
never played skyrim, can't relate
everything is broken
xd
All mods depend on some libraries for old skyrim
which means old c++ game code
and when these libraries updated, mods which depended on them started causing CTD's
It's nice that Java has very informative errors
and minecraft server prints stack traces
cuz skyrim just crashes and leave no log
Apparently when placing a block a canbuild is called, but when placing a torch its not lolol
how can I place redstone blocks on my map at -45, 82, -49 through -41, 82, -45
you just do a loop from 1 to the other
starting with 1 coord to the next
like -45, 82, -49
from -49 to -45
Then the next row,
Then the last and you just keep iterating
with a loop in a loop in a loop
Loop from -45 to -49
{
Loop From 72 to 82
{
Loop from -49 to -45
{
get world.get time and return time < 12300 || time > 23850;
set code here
}
}
}
thanks ๐
public void OnTimeSetNoon(worldtime evnt) {
if (evnt.getPlayer().getWorld().getWorldFolder().getName().equals("world")) {
if (!(evnt.getPlayer().hasPermission("permissions.dropitem.inlobby"))) {
evnt.setCancelled(true);
}
}?
and moreover to this point @fluid river
https://gfycat.com/MistyGorgeousDevilfish
What would world time be?
haha
spigot trolled you
literally
anyone know what class in the bukkit API listens to commands sent in the console?
im curious as to what method bukkit is using
@EventHandler
public void OnTimeSetNoon((time < 1200) evnt) {
if (evnt.getPlayer().getWorld().getWorldFolder().getName().equals("world")) {
if (!(evnt.getPlayer().hasPermission("permissions.dropitem.inlobby"))) {
evnt.setCancelled(true);
}
}
}
??
PlayerCommandPreProcessEvent
PlayerCommandSendEvent
and this two
unfortunately its not an event which im looking for.
im looking for what bukkit is using in order to call those events. like, when a message is sent in console how does bukkit identify that in order to send those events?
IT WORKS WITH LEVERS, AND DUST, BUT NOT WITH TORCHES??????????
is there a gettime event?
are you trying to check if its night?
in events yes
:0
does it work with ladders tho
and simple torches
try ladder and yellow torch
and lever
public boolean isNight(){
if(time > 12500){ //12500 is the beginning of sunset.
return true;
} else {
return false;
}
And
public void Nighttime(){
if(isNight = true){
// code
}
Thank you.
and for lever
yes for lever
hmm
seems to only NOT work on torches lol
Here's how you could simplify that code. (If you wanted it)
public boolean isNight(long time) {
return time > 12500;
}
ladders and levers are placed so ๐ญ
i left it non condensed for his ๐ฅ pleasure
i have a cringe solution
try setting block to air
and cancel after this
tho would be inventory flickering
how do I get it in a specific world?
so nah
Fair enough. :PP
world.getTime() i guess
how do I import that specific world?
Bukkit.getWorld(WorldId).getTime();
@nimble hill try blockform event on torch
Bukkit.getWolrd("worldname")
^
ill try the form
Called when a block is formed or spreads based on world conditions. lmaoo
yea pulling for straws
Cannot resolve symbol 'getWorld'
you cant spawn things async
how should I fix that?
send a code snippet
I'm using it to delay the spawning by 2 ticks
scheduleSyncDelayedTask() on Scheduler
runTaskLater()?
I only need to spawn like 3 entities
that's what I'm using
nope, no event trigger
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
loc.add(0D, .01D, 0D);
Arrow arrow1 = (Arrow) entity.getWorld().spawnEntity(arrowLoc.add(loc), EntityType.ARROW);
arrow1.setVelocity(velocity);
entity.getWorld().playSound(entity, Sound.ENTITY_ARROW_SHOOT, 1, 1);
arrow1.setShooter(entity);
arrow1.setDamage(arrow.getDamage());
arrow1.setPickupStatus(AbstractArrow.PickupStatus.ALLOWED);
}
}.runTaskLater(Main.getPlugin(Main.class), 2L * i);
Thread t = new Thread((Runnable) task, "bowTask");
t.start();
}``` this is in EntityShootBowEvent
Im going to have an Aneurism
why...
Bruh. You are trying to run it on another thread.
I just used the same code I used for something else earlier
remove the new Thread thing?
The Bukkit scheduler takes care of BukkitTasks
yea you dont need to multithread that for anything
ah ok
World world = Bukkit.getWorld("World");
Long time = world.getTime();
public void getTime(time) {
if (time == 12500) {
}
}
new BukkitRunnable() {
public void run() {
loc.add(0D, .01D, 0D);
Arrow arrow1 = (Arrow) entity.getWorld().spawnEntity(arrowLoc.add(loc), EntityType.ARROW);
arrow1.setVelocity(velocity);
entity.getWorld().playSound(entity, Sound.ENTITY_ARROW_SHOOT, 1, 1);
arrow1.setShooter(entity);
arrow1.setDamage(arrow.getDamage());
arrow1.setPickupStatus(AbstractArrow.PickupStatus.ALLOWED);
}
}.runTaskLater(Main.getPlugin(Main.class), 2L * i);
that's all you need
learn java
???
it was because Long was capitalized
well then packets and cancelling all redstonepowerevent's related to this block place
World world = Bukkit.getWorld("World");
long time = world.getTime();
if (time ...) return;
There's another problem, because i need to deny the client's capability of placing a block Before they try to place something. sO
I was thinking of checking the hand, and WHile the hand is a torch or whatever in this case i could deny the CanBuild event. BUT THERE IS NO BUILDABLE EVENT CALLED.
SO i cant cancel it
im going to have a stroke
where's MD_5 or Choco when you need em
i hope Choco's pupper is doing good too.
Can you just tell me the error that I made?
why the fuck are you initializing a static block
intellij
I uhhh, don't think IntelliJ put it there.
Intelij is the Smartest platform for development and software engineering with zero flaws and is perfect.
idk what event to set it to
in what?
a code block
A method
alr
12500L tho
Thanks Bukkit
https://i.imgur.com/SFHbFYQ.png
>> Your code is BAD, when uderline is RED
Why are you using the Bukkit Javadocs?
checking java docs is mid
just check the javadoc comments inside your IDE
much easier
>> Sometimes your code's disgusting, when you do Raw-Type casting
thanks mate
example
ahahahahha
oh hell naw
Ethan just trolling us i guess
?learnjava
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.
;-;
@echo basalt read my message
its honestly not the best place to look to learn java in a place where prerequisite knowledge of fundamentals is expected
you can unhide my message dumbass โค๏ธ
you did respond tho
i'm asking for help
psycho can you tell him that i need help
ehh the usual
he blocked me
my mom was flipping shit at me while I was watching yt
so I just did what any man fears the most
Who wins
and kept watching yt
mom has the Tazer so
psycho please
What i really want is to know why a TORCH IS NOT A BLOCK or why a TORCH BEING PLACED IS NOT A THING A SERVER CAN SEE
Probably just an oversight.
BlockCanBuildEvent-related ^^
does it just not fire any events?
sounds like a packet interception time
maybe you might have some insight on what im trying to do
@echo basalt read this, i need ur help
im trying to prevent the client from thinking it can place a block
uhh
unhide the message go on
Psudo Adventure mode
finally
this looks like garbage
? Doesn't look like that to me
I mean
I can zoom just fine
just resolution-wise
the gif was not intended to showcase anything other than a packet is not being read as canbuild
Press that HD cog on the website
there was context also
rip ok it wasnt worky
shit it wasn't mine
dumbass imllusion โค๏ธ
bro why
can't you read mesasges where i ping you
and only read unrelated stuff
because he blocked you, leave it be
I would hope that's not how it works if you are blocked.
@nimble hill found it
i need his help
hmm
he blocked me cuz he dislikes me helping noobs
Have you considered just asking anyways?
yes
Is there anyway to force the client to not be able to place an item it should be able to
(so there is no flicker)
Yeah just use adventure mode
the flicker is a client-sided prediction and pretty much unavoidable
i COULD but they still need to be able to hit and break things, just not place
thats what im trying to avoid
You can guarantee it's client-sided if you just Thread.sleep while still sending keepalive packets
and notice that placing blocks updates on the client
the only ways around that seem like Adventure mode or inplaceable
but interrupting that sleep makes all the blocks go back
As for the placement state thing
open a PR on jira saying that the event doesn't fire
and just list my explanation
it should get added pretty quick
i mean i can list my own explanation but yea i get it. ill make a post
or well, @worldly ingot
but yeah what could nuker possibly need
because I'm not unhiding messages for the next 2 business days
[19:12:14 ERROR]: [BetterEvents] BetterEvents v1.0-SNAPSHOT attempted to register an invalid EventHandler method signature "public long BetterEvents.Events.Customevent.Time()" in class BetterEvents.Events.Customevent
I removed event handler and it worked
nvm
Hello another question. So im using this API https://github.com/Gecolay/GSit/blob/main/core/src/main/java/dev/geco/gsit/api/GSitAPI.java To create a sleeping pose for a player. I have a PlayerInteractEvent that checks that you right click a bed. What it is supposed to do is make you lay in the bed, but the problem im getting is shown in the screenshot. My question is how do I make sure that the player sleeps laying the correct way, no matter where they click the bed from
World world = Bukkit.getWorld("World");
assert world != null;
Bukkit.getConsoleSender().sendMessage("" + world.getTime());
return world.getTime();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
sender.sendMessage("" + Time());
return true;
}```
How can I automatically detect if the time hits 12000?
you can do onTick
@Override
public void onTick() {
}
ty
how do I set a Skull to have a certain skin if there's no player using that skin
like if I have a link to the skin's image file thing
wait nvm
found a tutorial on the spigot forums
Still need help
What is the packet used to teleport players?
Packet ID: 0x66 Teleport Entity Packet
This packet is sent by the server when an entity moves more than 8 blocks.
On 1.19, I am using a() in (NMS) Entity to overwrite a players location, but the server is sending PacketPlayOutPosition packets to fix the problem that I am making. That was why I was asking...
oh
ok
But I don't know how to prevent that without having my player be out of sync.
I might know an alternative...
what are you trying to do?
I am trying to make to make a minigame that swaps the worlds blocks with different ones by reading the chunk data and modifying it before it gets sent out
why not just modify the chunkgenerator
or the palette
if thats what you are doing
or use schematics
Well, I want to keep the world data the same without overwriting it...
ok i see, you are trying to do packet magic
Yeah
Thank you, I will look into this
if im understanding you, you want to for example have a player be in a world in their home, then be able to start a minigame and have it fake it
Kinda, I just want to have a day night cycle that makes the game "nightmare-ish" when the nightmare event is called
Oh, I know about that... I am using reflection
How can i change slot server (bungeecord) with command?
Thanks for your help, I found where to edit the last known location... If anyone is wondering, take a look at net.minecraft.server.network.PlayerConnection
How does one untranslate color codes basically turning back a translated &e back into a normal &e?
ChatColor#stripColor()
Wonโt that remove the color codeโs completely and not include for example &e inside the string?
Oh, you actually want it converted back?
Ye.
I'm not sure a method exists, but you could just take the existing implementation and convert it to switch out the section symbol for the ampersand.
I believe that converted strings will contain the section symbol in console and whatnot, but it obviously won't be displayed in game.
Could be wrong about it though.
Has someone ever got special source plugin working on gradle yet? (For mappings 1.19.2)
pre sure everyone just uses paperweight
Never used it cause i use spigot api
always hear about it but never used it
Assuming theyre both compat with each other or no? (EG, when theyre on a spigot/paper server)
I know nothing about paperweight so i prolly sound stupid asf lmao
iirc yes
I just use the manual commands with Gradle
Not sure on the purpose of this
Theres manual commands? Or just commands you made
There's manual ones, they're provided in the thread
Ah i see so the top line takes my built jar file and remaps it, and bottom reverts?
I have my reasons.
yea xD just do a replaceAll of the special symbol to the &
how to do lay? (1.12.2)
for some reason this code is only registering the first custom item, and not the 2nd custom item and so on and so forth, so i was wondering what i was doing wrong and how i can fix this? Been at this all day. i really need the help and i would appreciate it a ton!
My Code: https://pastebin.com/2XrHcEBd
Ping me if u know a solution to this, going to sleep
How can I create a plugin that the sheep have the name jeb_ and that name is invisible
how I know you need disable showing nick at nbt tags
On spawn sheep
declaration: package: org.bukkit.event.entity, class: CreatureSpawnEvent
probably because you're returning in the for loop
if the item doesn't match your first/second condition, it breaks out of your loop.
yeah but this is how i got my config setup
Recipes:
testItem:
firstItem: stone
secondItem: diamond
itemResult: emerald
levelCost: 0
name: '&aTest Item'
lore:
- '&8Test Item'
- ''
- '&d&lCool Item forged by gods.'
- '&9I think..'
- ''
- '&c&lSPECIAL ITEM'
testItem2:
firstItem: emerald
secondItem: diamond
itemResult: totem of undying
levelCost: 0
name: '&aTest Item 2'
lore:
- '&8Test Item 2'
- ''
- '&d&lCool Item forged by gods.'
- '&9I think..'
- ''
- '&c&lSPECIAL ITEM 2'
it only lets me do the first recipe
and not the 2nd one
it's likely because you exit the for loop with return
yeah
np
Ello. Small brainer here, in setformat(), I get the error saying it cannot conversion โ?โ even though the string doesnโt contain โ?โ.
Show the code
?paste
https://paste.md-5.net/iwenadabow.pl bet it is the special character.
pretty sure you forgot to add %2$s or whatever the field is
%1$s gets replaced with name, %2$s gets replaced by the message
you need at least the %2$s on the end for the message
I did that now, but same thing.
you just have %s twice
I changed it, but same issue.
then post yoru full format code and the full error
need full error
I see nothing wrong with your format, but debug the final format you are setting after you call Placeholder. Your code should work fine on Spigot, can't advise on Paper
Well lmk if yall find the issue before I do.
Guys Do you know max length of Item display?
i think its like 30 characters?
This isn't the full code
Full code means at minimum the entire method. Preferably the entire class to be shown
why my spigot plugin doesn't run on paper, paper wasn't fork of spigot?
Oh thanks
all spigot plugins run on paper, unless you did something silly
Yes, they do run on Paper. Without an error though, there isn't really anything anyone can do to help.
it doesn't show error, didn't created the config folder
There would need to be an error.
nothing
Did you add the plugin to the plugins folder?
does it show up under /plugins
nope
?paste
Paste the full startup log
tmr ill send it, i can't rn
@fluid river I know this is comming from left field but this was my solution:
@EventHandler
public void on(PlayerItemHeldEvent e) {
Player p = e.getPlayer();
ItemStack hand = p.getInventory().getItemInMainHand();
if (!hasAdaptation(p)) {
if (p.getCooldown(Material.REDSTONE_TORCH) > 0) {
p.setCooldown(Material.REDSTONE_TORCH, 0);
}
return;
}
if (isBound(hand)) {
p.setCooldown(Material.REDSTONE_TORCH, 50000);
}
}
@Override
public void onTick() {
for (Player p : Bukkit.getOnlinePlayers()) {
ItemStack hand = p.getInventory().getItemInMainHand();
if (!isBound(hand)) {
J.s(() -> p.setCooldown(Material.REDSTONE_TORCH, 0));
continue;
}
if (!hasAdaptation(p)) {
continue;
}
if (isBound(hand)) {
J.s(() -> p.setCooldown(Material.REDSTONE_TORCH, 50000));
}
}
}
J.s()
Damn bro
damn, variables called "p", fields called "J", methods called "s()" o0
XD
Hello , anyone used Calender or TimeZone utils before ? iam having a problem i dont know how if its fixable ..
so this is the code iam using ,
check for if the day that quest started is the same as today && week of quest started is the same week
that's all what iam trying to do .. but it seems to not working ..
ofc , i set when a quest start i set this in mysql
ideas will be great [i have been suffering from this for weeks , could not fix it ..
๐ญ
wdym with "not working"?
i will try to explain it :
ok so when i finish a daily quest today , and i log out , and log in tomorrow , it should reset it and i can do it again right?
but no its not doing that .
i hope this explained the problem .
and i use the method in 2 places
1- when i load the user :
2- when i give him the
this same must go with weekly quest .
when i finish it this week , i login next week it should be reset
and i can do it again
but now , its not hapening .. it keep on you already started this quest .. xd
J.s()
https://paste.md-5.net/icuguzefod.cs
Why is this PacketPlayInSteerVehicle class not working?
I am sitting in the right vehicle
I mean, how are you registering that ๐ค
me?
honestly i kinda disagree with the fact that you need annotations for event listeners
how i can convert miliseconds to seconds?
long seconds = starteddate / 1000;
right?
it wouldve been more convenient to have a method to register methods as listeners as well
There kinda is
There probably is a fancy bitmask to get just the day difference
well , i have been trying to remake the code :
and it still send me the miliseconds
and not the seconds
i know i have 3 variable for seconds , long seconds , long l , and l / 1000
forgot to remove them
yes
that's why it's called MILLIseconds ๐
tried that didn't give me seconds .. still give me miliseconds
Hey guys, I want to get Item Name in inventory by slot, It works well, but It always return AIR when It's getting 1.19.2 items
public void saveInventory(String path, Inventory inv) {
for (HumanEntity viewers : inv.getViewers()) {
InventoryView OpenInv = viewers.getOpenInventory();
if (OpenInv.getTopInventory().equals(inv) && !inv.getType().equals(InventoryType.CRAFTING)) {
yaml.setString(path + ".inv.title", OpenInv.getTitle());
yaml.setInteger(path + ".inv.size", inv.getSize());
yaml.getConfig().createSection(path + ".inv.items");
for (int i = 0; i < inv.getSize(); i++) {
ItemStack item = inv.getItem(i);
if (item != null)
System.out.println(item.getType().name());
if (item != null) {
setItemStack(path, item, i, i);
}
}
}
}
yaml.saveConfig();
}
How can I get the Item Name on 1.19.2 ?
I recommend using a translatable component is possible
to me?
Yeah discord didn't load all the messages for some reason
Still unloaded?
Try setting your API version in the plugin.yml
K. I'll try
It works Thank you !
Can I ask why we have to put this on our plugin?
It's just so Spigot knows your plugin isn't an old one
Ahh so if I put on version like 1.13 spigot will know every version upper 1.13?
If you put 1.13 Spigot will know that the plugin was designed for the major changes that happened in 1.13
If you don't specify it Spigot will try to maintain backwards compatibility
anyone by chance making a plugin about custom emojis in minecraft chat?
stuff like using the discord emojis ingame
This is the wrong place to look for plugins
This channel is for help with development
Thank you!
api-version 1.13 will work for every version
api-version 1.14 will work for 1.12 and below, and 1.14+
etc
versions below 1.13 do not care about the set api-version, and versions equal or above 1.13 only work if the set version is equal or below the currently running version
how do i fix this in gradle
anyone :() ?
What is there to fix
how do i set the language level higher in gralde
gradle
ive done it in the ide
but im pretty sure it resets
after reloading
Conclure!!! Nice to see you alive!! I thought something had had happen to you
Us?
U*
aight thanks
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
so nothing built in?
thats built in
you just need to use it
TextComponent message = new TextComponent("Click me");
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org"));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Visit the Spigot website!").create()));
oh ok ty
can you use the clickevent to run another function?
do you have to declare that command in the plugin.yml and onenable?
if its a plugin command yes
then is there a parameter or something that makes it so it can only be executed by the textcomponent?
maybe a check if the sender is a player who has a book opened?
wondering what the point is of using hikaricp and then only closing the db connection every minute or smth vs calling datasource::getConn every time and closing it every time?
Does anyone here happen to remember the SOLID principles full form off the top of their heads?
I don't know much about DBs, but it seems that reusing connections is much more efficient than getting a new connection every time.
ye thats what i was thinking but whats the point of using hikaricp then
if you only have one connection open all the time
Preferably a pool is the best option
would you have to close a pooled connection then?
Don't believe so. IO should be handled by the pool
im not sure but calling ::close on a connection that hikaricp returns does not actually close it iirc
anyone :=: ?
HikariCP handles the connection pooling for you. It simplifies the coding even if you only have one connection (like for SQLLite).
im always used to close connections right after a statement
Why not try with resources
thats what im doing
You might find this helpful:
https://www.spigotmc.org/threads/guide-datasource-and-try-with-resources-how-to-connect-to-your-database-properly.480002/
It also covers using HikariCP.
hi a question on how could use interface to make a sort of config who change like
Mode: Teleport
Uses the Teleport interface
if i select the Mode: Random
Uses the random
Having something clean
interface paired with an enum
you have some sort of tutorial or reference i can pick?
he isnt saying anything about what the conn::close impl does
If you're using HikariCP and try with resources, I don't think you care.
is there a way to calculate the xp cost of combining 2 items on the anvil without using the anvil?
for the third time , any one used Calander or Date utils before?
yes
you answered me right ?
this ur quesiton?
wait
this is the current code ..
You can see, that we don't close our stuff here, because we don't need it. Any object you assign inside the braces of the try braces will be closed when you exit the code block. This will return the connection to our connection pool. Free the blocked memory for the result cache and statement and we are happy and ready for the next request.
@twin venture i think you should store System.currenttimemillis() + 24 hours after a quest is done
and when the player tries to do the quest again and its after that stored value
then it should reset and let you do the quest
bruh
there we go again with the static abooz
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
trust me with this, a few months ago I was using static left and right, I was able to get away from that tho. code is now much more readable and extensible... remember to use interfaces for main functionalities aswell
if you have questions feel free to ask me
np
Guys, does anyone know how to do such a placement of items by slots in the GUI?
At the moment, my items are placed like this:
That is, how to do auto-centering?
looks like a math issue (?
yes!
mc server start script go brr
use continue to cleanup that mess
to early for thing maths xd
you need calc the "/2" of the row for know where is the best place... but dont know the "formula"
does Location.getBlock.setType(Material.YOUR_TYPE_HERE); not work if the chunks aren't loaded
It should load the chunk and set the block
well its not spawning any blocks
it has the coordinates
public static void markPlot(Location loc, World w, double radius) {
double x = loc.getX(), z = loc.getZ();
for(double i = x - radius; i < radius; i++) {
for(double j = z - radius; j < radius; j++) {
Location tempLoc = new Location(w, loc.getX() + i, loc.getY(), loc.getZ() + j);
tempLoc.getBlock().setType(Material.GREEN_CONCRETE);
}
}
}
``` and I'm setting it like this :/
and yes i know im calling the line to edge of square a radius ๐
Why are you using hacks ๐
Are you in a void world or smth?
yes
u can see there it registers the coordinates
but doesnt spawn any blocks ๐ค
i dont test this.. but in NMS exists a boolfor know if the settype work..
but maybe only works for loaded chunks
somethings going wrong
not chunk loading error
cus i tried telporting player right before loading second one
at 256 0 0
which would 100% load the chunks
๐ค
but it didnt spawn
I'll just say it again your loop code does look off to me
Try printing where it's placing the blocks
hm i just had a thought
loc.getBlock().setType(Material.RED_CONCRETE);
I added that
to the end of markPlot
and it spawns
so its something about the 256
and the for loop
Like i = x - radius; i < radius; i++ ??
Is your first working position perhaps at 0, 0
and if print what block is in the location before change?
void
its the way im filling the blocks
thats the problem
does anyone have a pre made function to fill blocks using 2 locations?
public static void fillBlocks(Location loc1, Location loc2, World w, Material block) {
for(double i = loc1.getX(); i < loc2.getX(); i++) {
for(double j = loc1.getY(); j < loc2.getY(); j++) {
for(double k = loc1.getZ(); k < loc2.getZ(); k++) {
new Location(w, i, j, k).getBlock().setType(block);
}
}
}
}
``` came up with this, but it doesnt work. does anyone see why?
i think i figured it out
when Y is 0
it breaks
now to figure out how to fix it...
anyone have any idea?
is it possible to replace enchantmentoffers in prepareitemenchantevent? i am going to try reflection, but i am not able to test my code at this given moment, so i just wanted to get a second opinion:
public void preEnchant(PrepareItemEnchantEvent ev) {
// ...
EnchantmentOffer[] offers = Utils.generateOffers(
Triple.of(ench1, random.nextInt(ench1.getMaxLevel()) + 1, oldOffers[0].getCost()),
Triple.of(ench1, random.nextInt(ench1.getMaxLevel()) + 1, oldOffers[0].getCost()),
Triple.of(ench1, random.nextInt(ench1.getMaxLevel()) + 1, oldOffers[0].getCost())
);
try {
Field offersField = ev.getClass().getDeclaredField("offers");
offersField.setAccessible(true);
offersField.set(ev, offers);
} catch (Exception e) {
e.printStackTrace();
}
}
do i need to update the inventory somehow after this, or anything?
so I fixed this:
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "fill " + (int) loc1.getX() + " " + (int) loc1.getY() + " " + (int) loc1.getZ() + " " + (int) loc2.getX() + " " + (int) loc2.getY() + " " + (int) loc2.getZ() + " minecraft:green_concrete");
``` but now I need to load the chunks
tf
ok I fixed my problem by teleporting the player there
right before spawning blocks
that way chunks loaded ๐
Cancel it
this.cancel or this.stop?
not remember the runnable commands
cancel
doesnt work
btw there is an if() in my runnable and if thats true i wanna cancel it
You can only call this.cancel() inside if you're not doing
Bukkit.getScheduler().runTaskTimer()
You have to do new BukkitRunnable(() -> {}).runTaskTimer() I think is what it is
i have this
Yeah so change it to new BukkitRunnable
In Spigot there's absolutely no difference
they do the same thing
The 2nd one just allows you to access this in the Runnable itself while the other one is easier to write
change the () in () -> { with task
and then can use task.cancel()
gives error
You dont have the 2 longs for period and delay
if you want it to run every tick yes
so fast...
you call bukkittask.cancel()?
there a scheduler method that takes a Consumer<BukkitTask>
wtf you can use unicode in identifier names?
isnt that new year listener in spanish
now i notice... XD
i make this many time ago strange use spanish things xd
Can someone help me with this piece of code?
I'm trying to make a Chat-Color GUI plugin, where i can toggle Bold effect on or off. I can toggle it to on, but not Off.
I'm trying to replace the "ยงl" with "", but it doesn't work
ah
sick how thats possible though
imagine chinese characters
in the class name
xd
anyone can help? because i don't know how to make it?
Hi all! I have a question how to disable the ability to pick up in the gui?
Listen to the InventoryClickEvent
If you want to prevent people from putting in items you also need to listen to the InventoryDragEvent
I am currently using this event, and there is one problem now I canโt take anything at all, even from my inventory
Check where the item is taken from
like this?
like this? e.getInventory().equals(//name inv)
Not name
how would i wait for a while loop? I wanna do like while (item.isAlive()) but with like a 1 second delay
how do u check if u put in an item in the 2x2 crafting grid in ur inventory?
?scheduling
Have you tried the InventoryClickEvent
if item.isAlive() {
Bukkit.getScheduler().runTaskTimer(Main.getInstance(), () -> {
//ur code here
}, 1, 1);
}
mhm
it runs every tick
ik
no, not yet
ima do something like this
Item item = null;
new BukkitRunnable() {
@Override
public void run() {
if (item.isDead()) {
this.cancel();
}
item.teleport(location);
}
}.runTaskTimer(plugin, 20, 20);```
dont mind the null
ye that works
i was just doing a test
if I update a variable inside an enum will it update for all instancers of that variant
Enums shouldn't be updated
why not
how u detect if the thing u clicked was the 2x2 crafting grid, not the result tab
Check the slot number
smth liek thisd i mean
public enum Ability {
ATTACK;
private String title;
Ability() {
reload();
}
public void reload() {
title = // data from config
}
}
That's not how you use an Enum
oh ok
but it would be more efficient than constantly getting that data from config no?
Trust me pulling the data constantly from the config is the least of your concerns when it comes to performance
Just make sure you don't read the config from file every time because that would be real bad
alright
amount - 1 doesn't do anything
would it still be bad to have a gettitle method that pulls from the config
inside the enum
You're not using it in any way. You can remove that line and it changes nothing
Don't use an Enum for your config values
You can use it for the config keys but not the values
oh im not using it for config values
i meant like
enum_variant: stuff
and then gettitle method would like do return config.get(this.toString);
Java does the unboxing for you
It's because current is an Integer instead of an int
changed the param same story
alright, this is more of a java question but whats the best way to store stuff that the data wont get reset when the plugin stops
You need to check if current is null before using it
database
Depends on what data
ight ok
anything easier?
for example booleans
what kind of data
persistent containers work too
booleans for what
maybe like what uuid (player) is holding a specific item
ye thats what i want to use it for
huh
and how and when do you want to access the data
probably every tick
You probably don't want to store it to a file then
and whats the best way of doing that
Because if you're going to check every player ever every tick you're going to kill the server
what player is holding a specific item? just check their mainhand?
^
just one item, the dragon egg
holding as in?
or even better use events to detect when it changes
mainhand or in inventory
mye
and i need to detect if they have it in their inv
or you could listen to the inventory events and check if the item is the dragon egg
i have tried an arraylist, but that wont really work cuz when the server resets so does the arraylist
for the player uuid
wdym?
what is this for
i said i tried it
i think ur tryna do something
ngl I don't understand how you're structuring your plugin
that ur not explaining
It seems overly complex for something so simple
just explain what you're trying to do
I believe they're just trying to give a potion effect when the egg is in the inventory
At least that's what I understood from the previous conversations
you could just do a periodic check like every few secibds using a scheduler theres no point having a per-tick thing for a potion effect
alright, basically what ive been coding the past few days is an item (compass) that tracks the location of the dragon egg, it tracks if its in the players inv, it tracks the ground, it tracks containers, it tracks everything u can think of... but whenever u have the egg in ur inventory u get +100 exp levels making the item very valuable, but if u drop it, then u loose those levels. so i actually could make all those things work but i have one problem: if some 1 has the dragon egg and the server restarts, then after the restart that player will have another +100 levels since the arraylist got reset
and thats my problem
so i need a way to store the players uuid externally
Database or config?
i dont really have any experience with database so maybe ill go with config
actually i dont have experience in any of those lol...
so u need to use yml?
not need, it's just easy if you don't know how else to save ur data
theres an official spigot tut
Could even use pdc
oops
well yes
but you would have to remove it constantly from the person who used to have the egg
nvm u can
wdym?
A tutorial on how to do this async exists here:
https://www.spigotmc.org/threads/async-yaml-file-configuration-tutorial.474385/
Introduction
In this...
@vocal cloud's version also works
the 1 and 0 corresponds to true and false
without the need of a config file
No point in doing that
isn't that data persistent over server restarts
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
yeah but if theyre not using a file for anything else then theres not much point making a file system
I mean I still don't see why an array list is needed
or why you need to save anything
they want to know who has the dragon egg
I donโt see why that would change anything if the entire format is in the method except rebirths which is just a long.
to prevent them getting extra levels. You could just check if they have the egg on join
and don't add extra levels if they have it
Yeah you don't need file storage for that though
through the proxy?
redis and mongodb fun
for simple messaging you don't need mongodb
yeah ik lol
You could use that too but then you'd need to make a proxy plugin to pass along the data to each subserver
also it requires a player online to work
alright, so im just gonna read this and if i have any questions ill ask them here
Did you read this @serene sigil
no, thats why u use the arraylist is cuz i constantly loop though the players and see if they have the egg, if they do, and they are in the arraylist they will not receive +100 levels (cuz if i dont have the arraylist thing then it will constantly give them +100 levels)
Sync runnable but short handed
wdym?
have an UUID stored telling who has the egg
public static void checkegg() {
for (Player player1 : Bukkit.getOnlinePlayers()) {
if (player1.getInventory().contains(Material.DRAGON_EGG) && !eggHoler.contains(player1.getUniqueId())) {
player1.giveExpLevels(100);
eggHoler.add(player1.getUniqueId());
}
if (!player1.getInventory().contains(Material.DRAGON_EGG) && eggHoler.contains(player1.getUniqueId()) && player1.getInventory().getItemInOffHand().getType() != Material.DRAGON_EGG){
player1.giveExpLevels(-100);
eggHoler.remove(player1.getUniqueId());
}
}
}```
the code until now
eggHoler<UUID> (typo sry) is the arraylist
Guys, Can I ask there's a way to set the amount of item upper 64?
nvm i forgor i changed it to a hashset so there are no dupes
also the whole method checkEgg() is in a loop
You mean above the stack limit?
Yeah Exactly!
Short answer yes. Long answer you probably don't want to
is it too difficult ?
Stacks above 64 is kinda buggy.
Difficulty isn't the issue here. It's the fact of the matter which is that doing do so will produce unintentional side effects
in a constructor which is better practise?
- using the parameter to supply a variable
- using the newly assigned this.variable
for example
public RandomClass(DynamicCoordinates coords, etc..) {
this.coords = coords;
this.initialX = coords.getX(); // OR this.initialX = this.coords.getX();
}```
i dont really see the difference because in my experience both have worked
It's buggy because Minecraft doesn't have code to specifically allow it so when you modify it it will "work" for most things but there will be a lot of edge cases that do not.
Anyone know the issue?
Ahhh So There's a way, but It's not a right way Am I understand right?
There's a way to do it but it's going to result in a lot of potential bugs to which you may be unable to fix
thank you for answer! 100% get it
Here's a valid solution if you really need it
If you're having issues because the field is final, you can use Unsafe to modify it
is it support 1.19.2??
try it and see
Thanks for help ๐ I'll try it tomorrow!
why doesnt this work?
never seen a static event
error?
no it just doesnt show up
registered event
ye
add a debug to see if the event works
maybe you forgot to add config.yml or register it in the onenable
e
a
sports
i watched it in a tutorial and i do it every time
omfg
it doesnt do anything if not setting defaults
it returns
https://paste.md-5.net/retimakobi.pl Iโve got technical difficulties.
boolean
copyDefaults(bool)
Going to need the full error
what's the equivalent of this in code
i've got this but i'm not sure what extra does
you have to use packets
no i've used the inbuilt particles before lol
hu tagged me
ea
i say data, not data
nvm it says extra is speed
why is getting plugin instance better from a method than a variable?
That's not a valid format
?
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent