#help-development
1 messages · Page 1722 of 1
thats what i meant
basically to avoid making huge textcomponents and just have a formatted string
yo october 8th for me now
utc - 1
mines gmt+2 iirc
ye i live in south africa so its gmt+2
time is says mine is utc+2 or cest
can someone give me an incredibly stupid plugin idea
weed
:|
Blocks run away from you
Answer to this is probably no- but is it safe cancelling an event while in an async task?
also how do i see the output of an async task and run a sync task with that specific output
https://bukkit.org/threads/async-task-calling-sync-task-thread-safe.146476/
found this, i guess it works nvm
is it safe cancelling an event while in an async task?
By the time you cancel it in an async task, the event will have already been processed
Is it safe? Yes. Is it effective? No not at all
this seems good
Whats the best way to store server names as a list like hub Skyblock into a data base
im trying to do it as i want too store wheather or no a module is active on each server ETC
Anyhelp is appreciated
Your question doesn't really make sense
server names are set by editing the properties file, so you must already know the server name
also if you are using a bungee proxy you must already have added the names to the proxy, so again you already know the names
hm my laziness sometimes surprises me
so I need to map new durability values that are sort of similar to the vanilla mc ones
but, like, there's a lot of materials to cover
and config options
so
how about just doing some math on existing durability and calling it a day
say hello to (1000 - defaultDurability) / 1000
it never is but I have a ternary operator correcting for it anyway
Are we talking the default durability of vanilla items?
I assume this does not include tools then
Cast your meta
The class I linked?
there are no tools with more durability
are there?
im re-downloading jetbrains whatever it's called (ssd failure)
does it have remote git repo support or do i have to use the command line?
im not using github
hmm
I'll just run a different check for tools with an adjustment for 2k
man I never remember how damageable works
it counts up to the durability right
not down
1 damage means 1 away from full durability
https://paste.md-5.net/esonolowec.java let's see how close I got in my first try lol
oh wait
not close at all
I forgot what I was doing with these actually
https://paste.md-5.net/inozudebup.java ok now let's see
the damage get's count down. so for example:
you have a pickaxe with 500 base-durability.
if you set it's damage to 50, it's durability would be at 450
why tho? you set the damage, not the actual durability
No I get that
Suppose it's less NBT data if there's no damage on the tool, but we could otherwise have the luxury of setting alternative durabilities :((
i mean, minecraft has always been weird
ñ
How can i save custom configs withing Bungeecord any ideas cant see anything on google
migrating from eclipse to intellij what a nightmare
yikes
should make it faster :kekw
what an excellent idea
pain
how smart of me
appears you fear the blocks
Can pulling information from database without using async task cause lag?
Yes
Anything can cause lag if its not optimized
Is the best way to pull information from the database using asynctask?
Generally, yes
Doing it on the main thread would be worse
I did not understand
If you do anything involving databases on the main thread, the whole server has to wait until it is complete.
That’s how anything on the main thread works, but databases will take more time.
So I shouldn't put homes in asynchronous?
You should
When a player joins the server, you should asynchronously load their homes from the database and keep them cached
When they leave, remove them from the cache
If they create/delete a home, update the cache and perform an asynchronous update
oh
Any sort of IO operation, especially databases, do them async
Is it worth it to look into some sort of cache for database updates
When there is no possibility to use async, is there a problem?
Or should I just send them as they happen
No, sending as it happens is fine
And there's generally always an opportunity to perform operations asynchronously
Especially for homes because it's not required at all times
Again, loading when they join and caching prevents the need for a SELECT statement randomly on request
That too you would ideally keep a cache of
Unfortunately Vault isn't async-friendly so you really are SOL in that case
So should i remove my async?
In that case, maybe. Vault expects things to be run synchronously which is annoying
May be worth checking in on how economy is implemented in other open source plugins like Essentials
You can still cache everything though
Oh definitely. If done once you can cache and it's a hell of a lot less painful
I have a cache.
Though first run would hurt a bit
But this option is to set money for offline players.
Explains the somewhat heavy login event from essentials
Is saving cached data to the database after the player leaves a great idea?
Or it would be better to leave the data stored and every 5 minutes when there is an autosave, check if it is online and then remove it.
Well ask yourself this: do you need the database to be up-to-date at all times, or can you afford to be more lenient?
Both are good for me. I would like what has the least negative impact (lagg)
I disagree, it sounds like every 5 minutes would be preferable for them. A short, expected lag spike is certainly preferable to something a player can trigger, especially on larger servers.
Alternatively save it whenever it updates
You could also do both with a config variable that lets the server owner decide.
If you are able to save async there is no reason not to do it on update
But if you aren’t then you may want to consider the other option
it is allowed publish plugin with url shortner?
You don't have to get their offline player instance - you can simply invoke the regular method (Bukkit#getPlayer), check if its null then proceed into removing their cache as you usually would.
It's more efficient in that case iirc
hi im getting alot of errors
with this
idk spigot api.. i was watchin a plugin tutorial lol
Did you just copy and paste code?
yee.... and a bit of changes
i just watched the tutorial and followed it lol
i can send u it if needed
You should learn Java then start with spigot
i dont wanna learn it to make stuff rn... i was looking for a specific plugin
and found this
What were you looking for
dm's
Noted do NOT help ^
Goal is back door plugin
Hm?
Proof?
lmao
i just watched the tutorial and followed it lol
@gusty mica have you imported the spigot api via eclipe or maven?
You dont have any Spigot API packages
Eclips
What is best method for freeze a player ?
Give them a slowness effect or cancel their movement
you know, i thought about freezing with puting player to an array list and canceling move event, but cheking all players move event and array list is not optimized
and about slowness / speed, i don't want to player rotate his head too
This is the best way you're going to find
dont us an ArrayList, maybe a HashSet instead?
True that works
its just a player name or uuid, so i don't need hashmap
i thought about freezing player with spawning an npc, invisible and spect player into npc
but player can get out with shift
I didn’t say HashMap I said HashSet
And the problem with ArrayList is that it has an O(n) time complexity for its contains method
Meaning it isn’t scalable for what you’re doing
Well HashSets are essentially hashmaps
Yeah
HashSets are mostly used for duplicate sorting and o(1) access time. If you really know you wouldnt get any duplicate data and you dont need to access the data via object data, use arraylist or if its fixed size, primitive array,
Have you tried debugging the packet handler by adding message after instanceof clause?
Have you tried relogging?
Do you have any plugins that interfere with packets?
does anyone knows a bit of regex here?
i'm trying to remove all spaces, underscores and - characters from a string
i tried [\\ _-], "" but that doesnt seems to work
Hmm looks ok to me, assuming those are replaceAll arguments
Though idk if escaping space is required
Let's take my book from previous year
[\\ _-]+ works for me
You could always just do three replaces in a row, might even be faster
shouldn't you use \s also
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&bDiscord Invite Link Processing..."));
String message = ChatColor.translateAlternateColorCodes('&', "&b Discord Invite: <discord invite link will be here> ");
Bukkit.getScheduler().runTaskLater(DiscordCommand,message, 20);
return true;
}
``` how to make the String message send the message a bit late? i dont know if what i did with the scheduler is correct or not
maybe detect when they use it and then cancel the event?
e.setCancelled(true)
like that lol
lol
Isn't that also for tabs?
ye
Hey I tried to make a toggleable thing with the dragon egg but I think I got lost and my brain died does anyone know what I did wrong? https://pastebin.com/tLmFivEA
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
why use a burn after read
can i publish plugin with adfocus url shortner
you create a player object but continue to use e.getPlayer() in the rest of your code also
you should specify Player player = event.getPlayer(); and then after that just use player.blahblahblah instead, like you did on your player.sendMessage("you smell");
im not familiar w/ toggles as of yet tbh but just passing on the tip for the bit i saw right away that you could improve 🙂
your event is specified as e so for you, yes
personally i prefer something like public void onBreak(BlockBreakEvent event) { instead of just 'e' but it can be whatever
same, it technically makes no difference except i feel like it makes your code easier to read later on, by yourself and potentially others
where was that in his code?
am i blind o.o
oh lmao
I am dumb🥟
also, getItemInHand() is deprecated
People say that you need to know Java before coding plugins but do you know what level of Java you need to achieve before coding plugins?
Yeah Ik but it works
Ok its more readable I guess
personally i would rename your array as well
i find it kind of confusing personally might be just me
could make it like 'dragonplayer' or something
yeah just keeping future readability in mind
i dont see why the code wouldnt work @barren nacelle ```
public class ToggleEgg implements Listener {
ArrayList<Player> dragonplayer = new ArrayList<>();
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player player = e.getPlayer();
if (player.getInventory().getItemInMainHand().getType() == (Material.DRAGON_EGG)) {
if (dragonplayer.contains(player)) {
player.setAllowFlight(true);
player.setFlying(true);
player.setFlySpeed(10);
player.setHealth(50);
player.sendMessage("You smell");
dragonplayer.remove(player);
} else { //NOT dragonplayer
player.sendMessage("You suck");
player.setHealth(50);
dragonplayer.add(player);
}
}
}
@EventHandler
public void onDeath(PlayerDeathEvent e) {
Player player = e.getEntity();
if (dragonplayer.contains(player)) {
e.setDeathMessage("You died a dragon you suck");
}
}
}
i register mine in Main class, assuming he has one as well
typically i private Main plugin; public ExampleListenerClass(Main plugin) { this.plugin = plugin; }
and then
getServer().getPluginManager().registerEvents(new SQLLogger(this), this);
in the main class w/ an import
which i think is not-preferred? but whatevs
Don’t name your main class Main
Probably idk how to fix it tho
😛
So it works one way I just can't turn it off
`package server.core.one;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.DragonFireball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new ToggleEgg(), this);
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onIn1(PlayerInteractEvent e) {
if (e.getAction() == (Action.RIGHT_CLICK_AIR) || e.getAction() == (Action.RIGHT_CLICK_BLOCK)) {
if (e.getPlayer().getItemInHand() != null && e.getPlayer().getItemInHand().getType() == (Material.DRAGON_HEAD)) {
DragonFireball dragonfireball = e.getPlayer().launchProjectile(DragonFireball.class, e.getPlayer().getLocation().getDirection());
}
}}}`
Maybe I should of used paste bin
Can I ask a question about Gradle in here?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
Oh okay. When I want to use Gradle with Kotlin DSL in Intellij it always underlines everything. Ich have tried using different version of Intellij Idea, reinstalling Gradle and so on. I've also googled the problem but didn't find anything that helped me.
click on the Gradle button on the right side of IDEA
then, in the top left of that panel, click the refresh button
that fixes it most of the time for me
Doesn't do anything
have you tried restarting IDEA?
Yes
the problem probably is IDEA tho
considering it doesn't seem to recognize that the scope of the buildscript is a Project
have you tried invalidating the caches?
you can do so via File > Invalidate Caches... (File is in the top left)
that deletes all of IDEA's caches for the project and restarts IDEA
well, theoretically yeah
but you'd break a lot of shit
well you'd need to implement an event listener that listens for all cancellable events and then cancels them immediately
there isn't a generic way to do it since you can't find all classes that extend/implement a specific superclass/interface
i mostly use e cause its shorter and easier to write lol
I use e as it's conventional and looks nicer
but, as a Kotlin dev, I write the long names more often
yuh
where to download spigot
BuildTools
If you do that no one is going to be able to login
Latest ver: https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
Wiki if you need help: https://www.spigotmc.org/wiki/buildtools/
@swift creek
thanks
I think...?
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&bDiscord Invite Link Processing..."));
String message = ChatColor.translateAlternateColorCodes('&', "&bDiscord Invite: https://discord.gg/usNtXww9pD");
Bukkit.getScheduler().runTaskLater(Testing.getPlugin(Testing.class), () -> {
Bukkit.broadcastMessage(message);
}, 20);
return true;
}
``` guys how to make the discord link clickable? i tried to click it but its not clickable but if i send in chat it will be clickable
Did it just now and it didn't work
unfortunately a lot of events probably don't have superclasses
and
I think that would cause Spigot to listen to only an instance of the superclass instead of the subclasses
but that's impl logic that I don't know lol
you can find all cancellables via the javadocs
declaration: package: org.bukkit.event, interface: Cancellable
but uhhh
that's a lot of cancellable events
I'd recommend trying the superclass method on something like EntityEvent
and if that doesn't work
then
?xy
Asking about your attempted solution rather than your actual problem
feel free to suffer! :D
I don't think that'll work
I once tried to listen to all events by using the "super" classes but the events just weren't passed to the listeners
this plugin uses some kind of reflection thing I think to listen to all canceallable events -> https://www.spigotmc.org/resources/eventdebugger.82055/
snippets?
guys how to delete modules?
in my project, theres this thing now which i thought i was making a new project but instead did something else and now everything is broken down
i wanted to create a new project called Events but instead i made the events into the project i was in and now idk how to fix it
A Maven module you mean?
If so all you have to do is delete that project, and then in the parent pom.xml, remove the <modules> block
<modules>
<module>My plugin coding</module>
</modules>```
or something like that. You can just delete it
in the pomxml, its not what my old pom.xml is how to fix this?
You would now have two pom.xml's, one for the child, one for the parent
and there is no modules in the pomxml
Hi everyone I need an developer that can help the server from me if there are problems to fix it and also add plugings. Dm me if u want.
how to find the original?
theres only the pom.xml for the events thing
theres no pom.xml for my original project
yep that sounds about right
If I create a scoreboard via packets, will new joining players automatically get the scoreboard or do I have to resend all objectives/teams again?
i really need help, idk how to remove this Events thing in my plugin and it literally removed my plugin yml and stuff
Will you pay?
Doesn't matter
he also said he wouldn't
ye my bad
i just need an good dev but for free
so srr
I have many customers who are not even 15 :)
(what he actually means is he needs someone to setup plugins and check for bugs, so he needs a sysadmin lol)
There are usually no such ones :)
i know
ye
exactly
I'm not even accepting plugin commissions atm
Then either do it yourself or pay
not until I finish my framework
but even then they won't be free bc I need money for videogames
(speaking of which, my dead code eliminator may end up sucking the life out of me)
(I need to completely redo some parts of it)
(I am scared, someone please help me)
Hi
hi Conc
it's aight
just been playing some shit on my Switch instead of finishing my projects
the usual™️
Ah procrastination continues
replayed Undertale again since I saw we had it on there
Oo
I'm a master procrastinator
my family's had one since like
2 Christmases ago I think
we just don't have many games for it
it's mainly just the games my sister wants for it before she throws a fit bc she's 6 and doesn't know how to play videogames
example: Cuphead
What about #general 😋
Oh lel
are you a discord helper like Conclure?
Indeed, though generally fine as long as any questions take priority if ones are asked
what fuckin' hivemind did I end up in by accident
Everyone can help in something
then you are not actually cancelling the events, or your listeners are not registered correctly
?paste some actual code
where do you register it?
show
horrible static use but with that code there is no reason you can move items
also line 15 of main can be removed, its doing nothing
from that code, assuming you have no errors on startup, there is no reason you can move items
then it should be working. Perhaps you forgot to update the server with the jar?
there is nothign broken in that code
also, no point in final on your Main class
No idea, we only do spigot here
add some sysout to debug. Make sure the events are firing
try it on vanilla spigot
spigot
sorry, I was talking to morice
yes, spigot, not whatever you are using as a server
Is there an API to write/read schematic files?
Ok cool, and how do I access the StructureManager?
hm, it doesnt exist for some reason
what version are you on?
1.17
hm
this API is 3 days old
Oh
make sure your local maven cache is up to date
Well, how would you do it for older versions?
you are using 1.17 but not 1.17.1 ? xD
y
eeeh, well presumably you use WorldEdit API ? I don't know if there is any cute standalone library to read/write sponge schematics
I found a wiki page but its pretty superficial
meh
https://github.com/SpongePowered/Schematic-Specification is the official specs for sponge format
make your own
HAHAHA
whoops
Very nice, thankyou 👍
isn't it just a binary format?
I could probably make my own library
also maaaan it's been a while since I've seen the name "MCEdit"
this fortunately isn't mcedit format 🙏
it's built upon it
The goal of the Sponge Schematic Format is to improve upon the previous MCEdit Schematic Format to provide better forward compatibility and improve inter compatibility between different versions, platforms, and varyingly modded environments.
yea, but now we at least have a well documented standard xD
and yea, you could implement it yourself
half of it is just internal nbt
I mean, you don't actually have to do the writing
you are just constructing a huge compound tag
and using mojangs existing compression/writer to write it
wellllll
it's like
kinda different
does the name of the field actually matter?
if so, then it's just NBT
if not, then it's a custom format
I mean, you could definitely make this more efficient
on the other hand, not much need to do so
concerning these files never see the network besides an initial copy to the destination
it is pretty whatever
also (https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-3.md#format) confirms your sadness xD
Hello, I succesfully put the mojang mapping on nms but now the problem is that every classes changed and I don't know how, and what to do to send a packet (im in 1.17.1)
?paste
im using this code: https://paste.md-5.net/ikuceyuvop.java to create a circle using armor stands, but im getting this https://prnt.sc/1vbk1jt but i would like something like this https://prnt.sc/1vbk3on. Any help pls
this is more efficient
if (a < 10) {
return "something";
} else if (a < 20) {
return "something else";
} else {
"return nope";
}```
than this right?
```java
String str = "nope";
if (a < 10) {
str = "something";
} else if (a < 20) {
str = "something else";
}
return str;
return
if you are on this level of optimisation, you are probably missing a bunch of other low hanging fruits tho
no but my teacher doesnt allow me to use the first one
¯_(ツ)_/¯
say to him for me: fuck you
Was there a comment
felt that done that
On why you missed a point
If the first one is exactly what you submitted, you deserved a point off
"return nope";
true
it was for calculating something but its the same principe
there are 2pi radians in a circle, you will always be off by a small amount if you increment in 0.1F steps
correction: 1F steps which is even worse
so what i need to do
increment by 1/6 of 2pi each time
or just do it in degrees incrementing by 60deg and convert to rad before sin/cos
this?
the last statement of that for loop is where you increment the angle
you've just changed the bounds
a
?
got if after some seconds
your seperator should be (1/6)*2pi, not 1+1/6
you will get 6 equal angles of a circle
the 1 of 1/6 mean something like my separator or it is static?
nevermind I found the solution
hello. is it possible to choose a slot for a player somehow?
for nametagedits, when i add the group permissions on the group.yml it only shows with the owner rank even if im a lower one rank than owner (im using ultra permissions for the ranks btw) anyone know how to fix?
right now your separator is 1F, so you're incrementing the angle by 1 + 1/6F or 7/6F each time which is not 6 equal sections of a circle
but now I want to modify only the hat layer of a skin (not the first layer) how can I do?
actually 1 + 1 / 6 will be 1 + (1 / 6) 🤔
yes
which is 7/6
you mean something with player.getInventory().get(int)?
^
if you want 6 positions on a circle equidistant from each other along its circumference then you have to get those positions at equal angles around the circle
i wont have a static number
because i will change it based in something in the future
no, set the slot when logging in to the server. for example, there is a stone in 1 slot, a pickaxe in 2 slots. I need to put the slot on 1 when entering
so i want something that works for every number
since there are 2pi angles or 360deg then you need increments such that the sum of all of them equal 2pi or 360deg, but what you have right now is 1F which will never add to 2pi hence your offset
thanks
thanks, i just lost time trying to understand this
say it in simple words
hmm
addItem() does not give the item to the left hand, is it possible to fix it somehow?
set that slot?
I need to add 1 item if there is already one in the inventory
1 / number of items * 2pi
yes
the first one looks equally apart
rn my code is like this https://paste.md-5.net/esiyuvucic.java
let me increase the rad per sec
and you will see what i want to show better
for (ItemStack item : p.getInventory().getContents()
what are you actually doing?
are they supposed to be rotating along the circle each tick
if I hold the item in my left hand, it is not added
p.getInventory().addItem(item);
yes
but this is happening
in a low effect with lower RAD_PER_SEC
probably a spigot bug
the above is 15F
that is, do I need to additionally check if the object in the left hand is given in the left hand? else to inventory?
is there any reason why you add a seperator here RAD_PER_TICK * tick + SEPARATOR * i
yes, ctrl c ctrl v
you should be adding a constant angle to each armor stand for it to rotate about the centre
i dont think so
as i want them to rotate
so i need to change were the armor statnd will be
it looks like SEPARATOR * i is meant to be the original position of the armor stand, which is going to be wrong for the reasons we've already established
removing the * i the armor stands simply does not move
well it looks like SEPARATOR * i is supposed to be the original angle of the armor stand
but obviously the seperator is wrong
the way i would have done it is to keep the current angle of each stand somewhere and add a constant angle to it each tick, remembering to update the current angle each time
you should try with lower numbers than RAD_PER_SEC = 15f so you can actually see what is going on
2 and 6 share a common factor of 2, so you can write the angle as pi/3
the same effect but with a low speed
^
the point i was trying to communicate was that you need to increment by an equal factor of 2pi, i wanted to write 1/6 * 2pi but writing with a mouse is hard
is there any reason for this velocitystand.setVelocity(new Vector(1, 0, 0));?
well it looks like it's working as intended there
does it still go wild if you increase the rad per sec
is that a question?
yes
yes
you need to set your separator to 2 * PI / number of stands you want
tbh i'm just starting to think it's a bug with the client with high revolutions, because i've compiled it and testing it in game now as well
also applying a velocity doesnt seem to stop the stand falling at all if you increase the interval of the runnable
it still falls with AI set to false but there is a method setGravity which does exactly what we want
(on 1.17.1 at least)
actually the effect might not even be a bug, it might just be the client trying to interpolate the teleportations but since they are so drastic and constant they are interpolating across the circle instead of around it
maybe
yep, if you try to move too fast it will cut across the circle
why do you want it to spin so fast?
i was just testing
Is possible to get object what i need like getData(EServerData.Integer) without transform to int, but i dont know how to use generic with this :/
public Object getData(EServerData eServerData) {
try {
Connection connection = Westcore.getDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM wl_server_data WHERE server_data = ? LIMIT 1");
preparedStatement.setString(1, eServerData.name());
ResultSet resultSet = preparedStatement.executeQuery();
if(resultSet.next()) {
//Method to get data from the database by type
{
if (eServerData.getClassType().getClazz().equals(Integer.class)) {
return resultSet.getInt("int_data");
}
if (eServerData.getClassType().getClazz().equals(String.class)) {
return resultSet.getString("string_data");
}
if (eServerData.getClassType().getClazz().equals(Double.class)) {
return resultSet.getString("double_data");
}
if (eServerData.getClassType().getClazz().equals(Float.class)) {
return resultSet.getString("float_data");
}
if (eServerData.getClassType().getClazz().equals(Long.class)) {
return resultSet.getString("long_data");
}
if (eServerData.getClassType().getClazz().equals(Boolean.class)) {
return resultSet.getString("boolean_data");
}
}
}
connection.close();
preparedStatement.close();
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}```
Do I get it right and I need to use the original Mojang mapping when I want to use nms-code?
run buildtools?
ye
inside a ProjectileLaunchEvent for a blaze, for some reason it just wont give the new projectile the correct vector...
Map<String, Integer> enchants = (Map<String, Integer>) value;
Where does value come from
Also why is stringsutil an instance?
Hey! how can i add delay for closing inventory?
Cleaner then repetitive code
Utils are generally static
Not all methods in the class need it
Doesn't fix the issue.
Then why is it called util 🥴
Cause its still a class I utilize by other methods lol
if a player gets X blocks away from an armor stand i spawned with packets, the armorstand will disapear
and the x is entity tracking range
The idea of utility classes are that they should just contain a set of global stateless methods which by some sense are reasoned not to belong to an instance. With that being said any statefullness contained in a utility class is considered an anti pattern.
For your actual problem, have you debugged anything with tests or print statements?
Yeap
Returns 3.0 for looting instead of 3
Could someone help me?
elaborate
by "delay for closing inventory"
i mean
i have a code
a gui code
but with p.closeInventory();
it doesn't close it
and i want to try with delay
but idk how it works
Bukkit.getSchedular().runTaskLater(pluginInstance, () -> p.closeInventory(), 1);
something like that @acoustic pendant
@stone sinew taking a look rn
sends an error
If only the methods in ItemStack worked properly. I wouldn't need this.
with "pluginInstance"
also you probably want to just use
meta.getEnchants().entrySet().forEach(entry -> {enchantData.put(entry.getKey().getName(), entry.getValue().intValue());});
(hint the Number#intValue)
whats broken in ItemStack?
Same error
any one can explain how this text is warping
you have to actually get an instance of your main class (if you want i can show you how in call)
with line 73 also
it is like animated
pls 😄
The deserialize method doesn't function correctly.
General 1
73 | enchants.entrySet().forEach(enchantEntry -> item.addEnchantment(Enchantment.getByName(enchantEntry.getKey()), enchantEntry.getValue().intValue()));
yapperyaps
Yes... Same error
Okay if you just use Number instead of Integer
but still when quering and commanding the map use Number#intValue instead of (int) Number
Same error
hello
yeap
i want to spawn armor stands via packets
feels like you dont 😅
I do
i actually spawned it
but now i need to make them invisible
and display only the head
which packet do i need to use
they change the content of the sign I presume they use italic text decoration to make it wave
which is line 184?
73 on the pastebin
do u use plugman or reload?
God no
I have a fast PC?
hmm alr
I just restart the server lol
cuz the error seems irrelevant if you used the code I provided
Exactly. Thats what I am not understanding
Everything tells me its an integer but the server goes stupid and thinks its a double
send the class again if youre able to
maybe try using a
new HashMap<String,Integer>(){}
where the type will stay at runtime
so, after searching a bit and saw that i need to send this packet, but what the boolean means?
... Ok now it wants to work with Map<String, Number> WTF???
I tried this like 5+ mins ago lol
yeah weird
Welp. Thanks for the help. IDK why it doesn't work the first 5 times xD
conclure
do you know how to set an armorstand to the invisible mode using packets?
correct me if im wrong, but couldnt you just use ArmorStand#setVisible(false)?
no
interesting
You'd use entity metadata packet if im not wrong
yes
but i need to update the datawatcher
tried this and when the packet was sent it thrown a cast exception
wating int
so i sent as int
@ivory sleet i just exported my plugin and it didn't add the new code. I think it actually wasn't exporting and that was the issue. So yeah the jar might not have been updated lol
and it did nothing
ah fair and square
nvm
did it work?
yes
ah pog
didnt do a thing but happy it works :p
😎
👍
ok now i need to send the packet of the armor stand moving/teleporting
done
?paste
Wait nvm had the output under the wrong code 🤦 The integer thing I still don't know why that didn't work but works with Number so I'm not fucking with it xD
oh right lol
petition for
interface RequiresString {
String toString();
}
oo but why
generateChunkData() method in 1.17 spigot api is deprecated, which other should i use?
maybe a new keyword
explicit String toString();
must be implemented by the class inheriting
does not matter if the interface is implemented
every class extending / implementing it must have it
would be nice
oo yeah
static abstract T deserialize(Map<String, Object> data) 😔
static inheritance? 😮
yeah
just imagine
abstract class A {
public abstract synchronized explicit static void main(String[] args);
}
😂
public interface Serializable<T> {
Map<String, Object> serialize();
static T deserialize(Map<String, Object> data);
}```
yes.
Basically ConfigurationSerializable
why not just extract the serialization to a
interface Serializable<V> {
Map<String, Object> serialize(V value);
V deserialize(Map<String, Object> data);
}
interface SerializerProvider<V> {
Serializable<V> serializer();
}```
Then let classes derive SerializerProvider
@unreal quartz sorry for the ping
but i found the issue with the circles
actually not the issue
but the solution
im using packets to create and rotate the armorstands now
and it is static :D
i'm assuming that avoids the client interpolation then?
maybe
cool
How convert UUID player to name?
Bukkit.getOfflinePlayer(uuid).getName()
only works for players who at least joined the server once, otherwise getName returns null
yep if you want to get a name from a uuid without it being cached in your server then just pull it from the Mojang api @main dew
Does anyone have any code that makes the water give you some effect? :P
you mean applying a potion effect to a player when they're inside water?
How can i disable the recipe book? I already try to cancel the PacketPlayInRecipeSettings but it doesn't work. I dont want to remove the Recipes from the player. Its for a custom furnace inventory
Yes
Just loop over all online players (like, every tick, or every second, or how ever often you like), check if their getLocation().getBlock().getType == Material.WATER, and if yes, give them a potion effect
you could also use PlayerMoveEvent and check whether their getTo().getBlock().getType == WATER buuut that would stop them from getting effects when they stand still in water
@EventHandler
public void onMove(PlayerMoveEvent e) {
if (e.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == MATERIAL.WATER) {
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 400, 0, false, false, true));
}
}
something like that right?
I wouldnt use the MoveEvent because as said, that will stop them getting the effect when standing still in water
I'd use something like this
public void onEnable() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
if(player.isInWater()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 5,1));
}
}
},1L,1L);
}
isn't there a method like Entity#isInWater() ?
Ok thank you very much
np
how would i check on BlockPlaceEvent if a chest thats being placed, becomes a double chest?
if something exists, no need to reinvent the wheel 👍, and this helps code readability
also it's just a boolean on the vanilla entity so it doesnt have to convert any locations to blocks etc
hm only thing I could imagine is by checking it manually, like
- Is a chest already next to it, facing in the same direction?
- Is it a doublechest? If so, check the chest on the other side
- If that's a double chest too, this cannot become a double chest
- If a player shift-clicked, I think that prevents creating a double chest
Like, you basically have to recreate what the vanilla game's logic is for that I believe
if you don't need the result away, I'd simply wait one tick and check if the resulting block's state is now instanceof DoubleChest
it's not
no
nvm
the one i was using was depracated
oh, okay! thanks!
ignore this reply, see below
yeah that's the pre 1.13 version still using byte as data ^^
but why? two perfectly fine methods for it exist
declaration: package: org.bukkit, interface: World
its just that particular method signature @arctic moth is using lol
how do i prevent the spawn region from being ocean biome
actually MaterialData is the thing that's NOT deprecated
using bytes for data is deprecated and was replaced with BlockData and MaterialData
by using custom world generators, I don't think there's a nother possibility
oh indeed
yeah it is so u gotta use BlockData afaik
strange that spawnFallingBlock using MaterialData is not deprecated then
lol
anyway, you're fine with using BlockData, I promise 😄
they mustve forgot when making the library
xD
wait so how do u use blockdata
like it says string
it's actually already deprecated since 1.12 lol
lol
Bukkit.createBlockData(Material.CACTUS);
the material, unless you already have blockdata
like you could do Bukkit.createBlockData("minecraft:candle[candles=2,lit=true]"); to spawn two lit, falling candles
why does a spawned anvil not interact with the environment
it hits the ground and spawns the block but doesnt break or damage stuff
how do i get the block face?
anvils are very shy and tend to not do much interactions lol
of what?
wdym
of a block?
a blockface describes the relative position between two different blocks - what do you mean "the blockface of a block"?
no idea, let me try too
that's not the blockface, but the direction
a
get the blockstate and cast it to Directionable or however its called
oh sorry, BlockData not BlockState
lol
I always confuse blockstates and blockdata
is that happening to u?
I haven't started IntelliJ yet, wait a min pls
lol
k
for some reason when the anvil fell on a cactus it broke
nvm
lol
idk what happened then
so sometimes its breaking and sometimes its not
but not doing any damage
bro I died
how do I check if a chest (or another container was opened) without the open and close sound playing?
PlayerInteractEvent returns the clicked block, InventoryOpenEvent plays the sound when it's cancelled?? unless i am being dumb
also properly taking damage @arctic moth
what do you mean if it was opened without the sound playing?
the sound being played is simply a packet sent by the server
like whenever you open a chest or something, it plays the sound- i don't want that to ocuur when i open a chest
@tender shard why is it doing this
@EventHandler
public void onInteract(PlayerInteractEvent event) {
event.getPlayer().getLocation().getBlock().getRelative(0,20,0).setType(Material.ANVIL);
}
then cancel the InventoryOpenEvent and open the inventory manually
o
because you have other plugins that make you not take damage?
idk
ye
falling blocks are non-solid
o
they only turn solid when they hit the ground
just spawn a normal anvil using setBlock
why does it sometimes break when it hits ground tho
because falling blocks break when they land on certain blocks
like torches, cacti, ...
fences
...
but it did like the anvil breaking sound
don't you remember how people used torches to farm sand?
also it destroys cacti lol
the sound is controlled by the material
why do you need to spawn a falling block?
why don'T you simply set the block using setBlock?
lol if they are underground
it spawns a block
is there a way of detecting if a coordinate has a block
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event) {
event.setCancelled(true);
event.getPlayer().openInventory(event.getInventory());
}
BAsically just this (of course add checks whether it's a chest etc)
@EventHandler
public void InventoryOpen(InventoryOpenEvent event) {
InventoryType type = event.getInventory().getType();
if (type.equals(InventoryType.CHEST)) {
event.setCancelled(true);
}
}
This still plays the sound-
location.getBlock().getType().isAir()
let me check
unless i were to add this?
event.getPlayer().stopSound(SoundStop.named(Sound.BLOCK_CHEST_OPEN));?
okay the sound is triggered by the PlayerInteractEvent
cancel the PlayerInteractEvent and then open the inventory
depends on the other plugins of course^^
sad
just use it with a higher priority
ohh
so set my InventoryOpenEvent a higher priority compared to PlayerInteractEvent ?
oke
why do you think cancelling the interactevent would cause problems?
placing blocks etc
Placing blocks doesn't call a PlayerInteractEvent
You don't need any InventoryOpenEvent listener
oh, back to the docs i go
because it won't get called when you cancel the PlayerInteractEvent
Bukkit works like this:
so then- what do i make a higher priority?
- Player right-clicks block
--> Bukkit calls PlayerinteractEvent - Bukkit checks if that was cancelled, if so: do nothing
- Tell nearby players "Yo, a player interacted with a block", resulting in players hearing the open chest sound
- Now Bukkit calls an InventoryOpenEvent
--> If that's cancelled: do nothing - Bukkit opens the inventory
nothing, it doesn't change anything
well I'd probably use HIGHEST priority too and check if the event was already cancelled
but still, other plugins could also run on HIGHEST. Or on monitor and think "oh, the event was cancelled" although you actually intend to open the chest
oh, that makes a lot more sense on how bukkit works thanks!
np!
oh
yeah as said I'd use Highest too, because that you way the event will already be cancelled by most other plugins if they e.g. protect the chest
or
but a protection plugin could also use HIGHEST too, so it's random whether those can protect the chest or not when you simply cancel that event
use reflection and set your listener as the first listener of the list
you mean last? ^^
y
welp
because if it's the first, it will ignore every single protection plugin
:stonks:
what's actually the reason why you want to cancel the sound?
is it supposed to be for admins to silently open chests?
ye
oh yeah then fuck it
use LOWEST priority, cancel the event yourself and simply open the inv
why lowest now lmfao
because as admin, you do not care about protection plugins
You see, my idea was this:
oh wait, do lowest priority things get executed first?
- Player opens chest silently
- WorldGuard says "no, you must not" but the inv is already open
This happens when using lowest
yeah of course
Lowest is called first
oh, i am smart
Highest (actually Monitor) is called last
yeah it's because it means
the listeners on highest have the highest priority, so they have the last word whether the event gets cancelled
ohh
after that comes monitor, which COULD cancel the event too, but people will hate you if you do
lol
well, i did this-
@EventHandler
public void something(PlayerInteractEvent event) {
event.setCancelled(true);
}
and it prevents blocks from being placed :sip:
the event priority system is bad imo
they should all be equal
and why uncancel an event?
doesnt make sense to me
except monitor
some events are cancelled by default
like?
PlayerResurrectEvent
right click air
or idk if thats the correct name
thats never called
it is, but its default cancelled
declaration: package: org.bukkit.event.entity, class: EntityResurrectEvent
This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). For the purpose of avoiding doubt, this means that the event will only be in the cancelled state if it is fired as a result of some prediction made by the server where no subsequent code will run, rather than when the subsequent interaction activity (e.g. placing a block in an illegal position (BlockCanBuildEvent) will fail.
im trying to delete an anvil when it hits the ground using EntityBlockFormEvent but its not doing anything
yep that's the correct one
that gets called
@EventHandler
public void asd(EntityChangeBlockEvent event) {
if(event.getTo() != Material.ANVIL) return;
event.setCancelled(true);
event.getBlock().setType(Material.TNT);
}
it looks like custom fonts
oh
I'd say custom resource pack with custom fonts using a ton of mappings using some otherwise unused unicode letters? and a runnable to update the text
yep, it would take a LOT of fonts
it would be easier to render on a map
oki got it
I mean the color gradient is easy
I wonder if 1.17 exposes teh sign canvas
but the moving font is uugh
nope no sign canvas. has to be multiple fonts in a resource pack
or a modded client
or Photoshop 😛
magic
because the method is deprecated
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/EntityEquipment.html#setHelmet(org.bukkit.inventory.ItemStack) use this instead
declaration: package: org.bukkit.inventory, interface: EntityEquipment
but it works as well?
yes but it might not be working anymore tomorrow
remember when all plugins were broken when 1.13 was released? it's because 90% of developers ignored all the deprecation warnings they have been getting since years^^
so instead of that?
instead of that you can use the method I sent above