#help-development
1 messages · Page 1413 of 1
@bright yoke but this does not work it expects a ;
huh?
so in that loop, just teleport that someone
FileInputStream in = new FileInputStream(file);
ObjectInputStream objIn = new ObjectInputStream(in);
result.blocks = (Map<LocCoordinate, CustomBlock>)objIn.readObject();
intellij says im casting from Object to Map<LocCoordinate, CustomBlock> and highlights it yellow, is that normal with deserialising?
if (event.getCurrentItem().getType() == Material.BEDROCK) {
Player target = (Player) event.getWhoClicked();
Collection<Player> players = Bukkit.getOnlinePlayers();
Location location = target.getLocation();
for (Player someone : players) {
someone.sendMessage("§f" + target.getName() + "§a hat dich zu ihm teleportiert");
someone.teleport(location);
}
target.sendMessage("§aAlle Spieler wurden zu dir teleportiert");
target.closeInventory();
}
``` so it'd end up something like this
idk that language, im just guessing thats the right text
a bigger problem is that you're using ObjectInputStream
but yes generally with deserializing that usually pops up
yea ObjectInputStream is not going to be efficient in terms of space and speed
is it not just a bytestream?
i'd make my own serialize/deserialize methods
nah there's lots of metadata and it uses reflection, which is pretty slow in java
i have figured it out before you sent me this but thx 😄
so uh
the problem is I need to serialise ItemMeta
it can be serialised into Map<String, Object>
ItemStatcs are already serializable
yeah serialise gives Map<String, Object>, how do I turn that into a bytestream? I assume all the values should be serialisable (even if its not explicitly stated) but I don't know how to serialise an Object
aa this can be useful
look at the link
public static void write(File file, Map<LocCoordinate, CustomBlock> map) throws IOException {
try (DataOutputStream out = new DataOutputStream(new FileOutputStream(file))) {
out.writeInt(map.size());
for (Map.Entry<LocCoordinate, CustomBlock> entry : map.entrySet()) {
LocCoordinate coordinate = entry.getKey();
CustomBlock block = entry.getValue();
// Handle serializing these
out.writeInt(coordinate.getX());
out.writeInt(coordinate.getY());
out.writeInt(coordinate.getZ());
block.write(out);
}
}
}
public static Map<LocCoordinate, CustomBlock> read(File file) throws IOException {
try (DataInputStream in = new DataInputStream(new FileInputStream(file))) {
Map<LocCoordinate, CustomBlock> map = new HashMap<>();
int size = map.size();
for (int i = 0; i < size; i++) {
LocCoordinate coordinate = new LocCoordinate(in.readInt(), in.readInt(), in.readInt());
CustomBlock block = CustomBlock.read(in);
map.put(coordinate, block);
}
return map;
}
}
i havent touched bukkit in years, i forgot how itemstacks were serialized
is there a difference between using BukkitObjectOutputStream and DataOutputStream?
ah BukkitObjectInputStream
well yes
BukkitObjectInputStream will try to use the bukkit config serializers before defaulting to default java
then you'd have to add a public static CustomBlock read(DataInput in) throws IOException; method and a public void write(DataOutput out) throws IOException; method
I think for those I can use what Elgar linked 🙂
remember that ObjectInputStream is generally worse at everything
since it looks like BukkitObjectOutputStream.writeObject(ItemStack) works
and I guess same for ItemMeta
since its contained within a stack anyway
i would create a BukkitObjectOutputStream just for serializing an itemstack but continue using the data streams for everything else
okay, I'll give it a go, thanks both of you!
Location is serializable the same way. ItemMeta will be serialized with the ItemStack
im using a local location which is just 2 bytes and a short, plus the CustomBlock only stores an ItemMeta with no need for a stack, so it should be even easier 🙂
so if I pass one into BukkitObjectOutputStream that's how it serialises it?
yes
sweet
is it worth using GZIP to compress chunk data or is the cpu overhead not worth it
if i do player.getInventory() or player.getEquipment() with perworldinventory will i get the inventory or equipment of the world the player is currently in?
Its their current inventory inventories don't affect that.
so the one if the world they're in atm
Yes
ok thanks!
what should i extend if im making a custom player class
oh wow thats a lot of people typing
CraftPlayer but why don't do that
Probably wrap it instead? I mean kotlin on the flip side has some features such that you wouldn’t need to wrap it.
whats wrong with making a custom player class
The api is not made extendable, especially for CraftPlayer
I mean we have certain interfaces which are extendable but yeah
Yeah it's not designed to be implemented on your own
Better to just store a player reference
Hey, can someone help me with this error as i couldn’t understand the reason, im using playsound and it spits this error.
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
Caused by: java.lang.NoSuchFieldError: NOTE_BASS
TutorialListener.java:21
hmm does ChunkLoadedEvent not get called on spawn chunks?
@EventHandler
public void onItemHeld(PlayerItemHeldEvent event){
Player player = event.getPlayer();
int slot = event.getNewSlot();
if(player.getInventory().getItem(slot) != null && player.getInventory().getItem(slot).getType() == Material.STICK) {
// code here
}
}```
By default spawn chunks are kept in memory on server load
so they never receive a ChunkLoadedEvent?
not unless those chunks get unloaded
so I guess I need to manually call it for chunks loaded at world start
What are you trying to do?
read back from the file we wrote to
when a chunk is loaded, its appropriate file is read and it loads custom block data into memory
it works really well except for spawn chunks after restart
What do you do with this custom block data?
implement blocks with custom functionality
custom look or?
nope
they can just run custom code
I guess you could do custom look with armour stands tho
but that would be laggy
are these blocks passive unless interacted with?
so far yes but I plan to add ticking blocks too (for machines etc)
right now just testing that they can persistently store custom data and that is working well
i.e. if I have a block of silver with a randomly-assigned "quality" tag of 0.8, it does not re-roll the quality every time I mine it and put it back down
You can simply check after your plugin has loaded getWorld().getLoadedChunks()
sounds like that'll work, ty 🙂
After I learn Java will I still need to watch Youtube tutorials on how to make plugins?
I found the documentation and forum posts good enough
What forums posts?
didnt watch any videos, they tend to be not too concise in my experience
If you know java then you don’t need YouTube frankly
the bukkit/spigot forums have threads that pop up if you google your problems
hmm seems like WorldLoadEvent isn't getting called at startup
my plugin might be being enabled after the world is loaded
Register the listener onLoad
instead of onEnable?
Yeah
im getting this error:
[12:27:51] [Server thread/ERROR]: Plugin attempted to register kaktusz.kaktuszlogistics.world.WorldEventsListener@70e5599e while not enabled initializing KaktuszLogistics v1.0 (Is it up to date?)
org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register kaktusz.kaktuszlogistics.world.WorldEventsListener@70e5599e while not enabled
ohh I need to change the yml right
Just getWorlds() after your plugin is loaded, loop them to get the loaded chunks
ayy that works ty!
How do I get the effects of a potion itemstack? like if I have a lingering pot or a regular potion, how can I get a list of the effect objects
looked at the Deprecated Potion class but it did not work with lingering pots
tried PotionMeta potionMeta = (PotionMeta) item.getItemMeta(); and potionMeta.getCustomEffects but it always had nothing in it
suggestions?
all the spigot/bukkit forums posts are like 2017/2018
also looking for a way to get the potion effect of tipped arrows too but ill leave that for another day
Hello, GameProfile modifications are reset when i'm reconnecting please ?
you have to do the modifications again upon reconnection
Ok, thanks ! 😄
getBasePotionData? Looking at the PotionType javadocs but they do not seem to have a method to get the duration, list of effects, etc
potionMeta.getBasePotionData().getType(). //stuff here//```
suggestions?
Hello, how do i reopen a inventory after it is closed by a player
InventoryCloseEvent
ok ty
can we just cancel it
no
hey spigot people! can you gimme particleparm example?
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(**Here**, (float) (loc.getX() + x), (float) (loc.getY() + y), (float) (loc.getZ() + z), 0, 0, 0, 0, 1);
``` How to use particleparm?
```public <T extends ParticleParam> PacketPlayOutWorldParticles(T var0, boolean var1, double var2, double var4, double var6, float var8, float var9, float var10, float var11, int var12)``` It's method of packetplayoutworldparticles
T var0
btw, I know how to use generic type in java
Looks like the particle type or smtng no?
There is no reason to use packets for particles, use the damn api
Cannot resolve symbol 'senderName'
You need to instantiate the String out the if statements
String senderName;
if(asdka) {senderName = ""} else { senderName = ""}
getConfig()....
doesnt particles, spawned via the api, impact on the servers performance?
return true from your onCommand
hi i made a spigot forge server and its crashing
hi i made a spigot forge server and its crashing
and nobody was surprised
yes
hmm, I want to locate it.
Locate it?
How would I detect something like /mycommand -p (args) <--
The API has locations?
if args[0] equalsignorecase -p
wdym ?
It has a ton of overloads
The Damn API: .getLocation().getWorld().spawnParticle(Particle.CLOUD, dropBait.getLocation(), 5);
And packet:
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(**How to do**, true, (float) (loc.getX() + x), (float) (loc.getY() + y), (float) (loc.getZ() + z), 0, 0, 0, 0, 1);
what?
whats the difference
what
u dont need packets for particles
the api provides a bunch of ways to spawn them already
I just don't know how to fill in the first arg of the new PacketPlayOutWorldParticles.
[SpigotAV] Loaded class net.thearcanebrony.spigotav.Main from SpigotAV v1.0 which is not a depend, softdepend or loadbefore of this plugin.
something seems off there
why do u need to use the packet in the first place?
I want locate
the spawnParticle has
wait

I need packet to do something like this. https://www.spigotmc.org/threads/helix-tutorial-particle-effect-1.243363/
No you don’t
spawnParticle ?
hm my server hangs on plugin load
hey im back
can anyone help me figure it out?
and i deleted the mod
ill post code in a sec
and its still crashes
output:
seems to be getting stuck somewhere in here: https://gitlab.com/TheArcaneBrony/SpigotAV/-/blob/master/src/net/thearcanebrony/spigotav/HumanInterface.java
still the wrong channel
wrong server too? lol
Why is the ServerClients green and the other class is blue?
also 1.7.10
git
blue means uncommitted
ohh okay
if it's hanging on something, just take a jstack and see where it is
how can i take a jstack?
with jstack
how?
i have problem with my main class? i cant import it in all classes? it says not found or smth like that but it exists
have you tried importing it
yikes jstack lol
i did
it's not listed as an import in your screenshot
i click import class nothing happened
https://paste.md-5.net/iqehevibah.java
how do I get the weight of every item in this enum
import it manually i guess
its stuck on String.Replace?
it's probably repeatedly doing string.replace
try restarting the ide
it's 2021 but developers are retarded and can't make caches work properly
for (Ranks rank : Ranks.values()) {
int weight = rank.getWeight();
}
i think i found it lol
its me trying to replace colors
looking for prefix ~# but never actually replacing the prefix itself
ty
use Matcher
?
doing that manually is inefficient and dumb
never heard of Matcher
like the core class of java standard libraries when it comes to working with regular expressions and strings
my hex pattern is different but idk if its the best
this is mine
private static final Pattern HEX_PATTERN = Pattern.compile("&#([A-Fa-f0-9]{6})");
depending on the assumptions one makes about character ranges, either works
fair
how can i correctly use Matcher?
0-F might prove to have some issues if there are unexpected characters between 9 and A
you read the dox and then you invoke the right methods in the right order
(~#[0-9A-F]{6})
it's much easier to use on java9
this would be better no?
yes
also note to self, dont try to instantiate Matcher
yes, most of the regex related shit in java uses factory methods
i was hoping this'd work but no, cant instantiate Matcher: java new Matcher(Pattern.compile("~#[0-F]{6}"), text).replaceAll(matchResult -> new RGBColor(matchResult.group().substring(2)).getAnsiColor());
pattern.matcher
or match
i don't remember
and don't re-compile your pattern every time
precompute it and reuse the compiled pattern
also, instead of doing group().substring
define a group that only includes the characters you want
~#([0-F]{6})
ah
then just grab group(1)
Hello, it's possible to detect if a **Player **instance is the correct instance of the Player (not an old instance saved before re-connection of the player) please ?
player.isOnline would return false for such an instance probably
No :/
yeah that seems to match pretty well
Don;t store Player object. Store UUID and get teh player as required
but you never really want a situation to happen where you have stale player instances
always key stuff by either UUID or name and if you do hold onto player instances, evict and discard them on disconnect
Ok, I was not sure to do that but it seems the best solution
Thanks for your help and your time ! Have a nice day
what'd be the correct way to it with java 8?
you can't use the lambda thing
seems to work fine?
in java 8
so you would have to like create a string builder and manually pipe substrings of the original string into it with your replacements in between
yeah that'll blow up on 8
yeah
I thought Java 8 was the first version to have Lambdas?
it is yes
but in java 8 most of the standard library methods don't accept them as parameters yet
but it wasnt added everywhere at once lol
oh right i get that
f.e the replaceall thing that takes a lambda for Matcher was introduced in 9
fair enough, i didnt know that
before that you needed a while matcher.hasNext loop and manually juggling the substrings around
how can i iterate over all matches in a string?
like this
without the substringing
no i mean, with java 11
wut
replaceAll replaces all instances of the found pattern
meaning your lambda is called for each found instance
it's not exactly iteration, but your code does run for each match
find the keyword and then take all of the args after it
org.bukkit.plugin.InvalidPluginException: java.lang.IndexOutOfBoundsException: No group 1
maybe the first group is 0
although generally with regex the 0th group describes the entire match
i don't remember how java handles it, see the dox
oh like, its not couting ~# as a group?
ah
Hey I have an issue some classes sometimes don't of my custom plugins it's really weird, I don't ever reload, I always restart.
Caused by: java.lang.NoClassDefFoundError: nl/blackminetopia/minetopia/modules/player/gui/AdminToolGUI
at nl.blackminetopia.minetopia.modules.player.commands.AdminToolCommand.execute(AdminToolCommand.java:52) ~[?:?]
at nl.blackminetopia.minetopia.util.interfaces.CommandHandler$1.execute(CommandHandler.java:93) ~[?:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:152) ~[patched_1.12.2.jar:git-Paper-1618]
... 14 more
When I decompile the jar the class is really there I just think this is really weird.
are you using Eclipse
Nope I'm IntelliJ
Is it in the right package
Yes it is but the weird part is
when I restart my server it sometimes is gone or it just stays the same
after a few restarts it's gone I just really don't get it anymore
have been trying this out for weeks
classloading is hard
what could be the issue?
is it your plugin you are accessing or a separate plugin?
my plugin
all the classes are in your one plugin?
super difficult to try and diagnose classloading issues remotely
it could be that the class blew up while it was being initialized
make sure there are no static blocks or something that could explode in that class or the classes it refers to
Usually due to instancing classes at creation
Should I just send my class here I can show you
and make sure no other plugin is trying to access this class
?paste
just the class that is throwing this exception
how can I get the players cps
the class thats throwing the error and the class that is missing.
are you trying to rank 1.8 players in proficiency
Hey im looking to join a project. DM me if you are a new community looking to get off your feet.
What classes access this AdminToolGUI ?
uh
A lot
all the sub menus import it
and one Listener class
this is that Listener class
show your AdminToolCommand.java
Hello everyone, for storing IDs and relations in a database, would you recommend using the player UUID as a primary key ? (premium only)
Or would you rather create a generated and ID and associate the player UUID ?
you should use their horoscope as the primary key
Well, your code is quite a spiders nest. My best guess is something in your command handler/AdmintoolGUI is not being released onDisable.
I'm worried about the Microsoft Account Migration, i wonder if the UUIDs will change.
they probably won't
if they did, every server would be massively fucked
and you would have bigger issues than just your plugin database
Okay
guys, I’m going to repeat a problem that I was yesterday, but I don’t have time to solve
I suggest you use a paste tool
Well, i think you are right. Thanks
ConnectionSQL.loadAll().stream().forEach(e -> LootManager.loot.add(e)); this can my problem ?
Feels unnecessary to stream if the higher order function after that just is forEach and btw method reference is possible there if I’m not wrong?
yes i know of it
Same as yesterday. Your lootManager is providing a null location at some point
I was doing some tests
How can I get the cps of the playert
public static void spawnLoot(Location local, ItemStack item) {
#line 67 ArmorStand armor = local.getWorld().spawn(local, ArmorStand.class);
}```
You count it yourself
I debugged and saw that the location was not null and neither the item stack
i don't know if because I gave a for each to add everything to the hash, and when I use the runnable it may be that I haven't loaded all the data
The interact event would work
If you want to be fancy you would listen for the packets
^^
exactly
fancy not really, just more accurate
does anyone have an idea why all of my text is dark gray?
How will I store that varuable forever?
how
what is the raw string result
You're in basic java territory now. Might want to learn that first
I know how to store a varuable but not how to store a varuable after a restart
config
Learn sql, or json or whatever
if you just want to have the CPS(Clicks per second), store it in a HashMap or OOP. <UUID, Integer>. Clear it every second. If you want to have it persist, use a database, file system or something similar
Ah you want persistant data storage
Ideally don’t persist in yml
i did a thing like that but more advanced for redstone per second lol
one of my plugins fully concentrates on the CPS of a player^^
im storing based on current tick, and averaging the last 20 ticks
use a rolling average
what is the raw string output
its using ansi color
yes but what is the raw string output
and what is the raw string input
i should probably log that..
one second
this is the colors it instantiates:
my color test seems to work fine
Wow nice one
Just, what's the point of that ?
console spamm
testing my color system
Okok 👍
In my code Prefix is defined in a for statement. How can I use it outside of the for statement
for(String arg : args) {
if (arg.contains("-p")) {
Bukkit.broadcastMessage(ChatColor.RED + arg);
Prefix = arg.replace("-p", "");
Bukkit.broadcastMessage(ChatColor.BLUE + Prefix);
}
if (arg.contains("-s")) {
Bukkit.broadcastMessage(ChatColor.RED + arg);
Suffix = arg.replace("-s", "");
Bukkit.broadcastMessage(ChatColor.BLUE + Suffix);
}
}
// Send Broadcast
Bukkit.broadcastMessage(Prefix + messageToBroacast + Suffix); // I want to use Prefix here !
by initiating it outside the loop
how can i have an unsigned byte?
you could just use an int instead
fair
inside the if statement, Prefix doesnt contain -p whereas outside the if statement is does contain -p
just doesnt make sense in my head to represent the 3 color channels als integers
as in like, a waste of memory lol
just perform your math operations on the byte after you've cast it to int and masked with & 0xFF
and then trim back to byte
yeah and you have to do something like
String prefix, suffix;
for(asdwasd) {prefix = "BLA"; suffix="BRA"}
sendToConsole(prefix + "BMA" + suffix);
or do i get it wrong what you try to achieve?
that said you don't need to do that for + operations, and for - operations only if your unsigned byte is the right hand operand
String Prefix;
String Suffix;
Prefix = getConfig().getString("Prefix");
Prefix = ChatColor.translateAlternateColorCodes('&', Prefix);
Suffix = getConfig().getString("Suffix").replace("%sender%", senderName);
Suffix = ChatColor.translateAlternateColorCodes('&', Suffix);
// Custom Pre/Suffix
for(String arg : args) {
if (arg.contains("-p")) {
Bukkit.broadcastMessage(ChatColor.RED + arg);
Prefix = arg.replace("-p", "");
Bukkit.broadcastMessage(ChatColor.BLUE + Prefix);
}
if (arg.contains("-s")) {
Bukkit.broadcastMessage(ChatColor.RED + arg);
Suffix = arg.replace("-s", "");
Bukkit.broadcastMessage(ChatColor.BLUE + Suffix);
}
}
// Send Broadcast
Bukkit.broadcastMessage(Prefix + messageToBroacast + Suffix);```
and what are you trying to achieve? btw your if's are unnecressary if you don't want to keep the broadcast inside them
no idea
yes
i think so
pretty
yatopia
@limpid veldt ^
thanks now i have an epileptical attack
die
the purpur devs have stepped into the room with bats
afaik theres purpr devs in their discord lol
There is a default pre/suffix in the command. But if you use -p or -s it will replace the pre/suffix with what ever you have after -p or -s. If you are using a custom pre/suffix it will remove -s or -p and keep whats after it
@EventHandler
public void PlayerInteractEvent(final PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
final Player player = event.getPlayer();
final Location eye = player.getEyeLocation();
final Vector direction = eye.getDirection().multiply(10);
final Location ping = FinalCatch(eye, direction).add(0, -1.5, 0);
getClosest(ping, 0.5).ifPresent(e -> Bukkit.broadcastMessage(e.toString()));
ping.getWorld().spawnParticle(Particle.END_ROD, ping.add(0, 1.5, 0), 0, 0, 0, 0);
}
}```
in the execution of this code is it possible that it is called twice?
once for each hand
This obviously shouldnt look like that
how do i get it to run once
you ignore the second run
but how ?
check the hand
with logic
checking a hand ?
pos1
method();
goto pos1;
Plugman 🎈
Tbf same
all of plugins installed on test server has javaassist warning or something.
why's that?
because theyre all malware
lol
but yes, i intentionally installed malware on my server
really?
yep
so my server have a malware right now
i mean the mc plugin yeah
but it doesn't change anything in-game.
i don't see any effects
SpaceDash which one is the malplugin?
Oh thought there was one plugin which injected the rafael stuff into other plugins
Ah
Does anyone know how can I remove NPC from tablist?
My code to initialize NPC packets:
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw * 256 / 360)));```
how do i get the cpu load and usage in bungee?
didn't we already answered this question yesterday
idk
how would i do something every 10 kills
ty
store the kills somewhere and if the current kill is the 10th in a row, do you thing
how do i get the cpu load?
i have a kill counter already but its the exact amount of kills and doesnt reset
show the kill counter
it adds every time you get a kill to a mongodb document
so just make another one that counts kills in a row
or just store the kill count local, add it every 10th kill to your mongodb, reset it and do your thing
Would you guys say it is a bad idea to send any OP user a ingame message if the plugin is outdated everytime they join?
depend on permissions
and add a config setting to turn it off
other than that it's fine
ok thanks, cause theres a bunch of servers using quite outdated versions so yeah
How do I get the effects/strength/duration a potion has from an itemstack?
The Potion class was deprecated and does not work for lingering pots
that's just a symptom of quite a few servers being run by tards
also why on earth would you install malware on your server
quick question, what exactly do you mean by this?
add a seperate permission or just check if the user has op permissions
leave your update messages in the logs. Its annoying to be harassed.
That's what I thought too. However a) admins don't look at logs too carefully and b) a config setting to turn it on/off should be quite ok, no?
If they don;t look at the logs they should not be running a server
🤷♂️
Mind telling that to 80% of all the servers that run my plugin and use a version that is 3 months old? lol
Eh I'll just leave the setting off as default in the config, if anyone wants it they can turn it on I guess
If they are using a 3 month old version, it works for them. They don;t need harassing
Notify in teh logs so they see it when they decide to update
anyone got suggestions on this? PotionMeta aint really working
how do i get max storage of spigot server?
the same way you would get the max storage of any environment
it's a system/environment property, not something specific to the minecraft server application or spigot
anyone happen to know if scraping data from the spigot website is against spigot TOS? I'd like to collect data to get some basic dl trends but not if it is against the rules
not site-wide, just for my projects
@torn shuttle Use the API: https://github.com/SpigotMC/XenforoResourceManagerAPI
yeah using that is fine and has download data aswell
And scraping data from the website is most likely against tos lol
yeah all I want to know is the daily dl rate
How use FernFlower Decompiler?
intellij has it built in
easy way:
- rename the .jar to a .zip extension
- navigate to the .class file and double click it
- intellij does the rest
with this I have problem (idea decompiler isn't perfect)
its close enough for most things
or use luyten or jd-gui
occasionally converts foreach into Iterators and while loops but apart from that its great for stealing source code fixing dead plugins
gaze upon my class name and despair EnderDragonPotionBombardmentConfig
long ass class name
still better than VillagePlace
are they better than the built in fernflower in intellij?
yes
does anyone know if there an API to query what these values are set to in spigot.yml?
attribute:
maxHealth:
max: 2048.0
movementSpeed:
max: 2048.0
attackDamage:
max: 2048.0```
which one is better
i use luyten mostly
So need suggestion I am making tools need specific list of enchants to execute code
what would be the best way if tool has all enchant which are on white list
just for loop
and if one is false brake loop and return
Bukkit.getServer().spigot().getConfig().getDouble("settings.attribute.maxHealth.max")
Thanks!
np, it's one of the first lines in my plugin which I just happened to have open
also have code to change it if you want it
that's ok, I just needed to know the value. Until today I thought it was a hard-coded value and I had my plugin never allow more than 2048 max health to prevent an exception
it's not hard coded and a lot of people run with values under it
I bump it up to 10mil
Hello !
I'm trying to make a class that allows you to redo some small spigot features on the configurations (like the SaveDefaultConfig () method).
Do you have any idea how I will be able to check if the configuration sections in the plugin match those in the plugin file?
as in scan for changes?
not really
I just want to be able to add non-existing section configurations to avoid getting a "nullpointerexception" when I add configuration options
something like
use defaults
defaults ?
configurations have defaults
yeah defaults are a key feature for these
if a value is absent in the user-provided file, the default value is used
the defaults are loaded from the config.yml you bundle in your jar
you can also save defaults pretty decently
you can also manually set defaults with the methods on ConfigurationSection
it will write to file if it doesn't exist but will use existing values if it does
just keep in mind that saving configs in any way will nuke all comments
So I have to do something like this ?
hm
load the bundled resource as a yaml configuration
there is a method to bulk-set defaults from an existing configuration section
use that to apply all of the contents of your bundled messages.yml as defaults
do you want my configuration engine
Oh 🤔
yes
load the bundled resource as a configuration, then load the user-provided file on disk as a configuration
then apply the contents of the former as defaults to the latter
Well, if you agree to share it with me, I don't say no :x ♥
that's basically what bukkit does with config.yml under the hood
damned previews
sure
not claiming it's perfect but it works really well for me and my need to create hundreds of config files
that wasn't a joke
I just counted, my production server has 660 config files for my one plugin
add 6 more
devilish
How can you need 600+ config files for one plugin ? x_x'
it's a boss plugin and each boss has a config file
Aaaaaah
and each piece of custom loot has a config file
ok now i understand xD
Another question, I know how to edit a file from the plugin folder, but how I can edit a file from the plugin himself ?
For example, let's say I want to do a playerdata in the plugin itself (like essentials). How to get this file and then edit it?
I don't understand what method i should use
it's not as bad as it used to be since now they work based off of blueprints and no longer require 1 file per individual mob since they can put multiple locations on a single file
which is good because there's thousands of them now
DUDE YOUR CONFIGURATIONENGINE IS SO UNBELEIVABLE !!
Well done !!
lemme try
For someone of my level, I find it incredible
be careful about which file saver you use, only defaults will erase any non-default values and custom values will let you use whatever is on the file
how can I get the item that is being dropped in BlockBreakEvent?
are you close to yourself
iterate through the result
compare the entity to the player
pass it a Predicate that doesn't accept players
for (Entity entity : player.getNearbyEntities(player.getLocation(), 5, 5, 5){if (player.equals(entity)) {...}}
think that should probably work
player.getWorld().getNearbyEntities(player.getLocation(), 5, 5, 5, e -> !player.equals(e)) probably works better
following NNY's suggestion
You can get the block break and then get drops
or for (Entity entity : player.getNearbyEntities(player.getLocation(), 5, 5, 5, (e) -> !(e instanceof Player)) {...}
the former only discounts the player
the latter discounts all players
Though I figure BlockDropItemEvent would be easier
cool
Depending on what you need to do 🤷♂️
should do it https://paste.md-5.net/dudacilebo.cs
pretty sure entities can't be null there
oh sorry all is a player
with what
mind you if you are scanning for the lack of entities none of these are what you want to do lol
also keep in mind dropped items are entities
and armor stands and stuff
probably want to instanceof livingentity if you don't want stuff like items or paintings
that said armorstands are fucking living entities for some reason
Another question, I know how to edit a file from the plugin folder, but how I can edit a file from the plugin himself ?
For example, let's say I want to do a playerdata in the plugin itself (like essentials). How to get this file and then edit it?
I don't understand what method i should use
YamlConfiguration.loadFromFile(File file) or something
Does it work for a file inside the plugin?
yes
boolean hotSinglesInYourArea = false;
for (Entity entity : player.getNearbyEntities(player.getLocation(), 5, 5, 5){
if (entity.equals(player)
continue;
if (entity instanceof LivingEntity){
hotSinglesInYourArea = true;
break;
}
if (hotSinglesInYourArea){
awooga();
}
}
you don't want to be reading and writing into your plugin jar at runtime
the whole thing will explode
oh
How does Essentials work then?
There was a time when they stored everything inside the plugin I think
no
player.getWorld().getNearbyEntities(player.getLocation(), 5, 5, 5, e -> !player.equals(e)).isEmpty()
wait, that's illegal
yes
just keep in mind that it will return false if there is literally anything
including but not limited to paintings, invisible armor stands, area of effect clouds, xp orbs and more
Is there some utility to damage an item without having to re-code all the unbreaking logic etc?
is there way of checking the depth of getKeys true?
i dont know the player id and i cant get it
i do know tho the format
so its always this
playerID:
'1': 5
'4': 12
OtherPlayerId:
'2': 6
'2': 10```
theres activeBeds . a player id wich i dont know . 1 , 2,3, etc the amount of beds the player has
what are you doing
so if depth of the key is 2 (wich means that its activeBeds(0),playerID(1).num(2)) then edit it
what
literally what are you saying
cuz its the id of the player and i need to edit all players in the config file
hahahha idk how to explain better than that
iterate over all of the keys
i have activeBeds wich have playersID and each player has X amount of numbers
getKeys(true) is like entirely useless unless you want to print the contents of the config to console or something
if you want to iterate over all of the players in your config, go to the ConfigurationSection that contains them, and call getKeys(false)
each of the returned keys will point to a ConfigurationSection that holds whatever you've put in it
boy this is probably not a good way of doing this lol
it looks like you should know what the ids are so you can just do a get for the value and see if it's null
how do i change spigot messages like bungee has the messages.properties file?
can I get the item from BlockBreakEvent or will I have to spawn it myself
you should use e.getBlockState @lusty cipher
that has literally nothing to do with my question
what is your question?
you did not specify which item
there are multiple items involved
There's only one item (type) that is being dropped. The other thing is called a block
there is:
the item being dropped
the item corresponding to the block itself
the item in the player's hand
Is there a way to set a scoreboard in a specific area? I already did the scoreboard, I only need the area stuff
you'll have to scan where players are but it is feasible
assign the scoreboard when they enter, remove it when they leave
Wrong event, would've been https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockBreakEvent.html lol
declaration: package: org.bukkit.event.block, class: BlockBreakEvent
I know but I want to set the Area in the Scoteboard. As example: Area: Auction House
Not the wrong event. you want the drops
But I guess the answer is: I'll have to spawn the items myself
Yes wrong event because I asked for BlockBreakEvent
drops in bukkit are fucked
like have the scoreboard report where the player is?
for(String Key : String.valueOf(Objects.requireNonNull(Main.get().getConfig().getConfigurationSection("activeBeds")).getKeys(false))){
}```
why did this work yesterday and not today?
I need the block state, which is an air block in the other event
Yes
spnda if you want help you should consider showing some basic respect to those you're asking to help you
since when i cant use foreach in strings
what
Then your answer is No you can not get the drops from the BlockBreakEvent, only in the BlockDropItemEvent
yeah it's fairly easy, you are making a plugin right
again, literally what
not asking for support for featherboard or smth
No lol my own
you are calling String.valueOf on a Set
or a List
or whatever
and then trying to iterate over that String as if it were a Set or a List
String.valueOf makes things into strings
you can't iterate over a String
well first you'll have to define a bunch of regions, then it's as simple as checking where the player is when they get the board and making sure that you construct it with the adequate string for the location
a String is not a Collection, it's not Iterable
But how do I define these regions?
that's really up to you
if we're talking the easiest possible way do something like xMax xMin zMax zMin populate it with numbers and then check if the player's location is contained within that
or depend on WorldGuard
Ok
I quote the message you replied on:
which is an air block
if you want a fast way to check if a player is in some area you may consider looking into Quadtrees
to minimise how many areas you iterate through
Read teh javadocs, it says it will be AIR
depends on how many areas you have
Ok
4-5
It says it will be the state before the block is destroyed
Yes I know, why am I getting a link to the thing that confirms my statement again?
lol
Gets the BlockState of the block involved in this event before it was broken.
what are you even arguing about
The Block is already broken as this event is called, so #getBlock() will be AIR in most cases. Use #getBlockState() for more Information about the broken block.
are you sure you didn't call e.getBlock().getState
you wont need a quadtree for that then
just store a sparse list of AABBs, then iterate over them and check if player coords are within the bounds
if you can find a decent resource or a guide on worldguard without having a fucking aneurysm, you could maybe just depend on worldguard
saves you the effort of managing the configuration and defining of regions
and lets end users use a familiar way to define them
Im getting this error, https://paste.md-5.net/gododitura.cs this is the event https://paste.md-5.net/utukozomih.cs
looks like an incomplete stacktrace. Anything past this ?
nope just that
try like removing some code and try to see which thing causes it
There is more to that error. There is no plugin mentioned there at all
you wanna look for something along the lines of caused by Exception after that stacktrace
maybe check further up the log, some loggers tend to shorten these if configured incorrectly
doing db queries on inventory click event
who knows, maybe it is cached :>
oh its that Caused by: java.lang.NullPointerException at cc.solarpvp.solarkitpvp.mongodb.MongoDB.getLevel(MongoDB.java:157) ~[?:?] at cc.solarpvp.solarkitpvp.SolarKitPvP.loadEmeraldKit(SolarKitPvP.java:100) ~[?:?] at cc.solarpvp.solarkitpvp.event.MenuListener.onClick(MenuListener.java:29) ~[?:?] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[?:?] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-db6de12-18fbb24] ... 15 more
is that a bad thing?
👀
yes
whats on line 157 in MongoDB.java
db queries are potentially very slow
how can i get the location of a player who isn't on
why am I getting a NPE in a line# that is in a fucking javadoc comment
thats the whole method public int getDeaths(String uuid) { Document document = new Document("UUID", uuid); Document found = getPlayerInfo().find(document).first(); if(found != null) { Document var1 = new Document("UUID", uuid); return var1.getInteger("deaths"); } return 0; }
and what is the 157 line
its the return var1.getInteger
and does the "deaths" exist in mongodb collection?
is there a way to make custom mob animal tamer?
a what
custom nms mob
?paste
how can i send a player a message when the player clicks a specific head?
just do playerinteract event and check for the head
but how to check for the head?
for the specific head? by the name or what?
@quaint mantle
get its itemstack check its material if its skull and then get the item meta convert it into skullmeta and get the owning player and then check if the owning player is the name u want
texture
not the owner this is the Porblem
problem
how can i check the texture? @wraith rapids
how from the skull?
you can get it from like the gameprofile or something
i don't remember how you do it on spigot
easier on paper
okay
could use smth like this: https://paste.md-5.net/umihojadoy.cs
thx 😄
I try decompile .jar use FernFlower decompilator. Who can help me?
I added item damage logic myself but the item does not automatically break when its durability falls to 0
instead if goes negative
is there a way to call the item break event
you could just remove the item ig
yeah I could do that, play the sound and do the particles
yeah
thought there might be an inbuilt way
how do I get the correct location for particles?
i'm sure there is a way to call that properly
so I have a custom item called the wither sword, to craft it you need 2 nether stars and a netherite sword, how can I make the custom item have the same enchantments as whatever sword was used to craft it?
you copy them in the CraftItemEvent
the way how it'd be implemented internally would be through the ComplexRecipe or whatever that was called
k
but that's not intended for implementation by plugins
so you just need to hack around it
in the event, yes
^ anyone?
Is that your plugin
Yes?
And how i set my mob animal tamer?
You cast your mob to the entity type it is and then set the owner
Hi my plugin cant reach too messages? they are just blank but theyre not null?
Couls you show your code and what it sends
It’s what i did in the code
The entity appears to be casted to or is a skeleton
They cannot be tamed
I try to tame an horse with a custom mob skeleton
And there is a way to male mobs tame horse?
If I place gravel now why doesn't it stay in the air?
@EventHandler
public void onPhysics(BlockPhysicsEvent event ) {
event.setCancelled(true);
}```
Try watching the EntityChangeBlockEvent instead
for (UUID member : sgPlayer.getParty().getMembers()) {
OfflinePlayer memberPlayer = Bukkit.getOfflinePlayer(member);
if (memberPlayer.isOnline()) {
Bukkit.getPlayer(member).sendMessage(ChatColor.BLUE + "bababooey");
}
}```
is this a good way of doing things?
you can just memberPlayer.getPlayer()
oh, didn't know that.
because Bukkit.getPlayer(uuid) will return null if the player isn't online right
and if you are doing that check for every message it seems a bit inefficient
maybe cache the online members for each party or something
It's a partychat command
getOfflinePlayer can make a network request to mojang api to figure out the name and stuff of that player
which can take a long time
I'd hold a map <PartyUUID, Set<Player>> and on message get the right set and send the message to everyone
ideally each Party object would have a Set of online players in a field somewhere
but that'll go to shit when the player logs off right
you'd maintain them with the join/quit events
no, because on login and logout you just update the map
its a UUID lookup for OfflinePlayer. That shoudl not perform a Mojang lookup
iirc there's a line on the dox that says it can ring up mojang api
otherwise it won't know the offlineplayer's name
I thought it only rings up that api call when the player has never logged in
Yeah thats correct nny
paper has a getOfflinePlayerIfCached method which doesn't do that call
Only if you lookup by name
but it will return null if the uuid-name isn't cached
a lookup by UUID is only local
I mean getOfflinePlayer(UUID) never calls it but getOfflinePlayer(String) may make the request because to both methods an offline player for every name/uuid will exist
It will always return an OfflinePlayer but the name will be null if its unknown
right now this is what I've got for the command itself
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
Player p = (Player) sender;
if (args.length == 0) {
p.sendMessage(ChatColor.RED + "Invalid message. /pc <message>");
return true;
}
BlitzSGPlayer sgPlayer = BlitzSG.getInstance().getBlitzSGPlayerManager().getBsgPlayer(p.getUniqueId());
if (sgPlayer.getParty() == null) {
p.sendMessage(ChatColor.RED + "You're not part of a party.");
return true;
}
for (UUID member : sgPlayer.getParty().getMembers()) {
OfflinePlayer memberPlayer = Bukkit.getOfflinePlayer(member);
if (memberPlayer.isOnline()) {
memberPlayer.getPlayer().sendMessage(ChatColor.BLUE + "Party > " + sgPlayer.getRank(true).getPrefix() + p.getName() + (sgPlayer.getRank(true).getPrefix().equalsIgnoreCase(ChatColor.GRAY + "") ? ChatColor.GRAY + ": " : ChatColor.WHITE + ": ") + joined(args).replaceAll("%", "%%"));
}
}
return true;
}```
The caching thing will probably also work but oh well
Thats fine as you are using UUIDs, but I'd move the definition OfflinePlayer memberPlayer out of the for loop
I'd also construct the message once and send it each time.
Yep I just did that
but how would I retrieve the OfflinePlayer from the UUID without Bukkit.getOfflinePlayer
you use Bukkit.getOfflinePlayer(UUID)
It won;lt query Mojang and you will always get an Object back
your test for isOnline is all you need
how i can set a player automatically ride an horse ?
but that's what i'm doing right now isn't it
oh
yeah you said you'd move the definition of it outside of the for loop
so I thought you were suggesting another way of doing this
yes, define it before so you are just assigning a value each iteration
defined in the loop you are creating a new instance every iteration
Yeah that's what it's supposed to do, it's assigning the iterated value
define before for loop with OfflinePlayer memberPlayer;
Ohhh.
in the loop you do memberPlayer = Bukkit.getOffline
Right right
Is that even an improvement?
nevermind, you're 100% right.
thanks Elgar
there is a task to translate the name of the subject into another language. Is there any way to do this using the game if I initially get the name in the form of a string?
whats a fancy way of setting a gui size based on a number? like if the number is 4 then the gui size set to 9, but if the number is 23 then the gui size has to be 27
i dont wanna do if else etc
Math
size + (9 - (size % 9))
idk if that will work
but something like that
Size <#help-development message>
haha nice
I saw that, XP bar and hotbar differently sending by server, or whatever you call it. Then is it possible to use XP bar in creative mode?
I don't think so, I saw a thread in SpigotMC but I couldn't find it
but easiest example is on Hypixel. there are previews for cosmetics, when you preview them, it puts you to first person spectator mode and then your inventory goes. after you leave the preview mode, firstly your xp bar comes and then your hotbar/heart/food bar comes.
How can I lock the head with a specific texture on creative?
what
I want block skull with name "Raymano"
Cast item meta to SkullMeta and set the owner
oh wait it's a block?
or just the item?
yea but how block add this to inventory